Examples of UNIXUser


Examples of com.adito.unixauth.UNIXUser

     * @see com.adito.security.UserDatabase#checkPassword(java.lang.String,
     *      java.lang.String, int)
     */
    public boolean checkPassword(String username, String password) throws UserDatabaseException, InvalidLoginCredentialsException {
        // 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$")) {
View Full Code Here

Examples of com.adito.unixauth.UNIXUser

                                    continue;
                                }
                            } else {
                                pw = password.toCharArray();
                            }
                            UNIXUser user = new UNIXUser(username, userEmailMap == null ? "" : userEmailMap.getProperty(username,
                                ""), pw, uid, gid, fullname, home, shell, userRoles, this.getRealm());
                            userList.add(user);
                        }
                    }
                } finally {
View Full Code Here

Examples of org.jvnet.libpam.UnixUser

    }

    @Override
    protected synchronized UserDetails authenticate(String username, String password) throws AuthenticationException {
        try {
            UnixUser uu = new PAM(serviceName).authenticate(username, password);

            // I never understood why Acegi insists on keeping the password...
            return new User(username,"",true,true,true,true, toAuthorities(uu));
        } catch (PAMException e) {
            throw new BadCredentialsException(e.getMessage(),e);
View Full Code Here

Examples of org.jvnet.libpam.UnixUser

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
        if(!UnixUser.exists(username))
            throw new UsernameNotFoundException("No such Unix user: "+username);
        try {
            UnixUser uu = new UnixUser(username);
            // return some dummy instance
            return new User(username,"",true,true,true,true, toAuthorities(uu));
        } catch (PAMException e) {
            throw new UsernameNotFoundException("Failed to load information about Unix user "+username,e);
        }
View Full Code Here

Examples of org.jvnet.libpam.UnixUser

        info(Result.failure, "args[1]==null");
      }
      else {
        String userid = args[0];
        String password = args[1];
        UnixUser u = new PAM("sshd").authenticate(userid, password);
        info(Result.success, "groups = "+u.getGroups().toString());
      }
     
    }
    catch(Throwable t) {
      info(Result.failure,t.getMessage());
View Full Code Here

Examples of org.jvnet.libpam.UnixUser

        // A Unix user must have a name not null so check here.
        if ((_username == null) || (_username.length() == 0)) {
            throw new LoginException("Invalid Username");
        }
        UnixUser user = authenticate(_username, _password);

        if (user == null) {  // JAAS behavior
            throw new LoginException("Failed Pam Login for " + _username);
        }
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "PAM login succeeded for: " + _username);
        }
       
        /*
         * Get the groups from the libpam4j UnixUser class that has been
         * returned after a successful authentication.
         */

        String[] grpList = null;
        Set<String> groupSet = user.getGroups();
       
        if (groupSet != null) {
            grpList = new String[groupSet.size()];
            user.getGroups().toArray(grpList);
        }
        else {
            //Empty group list, create a zero-length group list
             grpList = new String[0];
        }
View Full Code Here

Examples of org.jvnet.libpam.UnixUser

     * @returns null if authentication failed,
     * returns the UnixUser object if authentication succeeded.
     *
     */
    private UnixUser authenticate(String username, String password) throws LoginException {
        UnixUser user = null;
        String pamService = null;

        if(_currentRealm instanceof PamRealm) {
            pamService = ((PamRealm)_currentRealm).getPamService();
        }
View Full Code Here

Examples of org.jvnet.libpam.UnixUser

        // A Unix user must have a name not null so check here.
        if ((_username == null) || (_username.length() == 0)) {
            throw new LoginException("Invalid Username");
        }
        UnixUser user = authenticate(_username, _password);

        if (user == null) {  // JAAS behavior
            throw new LoginException("Failed Pam Login for " + _username);
        }
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "PAM login succeeded for: " + _username);
        }
       
        /*
         * Get the groups from the libpam4j UnixUser class that has been
         * returned after a successful authentication.
         */

        String[] grpList = null;
        Set<String> groupSet = user.getGroups();
       
        if (groupSet != null) {
            grpList = new String[groupSet.size()];
            user.getGroups().toArray(grpList);
        }
        else {
            //Empty group list, create a zero-length group list
             grpList = new String[0];
        }
View Full Code Here

Examples of org.jvnet.libpam.UnixUser

     * @returns null if authentication failed,
     * returns the UnixUser object if authentication succeeded.
     *
     */
    private UnixUser authenticate(String username, String password) throws LoginException {
        UnixUser user = null;
        String pamService = null;

        if(_currentRealm instanceof PamRealm) {
            pamService = ((PamRealm)_currentRealm).getPamService();
        }
View Full Code Here

Examples of org.jvnet.libpam.UnixUser

        // A Unix user must have a name not null so check here.
        if ((_username == null) || (_username.length() == 0)) {
            throw new LoginException("Invalid Username");
        }
        UnixUser user = authenticate(_username, _password);

        if (user == null) {  // JAAS behavior
            throw new LoginException("Failed Pam Login for " + _username);
        }
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "PAM login succeeded for: " + _username);
        }
       
        /*
         * Get the groups from the libpam4j UnixUser class that has been
         * returned after a successful authentication.
         */

        String[] grpList = null;
        Set<String> groupSet = user.getGroups();
       
        if (groupSet != null) {
            grpList = new String[groupSet.size()];
            user.getGroups().toArray(grpList);
        }
        else {
            //Empty group list, create a zero-length group list
             grpList = new String[0];
        }
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.