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
36 public enum HttpAuthenticationMethods {
37
38 NO_AUTH(1), BASIC(2), NTLM(3), DIGEST(4);
39
40 private final int id;
41
42 private HttpAuthenticationMethods(int id) {
43 this.id = id;
44 }
45
46
47
48
49
50 public int getId() {
51 return id;
52 }
53
54
55
56
57
58
59
60 public AbstractAuthLogicHandler getNewHandler(ProxyIoSession proxyIoSession)
61 throws ProxyAuthException {
62 switch (this) {
63 case BASIC:
64 return new HttpBasicAuthLogicHandler(proxyIoSession);
65
66 case DIGEST:
67 return new HttpDigestAuthLogicHandler(proxyIoSession);
68
69 case NTLM:
70 return new HttpNTLMAuthLogicHandler(proxyIoSession);
71
72 case NO_AUTH:
73 return new HttpNoAuthLogicHandler(proxyIoSession);
74
75 default:
76 return null;
77 }
78 }
79 }