Search in sources :

Example 1 with Authenticator

use of org.apache.geode.security.Authenticator in project geode by apache.

the class HandShake method verifyCredentials.

/**
   * this could return either a Subject or a Principal depending on if it's integrated security or
   * not
   */
public static Object verifyCredentials(String authenticatorMethod, Properties credentials, Properties securityProperties, InternalLogWriter logWriter, InternalLogWriter securityLogWriter, DistributedMember member) throws AuthenticationRequiredException, AuthenticationFailedException {
    if (!AcceptorImpl.isAuthenticationRequired()) {
        return null;
    }
    Authenticator auth = null;
    try {
        if (AcceptorImpl.isIntegratedSecurity()) {
            return securityService.login(credentials);
        } else {
            Method instanceGetter = ClassLoadUtil.methodFromName(authenticatorMethod);
            auth = (Authenticator) instanceGetter.invoke(null, (Object[]) null);
            auth.init(securityProperties, logWriter, securityLogWriter);
            return auth.authenticate(credentials, member);
        }
    } catch (AuthenticationFailedException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new AuthenticationFailedException(ex.getMessage(), ex);
    } finally {
        if (auth != null)
            auth.close();
    }
}
Also used : AuthenticationFailedException(org.apache.geode.security.AuthenticationFailedException) Method(java.lang.reflect.Method) Authenticator(org.apache.geode.security.Authenticator) ServerRefusedConnectionException(org.apache.geode.cache.client.ServerRefusedConnectionException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) InternalGemFireException(org.apache.geode.InternalGemFireException) GatewayConfigurationException(org.apache.geode.cache.GatewayConfigurationException) EOFException(java.io.EOFException) AuthenticationFailedException(org.apache.geode.security.AuthenticationFailedException) GemFireConfigException(org.apache.geode.GemFireConfigException) IOException(java.io.IOException) AuthenticationRequiredException(org.apache.geode.security.AuthenticationRequiredException)

Aggregations

EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 GemFireConfigException (org.apache.geode.GemFireConfigException)1 InternalGemFireException (org.apache.geode.InternalGemFireException)1 GatewayConfigurationException (org.apache.geode.cache.GatewayConfigurationException)1 ServerRefusedConnectionException (org.apache.geode.cache.client.ServerRefusedConnectionException)1 AuthenticationFailedException (org.apache.geode.security.AuthenticationFailedException)1 AuthenticationRequiredException (org.apache.geode.security.AuthenticationRequiredException)1 Authenticator (org.apache.geode.security.Authenticator)1 GemFireSecurityException (org.apache.geode.security.GemFireSecurityException)1