1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.security.authentication;
20
21 import javax.servlet.http.HttpServletRequest;
22 import javax.servlet.http.HttpServletResponse;
23 import javax.servlet.http.HttpSession;
24
25 import org.eclipse.jetty.security.Authenticator;
26 import org.eclipse.jetty.security.IdentityService;
27 import org.eclipse.jetty.security.LoginService;
28 import org.eclipse.jetty.server.session.AbstractSessionManager;
29
30 public abstract class LoginAuthenticator implements Authenticator
31 {
32 protected final DeferredAuthentication _deferred=new DeferredAuthentication(this);
33 protected LoginService _loginService;
34 protected IdentityService _identityService;
35 private boolean _renewSession;
36
37 protected LoginAuthenticator()
38 {
39 }
40
41 public void setConfiguration(AuthConfiguration configuration)
42 {
43 _loginService=configuration.getLoginService();
44 if (_loginService==null)
45 throw new IllegalStateException("No LoginService for "+this+" in "+configuration);
46 _identityService=configuration.getIdentityService();
47 if (_identityService==null)
48 throw new IllegalStateException("No IdentityService for "+this+" in "+configuration);
49 _renewSession=configuration.isSessionRenewedOnAuthentication();
50 }
51
52 public LoginService getLoginService()
53 {
54 return _loginService;
55 }
56
57
58
59
60
61
62
63
64
65
66
67 protected HttpSession renewSession(HttpServletRequest request, HttpServletResponse response)
68 {
69 HttpSession httpSession = request.getSession(false);
70
71
72
73 if (_renewSession && httpSession!=null && httpSession.getAttribute(AbstractSessionManager.SESSION_KNOWN_ONLY_TO_AUTHENTICATED)!=Boolean.TRUE)
74 {
75 synchronized (this)
76 {
77 httpSession = AbstractSessionManager.renewSession(request, httpSession,true);
78 }
79 }
80 return httpSession;
81 }
82 }