use of org.jasypt.exceptions.EncryptionOperationNotPossibleException in project fabric8 by jboss-fuse.
the class FabricServiceImpl method substituteConfigurations.
/**
* Performs substitution to configuration based on the registered {@link PlaceholderResolver} instances.
*/
public Map<String, Map<String, String>> substituteConfigurations(final Map<String, Map<String, String>> configurations) {
final Map<String, PlaceholderResolver> resolversSnapshot = new HashMap<String, PlaceholderResolver>(placeholderResolvers);
// Check that all resolvers are available
Set<String> requiredSchemes = getSchemesForProfileConfigurations(configurations);
Set<String> availableSchemes = resolversSnapshot.keySet();
if (!availableSchemes.containsAll(requiredSchemes)) {
StringBuilder sb = new StringBuilder();
sb.append("Missing Placeholder Resolvers:");
for (String scheme : requiredSchemes) {
if (!availableSchemes.contains(scheme)) {
sb.append(" ").append(scheme);
}
}
throw new FabricException(sb.toString());
}
final Map<String, Map<String, String>> mutableConfigurations = new HashMap<>();
for (Entry<String, Map<String, String>> entry : configurations.entrySet()) {
String key = entry.getKey();
Map<String, String> value = new HashMap<>(entry.getValue());
mutableConfigurations.put(key, value);
}
final FabricService fabricService = this;
for (Map.Entry<String, Map<String, String>> entry : mutableConfigurations.entrySet()) {
final String pid = entry.getKey();
Map<String, String> props = entry.getValue();
Map<String, String> original = new HashMap<>(props);
for (Map.Entry<String, String> e : original.entrySet()) {
final String key = e.getKey();
final String value = e.getValue();
try {
props.put(key, InterpolationHelper.substVars(value, key, null, props, new InterpolationHelper.SubstitutionCallback() {
public String getValue(String toSubstitute) {
if (toSubstitute != null && toSubstitute.contains(":")) {
String scheme = toSubstitute.substring(0, toSubstitute.indexOf(":"));
return resolversSnapshot.get(scheme).resolve(fabricService, mutableConfigurations, pid, key, toSubstitute);
}
return substituteBundleProperty(toSubstitute, bundleContext);
}
}));
} catch (EncryptionOperationNotPossibleException exception) {
LOGGER.warn("Error resolving " + key, exception);
}
}
}
return mutableConfigurations;
}
use of org.jasypt.exceptions.EncryptionOperationNotPossibleException in project cloudbreak by hortonworks.
the class EncryptedStringConfig method register.
@PostConstruct
public void register() {
HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance();
registry.registerPBEStringEncryptor("hibernateStringEncryptor", new PBEStringEncryptor() {
@Override
public String encrypt(String message) {
StringEncryptor encryptor = (StringEncryptor) applicationContext.getBean("PBEStringCleanablePasswordEncryptor");
return encryptor.encrypt(message);
}
@Override
public String decrypt(String encryptedMessage) {
StringEncryptor encryptor = (StringEncryptor) applicationContext.getBean("PBEStringCleanablePasswordEncryptor");
try {
return encryptor.decrypt(encryptedMessage);
} catch (EncryptionOperationNotPossibleException e) {
StringEncryptor legacyEncryptor = (StringEncryptor) applicationContext.getBean("LegacyPBEStringCleanablePasswordEncryptor");
try {
return legacyEncryptor.decrypt(encryptedMessage);
} catch (EncryptionOperationNotPossibleException ignored) {
return encryptedMessage;
}
}
}
@Override
public void setPassword(String password) {
}
});
}
use of org.jasypt.exceptions.EncryptionOperationNotPossibleException in project simba-os by cegeka.
the class DatabaseLoginModule method verifyLoginData.
@Override
protected boolean verifyLoginData() throws FailedLoginException {
debug("Verifying credentials for user: " + getUsername());
boolean validCredentials = false;
try {
validCredentials = credentialService.checkCredentials(getUsername(), getPassword());
} catch (EncryptionOperationNotPossibleException legacyPasswordException) {
debug("Authentication failed");
throw new FailedLoginException(getUsername());
}
if (validCredentials) {
debug("Authentication succeeded");
return true;
}
debug("Authentication failed");
throw new FailedLoginException(getUsername());
}
Aggregations