portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r702172 - /portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
Date Mon, 06 Oct 2008 14:45:59 GMT
Author: ddam
Date: Mon Oct  6 07:45:59 2008
New Revision: 702172

URL: http://svn.apache.org/viewvc?rev=702172&view=rev
Log:
- fix bug in update method: used Entity fetched from LDAP instead of Entity derived from Principal
- fixed incorrect SecurityException messages

Modified:
    portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java

Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java?rev=702172&r1=702171&r2=702172&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
(original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/SpringLDAPEntityDAO.java
Mon Oct  6 07:45:59 2008
@@ -218,7 +218,14 @@
 
     private void internalUpdate(Entity entity, UpdateMode umode) throws SecurityException
     {
-        Name dn = getRelativeDN(entity.getInternalId());
+        String internalId = entity.getInternalId();
+        if (internalId == null){
+            Entity ldapEntity = getEntity(entity.getId());
+            if (ldapEntity == null || ldapEntity.getInternalId() == null) { throw new SecurityException(SecurityException.PRINCIPAL_UPDATE_FAILURE.createScoped(entity.getType(),
entity.getId())); }
+            internalId=ldapEntity.getInternalId();
+        }
+        
+        Name dn = getRelativeDN(internalId);
         DirContextOperations dirCtxOps = null;
         ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
         try
@@ -330,7 +337,7 @@
 
     public void remove(Entity entity) throws SecurityException
     {
-        if (!entityExists(entity)) { throw new SecurityException(SecurityException.PRINCIPAL_ALREADY_EXISTS.createScoped(entity.getType(),
entity.getId())); }
+        if (!entityExists(entity)) { throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(entity.getType(),
entity.getId())); }
         String internalIdStr = entity.getInternalId();
         if (internalIdStr == null)
         {
@@ -359,9 +366,7 @@
 
     public void update(Entity entity) throws SecurityException
     {
-        Entity ldapEntity = getEntity(entity.getId());
-        if (ldapEntity == null) { throw new SecurityException(SecurityException.PRINCIPAL_ALREADY_EXISTS.createScoped(entity.getType(),
entity.getId())); }
-        internalUpdate(ldapEntity, UpdateMode.MAPPED);
+        internalUpdate(entity, UpdateMode.MAPPED);
     }
 
     public void updateInternalAttributes(Entity entity) throws SecurityException



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