Package com.adito.security

Examples of com.adito.security.UserDatabaseException


            throw new InvalidLoginCredentialsException();
        }
        try {
            return getAccount(username);
        } catch (Exception e) {
            throw new UserDatabaseException("Failed to get user account.", e);
        }
    }
View Full Code Here


        // Get the user account
        UNIXUser user = null;
        try {
            user = (UNIXUser) getAccount(username);
        } catch (Exception e) {
            throw new UserDatabaseException("Could not get user account", e);
        }

        // Make sure the user exists
        if (user == null) {
            throw new InvalidLoginCredentialsException();
        }

        // Determine the password type
        String pw = new String(user.getPassword());
        try {
            if (pw.startsWith("$1$")) {
                // MD5
                return pw.substring(12).equals(MD5Crypt.crypt(password, pw.substring(3, 11)).substring(12));
            } else if (pw.startsWith("$2a$")) {
                // Blowfish
                return BCrypt.checkpw(password, pw);
            } else {
                // DES
                return DESCrypt.crypt(pw.substring(0, 2), password).equals(pw.substring(2));
            }
        } catch (Exception e) {
            throw new UserDatabaseException("Invalid password format.", e);
        }
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public Iterable<User> allUsers() throws UserDatabaseException {
        try {
            checkPasswdFile();
        } catch (Exception e) {
            throw new UserDatabaseException ("failed to list all users", e);
        }
        return (Iterable<User>) (List<? extends User>) Arrays.asList(users);
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public Iterable<Role> allRoles() throws UserDatabaseException {
        try {
            checkGroupFile();
        } catch (Exception e) {
            throw new UserDatabaseException ("failed to list all roles", e);
        }
        return (Iterable<Role>) (List<? extends Role>) Arrays.asList(roles);
    }
View Full Code Here

            } catch (InterruptedException ie) {

            }
            int ret = p.exitValue();
            if (ret != 0) {
                throw new UserDatabaseException("Failed to change password. chpasswd returned exit code " + ret + ".");
            }

        } catch (IOException e) {
            throw new UserDatabaseException("Failed to change password.", e);
        } finally {
            if (p != null) {
                Util.closeStream(p.getOutputStream());
                Util.closeStream(p.getInputStream());
                Util.closeStream(p.getErrorStream());
View Full Code Here

        ActiveDirectoryUser user = null;
        try {
            user = (ActiveDirectoryUser) getAccount(username);
        } catch (Exception e) {
            logger.error("Failed to logon", e);
            throw new UserDatabaseException("Failed to logon", e);
        }
        // this needs to be outside the try/catch, otherwise the specific
        // exception is turned into a general one
        assertValidCredentials(user, password);
        return user;
View Full Code Here

    public boolean checkPassword(String username, String password) throws UserDatabaseException, InvalidLoginCredentialsException {
        try {
            ActiveDirectoryUser user = (ActiveDirectoryUser) getAccount(username);
            return areCredentialsValid(user, password);
        } catch (UserNotFoundException e) {
            throw new UserDatabaseException("Failed to check password", e);
        } catch (Exception e) {
            throw new UserDatabaseException("Failed to check password", e);
        }
    }
View Full Code Here

                    return getAccountFromDN(dn, context);
                }
            });
        }

        throw new UserDatabaseException("Certificate requires subject to be DN of Active Directory user");
    }
View Full Code Here

                LoginContext context = getServiceAccountLoginContext();
                result = Subject.doAs(context.getSubject(), action);
                logoutContext(context);
            } catch (Exception e) {
                logger.error("Failure to create Login Context", e);
                throw new UserDatabaseException("", e);
            }
        } else {
            result = action.run();
        }
       
        if (result instanceof Throwable) {
            Throwable e = (Throwable) result;
            logger.error("Failure to doAs", e);
            throw new UserDatabaseException("", e);
        }
        return result;
    }
View Full Code Here

                        throw new FieldValidationException("doesNotMatchPolicy");
                    }
                } catch(FieldValidationException fve) {
                  throw fve;
                } catch (Exception e) {
                    throw new UserDatabaseException("Could not check password against current policy.", e);
                }
            }
        } catch (FieldValidationException fve) {
            errors.add(Globals.ERROR_KEY, new ActionMessage("changePassword.error." + fve.getResourceKey()));
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.adito.security.UserDatabaseException

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.