X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.ee%2Fsrc%2Forg%2Fargeo%2Fcms%2Fwebsocket%2Fserver%2FCmsWebSocketConfigurator.java;h=4dfdc5d2154ae524d644ae94f790b3673018f8dd;hb=5b6b49fa655c7b3ae3dcc06d6c504e3d0225684f;hp=279b610b6edf8cb9d0ef57943cde4ae73762eafb;hpb=c2eb0b8ebd1c9df4923f5fb2298a4ae04237f65d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.ee/src/org/argeo/cms/websocket/server/CmsWebSocketConfigurator.java b/org.argeo.cms.ee/src/org/argeo/cms/websocket/server/CmsWebSocketConfigurator.java index 279b610b6..4dfdc5d21 100644 --- a/org.argeo.cms.ee/src/org/argeo/cms/websocket/server/CmsWebSocketConfigurator.java +++ b/org.argeo.cms.ee/src/org/argeo/cms/websocket/server/CmsWebSocketConfigurator.java @@ -1,10 +1,8 @@ package org.argeo.cms.websocket.server; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.List; -import javax.security.auth.Subject; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; import javax.websocket.Extension; @@ -27,11 +25,10 @@ import org.argeo.cms.servlet.CmsServletContext; * the initialisation of a new web socket. */ public class CmsWebSocketConfigurator extends Configurator { - public final static String WEBSOCKET_SUBJECT = "org.argeo.cms.websocket.subject"; - public final static String REMOTE_USER = "org.osgi.service.http.authentication.remote.user"; private final static CmsLog log = CmsLog.getLog(CmsWebSocketConfigurator.class); - final static String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate"; + + private final String httpAuthRealm = "Argeo"; @Override public boolean checkOrigin(String originHeaderValue) { @@ -90,31 +87,33 @@ public class CmsWebSocketConfigurator extends Configurator { lc = CmsAuth.USER.newLoginContext(new RemoteAuthCallbackHandler(remoteAuthRequest, remoteAuthResponse)); lc.login(); } catch (LoginException e) { - // FIXME better analyse failure so as not to try endlessly if (authIsRequired(remoteAuthRequest, remoteAuthResponse)) { - int statusCode = RemoteAuthUtils.askForWwwAuth(remoteAuthResponse, "Argeo", true); - remoteAuthResponse.setHeader("Status-Code", Integer.toString(statusCode)); + int statusCode = RemoteAuthUtils.askForWwwAuth(remoteAuthRequest, remoteAuthResponse, httpAuthRealm, + true); +// remoteAuthResponse.setHeader("Status-Code", Integer.toString(statusCode)); return; } else { lc = RemoteAuthUtils.anonymousLogin(remoteAuthRequest, remoteAuthResponse); } - if (lc == null) + if (lc == null) { rejectResponse(response, e); + return; + } } finally { Thread.currentThread().setContextClassLoader(currentThreadContextClassLoader); } - Subject subject = lc.getSubject(); - Subject.doAs(subject, new PrivilegedAction() { - - @Override - public Void run() { - // TODO also set login context in order to log out ? - RemoteAuthUtils.configureRequestSecurity(remoteAuthRequest); - return null; - } - - }); +// Subject subject = lc.getSubject(); +// Subject.doAs(subject, new PrivilegedAction() { +// +// @Override +// public Void run() { +// // TODO also set login context in order to log out ? +// RemoteAuthUtils.configureRequestSecurity(remoteAuthRequest); +// return null; +// } +// +// }); } protected boolean authIsRequired(RemoteAuthRequest remoteAuthRequest, RemoteAuthResponse remoteAuthResponse) {