Search in sources :

Example 21 with SignedJwt

use of io.helidon.security.jwt.SignedJwt in project helidon by oracle.

the class JsonWebTokenImplTest method testGetClaim.

@Test
void testGetClaim() {
    Jwt jwt = Jwt.builder().issuer("issuer").subject("subject").addUserGroup("users").addUserGroup("admins").build();
    SignedJwt signed = SignedJwt.sign(jwt, Jwk.NONE_JWK);
    JsonWebTokenImpl impl = JsonWebTokenImpl.create(signed);
    assertAll(() -> testClaimType(impl, Claims.sub), () -> testClaimType(impl, Claims.groups), () -> testClaimType(impl, Claims.iss));
}
Also used : SignedJwt(io.helidon.security.jwt.SignedJwt) Jwt(io.helidon.security.jwt.Jwt) SignedJwt(io.helidon.security.jwt.SignedJwt) Test(org.junit.jupiter.api.Test)

Example 22 with SignedJwt

use of io.helidon.security.jwt.SignedJwt in project helidon by oracle.

the class JsonWebTokenImplTest method testUpnFromSub.

@Test
void testUpnFromSub() {
    String name = "me@example.org";
    Jwt jwt = Jwt.builder().subject(name).build();
    SignedJwt signed = SignedJwt.sign(jwt, Jwk.NONE_JWK);
    JsonWebTokenImpl impl = JsonWebTokenImpl.create(signed);
    assertThat(impl.getName(), is(name));
    assertThat(impl.getClaim(Claims.upn.name()), is(name));
}
Also used : SignedJwt(io.helidon.security.jwt.SignedJwt) Jwt(io.helidon.security.jwt.Jwt) SignedJwt(io.helidon.security.jwt.SignedJwt) Test(org.junit.jupiter.api.Test)

Aggregations

SignedJwt (io.helidon.security.jwt.SignedJwt)22 Jwt (io.helidon.security.jwt.Jwt)20 Test (org.junit.jupiter.api.Test)13 Principal (io.helidon.security.Principal)12 Subject (io.helidon.security.Subject)11 AuthenticationResponse (io.helidon.security.AuthenticationResponse)10 EndpointConfig (io.helidon.security.EndpointConfig)10 OutboundSecurityResponse (io.helidon.security.OutboundSecurityResponse)10 ProviderRequest (io.helidon.security.ProviderRequest)10 SecurityEnvironment (io.helidon.security.SecurityEnvironment)10 SecurityContext (io.helidon.security.SecurityContext)8 JwtException (io.helidon.security.jwt.JwtException)7 Instant (java.time.Instant)7 HashMap (java.util.HashMap)6 List (java.util.List)6 Locale (java.util.Locale)6 Jwk (io.helidon.security.jwt.jwk.Jwk)5 IdentityHashMap (java.util.IdentityHashMap)5 Errors (io.helidon.common.Errors)4 JwkKeys (io.helidon.security.jwt.jwk.JwkKeys)4