Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept Array type on verification and creation. #123

Merged
merged 6 commits into from
Jan 4, 2017

Conversation

lbalmaceda
Copy link
Contributor

@lbalmaceda lbalmaceda commented Dec 14, 2016

Now we can specify Arrays of type String or Integer for creation/verification of JWTs.

  1. Get a Claim as a custom class:
Claim claim = jwt.getClaim("user");
UserProfile user = claim.as(UserProfile.class);
  1. Create a token with an Array Claim:
String jwt = JWTCreator.init()
                .withArrayClaim("name", new String[]{"a", "b", "c"})
                .sign(Algorithm.HMAC256("secret"));
  1. Verify that a token contains an Array Claim with at least specific items:
DecodedJWT jwt = JWTVerifier.init(Algorithm.HMAC256("secret"))
                .withArrayClaim("name", "a", "b")
                .build()
                .verify(token);

Note that in this example, UserProfile class must have a no-args public constructor for deserialization to work.

@lbalmaceda
Copy link
Contributor Author

Adds the features discussed in #117

@lbalmaceda lbalmaceda force-pushed the feat-accept-more-types branch 2 times, most recently from 3842dc5 to 4b07586 Compare December 14, 2016 21:06
@lbalmaceda lbalmaceda changed the title Accept all class types in verification and creation. Accept Array type on verification and creation. Dec 16, 2016
@hzalaz hzalaz added this to the 3.1.0 milestone Jan 4, 2017
@hzalaz hzalaz merged commit 9148ca2 into master Jan 4, 2017
@hzalaz hzalaz deleted the feat-accept-more-types branch January 4, 2017 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants