Search in sources :

Example 21 with JwtAuthenticationToken

use of org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken in project spring-security by spring-projects.

the class JwtAuthenticationTokenTests method getNameWhenConstructedWithNameThenReturnsProvidedName.

@Test
public void getNameWhenConstructedWithNameThenReturnsProvidedName() {
    Collection<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("test");
    Jwt jwt = builder().claim("claim", "value").build();
    JwtAuthenticationToken token = new JwtAuthenticationToken(jwt, authorities, "Hayden");
    assertThat(token.getName()).isEqualTo("Hayden");
}
Also used : Jwt(org.springframework.security.oauth2.jwt.Jwt) GrantedAuthority(org.springframework.security.core.GrantedAuthority) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)20 Jwt (org.springframework.security.oauth2.jwt.Jwt)16 JwtAuthenticationToken (org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken)11 GrantedAuthority (org.springframework.security.core.GrantedAuthority)6 SecurityContext (org.springframework.security.core.context.SecurityContext)6 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)3 BearerTokenAuthenticationToken (org.springframework.security.oauth2.server.resource.BearerTokenAuthenticationToken)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Authentication (org.springframework.security.core.Authentication)2 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)2 JwtDecoder (org.springframework.security.oauth2.jwt.JwtDecoder)2 NimbusJwtDecoder (org.springframework.security.oauth2.jwt.NimbusJwtDecoder)2 TestJwts (org.springframework.security.oauth2.jwt.TestJwts)2 HttpModuleAuthentication (com.evolveum.midpoint.authentication.impl.module.authentication.HttpModuleAuthentication)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)1 AfterEach (org.junit.jupiter.api.AfterEach)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1