use of org.jboss.security.vault.SecurityVaultException in project wildfly by wildfly.
the class MockRuntimeVaultReader method createVault.
public void createVault(final String fqn, 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 {
return SecurityVaultFactory.get(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) {
e.printStackTrace();
throw SecurityLogger.ROOT_LOGGER.vaultReaderException(e);
}
this.vault = vault;
}
use of org.jboss.security.vault.SecurityVaultException in project wildfly by wildfly.
the class CheckVaultedPassServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/plain");
final PrintWriter writer = resp.getWriter();
String vaultString = req.getParameter(VAULTED_PASS);
char[] password = "nopass".toCharArray();
if (vaultString != null) {
try {
password = SecurityVaultUtil.getValue(vaultString);
} catch (SecurityVaultException e) {
e.printStackTrace();
}
}
writer.write(password);
writer.close();
}
Aggregations