1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.eclipse.jetty.security;
15
16 import javax.servlet.ServletContext;
17
18 import org.eclipse.jetty.http.security.Constraint;
19 import org.eclipse.jetty.security.Authenticator.Configuration;
20 import org.eclipse.jetty.security.authentication.BasicAuthenticator;
21 import org.eclipse.jetty.security.authentication.ClientCertAuthenticator;
22 import org.eclipse.jetty.security.authentication.DigestAuthenticator;
23 import org.eclipse.jetty.security.authentication.FormAuthenticator;
24 import org.eclipse.jetty.security.authentication.DeferredAuthenticator;
25 import org.eclipse.jetty.security.authentication.SessionCachingAuthenticator;
26 import org.eclipse.jetty.server.Server;
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 public class DefaultAuthenticatorFactory implements Authenticator.Factory
46 {
47 LoginService _loginService;
48
49 public Authenticator getAuthenticator(Server server, ServletContext context, Configuration configuration, IdentityService identityService, LoginService loginService)
50 {
51 String auth=configuration.getAuthMethod();
52 Authenticator authenticator=null;
53
54 if (auth==null || Constraint.__BASIC_AUTH.equalsIgnoreCase(auth))
55 authenticator=new BasicAuthenticator();
56 else if (Constraint.__DIGEST_AUTH.equalsIgnoreCase(auth))
57 authenticator=new DigestAuthenticator();
58 else if (Constraint.__FORM_AUTH.equalsIgnoreCase(auth))
59 authenticator=new SessionCachingAuthenticator(new FormAuthenticator());
60 if (Constraint.__CERT_AUTH.equalsIgnoreCase(auth)||Constraint.__CERT_AUTH2.equalsIgnoreCase(auth))
61 authenticator=new ClientCertAuthenticator();
62
63 if (configuration.isLazy() && authenticator!=null)
64 authenticator=new DeferredAuthenticator(authenticator);
65
66 return authenticator;
67 }
68
69
70
71
72
73
74 public LoginService getLoginService()
75 {
76 return _loginService;
77 }
78
79
80
81
82
83 public void setLoginService(LoginService loginService)
84 {
85 _loginService = loginService;
86 }
87
88 }