Package javax.security.auth.login

Examples of javax.security.auth.login.CredentialException


        }

        List<IdentityAuthenticator> authenticators =
            authenticatorMap.get(credentials.getCredentialsType());
        if (authenticators == null) {
            throw new CredentialException("Unsupported credentials type: " +
                                          credentials.getCredentialsType());
        }

        for (IdentityAuthenticator authenticator : authenticators) {
            try {
                return authenticator.authenticateIdentity(credentials);
            } catch (LoginException le) {
                // NOTE: because there could be multiple authenticators, it's
                // not possible to return all errors, and besides it's not
                // generally meaningful to return errors from different
                // authenticators since some of them might be expected
                // behavior. So, for now, these errors are being ignored
                if (logger.isLoggable(Level.FINEST)) {
                    logger.logThrow(Level.FINEST, le, "Could not " +
                                    "authenticate credentials with " +
                                    "authenticator {0}",
                                    authenticator.getClass().getName());
                }
            }
        }

        // no authenticators worked
        throw new CredentialException("Could not authenticate identity");
    }
View Full Code Here


     */
    public Identity authenticateIdentity(IdentityCredentials credentials)
        throws CredentialException
    {
        if (!(credentials instanceof NamePasswordCredentials)) {
            throw new CredentialException("unsupported credentials type");
        }
        return new IdentityImpl(((NamePasswordCredentials) credentials).
                getName());
    }
View Full Code Here

    public Identity authenticateIdentity(IdentityCredentials credentials)
        throws AccountNotFoundException, CredentialException
    {
        // make sure that we were given the right type of credentials
        if (!(credentials instanceof NamePasswordCredentials)) {
            throw new CredentialException("unsupported credentials");
        }
        NamePasswordCredentials npc = (NamePasswordCredentials) credentials;

        // get the name, and make sure they have a password entry
        String name = npc.getName();
        byte [] validPass = passwordMap.get(name);
        if (validPass == null) {
            throw new AccountNotFoundException("Unknown user: " + name);
        }

        // hash the given password
        byte [] pass = null;
        synchronized (digest) {
            digest.reset();
            try {
                pass = digest.digest((new String(npc.getPassword())).
                                     getBytes("UTF-8"));
            } catch (IOException ioe) {
                throw new CredentialException("Could not get password: " +
                                              ioe.getMessage());
            }
        }
       
        // verify that the hashes match
        if (!Arrays.equals(validPass, pass)) {
            throw new CredentialException("Invalid credentials");
        }

        return new IdentityImpl(name);
    }
View Full Code Here

    /**
     * @tests javax.security.auth.login.CredentialException#CredentialException()
     */
    public final void testCtor1() {
        assertNull(new CredentialException().getMessage());
    }
View Full Code Here

    /**
     * @tests javax.security.auth.login.CredentialException#CredentialException(
     *        java.lang.String)
     */
    public final void testCtor2() {
        assertNull(new CredentialException(null).getMessage());

        String message = "";
        assertSame(message, new CredentialException(message).getMessage());

        message = "message";
        assertSame(message, new CredentialException(message).getMessage());
    }
View Full Code Here

public class CredentialExceptionTest extends SerializationTest {

    @Override
    protected Object[] getData() {
        return new Object[] {new CredentialException("message")};
    }
View Full Code Here

     */
    public Identity authenticateIdentity(IdentityCredentials credentials)
        throws CredentialException
    {
        if (!(credentials instanceof NamePasswordCredentials)) {
            throw new CredentialException("unsupported credentials type");
        }
        return new IdentityImpl(((NamePasswordCredentials) credentials).
                getName());
    }
View Full Code Here

    public Identity authenticateIdentity(IdentityCredentials credentials)
        throws AccountNotFoundException, CredentialException
    {
        // make sure that we were given the right type of credentials
        if (!(credentials instanceof NamePasswordCredentials)) {
            throw new CredentialException("unsupported credentials");
        }
        NamePasswordCredentials npc = (NamePasswordCredentials) credentials;

        // get the name, and make sure they have a password entry
        String name = npc.getName();
        byte [] validPass = passwordMap.get(name);
        if (validPass == null) {
            throw new AccountNotFoundException("Unknown user: " + name);
        }

        // hash the given password
        byte [] pass = null;
        synchronized (digest) {
            digest.reset();
            try {
                pass = digest.digest((new String(npc.getPassword())).
                                     getBytes("UTF-8"));
            } catch (IOException ioe) {
                throw new CredentialException("Could not get password: " +
                                              ioe.getMessage());
            }
        }
       
        // verify that the hashes match
        if (!Arrays.equals(validPass, pass)) {
            throw new CredentialException("Invalid credentials");
        }

        return new IdentityImpl(name);
    }
View Full Code Here

        }

        List<IdentityAuthenticator> authenticators =
            authenticatorMap.get(credentials.getCredentialsType());
        if (authenticators == null) {
            throw new CredentialException("Unsupported credentials type: " +
                                          credentials.getCredentialsType());
        }

        for (IdentityAuthenticator authenticator : authenticators) {
            try {
                return authenticator.authenticateIdentity(credentials);
            } catch (LoginException le) {
                // NOTE: because there could be multiple authenticators, it's
                // not possible to return all errors, and besides it's not
                // generally meaningful to return errors from different
                // authenticators since some of them might be expected
                // behavior. So, for now, these errors are being ignored
                if (logger.isLoggable(Level.FINEST)) {
                    logger.logThrow(Level.FINEST, le, "Could not " +
                                    "authenticate credentials with " +
                                    "authenticator {0}",
                                    authenticator.getClass().getName());
                }
            }
        }

        // no authenticators worked
        throw new CredentialException("Could not authenticate identity");
    }
View Full Code Here

        // protection and token
        HashMap info = getPageInfo(title);
        if (!checkRights(info, "edit") || (Boolean)info.get("exists") && !checkRights(info, "create"))
        {
            CredentialException ex = new CredentialException("Permission denied: page is protected.");
            log(Level.WARNING, "edit", "Cannot edit - permission denied. " + ex);
            throw ex;
        }
        String wpEditToken = (String)info.get("token");
View Full Code Here

TOP

Related Classes of javax.security.auth.login.CredentialException

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.