X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fhttp%2FNodeHttp.java;h=b74b3815a082c9eb18640a814c0dbf017430367b;hb=34ba1b915e1d406f6574c0be93e1e9da3eab1978;hp=0de4cd29a67a38d6a3206e4fb3d9a29c88bccdf0;hpb=baccdf322cf7c6dda7b61f68d3a873be86c3089d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/http/NodeHttp.java b/org.argeo.cms/src/org/argeo/cms/internal/http/NodeHttp.java index 0de4cd29a..b74b3815a 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/http/NodeHttp.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/http/NodeHttp.java @@ -32,42 +32,20 @@ import org.osgi.util.tracker.ServiceTracker; public class NodeHttp implements KernelConstants { private final static Log log = LogFactory.getLog(NodeHttp.class); - // Filters - // private final RootFilter rootFilter; - - // private final DoSFilter dosFilter; - // private final QoSFilter qosFilter; + public final static String DEFAULT_SERVICE = "HTTP"; private final BundleContext bc = FrameworkUtil.getBundle(getClass()).getBundleContext(); private ServiceTracker repositories; private final ServiceTracker httpServiceTracker; - public NodeHttp() { - // rootFilter = new RootFilter(); - // dosFilter = new CustomDosFilter(); - // qosFilter = new QoSFilter(); + private String httpRealm = "Argeo"; + public NodeHttp() { httpServiceTracker = new PrepareHttpStc(); httpServiceTracker.open(); } - // class CustomDosFilter extends DoSFilter { - // @Override - // protected String extractUserId(ServletRequest request) { - // HttpSession httpSession = ((HttpServletRequest) request) - // .getSession(); - // if (isSessionAuthenticated(httpSession)) { - // String userId = ((SecurityContext) httpSession - // .getAttribute(SPRING_SECURITY_CONTEXT_KEY)) - // .getAuthentication().getName(); - // return userId; - // } - // return super.extractUserId(request); - // - // } - // } - public void destroy() { repositories.close(); } @@ -93,7 +71,8 @@ public class NodeHttp implements KernelConstants { try { httpService.unregister(webdavPath(alias)); httpService.unregister(remotingPath(alias)); - httpService.unregister(filesPath(alias)); + if (NodeConstants.HOME.equals(alias)) + httpService.unregister(filesPath(alias)); if (log.isDebugEnabled()) log.debug("Unregistered servlets for repository '" + alias + "'"); } catch (Exception e) { @@ -110,7 +89,7 @@ public class NodeHttp implements KernelConstants { Properties ip = new Properties(); ip.setProperty(WebdavServlet.INIT_PARAM_RESOURCE_CONFIG, HttpUtils.WEBDAV_CONFIG); ip.setProperty(WebdavServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, path); - httpService.registerServlet(path, webdavServlet, ip, new DataHttpContext()); + httpService.registerServlet(path, webdavServlet, ip, new DataHttpContext(httpRealm)); } void registerFilesServlet(HttpService httpService, String alias, Repository repository) @@ -120,7 +99,7 @@ public class NodeHttp implements KernelConstants { Properties ip = new Properties(); ip.setProperty(WebdavServlet.INIT_PARAM_RESOURCE_CONFIG, HttpUtils.WEBDAV_CONFIG); ip.setProperty(WebdavServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, path); - httpService.registerServlet(path, filesServlet, ip, new PrivateHttpContext()); + httpService.registerServlet(path, filesServlet, ip, new PrivateHttpContext(httpRealm, true)); } void registerRemotingServlet(HttpService httpService, String alias, Repository repository) @@ -129,6 +108,7 @@ public class NodeHttp implements KernelConstants { String path = remotingPath(alias); Properties ip = new Properties(); ip.setProperty(JcrRemotingServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, path); + ip.setProperty(JcrRemotingServlet.INIT_PARAM_AUTHENTICATE_HEADER, "Negotiate"); // Looks like a bug in Jackrabbit remoting init Path tmpDir; @@ -141,7 +121,7 @@ public class NodeHttp implements KernelConstants { ip.setProperty(RemotingServlet.INIT_PARAM_TMP_DIRECTORY, "remoting_" + alias); ip.setProperty(RemotingServlet.INIT_PARAM_PROTECTED_HANDLERS_CONFIG, HttpUtils.DEFAULT_PROTECTED_HANDLERS); ip.setProperty(RemotingServlet.INIT_PARAM_CREATE_ABSOLUTE_URI, "false"); - httpService.registerServlet(path, remotingServlet, ip, new PrivateHttpContext()); + httpService.registerServlet(path, remotingServlet, ip, new PrivateHttpContext(httpRealm)); } private String webdavPath(String alias) { @@ -300,9 +280,11 @@ public class NodeHttp implements KernelConstants { // e.getException()); // } } + } private class RemotingServlet extends JcrRemotingServlet { + private final Log log = LogFactory.getLog(RemotingServlet.class); private static final long serialVersionUID = 4605238259548058883L; private final Repository repository; private final SessionProvider sessionProvider; @@ -330,6 +312,8 @@ public class NodeHttp implements KernelConstants { // Subject.doAs(subject, new PrivilegedExceptionAction() { // @Override // public Void run() throws Exception { + if (log.isTraceEnabled()) + HttpUtils.logRequest(log, request); RemotingServlet.super.service(request, response); // return null; // }