jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r434074 - in /jackrabbit/trunk/contrib/spi: ./ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ spi/src/main/java/org/apache/jackrabbit/spi/ spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/
Date Wed, 23 Aug 2006 16:38:59 GMT
Author: mreutegg
Date: Wed Aug 23 09:38:57 2006
New Revision: 434074

URL: http://svn.apache.org/viewvc?rev=434074&view=rev
Log:
- Adjust jackrabbit dependency to version 1.1-SNAPSHOT
- Remove javax.security.auth.Subject from SPI interfaces. Whether JAAS is supported and how
is specific to the SPI implementation.
- Add JavaDoc to RepositoryService.login()

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/contrib/spi/project.properties
    jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.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?rev=434074&r1=434073&r2=434074&view=diff
==============================================================================
--- 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
Wed Aug 23 09:38:57 2006
@@ -81,7 +81,6 @@
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.version.VersionException;
-import javax.security.auth.Subject;
 import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.sax.TransformerHandler;
 import javax.xml.transform.stream.StreamResult;
@@ -92,8 +91,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.security.AccessControlException;
-import java.security.Principal;
-import java.util.Set;
 import java.util.Map;
 import java.util.HashMap;
 
@@ -119,7 +116,6 @@
     private final WorkspaceImpl workspace;
 
     private final String userId;
-    private final Subject subject;
 
     private final LocalNamespaceMappings nsMappings;
     private final NodeTypeManagerImpl ntManager;
@@ -134,18 +130,7 @@
 
         alive = true;
         this.repository = repository;
-        this.subject = sessionInfo.getSubject();
-
-        // DIFF JACKRABBIT don't expect principals
-        // TODO: not totally correct to use the first principles name as UserId
-        Set principals = sessionInfo.getSubject().getPrincipals();
-        if (!principals.isEmpty()) {
-            // use 1st principal in case there are more that one
-            Principal principal = (Principal) principals.iterator().next();
-            userId = principal.getName();
-        } else {
-            userId = null;
-        }
+        userId = sessionInfo.getUserID();
 
         workspace = createWorkspaceInstance(config.getRepositoryService(), sessionInfo);
         valueFactory = config.getValueFactory();
@@ -214,9 +199,9 @@
         }
 
         // set IMPERSONATOR_ATTRIBUTE attribute of given credentials
-        // with subject of current session
+        // with current session
         SimpleCredentials creds = (SimpleCredentials) credentials;
