Search in sources :

Example 6 with ConsumerCredentials

use of org.springframework.security.oauth.provider.ConsumerCredentials in project spring-security-oauth by spring-projects.

the class AccessTokenProcessingFilterTests method testCreateOAuthToken.

/**
	 * tests creating the oauth token.
	 */
@Test
public void testCreateOAuthToken() throws Exception {
    ConsumerCredentials creds = new ConsumerCredentials("key", "sig", "meth", "base", "tok");
    when(consumerDetails.getAuthorities()).thenReturn(new ArrayList<GrantedAuthority>());
    AccessTokenProcessingFilter filter = new AccessTokenProcessingFilter();
    filter.setTokenServices(tokenServices);
    when(tokenServices.createAccessToken("tok")).thenReturn(token);
    ConsumerAuthentication authentication = new ConsumerAuthentication(consumerDetails, creds);
    assertSame(token, filter.createOAuthToken(authentication));
}
Also used : ConsumerCredentials(org.springframework.security.oauth.provider.ConsumerCredentials) GrantedAuthority(org.springframework.security.core.GrantedAuthority) AccessTokenProcessingFilter(org.springframework.security.oauth.provider.filter.AccessTokenProcessingFilter) ConsumerAuthentication(org.springframework.security.oauth.provider.ConsumerAuthentication) Test(org.junit.Test)

Aggregations

ConsumerAuthentication (org.springframework.security.oauth.provider.ConsumerAuthentication)6 ConsumerCredentials (org.springframework.security.oauth.provider.ConsumerCredentials)6 Test (org.junit.Test)5 ConsumerDetails (org.springframework.security.oauth.provider.ConsumerDetails)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 GrantedAuthority (org.springframework.security.core.GrantedAuthority)4 FilterChain (javax.servlet.FilterChain)3 TreeMap (java.util.TreeMap)2 Authentication (org.springframework.security.core.Authentication)2 UnauthenticatedRequestTokenProcessingFilter (org.springframework.security.oauth.provider.filter.UnauthenticatedRequestTokenProcessingFilter)2 OAuthAccessProviderToken (org.springframework.security.oauth.provider.token.OAuthAccessProviderToken)2 OAuthProviderToken (org.springframework.security.oauth.provider.token.OAuthProviderToken)2 OAuthProviderTokenServices (org.springframework.security.oauth.provider.token.OAuthProviderTokenServices)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 AuthenticationException (org.springframework.security.core.AuthenticationException)1 OAuthSignatureMethod (org.springframework.security.oauth.common.signature.OAuthSignatureMethod)1 SignatureSecret (org.springframework.security.oauth.common.signature.SignatureSecret)1 InvalidOAuthParametersException (org.springframework.security.oauth.provider.InvalidOAuthParametersException)1