This project has retired. For details please refer to its Attic page.
NetworkProxy xref
View Javadoc
1   package org.apache.archiva.proxy.model;
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.io.Serializable;
23  import java.util.Arrays;
24  import java.util.Objects;
25  
26  public class NetworkProxy
27          implements Serializable
28  {
29      private String id;
30  
31      /**
32       * The network protocol to use with this proxy: "http", "socks-4"
33       * .
34       */
35      private String protocol = "http";
36  
37      /**
38       * The proxy host.
39       */
40      private String host;
41  
42      /**
43       * The proxy port.
44       */
45      private int port = 8080;
46  
47      /**
48       * The proxy user.
49       */
50      private String username;
51  
52      /**
53       * The proxy password.
54       */
55      private char[] password;
56  
57      /**
58       * @since 1.4-M3
59       *
60       * use NTLM proxy
61       */
62      private boolean useNtlm;
63  
64      public NetworkProxy()
65      {
66          // no op
67      }
68  
69      public NetworkProxy(String id, String protocol, String host, int port, String username, char[] password )
70      {
71          this.id = id;
72          this.protocol = protocol;
73          this.host = host;
74          this.port = port;
75          this.username = username;
76          setPassword(password);
77      }
78  
79      public String getId()
80      {
81          return id;
82      }
83  
84      public void setId( String id )
85      {
86          this.id = id;
87      }
88  
89      public String getProtocol()
90      {
91          return protocol;
92      }
93  
94      public void setProtocol( String protocol )
95      {
96          this.protocol = protocol;
97      }
98  
99      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./../../../org/apache/archiva/proxy/model/NetworkProxy.html#NetworkProxy">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