portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r698049 [1/3] - in /portals/jetspeed-2/portal/branches/security-refactoring: components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/ compone...
Date Tue, 23 Sep 2008 00:51:04 GMT
Author: ate
Date: Mon Sep 22 17:51:02 2008
New Revision: 698049

URL: http://svn.apache.org/viewvc?rev=698049&view=rev
Log:
- cleanup of Interface constants naming and usage
- completing security exception handling fixes and simplification replacing many/most of the custom exceptions within the security component with standarized and auto-localizing SecurityExceptions
- simplifiing the SynchronizationStateAccess usage and moving it to the spi.impl package (this one is also needed by the JetspeedSecuritySerializer, not just the JetspeedPrincipalSynchronizer)

Added:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SynchronizationStateAccess.java   (contents, props changed)
      - copied, changed from r697979, portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SynchronizationStateAccess.java
Removed:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SynchronizationState.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SynchronizationStateAccess.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/AttributeReadOnlyException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/AttributeRequiredException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/AttributesNotExtendableException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/AttributesReadOnlyException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/DependentPrincipalException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/InvalidDnException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/InvalidUidException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/PrincipalAlreadyExistsException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/PrincipalAssociationNotAllowedException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/PrincipalAssociationRequiredException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/PrincipalAssociationUnsupportedException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/PrincipalNotFoundException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/PrincipalNotRemovableException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/PrincipalReadOnlyException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/PrincipalUpdateException.java
Modified:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
    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/GroupManagerImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/LdapAuthenticationProvider.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PersistentJetspeedPrincipal.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/SecurityAttributesImpl.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/TransientJetspeedPrincipal.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/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAssociationStorageManager.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalStorageManager.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalSynchronizer.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPrincipalAssociationHandler.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedPrincipalSynchronizer.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SimpleMemberOfPrincipalAssociationHandler.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserPasswordCredentialManagerImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserSubjectPrincipalsResolverImpl.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipalManager.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/exception/JetspeedExceptionMessages.properties
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/exception/JetspeedExceptionMessages_en.properties
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/exception/JetspeedExceptionMessages_ja.properties
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/exception/JetspeedExceptionMessages_ko.properties
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/exception/JetspeedExceptionMessages_nl.properties
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/exception/JetspeedExceptionMessages_ua.properties
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/exception/JetspeedExceptionMessages_zh.properties
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/exception/JetspeedExceptionMessages_zh_TW.properties
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipal.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalAssociationType.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedPrincipalType.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/SecurityAttribute.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/SecurityAttributes.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/SecurityException.java
    portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/User.java

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/serializer/JetspeedUserTemplateSerializer.java Mon Sep 22 17:51:02 2008
@@ -32,10 +32,8 @@
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.PageManagerUtils;
 import org.apache.jetspeed.page.document.NodeException;
-import org.apache.jetspeed.security.AttributeReadOnlyException;
-import org.apache.jetspeed.security.AttributesNotExtendableException;
-import org.apache.jetspeed.security.AttributesReadOnlyException;
 import org.apache.jetspeed.security.JSSubject;
+import org.apache.jetspeed.security.JetspeedPrincipalType;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
@@ -99,7 +97,7 @@
                 adminUser = null;
             }            
             if (adminUser == null)
-                throw new SerializerException(SecurityException.USER_DOES_NOT_EXIST.create("admin"));
+                throw new SerializerException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, "admin"));
             for (JSUser user : snapshot.getUsers())
             {
                 String folderTemplate = user.getUserTemplate();
@@ -188,18 +186,6 @@
                     se.printStackTrace();
                     return se;                    
                 } 
-                catch (AttributesReadOnlyException ae)
-                {
-                    return ae;
-                }
-                catch (AttributeReadOnlyException e)
-                {
-                    return e;
-                }
-                catch (AttributesNotExtendableException e)
-                {
-                    return e;
-                } 
             }
         }, null);
 

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java Mon Sep 22 17:51:02 2008
@@ -43,9 +43,6 @@
 import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.profiler.rules.ProfilingRule;
 import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.AttributeReadOnlyException;
-import org.apache.jetspeed.security.AttributesNotExtendableException;
-import org.apache.jetspeed.security.AttributesReadOnlyException;
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.JSSubject;
 import org.apache.jetspeed.security.PasswordCredential;
@@ -312,18 +309,6 @@
                         {
                             return e1;
                         } 
-                        catch (AttributesReadOnlyException e1)
-                        {
-                            return e1;
-                        } 
-                        catch (AttributeReadOnlyException e)
-                        {
-                            return e;
-                        }
-                        catch (AttributesNotExtendableException e)
-                        {
-                            return e;
-                        } 
                     }
                 }, null);
                 

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=698049&r1=698048&r2=698049&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 Mon Sep 22 17:51:02 2008
@@ -24,26 +24,17 @@
 import java.util.Set;
 
 import org.apache.jetspeed.Jetspeed;
-import org.apache.jetspeed.security.DependentPrincipalException;
 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.JetspeedPrincipalManagerProvider;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.PrincipalAlreadyExistsException;
