<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.argeo.commons</groupId>
<version>2.1.13-SNAPSHOT</version>
</dependency>
- <!-- Minimal web target platform -->
+ <!-- Complete target platform -->
<dependency>
<groupId>org.argeo.commons</groupId>
<artifactId>org.argeo.security.dep.node</artifactId>
<type>pom</type>
<version>2.1.13-SNAPSHOT</version>
+ </dependency>
+
+ <!-- Third parties -->
+ <dependency>
+ <groupId>org.argeo.tp</groupId>
+ <artifactId>argeo-tp</artifactId>
+ <version>${version.argeo-distribution}</version>
<exclusions>
+ <!-- Equinox -->
+ <exclusion>
+ <groupId>org.argeo.tp.rap</groupId>
+ <artifactId>org.eclipse.equinox.security</artifactId>
+ </exclusion>
+ <!-- Databinding -->
+ <exclusion>
+ <groupId>org.argeo.tp.rap.platform</groupId>
+ <artifactId>com.ibm.icu.base</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.rap.platform</groupId>
+ <artifactId>org.eclipse.rap.jface.databinding</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.rap.platform</groupId>
+ <artifactId>org.eclipse.core.databinding</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.rap.platform</groupId>
+ <artifactId>org.eclipse.core.databinding.observable</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.rap.platform</groupId>
+ <artifactId>org.eclipse.core.databinding.property</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.rap.platform</groupId>
+ <artifactId>org.eclipse.core.databinding.beans</artifactId>
+ </exclusion>
+
<!-- Workbench -->
+ <exclusion>
+ <groupId>org.argeo.tp.rap.platform</groupId>
+ <artifactId>javax.xml</artifactId>
+ </exclusion>
<exclusion>
<groupId>org.argeo.tp.rap.platform</groupId>
<artifactId>org.eclipse.rap.ui.workbench</artifactId>
<groupId>org.argeo.tp.rap.platform</groupId>
<artifactId>org.eclipse.help</artifactId>
</exclusion>
+
+ <!-- Spring -->
+ <exclusion>
+ <groupId>org.argeo.tp.spring</groupId>
+ <artifactId>org.springframework.jdbc</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.spring</groupId>
+ <artifactId>org.springframework.web</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.spring</groupId>
+ <artifactId>org.springframework.web.servlet</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.spring</groupId>
+ <artifactId>org.springframework.ldap</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.spring</groupId>
+ <artifactId>org.springframework.aspects</artifactId>
+ </exclusion>
+
+ <!-- Spring Security -->
+ <exclusion>
+ <groupId>org.argeo.tp.spring.security</groupId>
+ <artifactId>org.springframework.security.aspects</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.spring.security</groupId>
+ <artifactId>org.springframework.security.ldap</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.spring.security</groupId>
+ <artifactId>org.springframework.security.web</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.argeo.tp.spring.security</groupId>
+ <artifactId>org.springframework.security.config</artifactId>
+ </exclusion>
+
+ <!-- Apache -->
+ <exclusion>
+ <groupId>org.argeo.tp.apache</groupId>
+ <artifactId>org.apache.tika.parser</artifactId>
+ </exclusion>
+ <!-- <exclusion> -->
+ <!-- <groupId>org.argeo.tp.apache.commons</groupId> -->
+ <!-- <artifactId>org.apache.commons.vfs</artifactId> -->
+ <!-- </exclusion> -->
+
+ <!-- Bouncycastle -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.argeo.tp.bouncycastle</groupId> -->
+ <!-- <artifactId>bcpkix</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.argeo.tp.bouncycastle</groupId> -->
+ <!-- <artifactId>bcmail</artifactId> -->
+ <!-- </exclusion> -->
+
+ <!-- Misc -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.argeo.tp</groupId> -->
+ <!-- <artifactId>org.junit</artifactId> -->
+ <!-- </exclusion> -->
+ <exclusion>
+ <groupId>org.argeo.tp</groupId>
+ <artifactId>org.joda.time</artifactId>
+ </exclusion>
+ <!-- <exclusion> -->
+ <!-- <groupId>org.argeo.tp.javax</groupId> -->
+ <!-- <artifactId>javax.mail</artifactId> -->
+ <!-- </exclusion> -->
+ <exclusion>
+ <groupId>org.argeo.tp</groupId>
+ <artifactId>org.objectweb.asm</artifactId>
+ </exclusion>
+ <!-- <exclusion> -->
+ <!-- <groupId>org.argeo.tp</groupId> -->
+ <!-- <artifactId>com.jcraft.jsch</artifactId> -->
+ <!-- </exclusion> -->
+
+ <!-- Require org.springframework.core repackaging -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.argeo.tp</groupId> -->
+ <!-- <artifactId>org.aspectj.weaver</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.argeo.tp.apache.ant</groupId> -->
+ <!-- <artifactId>org.apache.ant</artifactId> -->
+ <!-- </exclusion> -->
+ <!-- <exclusion> -->
+ <!-- <groupId>org.argeo.tp.apache.ant</groupId> -->
+ <!-- <artifactId>org.apache.ant.launch</artifactId> -->
+ <!-- </exclusion> -->
</exclusions>
</dependency>
+
</dependencies>
+ <profiles>
+ <profile>
+ <id>check-osgi</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.argeo.maven.plugins</groupId>
+ <artifactId>maven-argeo-osgi-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>check-osgi</id>
+ <phase>test</phase>
+ <goals>
+ <goal>equinox</goal>
+ </goals>
+ <configuration>
+ <onlyCheck>true</onlyCheck>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.argeo.commons</groupId>
<artifactId>org.argeo.security.dao.jackrabbit</artifactId>
<version>2.1.13-SNAPSHOT</version>
</dependency>
-
- <!-- Security (Standalone) -->
- <!-- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.security.dao.os</artifactId>
- <version>2.1.12-SNAPSHOT</version>
- </dependency>
- -->
- <dependency>
- <groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.server.jcr.mvc</artifactId>
- <version>2.1.13-SNAPSHOT</version>
- </dependency>
</dependencies>
<profiles>
<profile>
javax.jcr.security,\
org.eclipse.swt.widgets;version="0.0.0",\
org.eclipse.rap.*;resolution:=optional,\
+ org.argeo.jackrabbit.*;resolution:=optional,\
*
-# Useless
-#Private-Package: org.argeo.cms.internal.*
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.jcr.rememberme;
-
-import java.util.Date;
-
-import org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken;
-import org.springframework.security.web.authentication.rememberme.PersistentTokenRepository;
-
-public class JcrPersistentTokenRepository implements PersistentTokenRepository {
-
- public void createNewToken(PersistentRememberMeToken token) {
- // TODO Auto-generated method stub
-
- }
-
- public void updateToken(String series, String tokenValue, Date lastUsed) {
- // TODO Auto-generated method stub
-
- }
-
- public PersistentRememberMeToken getTokenForSeries(String seriesId) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void removeUserTokens(String username) {
- // TODO Auto-generated method stub
-
- }
-
-}
Import-Package: javax.servlet,\
org.apache.jackrabbit.webdav.server,\
-org.springframework.web.context,\
org.osgi.framework;version="0.0.0",\
org.xml.sax;version="0.0.0",\
org.apache.jackrabbit.webdav.jcr,\
</dependency>
<dependency>
<groupId>org.argeo.commons</groupId>
- <artifactId>org.argeo.server.jcr.mvc</artifactId>
+ <artifactId>org.argeo.server.jcr</artifactId>
<version>2.1.13-SNAPSHOT</version>
</dependency>
+<!-- <dependency> -->
+<!-- <groupId>org.argeo.commons</groupId> -->
+<!-- <artifactId>org.argeo.server.jcr.mvc</artifactId> -->
+<!-- <version>2.1.13-SNAPSHOT</version> -->
+<!-- <scope>compile</scope> -->
+<!-- </dependency> -->
<!-- Jackrabbit -->
<!-- <dependency> -->
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import org.apache.jackrabbit.server.SessionProvider;
-import org.argeo.jcr.mvc.MultipleRepositoryHandlerMapping;
-
-/** Base class for Jackrabbit handler mappings. */
-public abstract class AbstractJackrabbitHandlerMapping extends
- MultipleRepositoryHandlerMapping {
- private SessionProvider sessionProvider;
-
- protected SessionProvider getSessionProvider() {
- return sessionProvider;
- }
-
- public void setSessionProvider(SessionProvider sessionProvider) {
- this.sessionProvider = sessionProvider;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-import org.springframework.web.servlet.DispatcherServlet;
-
-/**
- * Overrides Spring {@link DispatcherServlet}, see
- * http://forum.springsource.org/showthread.php?t=53472.
- */
-public class ExtendedDispatcherServlet extends DispatcherServlet {
- private static final long serialVersionUID = -5584673209855752009L;
-
- private final static Log log = LogFactory
- .getLog(ExtendedDispatcherServlet.class);
-
- protected void service(HttpServletRequest request,
- HttpServletResponse response) throws ServletException,
- java.io.IOException {
- try {
- if (log.isTraceEnabled()) {
- log.trace("SessionID = " + request.getSession().getId());
- log.trace(" ContextPath = " + request.getContextPath());
- log.trace(" ServletPath = " + request.getServletPath());
- log.trace(" PathInfo = " + request.getPathInfo());
- log.trace(" Method = " + request.getMethod());
- log.trace(" User-Agent = " + request.getHeader("User-Agent"));
- }
- doService(request, response);
- } catch (Exception e) {
- throw new ArgeoException("Cannot process request", e);
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import java.io.IOException;
-
-import org.apache.jackrabbit.server.io.ExportContext;
-import org.apache.jackrabbit.server.io.IOHandler;
-import org.apache.jackrabbit.server.io.IOManager;
-import org.apache.jackrabbit.server.io.ImportContext;
-import org.apache.jackrabbit.webdav.DavResource;
-import org.argeo.ArgeoException;
-
-/** Wraps an IOHandler so that it can be injected a posteriori */
-public class IOHandlerWrapper implements IOHandler {
- private IOManager ioManager = null;
- private IOHandler ioHandler = null;
-
- public void setIOHandler(IOHandler ioHandler) {
- if ((this.ioHandler != null) && (ioHandler != null))
- throw new ArgeoException(
- "There is already an IO Handler registered");
- this.ioHandler = ioHandler;
- if (ioManager != null && this.ioHandler != null)
- ioHandler.setIOManager(ioManager);
- }
-
- public IOHandler getIOHandler() {
- return ioHandler;
- }
-
- public IOManager getIOManager() {
- return ioManager;
- }
-
- public void setIOManager(IOManager ioManager) {
- this.ioManager = ioManager;
- if (ioHandler != null)
- ioHandler.setIOManager(ioManager);
- }
-
- public String getName() {
- if (ioHandler != null)
- return ioHandler.getName();
- else
- return "Empty IOHandler Wrapper";
- }
-
- public boolean canImport(ImportContext context, boolean isCollection) {
- if (ioHandler != null)
- return ioHandler.canImport(context, isCollection);
- return false;
- }
-
- public boolean canImport(ImportContext context, DavResource resource) {
- if (ioHandler != null)
- return ioHandler.canImport(context, resource);
- return false;
- }
-
- public boolean importContent(ImportContext context, boolean isCollection)
- throws IOException {
- if (ioHandler != null)
- ioHandler.importContent(context, isCollection);
- return false;
- }
-
- public boolean importContent(ImportContext context, DavResource resource)
- throws IOException {
- if (ioHandler != null)
- ioHandler.importContent(context, resource);
- return false;
- }
-
- public boolean canExport(ExportContext context, boolean isCollection) {
- if (ioHandler != null)
- ioHandler.canExport(context, isCollection);
- return false;
- }
-
- public boolean canExport(ExportContext context, DavResource resource) {
- if (ioHandler != null)
- ioHandler.canExport(context, resource);
- return false;
- }
-
- public boolean exportContent(ExportContext context, boolean isCollection)
- throws IOException {
- if (ioHandler != null)
- ioHandler.exportContent(context, isCollection);
- return false;
- }
-
- public boolean exportContent(ExportContext context, DavResource resource)
- throws IOException {
- if (ioHandler != null)
- ioHandler.exportContent(context, resource);
- return false;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.jackrabbit.server.io.ExportContext;
-import org.apache.jackrabbit.server.io.IOHandler;
-import org.apache.jackrabbit.server.io.IOManager;
-import org.apache.jackrabbit.server.io.ImportContext;
-import org.apache.jackrabbit.webdav.DavResource;
-import org.apache.tika.detect.Detector;
-
-/** {@link IOManager} that can easily be configured as a bean. */
-public class IOManagerBean implements IOManager {
- private Detector detector = null;
- private List<IOHandler> ioHandlers = new ArrayList<IOHandler>();
-
- public boolean importContent(ImportContext context, boolean isCollection)
- throws IOException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean importContent(ImportContext context, DavResource resource)
- throws IOException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean exportContent(ExportContext context, boolean isCollection)
- throws IOException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean exportContent(ExportContext context, DavResource resource)
- throws IOException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public synchronized void addIOHandler(IOHandler ioHandler) {
- ioHandlers.add(ioHandler);
- }
-
- public synchronized IOHandler[] getIOHandlers() {
- return ioHandlers.toArray(new IOHandler[ioHandlers.size()]);
- }
-
- public Detector getDetector() {
- return detector;
- }
-
- public void setDetector(Detector detector) {
- this.detector = detector;
- }
-
- public synchronized List<IOHandler> getIoHandlers() {
- return ioHandlers;
- }
-
- public synchronized void setIoHandlers(List<IOHandler> ioHandlers) {
- this.ioHandlers = ioHandlers;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import java.util.Properties;
-
-import javax.jcr.Repository;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-
-public class JcrRemotingHandlerMapping extends AbstractJackrabbitHandlerMapping {
-
- protected HttpServlet createServlet(Repository repository, String pathPrefix)
- throws ServletException {
- JcrRemotingServlet servlet = new JcrRemotingServlet(repository,
- getSessionProvider());
- Properties initParameters = new Properties();
- initParameters.setProperty(
- JcrRemotingServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, pathPrefix);
- servlet.init(new DelegatingServletConfig(pathPrefix.replace('/', '_'),
- initParameters));
- return servlet;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import javax.jcr.Repository;
-
-import org.apache.jackrabbit.server.SessionProvider;
-
-public class JcrRemotingServlet extends
- org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet {
-
- private static final long serialVersionUID = 3131835511468341309L;
-
- private final Repository repository;
- private final SessionProvider sessionProvider;
-
- public JcrRemotingServlet(Repository repository,
- SessionProvider sessionProvider) {
- this.repository = repository;
- this.sessionProvider = sessionProvider;
- }
-
- @Override
- protected Repository getRepository() {
- return repository;
- }
-
- @Override
- protected SessionProvider getSessionProvider() {
- return sessionProvider;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import java.io.Serializable;
-
-import javax.jcr.LoginException;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.server.SessionProvider;
-import org.argeo.jcr.JcrUtils;
-
-/**
- * Implements an open session in view patter: a new JCR session is created for
- * each request
- */
-public class OpenInViewSessionProvider implements SessionProvider, Serializable {
- private static final long serialVersionUID = 2270957712453841368L;
-
- private final static Log log = LogFactory
- .getLog(OpenInViewSessionProvider.class);
-
- public Session getSession(HttpServletRequest request, Repository rep,
- String workspace) throws LoginException, ServletException,
- RepositoryException {
- return login(request, rep, workspace);
- }
-
- protected Session login(HttpServletRequest request, Repository repository,
- String workspace) throws RepositoryException {
- if (log.isTraceEnabled())
- log.trace("Login to workspace "
- + (workspace == null ? "<default>" : workspace)
- + " in web session " + request.getSession().getId());
- return repository.login(workspace);
- }
-
- public void releaseSession(Session session) {
- JcrUtils.logoutQuietly(session);
- if (log.isTraceEnabled())
- log.trace("Logged out remote JCR session " + session);
- }
-
- public void init() {
- }
-
- public void destroy() {
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import java.io.Serializable;
-
-import javax.jcr.LoginException;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.server.SessionProvider;
-import org.argeo.ArgeoException;
-import org.argeo.jcr.ArgeoJcrConstants;
-import org.argeo.jcr.JcrUtils;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-
-/**
- * Session provider assuming a single workspace and a short life cycle,
- * typically a Spring bean of scope (web) 'session'.
- */
-public class ScopedSessionProvider implements SessionProvider, Serializable {
- private static final long serialVersionUID = 6589775984177317058L;
- private static final Log log = LogFactory
- .getLog(ScopedSessionProvider.class);
- private transient HttpSession httpSession = null;
- private transient Session jcrSession = null;
-
- private transient String currentRepositoryName = null;
- private transient String currentWorkspaceName = null;
- private transient String currentJcrUser = null;
-
- // private transient String anonymousUserId = "anonymous";
-
- public Session getSession(HttpServletRequest request, Repository rep,
- String workspace) throws LoginException, ServletException,
- RepositoryException {
-
- Authentication authentication = SecurityContextHolder.getContext()
- .getAuthentication();
- if (authentication == null)
- throw new ArgeoException(
- "Request not authenticated by Spring Security");
- String springUser = authentication.getName();
-
- // HTTP
- String requestJcrRepository = (String) request
- .getAttribute(ArgeoJcrConstants.JCR_REPOSITORY_ALIAS);
-
- // HTTP session
- if (httpSession != null
- && !httpSession.getId().equals(request.getSession().getId()))
- throw new ArgeoException(
- "Only session scope is supported in this mode");
- if (httpSession == null)
- httpSession = request.getSession();
-
- // Initializes current values
- if (currentRepositoryName == null)
- currentRepositoryName = requestJcrRepository;
- if (currentWorkspaceName == null)
- currentWorkspaceName = workspace;
- if (currentJcrUser == null)
- currentJcrUser = springUser;
-
- // logout if there was a change in session coordinates
- if (jcrSession != null)
- if (!currentRepositoryName.equals(requestJcrRepository)) {
- if (log.isDebugEnabled())
- log.debug(getHttpSessionId() + " Changed from repository '"
- + currentRepositoryName + "' to '"
- + requestJcrRepository
- + "', logging out cached JCR session.");
- logout();
- } else if (!currentWorkspaceName.equals(workspace)) {
- if (log.isDebugEnabled())
- log.debug(getHttpSessionId() + " Changed from workspace '"
- + currentWorkspaceName + "' to '" + workspace
- + "', logging out cached JCR session.");
- logout();
- } else if (!currentJcrUser.equals(springUser)) {
- if (log.isDebugEnabled())
- log.debug(getHttpSessionId() + " Changed from user '"
- + currentJcrUser + "' to '" + springUser
- + "', logging out cached JCR session.");
- logout();
- }
-
- // login if needed
- if (jcrSession == null)
- try {
- Session session = login(rep, workspace);
- if (!session.getUserID().equals(springUser)) {
- JcrUtils.logoutQuietly(session);
- throw new ArgeoException("Spring Security user '"
- + springUser + "' not in line with JCR user '"
- + session.getUserID() + "'");
- }
- currentRepositoryName = requestJcrRepository;
- // do not use workspace variable which may be null
- currentWorkspaceName = session.getWorkspace().getName();
- currentJcrUser = session.getUserID();
-
- jcrSession = session;
- return jcrSession;
- } catch (RepositoryException e) {
- throw new ArgeoException("Cannot open session to workspace "
- + workspace, e);
- }
-
- // returns cached session
- return jcrSession;
- }
-
- protected Session login(Repository repository, String workspace)
- throws RepositoryException {
- Session session = repository.login(workspace);
- if (log.isDebugEnabled())
- log.debug(getHttpSessionId() + " User '" + session.getUserID()
- + "' logged in workspace '"
- + session.getWorkspace().getName() + "' of repository '"
- + currentRepositoryName + "'");
- return session;
- }
-
- public void releaseSession(Session session) {
- if (log.isTraceEnabled())
- log.trace(getHttpSessionId() + " Releasing JCR session " + session);
- }
-
- protected void logout() {
- JcrUtils.logoutQuietly(jcrSession);
- jcrSession = null;
- }
-
- protected final String getHttpSessionId() {
- return httpSession != null ? httpSession.getId() : "<null>";
- }
-
- public void init() {
- }
-
- public void destroy() {
- logout();
- if (getHttpSessionId() != null)
- if (log.isDebugEnabled())
- log.debug(getHttpSessionId()
- + " Cleaned up provider for web session ");
- httpSession = null;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.LoginException;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.Value;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.security.user.Group;
-import org.apache.jackrabbit.api.security.user.User;
-import org.apache.jackrabbit.api.security.user.UserManager;
-import org.apache.jackrabbit.server.SessionProvider;
-import org.argeo.ArgeoException;
-import org.argeo.jcr.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.jcr.UserJcrUtils;
-
-/**
- * Implements an open session in view patter: a new JCR session is created for
- * each request
- *
- * @deprecated use {@link ScopedSessionProvider} or
- * {@link OpenInViewSessionProvider}
- */
-@Deprecated
-public class SimpleSessionProvider implements SessionProvider, Serializable {
- private static final long serialVersionUID = 2270957712453841368L;
-
- private final static Log log = LogFactory
- .getLog(SimpleSessionProvider.class);
-
- private transient Map<String, Session> sessions;
-
- private Boolean openSessionInView = true;
-
- private String defaultWorkspace = "default";
-
- private String webSessionId = null;
-
- public Session getSession(HttpServletRequest request, Repository rep,
- String workspace) throws LoginException, ServletException,
- RepositoryException {
-
- if (openSessionInView) {
- JackrabbitSession session = (JackrabbitSession) login(request, rep,
- workspace);
- if (session.getWorkspace().getName().equals(defaultWorkspace))
- writeRemoteRoles(session);
- return session;
- } else {
- if (webSessionId != null
- && !webSessionId.equals(request.getSession().getId()))
- throw new ArgeoException(
- "Only session scope is supported in this mode");
- webSessionId = request.getSession().getId();
-
- // since sessions is transient it can't be restored from the session
- if (sessions == null)
- sessions = Collections
- .synchronizedMap(new HashMap<String, Session>());
-
- if (!sessions.containsKey(workspace)) {
- try {
- // JackrabbitSession session = (JackrabbitSession)
- // rep.login(
- // null, workspace);
- JackrabbitSession session = (JackrabbitSession) login(
- request, rep, workspace);
- if (session.getWorkspace().getName()
- .equals(defaultWorkspace))
- writeRemoteRoles(session);
- if (log.isTraceEnabled())
- log.trace("User " + session.getUserID()
- + " logged into " + request.getServletPath());
- sessions.put(workspace, session);
- return session;
- } catch (Exception e) {
- throw new ArgeoException("Cannot open session", e);
- }
- } else {
- Session session = sessions.get(workspace);
- if (!session.isLive()) {
- sessions.remove(workspace);
- session = login(request, rep, workspace);
- sessions.put(workspace, session);
- }
- return session;
- }
- }
- }
-
- protected Session login(HttpServletRequest request, Repository repository,
- String workspace) throws RepositoryException {
- if (log.isDebugEnabled())
- log.debug("Login to workspace "
- + (workspace == null ? "<default>" : workspace)
- + " in web session " + request.getSession().getId());
- return repository.login(workspace);
- }
-
- protected void writeRemoteRoles(JackrabbitSession session)
- throws RepositoryException {
- // FIXME better deal w/ non node repo
-
- // retrieve roles
- String userId = session.getUserID();
- UserManager userManager = session.getUserManager();
- User user = (User) userManager.getAuthorizable(userId);
- if (user == null) {
- // anonymous
- return;
- }
- List<String> userGroupIds = new ArrayList<String>();
- if (user != null)
- for (Iterator<Group> it = user.memberOf(); it.hasNext();)
- userGroupIds.add(it.next().getID());
-
- // write roles if needed
- Node userHome = UserJcrUtils.getUserHome(session);
- boolean writeRoles = false;
- if (userHome.hasProperty(ArgeoNames.ARGEO_REMOTE_ROLES)) {
- Value[] roles = userHome.getProperty(ArgeoNames.ARGEO_REMOTE_ROLES)
- .getValues();
- if (roles.length != userGroupIds.size())
- writeRoles = true;
- else
- for (int i = 0; i < roles.length; i++)
- if (!roles[i].getString().equals(userGroupIds.get(i)))
- writeRoles = true;
- } else
- writeRoles = true;
-
- if (writeRoles) {
- session.getWorkspace().getVersionManager()
- .checkout(userHome.getPath());
- String[] roleIds = userGroupIds.toArray(new String[userGroupIds
- .size()]);
- userHome.setProperty(ArgeoNames.ARGEO_REMOTE_ROLES, roleIds);
- JcrUtils.updateLastModified(userHome);
- session.save();
- session.getWorkspace().getVersionManager()
- .checkin(userHome.getPath());
- }
-
- }
-
- public void releaseSession(Session session) {
- if (log.isTraceEnabled())
- log.trace("Releasing JCR session " + session);
- if (openSessionInView) {
- JcrUtils.logoutQuietly(session);
- if (log.isDebugEnabled())
- log.debug("Logged out remote JCR session " + session);
- }
- }
-
- public void init() {
- if (log.isDebugEnabled())
- log.debug("Init session provider for web session " + webSessionId);
- }
-
- public void destroy() {
- if (log.isDebugEnabled())
- log.debug("Destroy session provider for web session "
- + webSessionId);
-
- if (sessions != null)
- for (String workspace : sessions.keySet()) {
- Session session = sessions.get(workspace);
- JcrUtils.logoutQuietly(session);
- }
- }
-
- /**
- * If set to true a new session will be created each time (the default),
- * otherwise a single session is cached by workspace and the object should
- * be of scope session (not supported)
- */
- public void setOpenSessionInView(Boolean openSessionInView) {
- this.openSessionInView = openSessionInView;
- }
-
- public void setSecurityWorkspace(String securityWorkspace) {
- this.defaultWorkspace = securityWorkspace;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import java.util.Properties;
-
-import javax.jcr.Repository;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-
-/** Handler mapping for WebDav */
-public class SimpleWebdavHandlerMapping extends
- AbstractJackrabbitHandlerMapping {
- private String configuration;
-
- protected HttpServlet createServlet(Repository repository, String pathPrefix)
- throws ServletException {
-
- SimpleWebdavServlet servlet = new SimpleWebdavServlet(repository,
- getSessionProvider());
- Properties initParameters = new Properties();
- initParameters.setProperty(
- SimpleWebdavServlet.INIT_PARAM_RESOURCE_CONFIG, configuration);
- initParameters
- .setProperty(
- SimpleWebdavServlet.INIT_PARAM_RESOURCE_PATH_PREFIX,
- pathPrefix);
- servlet.init(new DelegatingServletConfig(pathPrefix.replace('/', '_'),
- initParameters));
- return servlet;
- }
-
- public void setConfiguration(String configuration) {
- this.configuration = configuration;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.jackrabbit.remote;
-
-import java.io.IOException;
-
-import javax.jcr.Repository;
-import javax.servlet.ServletException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.server.SessionProvider;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.DavResource;
-import org.apache.jackrabbit.webdav.WebdavRequest;
-import org.apache.jackrabbit.webdav.WebdavResponse;
-
-/** WebDav servlet whose repository is injected */
-public class SimpleWebdavServlet extends
- org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet {
- private static final long serialVersionUID = -369787931175177080L;
-
- private final static Log log = LogFactory.getLog(SimpleWebdavServlet.class);
-
- private final Repository repository;
-
- public SimpleWebdavServlet(Repository repository,
- SessionProvider sessionProvider) {
- this.repository = repository;
- setSessionProvider(sessionProvider);
- }
-
- public Repository getRepository() {
- return repository;
- }
-
- @Override
- protected boolean execute(WebdavRequest request, WebdavResponse response,
- int method, DavResource resource) throws ServletException,
- IOException, DavException {
- if (log.isTraceEnabled())
- log.trace(request.getMethod() + "\t" + request.getPathInfo());
- boolean res = super.execute(request, response, method, resource);
- return res;
- }
-
-}
javax.xml.parsers.*;version="0.0.0",\
org.w3c.dom.*;version="0.0.0",\
org.xml.sax.*;version="0.0.0",\
+org.apache.jackrabbit.server.remoting.davex,\
+org.apache.jackrabbit.webdav.server,\
*
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import org.apache.jackrabbit.server.SessionProvider;
+import org.argeo.jcr.mvc.MultipleRepositoryHandlerMapping;
+
+/** Base class for Jackrabbit handler mappings. */
+public abstract class AbstractJackrabbitHandlerMapping extends
+ MultipleRepositoryHandlerMapping {
+ private SessionProvider sessionProvider;
+
+ protected SessionProvider getSessionProvider() {
+ return sessionProvider;
+ }
+
+ public void setSessionProvider(SessionProvider sessionProvider) {
+ this.sessionProvider = sessionProvider;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.springframework.web.servlet.DispatcherServlet;
+
+/**
+ * Overrides Spring {@link DispatcherServlet}, see
+ * http://forum.springsource.org/showthread.php?t=53472.
+ */
+public class ExtendedDispatcherServlet extends DispatcherServlet {
+ private static final long serialVersionUID = -5584673209855752009L;
+
+ private final static Log log = LogFactory
+ .getLog(ExtendedDispatcherServlet.class);
+
+ protected void service(HttpServletRequest request,
+ HttpServletResponse response) throws ServletException,
+ java.io.IOException {
+ try {
+ if (log.isTraceEnabled()) {
+ log.trace("SessionID = " + request.getSession().getId());
+ log.trace(" ContextPath = " + request.getContextPath());
+ log.trace(" ServletPath = " + request.getServletPath());
+ log.trace(" PathInfo = " + request.getPathInfo());
+ log.trace(" Method = " + request.getMethod());
+ log.trace(" User-Agent = " + request.getHeader("User-Agent"));
+ }
+ doService(request, response);
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot process request", e);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import java.io.IOException;
+
+import org.apache.jackrabbit.server.io.ExportContext;
+import org.apache.jackrabbit.server.io.IOHandler;
+import org.apache.jackrabbit.server.io.IOManager;
+import org.apache.jackrabbit.server.io.ImportContext;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.argeo.ArgeoException;
+
+/** Wraps an IOHandler so that it can be injected a posteriori */
+public class IOHandlerWrapper implements IOHandler {
+ private IOManager ioManager = null;
+ private IOHandler ioHandler = null;
+
+ public void setIOHandler(IOHandler ioHandler) {
+ if ((this.ioHandler != null) && (ioHandler != null))
+ throw new ArgeoException(
+ "There is already an IO Handler registered");
+ this.ioHandler = ioHandler;
+ if (ioManager != null && this.ioHandler != null)
+ ioHandler.setIOManager(ioManager);
+ }
+
+ public IOHandler getIOHandler() {
+ return ioHandler;
+ }
+
+ public IOManager getIOManager() {
+ return ioManager;
+ }
+
+ public void setIOManager(IOManager ioManager) {
+ this.ioManager = ioManager;
+ if (ioHandler != null)
+ ioHandler.setIOManager(ioManager);
+ }
+
+ public String getName() {
+ if (ioHandler != null)
+ return ioHandler.getName();
+ else
+ return "Empty IOHandler Wrapper";
+ }
+
+ public boolean canImport(ImportContext context, boolean isCollection) {
+ if (ioHandler != null)
+ return ioHandler.canImport(context, isCollection);
+ return false;
+ }
+
+ public boolean canImport(ImportContext context, DavResource resource) {
+ if (ioHandler != null)
+ return ioHandler.canImport(context, resource);
+ return false;
+ }
+
+ public boolean importContent(ImportContext context, boolean isCollection)
+ throws IOException {
+ if (ioHandler != null)
+ ioHandler.importContent(context, isCollection);
+ return false;
+ }
+
+ public boolean importContent(ImportContext context, DavResource resource)
+ throws IOException {
+ if (ioHandler != null)
+ ioHandler.importContent(context, resource);
+ return false;
+ }
+
+ public boolean canExport(ExportContext context, boolean isCollection) {
+ if (ioHandler != null)
+ ioHandler.canExport(context, isCollection);
+ return false;
+ }
+
+ public boolean canExport(ExportContext context, DavResource resource) {
+ if (ioHandler != null)
+ ioHandler.canExport(context, resource);
+ return false;
+ }
+
+ public boolean exportContent(ExportContext context, boolean isCollection)
+ throws IOException {
+ if (ioHandler != null)
+ ioHandler.exportContent(context, isCollection);
+ return false;
+ }
+
+ public boolean exportContent(ExportContext context, DavResource resource)
+ throws IOException {
+ if (ioHandler != null)
+ ioHandler.exportContent(context, resource);
+ return false;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jackrabbit.server.io.ExportContext;
+import org.apache.jackrabbit.server.io.IOHandler;
+import org.apache.jackrabbit.server.io.IOManager;
+import org.apache.jackrabbit.server.io.ImportContext;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.tika.detect.Detector;
+
+/** {@link IOManager} that can easily be configured as a bean. */
+public class IOManagerBean implements IOManager {
+ private Detector detector = null;
+ private List<IOHandler> ioHandlers = new ArrayList<IOHandler>();
+
+ public boolean importContent(ImportContext context, boolean isCollection)
+ throws IOException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean importContent(ImportContext context, DavResource resource)
+ throws IOException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean exportContent(ExportContext context, boolean isCollection)
+ throws IOException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean exportContent(ExportContext context, DavResource resource)
+ throws IOException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public synchronized void addIOHandler(IOHandler ioHandler) {
+ ioHandlers.add(ioHandler);
+ }
+
+ public synchronized IOHandler[] getIOHandlers() {
+ return ioHandlers.toArray(new IOHandler[ioHandlers.size()]);
+ }
+
+ public Detector getDetector() {
+ return detector;
+ }
+
+ public void setDetector(Detector detector) {
+ this.detector = detector;
+ }
+
+ public synchronized List<IOHandler> getIoHandlers() {
+ return ioHandlers;
+ }
+
+ public synchronized void setIoHandlers(List<IOHandler> ioHandlers) {
+ this.ioHandlers = ioHandlers;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import java.util.Properties;
+
+import javax.jcr.Repository;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+
+public class JcrRemotingHandlerMapping extends AbstractJackrabbitHandlerMapping {
+
+ protected HttpServlet createServlet(Repository repository, String pathPrefix)
+ throws ServletException {
+ JcrRemotingServlet servlet = new JcrRemotingServlet(repository,
+ getSessionProvider());
+ Properties initParameters = new Properties();
+ initParameters.setProperty(
+ JcrRemotingServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, pathPrefix);
+ servlet.init(new DelegatingServletConfig(pathPrefix.replace('/', '_'),
+ initParameters));
+ return servlet;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import javax.jcr.Repository;
+
+import org.apache.jackrabbit.server.SessionProvider;
+
+public class JcrRemotingServlet extends
+ org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet {
+
+ private static final long serialVersionUID = 3131835511468341309L;
+
+ private final Repository repository;
+ private final SessionProvider sessionProvider;
+
+ public JcrRemotingServlet(Repository repository,
+ SessionProvider sessionProvider) {
+ this.repository = repository;
+ this.sessionProvider = sessionProvider;
+ }
+
+ @Override
+ protected Repository getRepository() {
+ return repository;
+ }
+
+ @Override
+ protected SessionProvider getSessionProvider() {
+ return sessionProvider;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import java.io.Serializable;
+
+import javax.jcr.LoginException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.server.SessionProvider;
+import org.argeo.jcr.JcrUtils;
+
+/**
+ * Implements an open session in view patter: a new JCR session is created for
+ * each request
+ */
+public class OpenInViewSessionProvider implements SessionProvider, Serializable {
+ private static final long serialVersionUID = 2270957712453841368L;
+
+ private final static Log log = LogFactory
+ .getLog(OpenInViewSessionProvider.class);
+
+ public Session getSession(HttpServletRequest request, Repository rep,
+ String workspace) throws LoginException, ServletException,
+ RepositoryException {
+ return login(request, rep, workspace);
+ }
+
+ protected Session login(HttpServletRequest request, Repository repository,
+ String workspace) throws RepositoryException {
+ if (log.isTraceEnabled())
+ log.trace("Login to workspace "
+ + (workspace == null ? "<default>" : workspace)
+ + " in web session " + request.getSession().getId());
+ return repository.login(workspace);
+ }
+
+ public void releaseSession(Session session) {
+ JcrUtils.logoutQuietly(session);
+ if (log.isTraceEnabled())
+ log.trace("Logged out remote JCR session " + session);
+ }
+
+ public void init() {
+ }
+
+ public void destroy() {
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import java.io.Serializable;
+
+import javax.jcr.LoginException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.server.SessionProvider;
+import org.argeo.ArgeoException;
+import org.argeo.jcr.ArgeoJcrConstants;
+import org.argeo.jcr.JcrUtils;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+/**
+ * Session provider assuming a single workspace and a short life cycle,
+ * typically a Spring bean of scope (web) 'session'.
+ */
+public class ScopedSessionProvider implements SessionProvider, Serializable {
+ private static final long serialVersionUID = 6589775984177317058L;
+ private static final Log log = LogFactory
+ .getLog(ScopedSessionProvider.class);
+ private transient HttpSession httpSession = null;
+ private transient Session jcrSession = null;
+
+ private transient String currentRepositoryName = null;
+ private transient String currentWorkspaceName = null;
+ private transient String currentJcrUser = null;
+
+ // private transient String anonymousUserId = "anonymous";
+
+ public Session getSession(HttpServletRequest request, Repository rep,
+ String workspace) throws LoginException, ServletException,
+ RepositoryException {
+
+ Authentication authentication = SecurityContextHolder.getContext()
+ .getAuthentication();
+ if (authentication == null)
+ throw new ArgeoException(
+ "Request not authenticated by Spring Security");
+ String springUser = authentication.getName();
+
+ // HTTP
+ String requestJcrRepository = (String) request
+ .getAttribute(ArgeoJcrConstants.JCR_REPOSITORY_ALIAS);
+
+ // HTTP session
+ if (httpSession != null
+ && !httpSession.getId().equals(request.getSession().getId()))
+ throw new ArgeoException(
+ "Only session scope is supported in this mode");
+ if (httpSession == null)
+ httpSession = request.getSession();
+
+ // Initializes current values
+ if (currentRepositoryName == null)
+ currentRepositoryName = requestJcrRepository;
+ if (currentWorkspaceName == null)
+ currentWorkspaceName = workspace;
+ if (currentJcrUser == null)
+ currentJcrUser = springUser;
+
+ // logout if there was a change in session coordinates
+ if (jcrSession != null)
+ if (!currentRepositoryName.equals(requestJcrRepository)) {
+ if (log.isDebugEnabled())
+ log.debug(getHttpSessionId() + " Changed from repository '"
+ + currentRepositoryName + "' to '"
+ + requestJcrRepository
+ + "', logging out cached JCR session.");
+ logout();
+ } else if (!currentWorkspaceName.equals(workspace)) {
+ if (log.isDebugEnabled())
+ log.debug(getHttpSessionId() + " Changed from workspace '"
+ + currentWorkspaceName + "' to '" + workspace
+ + "', logging out cached JCR session.");
+ logout();
+ } else if (!currentJcrUser.equals(springUser)) {
+ if (log.isDebugEnabled())
+ log.debug(getHttpSessionId() + " Changed from user '"
+ + currentJcrUser + "' to '" + springUser
+ + "', logging out cached JCR session.");
+ logout();
+ }
+
+ // login if needed
+ if (jcrSession == null)
+ try {
+ Session session = login(rep, workspace);
+ if (!session.getUserID().equals(springUser)) {
+ JcrUtils.logoutQuietly(session);
+ throw new ArgeoException("Spring Security user '"
+ + springUser + "' not in line with JCR user '"
+ + session.getUserID() + "'");
+ }
+ currentRepositoryName = requestJcrRepository;
+ // do not use workspace variable which may be null
+ currentWorkspaceName = session.getWorkspace().getName();
+ currentJcrUser = session.getUserID();
+
+ jcrSession = session;
+ return jcrSession;
+ } catch (RepositoryException e) {
+ throw new ArgeoException("Cannot open session to workspace "
+ + workspace, e);
+ }
+
+ // returns cached session
+ return jcrSession;
+ }
+
+ protected Session login(Repository repository, String workspace)
+ throws RepositoryException {
+ Session session = repository.login(workspace);
+ if (log.isDebugEnabled())
+ log.debug(getHttpSessionId() + " User '" + session.getUserID()
+ + "' logged in workspace '"
+ + session.getWorkspace().getName() + "' of repository '"
+ + currentRepositoryName + "'");
+ return session;
+ }
+
+ public void releaseSession(Session session) {
+ if (log.isTraceEnabled())
+ log.trace(getHttpSessionId() + " Releasing JCR session " + session);
+ }
+
+ protected void logout() {
+ JcrUtils.logoutQuietly(jcrSession);
+ jcrSession = null;
+ }
+
+ protected final String getHttpSessionId() {
+ return httpSession != null ? httpSession.getId() : "<null>";
+ }
+
+ public void init() {
+ }
+
+ public void destroy() {
+ logout();
+ if (getHttpSessionId() != null)
+ if (log.isDebugEnabled())
+ log.debug(getHttpSessionId()
+ + " Cleaned up provider for web session ");
+ httpSession = null;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.LoginException;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.server.SessionProvider;
+import org.argeo.ArgeoException;
+import org.argeo.jcr.ArgeoNames;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.UserJcrUtils;
+
+/**
+ * Implements an open session in view patter: a new JCR session is created for
+ * each request
+ *
+ * @deprecated use {@link ScopedSessionProvider} or
+ * {@link OpenInViewSessionProvider}
+ */
+@Deprecated
+public class SimpleSessionProvider implements SessionProvider, Serializable {
+ private static final long serialVersionUID = 2270957712453841368L;
+
+ private final static Log log = LogFactory
+ .getLog(SimpleSessionProvider.class);
+
+ private transient Map<String, Session> sessions;
+
+ private Boolean openSessionInView = true;
+
+ private String defaultWorkspace = "default";
+
+ private String webSessionId = null;
+
+ public Session getSession(HttpServletRequest request, Repository rep,
+ String workspace) throws LoginException, ServletException,
+ RepositoryException {
+
+ if (openSessionInView) {
+ JackrabbitSession session = (JackrabbitSession) login(request, rep,
+ workspace);
+ if (session.getWorkspace().getName().equals(defaultWorkspace))
+ writeRemoteRoles(session);
+ return session;
+ } else {
+ if (webSessionId != null
+ && !webSessionId.equals(request.getSession().getId()))
+ throw new ArgeoException(
+ "Only session scope is supported in this mode");
+ webSessionId = request.getSession().getId();
+
+ // since sessions is transient it can't be restored from the session
+ if (sessions == null)
+ sessions = Collections
+ .synchronizedMap(new HashMap<String, Session>());
+
+ if (!sessions.containsKey(workspace)) {
+ try {
+ // JackrabbitSession session = (JackrabbitSession)
+ // rep.login(
+ // null, workspace);
+ JackrabbitSession session = (JackrabbitSession) login(
+ request, rep, workspace);
+ if (session.getWorkspace().getName()
+ .equals(defaultWorkspace))
+ writeRemoteRoles(session);
+ if (log.isTraceEnabled())
+ log.trace("User " + session.getUserID()
+ + " logged into " + request.getServletPath());
+ sessions.put(workspace, session);
+ return session;
+ } catch (Exception e) {
+ throw new ArgeoException("Cannot open session", e);
+ }
+ } else {
+ Session session = sessions.get(workspace);
+ if (!session.isLive()) {
+ sessions.remove(workspace);
+ session = login(request, rep, workspace);
+ sessions.put(workspace, session);
+ }
+ return session;
+ }
+ }
+ }
+
+ protected Session login(HttpServletRequest request, Repository repository,
+ String workspace) throws RepositoryException {
+ if (log.isDebugEnabled())
+ log.debug("Login to workspace "
+ + (workspace == null ? "<default>" : workspace)
+ + " in web session " + request.getSession().getId());
+ return repository.login(workspace);
+ }
+
+ protected void writeRemoteRoles(JackrabbitSession session)
+ throws RepositoryException {
+ // FIXME better deal w/ non node repo
+
+ // retrieve roles
+ String userId = session.getUserID();
+ UserManager userManager = session.getUserManager();
+ User user = (User) userManager.getAuthorizable(userId);
+ if (user == null) {
+ // anonymous
+ return;
+ }
+ List<String> userGroupIds = new ArrayList<String>();
+ if (user != null)
+ for (Iterator<Group> it = user.memberOf(); it.hasNext();)
+ userGroupIds.add(it.next().getID());
+
+ // write roles if needed
+ Node userHome = UserJcrUtils.getUserHome(session);
+ boolean writeRoles = false;
+ if (userHome.hasProperty(ArgeoNames.ARGEO_REMOTE_ROLES)) {
+ Value[] roles = userHome.getProperty(ArgeoNames.ARGEO_REMOTE_ROLES)
+ .getValues();
+ if (roles.length != userGroupIds.size())
+ writeRoles = true;
+ else
+ for (int i = 0; i < roles.length; i++)
+ if (!roles[i].getString().equals(userGroupIds.get(i)))
+ writeRoles = true;
+ } else
+ writeRoles = true;
+
+ if (writeRoles) {
+ session.getWorkspace().getVersionManager()
+ .checkout(userHome.getPath());
+ String[] roleIds = userGroupIds.toArray(new String[userGroupIds
+ .size()]);
+ userHome.setProperty(ArgeoNames.ARGEO_REMOTE_ROLES, roleIds);
+ JcrUtils.updateLastModified(userHome);
+ session.save();
+ session.getWorkspace().getVersionManager()
+ .checkin(userHome.getPath());
+ }
+
+ }
+
+ public void releaseSession(Session session) {
+ if (log.isTraceEnabled())
+ log.trace("Releasing JCR session " + session);
+ if (openSessionInView) {
+ JcrUtils.logoutQuietly(session);
+ if (log.isDebugEnabled())
+ log.debug("Logged out remote JCR session " + session);
+ }
+ }
+
+ public void init() {
+ if (log.isDebugEnabled())
+ log.debug("Init session provider for web session " + webSessionId);
+ }
+
+ public void destroy() {
+ if (log.isDebugEnabled())
+ log.debug("Destroy session provider for web session "
+ + webSessionId);
+
+ if (sessions != null)
+ for (String workspace : sessions.keySet()) {
+ Session session = sessions.get(workspace);
+ JcrUtils.logoutQuietly(session);
+ }
+ }
+
+ /**
+ * If set to true a new session will be created each time (the default),
+ * otherwise a single session is cached by workspace and the object should
+ * be of scope session (not supported)
+ */
+ public void setOpenSessionInView(Boolean openSessionInView) {
+ this.openSessionInView = openSessionInView;
+ }
+
+ public void setSecurityWorkspace(String securityWorkspace) {
+ this.defaultWorkspace = securityWorkspace;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import java.util.Properties;
+
+import javax.jcr.Repository;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+
+/** Handler mapping for WebDav */
+public class SimpleWebdavHandlerMapping extends
+ AbstractJackrabbitHandlerMapping {
+ private String configuration;
+
+ protected HttpServlet createServlet(Repository repository, String pathPrefix)
+ throws ServletException {
+
+ SimpleWebdavServlet servlet = new SimpleWebdavServlet(repository,
+ getSessionProvider());
+ Properties initParameters = new Properties();
+ initParameters.setProperty(
+ SimpleWebdavServlet.INIT_PARAM_RESOURCE_CONFIG, configuration);
+ initParameters
+ .setProperty(
+ SimpleWebdavServlet.INIT_PARAM_RESOURCE_PATH_PREFIX,
+ pathPrefix);
+ servlet.init(new DelegatingServletConfig(pathPrefix.replace('/', '_'),
+ initParameters));
+ return servlet;
+ }
+
+ public void setConfiguration(String configuration) {
+ this.configuration = configuration;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.jackrabbit.remote;
+
+import java.io.IOException;
+
+import javax.jcr.Repository;
+import javax.servlet.ServletException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.server.SessionProvider;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.WebdavRequest;
+import org.apache.jackrabbit.webdav.WebdavResponse;
+
+/** WebDav servlet whose repository is injected */
+public class SimpleWebdavServlet extends
+ org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet {
+ private static final long serialVersionUID = -369787931175177080L;
+
+ private final static Log log = LogFactory.getLog(SimpleWebdavServlet.class);
+
+ private final Repository repository;
+
+ public SimpleWebdavServlet(Repository repository,
+ SessionProvider sessionProvider) {
+ this.repository = repository;
+ setSessionProvider(sessionProvider);
+ }
+
+ public Repository getRepository() {
+ return repository;
+ }
+
+ @Override
+ protected boolean execute(WebdavRequest request, WebdavResponse response,
+ int method, DavResource resource) throws ServletException,
+ IOException, DavException {
+ if (log.isTraceEnabled())
+ log.trace(request.getMethod() + "\t" + request.getPathInfo());
+ boolean res = super.execute(request, response, method, resource);
+ return res;
+ }
+
+}