001package org.apache.maven.settings.crypto;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.ArrayList;
023import java.util.Arrays;
024import java.util.List;
025
026import org.apache.maven.settings.Proxy;
027import org.apache.maven.settings.Server;
028import org.apache.maven.settings.Settings;
029
030/**
031 * Collects parameters that control the decryption of settings.
032 * 
033 * @author Benjamin Bentmann
034 */
035public class DefaultSettingsDecryptionRequest
036    implements SettingsDecryptionRequest
037{
038
039    private List<Server> servers;
040
041    private List<Proxy> proxies;
042
043    /**
044     * Creates an empty request.
045     */
046    public DefaultSettingsDecryptionRequest()
047    {
048        // does nothing
049    }
050
051    /**
052     * Creates a new request to decrypt the specified settings.
053     * 
054     * @param settings The settings to decrypt, must not be {@code null}.
055     */
056    public DefaultSettingsDecryptionRequest( Settings settings )
057    {
058        setServers( settings.getServers() );
059        setProxies( settings.getProxies() );
060    }
061
062    /**
063     * Creates a new request to decrypt the specified server.
064     * 
065     * @param server The server to decrypt, must not be {@code null}.
066     */
067    public DefaultSettingsDecryptionRequest( Server server )
068    {
069        this.servers = new ArrayList<Server>( Arrays.asList( server ) );
070    }
071
072    /**
073     * Creates a new request to decrypt the specified proxy.
074     * 
075     * @param proxy The proxy to decrypt, must not be {@code null}.
076     */
077    public DefaultSettingsDecryptionRequest( Proxy proxy )
078    {
079        this.proxies = new ArrayList<Proxy>( Arrays.asList( proxy ) );
080    }
081
082    public List<Server> getServers()
083    {
084        if ( servers == null )
085        {
086            servers = new ArrayList<Server>();
087        }
088
089        return servers;
090    }
091
092    public DefaultSettingsDecryptionRequest setServers( List<Server> servers )
093    {
094        this.servers = servers;
095
096        return this;
097    }
098
099    public List<Proxy> getProxies()
100    {
101        if ( proxies == null )
102        {
103            proxies = new ArrayList<Proxy>();
104        }
105
106        return proxies;
107    }
108
109    public DefaultSettingsDecryptionRequest setProxies( List<Proxy> proxies )
110    {
111        this.proxies = proxies;
112
113        return this;
114    }
115
116}