geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r320977 - in /geronimo/trunk/modules: jetty/src/test/org/apache/geronimo/jetty/ security-builder/src/java/org/apache/geronimo/security/deployment/ security/src/java/org/apache/geronimo/security/deploy/ security/src/java/org/apache/geronimo/...
Date Fri, 14 Oct 2005 02:21:32 GMT
Author: djencks
Date: Thu Oct 13 19:21:26 2005
New Revision: 320977

URL: http://svn.apache.org/viewcvs?rev=320977&view=rev
Log:
Partial fix for new structure of wrapped principals.  At the moment no principals are wrapped
from security configuration

Modified:
    geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java
    geronimo/trunk/modules/security-builder/src/java/org/apache/geronimo/security/deployment/SecurityBuilder.java
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/deploy/DefaultPrincipal.java
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/util/ConfigurationUtil.java
    geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/JACCSecurityTest.java

Modified: geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java?rev=320977&r1=320976&r2=320977&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java (original)
+++ geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java Thu
Oct 13 19:21:26 2005
@@ -238,8 +238,10 @@
                  Iterator principals = realm.getPrincipals().iterator();
                  while (principals.hasNext()) {
                      Principal principal = (Principal) principals.next();
+                     //TODO check this
+                     String loginDomain = null;
 
-                     RealmPrincipal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(principal,
realm.getRealmName());
+                     java.security.Principal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(principal,
loginDomain, realm.getRealmName());
 
                      if (realmPrincipal == null) throw new DeploymentException("Unable to
create realm principal");
 

Modified: geronimo/trunk/modules/security-builder/src/java/org/apache/geronimo/security/deployment/SecurityBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security-builder/src/java/org/apache/geronimo/security/deployment/SecurityBuilder.java?rev=320977&r1=320976&r2=320977&view=diff
==============================================================================
--- geronimo/trunk/modules/security-builder/src/java/org/apache/geronimo/security/deployment/SecurityBuilder.java
(original)
+++ geronimo/trunk/modules/security-builder/src/java/org/apache/geronimo/security/deployment/SecurityBuilder.java
Thu Oct 13 19:21:26 2005
@@ -104,7 +104,9 @@
                 while (principals.hasNext()) {
                     Principal principal = (Principal) principals.next();
 
-                    RealmPrincipal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(principal,
realm.getRealmName());
+                    //TODO this is completely wrong
+                    String loginDomain = null;
+                    java.security.Principal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(principal,
loginDomain, realm.getRealmName());
 
                     if (realmPrincipal == null) throw new DeploymentException("Unable to
create realm principal");
 

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/deploy/DefaultPrincipal.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/deploy/DefaultPrincipal.java?rev=320977&r1=320976&r2=320977&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/deploy/DefaultPrincipal.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/deploy/DefaultPrincipal.java
Thu Oct 13 19:21:26 2005
@@ -25,6 +25,7 @@
  */
 public class DefaultPrincipal implements Serializable {
     private String realmName;
+    private String loginDomain;
     private Principal principal;
 
     private Set namedUserPasswordCredentials;
@@ -35,6 +36,14 @@
 
     public void setRealmName(String realmName) {
         this.realmName = realmName;
+    }
+
+    public String getLoginDomain() {
+        return loginDomain;
+    }
+
+    public void setLoginDomain(String loginDomain) {
+        this.loginDomain = loginDomain;
     }
 
     public Principal getPrincipal() {

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/util/ConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/util/ConfigurationUtil.java?rev=320977&r1=320976&r2=320977&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/util/ConfigurationUtil.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/util/ConfigurationUtil.java
Thu Oct 13 19:21:26 2005
@@ -30,6 +30,7 @@
 
 import org.apache.geronimo.security.PrimaryRealmPrincipal;
 import org.apache.geronimo.security.RealmPrincipal;
+import org.apache.geronimo.security.DomainPrincipal;
 import org.apache.geronimo.security.deploy.Principal;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
 import org.apache.geronimo.common.GeronimoSecurityException;
@@ -57,22 +58,28 @@
     /**
      * Create a RealmPrincipal from a deployment description.
      * @param principal the deployment description of the principal to be created.
+     * @param loginDomain
      * @return a RealmPrincipal from a deployment description
      */
-    public static RealmPrincipal generateRealmPrincipal(final Principal principal, final
String loginDomain) {
-        return generateRealmPrincipal(principal.getClassName(), principal.getPrincipalName(),
loginDomain);
+    public static java.security.Principal generateRealmPrincipal(final Principal principal,
final String loginDomain, final String realmName) {
+        return generateRealmPrincipal(principal.getClassName(), principal.getPrincipalName(),
loginDomain, realmName);
     }
 
-    public static RealmPrincipal generateRealmPrincipal(final String className, final String
principalName, final String loginDomain) {
+    public static java.security.Principal generateRealmPrincipal(final String className,
final String principalName, final String loginDomain, final String realmName) {
         try {
-            return (RealmPrincipal) AccessController.doPrivileged(new PrivilegedExceptionAction()
{
+            return (java.security.Principal) AccessController.doPrivileged(new PrivilegedExceptionAction()
{
                 public Object run() throws Exception {
                     java.security.Principal p = null;
                     Class clazz = Class.forName(className);
                     Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class});
                     p = (java.security.Principal) constructor.newInstance(new Object[]{principalName});
-
-                    return new RealmPrincipal(loginDomain, p);
+                    if (loginDomain != null) {
+                        p = new DomainPrincipal(loginDomain, p);
+                        if (realmName != null) {
+                            p = new RealmPrincipal(realmName, p);
+                        }
+                    }
+                    return p;
                 }
             });
         } catch (PrivilegedActionException e) {
@@ -126,7 +133,7 @@
         }
         Subject defaultSubject = new Subject();
 
-        RealmPrincipal realmPrincipal = generateRealmPrincipal(defaultPrincipal.getPrincipal(),
defaultPrincipal.getRealmName());
+        java.security.Principal realmPrincipal = generateRealmPrincipal(defaultPrincipal.getPrincipal(),
defaultPrincipal.getLoginDomain(), defaultPrincipal.getRealmName());
         if (realmPrincipal == null) {
             throw new GeronimoSecurityException("Unable to create realm principal");
         }

Modified: geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/JACCSecurityTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/JACCSecurityTest.java?rev=320977&r1=320976&r2=320977&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/JACCSecurityTest.java
(original)
+++ geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/JACCSecurityTest.java
Thu Oct 13 19:21:26 2005
@@ -62,7 +62,7 @@
      * @throws Exception thrown if an error in the test occurs
      */
     public void DavidJencksPleaseVisitMetestExplicitMapping() throws Exception {
-        
+
         Security securityConfig = new Security();
         securityConfig.setUseContextHandler(false);
 
@@ -74,7 +74,7 @@
         defaultPrincipal.setPrincipal(principal);
 
         securityConfig.setDefaultPrincipal(defaultPrincipal);
-        
+
         Role role = new Role();
         role.setRoleName("content-administrator");
         principal = new Principal();
@@ -86,11 +86,11 @@
         role.getRealms().put(realm.getRealmName(), realm);
 
         securityConfig.getRoleMappings().put(role.getRoleName(), role);
-        
+
         Map roleDesignates = new HashMap();
         Map principalRoleMap = new HashMap();
         buildPrincipalRoleMap(securityConfig, roleDesignates, principalRoleMap);
-       
+
         PermissionCollection uncheckedPermissions = new Permissions();
 
         PermissionCollection excludedPermissions = new Permissions();
@@ -103,11 +103,11 @@
         permissions.add(new WebResourcePermission("/protected/*", ""));
         rolePermissions.put("content-administrator", permissions);
         rolePermissions.put("auto-administrator", permissions);
-        
+
         PermissionCollection checked = permissions;
 
         ComponentPermissions componentPermissions = new ComponentPermissions(excludedPermissions,
uncheckedPermissions, rolePermissions);
-       
+
         startWebApp(roleDesignates, principalRoleMap,  componentPermissions,
                 defaultPrincipal, checked);
 
@@ -179,10 +179,10 @@
     }
 
     protected void startWebApp(
-            Map roleDesignates, 
+            Map roleDesignates,
             Map principalRoleMap,
-            ComponentPermissions componentPermissions, 
-            DefaultPrincipal defaultPrincipal, 
+            ComponentPermissions componentPermissions,
+            DefaultPrincipal defaultPrincipal,
             PermissionCollection checked) throws Exception {
 
         appName = setUpSecureAppContext(roleDesignates, principalRoleMap,
@@ -238,7 +238,10 @@
                 while (principals.hasNext()) {
                     Principal principal = (Principal) principals.next();
 
-                    RealmPrincipal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(principal,
realm.getRealmName());
+                    //TODO check this
+                    String loginDomain = null;
+
+                    java.security.Principal realmPrincipal = ConfigurationUtil.generateRealmPrincipal(principal,
loginDomain, realm.getRealmName());
 
                     if (realmPrincipal == null) throw new DeploymentException("Unable to
create realm principal");
 
@@ -270,7 +273,7 @@
             }
         }
     }
-    
+
     protected void setUp() throws Exception {
         super.setUp("org.apache.geronimo.tomcat.realm.TomcatGeronimoRealm");
         setUpSecurity();



Mime
View raw message