List of usage examples for org.apache.maven.settings.crypto SettingsDecryptionResult getProblems
List<SettingsProblem> getProblems();
From source file:com.goodformobile.build.mobile.RIMSigningMojo.java
License:Apache License
public void execute() throws MojoExecutionException { getLog().info("RIMSigningMojo.execute()"); if (skipSigning) { getLog().info("Skipping signing."); return;/* w w w. j av a 2s . c om*/ } Settings settings = this.settings; Server server = settings.getServer(signingCredentialsServerId); if (server == null) { throw new MojoExecutionException("Unable to find server with the id[" + signingCredentialsServerId + "]. Please configure this in your settings.xml"); } String password = server.getPassword(); if (StringUtils.isEmpty(password)) { throw new MojoExecutionException("Unable to find password in settings.xml for server with the id[" + signingCredentialsServerId + "]."); } if (password.contains("{")) { SettingsDecryptionRequest settingsDecryptionRequest = new DefaultSettingsDecryptionRequest(server); SettingsDecryptionResult result = settingsDecrypter.decrypt(settingsDecryptionRequest); if (result.getProblems() != null && result.getProblems().size() > 0) { throw new MojoExecutionException( "Unable to decrypt password:" + result.getProblems().get(0).toString(), result.getProblems().get(0).getException()); } password = result.getServer().getPassword(); } File deliverablesDirectory = new File(project.getBuild().getDirectory() + File.separator + "deliverables"); if (signaturePath == null) { throw new MojoExecutionException( "signaturePath is null. Please specify the <signature.path> property pointing to the directory with your signatureTools.jar"); } Commandline commandLine = new Commandline("java -jar " + signaturePath.getAbsolutePath() + File.separator + "SignatureTool.jar -a -C -s -p " + password + " -r " + deliverablesDirectory.getAbsolutePath()); commandLine.setWorkingDirectory(project.getBasedir()); executeCommandLineToLogger(commandLine); String inputClassesDirectory = project.getBuild().getOutputDirectory(); if (bundleCodsInOutputJar) { try { FileUtils.copyDirectory( new File(project.getBuild().getDirectory() + File.separator + "deliverables"), new File(inputClassesDirectory), "*.cod", ""); } catch (IOException e) { throw new MojoExecutionException("Error copying files.", e); } } }
From source file:org.apache.karaf.maven.command.MavenConfigurationSupport.java
License:Apache License
/** * <p>Decrypts passwords inside correctly read <code>settings.xml</code>. Also tries to decrypt master password.</p> * <p>Not called implicitly for each action invocation.</p> *//*from w ww .ja v a 2 s . c o m*/ private void decryptSettings() throws Exception { if (mavenSecuritySettings != null && mavenSettings != null) { masterPassword = cipher.decryptDecorated(mavenSecuritySettings.getMaster(), masterMasterPassword); DefaultSecDispatcher dispatcher = new DefaultSecDispatcher(); DefaultSettingsDecrypter decrypter = new DefaultSettingsDecrypter(); try { dispatcher.setConfigurationFile(securitySettings.value.getAbsolutePath()); Field f = dispatcher.getClass().getDeclaredField("_cipher"); f.setAccessible(true); f.set(dispatcher, cipher); f = decrypter.getClass().getDeclaredField("securityDispatcher"); f.setAccessible(true); f.set(decrypter, dispatcher); DefaultSettingsDecryptionRequest req = new DefaultSettingsDecryptionRequest(mavenSettings); SettingsDecryptionResult res = decrypter.decrypt(req); if (res.getProblems() != null && res.getProblems().size() > 0) { for (SettingsProblem sp : res.getProblems()) { System.err.println(sp); } } for (Proxy proxy : res.getProxies()) { if (!cipher.isEncryptedString(proxy.getPassword())) { proxyPasswords.put(proxy.getId(), proxy.getPassword()); } } for (Server server : res.getServers()) { if (!cipher.isEncryptedString(server.getPassword())) { serverPasswords.put(server.getId(), server.getPassword()); } } } catch (Throwable t) { LOG.warn("Can't decrypt " + securitySettings.value, t); } } }
From source file:org.debian.dependency.sources.SCMSourceRetrieval.java
License:Apache License
@Override public String retrieveSource(final Artifact artifact, final File directory, final MavenSession session) throws SourceRetrievalException { MavenProject project = findProjectRoot(constructProject(artifact, session)); Scm scm = project.getScm();/*from w ww . j a v a 2 s .co m*/ if (scm == null) { return null; } SettingsDecryptionResult decryptionResult = settingsDecrypter .decrypt(new DefaultSettingsDecryptionRequest(session.getSettings())); for (SettingsProblem problem : decryptionResult.getProblems()) { getLogger().warn("Error decrypting settings (" + problem.getLocation() + ") : " + problem.getMessage(), problem.getException()); } try { // first we check developer connection CheckOutScmResult checkoutResult = null; String connection = scm.getDeveloperConnection(); try { checkoutResult = performCheckout(connection, determineVersion(scm), directory, decryptionResult.getServers()); } catch (ScmException e) { // we don't really care about the exception here because we will try the regular connection next getLogger().debug( "Unable to checkout sources using developer connection, trying standard connection", e); } // now the regular connection if it wasn't successful if (checkoutResult == null || !checkoutResult.isSuccess()) { connection = scm.getConnection(); checkoutResult = performCheckout(connection, determineVersion(scm), directory, decryptionResult.getServers()); } if (checkoutResult == null) { throw new SourceRetrievalException("No scm information available"); } else if (!checkoutResult.isSuccess()) { getLogger().error("Provider Message:"); getLogger().error(StringUtils.defaultString(checkoutResult.getProviderMessage())); getLogger().error("Commandline:"); getLogger().error(StringUtils.defaultString(checkoutResult.getCommandOutput())); throw new SourceRetrievalException("Unable to checkout files: " + StringUtils.defaultString(checkoutResult.getProviderMessage())); } return connection; } catch (ScmException e) { throw new SourceRetrievalException("Unable to checkout project", e); } }
From source file:org.eclipse.ebr.maven.EclipseIpLogUtil.java
License:Open Source License
private Server getServer(final String serverId, final Settings settings, final SettingsDecrypter settingsDecrypter) { for (Server server : settings.getServers()) { if (StringUtils.equals(server.getId(), serverId)) { final SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(server); final SettingsDecryptionResult result = settingsDecrypter.decrypt(request); server = result.getServer(); // log any detected problems for (final SettingsProblem problem : result.getProblems()) { getLog().warn(problem.getMessage(), problem.getException()); }//from www . j a va2 s.com return server; } } return null; }
From source file:org.eclipse.m2e.core.internal.embedder.MavenImpl.java
License:Open Source License
public Server decryptPassword(Server server) throws CoreException { SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(server); SettingsDecryptionResult result = lookup(SettingsDecrypter.class).decrypt(request); for (SettingsProblem problem : result.getProblems()) { log.warn(problem.getMessage(), problem.getException()); }//w w w.ja v a 2s . c o m return result.getServer(); }
From source file:org.eclipse.tycho.osgi.configuration.SettingsDecrypterHelper.java
License:Open Source License
private void logProblems(SettingsDecryptionResult decryptionResult) { boolean hasErrors = false; for (SettingsProblem problem : decryptionResult.getProblems()) { switch (problem.getSeverity()) { case FATAL: case ERROR: logger.error(problem.toString()); hasErrors = true;//from ww w. j a v a2 s. c om break; case WARNING: logger.warn(problem.toString()); break; default: throw new IllegalStateException("unknown problem severity: " + problem.getSeverity()); } } if (hasErrors) { throw new RuntimeException("Error(s) while decrypting. See details above."); } }
From source file:org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.MavenSettingsBuilder.java
License:Apache License
private Settings decryptPasswords(Settings settings) { File securitySettings = new File(DEFAULT_SETTINGS_SECURITY_PATH); String altSecuritySettings = SecurityActions.getProperty(ALT_SECURITY_SETTINGS_XML_LOCATION); String altSecuritySettingsDeprecated = SecurityActions .getProperty(ALT_SECURITY_SETTINGS_XML_LOCATION_DEPRECATED); // set alternate file if (altSecuritySettingsDeprecated != null && altSecuritySettingsDeprecated.length() > 0) { log.log(Level.WARNING,//from w w w .j a v a 2 s. c o m "Maven settings-security.xml location ({0}) set via deprecated property \"{1}\", please use \"{2}\" instead", new Object[] { altSecuritySettingsDeprecated, ALT_SECURITY_SETTINGS_XML_LOCATION_DEPRECATED, ALT_SECURITY_SETTINGS_XML_LOCATION }); securitySettings = new File(altSecuritySettingsDeprecated); } // set alternate file if (altSecuritySettings != null && altSecuritySettings.length() > 0) { securitySettings = new File(altSecuritySettings); } SettingsDecrypter decrypter = new MavenSettingsDecrypter(securitySettings); SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(settings); SettingsDecryptionResult result = decrypter.decrypt(request); if (result.getProblems().size() > 0) { StringBuilder sb = new StringBuilder("Found ").append(result.getProblems().size()) .append(" problems while trying to decrypt settings configuration."); int counter = 1; for (SettingsProblem problem : result.getProblems()) { sb.append(counter++).append("/ ").append(problem).append("\n"); } throw new InvalidConfigurationFileException(sb.toString()); } settings.setProxies(result.getProxies()); settings.setServers(result.getServers()); return settings; }
From source file:org.springframework.boot.cli.compiler.grape.SettingsXmlRepositorySystemSessionAutoConfiguration.java
License:Apache License
@Override public void apply(DefaultRepositorySystemSession session, RepositorySystem repositorySystem) { Settings settings = loadSettings();//from w ww .j ava 2 s .c o m SettingsDecryptionResult decryptionResult = decryptSettings(settings); if (!decryptionResult.getProblems().isEmpty()) { Log.error("Maven settings decryption failed. Some Maven repositories may be inaccessible"); // Continue - the encrypted credentials may not be used } session.setOffline(settings.isOffline()); session.setMirrorSelector(createMirrorSelector(settings)); session.setAuthenticationSelector(createAuthenticationSelector(decryptionResult.getServers())); session.setProxySelector(createProxySelector(decryptionResult.getProxies())); String localRepository = settings.getLocalRepository(); if (localRepository != null) { session.setLocalRepositoryManager( repositorySystem.newLocalRepositoryManager(session, new LocalRepository(localRepository))); } }
From source file:org.springframework.boot.cli.compiler.maven.MavenSettingsReader.java
License:Apache License
public MavenSettings readSettings() { Settings settings = loadSettings();/*from w w w. ja v a 2 s .c o m*/ SettingsDecryptionResult decrypted = decryptSettings(settings); if (!decrypted.getProblems().isEmpty()) { Log.error("Maven settings decryption failed. Some Maven repositories may be inaccessible"); // Continue - the encrypted credentials may not be used } return new MavenSettings(settings, decrypted); }
From source file:org.springframework.boot.loader.thin.MavenSettingsReader.java
License:Apache License
public MavenSettings readSettings() { Settings settings = loadSettings();//from ww w . j a v a 2 s . c o m SettingsDecryptionResult decrypted = decryptSettings(settings); if (!decrypted.getProblems().isEmpty()) { log.error("Maven settings decryption failed. Some Maven repositories may be inaccessible"); // Continue - the encrypted credentials may not be used } return new MavenSettings(settings, decrypted); }