private static UserGroupInformation createSecurityEnabledProxyUser ( String userToProxy , String fileLocation , Logger log ) throws IOException { if ( ! new File ( fileLocation ) . exists ( ) ) { throw new RuntimeException ( "hadoop token file doesn't exist." ) ; } log . info ( "Found token file. Setting " + HadoopSecurityManager . MAPREDUCE_JOB_CREDENTIALS_BINARY + " to " + fileLocation ) ; System . setProperty ( HadoopSecurityManager . MAPREDUCE_JOB_CREDENTIALS_BINARY , fileLocation ) ; UserGroupInformation loginUser = null ; loginUser = UserGroupInformation . getLoginUser ( ) ; log . info ( "Current logged in user is " + loginUser . getUserName ( ) ) ; UserGroupInformation proxyUser = UserGroupInformation . createProxyUser ( userToProxy , loginUser ) ; for ( Token < ? > token : loginUser . getTokens ( ) ) { proxyUser . addToken ( token ) ; } proxyUser . addCredentials ( loginUser . getCredentials ( ) ) ; return proxyUser ; }
Perform all the magic required to get the proxyUser in a securitized grid