2727 */
2828public class JWTSigner {
2929 private final String secret ;
30-
30+
3131 public JWTSigner (String secret ) {
3232 this .secret = secret ;
3333 }
@@ -36,7 +36,7 @@ public JWTSigner(String secret) {
3636 * Generate a JSON Web Token.
3737 * using the default algorithm HMAC SHA-256 ("HS256")
3838 * and no claims automatically set.
39- *
39+ *
4040 * @param claims A map of the JWT claims that form the payload. Registered claims
4141 * must be of appropriate Java datatype as following:
4242 * <ul>
@@ -47,9 +47,8 @@ public JWTSigner(String secret) {
4747 * All claims with a null value are left out the JWT.
4848 * Any claims set automatically as specified in
4949 * the "options" parameter override claims in this map.
50- *
51- * @param secret Key to use in signing. Used as-is without Base64 encoding.
52- *
50+ *
51+ *
5352 * @param options Allow choosing the signing algorithm, and automatic setting of some registered claims.
5453 */
5554 public String sign (Map <String , Object > claims , Options options ) {
@@ -72,15 +71,11 @@ public String sign(Map<String, Object> claims, Options options) {
7271 /**
7372 * Generate a JSON Web Token using the default algorithm HMAC SHA-256 ("HS256")
7473 * and no claims automatically set.
75- *
76- * @param secret Key to use in signing. Used as-is without Base64 encoding.
77- *
78- * For details, see the two parameter variant of this method.
7974 */
8075 public String sign (Map <String , Object > claims ) {
8176 return sign (claims , null );
8277 }
83-
78+
8479 /**
8580 * Generate the header part of a JSON web token.
8681 */
@@ -99,7 +94,7 @@ private String encodedHeader(Algorithm algorithm) throws UnsupportedEncodingExce
9994
10095 /**
10196 * Generate the JSON web token payload string from the claims.
102- * @param options
97+ * @param options
10398 */
10499 private String encodedPayload (Map <String , Object > _claims , Options options ) throws Exception {
105100 Map <String , Object > claims = new HashMap <String , Object >(_claims );
@@ -110,14 +105,14 @@ private String encodedPayload(Map<String, Object> _claims, Options options) thro
110105 enforceIntDate (claims , "nbf" );
111106 enforceIntDate (claims , "iat" );
112107 enforceString (claims , "jti" );
113-
108+
114109 if (options != null )
115110 processPayloadOptions (claims , options );
116111
117112 String payload = new ObjectMapper ().writeValueAsString (claims );
118113 return base64UrlEncode (payload .getBytes ("UTF-8" ));
119114 }
120-
115+
121116 private void processPayloadOptions (Map <String , Object > claims , Options options ) {
122117 long now = System .currentTimeMillis () / 1000l ;
123118 if (options .expirySeconds != null )
@@ -202,7 +197,7 @@ private String checkStringOrURI(Object value) {
202197 }
203198 return null ;
204199 }
205-
200+
206201 /**
207202 * Sign the header and payload
208203 */
@@ -269,7 +264,7 @@ public static class Options {
269264 private Integer notValidBeforeLeeway ;
270265 private boolean issuedAt ;
271266 private boolean jwtId ;
272-
267+
273268 public Algorithm getAlgorithm () {
274269 return algorithm ;
275270 }
@@ -280,8 +275,8 @@ public Options setAlgorithm(Algorithm algorithm) {
280275 this .algorithm = algorithm ;
281276 return this ;
282277 }
283-
284-
278+
279+
285280 public Integer getExpirySeconds () {
286281 return expirySeconds ;
287282 }
@@ -293,7 +288,7 @@ public Options setExpirySeconds(Integer expirySeconds) {
293288 this .expirySeconds = expirySeconds ;
294289 return this ;
295290 }
296-
291+
297292 public Integer getNotValidBeforeLeeway () {
298293 return notValidBeforeLeeway ;
299294 }
@@ -305,7 +300,7 @@ public Options setNotValidBeforeLeeway(Integer notValidBeforeLeeway) {
305300 this .notValidBeforeLeeway = notValidBeforeLeeway ;
306301 return this ;
307302 }
308-
303+
309304 public boolean isIssuedAt () {
310305 return issuedAt ;
311306 }
@@ -317,7 +312,7 @@ public Options setIssuedAt(boolean issuedAt) {
317312 this .issuedAt = issuedAt ;
318313 return this ;
319314 }
320-
315+
321316 public boolean isJwtId () {
322317 return jwtId ;
323318 }
0 commit comments