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      public List<Server> getServers()
83      {
84          if ( servers == null )
85          {
86              servers = new ArrayList<Server>();
87          }
88  
89          return servers;
90      }
91  
92      public DefaultSettingsDecryptionRequest setServers( List<Server> servers )
93      {
94          this.servers = servers;
95  
96          return this;
97      }
98  
99      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 }