]>
git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.cms.integration/src/org/argeo/cms/websocket/CmsWebSocketConfigurator.java
1 package org
.argeo
.cms
.websocket
;
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";
8 // private final static CmsLog log = CmsLog.getLog(CmsWebSocketConfigurator.class);
9 // final static String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate";
12 // public boolean checkOrigin(String originHeaderValue) {
17 // public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
19 // return endpointClass.getDeclaredConstructor().newInstance();
20 // } catch (Exception e) {
21 // throw new IllegalArgumentException("Cannot get endpoint instance", e);
26 // public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) {
31 // public String getNegotiatedSubprotocol(List<String> supported, List<String> requested) {
32 // if ((requested == null) || (requested.size() == 0))
34 // if ((supported == null) || (supported.isEmpty()))
36 // for (String possible : requested) {
37 // if (possible == null)
39 // if (supported.contains(possible))
46 // public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
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());
52 // if (httpSession == null) {
53 // rejectResponse(response, null);
56 // LoginContext lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_USER,
57 // new RemoteAuthCallbackHandler(httpSession));
59 // if (log.isDebugEnabled())
60 // log.debug("Web socket logged-in as " + lc.getSubject());
61 // Subject.doAs(lc.getSubject(), new PrivilegedAction<Void>() {
64 // public Void run() {
65 // sec.getUserProperties().put(ServletContextHelper.REMOTE_USER, AccessController.getContext());
70 // } catch (Exception e) {
71 // rejectResponse(response, e);
76 // * Behaviour when the web socket could not be authenticated. Throws an
77 // * {@link IllegalStateException} by default.
79 // * @param e can be null
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");