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

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

Introduction

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

Prototype

public Map<String, String> getDefaultProperties() 

Source Link

Document

The default Sasl Properties read from the configuration

Usage

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

License:Apache License

/**
 * Create a SaslNettyClient for authentication with BSP servers.
 *///from   w  ww.j  a v  a  2  s.c o  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//from ww w  .  ja  va  2  s.  c o m
 *
 * @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);
    }
}