portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r692356 - in /portals/jetspeed-2/portal/branches/security-refactoring: components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/ jetspeed-api/src/main/java/org/apache/jetspeed/security/
Date Fri, 05 Sep 2008 07:09:48 GMT
Author: ate
Date: Fri Sep  5 00:09:47 2008
New Revision: 692356

URL: http://svn.apache.org/viewvc?rev=692356&view=rev
Log:
Some corrections and further implementation of RoleManager(Impl)

Modified:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseJetspeedPrincipalManager.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientGroup.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientRole.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientUser.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseJetspeedPrincipalManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseJetspeedPrincipalManager.java?rev=692356&r1=692355&r2=692356&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseJetspeedPrincipalManager.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/BaseJetspeedPrincipalManager.java
Fri Sep  5 00:09:47 2008
@@ -90,7 +90,7 @@
         this.jppsm = jppsm;
     }
     
-    protected void validatePrincipal(JetspeedPrincipal principal)
+    protected final void validatePrincipal(JetspeedPrincipal principal)
     {
         if (!principal.getType().getName().equals(principalType.getName()))
         {
@@ -102,7 +102,7 @@
         }
     }
 
-    public JetspeedPrincipalType getPrincipalType()
+    public final JetspeedPrincipalType getPrincipalType()
     {
         return principalType;
     }
@@ -182,7 +182,7 @@
     //
     // JetspeedPrincipalStorageManager interface implementation
     //
-    public boolean isMapped()
+    public final boolean isMapped()
     {
         return jpsm.isMapped();
     }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java?rev=692356&r1=692355&r2=692356&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/RoleManagerImpl.java
Fri Sep  5 00:09:47 2008
@@ -28,10 +28,13 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.security.AuthenticationProviderProxy;
 import org.apache.jetspeed.security.DependentPrincipalException;
+import org.apache.jetspeed.security.JetspeedPermission;
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationHandler;
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationReference;
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
+import org.apache.jetspeed.security.JetspeedPrincipalManager;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
 import org.apache.jetspeed.security.PrincipalAlreadyExistsException;
 import org.apache.jetspeed.security.PrincipalAssociationRequiredException;
 import org.apache.jetspeed.security.PrincipalNotFoundException;
@@ -45,6 +48,7 @@
 import org.apache.jetspeed.security.SecurityProvider;
 import org.apache.jetspeed.security.attributes.SecurityAttributes;
 import org.apache.jetspeed.security.attributes.SecurityAttributesProvider;
+import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalPermissionStorageManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
 import org.apache.jetspeed.security.spi.RoleSecurityHandler;
@@ -74,17 +78,33 @@
     /** The logger. */
     private static final Log log = LogFactory.getLog(RoleManagerImpl.class);
     
-    private JetspeedPrincipalAssociationHandler associationHandler;
+    public RoleManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalAccessManager
jpam,
+                                        JetspeedPrincipalStorageManager jpsm,
+                                        JetspeedPrincipalPermissionStorageManager jppsm)
+    {
+        super(principalType, jpam, jpsm, jppsm);
+    }
 
-    public RoleManagerImpl() 
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.RoleManager#newRole(java.lang.String, boolean)
+     */
+    public Role newRole(String name, boolean mapped)
     {
-        super();        
+        RoleImpl role = new RoleImpl();
+        role.setName(name);
+        role.setMapped(mapped);
+        return role;
     }
 
-    public RoleManagerImpl(JetspeedPrincipalStorageManager jetspeedPrincipalStorageManager,
JetspeedPrincipalPermissionStorageManager jetspeedPrincipalPermissionStorageManager, JetspeedPrincipalAssociationHandler
associationHandler)
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.RoleManager#newTransientRole(java.lang.String)
+     */
+    public Role newTransientRole(String name)
     {
-        super(jetspeedPrincipalStorageManager, jetspeedPrincipalPermissionStorageManager);
-        this.associationHandler = associationHandler;
+        TransientRole role = new TransientRole();
+        role.setName(name);
+        return role;
     }
 
     /**
@@ -92,15 +112,20 @@
      */
     public void addRole(String roleName) throws SecurityException
     {
-        if (roleExists(roleName)) 
-        {  
+        Role role = newRole(roleName, true);
+        try
+        {
+            super.addPrincipal(role, null);
+        }
+        catch (PrincipalAlreadyExistsException e)
+        {
             throw new SecurityException(SecurityException.ROLE_ALREADY_EXISTS.create(roleName));

         }
-        
-        RolePrincipal rolePrincipal = new RolePrincipalImpl(roleName);        
-        roleSecurityHandler.storeRolePrincipal(rolePrincipal);
-        SecurityAttributes sa = attributesProvider.createSecurityAttributes(rolePrincipal);
-        attributesProvider.saveAttributes(sa);
+        catch (PrincipalAssociationRequiredException e)
+        {
+            // TODO: add SecurityException type for this?
+            throw new SecurityException(SecurityException.UNEXPECTED.create("RoleManager.addRole",
"add", e.getMessage()));
+        }
         if (log.isDebugEnabled())
             log.debug("Added role: " + roleName);
     }
@@ -330,45 +355,183 @@
         }
     }
 
