]> git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.cms.integration/src/org/argeo/cms/websocket/CmsWebSocketConfigurator.java
Merge remote-tracking branch 'origin/unstable' into testing
[gpl/argeo-slc.git] / cms / org.argeo.cms.integration / src / org / argeo / cms / websocket / CmsWebSocketConfigurator.java
1 package org.argeo.cms.websocket;
2
3 /** <strong>Disabled until third party issues are solved.</strong>. Customises the initialisation of a new web socket. */
4 public class CmsWebSocketConfigurator {
5 //extends Configurator {
6 // public final static String WEBSOCKET_SUBJECT = "org.argeo.cms.websocket.subject";
7 //
8 // private final static CmsLog log = CmsLog.getLog(CmsWebSocketConfigurator.class);
9 // final static String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate";
10 //
11 // @Override
12 // public boolean checkOrigin(String originHeaderValue) {
13 // return true;
14 // }
15 //
16 // @Override
17 // public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
18 // try {
19 // return endpointClass.getDeclaredConstructor().newInstance();
20 // } catch (Exception e) {
21 // throw new IllegalArgumentException("Cannot get endpoint instance", e);
22 // }
23 // }
24 //
25 // @Override
26 // public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) {
27 // return requested;
28 // }
29 //
30 // @Override
31 // public String getNegotiatedSubprotocol(List<String> supported, List<String> requested) {
32 // if ((requested == null) || (requested.size() == 0))
33 // return "";
34 // if ((supported == null) || (supported.isEmpty()))
35 // return "";
36 // for (String possible : requested) {
37 // if (possible == null)
38 // continue;
39 // if (supported.contains(possible))
40 // return possible;
41 // }
42 // return "";
43 // }
44 //
45 // @Override
46 // public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
47 //
48 // RemoteAuthSession httpSession = new ServletHttpSession((javax.servlet.http.HttpSession) request.getHttpSession());
49 // if (log.isDebugEnabled() && httpSession != null)
50 // log.debug("Web socket HTTP session id: " + httpSession.getId());
51 //
52 // if (httpSession == null) {
53 // rejectResponse(response, null);
54 // }
55 // try {
56 // LoginContext lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_USER,
57 // new RemoteAuthCallbackHandler(httpSession));
58 // lc.login();
59 // if (log.isDebugEnabled())
60 // log.debug("Web socket logged-in as " + lc.getSubject());
61 // Subject.doAs(lc.getSubject(), new PrivilegedAction<Void>() {
62 //
63 // @Override
64 // public Void run() {
65 // sec.getUserProperties().put(ServletContextHelper.REMOTE_USER, AccessController.getContext());
66 // return null;
67 // }
68 //
69 // });
70 // } catch (Exception e) {
71 // rejectResponse(response, e);
72 // }
73 // }
74 //
75 // /**
76 // * Behaviour when the web socket could not be authenticated. Throws an
77 // * {@link IllegalStateException} by default.
78 // *
79 // * @param e can be null
80 // */
81 // protected void rejectResponse(HandshakeResponse response, Exception e) {
82 // // violent implementation, as suggested in
83 // // https://stackoverflow.com/questions/21763829/jsr-356-how-to-abort-a-websocket-connection-during-the-handshake
84 //// throw new IllegalStateException("Web socket cannot be authenticated");
85 // }
86 }