-import org.apache.jetspeed.security.PrincipalAssociationNotAllowedException;
-import org.apache.jetspeed.security.PrincipalAssociationRequiredException;
-import org.apache.jetspeed.security.PrincipalAssociationUnsupportedException;
-import org.apache.jetspeed.security.PrincipalNotFoundException;
-import org.apache.jetspeed.security.PrincipalNotRemovableException;
-import org.apache.jetspeed.security.PrincipalReadOnlyException;
-import org.apache.jetspeed.security.PrincipalUpdateException;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalAccessManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalManagerSPI;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
-import org.apache.jetspeed.security.spi.SynchronizationStateAccess;
+import org.apache.jetspeed.security.spi.impl.SynchronizationStateAccess;
 
 /**
  * @version $Id$
@@ -174,7 +165,9 @@
     {
         JetspeedPrincipal principal = jpam.getPrincipal(name, principalType);
         if (principal == null)
+        {
             throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(principalType.getName(),name));
+        }
         jpsm.removePrincipal(principal);
     }
     
@@ -276,14 +269,24 @@
                     }
                     if (!assHandlers.containsKey(key))
                     {
-                        throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_NOT_ALLOWED.createScoped(principal.getName()));
+                        if (ref.type == JetspeedPrincipalAssociationReference.Type.FROM)
+                        {
+                            throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_UNSUPPORTED.createScoped(ref.ref.getType().getName(), ref.associationName, principal.getType().getName()));
+                        }
+                        else
+                        {
+                            throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_UNSUPPORTED.createScoped(principal.getType().getName(), ref.associationName, ref.ref.getType().getName()));
+                        }
                     }
                     reqAss.remove(key);
                 }
             }
             if (!reqAss.isEmpty())
             {
-                throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_REQUIRED.createScoped(principal.getName()));
+                JetspeedPrincipalAssociationType assType = reqAss.values().iterator().next();
+                throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_REQUIRED.createScoped(assType.getFromPrincipalType().getName(),
+                                                                                                          assType.getAssociationName(),
+                                                                                                          assType.getToPrincipalType().getName()));
             }
         }
         jpsm.addPrincipal(principal, associations);
@@ -325,7 +328,7 @@
         validatePrincipal(principal);
         if (principal.isReadOnly() && !isSynchronizing())
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_IS_READ_ONLY.createScoped(principal.getName()));
+            throw new SecurityException(SecurityException.PRINCIPAL_IS_READ_ONLY.createScoped(principal.getType().getName(), principal.getName()));
         }
         jpsm.updatePrincipal(principal);
     }
@@ -340,23 +343,25 @@
         
         if (jpah == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_NOT_ALLOWED.createScoped(from.getName()));
+            throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_UNSUPPORTED.createScoped(from.getType().getName(), associationName, to.getType().getName()));
         }
         if (from.isTransient() || from.getId() == null)
         {
-            from = jpah.getManagerFrom().getPrincipal(from.getName());
-        }
-        if (from == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST);
+            JetspeedPrincipal pfrom = jpah.getManagerFrom().getPrincipal(from.getName());
+            if (pfrom == null)
+            {
+                throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(from.getType().getName(), from.getName()));
+            }
+            from = pfrom;
         }
         if (to.isTransient() || to.getId() == null)
         {
-            to = jpah.getManagerTo().getPrincipal(to.getName());
-        }
-        if (to == null)
-        {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST);
+            JetspeedPrincipal pto = jpah.getManagerTo().getPrincipal(to.getName());
+            if (pto == null)
+            {
+                throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(to.getType().getName(), to.getName()));
+            }
+            to = pto;
         }
         jpah.add(from, to);
     }
@@ -384,30 +389,35 @@
         {
             if (jpah.getAssociationType().isRequired() && !isSynchronizing())
             {
-                throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_REQUIRED.createScoped(from.getName()));             
+                JetspeedPrincipalAssociationType assType = jpah.getAssociationType();
+                throw new SecurityException(SecurityException.PRINCIPAL_ASSOCIATION_REQUIRED.createScoped(assType.getFromPrincipalType().getName(),
+                                                                                                          assType.getAssociationName(),
+                                                                                                          assType.getToPrincipalType().getName()));             
             }
             if (from.isTransient() || from.getId() == null)
             {
-                from = jpah.getManagerFrom().getPrincipal(from.getName());
-            }
-            if (from == null)
-            {
-                throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST);
+                JetspeedPrincipal pfrom = jpah.getManagerFrom().getPrincipal(from.getName());
+                if (pfrom == null)
+                {
+                    throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(from.getType().getName(), from.getName()));
+                }
+                from = pfrom;
             }
             if (to.isTransient() || to.getId() == null)
             {
-                to = jpah.getManagerTo().getPrincipal(to.getName());
-            }
-            if (to == null)
-            {
-                throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST);
+                JetspeedPrincipal pto = jpah.getManagerTo().getPrincipal(to.getName());
+                if (pto == null)
+                {
+                    throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(to.getType().getName(), to.getName()));
+                }
+                to = pto;
             }
             jpah.remove(from, to);
         }
     }
     
     protected boolean isSynchronizing(){
-        return SynchronizationStateAccess.getInstance().isSynchronizing();
+        return SynchronizationStateAccess.isSynchronizing();
     }
 
 }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.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/GroupManagerImpl.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/GroupManagerImpl.java Mon Sep 22 17:51:02 2008
@@ -20,20 +20,11 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.security.DependentPrincipalException;
 import org.apache.jetspeed.security.Group;
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.PrincipalAlreadyExistsException;
-import org.apache.jetspeed.security.PrincipalAssociationNotAllowedException;
-import org.apache.jetspeed.security.PrincipalAssociationRequiredException;
-import org.apache.jetspeed.security.PrincipalAssociationUnsupportedException;
-import org.apache.jetspeed.security.PrincipalNotFoundException;
-import org.apache.jetspeed.security.PrincipalNotRemovableException;
-import org.apache.jetspeed.security.PrincipalReadOnlyException;
-import org.apache.jetspeed.security.PrincipalUpdateException;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
@@ -149,7 +140,7 @@
         
         if (null == group) 
         { 
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP_TYPE_NAME, groupName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
         }
 
         return group;
@@ -161,7 +152,7 @@
     public List<Group> getGroupsForUser(String username)
             throws SecurityException
     {
-        return (List<Group>) super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        return (List<Group>) super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**
@@ -170,7 +161,7 @@
     public List<Group> getGroupsInRole(String roleName)
             throws SecurityException
     {
-        return (List<Group>) super.getAssociatedTo(roleName, roleType, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        return (List<Group>) super.getAssociatedTo(roleName, roleType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**
@@ -183,15 +174,15 @@
        	checkInitialized();
        	User user = userManager.getUser(username);
         if (user == null)
-            {
-                throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER_TYPE_NAME, username));
-            }
-            Group group = getGroup(groupName);
-            if (group == null)
-            {
-                throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP_TYPE_NAME, groupName));
-            }
-            super.addAssociation(user, group, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        {
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
+        }
+        Group group = getGroup(groupName);
+        if (group == null)
+        {
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
+        }
+        super.addAssociation(user, group, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**
@@ -205,14 +196,14 @@
         User user = userManager.getUser(username);
         if (user == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER_TYPE_NAME, username));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
         }
         Group group = getGroup(groupName);
         if (group == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP_TYPE_NAME, groupName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
         }
-        super.removeAssociation(user, group, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        super.removeAssociation(user, group, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/LdapAuthenticationProvider.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/LdapAuthenticationProvider.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/LdapAuthenticationProvider.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/LdapAuthenticationProvider.java Mon Sep 22 17:51:02 2008
@@ -27,7 +27,6 @@
 import javax.naming.directory.SearchResult;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.jetspeed.i18n.KeyedMessage;
 import org.apache.jetspeed.security.AuthenticatedUser;
 import org.apache.jetspeed.security.AuthenticatedUserImpl;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
@@ -80,7 +79,7 @@
         }
         catch (Exception e)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER_TYPE_NAME, userName), e);
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName), e);
         }
         return authUser;
     }
@@ -102,7 +101,9 @@
         try
         {
             if (dn == null)
-                throw new SecurityException(new KeyedMessage("User " + userName + " not found"));
+            {
+                throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
+            }
             // Build user dn using lookup value, just appending the user filter after the uid won't work when users
             // are/can be stored in a subtree (searchScope sub-tree)
             // The looked up dn though is/should always be correct, just need to append the root context.

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PersistentJetspeedPrincipal.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/PersistentJetspeedPrincipal.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PersistentJetspeedPrincipal.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/PersistentJetspeedPrincipal.java Mon Sep 22 17:51:02 2008
@@ -23,9 +23,9 @@
 import java.util.Collection;
 import java.util.Map;
 
-import org.apache.jetspeed.security.PrincipalReadOnlyException;
 import org.apache.jetspeed.security.SecurityAttributes;
-import org.apache.jetspeed.security.spi.SynchronizationStateAccess;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.spi.impl.SynchronizationStateAccess;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerAware;
 import org.apache.ojb.broker.PersistenceBrokerException;
@@ -83,11 +83,11 @@
         return enabled;
     }
 
-    public void setEnabled(boolean enabled) throws PrincipalReadOnlyException
+    public void setEnabled(boolean enabled) throws SecurityException
     {
         if (isReadOnly() && !isSynchronizing())
         {
-            throw new PrincipalReadOnlyException();
+            throw new SecurityException(SecurityException.PRINCIPAL_IS_READ_ONLY.createScoped(getType().getName(), getName()));
         }
         this.enabled = enabled;
     }
@@ -190,7 +190,7 @@
     }
     
     protected boolean isSynchronizing(){
-        return SynchronizationStateAccess.getInstance().isSynchronizing();
+        return SynchronizationStateAccess.isSynchronizing();
     }
 
 }

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=698049&r1=698048&r2=698049&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 Mon Sep 22 17:51:02 2008
@@ -20,20 +20,11 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.security.DependentPrincipalException;
 import org.apache.jetspeed.security.Group;
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.PrincipalAlreadyExistsException;
-import org.apache.jetspeed.security.PrincipalAssociationNotAllowedException;
-import org.apache.jetspeed.security.PrincipalAssociationRequiredException;
-import org.apache.jetspeed.security.PrincipalAssociationUnsupportedException;
-import org.apache.jetspeed.security.PrincipalNotFoundException;
-import org.apache.jetspeed.security.PrincipalNotRemovableException;
-import org.apache.jetspeed.security.PrincipalReadOnlyException;
-import org.apache.jetspeed.security.PrincipalUpdateException;
 import org.apache.jetspeed.security.Role;
 import org.apache.jetspeed.security.RoleManager;
 import org.apache.jetspeed.security.SecurityException;
@@ -157,7 +148,7 @@
         
         if (null == role) 
         { 
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE_TYPE_NAME, roleName)); 
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName)); 
         }
 
         return role;
@@ -168,7 +159,7 @@
      */
     public List<Role> getRolesForUser(String username) throws SecurityException
     {        
-        return (List<Role>)super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        return (List<Role>)super.getAssociatedFrom(username, userType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**
@@ -176,7 +167,7 @@
      */
     public List<Role> getRolesInGroup(String groupName) throws SecurityException
     {
-        return (List<Role>)super.getAssociatedFrom(groupName, groupType, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        return (List<Role>)super.getAssociatedFrom(groupName, groupType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**
@@ -189,14 +180,14 @@
     	User user = userManager.getUser(username);
         if (user == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER_TYPE_NAME, username));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
         }
         Role role = getRole(roleName);
         if (role == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE_TYPE_NAME, roleName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName));
         }
-        super.addAssociation(user, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        super.addAssociation(user, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**
@@ -209,14 +200,14 @@
     	User user = userManager.getUser(username);
         if (user == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER_TYPE_NAME, username));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, username));
         }
         Role role = getRole(roleName);
         if (role == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE_TYPE_NAME, roleName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName));
         }
