Search in sources :

Example 1 with DefaultSettingsDecrypter

use of org.apache.maven.settings.crypto.DefaultSettingsDecrypter in project spring-boot by spring-projects.

the class MavenSettingsReader method createSettingsDecrypter.

private SettingsDecrypter createSettingsDecrypter() {
    SettingsDecrypter settingsDecrypter = new DefaultSettingsDecrypter();
    setField(DefaultSettingsDecrypter.class, "securityDispatcher", settingsDecrypter, new SpringBootSecDispatcher());
    return settingsDecrypter;
}
Also used : SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) DefaultSettingsDecrypter(org.apache.maven.settings.crypto.DefaultSettingsDecrypter) DefaultSettingsDecrypter(org.apache.maven.settings.crypto.DefaultSettingsDecrypter)

Example 2 with DefaultSettingsDecrypter

use of org.apache.maven.settings.crypto.DefaultSettingsDecrypter in project karaf by apache.

the class MavenConfigurationSupport method decryptSettings.

/**
 * <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>
 */
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);
        }
    }
}
Also used : Field(java.lang.reflect.Field) Proxy(org.apache.maven.settings.Proxy) Server(org.apache.maven.settings.Server) DefaultSettingsDecrypter(org.apache.maven.settings.crypto.DefaultSettingsDecrypter) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult) DefaultSecDispatcher(org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher) SettingsProblem(org.apache.maven.settings.building.SettingsProblem)

Example 3 with DefaultSettingsDecrypter

use of org.apache.maven.settings.crypto.DefaultSettingsDecrypter in project spring-cloud-function by spring-cloud.

the class MavenSettingsReader method createSettingsDecrypter.

private SettingsDecrypter createSettingsDecrypter() {
    SettingsDecrypter settingsDecrypter = new DefaultSettingsDecrypter();
    setField(DefaultSettingsDecrypter.class, "securityDispatcher", settingsDecrypter, new SpringBootSecDispatcher());
    return settingsDecrypter;
}
Also used : SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) DefaultSettingsDecrypter(org.apache.maven.settings.crypto.DefaultSettingsDecrypter) DefaultSettingsDecrypter(org.apache.maven.settings.crypto.DefaultSettingsDecrypter)

Aggregations

DefaultSettingsDecrypter (org.apache.maven.settings.crypto.DefaultSettingsDecrypter)3 SettingsDecrypter (org.apache.maven.settings.crypto.SettingsDecrypter)2 Field (java.lang.reflect.Field)1 Proxy (org.apache.maven.settings.Proxy)1 Server (org.apache.maven.settings.Server)1 SettingsProblem (org.apache.maven.settings.building.SettingsProblem)1 DefaultSettingsDecryptionRequest (org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest)1 SettingsDecryptionResult (org.apache.maven.settings.crypto.SettingsDecryptionResult)1 DefaultSecDispatcher (org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher)1