use of net.sf.jpam.Pam in project hive by apache.
the class PamAuthenticationProviderImpl method Authenticate.
@Override
public void Authenticate(String user, String password) throws AuthenticationException {
if (pamServiceNames == null || pamServiceNames.trim().isEmpty()) {
throw new AuthenticationException("No PAM services are set.");
}
String errorMsg = "Error authenticating with the PAM service: ";
String[] pamServices = pamServiceNames.split(",");
for (String pamService : pamServices) {
try {
Pam pam = new Pam(pamService);
boolean isAuthenticated = pam.authenticateSuccessful(user, password);
if (!isAuthenticated) {
throw new AuthenticationException(errorMsg + pamService);
}
} catch (Throwable e) {
// the client nicely
throw new AuthenticationException(errorMsg + pamService, e);
}
}
}
Aggregations