nicolas.veilleux Posted August 8, 2017 Share Posted August 8, 2017 Hello, i enable the login encryption in my jasper server, and i want use a dynamic key encryption ( http://community.jaspersoft.com/documentation/jasperreports-server-web-services-guide/v56/login-encryption).The rest service 'GetEncryptionKey' returns : { "maxdigits":"131", "e":"10001", "n":"9f8a2dc4baa260a5835fa33ef94c..."}[/code] But, how i build the public key with this ? I tried this code : byte[] publicBytes = Base64.decodeBase64(responseBody); X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicBytes); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); PublicKey publicKey = keyFactory.generatePublic(keySpec);[/code] but i have a java.security.InvalidKeyException: invalid key format. What is the solution ? Thx! Link to comment Share on other sites More sharing options...
nicolas.veilleux Posted August 9, 2017 Author Share Posted August 9, 2017 Ok, I use this code to encrypt password with bouncycastle 1.57: Security.insertProviderAt(new BouncyCastleProvider(), 1); RSAPublicKeySpec publicKeySpec = new RSAPublicKeySpec(new BigInteger(n, 16), new BigInteger(e, 16)); PublicKey publicKey = KeyFactory.getInstance("RSA").generatePublic(publicKeySpec); Cipher cipher = Cipher.getInstance("RSA/NONE/NoPadding", "BC"); cipher.init(Cipher.ENCRYPT_MODE, publicKey); byte[] cipherText = cipher.doFinal("joeuser".getBytes("UTF8")); return Base64.encodeBase64String(cipherText);[/code] After, i use this direct url and i have an error on login page :...standAlone=true&j_username=joeuser&j_password=gReYRml7YlMuEQ2... BUT, if i write the password in plain text, this url works : ...standAlone=true&j_username=joeuser&j_password=joeuser Encryption is enabled, so why the plain text version works, and not the encrypted version ? If i turn off encryption, the rest service returns Error: Key generation is off.Maybe i have to use somewhere the attribute 'maxdigits' to build public key ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now