Search in sources :

Example 36 with JwtClaims

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

the class JwtIssuerTest method longLivedATMP1000Jwt.

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

Example 37 with JwtClaims

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

the class JwtIssuerTest method AcRoleAccessControlWrong.

/**
 * The returned token contains scopes for access-control example
 * @throws Exception
 */
@Test
public void AcRoleAccessControlWrong() throws Exception {
    JwtClaims claims = ClaimsUtil.getTestClaims("stevehu", "CUSTOMER", "f7d42348-c647-4efb-a52d-4c5787421e72", Arrays.asList("account.r", "account.w"), "user");
    claims.setExpirationTimeMinutesInTheFuture(5256000);
    String jwt = JwtIssuer.getJwt(claims);
    System.out.println("***Long lived token Authorization code customer with  roles***: " + jwt);
}
Also used : JwtClaims(org.jose4j.jwt.JwtClaims) Test(org.junit.Test)

Example 38 with JwtClaims

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

the class JwtIssuerTest method petstoreBootstrap.

/**
 * This token is used to connect to the light-config-server with serviceId 0100 for testing with a service specific for a client.
 * @throws Exception
 */
@Test
public void petstoreBootstrap() throws Exception {
    JwtClaims claims = ClaimsUtil.getTestCcClaimsScopeService("f7d42348-c647-4efb-a52d-4c5787421e72", "portal.r portal.w", "com.networknt.petstore-3.0.1");
    claims.setExpirationTimeMinutesInTheFuture(5256000);
    String jwt = JwtIssuer.getJwt(claims);
    System.out.println("***Reference Long lived Bootstrap token for config server and controller: " + jwt);
}
Also used : JwtClaims(org.jose4j.jwt.JwtClaims) Test(org.junit.Test)

Example 39 with JwtClaims

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

the class JwtIssuerTest method AcGroupAccessControlWrong.

/**
 * The returned token contains scopes for access-control example
 * @throws Exception
 */
@Test
public void AcGroupAccessControlWrong() throws Exception {
    JwtClaims claims = ClaimsUtil.getTestClaimsGroup("stevehu", "EMPLOYEE", "f7d42348-c647-4efb-a52d-4c5787421e72", Arrays.asList("account.r", "account.w"), "backOffice");
    claims.setExpirationTimeMinutesInTheFuture(5256000);
    String jwt = JwtIssuer.getJwt(claims);
    System.out.println("***Long lived token Authorization code customer with  roles***: " + jwt);
}
Also used : JwtClaims(org.jose4j.jwt.JwtClaims) Test(org.junit.Test)

Example 40 with JwtClaims

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

the class JwtIssuerTest method longlivedLightPortalController.

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

Aggregations

JwtClaims (org.jose4j.jwt.JwtClaims)236 Test (org.junit.Test)90 JsonWebSignature (org.jose4j.jws.JsonWebSignature)62 InvalidJwtException (org.jose4j.jwt.consumer.InvalidJwtException)33 JwtConsumerBuilder (org.jose4j.jwt.consumer.JwtConsumerBuilder)31 JwtConsumer (org.jose4j.jwt.consumer.JwtConsumer)29 JoseException (org.jose4j.lang.JoseException)27 MalformedClaimException (org.jose4j.jwt.MalformedClaimException)24 Map (java.util.Map)22 JsonWebEncryption (org.jose4j.jwe.JsonWebEncryption)22 Test (org.junit.jupiter.api.Test)17 lombok.val (lombok.val)15 HashMap (java.util.HashMap)14 DefaultJWTCallerPrincipal (io.smallrye.jwt.auth.principal.DefaultJWTCallerPrincipal)13 JwtContext (org.jose4j.jwt.consumer.JwtContext)13 JsonWebToken (org.eclipse.microprofile.jwt.JsonWebToken)12 NumericDate (org.jose4j.jwt.NumericDate)12 JsonWebStructure (org.jose4j.jwx.JsonWebStructure)9 SecretKey (javax.crypto.SecretKey)7 KeyStoreException (java.security.KeyStoreException)6