X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fhttp%2FNodeHttp.java;h=4cc0b5538782df57c51d587c75f9bbfe6a7e4522;hb=35507e18257f2e9f59842ba5120fcd3f19c4cf4d;hp=901731aa063eb2c113d1376c33e85477a1413f4e;hpb=10f188b3b9f945789c34fc6124e9425e83938471;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 901731aa0..4cc0b5538 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,44 +32,23 @@ 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(); + if (repositories != null) + repositories.close(); } void registerRepositoryServlets(HttpService httpService, String alias, Repository repository) { @@ -111,7 +90,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) @@ -121,7 +100,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) @@ -130,6 +109,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; @@ -142,7 +122,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) { @@ -301,9 +281,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; @@ -331,6 +313,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; // }