Search in sources :

Example 1 with AccessTokenProcessingFilter

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

the class AccessTokenProcessingFilterTests method testOnNewTimestamp.

/**
	 * tests the logic on a new timestamp.
	 */
@Test
public void testOnNewTimestamp() throws Exception {
    try {
        new AccessTokenProcessingFilter().onNewTimestamp();
        fail();
    } catch (InvalidOAuthParametersException e) {
    // fall through
    }
}
Also used : InvalidOAuthParametersException(org.springframework.security.oauth.provider.InvalidOAuthParametersException) AccessTokenProcessingFilter(org.springframework.security.oauth.provider.filter.AccessTokenProcessingFilter) Test(org.junit.Test)

Example 2 with AccessTokenProcessingFilter

use of org.springframework.security.oauth.provider.filter.AccessTokenProcessingFilter 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

Test (org.junit.Test)2 AccessTokenProcessingFilter (org.springframework.security.oauth.provider.filter.AccessTokenProcessingFilter)2 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1 ConsumerAuthentication (org.springframework.security.oauth.provider.ConsumerAuthentication)1 ConsumerCredentials (org.springframework.security.oauth.provider.ConsumerCredentials)1 InvalidOAuthParametersException (org.springframework.security.oauth.provider.InvalidOAuthParametersException)1