use of org.sonatype.plexus.components.cipher.PlexusCipherException in project fabric8 by jboss-fuse.
the class MavenSecurityDispatcher method decrypt.
@Override
public String decrypt(String str) throws SecDispatcherException {
if (!isEncryptedString(str)) {
return str;
}
String bare = null;
try {
bare = cipher.unDecorate(str);
} catch (PlexusCipherException e1) {
throw new SecDispatcherException(e1);
}
Map<String, String> attr = stripAttributes(bare);
String res = null;
if (attr == null || attr.get("type") == null) {
String master = getMaster();
try {
res = cipher.decrypt(bare, master);
} catch (PlexusCipherException e) {
throw new SecDispatcherException("Unable to decrypt encrypted string", e);
}
} else {
String type = (String) attr.get(TYPE_ATTR);
throw new UnsupportedOperationException("Unable to lookup security dispatched of type " + type);
}
return res;
}
use of org.sonatype.plexus.components.cipher.PlexusCipherException in project fabric8 by jboss-fuse.
the class MavenPasswordAction method findMasterMavenPassword.
/**
* Searches for master Maven password configured in <code>settings-security.xml</code>
* @param securitySettingsInMavenConfig
* @param securitySettingsInAgentConfig
* @param securitySettingsInPaxConfig
* @param securitySettingsInImplicitLocation
* @return
*/
private String findMasterMavenPassword(String securitySettingsInMavenConfig, String securitySettingsInAgentConfig, String securitySettingsInPaxConfig, String securitySettingsInImplicitLocation) throws SecDispatcherException, PlexusCipherException {
if (command.cipher == null) {
System.out.println("Can't decrypt Maven master password: " + command.cipherInitializationProblem);
return null;
}
for (String loc : new String[] { securitySettingsInMavenConfig, securitySettingsInAgentConfig, securitySettingsInPaxConfig, securitySettingsInImplicitLocation }) {
if (loc == null) {
continue;
}
System.out.print("Looking up master Maven password in " + loc + "...");
if (new File(loc).isFile()) {
String decrypted = null;
try {
SettingsSecurity settingsSecurity = SecUtil.read(loc, true);
decrypted = command.cipher.decryptDecorated(settingsSecurity.getMaster(), DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION);
System.out.println(" Done!");
return decrypted;
} catch (Exception e) {
System.out.println(" Failure! (" + e.getMessage() + ")");
}
} else {
System.out.println(" Not found.");
}
}
return null;
}
Aggregations