-        super.removeAssociation(user, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        super.removeAssociation(user, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**
@@ -238,14 +229,14 @@
     	Group group = groupManager.getGroup(groupName);
         if (group == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP_TYPE_NAME, groupName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
         }
         Role role = getRole(roleName);
         if (role == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE_TYPE_NAME, roleName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName));
         }
-        super.addAssociation(group, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        super.addAssociation(group, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**
@@ -258,14 +249,14 @@
     	Group group = groupManager.getGroup(groupName);
         if (group == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP_TYPE_NAME, groupName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.GROUP, groupName));
         }
         Role role = getRole(roleName);
         if (role == null)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE_TYPE_NAME, roleName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.ROLE, roleName));
         }
-        super.removeAssociation(group, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+        super.removeAssociation(group, role, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
     }
 
     /**

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributesImpl.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/SecurityAttributesImpl.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributesImpl.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/SecurityAttributesImpl.java Mon Sep 22 17:51:02 2008
@@ -25,16 +25,13 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.jetspeed.security.AttributesNotExtendableException;
 import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.AttributeReadOnlyException;
-import org.apache.jetspeed.security.AttributesReadOnlyException;
-import org.apache.jetspeed.security.AttributeRequiredException;
 import org.apache.jetspeed.security.SecurityAttribute;
 import org.apache.jetspeed.security.SecurityAttributeType;
 import org.apache.jetspeed.security.SecurityAttributeTypes;
 import org.apache.jetspeed.security.SecurityAttributes;
-import org.apache.jetspeed.security.spi.SynchronizationStateAccess;
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.spi.impl.SynchronizationStateAccess;
 
 /**
  * @version $Id$
@@ -176,7 +173,7 @@
     }
 
     public SecurityAttribute getAttribute(String name, boolean create)
-        throws AttributesReadOnlyException, AttributesNotExtendableException
+        throws SecurityException
     {
         SecurityAttributeImpl sa = saMap.get(name);
         
@@ -191,7 +188,7 @@
         
         if (isReadOnly() && !isSynchronizing())
         {
-            throw new AttributesReadOnlyException();
+            throw new SecurityException(SecurityException.ATTRIBUTES_ARE_READ_ONLY.createScoped(getPrincipal().getType().getName()));
         }
         
         SecurityAttributeType sat = getSecurityAttributeTypes().getAttributeTypeMap().get(name);
@@ -200,7 +197,7 @@
         {
             if (!isExtendable() && !isSynchronizing())
             {
-                throw new AttributesNotExtendableException();
+                throw new SecurityException(SecurityException.ATTRIBUTES_NOT_EXTENDABLE.createScoped(getPrincipal().getType().getName()));
             }
             // New INFO_CATEGORY attribute, always of type STRING
             SecurityAttributeValue value = new SecurityAttributeValue(name);
@@ -219,22 +216,22 @@
         return sa;
     }
 
-    public void removeAttribute(String name) throws AttributesReadOnlyException, AttributeReadOnlyException, AttributeRequiredException
+    public void removeAttribute(String name) throws SecurityException
     {
         if (isReadOnly() && !isSynchronizing())
         {
-            throw new AttributesReadOnlyException();
+            throw new SecurityException(SecurityException.ATTRIBUTES_ARE_READ_ONLY.createScoped(getPrincipal().getType().getName()));
         }
         SecurityAttributeImpl sa = saMap.get(name);
         if (sa != null)
         {
             if (sa.isReadOnly() && !isSynchronizing())
             {
-                throw new AttributeReadOnlyException();
+                throw new SecurityException(SecurityException.ATTRIBUTE_IS_READ_ONLY.createScoped(getPrincipal().getType().getName(), name));
             }
             if (sa.isRequired() && !isSynchronizing())
             {
-                throw new AttributeRequiredException();
+                throw new SecurityException(SecurityException.ATTRIBUTE_IS_REQUIRED.createScoped(getPrincipal().getType().getName(), name));
             }
             saMap.remove(name);
             avColl.remove(sa.getSecurityAttributeValue());
@@ -242,6 +239,6 @@
     }
     
     protected boolean isSynchronizing(){
-        return SynchronizationStateAccess.getInstance().isSynchronizing();
+        return SynchronizationStateAccess.isSynchronizing();
     }
 }

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=698049&r1=698048&r2=698049&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 Mon Sep 22 17:51:02 2008
@@ -30,6 +30,6 @@
 
 	public TransientGroup(String name)
 	{
-        super(JetspeedPrincipalType.GROUP_TYPE_NAME, name);
+        super(JetspeedPrincipalType.GROUP, name);
 	}
 }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientJetspeedPrincipal.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/TransientJetspeedPrincipal.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientJetspeedPrincipal.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/TransientJetspeedPrincipal.java Mon Sep 22 17:51:02 2008
@@ -24,8 +24,8 @@
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalManagerProvider;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.PrincipalReadOnlyException;
 import org.apache.jetspeed.security.SecurityAttributes;
+import org.apache.jetspeed.security.SecurityException;
 
 /**
  * @$
@@ -103,7 +103,7 @@
         return true;
     }
 
-    public void setEnabled(boolean enabled) throws PrincipalReadOnlyException
+    public void setEnabled(boolean enabled) throws SecurityException
     {
         throw new UnsupportedOperationException();
     }

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=698049&r1=698048&r2=698049&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 Mon Sep 22 17:51:02 2008
@@ -30,6 +30,6 @@
 
 	public TransientRole(String name)
 	{
-        super(JetspeedPrincipalType.ROLE_TYPE_NAME, name);
+        super(JetspeedPrincipalType.ROLE, name);
 	}
 }

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=698049&r1=698048&r2=698049&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 Mon Sep 22 17:51:02 2008
@@ -30,6 +30,6 @@
 
 	public TransientUser(String name)
 	{
-		super(JetspeedPrincipalType.USER_TYPE_NAME, name);
+		super(JetspeedPrincipalType.USER, name);
 	}
 }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.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/UserManagerImpl.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java Mon Sep 22 17:51:02 2008
@@ -29,21 +29,12 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.security.AuthenticatedUser;
 import org.apache.jetspeed.security.AuthenticatedUserImpl;
-import org.apache.jetspeed.security.DependentPrincipalException;
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
 import org.apache.jetspeed.security.JetspeedSubjectFactory;
 import org.apache.jetspeed.security.PasswordCredential;
-import org.apache.jetspeed.security.PrincipalAlreadyExistsException;
-import org.apache.jetspeed.security.PrincipalAssociationNotAllowedException;
-import org.apache.jetspeed.security.PrincipalAssociationRequiredException;
-import org.apache.jetspeed.security.PrincipalAssociationUnsupportedException;
-import org.apache.jetspeed.security.PrincipalNotFoundException;
-import org.apache.jetspeed.security.PrincipalNotRemovableException;
-import org.apache.jetspeed.security.PrincipalReadOnlyException;
-import org.apache.jetspeed.security.PrincipalUpdateException;
 import org.apache.jetspeed.security.PrincipalsSet;
 import org.apache.jetspeed.security.RoleManager;
 import org.apache.jetspeed.security.SecurityException;
@@ -200,12 +191,12 @@
 
 	public List<User> getUsersInGroup(String groupFullPathName) throws SecurityException
 	{
-		return (List<User>) super.getAssociatedTo(groupFullPathName, groupType, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+		return (List<User>) super.getAssociatedTo(groupFullPathName, groupType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
 	}
 
 	public List<User> getUsersInRole(String roleFullPathName) throws SecurityException
 	{
-		return (List<User>) super.getAssociatedTo(roleFullPathName, roleType, JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME);
+		return (List<User>) super.getAssociatedTo(roleFullPathName, roleType, JetspeedPrincipalAssociationType.IS_MEMBER_OF);
 	}
 
 	public List<User> lookupUsers(String attributeName, String attributeValue) throws SecurityException

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAssociationStorageManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAssociationStorageManager.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAssociationStorageManager.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalAssociationStorageManager.java Mon Sep 22 17:51:02 2008
@@ -17,10 +17,6 @@
 package org.apache.jetspeed.security.spi;
 
 import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.PrincipalAssociationNotAllowedException;
-import org.apache.jetspeed.security.PrincipalNotFoundException;
-import org.apache.jetspeed.security.PrincipalAssociationRequiredException;
-import org.apache.jetspeed.security.PrincipalAssociationUnsupportedException;
 import org.apache.jetspeed.security.SecurityException;
 
 /**

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalStorageManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalStorageManager.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalStorageManager.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalStorageManager.java Mon Sep 22 17:51:02 2008
@@ -18,17 +18,8 @@
 
 import java.util.Set;
 
-import org.apache.jetspeed.security.DependentPrincipalException;
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationReference;
-import org.apache.jetspeed.security.PrincipalAlreadyExistsException;
-import org.apache.jetspeed.security.PrincipalAssociationNotAllowedException;
-import org.apache.jetspeed.security.PrincipalAssociationUnsupportedException;
-import org.apache.jetspeed.security.PrincipalNotFoundException;
-import org.apache.jetspeed.security.PrincipalNotRemovableException;
-import org.apache.jetspeed.security.PrincipalReadOnlyException;
-import org.apache.jetspeed.security.PrincipalUpdateException;
-import org.apache.jetspeed.security.PrincipalAssociationRequiredException;
 import org.apache.jetspeed.security.SecurityException;
 
 /**

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalSynchronizer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalSynchronizer.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalSynchronizer.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPrincipalSynchronizer.java Mon Sep 22 17:51:02 2008
@@ -22,9 +22,6 @@
  */
 public interface JetspeedPrincipalSynchronizer
 {
-
-    SynchronizationState getSynchronizationState();
-    
     void synchronizeUserPrincipal(String name);
     
     void synchronizePrincipalsByType(String principalTypeName);

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPrincipalAssociationHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPrincipalAssociationHandler.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPrincipalAssociationHandler.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/BaseJetspeedPrincipalAssociationHandler.java Mon Sep 22 17:51:02 2008
@@ -24,7 +24,6 @@
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalAssociationStorageManager;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalManagerSPI;
-import org.apache.jetspeed.security.spi.SynchronizationStateAccess;
 
 /**
  * @version $Id$
@@ -87,8 +86,8 @@
         }
     }
     
-    protected boolean isSynchronizing(){
-        return SynchronizationStateAccess.getInstance().isSynchronizing();
+    protected boolean isSynchronizing()
+    {
+        return SynchronizationStateAccess.isSynchronizing();
     }
-
 }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedPrincipalSynchronizer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedPrincipalSynchronizer.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedPrincipalSynchronizer.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedPrincipalSynchronizer.java Mon Sep 22 17:51:02 2008
@@ -29,20 +29,11 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.security.AttributeReadOnlyException;
-import org.apache.jetspeed.security.AttributeRequiredException;
-import org.apache.jetspeed.security.AttributesNotExtendableException;
-import org.apache.jetspeed.security.AttributesReadOnlyException;
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalManager;
 import org.apache.jetspeed.security.JetspeedPrincipalManagerProvider;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.PrincipalAssociationNotAllowedException;
-import org.apache.jetspeed.security.PrincipalAssociationRequiredException;
-import org.apache.jetspeed.security.PrincipalAssociationUnsupportedException;
-import org.apache.jetspeed.security.PrincipalNotFoundException;
 import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.PrincipalUpdateException;
 import org.apache.jetspeed.security.SecurityAttribute;
 import org.apache.jetspeed.security.SecurityAttributeType;
 import org.apache.jetspeed.security.SecurityAttributes;
@@ -51,7 +42,6 @@
 import org.apache.jetspeed.security.mapping.model.Attribute;
 import org.apache.jetspeed.security.mapping.model.Entity;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalSynchronizer;
-import org.apache.jetspeed.security.spi.SynchronizationState;
 
 /**
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
@@ -60,21 +50,8 @@
  */
 public class DefaultJetspeedPrincipalSynchronizer implements JetspeedPrincipalSynchronizer
 {
-
     private static final Log logger = LogFactory.getLog(DefaultJetspeedPrincipalSynchronizer.class);
 
-    private static ThreadLocal synchronizing = new ThreadLocal();  
-    
-    private static final SynchronizationState syncStateSingleton = new SynchronizationState(){
-
-        public boolean isSynchronizing()
-        {
-            Boolean syncing = (Boolean)synchronizing.get();
-            return syncing != null && syncing;
-        }
-        
-    };
-    
     JetspeedPrincipalManagerProvider principalManagerProvider;
 
     SecurityEntityManager securityEntityManager;
@@ -98,30 +75,48 @@
 
     public void synchronizeAll()
     {
-        setSynchronizing(true);
-        // TODO
-        setSynchronizing(false);
+        try
+        {
+            setSynchronizing(true);
+            // TODO
+        }
+        finally
+        {
+            setSynchronizing(false);
+        }
     }
 
     public void synchronizePrincipalsByType(String principalTypeName)
     {
-        setSynchronizing(true);
-        // TODO
-        setSynchronizing(false);
+        try
+        {
+            setSynchronizing(true);
+            // TODO
+        }
+        finally
+        {
+            setSynchronizing(false);
+        }
     }
 
     public void synchronizeUserPrincipal(String name)
     {
-        setSynchronizing(true);
-        
-        // don't process relations going towards users to avoid sync'ing huge
-        // amounts of data.
-        // TODO: allow processing of required relations towards users.
-        Collection<String> skipEntities = Arrays.asList(new String[]
-        { JetspeedPrincipalType.USER_TYPE_NAME});
-        recursiveSynchronizePrincipal(securityEntityManager.getEntity(JetspeedPrincipalType.USER_TYPE_NAME, name), new InternalSynchronizationState(skipEntities));
-        
-        setSynchronizing(false);
+        try
+        {
+            setSynchronizing(true);
+            
+            // don't process relations going towards users to avoid sync'ing huge
+            // amounts of data.
+            // TODO: allow processing of required relations towards users.
+            Collection<String> skipEntities = Arrays.asList(new String[]
+            { JetspeedPrincipalType.USER});
+            recursiveSynchronizePrincipal(securityEntityManager.getEntity(JetspeedPrincipalType.USER, name), new InternalSynchronizationState(skipEntities));
+            
+        }
+        finally
+        {
+            setSynchronizing(false);
+        }
     }
 
     public JetspeedPrincipal recursiveSynchronizePrincipal(Entity entity, InternalSynchronizationState syncState)
@@ -267,7 +262,8 @@
                 // principal manager
                 updatedPrincipal = principalManager.newPrincipal(entity.getId(), true);
                 attrsToBeUpdated.addAll(mappedEntityAttrs.values());
-            } else if (updatedPrincipal.isMapped())
+            } 
+            else if (updatedPrincipal.isMapped())
             {
                 SecurityAttributes principalAttrs = updatedPrincipal.getSecurityAttributes();
                 for (Map.Entry<String, Attribute> entityAttrEntry : mappedEntityAttrs.entrySet())
@@ -280,14 +276,16 @@
                         {
                             // TODO : multi-valued Principal attrs are not yet
                             // supported
-                        } else
+                        } 
+                        else
                         {
                             if (!StringUtils.equals(principalAttr.getStringValue(), entityAttr.getValue()))
                             {
                                 attrsToBeUpdated.add(entityAttr);
                             }
                         }
-                    } else
+                    } 
+                    else
                     {
                         attrsToBeUpdated.add(entityAttr);
                     }
