I have emplemented an token-based encryption with Jasper server. My question is how will I used this in my javascript to especially in iframe?
http://localhost:8080/jasperserver?pp=l4O3_onTsKh_vsBmfios-u72esQMepeawMD3QQkOE_ETDX1dvb3af4o5h4dXjpFyUOA2J5XrYSzreQ==
Above is the encrypted token.
Here's my java code which I compiled to .jar then added in WEB-INF/lib folder.
package com.jaspersoft.cipher; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.Base64; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import com.jaspersoft.jasperserver.api.common.crypto.CipherI; public class NewClass implements CipherI{ private SecretKeySpec secretKey; private byte[] key; String myKey="Mehul Katara"; public void setKey(String myKey) { MessageDigest sha = null; try { key = myKey.getBytes("UTF-8"); sha = MessageDigest.getInstance("SHA-1"); key = sha.digest(key); key = Arrays.copyOf(key, 16); secretKey = new SecretKeySpec(key, "RC4"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } public String decrypt(String strToDecrypt) { try { String secret=myKey; setKey(secret); Cipher cipher = Cipher.getInstance("RC4"); cipher.init(Cipher.DECRYPT_MODE, secretKey); return new String(cipher.doFinal(Base64.getUrlDecoder().decode(strToDecrypt.getBytes("UTF-8")))); } catch(Exception e) { System.out.println("Error while decrypting !" +e.toString()); System.out.println("Error while descrypt GetMEssage() : " +e.getMessage()); e.printStackTrace(); } return null; } public String encrypt(String strToEncrypt) { try { String secret=myKey; setKey(secret); Cipher cipher = Cipher.getInstance("RC4"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); return Base64.getUrlEncoder().encodeToString(cipher.doFinal(strToEncrypt.getBytes("UTF-8"))); } catch(Exception e) { System.out.println("Error while encrypting" +e.toString()); } return null; } }
I also modified the xml
<property name="tokenDecryptor"> <!--<bean class="com.jaspersoft.jasperserver.api.common.crypto.DevelopmentPlainTextNonCipher"/>--> <bean class="com.jaspersoft.cipher.NewClass"/> </property>
I'm very confused right now on how to login using the token. If I go directly to the link above it will just send me to login page. The documentation is not very detailed about it.
0 Answers:
No answers yet
hi,i'm facing the same issue .did you manage to resolve this issue ?