Example usage for org.apache.hadoop.security SaslPropertiesResolver getInstance

List of usage examples for org.apache.hadoop.security SaslPropertiesResolver getInstance

Introduction

In this page you can find the example usage for org.apache.hadoop.security SaslPropertiesResolver getInstance.

Prototype

public static SaslPropertiesResolver getInstance(Configuration conf) 

Source Link

Document

Returns an instance of SaslPropertiesResolver.

Usage

From source file:org.apache.giraph.comm.netty.SaslNettyClient.java

License:Apache License

/**
 * Create a SaslNettyClient for authentication with BSP servers.
 *///from   w  w  w .j a  v  a  2  s  . co m
public SaslNettyClient() {
    try {
        Token<? extends TokenIdentifier> token = createJobToken(new Configuration());
        if (LOG.isDebugEnabled()) {
            LOG.debug("SaslNettyClient: Creating SASL " + AuthMethod.DIGEST.getMechanismName()
                    + " client to authenticate to service at " + token.getService());
        }
        /*if[STATIC_SASL_SYMBOL]
        saslClient =
            Sasl.createSaslClient(
                new String[] { AuthMethod.DIGEST.getMechanismName() }, null,
                null, SaslRpcServer.SASL_DEFAULT_REALM, SaslRpcServer.SASL_PROPS,
                new SaslClientCallbackHandler(token));
        else[STATIC_SASL_SYMBOL]*/
        SaslPropertiesResolver saslPropsResolver = SaslPropertiesResolver.getInstance(new Configuration());
        saslClient = Sasl.createSaslClient(new String[] { AuthMethod.DIGEST.getMechanismName() }, null, null,
                SaslRpcServer.SASL_DEFAULT_REALM, saslPropsResolver.getDefaultProperties(),
                new SaslClientCallbackHandler(token));
        /*end[STATIC_SASL_SYMBOL]*/
    } catch (IOException e) {
        LOG.error("SaslNettyClient: Could not obtain job token for Netty "
                + "Client to use to authenticate with a Netty Server.");
        saslClient = null;
    }
}

From source file:org.apache.giraph.comm.netty.SaslNettyServer.java

License:Apache License

/**
 * Constructor//w  ww  .  j a  v  a 2s  . c om
 *
 * @param secretManager supplied by SaslServerHandler.
 * @param authMethod Authentication method
 */
public SaslNettyServer(JobTokenSecretManager secretManager, AuthMethod authMethod) throws IOException {
    /*if[HADOOP_1_SECRET_MANAGER]
    else[HADOOP_1_SECRET_MANAGER]*/
    super(authMethod);
    /*end[HADOOP_1_SECRET_MANAGER]*/
    if (LOG.isDebugEnabled()) {
        LOG.debug("SaslNettyServer: Secret manager is: " + secretManager + " with authmethod " + authMethod);
    }
    /*if[HADOOP_1_SECRET_MANAGER]
    else[HADOOP_1_SECRET_MANAGER]*/
    try {
        secretManager.checkAvailableForRead();
    } catch (StandbyException e) {
        LOG.error("SaslNettyServer: Could not read secret manager: " + e);
    }
    /*end[HADOOP_1_SECRET_MANAGER]*/
    try {
        SaslDigestCallbackHandler ch = new SaslNettyServer.SaslDigestCallbackHandler(secretManager);
        /*if[STATIC_SASL_SYMBOL]
        saslServer =
            Sasl.createSaslServer(
                SaslNettyServer.AuthMethod.DIGEST.getMechanismName(), null,
                SaslRpcServer.SASL_DEFAULT_REALM, SaslRpcServer.SASL_PROPS, ch);
        else[STATIC_SASL_SYMBOL]*/
        SaslPropertiesResolver saslPropsResolver = SaslPropertiesResolver.getInstance(new Configuration());
        saslServer = Sasl.createSaslServer(SaslNettyServer.AuthMethod.DIGEST.getMechanismName(), null,
                SaslRpcServer.SASL_DEFAULT_REALM, saslPropsResolver.getDefaultProperties(), ch);
        /*end[STATIC_SASL_SYMBOL]*/
    } catch (SaslException e) {
        LOG.error("SaslNettyServer: Could not create SaslServer: " + e);
    }
}