public static String encode ( JSONObject claims , String secret ) { String encodedHeader = getCommonHeader ( ) ; String encodedClaims = encodeJson ( claims ) ; String secureBits = new StringBuilder ( encodedHeader ) . append ( TOKEN_SEP ) . append ( encodedClaims ) . toString ( ) ; String sig = sign ( secret , secureBits ) ; return new StringBuilder ( secureBits ) . append ( TOKEN_SEP ) . append ( sig ) . toString ( ) ; }
Encode and sign a set of claims .