Forum Discussion

nickz's avatar
nickz
Guide
10 years ago

Could not encrypt buf: BouncyCodec encode failed

We use SSO in our product. It works well before we did some modifications to the code in the recent release.

 

We want to pass a new parameter to Lithium side when doing SSO cookie writing.

So we add a new parameter in the following way:

"

Map<STRING, STRING> chatParms = NEW HashMap<STRING, STRING>();
chatParms.put("profile.businessname", busName);
chatParms.put("profile.businessid", "" + busId);
chatParms.put("profile.industry", industryName);// this is the newly added parameter
chatParms.put("roles.grant", "DF_SSO_Role");

LithiumSSOClient.writeLithiumCookie(ssoId, login, loginUser.getEmail(), chatParms, request, response);

"

 

But we got an exception:

 

lithium.user.sso.SSOException: Could NOT ENCRYPT buf: lithium.util.io.EncodeException- BouncyCodec ENCODE failed
AT lithium.user.sso.LithiumSSOClient.encode(LithiumSSOClient.java:203)
AT lithium.user.sso.LithiumSSOClient.getLithiumCookieValue(LithiumSSOClient.java:437)
AT lithium.user.sso.LithiumSSOClient.getLithiumCookieValue(LithiumSSOClient.java:463)
AT lithium.user.sso.LithiumSSOClient.getLithiumCookie(LithiumSSOClient.java:532)
AT lithium.user.sso.LithiumSSOClient.writeLithiumCookie(LithiumSSOClient.java:598)

 

 

It seems that the exception was thrown in LithiumSSOClient.encode().

Can anyone help me out?

 

Thanks.

 

2 Replies

  • Sounds like a bug in the underlying SSO library.

     

    A couple of things you could check

    • Do you have an up-to-date version of the SSO client? (found here)
    • Are there any strange characters in the industry name that mgith be causing an issue? (You could try setting it to something innocous like "abc" and see if you still get the error).

     

    Failing that, I suspect you'll need to raise a support case.

  • JasonL's avatar
    JasonL
    Lithium Alumni (Retired)
    10 years ago

    hi nickz ,

    I don't think it is correct to call the class method directly like this:

    LithiumSSOClient.writeLithiumCookie(ssoId, login, loginUser.getEmail(), chatParms, request, response);

     Believe you have to getInstance(), which requires sso key, etc, and then invoke the writeLithiumCookie method of that instance. Something like this:

    LithiumSSOClient ssoClient=LithiumSSOClient.getInstance(ssoKey.getRaw(), clientId, clientDomain, serverId);
    ....
    ssoClient.writeLithiumCookie(...)

     Hope that helps ... otherwise, kindly log a Support ticket and provide details of your coding