As of now we have interface to generate JWT. So we can implement specific class with this implementation. And with this feature lets do not remove flexibility of extending JWT generation logic. Also please note that JWT generation process is kind of heavy process which takes more CPU time. So we need to do small performance comparison as well. If this support our use case +1 for evaluate this.
Thanks, sanjeewa. On Wed, May 18, 2016 at 3:54 PM, Abimaran Kugathasan <[email protected]> wrote: > Hi All, > > > Shall we use Nimbus libraryto generate JWT in API Manager? > > Currently, we are generating the token without any standard libraries > which leads to errors like [2] and [3]. > > For the JIRA [3], currently we are having following code snippet to > create x5t header. > > byte[] digestInBytes = digestValue.digest(); > String publicCertThumbprint = hexify(digestInBytes); > String base64EncodedThumbPrint = Base64Utils.encode( > publicCertThumbprint.getBytes()); > > But, We have to use in the following way inorder to fix by ourself > > byte[] digestInBytes = digestValue.digest(); > String base64EncodedThumbPrint; > base64EncodedThumbPrint = Base64Utils.encode(digestInBytes); > base64EncodedThumbPrint = base64EncodedThumbPrint.split("=")[0]; // > Remove any trailing '='s > base64EncodedThumbPrint = base64EncodedThumbPrint.replace('+', '-'); // > 62nd char of encoding > base64EncodedThumbPrint = base64EncodedThumbPrint.replace('/', '_'); // > 63rd char of encoding > return base64EncodedThumbPrint; > > If we are using Nimbus, we can use JWSHeader.Builder [4] to generate JWT > Headers like > > JWSHeader header = new JWSHeader.Builder(JWSAlgorithm.HS256). > contentType("text/plain"). > customParam("exp", new Date().getTime()). > build(); > > We can add custom headers too. Appriciate your input on this. > > [1] : http://connect2id.com/products/nimbus-jose-jwt > [2] : https://wso2.org/jira/browse/APIMANAGER-4117 > [3] : https://wso2.org/jira/browse/APIMANAGER-2922 > [4] : > http://static.javadoc.io/com.nimbusds/nimbus-jose-jwt/4.5/com/nimbusds/jose/JWSHeader.Builder.html > > -- > Thanks > Abimaran Kugathasan > > Software Engineer | WSO2 Inc > Data & APIs Technologies Team > Mobile : +94 773922820 > > <http://stackoverflow.com/users/515034> > <http://lk.linkedin.com/in/abimaran> > <http://www.lkabimaran.blogspot.com/> <https://github.com/abimarank> > <https://twitter.com/abimaran> > > -- *Sanjeewa Malalgoda* WSO2 Inc. Mobile : +94713068779 <http://sanjeewamalalgoda.blogspot.com/>blog :http://sanjeewamalalgoda.blogspot.com/ <http://sanjeewamalalgoda.blogspot.com/>
_______________________________________________ Architecture mailing list [email protected] https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
