Package org.jvnet.libpam

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


    @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

        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

        // 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

     * @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

        // 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

     * @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

        // 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

     * @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

            if ((name == null) || (password == null)) {
                debug("user or pass is null");
                return false;
            }
            debug("PAM authentication trying (" + serviceName + ") for: " + name);
            UnixUser authenticate = new PAM(serviceName).authenticate(name, new String(password));
            debug("PAM authentication succeeded for: " + name);
            this.unixUser = authenticate;

            return true;
        } catch (PAMException e) {
View Full Code Here

TOP

Related Classes of org.jvnet.libpam.UnixUser

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.