01: /**
02: *
03: */package clime.messadmin.providers.user;
04:
05: import javax.servlet.http.HttpSession;
06:
07: import clime.messadmin.model.ISessionInfo;
08: import clime.messadmin.model.Server;
09: import clime.messadmin.model.Session;
10: import clime.messadmin.providers.spi.UserNameProvider;
11:
12: /**
13: * See if there is a HttpRequest remote user
14: * @author Cédrik LIME
15: */
16: public class HttpRequestRemoteUser implements UserNameProvider {
17:
18: /**
19: *
20: */
21: public HttpRequestRemoteUser() {
22: super ();
23: }
24:
25: /**
26: * {@inheritDoc}
27: */
28: public int getPriority() {
29: return 200;
30: }
31:
32: /**
33: * {@inheritDoc}
34: */
35: public Object guessUserFromSession(HttpSession httpSession) {
36: Object user = null;
37:
38: Session session = Server.getInstance().getSession(httpSession);
39: if (session != null) {
40: ISessionInfo sessionInfo = session.getSessionInfo();
41: if (sessionInfo != null) {
42: if (sessionInfo.getRemoteUser() != null) {
43: return sessionInfo.getRemoteUser();
44: } else if (sessionInfo.getUserPrincipal() != null) {
45: return sessionInfo.getUserPrincipal();
46: }
47: }
48: }
49:
50: return user;
51: }
52:
53: }
|