use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.
the class JwtIssuerTest method GroupToRoleAccessControlRight.
/**
* The returned token contains groups User_API_Dev_R User_API_Dev_W for controller-group-role rule
* @throws Exception
*/
@Test
public void GroupToRoleAccessControlRight() throws Exception {
JwtClaims claims = ClaimsUtil.getTestClaimsGroup("stevehu", "EMPLOYEE", "f7d42348-c647-4efb-a52d-4c5787421e72", Arrays.asList("portal.r", "portal.w"), "User_API_Dev_R User_API_Dev_W");
claims.setExpirationTimeMinutesInTheFuture(5256000);
String jwt = JwtIssuer.getJwt(claims);
System.out.println("***Long lived token Authorization code customer with controller groups to roles ***: " + jwt);
}
use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.
the class JwtIssuerTest method longlivedLightPortalConfigServer.
@Test
public void longlivedLightPortalConfigServer() throws Exception {
JwtClaims claims = ClaimsUtil.getTestClaims("stevehu@gmail.com", "EMPLOYEE", "f7d42348-c647-4efb-a52d-4c5787421e73", Arrays.asList("portal.r", "portal.w"), "user CfgPltAdmin CfgPltRead CfgPltWrite");
claims.setExpirationTimeMinutesInTheFuture(5256000);
String jwt = JwtIssuer.getJwt(claims);
System.out.println("***Long lived token for portal config server ***: " + jwt);
}
use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.
the class JwtIssuerTest method longLivedAPIAJwt.
@Test
public void longLivedAPIAJwt() throws Exception {
JwtClaims claims = ClaimsUtil.getTestClaims("Steve", "EMPLOYEE", "f7d42348-c647-4efb-a52d-4c5787421e72", Arrays.asList("api_a.w", "api_b.w", "api_c.w", "api_d.w", "server.info.r"), "user");
claims.setExpirationTimeMinutesInTheFuture(5256000);
String jwt = JwtIssuer.getJwt(claims);
System.out.println("***LongLived APIA JWT***: " + jwt);
}
use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.
the class JwtIssuerTest method normalPetStoreJwt.
@Test
public void normalPetStoreJwt() throws Exception {
JwtClaims claims = ClaimsUtil.getTestClaims("steve", "EMPLOYEE", "f7d42348-c647-4efb-a52d-4c5787421e72", Arrays.asList("write:pets", "read:pets"), "user");
claims.setExpirationTimeMinutesInTheFuture(10);
String jwt = JwtIssuer.getJwt(claims);
System.out.println("***JWT***: " + jwt);
}
use of org.jose4j.jwt.JwtClaims in project light-4j by networknt.
the class JwtIssuer method getJwtClaimsWithExpiresIn.
/**
* Construct a default JwtClaims
* @param expiresIn expires in
* @return JwtClaims
*/
public static JwtClaims getJwtClaimsWithExpiresIn(int expiresIn) {
JwtClaims claims = new JwtClaims();
claims.setIssuer(jwtConfig.getIssuer());
claims.setAudience(jwtConfig.getAudience());
claims.setExpirationTimeMinutesInTheFuture(expiresIn / 60);
// a unique identifier for the token
claims.setGeneratedJwtId();
// when the token was issued/created (now)
claims.setIssuedAtToNow();
// time before which the token is not yet valid (2 minutes ago)
claims.setNotBeforeMinutesInThePast(2);
claims.setClaim("version", jwtConfig.getVersion());
return claims;
}
Aggregations