use of org.springframework.security.oauth2.core.DefaultOAuth2AuthenticatedPrincipal in project spring-security by spring-projects.
the class BearerTokenAuthenticationTests method toStringWhenAttributesContainsURLThenDoesNotFail.
// gh-6843
@Test
public void toStringWhenAttributesContainsURLThenDoesNotFail() throws Exception {
JSONObject attributes = new JSONObject(Collections.singletonMap("iss", new URL("https://idp.example.com")));
OAuth2AuthenticatedPrincipal principal = new DefaultOAuth2AuthenticatedPrincipal(attributes, null);
BearerTokenAuthentication token = new BearerTokenAuthentication(principal, this.token, null);
token.toString();
}
use of org.springframework.security.oauth2.core.DefaultOAuth2AuthenticatedPrincipal in project spring-security by spring-projects.
the class BearerTokenAuthenticationTests method setUp.
@BeforeEach
public void setUp() {
this.attributesMap.put(OAuth2TokenIntrospectionClaimNames.SUB, this.name);
this.attributesMap.put(OAuth2TokenIntrospectionClaimNames.CLIENT_ID, "client_id");
this.attributesMap.put(OAuth2TokenIntrospectionClaimNames.USERNAME, "username");
this.principal = new DefaultOAuth2AuthenticatedPrincipal(this.attributesMap, null);
}
use of org.springframework.security.oauth2.core.DefaultOAuth2AuthenticatedPrincipal in project spring-security by spring-projects.
the class BearerTokenAuthenticationTests method getNameWhenConfiguredInConstructorThenReturnsName.
@Test
public void getNameWhenConfiguredInConstructorThenReturnsName() {
OAuth2AuthenticatedPrincipal principal = new DefaultOAuth2AuthenticatedPrincipal(this.name, this.attributesMap, this.authorities);
BearerTokenAuthentication authenticated = new BearerTokenAuthentication(principal, this.token, this.authorities);
assertThat(authenticated.getName()).isEqualTo(this.name);
}
Aggregations