jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r518970 - in /jackrabbit/trunk/contrib/spi: jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/ spi-rmi/src/main/java/o...
Date Fri, 16 Mar 2007 13:39:48 GMT
Author: angela
Date: Fri Mar 16 06:39:47 2007
New Revision: 518970

URL: http://svn.apache.org/viewvc?view=rev&rev=518970
Log:
- SPI: add RepositoryService.impersonate
- add implementations
- adjust SessionImpl.impersonate

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
    jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?view=diff&rev=518970&r1=518969&r2=518970
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Fri Mar 16 06:39:47 2007
@@ -20,7 +20,6 @@
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeManagerImpl;
-import org.apache.jackrabbit.jcr2spi.security.SecurityConstants;
 import org.apache.jackrabbit.jcr2spi.security.AccessManager;
 import org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager;
 import org.apache.jackrabbit.jcr2spi.state.UpdatableItemStateManager;
@@ -74,7 +73,6 @@
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.ValueFactory;
 import javax.jcr.Workspace;
@@ -191,28 +189,16 @@
      */
     public Session impersonate(Credentials credentials) throws LoginException, RepositoryException
{
         checkIsAlive();
-        // TODO: check whether restriction to SimpleCredentials is correct
-        if (!(credentials instanceof SimpleCredentials)) {
-            String msg = "impersonate failed: incompatible credentials, SimpleCredentials
expected";
-            log.debug(msg);
-            throw new RepositoryException(msg);
-        }
-
-        // set IMPERSONATOR_ATTRIBUTE attribute of given credentials
-        // with current session
-        SimpleCredentials creds = (SimpleCredentials) credentials;
-        creds.setAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE, this);
-
+        SessionInfo info = config.getRepositoryService().impersonate(sessionInfo, credentials);
         try {
-            return repository.login(credentials, getWorkspace().getName());
-        } catch (NoSuchWorkspaceException nswe) {
-            // should never get here...
-            String msg = "impersonate failed";
-            log.error(msg, nswe);
-            throw new RepositoryException(msg, nswe);
-        } finally {
-            // make sure IMPERSONATOR_ATTRIBUTE is removed
-            creds.removeAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE);
+            if (info instanceof XASessionInfo) {
+                return new XASessionImpl((XASessionInfo) info, repository, config);
+            } else {
+                return new SessionImpl(info, repository, config);
+            }
+        } catch (RepositoryException ex) {
+            config.getRepositoryService().dispose(info);
+            throw ex;
         }
     }
 

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java?view=diff&rev=518970&r1=518969&r2=518970
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/client/ClientRepositoryService.java
Fri Mar 16 06:39:47 2007
@@ -153,6 +153,15 @@
         }
     }
 
+    public SessionInfo impersonate(SessionInfo sessionInfo, Credentials credentials) throws
LoginException, RepositoryException {
+        try {
+            return new ClientSessionInfo(remoteService.impersonate(
+                    getRemoteSessionInfo(sessionInfo), credentials));
+        } catch (RemoteException e) {
+            throw new RemoteRepositoryException(e);
+        }
+    }
+
     /**
      * {@inheritDoc}
      */

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java?view=diff&rev=518970&r1=518969&r2=518970
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/remote/RemoteRepositoryService.java
Fri Mar 16 06:39:47 2007
@@ -27,6 +27,7 @@
 import org.apache.jackrabbit.spi.EventFilter;
 import org.apache.jackrabbit.spi.EventBundle;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.Path;
 
@@ -79,6 +80,20 @@
      */
     public RemoteSessionInfo obtain(RemoteSessionInfo sessionInfo,
                                     String workspaceName)
+            throws RepositoryException, RemoteException;
+
+    /**
+     * Returns a new <code>RemoteSessionInfo</code>.
+     *
+     * @param sessionInfo
+     * @param credentials
+     * @return a <code>RemoteSessionInfo</code> if impersonate was
+     *         successful.
+     * @throws RemoteException if an error occurs.
+     * @see RepositoryService#impersonate(SessionInfo, Credentials)
+     */
+    public RemoteSessionInfo impersonate(RemoteSessionInfo sessionInfo,
+                                         Credentials credentials)
             throws RepositoryException, RemoteException;
 
     /**

Modified: jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java?view=diff&rev=518970&r1=518969&r2=518970
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi-rmi/src/main/java/org/apache/jackrabbit/spi/rmi/server/ServerRepositoryService.java
Fri Mar 16 06:39:47 2007
@@ -160,6 +160,20 @@
     /**
      * {@inheritDoc}
      */
+    public RemoteSessionInfo impersonate(RemoteSessionInfo sessionInfo,
+                                         Credentials credentials)
+            throws RepositoryException, RemoteException {
+        try {
+            return createServerSessionInfo(
+                    service.impersonate(getSessionInfo(sessionInfo), credentials));
+        } catch (RepositoryException e) {
+            throw getRepositoryException(e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public void dispose(RemoteSessionInfo sessionInfo)
             throws RepositoryException, RemoteException {
         try {

Modified: jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?view=diff&rev=518970&r1=518969&r2=518970
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
Fri Mar 16 06:39:47 2007
@@ -104,6 +104,17 @@
             throws LoginException, NoSuchWorkspaceException, RepositoryException;
 
     /**
+     * Returns a <code>SessionInfo</code> that will be used by other methods
+     * on the <code>RepositoryService</code>.
+     *
+     * @param sessionInfo
+     * @param credentials
+     * @return a <code>SessionInfo</code> if impersonate was successful.
+     * @see Session#impersonate(Credentials)
+     */
+    public SessionInfo impersonate(SessionInfo sessionInfo, Credentials credentials) throws
LoginException, RepositoryException;
+
+    /**
      * Indicates to the <code>RepositoryService</code>, that the given SessionInfo
      * will not be used any more.
      *

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?view=diff&rev=518970&r1=518969&r2=518970
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Fri Mar 16 06:39:47 2007
@@ -449,8 +449,6 @@
     }
 
     /**
-     * TODO: handle impersonation
-     *
      * @see RepositoryService#obtain(Credentials, String)
      */
     public SessionInfo obtain(Credentials credentials, String workspaceName)
@@ -463,6 +461,10 @@
         throws LoginException, NoSuchWorkspaceException, RepositoryException {
         checkSessionInfo(sessionInfo);
         return obtain(((SessionInfoImpl)sessionInfo).getCredentials(), workspaceName);
+    }
+
+    public SessionInfo impersonate(SessionInfo sessionInfo, Credentials credentials) throws
LoginException, RepositoryException {
+        throw new UnsupportedOperationException("Not implemented yet.");
     }
 
     private SessionInfo obtain(CredentialsWrapper credentials, String workspaceName)

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?view=diff&rev=518970&r1=518969&r2=518970
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Fri Mar 16 06:39:47 2007
@@ -186,6 +186,15 @@
     /**
      * {@inheritDoc}
      */
+    public SessionInfo impersonate(SessionInfo sessionInfo, Credentials credentials) throws
LoginException, RepositoryException {
+        Credentials duplicate = SessionInfoImpl.duplicateCredentials(credentials);
+        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
+        return new SessionInfoImpl(sInfo.getSession().impersonate(credentials), duplicate);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public void dispose(SessionInfo sessionInfo) throws RepositoryException {
         subscriptions.remove(sessionInfo);
         getSessionInfoImpl(sessionInfo).getSession().logout();



Mime
View raw message