jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1379484 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Date Fri, 31 Aug 2012 15:48:38 GMT
Author: mduerig
Date: Fri Aug 31 15:48:37 2012
New Revision: 1379484

URL: http://svn.apache.org/viewvc?rev=1379484&view=rev
Log:
OAK-50: Implement User Management
allow passing in additional principals to RootImpl.commit. 
TODO: we need a cleaner way to handle this

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1379484&r1=1379483&r2=1379484&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Fri Aug 31 15:48:37 2012
@@ -18,6 +18,7 @@
  */
 package org.apache.jackrabbit.oak.core;
 
+import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.List;
@@ -163,7 +164,7 @@ public class RootImpl implements Root {
         rebase(conflictHandler);
         purgePendingChanges();
         CommitFailedException exception = Subject.doAs(
-                subject, new PrivilegedAction<CommitFailedException>() {
+                getCombinedSubject(), new PrivilegedAction<CommitFailedException>()
{
                     @Override
                     public CommitFailedException run() {
                         try {
@@ -180,6 +181,22 @@ public class RootImpl implements Root {
         refresh();
     }
 
+    // TODO: find a better solution for passing in additional principals
+    private Subject getCombinedSubject() {
+        Subject accSubject = Subject.getSubject(AccessController.getContext());
+        if (accSubject == null) {
+            return subject;
+        }
+        else {
+            Subject combinedSubject = new Subject(false,
+                    subject.getPrincipals(), subject.getPublicCredentials(), subject.getPrivateCredentials());
+            combinedSubject.getPrincipals().addAll(accSubject.getPrincipals());
+            combinedSubject.getPrivateCredentials().addAll(accSubject.getPrivateCredentials());
+            combinedSubject.getPublicCredentials().addAll((accSubject.getPublicCredentials()));
+            return combinedSubject;
+        }
+    }
+
     @Override
     public boolean hasPendingChanges() {
         return !getBaseState().equals(rootTree.getNodeState());



Mime
View raw message