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<>( 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<>( Arrays.asList( proxy ) ); 080 } 081 082 @Override 083 public List<Server> getServers() 084 { 085 if ( servers == null ) 086 { 087 servers = new ArrayList<>(); 088 } 089 090 return servers; 091 } 092 093 @Override 094 public DefaultSettingsDecryptionRequest setServers( List<Server> servers ) 095 { 096 this.servers = servers; 097 098 return this; 099 } 100 101 @Override 102 public List<Proxy> getProxies() 103 { 104 if ( proxies == null ) 105 { 106 proxies = new ArrayList<>(); 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}