Search in sources :

Example 51 with JwtClaims

use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.

the class JwtIssuerTest method longLivedProductAccessJwt.

@Test
public void longLivedProductAccessJwt() throws Exception {
    JwtClaims claims = ClaimsUtil.getTestClaims("steve", "EMPLOYEE", "f7d42348-c647-4efb-a52d-4c5787421e72", Arrays.asList("party.product.read", "server.info.r"));
    claims.setExpirationTimeMinutesInTheFuture(5256000);
    String jwt = JwtIssuer.getJwt(claims);
    System.out.println("***LongLived product access JWT***: " + jwt);
}
Also used : JwtClaims(org.jose4j.jwt.JwtClaims) Test(org.junit.Test)

Example 52 with JwtClaims

use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.

the class JwtIssuerTest method longLivedCodegenJwt.

@Test
public void longLivedCodegenJwt() throws Exception {
    JwtClaims claims = ClaimsUtil.getTestClaims("steve", "EMPLOYEE", "f7d42348-c647-4efb-a52d-4c5787421e72", Arrays.asList("codegen.r", "codegen.w", "server.info.r"));
    claims.setExpirationTimeMinutesInTheFuture(5256000);
    String jwt = JwtIssuer.getJwt(claims);
    System.out.println("***LongLived Codegen JWT***: " + jwt);
}
Also used : JwtClaims(org.jose4j.jwt.JwtClaims) Test(org.junit.Test)

Example 53 with JwtClaims

use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.

the class JwtIssuerTest method longLivedReferenceJwt.

@Test
public void longLivedReferenceJwt() throws Exception {
    Map<String, String> custom = new HashMap<>();
    custom.put("consumer_application_id", "361");
    custom.put("request_transit", "67");
    JwtClaims claims = ClaimsUtil.getCustomClaims("steve", "EMPLOYEE", "f7d42348-c647-4efb-a52d-4c5787421e72", Arrays.asList("party.util.reference.read", "server.info.r"), custom);
    claims.setExpirationTimeMinutesInTheFuture(5256000);
    String jwt = JwtIssuer.getJwt(claims);
    System.out.println("***LongLived reference JWT***: " + jwt);
}
Also used : HashMap(java.util.HashMap) JwtClaims(org.jose4j.jwt.JwtClaims) Test(org.junit.Test)

Example 54 with JwtClaims

use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.

the class JwtIssuerTest method longlivedTokenizationJwt73.

@Test
public void longlivedTokenizationJwt73() throws Exception {
    JwtClaims claims = ClaimsUtil.getTestClaims("steve", "EMPLOYEE", "f7d42348-c647-4efb-a52d-4c5787421e73", Arrays.asList("token.r", "token.w"));
    claims.setExpirationTimeMinutesInTheFuture(5256000);
    String jwt = JwtIssuer.getJwt(claims);
    System.out.println("***Long lived token for tokenizaiton***: " + jwt);
}
Also used : JwtClaims(org.jose4j.jwt.JwtClaims) Test(org.junit.Test)

Example 55 with JwtClaims

use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.

the class ClaimsUtil method getTestClaims.

public static JwtClaims getTestClaims(String userId, String userType, String clientId, List<String> scope) {
    JwtClaims claims = JwtIssuer.getDefaultJwtClaims();
    claims.setClaim("user_id", userId);
    claims.setClaim("user_type", userType);
    claims.setClaim("client_id", clientId);
    // multi-valued claims work too and will end up as a JSON array
    if (scope != null)
        claims.setStringListClaim("scope", scope);
    return claims;
}
Also used : JwtClaims(org.jose4j.jwt.JwtClaims)

Aggregations

JwtClaims (org.jose4j.jwt.JwtClaims)72 Test (org.junit.Test)19 lombok.val (lombok.val)15 JwtConsumer (org.jose4j.jwt.consumer.JwtConsumer)15 MalformedClaimException (org.jose4j.jwt.MalformedClaimException)14 JwtConsumerBuilder (org.jose4j.jwt.consumer.JwtConsumerBuilder)14 InvalidJwtException (org.jose4j.jwt.consumer.InvalidJwtException)13 Map (java.util.Map)11 JsonWebSignature (org.jose4j.jws.JsonWebSignature)10 NumericDate (org.jose4j.jwt.NumericDate)8 JwtContext (org.jose4j.jwt.consumer.JwtContext)7 JoseException (org.jose4j.lang.JoseException)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 OidcRegisteredService (org.apereo.cas.services.OidcRegisteredService)5 JsonWebStructure (org.jose4j.jwx.JsonWebStructure)5 Test (org.junit.jupiter.api.Test)4 UserProfile (org.pac4j.core.profile.UserProfile)4 Objects (java.util.Objects)3 Optional (java.util.Optional)3