Search in sources :

Example 1 with JwsHeader

use of org.forgerock.json.jose.jws.JwsHeader in project OpenAM by OpenRock.

the class OAuth2JwtTest method notBeforeTimeSetInPastJWTShouldBeValid.

@Test
public void notBeforeTimeSetInPastJWTShouldBeValid() {
    JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap());
    JwtClaimsSet claims = getJwtClaimsSet(VALID_NOT_BEFORE_TIME, VALID_EXPIRATION_TIME);
    SigningHandler handler = new NOPSigningHandler();
    OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler);
    assertTrue(oAuth2Jwt.isValid(handler));
}
Also used : JwtClaimsSet(org.forgerock.json.jose.jwt.JwtClaimsSet) JwsHeader(org.forgerock.json.jose.jws.JwsHeader) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) SigningHandler(org.forgerock.json.jose.jws.handlers.SigningHandler) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) Test(org.testng.annotations.Test)

Example 2 with JwsHeader

use of org.forgerock.json.jose.jws.JwsHeader in project OpenAM by OpenRock.

the class OAuth2JwtTest method notBeforeTimeSetAsNowShouldBeValid.

@Test
public void notBeforeTimeSetAsNowShouldBeValid() {
    //The skew set in oAuth2Jwt is significant in this test
    JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap());
    JwtClaimsSet claims = getJwtClaimsSet(0, VALID_EXPIRATION_TIME);
    SigningHandler handler = new NOPSigningHandler();
    OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler);
    assertTrue(oAuth2Jwt.isValid(handler));
}
Also used : JwtClaimsSet(org.forgerock.json.jose.jwt.JwtClaimsSet) JwsHeader(org.forgerock.json.jose.jws.JwsHeader) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) SigningHandler(org.forgerock.json.jose.jws.handlers.SigningHandler) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) Test(org.testng.annotations.Test)

Example 3 with JwsHeader

use of org.forgerock.json.jose.jws.JwsHeader in project OpenAM by OpenRock.

the class OAuth2JwtTest method notBeforeTimeSetInFutureJWTShouldBeInvalid.

@Test
public void notBeforeTimeSetInFutureJWTShouldBeInvalid() {
    JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap());
    JwtClaimsSet claims = getJwtClaimsSet(INVALID_NOT_BEFORE_TIME, VALID_EXPIRATION_TIME);
    SigningHandler handler = new NOPSigningHandler();
    OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler);
    assertTrue(!oAuth2Jwt.isValid(handler));
}
Also used : JwtClaimsSet(org.forgerock.json.jose.jwt.JwtClaimsSet) JwsHeader(org.forgerock.json.jose.jws.JwsHeader) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) SigningHandler(org.forgerock.json.jose.jws.handlers.SigningHandler) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) Test(org.testng.annotations.Test)

Example 4 with JwsHeader

use of org.forgerock.json.jose.jws.JwsHeader in project OpenAM by OpenRock.

the class OAuth2JwtTest method expirationTimeSetInFutureJWTShouldBeValid.

@Test
public void expirationTimeSetInFutureJWTShouldBeValid() {
    JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap());
    JwtClaimsSet claims = getJwtClaimsSet(VALID_NOT_BEFORE_TIME, VALID_EXPIRATION_TIME);
    SigningHandler handler = new NOPSigningHandler();
    OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler);
    assertTrue(oAuth2Jwt.isValid(handler));
}
Also used : JwtClaimsSet(org.forgerock.json.jose.jwt.JwtClaimsSet) JwsHeader(org.forgerock.json.jose.jws.JwsHeader) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) SigningHandler(org.forgerock.json.jose.jws.handlers.SigningHandler) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) Test(org.testng.annotations.Test)

Example 5 with JwsHeader

use of org.forgerock.json.jose.jws.JwsHeader in project OpenAM by OpenRock.

the class OAuth2JwtTest method expirationTimeSetAsNowJWTShouldBeValid.

@Test
public void expirationTimeSetAsNowJWTShouldBeValid() {
    //The skew set in oAuth2Jwt is significant in this test
    JwsHeader header = new JwsHeader(Collections.<String, Object>emptyMap());
    JwtClaimsSet claims = getJwtClaimsSet(VALID_NOT_BEFORE_TIME, 0);
    SigningHandler handler = new NOPSigningHandler();
    OAuth2Jwt oAuth2Jwt = getOAuth2Jwt(header, claims, handler);
    assertTrue(oAuth2Jwt.isValid(handler));
}
Also used : JwtClaimsSet(org.forgerock.json.jose.jwt.JwtClaimsSet) JwsHeader(org.forgerock.json.jose.jws.JwsHeader) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) SigningHandler(org.forgerock.json.jose.jws.handlers.SigningHandler) NOPSigningHandler(org.forgerock.json.jose.jws.handlers.NOPSigningHandler) Test(org.testng.annotations.Test)

Aggregations

JwsHeader (org.forgerock.json.jose.jws.JwsHeader)7 NOPSigningHandler (org.forgerock.json.jose.jws.handlers.NOPSigningHandler)7 SigningHandler (org.forgerock.json.jose.jws.handlers.SigningHandler)7 JwtClaimsSet (org.forgerock.json.jose.jwt.JwtClaimsSet)7 Test (org.testng.annotations.Test)6 SignedJwt (org.forgerock.json.jose.jws.SignedJwt)1