-    public JetspeedPrincipal newPrincipal(String name, boolean mapped)
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#addAssociationHandler(org.apache.jetspeed.security.JetspeedPrincipalAssociationHandler)
+     */
+    @Override
+    public void addAssociationHandler(JetspeedPrincipalAssociationHandler jpah)
     {
         // TODO Auto-generated method stub
-        return null;
+        super.addAssociationHandler(jpah);
     }
 
-    public JetspeedPrincipal newTransientPrincipal(String name)
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#addPrincipal(org.apache.jetspeed.security.JetspeedPrincipal,
java.util.Set)
+     */
+    @Override
+    public void addPrincipal(JetspeedPrincipal principal, Set<JetspeedPrincipalAssociationReference>
associations)
+                                                                                        
                         throws PrincipalAlreadyExistsException,
+                                                                                        
                         PrincipalAssociationRequiredException
     {
         // TODO Auto-generated method stub
-        return null;
+        super.addPrincipal(principal, associations);
     }
 
-    public void addPrincipal(JetspeedPrincipal principal,
-            Set<JetspeedPrincipalAssociationReference> associations)
-            throws PrincipalAlreadyExistsException,
-            PrincipalAssociationRequiredException
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#getAssociatedFrom(java.lang.String,
java.lang.String)
+     */
+    @Override
+    public List<JetspeedPrincipal> getAssociatedFrom(String principalName, String associationName)
     {
         // TODO Auto-generated method stub
-        
+        return super.getAssociatedFrom(principalName, associationName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#getAssociatedNamesFrom(java.lang.String,
java.lang.String)
+     */
+    @Override
+    public List<String> getAssociatedNamesFrom(String principalName, String associationName)
+    {
+        // TODO Auto-generated method stub
+        return super.getAssociatedNamesFrom(principalName, associationName);
     }
 
-    public boolean isMapped()
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#getAssociatedNamesTo(java.lang.String,
java.lang.String)
+     */
+    @Override
+    public List<String> getAssociatedNamesTo(String principalName, String associationName)
     {
         // TODO Auto-generated method stub
-        return false;
+        return super.getAssociatedNamesTo(principalName, associationName);
     }
 
-    public void removePrincipal(JetspeedPrincipal principal)
-            throws PrincipalNotFoundException, PrincipalNotRemovableException,
-            DependentPrincipalException
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#getAssociatedTo(java.lang.String,
java.lang.String)
+     */
+    @Override
+    public List<JetspeedPrincipal> getAssociatedTo(String principalName, String associationName)
     {
         // TODO Auto-generated method stub
-        
+        return super.getAssociatedTo(principalName, associationName);
     }
 
