1 package org
.argeo
.cms
.e4
.rap
;
3 import java
.security
.PrivilegedAction
;
5 import javax
.security
.auth
.Subject
;
7 import org
.eclipse
.rap
.e4
.E4ApplicationConfig
;
8 import org
.eclipse
.rap
.e4
.E4EntryPointFactory
;
9 import org
.eclipse
.rap
.rwt
.RWT
;
10 import org
.eclipse
.rap
.rwt
.application
.EntryPoint
;
11 import org
.eclipse
.rap
.rwt
.client
.service
.JavaScriptExecutor
;
13 public class CmsE4EntryPointFactory
extends E4EntryPointFactory
{
15 public CmsE4EntryPointFactory(E4ApplicationConfig config
) {
20 public EntryPoint
create() {
21 EntryPoint ep
= createEntryPoint();
22 EntryPoint authEp
= new EntryPoint() {
25 public int createUI() {
26 Subject subject
= new Subject();
27 return Subject
.doAs(subject
, new PrivilegedAction
<Integer
>() {
30 public Integer
run() {
32 // HttpServletRequest request = RWT.getRequest();
33 // String authorization = request.getHeader(HEADER_AUTHORIZATION);
34 // if (authorization == null || !authorization.startsWith("Negotiate")) {
35 // HttpServletResponse response = RWT.getResponse();
36 // response.setStatus(401);
37 // response.setHeader(HEADER_WWW_AUTHENTICATE, "Negotiate");
38 // response.setDateHeader("Date", System.currentTimeMillis());
39 // response.setDateHeader("Expires", System.currentTimeMillis() + (24 * 60 * 60
41 // response.setHeader("Accept-Ranges", "bytes");
42 // response.setHeader("Connection", "Keep-Alive");
43 // response.setHeader("Keep-Alive", "timeout=5, max=97");
44 // // response.setContentType("text/html; charset=UTF-8");
47 JavaScriptExecutor jsExecutor
= RWT
.getClient().getService(JavaScriptExecutor
.class);
48 Integer exitCode
= ep
.createUI();
49 jsExecutor
.execute("location.reload()");
59 protected EntryPoint
createEntryPoint() {
60 return super.create();
63 // private boolean login(Subject subject) {
64 // Display display = new Display();
65 // CmsView cmsView = new E4CmsView(subject);
66 // CmsLoginShell loginShell = new CmsLoginShell(cmsView);
67 // loginShell.setSubject(subject);
70 // LoginContext loginContext = new
71 // LoginContext(NodeConstants.LOGIN_CONTEXT_USER, subject, loginShell);
72 // loginContext.login();
73 // } catch (LoginException e) {
74 // loginShell.createUi();
77 // while (!loginShell.getShell().isDisposed()) {
78 // if (!display.readAndDispatch())
84 // if (CurrentUser.getUsername(subject) == null)
89 // private class E4CmsView implements CmsView {
90 // private LoginContext loginContext;
91 // private UxContext uxContext;
92 // private Subject subject;
94 // public E4CmsView(Subject subject) {
95 // this.subject = subject;
96 // uxContext = new SimpleUxContext();
100 // public UxContext getUxContext() {
105 // public void navigateTo(String state) {
106 // // TODO Auto-generated method stub
111 // public void authChange(LoginContext loginContext) {
112 // if (loginContext == null)
113 // throw new CmsException("Login context cannot be null");
114 // // logout previous login context
115 // // if (this.loginContext != null)
117 // // this.loginContext.logout();
118 // // } catch (LoginException e1) {
119 // // System.err.println("Could not log out: " + e1);
121 // this.loginContext = loginContext;
125 // public void logout() {
126 // if (loginContext == null)
127 // throw new CmsException("Login context should not bet null");
129 // CurrentUser.logoutCmsSession(loginContext.getSubject());
130 // loginContext.logout();
131 // } catch (LoginException e) {
132 // throw new CmsException("Cannot log out", e);
137 // public void exception(Throwable e) {
138 // log.error("Unexpected exception in Eclipse 4 RAP", e);
142 // public CmsImageManager getImageManager() {
143 // // TODO Auto-generated method stub
147 // protected Subject getSubject() {
152 // public boolean isAnonymous() {
153 // return CurrentUser.isAnonymous(getSubject());