]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.ui.rap/src/org/argeo/security/ui/rap/AnonymousEntryPoint.java
4977815ae86dc81011f1b7da8700235a43b30a36
2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.security
.ui
.rap
;
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
;
26 * RAP entry point which authenticates the subject as anonymous, for public
27 * unauthenticated access.
29 public class AnonymousEntryPoint
implements IEntryPoint
{
30 private final static Log log
= LogFactory
.getLog(AnonymousEntryPoint
.class);
33 * How many seconds to wait before invalidating the session if the user has
36 private Integer loginTimeout
= 1 * 60;
37 private Integer sessionTimeout
= 15 * 60;
40 public int createUI() {
41 // Short login timeout so that the modal dialog login doesn't hang
43 RWT
.getRequest().getSession().setMaxInactiveInterval(loginTimeout
);
45 if (log
.isDebugEnabled())
46 log
.debug("Anonymous THREAD=" + Thread
.currentThread().getId()
47 + ", sessionStore=" + RWT
.getSessionStore().getId());
50 final Display display
= PlatformUI
.createDisplay();
53 // final ILoginContext loginContext = SecureRapActivator
54 // .createLoginContext(SecureRapActivator.CONTEXT_SPRING_ANONYMOUS);
55 // Subject subject = null;
57 // loginContext.login();
58 // subject = loginContext.getSubject();
59 // } catch (LoginException e) {
60 // throw new ArgeoException(
61 // "Unexpected exception during authentication", e);
64 // // identify after successful login
65 // if (log.isDebugEnabled())
66 // log.debug("Authenticated " + subject);
67 // final String username = subject.getPrincipals().iterator().next()
70 // // Once the user is logged in, she can have a longer session timeout
71 // RWT.getRequest().getSession().setMaxInactiveInterval(sessionTimeout);
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);
82 // // RUN THE WORKBENCH
84 // Integer returnCode = null;
86 // returnCode = Subject.doAs(subject, new PrivilegedAction<Integer>() {
87 // public Integer run() {
88 // RapWorkbenchAdvisor workbenchAdvisor = new RapWorkbenchAdvisor(
90 // int result = PlatformUI.createAndRunWorkbench(display,
92 // return new Integer(result);
95 // logout(loginContext, username);
102 // private void logout(ILoginContext secureContext, String username) {
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);