Author: bblfish
Date: Mon Apr 11 11:40:26 2011
New Revision: 1091039

URL: http://svn.apache.org/viewvc?rev=1091039&view=rev
Log:
CLEREZZA-494: Subject should be reused. This is the core change set for this.

Modified:
    
incubator/clerezza/trunk/parent/platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
    
incubator/clerezza/trunk/parent/platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
    
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala

Modified: 
incubator/clerezza/trunk/parent/platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java?rev=1091039&r1=1091038&r2=1091039&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
 Mon Apr 11 11:40:26 2011
@@ -25,6 +25,7 @@ import java.nio.channels.ReadableByteCha
 import java.security.AccessControlException;
 import java.util.Collections;
 
+import org.apache.clerezza.platform.security.UserUtil;
 import org.osgi.service.component.ComponentContext;
 import org.apache.clerezza.platform.security.auth.*;
 import org.apache.felix.scr.annotations.Component;
@@ -79,10 +80,12 @@ public class BasicAuthentication impleme
                        }
                        try {
                                if 
(authenticationService.authenticateUser(userName, password)) {
-                                       return new Subject(true,
-                                               Collections.singleton(new 
PrincipalImpl(userName)),
-                                               Collections.EMPTY_SET,
-                                               Collections.EMPTY_SET);
+                                       Subject subj = 
UserUtil.getCurrentSubject();   //arguably getCurrentSubject should always 
return a subject
+                                       if (subj == null) {
+                                               subj = new Subject();
+                                       }
+                                       subj.getPrincipals().add(new 
PrincipalImpl(userName));
+                                       return subj;
                                } else {
                                        throw new 
LoginException(LoginException.PASSWORD_NOT_MATCHING);
                                }

Modified: 
incubator/clerezza/trunk/parent/platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java?rev=1091039&r1=1091038&r2=1091039&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
 Mon Apr 11 11:40:26 2011
@@ -25,6 +25,8 @@ import java.security.Principal;
 import java.util.*;
 import javax.security.auth.Subject;
 import javax.ws.rs.core.Cookie;
+
+import org.apache.clerezza.platform.security.UserUtil;
 import org.osgi.service.component.ComponentContext;
 import org.apache.clerezza.platform.security.auth.*;
 import org.apache.felix.scr.annotations.Component;
@@ -88,10 +90,12 @@ public class CookieAuthentication implem
                        }
                        try {
                                if 
(authenticationService.authenticateUser(userName, password)){
-                                       return new Subject(true,
-                                               Collections.singleton(new 
PrincipalImpl(userName)),
-                                               Collections.EMPTY_SET,
-                                               Collections.EMPTY_SET);
+                                       Subject subj = 
UserUtil.getCurrentSubject();   //arguably getCurrentSubject should always 
return a subject
+                                       if (subj == null) {
+                                               subj = new Subject();
+                                       }
+                                       subj.getPrincipals().add(new 
PrincipalImpl(userName));
+                                       return subj;
                                } else {
                                        throw new 
LoginException(LoginException.PASSWORD_NOT_MATCHING);
                                }

Modified: 
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala?rev=1091039&r1=1091038&r2=1091039&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala
 Mon Apr 11 11:40:26 2011
@@ -31,6 +31,7 @@ import org.apache.clerezza.rdf.ontologie
 import org.apache.clerezza.platform.users.WebIdGraphsService
 import org.slf4j.LoggerFactory
 import java.util.Collections
+import org.apache.clerezza.platform.security.UserUtil
 
 
 object FoafSslAuthentication {
@@ -75,13 +76,15 @@ class FoafSslAuthentication extends Weig
       addAgentToSystem(claim)
       claim.principal
     }
+        var subj = UserUtil.getCurrentSubject();   //arguably 
getCurrentSubject should always return a subject
+        if (subj == null) {
+                subj = new Subject()
+        }
 
-    if (verified.size == 0) return null
+        subj.getPrincipals().addAll(verified)
+    subj.getPublicCredentials.add(x509c)
 
-    return new Subject(true,
-      asJavaSet(verified.toSet),
-      Collections.singleton(x509c),
-      Collections.EMPTY_SET);
+    return subj;
 
 
   }


Reply via email to