I faced the same issue. Unless you are using a CAS version where the double
base64 encoding issue is fixed, please use below method to extract json
payload from JWT tickets.
public static String getjsonPayloadFromJWT(String jwt) throws Exception{
Key key = new AesKey(signKey.getBytes(StandardCharsets.UTF_8));
JsonWebSignature jws = new JsonWebSignature();
try {
jws.setCompactSerialization(jwt);
} catch (JoseException e) {
e.printStackTrace();
throw new Exception();
}
jws.setKey(key);
boolean signatureVerified = false;
try {
signatureVerified = jws.verifySignature();
} catch (JoseException e) {
e.printStackTrace();
throw new Exception("JWT verification failed");
}
if(!signatureVerified)
throw new Exception("JWT verification failed");
// Bug in CAS. Double encoded payload
return new
String(Base64.decodeBase64(Base64.decodeBase64(jws.getEncodedPayload().getBytes(StandardCharsets.UTF_8))),
StandardCharsets.UTF_8);
}
Hope this helps.
- Nilesh Choudhary
On Tuesday, March 20, 2018 at 3:12:40 PM UTC+5:30, jojoyoung wrote:
>
> Run into the same issue, have you solved it?
>
> 在 2018年1月8日星期一 UTC+8下午10:29:19,Didier Capdevielle写道:
>>
>> from beyond the grave : happy new year !
>>
>>
>>
--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/a/apereo.org/d/msgid/cas-user/af669d2e-7b49-447c-893b-22417a619387%40apereo.org.