Package org.openengsb.core.api.security.model

Examples of org.openengsb.core.api.security.model.Authentication


                userManager.createUser("test");
                userManager.setUserCredentials("test", "password", "password");
                return null;
            }
        });
        Authentication authenticate = authenticator.authenticate("test", new Password("password"));
        assertThat(authenticate, not(nullValue()));
    }
View Full Code Here


                @Override
                public Authentication answer(InvocationOnMock invocation) throws Throwable {
                    String user = (String) invocation.getArguments()[0];
                    Password credentials = (Password) invocation.getArguments()[1];
                    if ("user".equals(user) && credentials.getValue().equals("password")) {
                        return new Authentication(user, credentials.toString());
                    }
                    throw new AuthenticationException("username and password did not match");
                }
            });
        PrivateKeySource keySource = mock(PrivateKeySource.class);
View Full Code Here

        when(authManager.authenticate(anyString(), any(Credentials.class))).thenAnswer(new Answer<Authentication>() {
            @Override
            public Authentication answer(InvocationOnMock invocation) throws Throwable {
                String username = (String) invocation.getArguments()[0];
                Credentials credentials = (Credentials) invocation.getArguments()[1];
                return new Authentication(username, credentials);
            }
        });
        OpenEngSBSecurityManager openEngSBSecurityManager = new OpenEngSBSecurityManager();
        OpenEngSBShiroAuthenticator authenticator = new OpenEngSBShiroAuthenticator();
        authenticator.setAuthenticator(authManager);
View Full Code Here

        when(authManager.authenticate(anyString(), any(Credentials.class))).thenAnswer(new Answer<Authentication>() {
            @Override
            public Authentication answer(InvocationOnMock invocation) throws Throwable {
                String username = (String) invocation.getArguments()[0];
                Credentials credentials = (Credentials) invocation.getArguments()[1];
                return new Authentication(username, credentials);
            }
        });
        setupSecurityManager();
        when(requestHandler.handleCall(any(MethodCall.class))).thenAnswer(new Answer<MethodResult>() {
            @Override
View Full Code Here

        factory.applyAttributes((Connector) authManager, attributes);
    }

    @Test
    public void authenticateUsernamePassword_shouldAuthenticateSuccessful() throws Exception {
        Authentication authenticate = passwordAuthenticator.authenticate("testuser", new Password("password"));
        assertThat(authenticate.getUsername(), is("testuser"));
    }
View Full Code Here

        passwordAuthenticator.authenticate("testuser", new Password("password2"));
    }

    @Test
    public void authenticateOnetimePassword() throws Exception {
        Authentication authenticate = onetimeAuthenticator.authenticate("testuser", new OneTimeValue(90489 * 2));
        assertThat(authenticate.getUsername(), is("testuser"));
    }
View Full Code Here

        onetimeAuthenticator.authenticate("testuser", new OneTimeValue(123));
    }

    @Test
    public void authenticateUsernamePasswordAtManager_shouldAuthenticateSuccessful() throws Exception {
        Authentication authenticate = authManager.authenticate("testuser", new Password("password"));
        assertThat(authenticate.getUsername(), is("testuser"));
    }
View Full Code Here

        authManager.authenticate("testuser", new Password("password2"));
    }

    @Test
    public void authenticateOnetimePasswordAtManager_shouldWork() throws Exception {
        Authentication authenticate = authManager.authenticate("testuser", new OneTimeValue(90489 * 2));
        assertThat(authenticate.getUsername(), is("testuser"));
    }
View Full Code Here

    protected AuthenticationInfo doAuthenticate(AuthenticationToken token) throws AuthenticationException {
        if (token instanceof RootAuthenticationToken) {
            return new SimpleAuthenticationInfo(new Object(), null, "openengsb");
        }
        try {
            Authentication authenticate =
                authenticator.authenticate(token.getPrincipal().toString(), (Credentials) token.getCredentials());
            return new SimpleAuthenticationInfo(authenticate.getUsername(), authenticate.getCredentials(),
                "openengsb");
        } catch (org.openengsb.domain.authentication.AuthenticationException e) {
            throw new AuthenticationException(e);
        }
    }
View Full Code Here

            }
            userManager.setUserCredentials(username, "counter", Integer.toString(counter + 1));
        } catch (UserNotFoundException e) {
            throw new AuthenticationException(e);
        }
        return new Authentication(username);
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.security.model.Authentication

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.