diff options
author | Martin Stockhammer <martin_s@apache.org> | 2019-01-31 22:49:06 +0100 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2019-01-31 22:49:06 +0100 |
commit | 21220fcd57d228a7a87694998e354493e92eb978 (patch) | |
tree | 19b73236d4208233b687254b14629ec56bb17931 /archiva-modules/archiva-base/archiva-proxy-api | |
parent | 847727d57d17b35b108063b45999cff6d506da10 (diff) | |
download | archiva-21220fcd57d228a7a87694998e354493e92eb978.tar.gz archiva-21220fcd57d228a7a87694998e354493e92eb978.zip |
Starting refactoring of proxy handling.
Diffstat (limited to 'archiva-modules/archiva-base/archiva-proxy-api')
-rw-r--r-- | archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/NetworkProxy.java | 192 | ||||
-rw-r--r-- | archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnector.java | 11 | ||||
-rw-r--r-- | archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnectorRuleType.java | 55 | ||||
-rw-r--r-- | archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyHandler.java (renamed from archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyConnectors.java) | 15 |
4 files changed, 272 insertions, 1 deletions
diff --git a/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/NetworkProxy.java b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/NetworkProxy.java new file mode 100644 index 000000000..849a89384 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/NetworkProxy.java @@ -0,0 +1,192 @@ +package org.apache.archiva.proxy.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.Serializable; + +public class NetworkProxy + implements Serializable +{ + private String id; + + /** + * The network protocol to use with this proxy: "http", "socks-4" + * . + */ + private String protocol = "http"; + + /** + * The proxy host. + */ + private String host; + + /** + * The proxy port. + */ + private int port = 8080; + + /** + * The proxy user. + */ + private String username; + + /** + * The proxy password. + */ + private String password; + + /** + * @since 1.4-M3 + * + * use NTLM proxy + */ + private boolean useNtlm; + + public NetworkProxy() + { + // no op + } + + public NetworkProxy( String id, String protocol, String host, int port, String username, String password ) + { + this.id = id; + this.protocol = protocol; + this.host = host; + this.port = port; + this.username = username; + this.password = password; + } + + public String getId() + { + return id; + } + + public void setId( String id ) + { + this.id = id; + } + + public String getProtocol() + { + return protocol; + } + + public void setProtocol( String protocol ) + { + this.protocol = protocol; + } + + public String getHost() + { + return host; + } + + public void setHost( String host ) + { + this.host = host; + } + + public int getPort() + { + return port; + } + + public void setPort( int port ) + { + this.port = port; + } + + public String getUsername() + { + return username; + } + + public void setUsername( String username ) + { + this.username = username; + } + + public String getPassword() + { + return password; + } + + public void setPassword( String password ) + { + this.password = password; + } + + public boolean isUseNtlm() + { + return useNtlm; + } + + public void setUseNtlm( boolean useNtlm ) + { + this.useNtlm = useNtlm; + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( o == null || getClass() != o.getClass() ) + { + return false; + } + + NetworkProxy that = (NetworkProxy) o; + + if ( id != null ? !id.equals( that.id ) : that.id != null ) + { + return false; + } + + return true; + } + + @Override + public int hashCode() + { + int result = 629 + ( id != null ? id.hashCode() : 0 ); + return result; + } + + @Override + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append( "NetworkProxy" ); + sb.append( "{id='" ).append( id ).append( '\'' ); + sb.append( ", protocol='" ).append( protocol ).append( '\'' ); + sb.append( ", host='" ).append( host ).append( '\'' ); + sb.append( ", port=" ).append( port ); + sb.append( ", username='" ).append( username ).append( '\'' ); + //sb.append( ", password='" ).append( password ).append( '\'' ); + sb.append( ", useNtlm=" ).append( useNtlm ); + sb.append( '}' ); + return sb.toString(); + } +} + diff --git a/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnector.java b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnector.java index d653de572..8e8887b94 100644 --- a/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnector.java +++ b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnector.java @@ -49,6 +49,8 @@ public class ProxyConnector private boolean disabled; + private Map<String, String> properties; + public ProxyConnector() { // no op @@ -167,4 +169,13 @@ public class ProxyConnector { this.order = order; } + + + public Map<String, String> getProperties() { + return properties; + } + + public void setProperties(Map<String, String> properties) { + this.properties = properties; + } } diff --git a/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnectorRuleType.java b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnectorRuleType.java new file mode 100644 index 000000000..4f8417d37 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/ProxyConnectorRuleType.java @@ -0,0 +1,55 @@ +package org.apache.archiva.proxy.model; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * @author Olivier Lamy + * @since 1.4-M3 + */ +public enum ProxyConnectorRuleType +{ + WHITE_LIST( "whiteList" ), BLACK_LIST( "blackList" ); + + private String ruleType; + + private ProxyConnectorRuleType( String ruleType ) + { + this.ruleType = ruleType; + } + + public void setRuleType( String ruleType ) + { + this.ruleType = ruleType; + } + + public String getRuleType() + { + return ruleType; + } + + @Override + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append( "ProxyConnectorRuleType" ); + sb.append( "{ruleType='" ).append( ruleType ).append( '\'' ); + sb.append( '}' ); + return sb.toString(); + } +} diff --git a/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyHandler.java index 1216fe253..eee2d86d2 100644 --- a/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyConnectors.java +++ b/archiva-modules/archiva-base/archiva-proxy-api/src/main/java/org/apache/archiva/proxy/model/RepositoryProxyHandler.java @@ -22,17 +22,22 @@ package org.apache.archiva.proxy.model; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.policies.ProxyDownloadException; import org.apache.archiva.repository.ManagedRepositoryContent; +import org.apache.archiva.repository.RepositoryType; import java.nio.file.Path; import java.util.List; +import java.util.Map; /** * Handler for potential repository proxy connectors. * * */ -public interface RepositoryProxyConnectors +public interface RepositoryProxyHandler { + + List<RepositoryType> supports(); + /** * Performs the artifact fetch operation against the target repositories * of the provided source repository. @@ -88,4 +93,12 @@ public interface RepositoryProxyConnectors * repository as a source repository. */ boolean hasProxies( ManagedRepositoryContent repository ); + + void setNetworkProxies(Map<String, NetworkProxy> proxies); + + Map<String, NetworkProxy> getNetworkProxies(); + + NetworkProxy getNetworkProxy(String id); + + } |