Package org.apache.ace.authentication.api

Examples of org.apache.ace.authentication.api.AuthenticationProcessor


        int size = processors.size();
       
        List<AuthenticationProcessor> result = new ArrayList<AuthenticationProcessor>(size);
        for (int i = 0; i < size; i++) {
            AuthenticationProcessor authenticationProcessor = processors.get(i).getAuthenticationProcessor();
            // Can be null if it is already GC'd for some reason...
            if ((authenticationProcessor != null) && authenticationProcessor.canHandle(context)) {
                result.add(authenticationProcessor);
            }
        }

        return result;
View Full Code Here


     */
    @Test(groups = { UNIT })
    public void testAuthenticateFailsWithSingleAuthProcessorAndWrongContext() {
        AuthenticationServiceImpl authService = createAuthenticationService();
       
        AuthenticationProcessor authProc = mock(AuthenticationProcessor.class);
        when(authProc.canHandle(anyString())).thenReturn(Boolean.TRUE);

        registerAuthProcessor(authService, authProc);

        assert authService.authenticate("foo", "bar") == null;
    }
View Full Code Here

        Date now = new Date();
       
        User user1 = mock(User.class);
        User user2 = mock(User.class);

        AuthenticationProcessor authProc1 = mock(AuthenticationProcessor.class);
        when(authProc1.canHandle(any())).thenAnswer(new Answer<Boolean>() {
            public Boolean answer(InvocationOnMock invocation) throws Throwable {
                Object[] args = invocation.getArguments();
                return (args.length == 1 && args[0] instanceof Date);
            }
        });
        when(authProc1.authenticate(Mockito.<UserAdmin>any(), eq(now))).thenReturn(user1);

        AuthenticationProcessor authProc2 = mock(AuthenticationProcessor.class);
        when(authProc2.canHandle(anyString())).thenAnswer(new Answer<Boolean>() {
            public Boolean answer(InvocationOnMock invocation) throws Throwable {
                Object[] args = invocation.getArguments();
                return (args.length == 1 && args[0] instanceof String);
            }
        });
        when(authProc2.authenticate(Mockito.<UserAdmin>any(), eq("foo"))).thenReturn(user2);

        AuthenticationServiceImpl authService = createAuthenticationService();

        registerAuthProcessor(authService, authProc1);
        registerAuthProcessor(authService, authProc2);
View Full Code Here

    public void testAuthenticateSucceedsWithSingleAuthProcessorAndCorrectContext() {
        AuthenticationServiceImpl authService = createAuthenticationService();

        User user = mock(User.class);

        AuthenticationProcessor authProc = mock(AuthenticationProcessor.class);
        when(authProc.canHandle(anyString())).thenReturn(Boolean.TRUE);
        when(authProc.authenticate(Mockito.<UserAdmin>any(), eq("foo"))).thenReturn(user);

        registerAuthProcessor(authService, authProc);

        assert authService.authenticate("foo") != null;
    }
View Full Code Here

        Date now = new Date();
       
        User user1 = mock(User.class);
        User user2 = mock(User.class);

        AuthenticationProcessor authProc1 = mock(AuthenticationProcessor.class);
        when(authProc1.canHandle(any())).thenAnswer(new Answer<Boolean>() {
            public Boolean answer(InvocationOnMock invocation) throws Throwable {
                Object[] args = invocation.getArguments();
                return (args.length == 1 && args[0] instanceof Date);
            }
        });
        when(authProc1.authenticate(Mockito.<UserAdmin>any(), eq(now))).thenReturn(user1);

        AuthenticationProcessor authProc2 = mock(AuthenticationProcessor.class);
        when(authProc2.canHandle(anyString())).thenAnswer(new Answer<Boolean>() {
            public Boolean answer(InvocationOnMock invocation) throws Throwable {
                Object[] args = invocation.getArguments();
                return (args.length == 1 && args[0] instanceof String);
            }
        });
        when(authProc2.authenticate(Mockito.<UserAdmin>any(), eq("foo"))).thenReturn(user2);

        AuthenticationServiceImpl authService = createAuthenticationService();

        registerAuthProcessor(authService, authProc1);
        registerAuthProcessor(authService, authProc2);
View Full Code Here

TOP

Related Classes of org.apache.ace.authentication.api.AuthenticationProcessor

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.