Package javax.security.auth.login

Examples of javax.security.auth.login.FailedLoginException


        if (auth == null) {
            return false;
        } else if (auth.authenticate(credentials)) {
            return true;
        }
        throw new FailedLoginException();
    }
View Full Code Here


        if (user != null) {
            Subject impersSubject = getImpersonatorSubject(credentials);
            if (user.getImpersonation().allows(impersSubject)) {
                return true;
            } else {
                throw new FailedLoginException("attempt to impersonate denied for " + principal.getName());
            }
        } else {
            log.debug("Failed to retrieve user to impersonate for principal name " + principal.getName());
            return false;
        }
View Full Code Here

        // Report results based on success or failure
        if (principal != null) {
            return (true);
        } else {
            throw new
                FailedLoginException("Username or password is incorrect");
        }

    }
View Full Code Here

        if (auth == null) {
            return false;
        } else if (auth.authenticate(credentials)) {
            return true;
        }
        throw new FailedLoginException();
    }
View Full Code Here

                throw (IOException) new IOException("Cannot connect to "+location).initCause(e);
            }

            if (http.getResponseCode() == 401) { // need to authenticate
                if (username == null || username.equals("")) {
                    throw new FailedLoginException("Server returned 401 " + http.getResponseMessage());
                }
                //TODO is it necessary to keep getting new http's ?
                http = (HttpURLConnection) location.openConnection();
                http.setRequestProperty("Authorization",
                        "Basic " + new String(Base64.encode((username + ":" + password).getBytes())));
                http.connect();
                if (http.getResponseCode() == 401) {
                    throw new FailedLoginException("Server returned 401 " + http.getResponseMessage());
                } else if (http.getResponseCode() == 404) {
                    return null; // Not found at this repository
                }
            } else if (http.getResponseCode() == 404) {
                return null; // Not found at this repository
View Full Code Here

        } catch (HeaderMismatchException e) {
            throw (LoginException) new LoginException("Header Mistmatch error").initCause(e);
        }

        if (headerMap.isEmpty()) {
            throw new FailedLoginException();
        }

        if (authenticationAuthority.equalsIgnoreCase("Siteminder")) {
            HeaderHandler headerHandler = new SiteminderHeaderHandler();
            username = headerHandler.getUser(headerMap);
        } else if (authenticationAuthority.equalsIgnoreCase("Datapower")) {
            /* To be Done */
        }
        if (username == null || username.equals("")) {
            username = null;
            throw new FailedLoginException();
        }

        if (username != null) {
            for (Map.Entry<String, Set<String>> entry : roleUsersMap.entrySet()) {
                String groupName = entry.getKey();
                Set<String> users = entry.getValue();
                for (String user : users) {
                    if (username.equals(user)) {
                        groups.add(groupName);
                        break;
                    }
                }
            }
        }

        if (groups.isEmpty()) {
            log.error("No roles associated with user " + username);
            loginSucceeded = false;
            throw new FailedLoginException();
        } else
            loginSucceeded = true;
        return loginSucceeded;
    }
View Full Code Here

            throw (LoginException) new LoginException().initCause(uce);
        }
        assert callbacks.length == 1;
        Certificate[] certificateChain = ((CertificateChainCallback)callbacks[0]).getCertificateChain();
        if (certificateChain == null || certificateChain.length == 0) {
            throw new FailedLoginException();
        }
        if (!(certificateChain[0] instanceof X509Certificate)) {
            throw new FailedLoginException();
        }
        //TODO actually validate chain
        principal = ((X509Certificate)certificateChain[0]).getSubjectX500Principal();

        loginSucceeded = true;
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.