http://blog.csdn.net/mingzhnglei/article/details/51119836
Put a little example on your project.
Importcom.nimbusds.jose.JOSEException;ImportCom.nimbusds.jose.JWSAlgorithm;ImportCom.nimbusds.jose.JWSHeader;ImportCom.nimbusds.jose.JWSObject;ImportCom.nimbusds.jose.JWSSigner;ImportCom.nimbusds.jose.Payload;ImportCom.nimbusds.jose.crypto.MACSigner;ImportNet.minidev.json.JSONObject;/*** Created by Fly0116 on 2016/4/9 0009. * JSON Web Token example*/ Public classExample {StaticString duoshuo_shortname = "Test"; StaticString Duoshuo_secret = "3d990d2276917dfac04467df11fff26d"; Public Static voidmain (String [] args) {jsonobject userInfo=NewJsonobject (); Userinfo.put ("Short_name", duoshuo_shortname);//Required ItemsUserinfo.put ("User_key", "1");//Required ItemsUserinfo.put ("name", "website User A");//options availablePayload Payload=NewPayload (UserInfo); Jwsheader Header=NewJwsheader (jwsalgorithm.hs256); Header.setcontenttype ("JWT"); //Create JWS ObjectJwsobject Jwsobject =NewJwsobject (header, payload); //Create HMAC signerJwssigner signer =NewMacsigner (Duoshuo_secret.getbytes ()); Try{jwsobject.sign (signer); } Catch(joseexception e) {System.err.println ("Couldn ' t sign JWS object:" +e.getmessage ()); return; } //serialise JWS object to compact formatString token =jwsobject.serialize (); System.out.println ("Serialised JWS object:" +token); //example output is eyjhbgcioijiuzi1niisimn0esi6imp3dcj9.eyj1c2vyx2tlesi6ijeilcjuyw1lijoi572r56uz55so5oi3qsisinnob3j0x25hbwuioij0z Xn0in0.nxkdxwxthzfkyfl_k_-p6mfm5cpofppvfdijrjeq14i }}
Eight comics understanding design of single sign-on system using JSON Web token
http://blog.leapoahead.com/2015/09/07/user-authentication-with-jwt/
JSON Web Token-securely pass information between Web Apps
http://blog.leapoahead.com/2015/09/06/understanding-jwt/
Use JWT token (JSON Web token) in Android--java