Package javax.security.auth.login

Examples of javax.security.auth.login.FailedLoginException


            throw (LoginException) new LoginException().initCause(uce);
        }
        assert callbacks.length == 2;
        cbUsername = ((NameCallback) callbacks[0]).getName();
        if (cbUsername == null || cbUsername.equals("")) {
            throw new FailedLoginException();
        }
        char[] provided = ((PasswordCallback) callbacks[1]).getPassword();
        cbPassword = provided == null ? null : new String(provided);

        try {
            Connection conn;
            if (factory != null) {
                DataSource ds = (DataSource) factory.getConnectionFactory();
                conn = ds.getConnection();
            } else {
                conn = driver.connect(connectionURL, properties);
            }

            try {
                PreparedStatement statement = conn.prepareStatement(userSelect);
                try {
                    int count = countParameters(userSelect);
                    for (int i = 0; i < count; i++) {
                        statement.setObject(i + 1, cbUsername);
                    }
                    ResultSet result = statement.executeQuery();

                    try {
                        boolean found = false;
                        while (result.next()) {
                            String userName = result.getString(1);
                            String userPassword = result.getString(2);

                            if (cbUsername.equals(userName)) {
                                found = true;
                                if (!checkPassword(userPassword, cbPassword)) {
                                    throw new FailedLoginException();
                                }
                                break;
                            }
                        }
                        if(!found) {
                            // User does not exist
                            throw new FailedLoginException();
                        }
                    } finally {
                        result.close();
                    }
                } finally {
View Full Code Here


            throw (LoginException) new LoginException().initCause(uce);
        }
        assert callbacks.length == 1;
        X509Certificate certificate = ((CertificateCallback)callbacks[0]).getCertificate();
        if (certificate == null) {
            throw new FailedLoginException();
        }
        principal = certificate.getSubjectX500Principal();

        if(!users.containsKey(principal.getName())) {
            // Clear out the private state
            principal = null;
            throw new FailedLoginException();
        }

        loginSucceeded = true;
        return true;
    }
View Full Code Here

        assert callbacks.length == 1;
        username = ((NameCallback) callbacks[0]).getName();
        if (username == null || username.equals("")) {
            // Clear out the private state
            username = null;
            throw new FailedLoginException();
        }

        loginSucceeded = true;
        return true;
    }
View Full Code Here

            try {
                handler.handle(new Callback[] {nameCallback, passwordCallback});
                username = nameCallback.getName();
                String password = (String) options.get(username);
                if (password == null) {
                    throw new FailedLoginException();
                }
                if (password.equals(new String(passwordCallback.getPassword()))) {
                    return true;
                }
                throw new FailedLoginException();
            } catch (java.io.IOException e) {
                throw new FailedLoginException();
            } catch (UnsupportedCallbackException e) {
                throw new FailedLoginException();
            }
        }
View Full Code Here

        }
        name = callback.getName();
        if (allowedNames.contains(name)) {
            return true;
        }
        throw new FailedLoginException("name not recognized " + name);
    }
View Full Code Here

        username = ((NameCallback) callbacks[0]).getName();
        if (username == null || username.equals("")) {
            // Clear out the private state
            username = null;
            password = null;
            throw new FailedLoginException();
        }
        String realPassword = users.getProperty(username);
        if (realPassword == null || realPassword.equals("")) {
            // Clear out the private state
            username = null;
            password = null;
            throw new FailedLoginException();
        } else {
            // Decrypt the password if needed, so we can compare it with the supplied one
            realPassword = (String) EncryptionManager.decrypt(realPassword);
        }
        char[] entered = ((PasswordCallback) callbacks[1]).getPassword();
        password = entered == null ? null : new String(entered);
        if (!checkPassword(realPassword, password)) {
            // Clear out the private state
            username = null;
            password = null;
            throw new FailedLoginException();
        }

        loginSucceeded = true;
        return true;
    }
View Full Code Here

            throw (LoginException) new LoginException().initCause(uce);
        }
        username = ((NameCallback) callbacks[0]).getName();
        if (username == null || username.equals("")) {
            username = null;
            throw new FailedLoginException();
        }
        byte[] token = Base64.decode(username);
        try {
            GSSManager manager = GSSManager.getInstance();
            Oid krb5Oid = new Oid("1.3.6.1.5.5.2");
View Full Code Here

                || cbPassword == null || "".equals(cbPassword)) {
            // Clear out the private state
            cbUsername = null;
            cbPassword = null;
            groups.clear();
            throw new FailedLoginException();
        }

        try {
            boolean result = authenticate(cbUsername, cbPassword);
            if (!result) {
                throw new FailedLoginException();
            }
        } catch (LoginException e) {
            // Clear out the private state
            cbUsername = null;
            cbPassword = null;
View Full Code Here

            for (String role : roles) {
                groups.add(role);
            }
        } catch (CommunicationException e) {
            close(context);
            throw (LoginException) new FailedLoginException().initCause(e);
        } catch (NamingException e) {
            close(context);
            throw (LoginException) new FailedLoginException().initCause(e);
        }


        return true;
    }
View Full Code Here

        context.addToEnvironment(Context.SECURITY_CREDENTIALS, password);
        try {
            context.getAttributes("", null);
        } catch (AuthenticationException e) {
            log.debug("Authentication failed for dn=" + dn);
            throw new FailedLoginException();
        } finally {

            if (connectionUsername != null) {
                context.addToEnvironment(Context.SECURITY_PRINCIPAL,
                        connectionUsername);
View Full Code Here

TOP

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

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.