Search in sources :

Example 1 with InMemoryApprovalStore

use of org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore 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 InMemoryApprovalStore

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

the class AbstractIntegrationTests method clear.

private void clear(ApprovalStore approvalStore) throws Exception {
    if (approvalStore instanceof Advised) {
        Advised advised = (Advised) tokenStore;
        ApprovalStore target = (ApprovalStore) advised.getTargetSource().getTarget();
        clear(target);
        return;
    }
    if (approvalStore instanceof InMemoryApprovalStore) {
        ((InMemoryApprovalStore) approvalStore).clear();
    }
    if (approvalStore instanceof JdbcApprovalStore) {
        JdbcTemplate template = new JdbcTemplate(dataSource);
        template.execute("delete from oauth_approvals");
    }
}
Also used : InMemoryApprovalStore(org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore) Advised(org.springframework.aop.framework.Advised) InMemoryApprovalStore(org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore) ApprovalStore(org.springframework.security.oauth2.provider.approval.ApprovalStore) JdbcApprovalStore(org.springframework.security.oauth2.provider.approval.JdbcApprovalStore) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) JdbcApprovalStore(org.springframework.security.oauth2.provider.approval.JdbcApprovalStore)

Aggregations

InMemoryApprovalStore (org.springframework.security.oauth2.provider.approval.InMemoryApprovalStore)2 Test (org.junit.Test)1 Advised (org.springframework.aop.framework.Advised)1 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)1 ApprovalStore (org.springframework.security.oauth2.provider.approval.ApprovalStore)1 ApprovalStoreUserApprovalHandler (org.springframework.security.oauth2.provider.approval.ApprovalStoreUserApprovalHandler)1 JdbcApprovalStore (org.springframework.security.oauth2.provider.approval.JdbcApprovalStore)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1