Examples of SimpleMethodInvocation


Examples of org.springframework.security.util.SimpleMethodInvocation

        when(delegate.getAttributes(toString, String.class)).thenReturn(attributes);
        sources.add(delegate);
        mds = new DelegatingMethodSecurityMetadataSource(sources);
        assertSame(sources, mds.getMethodSecurityMetadataSources());
        assertTrue(mds.getAllConfigAttributes().isEmpty());
        MethodInvocation mi = new SimpleMethodInvocation("", toString);
        assertSame(attributes, mds.getAttributes(mi));
        // Exercise the cached case
        assertSame(attributes, mds.getAttributes(mi));
        assertTrue(mds.getAttributes(new SimpleMethodInvocation(null, String.class.getMethod("length"))).isEmpty());
    }
View Full Code Here

Examples of org.springframework.security.util.SimpleMethodInvocation

        List<ConfigAttribute> attr2 = SecurityConfig.createList(new String[] {"GIVE_ME_SWAP2"});
        List<ConfigAttribute> attr3 = SecurityConfig.createList(new String[] {"GIVE_ME_SWAP3"});
        List<ConfigAttribute> attr2and3 = SecurityConfig.createList(new String[] {"GIVE_ME_SWAP2","GIVE_ME_SWAP3"});
        List<ConfigAttribute> attr4 = SecurityConfig.createList(new String[] {"NEVER_CAUSES_SWAP"});

        assertEquals("swap1", manager.decide(null, new SimpleMethodInvocation(), attr1, "content-before-swapping"));

        assertEquals("swap2", manager.decide(null, new SimpleMethodInvocation(), attr2, "content-before-swapping"));

        assertEquals("swap3", manager.decide(null, new SimpleMethodInvocation(), attr3, "content-before-swapping"));

        assertEquals("content-before-swapping",
            manager.decide(null, new SimpleMethodInvocation(), attr4, "content-before-swapping"));

        assertEquals("swap3", manager.decide(null, new SimpleMethodInvocation(), attr2and3, "content-before-swapping"));
    }
View Full Code Here

Examples of org.springframework.security.util.SimpleMethodInvocation

public class InterceptorStatusTokenTests {

    @Test
    public void testOperation() {
        List<ConfigAttribute> attr = SecurityConfig.createList("FOO");
        MethodInvocation mi = new SimpleMethodInvocation();
        SecurityContext ctx = SecurityContextHolder.createEmptyContext();
        InterceptorStatusToken token = new InterceptorStatusToken(ctx, true, attr, mi);

        assertTrue(token.isContextHolderRefreshRequired());
        assertEquals(attr, token.getAttributes());
View Full Code Here

Examples of org.springframework.security.util.SimpleMethodInvocation

        si.setRunAsManager(mock(RunAsManager.class));
        si.setAuthenticationManager(mock(AuthenticationManager.class));
        si.setAfterInvocationManager(mock(AfterInvocationManager.class));
        si.setAccessDecisionManager(mock(AccessDecisionManager.class));
        si.setSecurityMetadataSource(mock(SecurityMetadataSource.class));
        si.beforeInvocation(new SimpleMethodInvocation());
    }
View Full Code Here

Examples of org.springframework.security.util.SimpleMethodInvocation

    request.setApproved(true);
    OAuth2Request clientAuthentication = request.createOAuth2Request();
    Authentication userAuthentication = new UsernamePasswordAuthenticationToken("user", "pass",
        AuthorityUtils.createAuthorityList("ROLE_USER"));
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    MethodInvocation invocation = new SimpleMethodInvocation(this, ReflectionUtils.findMethod(getClass(),
        "testOauthClient"));
    EvaluationContext context = handler.createEvaluationContext(oAuth2Authentication, invocation);
    Expression expression = handler.getExpressionParser().parseExpression(
        "#oauth2.hasAnyScope('write') or #oauth2.isUser()");
    assertTrue((Boolean) expression.getValue(context));
View Full Code Here

Examples of org.springframework.security.util.SimpleMethodInvocation

        "client_credentials", "ROLE_CLIENT"));
    OAuth2Request clientAuthentication = request.createOAuth2Request();
    Authentication userAuthentication = new UsernamePasswordAuthenticationToken("user", "pass",
        AuthorityUtils.createAuthorityList("ROLE_USER"));
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    MethodInvocation invocation = new SimpleMethodInvocation(this, ReflectionUtils.findMethod(getClass(),
        "testOauthClient"));
    EvaluationContext context = handler.createEvaluationContext(oAuth2Authentication, invocation);
    Expression expression = handler.getExpressionParser().parseExpression("#oauth2.hasAnyScope('write')");
    expression.getValue(context);
  }
View Full Code Here

Examples of org.springframework.security.util.SimpleMethodInvocation

        .createOAuth2Request(request.getRequestParameters(), request.getClientId(), request.getAuthorities(),
            request.isApproved(), request.getScope(), request.getResourceIds(), request.getRedirectUri(),
            request.getResponseTypes(), request.getExtensions());

    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    MethodInvocation invocation = new SimpleMethodInvocation(this, ReflectionUtils.findMethod(getClass(),
        "testOauthClient"));
    EvaluationContext context = handler.createEvaluationContext(oAuth2Authentication, invocation);
    Expression expression = handler.getExpressionParser()
        .parseExpression("#oauth2.clientHasAnyRole('ROLE_CLIENT')");
    assertTrue((Boolean) expression.getValue(context));
View Full Code Here

Examples of org.springframework.security.util.SimpleMethodInvocation

    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false,
        Collections.singleton("read"));

    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    MethodInvocation invocation = new SimpleMethodInvocation(this, ReflectionUtils.findMethod(getClass(),
        "testOauthClient"));
    EvaluationContext context = handler.createEvaluationContext(oAuth2Authentication, invocation);
    Expression expression = handler.getExpressionParser().parseExpression("#oauth2.hasAnyScope('read','write')");
    assertTrue((Boolean) expression.getValue(context));
  }
View Full Code Here

Examples of org.springframework.security.util.SimpleMethodInvocation

    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false,
        Collections.singleton("ns_admin:read"));

    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    MethodInvocation invocation = new SimpleMethodInvocation(this, ReflectionUtils.findMethod(getClass(),
        "testOauthClient"));
    EvaluationContext context = handler.createEvaluationContext(oAuth2Authentication, invocation);
    Expression expression = handler.getExpressionParser().parseExpression(
        "#oauth2.hasScopeMatching('.*_admin:read')");
    assertTrue((Boolean) expression.getValue(context));
View Full Code Here

Examples of org.springframework.security.util.SimpleMethodInvocation

    OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false,
        Collections.singleton("ns_admin:read"));

    Authentication userAuthentication = null;
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
    MethodInvocation invocation = new SimpleMethodInvocation(this, ReflectionUtils.findMethod(getClass(),
        "testOauthClient"));
    EvaluationContext context = handler.createEvaluationContext(oAuth2Authentication, invocation);
    Expression expression = handler.getExpressionParser().parseExpression(
        "#oauth2.hasScopeMatching('.*_admin:write')");
    assertFalse((Boolean) expression.getValue(context));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.