1 package org
.argeo
.cms
.util
;
3 import java
.util
.Locale
;
5 import javax
.security
.auth
.login
.LoginContext
;
6 import javax
.security
.auth
.login
.LoginException
;
7 import javax
.servlet
.http
.HttpServletRequest
;
9 import org
.argeo
.cms
.CmsException
;
10 import org
.argeo
.cms
.auth
.CurrentUser
;
11 import org
.argeo
.cms
.ui
.CmsImageManager
;
12 import org
.argeo
.cms
.ui
.CmsView
;
13 import org
.argeo
.cms
.ui
.UxContext
;
14 import org
.argeo
.cms
.widgets
.auth
.CmsLogin
;
15 import org
.argeo
.cms
.widgets
.auth
.CmsLoginShell
;
16 import org
.argeo
.eclipse
.ui
.specific
.UiContext
;
17 import org
.argeo
.node
.NodeConstants
;
18 import org
.argeo
.node
.security
.NodeAuthenticated
;
19 import org
.eclipse
.rap
.rwt
.RWT
;
20 import org
.eclipse
.rap
.rwt
.application
.EntryPoint
;
21 import org
.eclipse
.swt
.events
.SelectionListener
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
23 import org
.eclipse
.swt
.widgets
.Display
;
25 public class LoginEntryPoint
implements EntryPoint
, CmsView
{
26 // private final static Log log = LogFactory.getLog(WorkbenchLogin.class);
27 // private final Subject subject = new Subject();
28 private LoginContext loginContext
;
29 private UxContext uxContext
= null;
32 public int createUI() {
33 final Display display
= createDisplay();
34 UiContext
.setData(NodeAuthenticated
.KEY
, this);
35 CmsLoginShell loginShell
= createCmsLoginShell();
38 loginContext
= new LoginContext(NodeConstants
.LOGIN_CONTEXT_USER
, loginShell
);
40 } catch (LoginException e
) {
41 loginShell
.createUi();
43 while (!loginShell
.getShell().isDisposed()) {
44 if (!display
.readAndDispatch())
49 if (CurrentUser
.getUsername() == null)
51 uxContext
= new SimpleUxContext();
55 protected Display
createDisplay() {
59 protected int postLogin() {
63 protected HttpServletRequest
getRequest() {
64 return RWT
.getRequest();
67 protected CmsLoginShell
createCmsLoginShell() {
68 return new CmsLoginShell(this) {
71 public void createContents(Composite parent
) {
72 LoginEntryPoint
.this.createLoginPage(parent
, this);
76 protected void extendsCredentialsBlock(Composite credentialsBlock
, Locale selectedLocale
,
77 SelectionListener loginSelectionListener
) {
78 LoginEntryPoint
.this.extendsCredentialsBlock(credentialsBlock
, selectedLocale
, loginSelectionListener
);
85 * To be overridden. CmsLogin#createCredentialsBlock() should be called at
86 * some point in order to create the credentials composite. In order to use
87 * the default layout, call CmsLogin#defaultCreateContents() but <b>not</b>
88 * CmsLogin#createContent(), since it would lead to a stack overflow.
90 protected void createLoginPage(Composite parent
, CmsLogin login
) {
91 login
.defaultCreateContents(parent
);
94 protected void extendsCredentialsBlock(Composite credentialsBlock
, Locale selectedLocale
,
95 SelectionListener loginSelectionListener
) {
100 public void navigateTo(String state
) {
101 // TODO Auto-generated method stub
106 public void authChange(LoginContext loginContext
) {
107 this.loginContext
= loginContext
;
111 public void logout() {
112 if (loginContext
== null)
113 throw new CmsException("Login context should not bet null");
115 loginContext
.logout();
116 } catch (LoginException e
) {
117 throw new CmsException("Cannot log out", e
);
122 public void exception(Throwable e
) {
123 // TODO Auto-generated method stub
128 public LoginContext
getLoginContext() {
133 public CmsImageManager
getImageManager() {
134 // TODO Auto-generated method stub
139 public UxContext
getUxContext() {