Search in sources :

Example 1 with PamRealm

use of com.sun.enterprise.security.auth.realm.pam.PamRealm in project Payara by payara.

the class PamLoginModule method authenticate.

/**
 * Invokes the authentication call.This class uses the default PAM service - sshd
 *
 * @param username OS User to authenticate.
 * @param password Given password.
 * @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();
    } else {
        throw new LoginException("pamrealm.invalid_realm");
    }
    try {
        user = new PAM(pamService).authenticate(username, password);
    } catch (PAMException e) {
        LOGGER.log(SEVERE, "pam_exception_authenticate", e);
    }
    return user;
}
Also used : UnixUser(org.jvnet.libpam.UnixUser) LoginException(javax.security.auth.login.LoginException) PAM(org.jvnet.libpam.PAM) PAMException(org.jvnet.libpam.PAMException) PamRealm(com.sun.enterprise.security.auth.realm.pam.PamRealm)

Aggregations

PamRealm (com.sun.enterprise.security.auth.realm.pam.PamRealm)1 LoginException (javax.security.auth.login.LoginException)1 PAM (org.jvnet.libpam.PAM)1 PAMException (org.jvnet.libpam.PAMException)1 UnixUser (org.jvnet.libpam.UnixUser)1