Example usage for org.apache.hadoop.security HadoopKerberosName getRealm

List of usage examples for org.apache.hadoop.security HadoopKerberosName getRealm

Introduction

In this page you can find the example usage for org.apache.hadoop.security HadoopKerberosName getRealm.

Prototype

public String getRealm() 

Source Link

Document

Get the realm of the name.

Usage

From source file:org.apache.drill.exec.rpc.BitConnectionConfig.java

License:Apache License

public Map<String, ?> getSaslClientProperties(final DrillbitEndpoint remoteEndpoint) throws IOException {
    final DrillProperties properties = DrillProperties.createEmpty();

    final UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
    if (loginUser.getAuthenticationMethod() == UserGroupInformation.AuthenticationMethod.KERBEROS) {
        final HadoopKerberosName loginPrincipal = new HadoopKerberosName(loginUser.getUserName());
        if (!useLoginPrincipal) {
            properties.setProperty(DrillProperties.SERVICE_PRINCIPAL, KerberosUtil.getPrincipalFromParts(
                    loginPrincipal.getShortName(), remoteEndpoint.getAddress(), loginPrincipal.getRealm()));
        } else {//from w ww . j  a  v a2  s. c  om
            properties.setProperty(DrillProperties.SERVICE_PRINCIPAL, loginPrincipal.toString());
        }
    }
    return properties.stringPropertiesAsMap();
}