@@ -311,27 +309,14 @@
                             principalAttr = principalAttrs.getAttribute(addedEntityAttr.getMappedName(), true);
                         }
                         principalAttr.setStringValue(addedEntityAttr.getValue());
-                    } catch (AttributesReadOnlyException e)
-                    {
-                        if (logger.isErrorEnabled())
-                        {
-                            logger.error("Unexpected read-only exception for attribute " + addedEntityAttr.getMappedName() + ".", e);
-                        }
                     } 
-                    catch (AttributesNotExtendableException e)
+                    catch (SecurityException e)
                     {
                         if (logger.isErrorEnabled())
                         {
-                            logger.error("Unexpected not extendable exception for attribute " + addedEntityAttr.getMappedName() + ".", e);
+                            logger.error("Unexpected exception for attribute " + addedEntityAttr.getMappedName() + ".", e);
                         }
-                    }
-                    catch (AttributeReadOnlyException e)
-                    {
-                        if (logger.isErrorEnabled())
-                        {
-                            logger.error("Unexpected read-only exception for attribute " + addedEntityAttr.getMappedName() + ".", e);
-                        }
-                    }
+                    } 
                 }
             }
             if (updatedPrincipal.isMapped())
@@ -347,15 +332,8 @@
                         {
                             principalAttrs.removeAttribute(principalAttrEntry.getKey());
                             updated = true;
-                        } catch (AttributesReadOnlyException e)
-                        {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
-                        } catch (AttributeReadOnlyException e)
-                        {
-                            // TODO Auto-generated catch block
-                            e.printStackTrace();
-                        } catch (AttributeRequiredException e)
+                        }
+                        catch (SecurityException e)
                         {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
@@ -368,26 +346,24 @@
                     try
                     {
                         principalManager.updatePrincipal(updatedPrincipal);
-                    } catch (SecurityException e){
+                    } 
+                    catch (SecurityException e)
+                    {
                         logger.error("Unexpected SecurityException: could not synchronize principal " + updatedPrincipal.getName() + " of type " + updatedPrincipal.getType().getName(), e);
                     }  
                 }
             }
 
