Package org.openengsb.domain.authentication

Examples of org.openengsb.domain.authentication.AuthenticationException


                    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);
        when(keySource.getPrivateKey()).thenReturn(privateKey);
        MessageCryptoFilterFactory cipherFactory = new MessageCryptoFilterFactory(keySource, "AES");
View Full Code Here


    }

    @Test
    public void testInvalidAuthentication_shouldNotInvokeRequestHandler() throws Exception {
        when(authManager.authenticate(anyString(), any(Credentials.class))).thenThrow(
            new AuthenticationException("bad"));
        MethodCallMessage secureRequest = prepareSecureRequest();
        try {
            processRequest(secureRequest);
            fail("Expected exception");
        } catch (FilterException e) {
View Full Code Here

        @Override
        public Authentication authenticate(String username, Credentials credentials) throws AuthenticationException {
            Iterator<AuthenticationDomain> serviceIterator =
                utilsService.getServiceIterator(providers, AuthenticationDomain.class);
            AuthenticationException lastException = null;
            LOGGER.debug("iterating {} authenticationProviderServices", providers.size());
            while (serviceIterator.hasNext()) {
                AuthenticationDomain provider = serviceIterator.next();
                if (provider.supports(credentials)) {
                    LOGGER.info("attempting authentication using provider {}", provider.getClass());
                    try {
                        return provider.authenticate(username, credentials);
                    } catch (AuthenticationException e) {
                        lastException = e;
                    }
                }
            }

            if (lastException == null) {
                lastException =
                    new AuthenticationException("No AuthenticationProvider found, that supports " + credentials);
            }
            throw lastException;
        }
View Full Code Here

    @Override
    public Authentication authenticate(String username, Credentials credentials) throws AuthenticationException {
        Integer code = ((OneTimeValue) credentials).getValue();
        if (!NUMBER_RANGE.containsInteger(code)) {
            throw new AuthenticationException("value is outside the specified range");
        }
        String baseCodeString;
        String counterString;
        try {
            baseCodeString = userManager.getUserCredentials(username, "onetime-basecode");
            counterString = userManager.getUserCredentials(username, "onetime-counter");
            Integer baseCode = Integer.parseInt(baseCodeString);
            Integer counter = Integer.parseInt(counterString);
            Integer expectedCode = (baseCode * counter) % MAXCODE;
            if (ObjectUtils.notEqual(code, expectedCode)) {
                throw new AuthenticationException("wrong auth-code");
            }
            userManager.setUserCredentials(username, "counter", Integer.toString(counter + 1));
        } catch (UserNotFoundException e) {
            throw new AuthenticationException(e);
        }
        return new Authentication(username);
    }
View Full Code Here

    public Authentication authenticate(String username, Credentials credentials) throws AuthenticationException {
        String actualPassword;
        try {
            actualPassword = userManager.getUserCredentials(username, "password");
        } catch (UserNotFoundException e) {
            throw new AuthenticationException(e);
        }
        String givenPassword = ((Password) credentials).getValue();
        if (ObjectUtils.notEqual(givenPassword, actualPassword)) {
            throw new AuthenticationException("wrong password");
        }
        Authentication authentication = new Authentication(username);
        return authentication;

    }
View Full Code Here

            restClientFactory.createWithBasicHttpAuthentication(ServerConfig.serverUri, username, givenPassword);
        try {
            restClient.getSessionClient().getCurrentSession().claim();
        } catch (Exception e) {
            // statuscode 401: missing user or wrong pass. 403: forbidden (e.g.captcha required)
            throw new AuthenticationException(e);
        }
        Authentication authentication = new Authentication(username);
        return authentication;

    }
View Full Code Here

TOP

Related Classes of org.openengsb.domain.authentication.AuthenticationException

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.