1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.proxy.handlers.http;
21
22 import org.apache.mina.proxy.ProxyAuthException;
23 import org.apache.mina.proxy.handlers.http.basic.HttpBasicAuthLogicHandler;
24 import org.apache.mina.proxy.handlers.http.basic.HttpNoAuthLogicHandler;
25 import org.apache.mina.proxy.handlers.http.digest.HttpDigestAuthLogicHandler;
26 import org.apache.mina.proxy.handlers.http.ntlm.HttpNTLMAuthLogicHandler;
27 import org.apache.mina.proxy.session.ProxyIoSession;
28
29
30
31
32
33
34
35 public enum HttpAuthenticationMethods {
36
37 NO_AUTH(1), BASIC(2), NTLM(3), DIGEST(4);
38
39 private final int id;
40
41 private HttpAuthenticationMethods(int id) {
42 this.id = id;
43 }
44
45
46
47
48
49 public int getId() {
50 return id;
51 }
52
53
54
55
56
57
58
59 public AbstractAuthLogicHandler getNewHandler(ProxyIoSession proxyIoSession)
60 throws ProxyAuthException {
61 return getNewHandler(this.id, proxyIoSession);
62 }
63
64
65
66
67
68
69
70
71 public static AbstractAuthLogicHandler getNewHandler(
72 int method, ProxyIoSession proxyIoSession)
73 throws ProxyAuthException {
74
75 if (method == BASIC.id)
76 return new HttpBasicAuthLogicHandler(proxyIoSession);
77 else
78 if (method == DIGEST.id)
79 return new HttpDigestAuthLogicHandler(proxyIoSession);
80 else
81 if (method == NTLM.id)
82 return new HttpNTLMAuthLogicHandler(proxyIoSession);
83 else
84 if (method == NO_AUTH.id)
85 return new HttpNoAuthLogicHandler(proxyIoSession);
86 else
87 return null;
88 }
89 }