Search in sources :

Example 6 with ResourceOwnerPasswordTokenGranter

use of org.springframework.security.oauth2.provider.password.ResourceOwnerPasswordTokenGranter in project spring-security-oauth by spring-projects.

the class ResourceOwnerPasswordTokenGranterTests method testPasswordRemoved.

@Test
public void testPasswordRemoved() {
    ResourceOwnerPasswordTokenGranter granter = new ResourceOwnerPasswordTokenGranter(authenticationManager, providerTokenServices, clientDetailsService, requestFactory);
    OAuth2AccessToken token = granter.grant("password", tokenRequest);
    OAuth2Authentication authentication = providerTokenServices.loadAuthentication(token.getValue());
    assertNotNull(authentication.getOAuth2Request().getRequestParameters().get("username"));
    assertNull(authentication.getOAuth2Request().getRequestParameters().get("password"));
}
Also used : OAuth2AccessToken(org.springframework.security.oauth2.common.OAuth2AccessToken) OAuth2Authentication(org.springframework.security.oauth2.provider.OAuth2Authentication) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)5 AuthenticationManager (org.springframework.security.authentication.AuthenticationManager)3 Authentication (org.springframework.security.core.Authentication)3 AuthenticationException (org.springframework.security.core.AuthenticationException)3 OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)1 LockedException (org.springframework.security.authentication.LockedException)1 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)1 ClientDetailsService (org.springframework.security.oauth2.provider.ClientDetailsService)1 CompositeTokenGranter (org.springframework.security.oauth2.provider.CompositeTokenGranter)1 OAuth2RequestFactory (org.springframework.security.oauth2.provider.OAuth2RequestFactory)1 TokenGranter (org.springframework.security.oauth2.provider.TokenGranter)1 ClientCredentialsTokenGranter (org.springframework.security.oauth2.provider.client.ClientCredentialsTokenGranter)1 InMemoryClientDetailsService (org.springframework.security.oauth2.provider.client.InMemoryClientDetailsService)1 AuthorizationCodeServices (org.springframework.security.oauth2.provider.code.AuthorizationCodeServices)1 AuthorizationCodeTokenGranter (org.springframework.security.oauth2.provider.code.AuthorizationCodeTokenGranter)1