use of org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException 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.sec.dispatcher.SecDispatcherException 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;
}
use of org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException in project fabric8 by jboss-fuse.
the class MavenSettingsDecrypter method decrypt.
public SettingsDecryptionResult decrypt(SettingsDecryptionRequest request) {
List<SettingsProblem> problems = new ArrayList<SettingsProblem>();
List<Server> servers = new ArrayList<Server>();
for (Server server : request.getServers()) {
server = server.clone();
servers.add(server);
try {
server.setPassword(decrypt(server.getPassword()));
} catch (SecDispatcherException e) {
problems.add(new DefaultSettingsProblem("Failed to decrypt password for server " + server.getId() + ": " + e.getMessage(), Severity.ERROR, "server: " + server.getId(), -1, -1, e));
}
try {
server.setPassphrase(decrypt(server.getPassphrase()));
} catch (SecDispatcherException e) {
problems.add(new DefaultSettingsProblem("Failed to decrypt passphrase for server " + server.getId() + ": " + e.getMessage(), Severity.ERROR, "server: " + server.getId(), -1, -1, e));
}
}
List<Proxy> proxies = new ArrayList<Proxy>();
for (Proxy proxy : request.getProxies()) {
proxy = proxy.clone();
proxies.add(proxy);
try {
proxy.setPassword(decrypt(proxy.getPassword()));
} catch (SecDispatcherException e) {
problems.add(new DefaultSettingsProblem("Failed to decrypt password for proxy " + proxy.getId() + ": " + e.getMessage(), Severity.ERROR, "proxy: " + proxy.getId(), -1, -1, e));
}
}
return new MavenSettingsDecryptionResult(servers, proxies, problems);
}
Aggregations