Package org.springframework.security

Examples of org.springframework.security.TargetObject


    }

    private ContextPropagatingRemoteInvocation getRemoteInvocation() throws Exception {
        Class<TargetObject> clazz = TargetObject.class;
        Method method = clazz.getMethod("makeLowerCase", new Class[] {String.class});
        MethodInvocation mi = new SimpleMethodInvocation(new TargetObject(), method, "SOME_STRING");

        ContextPropagatingRemoteInvocationFactory factory = new ContextPropagatingRemoteInvocationFactory();

        return (ContextPropagatingRemoteInvocation) factory.createRemoteInvocation(mi);
    }
View Full Code Here


        SecurityContextHolder.clearContext();

        // The result from invoking the TargetObject should contain the
        // Authentication class delivered via the SecurityContextHolder
        assertEquals("some_string org.springframework.security.authentication.UsernamePasswordAuthenticationToken false",
            remoteInvocation.invoke(new TargetObject()));
    }
View Full Code Here

        SecurityContextHolder.clearContext(); // just to be explicit

        ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation();
        SecurityContextHolder.clearContext(); // unnecessary, but for explicitness

        assertEquals("some_string Authentication empty", remoteInvocation.invoke(new TargetObject()));
    }
View Full Code Here

        verify(aspectJCallback, never()).proceedWithObject();
    }

    @Test
    public void adapterHoldsCorrectData() throws Exception {
        TargetObject to = new TargetObject();
        Method m = ClassUtils.getMethodIfAvailable(TargetObject.class, "countLength", new Class[] {String.class});

        when(joinPoint.getTarget()).thenReturn(to);
        when(joinPoint.getArgs()).thenReturn(new Object[] {"Hi"});
        MethodInvocationAdapter mia = new MethodInvocationAdapter(joinPoint);
View Full Code Here

        interceptor.setSecurityMetadataSource(mds);
    }

    @Test
    public void allowsAccessUsingCreate() throws Exception {
        Object object = new TargetObject();
        final MethodInvocation mi = MethodInvocationUtils.create(object, "makeLowerCase", "foobar");

        MethodInvocationPrivilegeEvaluator mipe = new MethodInvocationPrivilegeEvaluator();
        when(mds.getAttributes(mi)).thenReturn(role);
View Full Code Here

        assertTrue(mipe.isAllowed(mi, token));
    }

    @Test
    public void declinesAccessUsingCreate() throws Exception {
        Object object = new TargetObject();
        final MethodInvocation mi = MethodInvocationUtils.create(object, "makeLowerCase", "foobar");
        MethodInvocationPrivilegeEvaluator mipe = new MethodInvocationPrivilegeEvaluator();
        mipe.setSecurityInterceptor(interceptor);
        when(mds.getAttributes(mi)).thenReturn(role);
        doThrow(new AccessDeniedException("rejected")).when(adm).decide(token, mi, role);
View Full Code Here

    public void tearDown() throws Exception {
        SecurityContextHolder.clearContext();
    }

    private void createTarget(boolean useMock) {
        realTarget = useMock ? mock(ITargetObject.class) : new TargetObject();
        ProxyFactory pf = new ProxyFactory(realTarget);
        pf.addAdvice(interceptor);
        advisedTarget = (ITargetObject) pf.getProxy();
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.TargetObject

Copyright © 2018 www.massapicom. 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.