-        } else
+        } 
+        else
         {
             // TODO throw proper exception
         }
         return updatedPrincipal;
     }
 
-    public SynchronizationState getSynchronizationState()
-    {
-        return syncStateSingleton;
-    }
-
     private void setSynchronizing(boolean sync){
-        this.synchronizing.set(new Boolean(sync));
+        SynchronizationStateAccess.setSynchronizing(sync ? Boolean.TRUE : Boolean.FALSE);
     }
     
     public void setPrincipalManagerProvider(JetspeedPrincipalManagerProvider principalManagerProvider)

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SimpleMemberOfPrincipalAssociationHandler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SimpleMemberOfPrincipalAssociationHandler.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SimpleMemberOfPrincipalAssociationHandler.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SimpleMemberOfPrincipalAssociationHandler.java Mon Sep 22 17:51:02 2008
@@ -17,10 +17,8 @@
 
 package org.apache.jetspeed.security.spi.impl;
 
-import org.apache.jetspeed.security.DependentPrincipalException;
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalAssociationType;
-import org.apache.jetspeed.security.PrincipalNotRemovableException;
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.impl.JetspeedPrincipalAssociationTypeImpl;
 import org.apache.jetspeed.security.spi.JetspeedPrincipalAssociationStorageManager;

Copied: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SynchronizationStateAccess.java (from r697979, portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SynchronizationStateAccess.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SynchronizationStateAccess.java?p2=portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SynchronizationStateAccess.java&p1=portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SynchronizationStateAccess.java&r1=697979&r2=698049&rev=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/SynchronizationStateAccess.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SynchronizationStateAccess.java Mon Sep 22 17:51:02 2008
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jetspeed.security.spi;
+package org.apache.jetspeed.security.spi.impl;
 
 
 
@@ -24,15 +24,22 @@
  */
 public class SynchronizationStateAccess
 {
-    private static JetspeedPrincipalSynchronizer synchronizer;
+    private static ThreadLocal<Boolean> synchronizing = new ThreadLocal<Boolean>();
     
-    protected SynchronizationStateAccess(JetspeedPrincipalSynchronizer synchronizer){
-        this.synchronizer = synchronizer;
-    }
-    
-    public static SynchronizationState getInstance()
+    public static boolean isSynchronizing()
     {        
-        return synchronizer.getSynchronizationState();
+        return synchronizing.get() != null;
     }
     
+    public static void setSynchronizing(Boolean synchronizing)
+    {
+        if (synchronizing != null && synchronizing.booleanValue())
+        {
+            SynchronizationStateAccess.synchronizing.set(synchronizing);
+        }
+        else
+        {
+            SynchronizationStateAccess.synchronizing.remove();
+        }
+    }
 }

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SynchronizationStateAccess.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/SynchronizationStateAccess.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserPasswordCredentialManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserPasswordCredentialManagerImpl.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserPasswordCredentialManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserPasswordCredentialManagerImpl.java Mon Sep 22 17:51:02 2008
@@ -83,7 +83,7 @@
         }
         if (!credential.isEnabled() || credential.isExpired())
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER_TYPE_NAME, userName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
         }
         try
         {
@@ -91,11 +91,11 @@
         }
         catch (Exception e)
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER_TYPE_NAME, userName), e);
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName), e);
         }
         if (credential.getUser() == null || !credential.getUser().isEnabled())
         {
-            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER_TYPE_NAME, userName));
+            throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(JetspeedPrincipalType.USER, userName));
         }
         return credential;
     }

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserSubjectPrincipalsResolverImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserSubjectPrincipalsResolverImpl.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserSubjectPrincipalsResolverImpl.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/UserSubjectPrincipalsResolverImpl.java Mon Sep 22 17:51:02 2008
@@ -55,19 +55,19 @@
                                          JetspeedPrincipalAssociationType userAssociationType,
                                          JetspeedPrincipalAssociationType indirectAssociationType)
     {
-        if (!spp.getPrincipalType().getName().equals(JetspeedPrincipalType.USER_TYPE_NAME))
+        if (!spp.getPrincipalType().getName().equals(JetspeedPrincipalType.USER))
         {
             throw new IllegalArgumentException("The provided SubjectPrincipalsProvider should be for the user principalType");
         }
         this.spp = spp;
 
-        if (principalType.getName().equals(JetspeedPrincipalType.USER_TYPE_NAME))
+        if (principalType.getName().equals(JetspeedPrincipalType.USER))
         {
             throw new IllegalArgumentException("This resolver principalType cannot be that of the user principalType");
         }
         this.principalType = principalType;        
         
-        if (userAssociationType.getFromPrincipalType().getName().equals(JetspeedPrincipalType.USER_TYPE_NAME))
+        if (userAssociationType.getFromPrincipalType().getName().equals(JetspeedPrincipalType.USER))
         {
             if (userAssociationType.getToPrincipalType() != principalType)
             {
@@ -75,7 +75,7 @@
             }
             fromUser = true;
         }
-        else if (userAssociationType.getToPrincipalType().getName().equals(JetspeedPrincipalType.USER_TYPE_NAME))
+        else if (userAssociationType.getToPrincipalType().getName().equals(JetspeedPrincipalType.USER))
         {
             if (userAssociationType.getFromPrincipalType() != principalType)
             {

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/serializer/JetspeedSecuritySerializer.java Mon Sep 22 17:51:02 2008
@@ -43,6 +43,7 @@
 import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.security.SecurityAttribute;
 import org.apache.jetspeed.security.SecurityAttributes;
+import org.apache.jetspeed.security.spi.impl.SynchronizationStateAccess;
 import org.apache.jetspeed.serializer.objects.JSGroup;
 import org.apache.jetspeed.serializer.objects.JSNVPElement;
 import org.apache.jetspeed.serializer.objects.JSNVPElements;
@@ -78,9 +79,9 @@
         
         public ImportRefs()
         {
-            principalMapByType.put(JetspeedPrincipalType.USER_TYPE_NAME, userMap);
-            principalMapByType.put(JetspeedPrincipalType.GROUP_TYPE_NAME, groupMap);
-            principalMapByType.put(JetspeedPrincipalType.ROLE_TYPE_NAME, roleMap);
+            principalMapByType.put(JetspeedPrincipalType.USER, userMap);
+            principalMapByType.put(JetspeedPrincipalType.GROUP, groupMap);
+            principalMapByType.put(JetspeedPrincipalType.ROLE, roleMap);
         }
         
         public HashMap<String, Principal> getPrincipalMap(String principalTypeName)
@@ -165,13 +166,21 @@
         if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_USERS))
         {
             log.info("creating users/roles/groups and permissions");
-            ImportRefs refs = new ImportRefs();
-            recreateJetspeedPrincipals(refs, snapshot, settings, log);
-            recreateRolesGroupsUsers(refs, snapshot, settings, log);
-            if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_PERMISSIONS))
+            try
+            {
+                SynchronizationStateAccess.setSynchronizing(Boolean.TRUE);
+                ImportRefs refs = new ImportRefs();
+                recreateJetspeedPrincipals(refs, snapshot, settings, log);
+                recreateRolesGroupsUsers(refs, snapshot, settings, log);
+                if (isSettingSet(settings, JetspeedSerializer.KEY_PROCESS_PERMISSIONS))
+                {
+                    log.info("creating permissions");
+                    recreatePermissions(refs, snapshot, settings, log);
+                }
+            }
+            finally
             {
-                log.info("creating permissions");
-                recreatePermissions(refs, snapshot, settings, log);
+                SynchronizationStateAccess.setSynchronizing(Boolean.FALSE);
             }
         }
     }
