You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by dd...@apache.org on 2008/10/07 16:47:47 UTC
svn commit: r702498 -
/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.java
Author: ddam
Date: Tue Oct 7 07:47:46 2008
New Revision: 702498
URL: http://svn.apache.org/viewvc?rev=702498&view=rev
Log:
throw exception when entity is not found in ldap
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.java
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.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/AttributeBasedRelationDAO.java?rev=702498&r1=702497&r2=702498&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/impl/AttributeBasedRelationDAO.java Tue Oct 7 07:47:46 2008
@@ -121,18 +121,26 @@
this.attributeContainsInternalId = attributeContainsInternalId;
}
+ private Entity getLiveEntity(EntityDAO dao, Entity transientEntity) throws SecurityException {
+ Entity liveEntity = dao.getEntity(transientEntity.getId());
+ if (liveEntity == null){
+ throw new SecurityException(SecurityException.PRINCIPAL_DOES_NOT_EXIST.createScoped(transientEntity.getType(), transientEntity.getId()));
+ }
+ if (liveEntity.getInternalId() == null){
+ throw new SecurityException(SecurityException.UNEXPECTED);
+ }
+ return liveEntity;
+ }
+
private void internalAddRelation(EntityDAO fromEntityDAO, EntityDAO toEntityDAO, Entity fromEntity, Entity toEntity) throws SecurityException
{
- fromEntity = fromEntityDAO.getEntity(fromEntity.getId());
- toEntity = toEntityDAO.getEntity(toEntity.getId());
+ fromEntity = getLiveEntity(fromEntityDAO, fromEntity);
+
+ toEntity = getLiveEntity(toEntityDAO, toEntity);
+
String attrValue = null;
if (attributeContainsInternalId)
- {
- if (toEntity.getInternalId() == null)
- {
- // internal ID (ldap DN) is not present, refetch the entity from LDAP to get the DN
- toEntity = toEntityDAO.getEntity(toEntity.getId());
- }
+ {
attrValue = toEntity.getInternalId();
}
else
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org