Pārlūkot izejas kodu

Move IRCAuthenticator into common, rename.

Change-Id: I8fb851ccb0d260197ca996fe0f351dc983b747cd
Reviewed-on: http://gerrit.dmdirc.com/3977
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
changes/77/3977/2
Chris Smith 9 gadus atpakaļ
vecāks
revīzija
e1a4076e4a

+ 1
- 3
src/com/dmdirc/parser/common/BaseSocketAwareParser.java Parādīt failu

@@ -22,8 +22,6 @@
22 22
 
23 23
 package com.dmdirc.parser.common;
24 24
 
25
-import com.dmdirc.parser.irc.IRCAuthenticator;
26
-
27 25
 import java.io.IOException;
28 26
 import java.net.Inet4Address;
29 27
 import java.net.Inet6Address;
@@ -162,7 +160,7 @@ public abstract class BaseSocketAwareParser extends BaseParser {
162 160
                 new Proxy(proxyType, new InetSocketAddress(proxyHost, proxyPort)));
163 161
 
164 162
         try {
165
-            final IRCAuthenticator ia = IRCAuthenticator.getIRCAuthenticator();
163
+            final ProxyAuthenticator ia = ProxyAuthenticator.getProxyAuthenticator();
166 164
             final URI serverUri = new URI(null, null, host.getHostName(), port,
167 165
                     null, null, null);
168 166
             try {

src/com/dmdirc/parser/irc/IRCAuthenticator.java → src/com/dmdirc/parser/common/ProxyAuthenticator.java Parādīt failu

@@ -19,7 +19,7 @@
19 19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 20
  * SOFTWARE.
21 21
  */
22
-package com.dmdirc.parser.irc;
22
+package com.dmdirc.parser.common;
23 23
 
24 24
 import java.net.Authenticator;
25 25
 import java.net.PasswordAuthentication;
@@ -31,11 +31,9 @@ import java.util.Map;
31 31
 import java.util.concurrent.Semaphore;
32 32
 
33 33
 /**
34
- * Handles proxy authentication for the parser.
35
- *
36
- * @see IRCParser
34
+ * Handles proxy authentication for a {@link BaseSocketAwareParser} to a proxy.
37 35
  */
38
-public final class IRCAuthenticator extends Authenticator {
36
+public final class ProxyAuthenticator extends Authenticator {
39 37
 
40 38
     /**
41 39
      * A version number for this class. It should be changed whenever the class
@@ -44,7 +42,7 @@ public final class IRCAuthenticator extends Authenticator {
44 42
      */
45 43
     private static final long serialVersionUID = 1;
46 44
     /** Singleton instance of IRCAuthenticator. */
47
-    private static IRCAuthenticator me;
45
+    private static ProxyAuthenticator me;
48 46
     /** List of authentication replies. */
49 47
     private final Map<String, PasswordAuthentication> replies = new HashMap<>();
50 48
     /** List of servers for each host. */
@@ -58,7 +56,7 @@ public final class IRCAuthenticator extends Authenticator {
58 56
      * This creates an IRCAuthenticator and registers it as the default
59 57
      * Authenticator.
60 58
      */
61
-    private IRCAuthenticator() {
59
+    private ProxyAuthenticator() {
62 60
 
63 61
         Authenticator.setDefault(this);
64 62
     }
@@ -68,9 +66,9 @@ public final class IRCAuthenticator extends Authenticator {
68 66
      *
69 67
      * @return The IRCAuthenticator instance.
70 68
      */
71
-    public static synchronized IRCAuthenticator getIRCAuthenticator() {
69
+    public static synchronized ProxyAuthenticator getProxyAuthenticator() {
72 70
         if (me == null) {
73
-            me = new IRCAuthenticator();
71
+            me = new ProxyAuthenticator();
74 72
         } else {
75 73
             // Make ourself the default authenticator again just incase.
76 74
             Authenticator.setDefault(me);
@@ -98,7 +96,7 @@ public final class IRCAuthenticator extends Authenticator {
98 96
         final String host = proxy.getHost();
99 97
         final int port = proxy.getPort();
100 98
         final PasswordAuthentication pass = new PasswordAuthentication(username, password.toCharArray());
101
-        final String fullhost = host.toLowerCase() + ":" + port;
99
+        final String fullhost = host.toLowerCase() + ':' + port;
102 100
 
103 101
         // Delete old username/password if one exists and then add the new one
104 102
         replies.remove(fullhost);
@@ -130,7 +128,7 @@ public final class IRCAuthenticator extends Authenticator {
130 128
         final String host = proxy.getHost();
131 129
         final int port = proxy.getPort();
132 130
 
133
-        final String fullhost = host.toLowerCase() + ":" + port;
131
+        final String fullhost = host.toLowerCase() + ':' + port;
134 132
 
135 133
         // See if any other servers are associated with this proxy.
136 134
         final List<URI> servers = owners.containsKey(fullhost) ? owners.get(fullhost) : new ArrayList<URI>();
@@ -156,7 +154,7 @@ public final class IRCAuthenticator extends Authenticator {
156 154
          * getRequestorType: SERVER
157 155
          */
158 156
 
159
-        final String fullhost = getRequestingHost().toLowerCase() + ":" + getRequestingPort();
157
+        final String fullhost = getRequestingHost().toLowerCase() + ':' + getRequestingPort();
160 158
         return replies.get(fullhost);
161 159
     }
162 160
 }

Notiek ielāde…
Atcelt
Saglabāt