@@ -183,6 +192,7 @@
             log.info("deleting users/roles/groups and permissions");
             try
             {
+                SynchronizationStateAccess.setSynchronizing(Boolean.TRUE);
                 for (JetspeedPermission permission : pm.getPermissions())
                 {
                     pm.removePermission(permission);
@@ -208,6 +218,10 @@
             {
                 throw new SerializerException(e);
             }
+            finally
+            {
+                SynchronizationStateAccess.setSynchronizing(Boolean.FALSE);
+            }
         }
     }
 

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/spi/TestDefaultJetspeedSynchronizer.java Mon Sep 22 17:51:02 2008
@@ -21,7 +21,6 @@
 import org.apache.jetspeed.security.mapping.stubs.StubEntityFactory;
 import org.apache.jetspeed.security.mapping.stubs.StubEntityRelationDAO;
 
-
 public class TestDefaultJetspeedSynchronizer extends TestCase
 {
 
@@ -69,9 +68,9 @@
         userDao.addEntity(group_yetAnother);
 
         StubEntityRelationDAO userToRole = new StubEntityRelationDAO(new SecurityEntityRelationTypeImpl(
-                JetspeedPrincipalAssociationType.IS_MEMBER_OF_ASSOCIATION_TYPE_NAME,
-                JetspeedPrincipalType.USER_TYPE_NAME,
-                JetspeedPrincipalType.ROLE_TYPE_NAME));
+                JetspeedPrincipalAssociationType.IS_MEMBER_OF,
+                JetspeedPrincipalType.USER,
+                JetspeedPrincipalType.ROLE));
         userToRole.relate(null, null, user_jsmith, role_manager);
         userToRole.relate(null, null, user_jsmith, role_random);
         userToRole.relate(null, null, user_jdoe, role_manager);
