Don't need to provide nonstandard claims · GJWT/javaOIDCMsg@709ca99 · GitHub
Skip to content

Commit 709ca99

Browse files
author
Justin Dahmubed
committed
Don't need to provide nonstandard claims
1 parent 705efd7 commit 709ca99

7 files changed

Lines changed: 12 additions & 49 deletions

File tree

lib/src/main/java/com/auth0/jwt/creators/ExtendedJwtCreator.java

Lines changed: 1 addition & 3 deletions

lib/src/main/java/com/auth0/jwt/creators/FbJwtCreator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.auth0.jwt;
1+
package com.auth0.jwt.creators;
22

33
import com.auth0.jwt.algorithms.Algorithm;
44
import com.auth0.jwt.exceptions.JWTCreationException;
@@ -24,7 +24,6 @@ public FbJwtCreator() {
2424
addedClaims = new HashMap<String, Boolean>() {{
2525
put("UserId", false);
2626
put("AppId", false);
27-
put("Exp", false);
2827
put("Iat", false);
2928
}};
3029
publicClaims = new HashSet<String>() {{
@@ -53,7 +52,6 @@ public FbJwtCreator withIat(Date iat) {
5352
*/
5453
public FbJwtCreator withExp(Date exp) {
5554
jwt.withExpiresAt(exp);
56-
addedClaims.put("Exp", true);
5755
return this;
5856
}
5957

lib/src/main/java/com/auth0/jwt/creators/GoogleJwtCreator.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.auth0.jwt;
1+
package com.auth0.jwt.creators;
22

33
import com.auth0.jwt.algorithms.Algorithm;
44
import com.auth0.jwt.exceptions.JWTCreationException;
@@ -27,9 +27,7 @@ public GoogleJwtCreator() {
2727
put("Picture", false);
2828
put("Issuer", false);
2929
put("Subject", false);
30-
put("Audience", false);
3130
put("Iat", false);
32-
put("Exp", false);
3331
}};
3432
publicClaims = new HashSet<String>() {{
3533
add(PublicClaims.ISSUER);
@@ -49,7 +47,7 @@ public GoogleJwtCreator() {
4947
* @param name the Name value.
5048
* @return this same Builder instance.
5149
*/
52-
protected GoogleJwtCreator withName(String name) {
50+
public GoogleJwtCreator withName(String name) {
5351
jwt.withNonStandardClaim("name", name);
5452
addedClaims.put("Name", true);
5553
return this;
@@ -61,7 +59,7 @@ protected GoogleJwtCreator withName(String name) {
6159
* @param email the Email value.
6260
* @return this same Builder instance.
6361
*/
64-
GoogleJwtCreator withEmail(String email) {
62+
public GoogleJwtCreator withEmail(String email) {
6563
jwt.withNonStandardClaim("email", email);
6664
addedClaims.put("Email", true);
6765
return this;
@@ -73,7 +71,7 @@ GoogleJwtCreator withEmail(String email) {
7371
* @param picture the Picture value.
7472
* @return this same Builder instance.
7573
*/
76-
protected GoogleJwtCreator withPicture(String picture) {
74+
public GoogleJwtCreator withPicture(String picture) {
7775
jwt.withNonStandardClaim("picture", picture);
7876
addedClaims.put("Picture", true);
7977
return this;
@@ -114,7 +112,6 @@ public GoogleJwtCreator withSubject(String... subject) {
114112
*/
115113
public GoogleJwtCreator withAudience(String... audience) {
116114
jwt.withAudience(audience);
117-
addedClaims.put("Audience", true);
118115
return this;
119116
}
120117

@@ -138,7 +135,6 @@ public GoogleJwtCreator withIat(Date iat) {
138135
*/
139136
public GoogleJwtCreator withExp(Date exp) {
140137
jwt.withExpiresAt(exp);
141-
addedClaims.put("Exp", true);
142138
return this;
143139
}
144140

lib/src/main/java/com/auth0/jwt/creators/ImplicitJwtCreator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.auth0.jwt;
1+
package com.auth0.jwt.creators;
22

33
import com.auth0.jwt.algorithms.Algorithm;
44
import com.auth0.jwt.exceptions.JWTCreationException;
@@ -24,7 +24,6 @@ public ImplicitJwtCreator() {
2424
addedClaims = new HashMap<String, Boolean>() {{
2525
put("Issuer", false);
2626
put("Subject", false);
27-
put("Audience", false);
2827
put("Iat", false);
2928
}};
3029
publicClaims = new HashSet<String>() {{
@@ -70,7 +69,6 @@ public ImplicitJwtCreator withSubject(String... subject) {
7069
*/
7170
public ImplicitJwtCreator withAudience(String... audience) {
7271
jwt.withAudience(audience);
73-
addedClaims.put("Audience", true);
7472
return this;
7573
}
7674

lib/src/main/java/com/auth0/jwt/creators/JWTCreator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.auth0.jwt;
1+
package com.auth0.jwt.creators;
22

33
import com.auth0.jwt.algorithms.Algorithm;
44
import com.auth0.jwt.exceptions.JWTCreationException;
@@ -48,7 +48,7 @@ private JWTCreator(Algorithm algorithm, Map<String, Object> headerClaims, Map<St
4848
*
4949
* @return a JWTCreator.Builder instance to configure.
5050
*/
51-
static JWTCreator.Builder init() {
51+
public static JWTCreator.Builder init() {
5252
return new Builder();
5353
}
5454

lib/src/main/java/com/auth0/jwt/creators/ScopedJwtCreator.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.auth0.jwt;
1+
package com.auth0.jwt.creators;
22

33
import com.auth0.jwt.algorithms.Algorithm;
44
import com.auth0.jwt.exceptions.JWTCreationException;
@@ -25,9 +25,7 @@ public ScopedJwtCreator() {
2525
put("Scope", false);
2626
put("Issuer", false);
2727
put("Subject", false);
28-
put("Audience", false);
2928
put("Iat", false);
30-
put("Exp", false);
3129
}};
3230
publicClaims = new HashSet<String>() {{
3331
add(PublicClaims.ISSUER);
@@ -88,7 +86,6 @@ public ScopedJwtCreator withSubject(String... subject) {
8886
*/
8987
public ScopedJwtCreator withAudience(String... audience) {
9088
jwt.withAudience(audience);
91-
addedClaims.put("Audience", true);
9289
return this;
9390
}
9491

@@ -112,7 +109,6 @@ public ScopedJwtCreator withIat(Date iat) {
112109
*/
113110
public ScopedJwtCreator withExp(Date exp) {
114111
jwt.withExpiresAt(exp);
115-
addedClaims.put("Exp", true);
116112
return this;
117113
}
118114

lib/src/test/java/com/auth0/jwt/creators/ExtendedJwtCreatorTest.java

Lines changed: 2 additions & 25 deletions

0 commit comments

Comments
 (0)