Skip to content

Commit e81ab98

Browse files
committed
Fixed docs
1 parent 1e6f687 commit e81ab98

File tree

2 files changed

+19
-25
lines changed

2 files changed

+19
-25
lines changed

src/main/java/com/auth0/jwt/JWTSigner.java

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
public 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
}

src/main/java/com/auth0/jwt/JWTVerifier.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
/**
2323
* JWT Java Implementation
24-
* <p/>
2524
* Adapted from https://bitbucket.org/lluisfaja/javajwt/wiki/Home
2625
* See <a href="https://bitbucket.org/lluisfaja/javajwt/src/3941d23e8e70f681d8a9a2584760e58e79e498f1/JavaJWT/src/com/unblau/javajwt/JWTVerifier.java">JWTVerifier.java</a>
2726
*/
@@ -35,7 +34,7 @@ public class JWTVerifier {
3534
private final ObjectMapper mapper;
3635

3736
private Map<String, String> algorithms;
38-
37+
3938
public JWTVerifier(String secret, String audience, String issuer) {
4039
this(secret.getBytes(Charset.forName("UTF-8")), audience, issuer);
4140
}
@@ -47,12 +46,12 @@ public JWTVerifier(String secret, String audience) {
4746
public JWTVerifier(String secret) {
4847
this(secret, null, null);
4948
}
50-
49+
5150
public JWTVerifier(byte[] secret, String audience, String issuer) {
5251
if (secret == null || secret.length == 0) {
5352
throw new IllegalArgumentException("Secret cannot be null or empty");
5453
}
55-
54+
5655
mapper = new ObjectMapper();
5756

5857
algorithms = new HashMap<String, String>();
@@ -177,4 +176,4 @@ JsonNode decodeAndParse(String b64String) throws IOException {
177176
JsonNode jwtHeader = mapper.readValue(jsonString, JsonNode.class);
178177
return jwtHeader;
179178
}
180-
}
179+
}

0 commit comments

Comments
 (0)