use of org.springframework.security.oauth2.provider.OAuth2Request in project spring-security-oauth by spring-projects.
the class OAuth2RequestTests method testImplicitGrantType.
@Test
public void testImplicitGrantType() throws Exception {
parameters.put("response_type", "token");
OAuth2Request authorizationRequest = createFromParameters(parameters);
assertEquals("implicit", authorizationRequest.getGrantType());
}
use of org.springframework.security.oauth2.provider.OAuth2Request in project spring-security-oauth by spring-projects.
the class RedisTokenStoreTests method storeAccessTokenWithoutRefreshTokenRemoveAccessTokenVerifyTokenRemoved.
// gh-572
@Test
public void storeAccessTokenWithoutRefreshTokenRemoveAccessTokenVerifyTokenRemoved() {
OAuth2Request request = RequestTokenFactory.createOAuth2Request("clientId", false);
TestingAuthenticationToken authentication = new TestingAuthenticationToken("user", "password");
OAuth2AccessToken oauth2AccessToken = new DefaultOAuth2AccessToken("access-token-" + UUID.randomUUID());
OAuth2Authentication oauth2Authentication = new OAuth2Authentication(request, authentication);
tokenStore.storeAccessToken(oauth2AccessToken, oauth2Authentication);
tokenStore.removeAccessToken(oauth2AccessToken);
Collection<OAuth2AccessToken> oauth2AccessTokens = tokenStore.findTokensByClientId(request.getClientId());
assertTrue(oauth2AccessTokens.isEmpty());
}
use of org.springframework.security.oauth2.provider.OAuth2Request in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testAccessGrantedIfScopesPresent.
@Test
public void testAccessGrantedIfScopesPresent() throws Exception {
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("SCOPE_READ"))));
}
use of org.springframework.security.oauth2.provider.OAuth2Request in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testAccessGrantedIfScopesPresentWithPrefix.
@Test
public void testAccessGrantedIfScopesPresentWithPrefix() throws Exception {
voter.setScopePrefix("scope=");
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("scope=read"))));
}
use of org.springframework.security.oauth2.provider.OAuth2Request in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testExceptionThrownIfWrongScopesPresent.
@Test(expected = AccessDeniedException.class)
public void testExceptionThrownIfWrongScopesPresent() throws Exception {
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
assertEquals(AccessDecisionVoter.ACCESS_DENIED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("SCOPE_WRITE"))));
}
Aggregations