in emr-user-role-mapper-application/src/main/java/com/amazon/aws/emr/mapping/MappingInvoker.java [52:84]
void init() {
try {
String className = applicationConfiguration.getProperty(Constants.ROLE_MAPPER_CLASS,
Constants.ROLE_MAPPING_DEFAULT_CLASSNAME);
log.info("Trying to load {}", className);
if (isS3BasedProviderImpl(className)) {
// For our default mapper implementation we need at least the S3 bucket name and key
Constructor c = Class.forName(className)
.getConstructor(String.class, String.class, PrincipalResolver.class);
String bucketName = applicationConfiguration
.getProperty(Constants.ROLE_MAPPING_S3_BUCKET, null);
String key = applicationConfiguration
.getProperty(Constants.ROLE_MAPPING_S3_KEY, null);
roleMapperProvider = (UserRoleMapperProvider) c
.newInstance(bucketName, key, principalResolver);
log.info("Successfully created the mapper using {}/{}", bucketName, key);
} else {
Class clazz = Class.forName(className);
roleMapperProvider = (UserRoleMapperProvider) clazz.newInstance();
}
roleMapperProvider.init(applicationConfiguration.asMap());
log.info("Initialized the mapper.");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
log.error("Could not load the mapper " + e.getMessage());
throw new RuntimeException("Could not load the mapper class", e);
} catch (Throwable t) {
log.error("Could not load the mapper " + t.getMessage());
throw new RuntimeException("Could not load the mapper class", t);
}
int refreshIntervalMins = Integer.parseInt(applicationConfiguration.getProperty
(Constants.ROLE_MAPPPING_REFRESH_INTERVAL_MIN, Constants.ROLE_MAPPPING_DEFAULT_REFRESH_INTERVAL_MIN));
createRefreshTask(Math.max(Constants.ROLE_MAPPING_MIN_REFRESH_INTERVAL_MIN, refreshIntervalMins));
}