Examples of AuthenticationResult


Examples of org.apache.qpid.server.security.auth.AuthenticationResult

    @Override
    public AuthenticationResult authenticate(String username, String password)
    {
        try
        {
            AuthenticationResult result = doLDAPNameAuthentication(getNameFromId(username), password);
            if(result.getStatus() == AuthenticationStatus.SUCCESS)
            {
                //Return a result based on the supplied username rather than the search name
                return new AuthenticationResult(new UsernamePrincipal(username));
            }
            else
            {
                return result;
            }
        }
        catch (NamingException e)
        {
            return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR, e);
        }
    }
View Full Code Here

Examples of org.apache.qpid.server.security.auth.AuthenticationResult

    private AuthenticationResult doLDAPNameAuthentication(String name, String password)
    {
        if(name == null)
        {
            //The search didn't return anything, class as not-authenticated before it NPEs below
            return new AuthenticationResult(AuthenticationStatus.CONTINUE);
        }

        Hashtable<Object,Object> env = new Hashtable<Object,Object>();
        env.put(Context.INITIAL_CONTEXT_FACTORY, _ldapContextFactory);
        env.put(Context.PROVIDER_URL, _providerAuthURL);

        env.put(Context.SECURITY_AUTHENTICATION, "simple");

        env.put(Context.SECURITY_PRINCIPAL, name);
        env.put(Context.SECURITY_CREDENTIALS, password);

        DirContext ctx = null;
        try
        {
            ctx = new InitialDirContext(env);

            //Authentication succeeded
            return new AuthenticationResult(new UsernamePrincipal(name));
        }
        catch(AuthenticationException ae)
        {
            //Authentication failed
            return new AuthenticationResult(AuthenticationStatus.CONTINUE);
        }
        catch (NamingException e)
        {
            //Some other failure
            return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR, e);
        }
        finally
        {
            if(ctx != null)
            {
View Full Code Here

Examples of org.apache.qpid.server.security.auth.AuthenticationResult

        @Override
        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
        {
            String name = null;
            String password = null;
            AuthenticationResult authenticated = null;
            for(Callback callback : callbacks)
            {
                if (callback instanceof NameCallback)
                {
                    String id = ((NameCallback) callback).getDefaultName();
                    try
                    {
                        name = getNameFromId(id);
                    }
                    catch (NamingException e)
                    {
                        _logger.warn("SASL Authentication Exception", e);
                    }
                    if(password != null)
                    {
                        authenticated = doLDAPNameAuthentication(name, password);
                    }
                }
                else if (callback instanceof PlainPasswordCallback)
                {
                    password = ((PlainPasswordCallback)callback).getPlainPassword();
                    if(name != null)
                    {
                        authenticated = doLDAPNameAuthentication(name, password);
                        if(authenticated.getStatus()== AuthenticationResult.AuthenticationStatus.SUCCESS)
                        {
                            ((PlainPasswordCallback)callback).setAuthenticated(true);
                        }
                    }
                }
                else if (callback instanceof AuthorizeCallback)
                {
                    ((AuthorizeCallback) callback).setAuthorized(authenticated != null && authenticated.getStatus() == AuthenticationResult.AuthenticationStatus.SUCCESS);
                }
                else
                {
                    throw new UnsupportedCallbackException(callback);
                }
View Full Code Here

Examples of org.apache.qpid.server.security.auth.AuthenticationResult

            byte[] challenge = server.evaluateResponse(response != null ? response : new byte[0]);

            if (server.isComplete())
            {
                final String userId = server.getAuthorizationID();
                return new AuthenticationResult(new UsernamePrincipal(userId));
            }
            else
            {
                return new AuthenticationResult(challenge, AuthenticationResult.AuthenticationStatus.CONTINUE);
            }
        }
        catch (SaslException e)
        {
            return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR, e);
        }
    }
View Full Code Here

Examples of org.apache.qpid.server.security.auth.AuthenticationResult

    {
        try
        {
            if (_principalDatabase.verifyPassword(username, password.toCharArray()))
            {
                return new AuthenticationResult(new UsernamePrincipal(username));
            }
            else
            {
                return new AuthenticationResult(AuthenticationStatus.CONTINUE);
            }
        }
        catch (AccountNotFoundException e)
        {
            return new AuthenticationResult(AuthenticationStatus.CONTINUE);
        }
    }
View Full Code Here

Examples of org.apache.qpid.server.security.auth.AuthenticationResult

            Principal principal = ((ExternalSaslServer)server).getAuthenticatedPrincipal();

            if(principal != null)
            {
                return new AuthenticationResult(principal);
            }
            else
            {
                return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR);
            }
        }
        catch (SaslException e)
        {
            return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR,e);
        }

    }
View Full Code Here

Examples of org.apache.qpid.server.security.auth.AuthenticationResult

    }

    @Override
    public AuthenticationResult authenticate(String username, String password)
    {
        return new AuthenticationResult(new UsernamePrincipal(username));
    }
View Full Code Here

Examples of org.apache.qpid.server.security.auth.AuthenticationResult

            // Process response from the client
            byte[] challenge = server.evaluateResponse(response != null ? response : new byte[0]);

            if (server.isComplete())
            {
                return new AuthenticationResult(new UsernamePrincipal(server.getAuthorizationID()));
            }
            else
            {
                return new AuthenticationResult(challenge, AuthenticationResult.AuthenticationStatus.CONTINUE);
            }
        }
        catch (SaslException e)
        {
            e.printStackTrace(System.err);
            return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR, e);
        }
    }
View Full Code Here

Examples of org.apache.qpid.server.security.auth.AuthenticationResult

    }

    @Override
    public AuthenticationResult authenticate(String username, String password)
    {
        return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR);
    }
View Full Code Here

Examples of org.apache.qpid.server.security.auth.AuthenticationResult

            {
                return ANONYMOUS_AUTHENTICATION;
            }
            else
            {
                return new AuthenticationResult(challenge, AuthenticationResult.AuthenticationStatus.CONTINUE);
            }
        }
        catch (SaslException e)
        {
            return new AuthenticationResult(AuthenticationResult.AuthenticationStatus.ERROR, e);
        }
    }
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.