Example usage for org.apache.maven.settings.crypto DefaultSettingsDecryptionRequest DefaultSettingsDecryptionRequest

List of usage examples for org.apache.maven.settings.crypto DefaultSettingsDecryptionRequest DefaultSettingsDecryptionRequest

Introduction

In this page you can find the example usage for org.apache.maven.settings.crypto DefaultSettingsDecryptionRequest DefaultSettingsDecryptionRequest.

Prototype

public DefaultSettingsDecryptionRequest() 

Source Link

Document

Creates an empty request.

Usage

From source file:com.isomorphic.maven.mojo.DeployMojo.java

License:Apache License

/**
 * Decrypt settings and return the server element with the given id.  Useful for e.g., reading encrypted 
 * user credentials./*from w  w  w  .j  a  v a  2  s .c  om*/
 * 
 * @param id the id of the server to be decrypted
 * @return a Server with its protected elements decrypted, if one is found with the given id.  Null otherwise.
 * 
 * @see http://maven.apache.org/guides/mini/guide-encryption.html
 */
private Server getDecryptedServer(String id) {
    final SettingsDecryptionRequest settingsDecryptionRequest = new DefaultSettingsDecryptionRequest();
    settingsDecryptionRequest.setServers(settings.getServers());
    final SettingsDecryptionResult decrypt = settingsDecrypter.decrypt(settingsDecryptionRequest);
    List<Server> servers = decrypt.getServers();

    for (Server server : servers) {
        if (server.getId().equals(id)) {
            return server;
        }
    }
    return null;
}

From source file:com.mycila.maven.plugin.license.AbstractLicenseMojo.java

License:Apache License

/**
 * Returns the list of servers with decrypted passwords.
 *
 * @return list of servers with decrypted passwords.
 *//*w w  w  .  j ava  2 s  . c o  m*/
List<Server> getDecryptedServers() {
    final SettingsDecryptionRequest settingsDecryptionRequest = new DefaultSettingsDecryptionRequest();
    settingsDecryptionRequest.setServers(settings.getServers());
    final SettingsDecryptionResult decrypt = settingsDecrypter.decrypt(settingsDecryptionRequest);
    return decrypt.getServers();
}

From source file:com.sap.research.maven.plugin.nwcloud.NWCloudGetPwd.java

License:Apache License

/**
 * Returns List of Server objects defined by Maven settings having the passwords decrypted.
 * @return List of Servers with decrypted passwords.
 *//*w  ww  .j  ava2s. c  om*/
private List<Server> getDecryptedServers() {

    List<Server> result = null;

    if (settings != null) {
        result = settings.getServers();
        if (result != null) {
            if (settingsDecrypter != null) {
                SettingsDecryptionRequest settingsDecryptionRequest = new DefaultSettingsDecryptionRequest();
                settingsDecryptionRequest.setServers(result);
                SettingsDecryptionResult decrypt = settingsDecrypter.decrypt(settingsDecryptionRequest);
                result = decrypt.getServers();
            } else {
                getLog().info(
                        "Cannot decrypt the server settings as the SettingsDecrypter provided by Maven is null.");
            }
        } else {
            getLog().info("Servers defined in Maven settings are null.");
        }
    } else {
        getLog().info("Maven settings are null.");
    }

    return result;

}