@@ -79,9 +78,9 @@
         userToRole.relate(null, null, user_jdoe, role_admin);
 
         StubEntityRelationDAO userToGroup = new StubEntityRelationDAO(new SecurityEntityRelationTypeImpl(
-                JetspeedPrincipalAssociationType.IS_CHILD_OF_ASSOCIATION_TYPE_NAME,
-                JetspeedPrincipalType.USER_TYPE_NAME,
-                JetspeedPrincipalType.GROUP_TYPE_NAME));
+                JetspeedPrincipalAssociationType.IS_CHILD_OF,
+                JetspeedPrincipalType.USER,
+                JetspeedPrincipalType.GROUP));
         userToGroup.relate(null, null, user_jsmith, group_programmers);
         userToGroup.relate(null, null, user_jsmith, group_random);
         userToGroup.relate(null, null, user_jdoe, group_board);
@@ -89,17 +88,17 @@
         userToGroup.relate(null, null, user_jdoe, group_random);
         
         StubEntityRelationDAO groupToRole = new StubEntityRelationDAO(new SecurityEntityRelationTypeImpl(
-                JetspeedPrincipalAssociationType.IS_CHILD_OF_ASSOCIATION_TYPE_NAME,
-                JetspeedPrincipalType.GROUP_TYPE_NAME,
-                JetspeedPrincipalType.ROLE_TYPE_NAME));
+                JetspeedPrincipalAssociationType.IS_CHILD_OF,
+                JetspeedPrincipalType.GROUP,
+                JetspeedPrincipalType.ROLE));
         
         groupToRole.relate(null, null, group_board, role_manager);
         groupToRole.relate(null, null, group_programmers, role_yetAnother);
         
         Map<String,EntityDAO> entityDAOs = new HashMap<String,EntityDAO>();
