Skip to content

Commit

Permalink
Merge pull request #6708 from kdnakt/fix-doc-jwt
Browse files Browse the repository at this point in the history
doc: fix security-jwt.adoc according to quickstart project
  • Loading branch information
gsmet authored Jan 22, 2020
2 parents eab6760 + b94c314 commit b53125d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions docs/src/main/asciidoc/security-jwt.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ import java.security.Principal;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
Expand Down Expand Up @@ -687,8 +688,8 @@ import java.util.ArrayList;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.json.JsonString;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
Expand All @@ -703,12 +704,12 @@ import org.eclipse.microprofile.jwt.JsonWebToken;
/**
* Version 3 of the TokenSecuredResource
*/
@Path("/secured")
@RequestScoped
@Path("/secured")
@RequestScoped
public class TokenSecuredResourceV3 {
@Inject
JsonWebToken jwt;
@Inject
JsonWebToken jwt;
...
Expand Down Expand Up @@ -781,7 +782,9 @@ import java.util.Optional;
import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.json.JsonString;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
Expand All @@ -804,7 +807,7 @@ public class TokenSecuredResource {
JsonWebToken jwt;
@Inject // <1>
@Claim(standard = Claims.birthdate) // <2>
Optional<String> birthdate; // <3>
Optional<JsonString> birthdate; // <3>
...
Expand All @@ -818,7 +821,7 @@ public class TokenSecuredResource {
// If the JWT contains a birthdate claim, use the day of the month as a pick
if (birthdate.isPresent()) { // <4>
String bdayString = birthdate.get(); <5>
String bdayString = birthdate.get().getString(); <5>
LocalDate bday = LocalDate.parse(bdayString);
numbers.add(bday.getDayOfMonth());
remaining --;
Expand All @@ -835,7 +838,7 @@ public class TokenSecuredResource {
----
<1> We use CDI `@Inject` along with...
<2> an {mp-jwt} `@Claim(standard = Claims.birthdate)` qualifier to inject the `birthdate` claim directly as
<3> an `Optional<String>` value.
<3> an `Optional<JsonString>` value.
<4> Now we check whether the injected `birthdate` field is present
<5> and if it is, get its value.

Expand Down

0 comments on commit b53125d

Please sign in to comment.