Example usage for org.apache.hadoop.security.authorize ProxyUsers authorize

List of usage examples for org.apache.hadoop.security.authorize ProxyUsers authorize

Introduction

In this page you can find the example usage for org.apache.hadoop.security.authorize ProxyUsers authorize.

Prototype

@Deprecated
public static void authorize(UserGroupInformation user, String remoteAddress, Configuration conf)
        throws AuthorizationException 

Source Link

Document

This function is kept to provide backward compatibility.

Usage

From source file:org.apache.hive.service.auth.HiveAuthFactory.java

License:Apache License

public static void verifyProxyAccess(String realUser, String proxyUser, String ipAddress, HiveConf hiveConf)
        throws HiveSQLException {
    try {//w  ww .  j  a va  2s .  co m
        UserGroupInformation sessionUgi;
        if (UserGroupInformation.isSecurityEnabled()) {
            KerberosNameShim kerbName = ShimLoader.getHadoopShims().getKerberosNameShim(realUser);
            sessionUgi = UserGroupInformation.createProxyUser(kerbName.getServiceName(),
                    UserGroupInformation.getLoginUser());
        } else {
            sessionUgi = UserGroupInformation.createRemoteUser(realUser);
        }
        if (!proxyUser.equalsIgnoreCase(realUser)) {
            ProxyUsers.refreshSuperUserGroupsConfiguration(hiveConf);
            ProxyUsers.authorize(UserGroupInformation.createProxyUser(proxyUser, sessionUgi), ipAddress,
                    hiveConf);
        }
    } catch (IOException e) {
        throw new HiveSQLException("Failed to validate proxy privilege of " + realUser + " for " + proxyUser,
                "08S01", e);
    }
}