-        entityDAOs.put(JetspeedPrincipalType.USER_TYPE_NAME,userDao);
-        entityDAOs.put(JetspeedPrincipalType.ROLE_TYPE_NAME,roleDao);
-        entityDAOs.put(JetspeedPrincipalType.USER_TYPE_NAME,groupDao);
+        entityDAOs.put(JetspeedPrincipalType.USER,userDao);
+        entityDAOs.put(JetspeedPrincipalType.ROLE,roleDao);
+        entityDAOs.put(JetspeedPrincipalType.USER,groupDao);
 
         Collection<EntityRelationDAO> entityRelationDAOs = new ArrayList<EntityRelationDAO>();
         entityRelationDAOs.add(userToRole);

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java?rev=698049&r1=698048&r2=698049&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubJetspeedPrincipal.java Mon Sep 22 17:51:02 2008
@@ -21,8 +21,8 @@
 
 import org.apache.jetspeed.security.JetspeedPrincipal;
 import org.apache.jetspeed.security.JetspeedPrincipalType;
-import org.apache.jetspeed.security.PrincipalReadOnlyException;
 import org.apache.jetspeed.security.SecurityAttributes;
+import org.apache.jetspeed.security.SecurityException;
 
 
 /**
@@ -144,7 +144,7 @@
     /* (non-Javadoc)
      * @see org.apache.jetspeed.security.JetspeedPrincipal#setEnabled(boolean)
      */
-    public void setEnabled(boolean enabled) throws PrincipalReadOnlyException
+    public void setEnabled(boolean enabled) throws SecurityException
     {
         // TODO Auto-generated method stub
 



---------------------------------------------------------------------
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