-    public void updatePrincipal(JetspeedPrincipal principal)
-            throws PrincipalUpdateException, PrincipalNotFoundException
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#getPrincipal(java.lang.String)
+     */
+    @Override
+    public JetspeedPrincipal getPrincipal(String name)
     {
         // TODO Auto-generated method stub
-        
+        return super.getPrincipal(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#getPrincipalNames(java.lang.String)
+     */
+    @Override
+    public List<String> getPrincipalNames(String nameFilter)
+    {
+        // TODO Auto-generated method stub
+        return super.getPrincipalNames(nameFilter);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#getPrincipals(java.lang.String)
+     */
+    @Override
+    public List<JetspeedPrincipal> getPrincipals(String nameFilter)
+    {
+        // TODO Auto-generated method stub
+        return super.getPrincipals(nameFilter);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#grantPermission(org.apache.jetspeed.security.JetspeedPrincipal,
org.apache.jetspeed.security.JetspeedPermission)
+     */
+    @Override
+    public void grantPermission(JetspeedPrincipal principal, JetspeedPermission permission)
+    {
+        // TODO Auto-generated method stub
+        super.grantPermission(principal, permission);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#principalExists(java.lang.String)
+     */
+    @Override
+    public boolean principalExists(String name)
+    {
+        return super.principalExists(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#removePrincipal(org.apache.jetspeed.security.JetspeedPrincipal)
+     */
+    @Override
+    public void removePrincipal(JetspeedPrincipal principal) throws PrincipalNotFoundException,
+                                                            PrincipalNotRemovableException,
DependentPrincipalException
+    {
+        // TODO Auto-generated method stub
+        super.removePrincipal(principal);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#removePrincipal(java.lang.String)
+     */
+    @Override
+    public void removePrincipal(String name) throws PrincipalNotFoundException, PrincipalNotRemovableException,
+                                            DependentPrincipalException
+    {
+        // TODO Auto-generated method stub
+        super.removePrincipal(name);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#revokeAll(org.apache.jetspeed.security.JetspeedPrincipal)
+     */
+    @Override
+    public void revokeAll(JetspeedPrincipal principal)
+    {
+        // TODO Auto-generated method stub
+        super.revokeAll(principal);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#revokePermission(org.apache.jetspeed.security.JetspeedPrincipal,
org.apache.jetspeed.security.JetspeedPermission)
+     */
+    @Override
+    public void revokePermission(JetspeedPrincipal principal, JetspeedPermission permission)
+    {
+        // TODO Auto-generated method stub
+        super.revokePermission(principal, permission);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.impl.BaseJetspeedPrincipalManager#updatePrincipal(org.apache.jetspeed.security.JetspeedPrincipal)
+     */
+    @Override
+    public void updatePrincipal(JetspeedPrincipal principal) throws PrincipalUpdateException,
+                                                            PrincipalNotFoundException
+    {
+        // TODO Auto-generated method stub
+        super.updatePrincipal(principal);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipalManager#newPrincipal(java.lang.String,
boolean)
+     */
+    public JetspeedPrincipal newPrincipal(String name, boolean mapped)
+    {
+        return newRole(name, mapped);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.security.JetspeedPrincipalManager#newTransientPrincipal(java.lang.String)
+     */
+    public JetspeedPrincipal newTransientPrincipal(String name)
+    {
+        return newTransientRole(name);
     }
 }
\ No newline at end of file

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientGroup.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientGroup.java?rev=692356&r1=692355&r2=692356&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientGroup.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientGroup.java
Fri Sep  5 00:09:47 2008
@@ -17,11 +17,13 @@
 
 package org.apache.jetspeed.security.impl;
 
+import org.apache.jetspeed.security.Group;
+
 /**
  * @version $Id$
  *
  */
-public class TransientGroup extends TransientJetspeedPrincipal
+public class TransientGroup extends TransientJetspeedPrincipal implements Group
 {
     private static final long serialVersionUID = -4347595527204071090L;
 }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientRole.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientRole.java?rev=692356&r1=692355&r2=692356&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientRole.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientRole.java
Fri Sep  5 00:09:47 2008
@@ -17,11 +17,13 @@
 
 package org.apache.jetspeed.security.impl;
 
+import org.apache.jetspeed.security.Role;
+
 /**
  * @version $Id$
  *
  */
-public class TransientRole extends TransientJetspeedPrincipal
+public class TransientRole extends TransientJetspeedPrincipal implements Role
 {
     private static final long serialVersionUID = -3622751457840996366L;
 }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientUser.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientUser.java?rev=692356&r1=692355&r2=692356&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientUser.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientUser.java
Fri Sep  5 00:09:47 2008
@@ -17,11 +17,13 @@
 
 package org.apache.jetspeed.security.impl;
 
+import org.apache.jetspeed.security.User;
+
 /**
  * @version $Id$
  *
  */
-public class TransientUser extends TransientJetspeedPrincipal
+public class TransientUser extends TransientJetspeedPrincipal implements User
 {
     private static final long serialVersionUID = 2966176187274497019L;
 }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java?rev=692356&r1=692355&r2=692356&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/RoleManager.java
Fri Sep  5 00:09:47 2008
@@ -31,7 +31,9 @@
  */
 public interface RoleManager
 {
-
+    Role newRole(String name, boolean mapped);
+    Role newTransientRole(String name);
+    
     /**
      * <p>Add a new role.</p>
      * <p>Role principal names are expressed as {principal}.{subprincipal} where



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message