]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.e4.rap/src/org/argeo/cms/e4/rap/CmsE4EntryPointFactory.java
Simplify Argeo Commons project structure
[lgpl/argeo-commons.git] / org.argeo.cms.e4.rap / src / org / argeo / cms / e4 / rap / CmsE4EntryPointFactory.java
1 package org.argeo.cms.e4.rap;
2
3 import java.security.PrivilegedAction;
4
5 import javax.security.auth.Subject;
6
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;
12
13 public class CmsE4EntryPointFactory extends E4EntryPointFactory {
14 public final static String DEFAULT_LIFECYCLE_URI = "bundleclass://org.argeo.cms.e4.rap/org.argeo.cms.e4.rap.CmsLoginLifecycle";
15
16 public CmsE4EntryPointFactory(E4ApplicationConfig config) {
17 super(config);
18 }
19
20 public CmsE4EntryPointFactory(String e4Xmi, String lifeCycleUri) {
21 super(defaultConfig(e4Xmi, lifeCycleUri));
22 }
23
24 public CmsE4EntryPointFactory(String e4Xmi) {
25 this(e4Xmi, DEFAULT_LIFECYCLE_URI);
26 }
27
28 public static E4ApplicationConfig defaultConfig(String e4Xmi, String lifeCycleUri) {
29 E4ApplicationConfig config = new E4ApplicationConfig(e4Xmi, lifeCycleUri, null, null, false, true, true);
30 return config;
31 }
32
33 @Override
34 public EntryPoint create() {
35 EntryPoint ep = createEntryPoint();
36 EntryPoint authEp = new EntryPoint() {
37
38 @Override
39 public int createUI() {
40 Subject subject = new Subject();
41 return Subject.doAs(subject, new PrivilegedAction<Integer>() {
42
43 @Override
44 public Integer run() {
45 // SPNEGO
46 // HttpServletRequest request = RWT.getRequest();
47 // String authorization = request.getHeader(HEADER_AUTHORIZATION);
48 // if (authorization == null || !authorization.startsWith("Negotiate")) {
49 // HttpServletResponse response = RWT.getResponse();
50 // response.setStatus(401);
51 // response.setHeader(HEADER_WWW_AUTHENTICATE, "Negotiate");
52 // response.setDateHeader("Date", System.currentTimeMillis());
53 // response.setDateHeader("Expires", System.currentTimeMillis() + (24 * 60 * 60
54 // * 1000));
55 // response.setHeader("Accept-Ranges", "bytes");
56 // response.setHeader("Connection", "Keep-Alive");
57 // response.setHeader("Keep-Alive", "timeout=5, max=97");
58 // // response.setContentType("text/html; charset=UTF-8");
59 // }
60
61 JavaScriptExecutor jsExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
62 Integer exitCode = ep.createUI();
63 jsExecutor.execute("location.reload()");
64 return exitCode;
65 }
66
67 });
68 }
69 };
70 return authEp;
71 }
72
73 protected EntryPoint createEntryPoint() {
74 return super.create();
75 }
76 }