]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/AnonymousEntryPoint.java
Remove the 'Logout' entry point from plugin.xml after corresponding class deletion
[lgpl/argeo-commons.git] / org.argeo.security.ui.rap / src / org / argeo / security / ui / rap / AnonymousEntryPoint.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.security.ui.rap;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.eclipse.rap.rwt.RWT;
21 import org.eclipse.rap.rwt.application.IEntryPoint;
22 import org.eclipse.swt.widgets.Display;
23 import org.eclipse.ui.PlatformUI;
24
25 /**
26 * RAP entry point which authenticates the subject as anonymous, for public
27 * unauthenticated access.
28 */
29 public class AnonymousEntryPoint implements IEntryPoint {
30 private final static Log log = LogFactory.getLog(AnonymousEntryPoint.class);
31
32 /**
33 * How many seconds to wait before invalidating the session if the user has
34 * not yet logged in.
35 */
36 private Integer loginTimeout = 1 * 60;
37 private Integer sessionTimeout = 15 * 60;
38
39 @Override
40 public int createUI() {
41 // Short login timeout so that the modal dialog login doesn't hang
42 // around too long
43 RWT.getRequest().getSession().setMaxInactiveInterval(loginTimeout);
44
45 if (log.isDebugEnabled())
46 log.debug("Anonymous THREAD=" + Thread.currentThread().getId()
47 + ", sessionStore=" + RWT.getSessionStore().getId());
48
49 // create display
50 final Display display = PlatformUI.createDisplay();
51
52 // log in
53 // final ILoginContext loginContext = SecureRapActivator
54 // .createLoginContext(SecureRapActivator.CONTEXT_SPRING_ANONYMOUS);
55 // Subject subject = null;
56 // try {
57 // loginContext.login();
58 // subject = loginContext.getSubject();
59 // } catch (LoginException e) {
60 // throw new ArgeoException(
61 // "Unexpected exception during authentication", e);
62 // }
63 //
64 // // identify after successful login
65 // if (log.isDebugEnabled())
66 // log.debug("Authenticated " + subject);
67 // final String username = subject.getPrincipals().iterator().next()
68 // .getName();
69 //
70 // // Once the user is logged in, she can have a longer session timeout
71 // RWT.getRequest().getSession().setMaxInactiveInterval(sessionTimeout);
72 //
73 // // Logout callback when the display is disposed
74 // display.disposeExec(new Runnable() {
75 // public void run() {
76 // log.debug("Display disposed");
77 // logout(loginContext, username);
78 // }
79 // });
80 //
81 // //
82 // // RUN THE WORKBENCH
83 // //
84 // Integer returnCode = null;
85 // try {
86 // returnCode = Subject.doAs(subject, new PrivilegedAction<Integer>() {
87 // public Integer run() {
88 // RapWorkbenchAdvisor workbenchAdvisor = new RapWorkbenchAdvisor(
89 // null);
90 // int result = PlatformUI.createAndRunWorkbench(display,
91 // workbenchAdvisor);
92 // return new Integer(result);
93 // }
94 // });
95 // logout(loginContext, username);
96 // } finally {
97 // display.dispose();
98 // }
99 return 1;
100 }
101
102 // private void logout(ILoginContext secureContext, String username) {
103 // try {
104 // secureContext.logout();
105 // log.info("Logged out " + (username != null ? username : "")
106 // + " (THREAD=" + Thread.currentThread().getId() + ")");
107 // } catch (LoginException e) {
108 // log.error("Erorr when logging out", e);
109 // }
110 // }
111 }