View Javadoc
1   package org.apache.maven.settings.crypto;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.ArrayList;
23  import java.util.Arrays;
24  import java.util.List;
25  
26  import org.apache.maven.settings.Proxy;
27  import org.apache.maven.settings.Server;
28  import org.apache.maven.settings.Settings;
29  
30  /**
31   * Collects parameters that control the decryption of settings.
32   *
33   * @author Benjamin Bentmann
34   */
35  public class DefaultSettingsDecryptionRequest
36      implements SettingsDecryptionRequest
37  {
38  
39      private List<Server> servers;
40  
41      private List<Proxy> proxies;
42  
43      /**
44       * Creates an empty request.
45       */
46      public DefaultSettingsDecryptionRequest()
47      {
48          // does nothing
49      }
50  
51      /**
52       * Creates a new request to decrypt the specified settings.
53       *
54       * @param settings The settings to decrypt, must not be {@code null}.
55       */
56      public DefaultSettingsDecryptionRequest( Settings settings )
57      {
58          setServers( settings.getServers() );
59          setProxies( settings.getProxies() );
60      }
61  
62      /**
63       * Creates a new request to decrypt the specified server.
64       *
65       * @param server The server to decrypt, must not be {@code null}.
66       */
67      public DefaultSettingsDecryptionRequest( Server server )
68      {
69          this.servers = new ArrayList<Server>( Arrays.asList( server ) );
70      }
71  
72      /**
73       * Creates a new request to decrypt the specified proxy.
74       *
75       * @param proxy The proxy to decrypt, must not be {@code null}.
76       */
77      public DefaultSettingsDecryptionRequest( Proxy proxy )
78      {
79          this.proxies = new ArrayList<Proxy>( Arrays.asList( proxy ) );
80      }
81  
82      @Override
83      public List<Server> getServers()
84      {
85          if ( servers == null )
86          {
87              servers = new ArrayList<Server>();
88          }
89  
90          return servers;
91      }
92  
93      @Override
94      public DefaultSettingsDecryptionRequest setServers( List<Server> servers )
95      {
96          this.servers = servers;
97  
98          return this;
99      }
100 
101     @Override
102     public List<Proxy> getProxies()
103     {
104         if ( proxies == null )
105         {
106             proxies = new ArrayList<Proxy>();
107         }
108 
109         return proxies;
110     }
111 
112     @Override
113     public DefaultSettingsDecryptionRequest setProxies( List<Proxy> proxies )
114     {
115         this.proxies = proxies;
116 
117         return this;
118     }
119 
120 }