Search in sources :

Example 1 with ApprovalStoreUserApprovalHandler

use of org.springframework.security.oauth2.provider.approval.ApprovalStoreUserApprovalHandler in project spring-security-oauth by spring-projects.

the class AuthorizationEndpointTests method testApprovalStoreAddsScopes.

@Test
public void testApprovalStoreAddsScopes() throws Exception {
    ApprovalStoreUserApprovalHandler userApprovalHandler = new ApprovalStoreUserApprovalHandler();
    userApprovalHandler.setApprovalStore(new InMemoryApprovalStore());
    endpoint.setUserApprovalHandler(userApprovalHandler);
    ModelAndView result = endpoint.authorize(model, getAuthorizationRequest("foo", null, null, "read", Collections.singleton("code")).getRequestParameters(), sessionStatus, principal);
    assertEquals("forward:/oauth/confirm_access", result.getViewName());
    assertTrue(result.getModel().containsKey("scopes"));
}
Also used : InMemoryApprovalStore(org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore) ModelAndView(org.springframework.web.servlet.ModelAndView) ApprovalStoreUserApprovalHandler(org.springframework.security.oauth2.provider.approval.ApprovalStoreUserApprovalHandler) Test(org.junit.Test)

Example 2 with ApprovalStoreUserApprovalHandler

use of org.springframework.security.oauth2.provider.approval.ApprovalStoreUserApprovalHandler in project spring-security-oauth by spring-projects.

the class AuthorizationServerEndpointsConfigurer method userApprovalHandler.

private UserApprovalHandler userApprovalHandler() {
    if (userApprovalHandler == null) {
        if (approvalStore() != null) {
            ApprovalStoreUserApprovalHandler handler = new ApprovalStoreUserApprovalHandler();
            handler.setApprovalStore(approvalStore());
            handler.setRequestFactory(requestFactory());
            handler.setClientDetailsService(clientDetailsService);
            this.userApprovalHandler = handler;
        } else if (tokenStore() != null) {
            TokenStoreUserApprovalHandler userApprovalHandler = new TokenStoreUserApprovalHandler();
            userApprovalHandler.setTokenStore(tokenStore());
            userApprovalHandler.setClientDetailsService(clientDetailsService());
            userApprovalHandler.setRequestFactory(requestFactory());
            this.userApprovalHandler = userApprovalHandler;
        } else {
            throw new IllegalStateException("Either a TokenStore or an ApprovalStore must be provided");
        }
    }
    return this.userApprovalHandler;
}
Also used : TokenStoreUserApprovalHandler(org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler) ApprovalStoreUserApprovalHandler(org.springframework.security.oauth2.provider.approval.ApprovalStoreUserApprovalHandler)

Aggregations

ApprovalStoreUserApprovalHandler (org.springframework.security.oauth2.provider.approval.ApprovalStoreUserApprovalHandler)2 Test (org.junit.Test)1 InMemoryApprovalStore (org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore)1 TokenStoreUserApprovalHandler (org.springframework.security.oauth2.provider.approval.TokenStoreUserApprovalHandler)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1