-        creds.setAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE, subject);
+        creds.setAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE, this);
 
         try {
             return repository.login(credentials, getWorkspace().getName());

Modified: jackrabbit/trunk/contrib/spi/project.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/project.properties?rev=434074&r1=434073&r2=434074&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/project.properties (original)
+++ jackrabbit/trunk/contrib/spi/project.properties Wed Aug 23 09:38:57 2006
@@ -2,7 +2,7 @@
 maven.repo.remote = http://www.ibiblio.org/maven/,http://www.day.com/maven/
 
 #-------------------------------------------------------
-jackrabbit.build.version.jackrabbit=1.0-SNAPSHOT
+jackrabbit.build.version.jackrabbit=1.1-SNAPSHOT
 jackrabbit.build.version.jcr=1.0
 jackrabbit.build.version.spi=0.1-dev
 

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?rev=434074&r1=434073&r2=434074&view=diff
==============================================================================
--- 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
Wed Aug 23 09:38:57 2006
@@ -36,6 +36,7 @@
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.ValueFormatException;
 import javax.jcr.Node;
+import javax.jcr.LoginException;
 import java.util.Properties;
 import java.io.InputStream;
 
@@ -61,13 +62,24 @@
     public Properties getRepositoryDescriptors() throws RepositoryException;
 
     //------------------------------------------------------< Initial login >---
+
     /**
+     * Authenticates the user using the supplied <code>credentials</code>. If
+     * <code>credentials</code> is <code>null</code> an implementation
will use
+     * the current security context to obtain the {@link
+     * javax.security.auth.Subject}. If <code>credentials</code> is
+     * <code>null</code> and there is no <code>Subject</code> present
in the
+     * current security context a <code>RepositoryException</code> is thrown.
      *
-     * @param credentials
-     * @return
-     * @throws RepositoryException
+     * @param credentials the credentials of the user.
+     * @return a <code>SessionInfo</code> if authentication was successful.
+     * @throws LoginException           if authentication of the user fails.
+     * @throws NoSuchWorkspaceException if the specified <code>workspaceName</code>
+     *                                  is not recognized.
+     * @throws RepositoryException      if an error occurs.
      */
-    public SessionInfo login(Credentials credentials, String workspaceName) throws RepositoryException;
+    public SessionInfo login(Credentials credentials, String workspaceName)
+            throws LoginException, NoSuchWorkspaceException, RepositoryException;
 
     //--------------------------------------------------------------------------
     /**

Modified: jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java?rev=434074&r1=434073&r2=434074&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/SessionInfo.java
Wed Aug 23 09:38:57 2006
@@ -16,14 +16,12 @@
  */
 package org.apache.jackrabbit.spi;
 
-import javax.security.auth.Subject;
-
 /**
  * <code>SessionInfo</code>...
  */
 public interface SessionInfo {
 
-    public Subject getSubject();
+    public String getUserID();
 
     public String getWorkspaceName();
 

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?rev=434074&r1=434073&r2=434074&view=diff
==============================================================================
--- 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
Wed Aug 23 09:38:57 2006
@@ -143,6 +143,7 @@
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.SimpleCredentials;
+import javax.jcr.LoginException;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -231,10 +232,9 @@
     }
 
     private HttpClient getClient(SessionInfo sessionInfo) {
-        Iterator allCreds = sessionInfo.getSubject().getPublicCredentials(Credentials.class).iterator();
         Credentials credentials = null;
-        if (allCreds.hasNext()) {
-            credentials = (Credentials) allCreds.next();
+        if (sessionInfo instanceof SessionInfoImpl) {
+            credentials = ((SessionInfoImpl) sessionInfo).getCredentials();
         }
         return getClient(credentials);
     }
@@ -372,9 +372,16 @@
     }
 
     /**
+     * TODO: handle impersonation
      * @see RepositoryService#login(Credentials, String)
      */
-    public SessionInfo login(Credentials credentials, String workspaceName) throws RepositoryException
{
+    public SessionInfo login(Credentials credentials, String workspaceName)
+            throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        if (credentials == null) {
+            // no credentials provided, use JAAS
+            throw new RepositoryException("JAAS authentication not implemented");
+        }
+
         // interested in workspace href property only, which allows to retrieve the
         // name of the workspace in case 'workspaceName' is 'null'.
         DavPropertyNameSet nameSet = new DavPropertyNameSet();

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.java?rev=434074&r1=434073&r2=434074&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/SessionInfoImpl.java
Wed Aug 23 09:38:57 2006
@@ -21,7 +21,7 @@
 
 import org.apache.jackrabbit.spi.SessionInfo;
 import javax.jcr.Credentials;
-import javax.security.auth.Subject;
+import javax.jcr.SimpleCredentials;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -32,23 +32,23 @@
 
     private static Logger log = LoggerFactory.getLogger(SessionInfoImpl.class);
 
-    private final Subject subject;
+    private final Credentials credentials;
     private final String workspaceName;
     private String batchId;
 
     private final Set lockTokens = new HashSet();
 
     SessionInfoImpl(Credentials creds, String workspaceName) {
-        Set publicCreds = new HashSet();
-        if (creds != null) {
-            publicCreds.add(creds);
-        }
-        this.subject = new Subject(false, new HashSet(), publicCreds, new HashSet());
+        this.credentials = creds;
         this.workspaceName = workspaceName;
     }
 
-    public Subject getSubject() {
-        return subject;
+    public String getUserID() {
+        if (credentials instanceof SimpleCredentials) {
+            return ((SimpleCredentials) credentials).getUserID();
+        } else {
+            return null;
+        }
     }
 
     public String getWorkspaceName() {
@@ -73,5 +73,9 @@
 
     public void setBatchId(String id) {
         batchId = id;
+    }
+
+    Credentials getCredentials() {
+        return credentials;
     }
 }



Mime
View raw message