This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.proxy.model;
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.io.Serializable;
023import java.util.Arrays;
024import java.util.Objects;
025
026public class NetworkProxy
027        implements Serializable
028{
029    private String id;
030
031    /**
032     * The network protocol to use with this proxy: "http", "socks-4"
033     * .
034     */
035    private String protocol = "http";
036
037    /**
038     * The proxy host.
039     */
040    private String host;
041
042    /**
043     * The proxy port.
044     */
045    private int port = 8080;
046
047    /**
048     * The proxy user.
049     */
050    private String username;
051
052    /**
053     * The proxy password.
054     */
055    private char[] password;
056
057    /**
058     * @since 1.4-M3
059     *
060     * use NTLM proxy
061     */
062    private boolean useNtlm;
063
064    public NetworkProxy()
065    {
066        // no op
067    }
068
069    public NetworkProxy(String id, String protocol, String host, int port, String username, char[] password )
070    {
071        this.id = id;
072        this.protocol = protocol;
073        this.host = host;
074        this.port = port;
075        this.username = username;
076        setPassword(password);
077    }
078
079    public String getId()
080    {
081        return id;
082    }
083
084    public void setId( String id )
085    {
086        this.id = id;
087    }
088
089    public String getProtocol()
090    {
091        return protocol;
092    }
093
094    public void setProtocol( String protocol )
095    {
096        this.protocol = protocol;
097    }
098
099    public String getHost()
100    {
101        return host;
102    }
103
104    public void setHost( String host )
105    {
106        this.host = host;
107    }
108
109    public int getPort()
110    {
111        return port;
112    }
113
114    public void setPort( int port )
115    {
116        this.port = port;
117    }
118
119    public String getUsername()
120    {
121        return username;
122    }
123
124    public void setUsername( String username )
125    {
126        this.username = username;
127    }
128
129    public char[] getPassword()
130    {
131        return password;
132    }
133
134    public void setPassword(char[] password )
135    {
136        if (this.password!=null) {
137            Arrays.fill(this.password, '0');
138        }
139        this.password = Arrays.copyOf(password, password.length);
140    }
141
142    public boolean isUseNtlm()
143    {
144        return useNtlm;
145    }
146
147    public void setUseNtlm( boolean useNtlm )
148    {
149        this.useNtlm = useNtlm;
150    }
151
152    @Override
153    public boolean equals( Object o )
154    {
155        if ( this == o )
156        {
157            return true;
158        }
159        if ( o == null || getClass() != o.getClass() )
160        {
161            return false;
162        }
163
164        NetworkProxy that = (NetworkProxy) o;
165
166        return Objects.equals(id, that.id);
167    }
168
169    @Override
170    public int hashCode()
171    {
172        int result = 629 + ( id != null ? id.hashCode() : 0 );
173        return result;
174    }
175
176    @Override
177    public String toString()
178    {
179        final StringBuilder sb = new StringBuilder();
180        sb.append( "NetworkProxy" );
181        sb.append( "{id='" ).append( id ).append( '\'' );
182        sb.append( ", protocol='" ).append( protocol ).append( '\'' );
183        sb.append( ", host='" ).append( host ).append( '\'' );
184        sb.append( ", port=" ).append( port );
185        sb.append( ", username='" ).append( username ).append( '\'' );
186        //sb.append( ", password='" ).append( password ).append( '\'' );
187        sb.append( ", useNtlm=" ).append( useNtlm );
188        sb.append( '}' );
189        return sb.toString();
190    }
191}
192