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