createVault(fqn, null, options);
}
protected void createVault(final String fqn, final String module, final Map<String, Object> options) throws VaultReaderException {
Map<String, Object> vaultOptions = new HashMap<String, Object>(options);
SecurityVault vault = null;
try {
vault = AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityVault>() {
@Override
public SecurityVault run() throws Exception {
if (fqn == null || fqn.isEmpty()) {
return SecurityVaultFactory.get();
} else if (module == null ){
return SecurityVaultFactory.get(fqn);
} else {
return SecurityVaultFactory.get(getModuleClassLoader(module), fqn);
}
}
});
} catch (PrivilegedActionException e) {
Throwable t = e.getCause();
if (t instanceof SecurityVaultException) {
throw SecurityLogger.ROOT_LOGGER.vaultReaderException(t);
}
if (t instanceof RuntimeException) {
throw SecurityLogger.ROOT_LOGGER.runtimeException(t);
}
throw SecurityLogger.ROOT_LOGGER.runtimeException(t);
}
try {
vault.init(vaultOptions);
} catch (SecurityVaultException e) {
throw SecurityLogger.ROOT_LOGGER.vaultReaderException(e);
}
this.vault = vault;
}