Search in sources :

Example 1 with Pam

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);
        }
    }
}
Also used : AuthenticationException(javax.security.sasl.AuthenticationException) Pam(net.sf.jpam.Pam)

Aggregations

AuthenticationException (javax.security.sasl.AuthenticationException)1 Pam (net.sf.jpam.Pam)1