import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
-import javax.servlet.http.HttpSession;
import javax.websocket.Extension;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import javax.websocket.server.ServerEndpointConfig.Configurator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.api.NodeConstants;
-import org.argeo.cms.auth.HttpRequestCallbackHandler;
+import org.argeo.api.cms.CmsAuth;
+import org.argeo.api.cms.CmsLog;
+import org.argeo.cms.auth.RemoteAuthCallbackHandler;
+import org.argeo.cms.auth.RemoteAuthSession;
+import org.argeo.cms.servlet.ServletHttpSession;
import org.osgi.service.http.context.ServletContextHelper;
/** Customises the initialisation of a new web socket. */
public class CmsWebSocketConfigurator extends Configurator {
public final static String WEBSOCKET_SUBJECT = "org.argeo.cms.websocket.subject";
- private final static Log log = LogFactory.getLog(CmsWebSocketConfigurator.class);
+ private final static CmsLog log = CmsLog.getLog(CmsWebSocketConfigurator.class);
final static String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate";
@Override
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
- HttpSession httpSession = (HttpSession) request.getHttpSession();
+
+ RemoteAuthSession httpSession = new ServletHttpSession((javax.servlet.http.HttpSession) request.getHttpSession());
if (log.isDebugEnabled() && httpSession != null)
log.debug("Web socket HTTP session id: " + httpSession.getId());
rejectResponse(response, null);
}
try {
- LoginContext lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER,
- new HttpRequestCallbackHandler(httpSession));
+ LoginContext lc = new LoginContext(CmsAuth.LOGIN_CONTEXT_USER,
+ new RemoteAuthCallbackHandler(httpSession));
lc.login();
if (log.isDebugEnabled())
log.debug("Web socket logged-in as " + lc.getSubject());
// webServerConfig.put(InternalHttpConstants.WEBSOCKET_ENABLED, "true");
//}
//}
-