use of org.jvnet.libpam.PAMException in project atlas by apache.
the class PamLoginModule method performLogin.
private boolean performLogin() throws LoginException {
try {
UnixUser user = pam.authenticate(username, password);
principal = new PamPrincipal(user);
authSucceeded = true;
return true;
} catch (PAMException ex) {
LoginException le = new FailedLoginException("Invalid username or password");
le.initCause(ex);
throw le;
}
}
use of org.jvnet.libpam.PAMException in project incubator-atlas by apache.
the class PamLoginModule method performLogin.
private boolean performLogin() throws LoginException {
try {
UnixUser user = pam.authenticate(username, password);
principal = new PamPrincipal(user);
authSucceeded = true;
return true;
} catch (PAMException ex) {
LoginException le = new FailedLoginException("Invalid username or password");
le.initCause(ex);
throw le;
}
}
use of org.jvnet.libpam.PAMException in project ranger by apache.
the class PamLoginModule method performLogin.
private boolean performLogin() throws LoginException {
try {
if (_passwordchar != null) {
UnixUser user = _pam.authenticate(_username, String.valueOf(_passwordchar));
_principal = new PamPrincipal(user);
_authSucceeded = true;
return true;
} else {
throw new PAMException("Password is Null or Empty!!!");
}
} catch (PAMException ex) {
LoginException le = new FailedLoginException("Invalid username or password");
le.initCause(ex);
throw le;
}
}
use of org.jvnet.libpam.PAMException in project drill by axbaretto.
the class Pam4jUserAuthenticator method authenticate.
@Override
public void authenticate(String user, String password) throws UserAuthenticationException {
for (String profile : profiles) {
PAM pam = null;
try {
pam = new PAM(profile);
pam.authenticate(user, password);
} catch (PAMException ex) {
logger.error("PAM auth failed for user: {} against {} profile. Exception: {}", user, profile, ex.getMessage());
throw new UserAuthenticationException(String.format("PAM auth failed for user: %s using profile: %s", user, profile));
} finally {
if (pam != null) {
pam.dispose();
}
}
// No need to check for null unixUser as in case of failure we will not reach here.
logger.trace("PAM authentication was successful for user: {} using profile: {}", user, profile);
}
}
use of org.jvnet.libpam.PAMException in project knox by apache.
the class KnoxPamRealm method doGetAuthenticationInfo.
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
UnixUser user = null;
try {
user = (new PAM(this.getService())).authenticate(upToken.getUsername(), new String(upToken.getPassword()));
} catch (PAMException e) {
handleAuthFailure(token, e.getMessage(), e);
}
HashRequest.Builder builder = new HashRequest.Builder();
Hash credentialsHash = hashService.computeHash(builder.setSource(token.getCredentials()).setAlgorithmName(HASHING_ALGORITHM).build());
/* Coverity Scan CID 1361684 */
if (credentialsHash == null) {
handleAuthFailure(token, "Failed to compute hash", null);
}
return new SimpleAuthenticationInfo(new UnixUserPrincipal(user), credentialsHash.toHex(), credentialsHash.getSalt(), getName());
}
Aggregations