public static void install ( SecurityConfiguration config ) throws Exception { // install the security modules List < SecurityModule > modules = new ArrayList <> ( ) ; try { for ( SecurityModuleFactory moduleFactory : config . getSecurityModuleFactories ( ) ) { SecurityModule module = moduleFactory . createModule ( config ) ; // can be null if a SecurityModule is not supported in the current environment if ( module != null ) { module . install ( ) ; modules . add ( module ) ; } } } catch ( Exception ex ) { throw new Exception ( "unable to establish the security context" , ex ) ; } installedModules = modules ; // First check if we have Hadoop in the ClassPath. If not, we simply don't do anything. try { Class . forName ( "org.apache.hadoop.security.UserGroupInformation" , false , SecurityUtils . class . getClassLoader ( ) ) ; // install a security context // use the Hadoop login user as the subject of the installed security context if ( ! ( installedContext instanceof NoOpSecurityContext ) ) { LOG . warn ( "overriding previous security context" ) ; } UserGroupInformation loginUser = UserGroupInformation . getLoginUser ( ) ; installedContext = new HadoopSecurityContext ( loginUser ) ; } catch ( ClassNotFoundException e ) { LOG . info ( "Cannot install HadoopSecurityContext because Hadoop cannot be found in the Classpath." ) ; } catch ( LinkageError e ) { LOG . error ( "Cannot install HadoopSecurityContext." , e ) ; } }
Installs a process - wide security configuration .