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 vk...@apache.org on 2008/10/01 15:39:56 UTC
svn commit: r700765 - in
/portals/jetspeed-2/portal/branches/security-refactoring:
components/jetspeed-security/src/main/java/org/apache/jetspeed/security/
components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/
components/jets...
Author: vkumar
Date: Wed Oct 1 06:39:55 2008
New Revision: 700765
URL: http://svn.apache.org/viewvc?rev=700765&view=rev
Log:
Few corrections in security-ldap.xml and replication code.
Modified:
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SecurityEntityManager.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/DefaultLDAPEntityManager.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPostContextLoader.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedSecuritySynchronizer.java
portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalLdapStorageManager.java
portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java
portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java?rev=700765&r1=700764&r2=700765&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/JetspeedBeanPostProcessor.java Wed Oct 1 06:39:55 2008
@@ -60,7 +60,7 @@
try
{
intializer = (JetspeedBeanInitializer) context.getBean(bean);
- intializer.intialize();
+ intializer.initialize();
}
catch (Exception e)
{
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SecurityEntityManager.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/SecurityEntityManager.java?rev=700765&r1=700764&r2=700765&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SecurityEntityManager.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/SecurityEntityManager.java Wed Oct 1 06:39:55 2008
@@ -37,11 +37,11 @@
Collection<Entity> getAllEntities(String entityType);
- void addEnity(Entity entity);
+ void addEntity(Entity entity);
- void removeEnity(Entity entity);
+ void removeEntity(Entity entity);
- void updateEnity(Entity entity);
+ void updateEntity(Entity entity);
void addRelation(Entity fromEntity, Entity toEntity, SecurityEntityRelationType relationType);
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/DefaultLDAPEntityManager.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/DefaultLDAPEntityManager.java?rev=700765&r1=700764&r2=700765&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/DefaultLDAPEntityManager.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/mapping/ldap/dao/DefaultLDAPEntityManager.java Wed Oct 1 06:39:55 2008
@@ -34,14 +34,12 @@
*/
public class DefaultLDAPEntityManager implements SecurityEntityManager
{
-
// entity type DAOs
protected Map<String, EntityDAO> entityDAOs;
-
protected Map<SecurityEntityRelationType, EntityRelationDAO> entityRelationDAOs = new HashMap<SecurityEntityRelationType, EntityRelationDAO>();
public Collection<SecurityEntityRelationType> getSupportedEntityRelationTypes()
- {
+ {
return Collections.unmodifiableCollection(entityRelationDAOs.keySet());
}
@@ -50,62 +48,58 @@
return Collections.unmodifiableCollection(entityDAOs.keySet());
}
- public Collection<SecurityEntityRelationType> getSupportedEntityRelationTypes(
- String entityType)
+ public Collection<SecurityEntityRelationType> getSupportedEntityRelationTypes(String entityType)
{
- Collection<SecurityEntityRelationType> supportedRelationTypes=new ArrayList<SecurityEntityRelationType>();
+ Collection<SecurityEntityRelationType> supportedRelationTypes = new ArrayList<SecurityEntityRelationType>();
for (SecurityEntityRelationType type : entityRelationDAOs.keySet())
{
- if (type.getFromEntityType().equals(entityType) || type.getToEntityType().equals(entityType)){
+ if (type.getFromEntityType().equals(entityType) || type.getToEntityType().equals(entityType))
+ {
supportedRelationTypes.add(type);
}
-
}
return Collections.unmodifiableCollection(supportedRelationTypes);
}
private EntityDAO getDAOForEntity(Entity entity)
{
- return entity.getType() != null ? entityDAOs.get(entity.getType())
- : null;
+ return entity.getType() != null ? entityDAOs.get(entity.getType()) : null;
}
- private EntityRelationDAO getRelationDAO(String relationType,
- String fromEntityType, String targetEntityType)
+ private EntityRelationDAO getRelationDAO(String relationType, String fromEntityType, String targetEntityType)
{
- return entityRelationDAOs.get(new SecurityEntityRelationTypeImpl(relationType,
- fromEntityType, targetEntityType));
+ return entityRelationDAOs.get(new SecurityEntityRelationTypeImpl(relationType, fromEntityType, targetEntityType));
}
- public void addRelation(Entity sourceEntity, Entity targetEntity,
- SecurityEntityRelationType relationType)
+ public void addRelation(Entity sourceEntity, Entity targetEntity, SecurityEntityRelationType relationType)
{
EntityRelationDAO relationDAO = entityRelationDAOs.get(relationType);
if (relationDAO != null)
{
EntityDAO sourceDAO;
EntityDAO targetDAO;
- if (relationType.getFromEntityType().equals(sourceEntity.getType())){
- sourceDAO=entityDAOs.get(sourceEntity.getType());
- targetDAO=entityDAOs.get(relationType.getToEntityType());
- } else {
- targetDAO=entityDAOs.get(sourceEntity.getType());
- sourceDAO=entityDAOs.get(relationType.getToEntityType());
- }
+ if (relationType.getFromEntityType().equals(sourceEntity.getType()))
+ {
+ sourceDAO = entityDAOs.get(sourceEntity.getType());
+ targetDAO = entityDAOs.get(relationType.getToEntityType());
+ }
+ else
+ {
+ targetDAO = entityDAOs.get(sourceEntity.getType());
+ sourceDAO = entityDAOs.get(relationType.getToEntityType());
+ }
if (relationDAO != null)
{
- relationDAO.addRelation(sourceDAO, targetDAO, sourceEntity,
- targetEntity);
+ relationDAO.addRelation(sourceDAO, targetDAO, sourceEntity, targetEntity);
}
}
}
-
+
public void removeRelation(Entity entity, Entity relatedEntity, SecurityEntityRelationType relationType)
{
// TODO Auto-generated method stub
-
}
-
+
public Collection<Entity> getAllEntities(String entityType)
{
EntityDAO dao = entityDAOs.get(entityType);
@@ -118,37 +112,33 @@
return dao != null ? dao.getEntity(entityId) : null;
}
- public Collection<Entity> getRelatedEntitiesTo(Entity toEntity,
- SecurityEntityRelationType relationType)
+ public Collection<Entity> getRelatedEntitiesTo(Entity toEntity, SecurityEntityRelationType relationType)
{
- EntityDAO fromDAO=entityDAOs.get(relationType.getFromEntityType());
- EntityDAO toDAO=entityDAOs.get(relationType.getToEntityType());
+ EntityDAO fromDAO = entityDAOs.get(relationType.getFromEntityType());
+ EntityDAO toDAO = entityDAOs.get(relationType.getToEntityType());
EntityRelationDAO relationDAO = entityRelationDAOs.get(relationType);
if (fromDAO != null && toDAO != null && relationDAO != null)
{
- return relationDAO.getRelatedEntitiesTo(
- fromDAO, toDAO, toEntity);
+ return relationDAO.getRelatedEntitiesTo(fromDAO, toDAO, toEntity);
}
return null; // todo : throw exception, since combination of entity
- // types and relation type is not configured.
+ // types and relation type is not configured.
}
- public Collection<Entity> getRelatedEntitiesFrom(Entity fromEntity,
- SecurityEntityRelationType relationType)
+ public Collection<Entity> getRelatedEntitiesFrom(Entity fromEntity, SecurityEntityRelationType relationType)
{
- EntityDAO fromDAO=entityDAOs.get(relationType.getFromEntityType());
- EntityDAO toDAO=entityDAOs.get(relationType.getToEntityType());
+ EntityDAO fromDAO = entityDAOs.get(relationType.getFromEntityType());
+ EntityDAO toDAO = entityDAOs.get(relationType.getToEntityType());
EntityRelationDAO relationDAO = entityRelationDAOs.get(relationType);
if (fromDAO != null && toDAO != null && relationDAO != null)
{
- return relationDAO.getRelatedEntitiesFrom(
- fromDAO, toDAO, fromEntity);
+ return relationDAO.getRelatedEntitiesFrom(fromDAO, toDAO, fromEntity);
}
return null; // todo : throw exception, since combination of entity
- // types and relation type is not configured.
+ // types and relation type is not configured.
}
- public void update(Entity entity)
+ public void updateEntity(Entity entity)
{
EntityDAO dao = getDAOForEntity(entity);
if (dao != null)
@@ -157,25 +147,41 @@
}
}
+ public void removeEntity(Entity entity)
+ {
+ EntityDAO dao = getDAOForEntity(entity);
+ if (dao != null)
+ {
+ dao.update(entity);
+ }
+ }
+
+ public void addEntity(Entity entity)
+ {
+ EntityDAO dao = getDAOForEntity(entity);
+ if (dao != null)
+ {
+ dao.addEntity(entity);
+ }
+ }
+
public void setEntityDAOs(Map<String, EntityDAO> entityDAOs)
{
this.entityDAOs = entityDAOs;
}
- public void setEntityRelationDAOs(
- Collection<EntityRelationDAO> entityRelationDAOs)
+ public void setEntityRelationDAOs(Collection<EntityRelationDAO> entityRelationDAOs)
{
this.entityRelationDAOs.clear();
for (EntityRelationDAO dao : entityRelationDAOs)
{
- this.entityRelationDAOs.put( dao.getRelationType(), dao);
+ this.entityRelationDAOs.put(dao.getRelationType(), dao);
}
}
public EntityFactory getEntityFactory(String entityType)
{
EntityDAO dao = entityDAOs.get(entityType);
-
return dao != null ? dao.getEntityFactory() : null;
}
}
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPostContextLoader.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/JetspeedPostContextLoader.java?rev=700765&r1=700764&r2=700765&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPostContextLoader.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/JetspeedPostContextLoader.java Wed Oct 1 06:39:55 2008
@@ -21,7 +21,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.jetspeed.security.JetspeedBeanInitializer;
import org.apache.jetspeed.security.SecurityException;
-import org.apache.jetspeed.security.User;
import org.apache.jetspeed.security.UserManager;
/**
@@ -48,8 +47,8 @@
this.synchronizeAllUser = synchronizeAllUser;
this.synchronizeEntityType = synchronizeEntityType;
}
-
- public void intialize()
+
+ public void initialize()
{
if (synchronizer != null)
{
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedSecuritySynchronizer.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/DefaultJetspeedSecuritySynchronizer.java?rev=700765&r1=700764&r2=700765&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedSecuritySynchronizer.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/DefaultJetspeedSecuritySynchronizer.java Wed Oct 1 06:39:55 2008
@@ -75,7 +75,6 @@
// don't skip any entity type when synchronizing all
Collection<String> skipEntities = new ArrayList<String>();
InternalSynchronizationState synchronizationState = new InternalSynchronizationState(skipEntities);
-
for (String type : securityEntityManager.getSupportedEntityTypes())
{
for (Entity entity : securityEntityManager.getAllEntities(type))
@@ -251,6 +250,8 @@
syncState.setRelationProcessed(relationTypeForThisEntity, fromEntity, toEntity, entityIsFromEntity);
// first create/update principal
// JetspeedPrincipal relatedPrincipal = recursiveSynchronizePrincipal(relatedEntity, syncState);
+
+ //TODO change for nested level of group and roles.
JetspeedPrincipal relatedPrincipal = null;
JetspeedPrincipalManager principalManager = principalManagerProvider
.getManager(principalManagerProvider
Modified: portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalLdapStorageManager.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/JetspeedPrincipalLdapStorageManager.java?rev=700765&r1=700764&r2=700765&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalLdapStorageManager.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/spi/impl/JetspeedPrincipalLdapStorageManager.java Wed Oct 1 06:39:55 2008
@@ -21,6 +21,8 @@
import org.apache.jetspeed.security.JetspeedPrincipal;
import org.apache.jetspeed.security.JetspeedPrincipalAssociationReference;
import org.apache.jetspeed.security.SecurityException;
+import org.apache.jetspeed.security.mapping.EntityFactory;
+import org.apache.jetspeed.security.mapping.SecurityEntityManager;
import org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager;
/**
@@ -29,15 +31,19 @@
*/
public class JetspeedPrincipalLdapStorageManager implements JetspeedPrincipalStorageManager
{
+ private SecurityEntityManager ldapEntityManager;
private JetspeedPrincipalStorageManager delegateJpsm;
-
- public JetspeedPrincipalLdapStorageManager(JetspeedPrincipalStorageManager ldapStorage,JetspeedPrincipalStorageManager databaseStorage)
+
+ public JetspeedPrincipalLdapStorageManager(JetspeedPrincipalStorageManager databaseStorage,SecurityEntityManager ldapEntityManager)
{
this.delegateJpsm = databaseStorage;
+ this.ldapEntityManager = ldapEntityManager;
}
public void addPrincipal(JetspeedPrincipal principal, Set<JetspeedPrincipalAssociationReference> associations) throws SecurityException
{
+ EntityFactory entityFactory = ldapEntityManager.getEntityFactory(principal.getType().getName());
+ ldapEntityManager.addEntity(entityFactory.createEntity(principal));
delegateJpsm.addPrincipal(principal, associations);
}
@@ -48,11 +54,15 @@
public void removePrincipal(JetspeedPrincipal principal) throws SecurityException
{
+ EntityFactory entityFactory = ldapEntityManager.getEntityFactory(principal.getType().getName());
+ ldapEntityManager.removeEntity(entityFactory.createEntity(principal));
delegateJpsm.removePrincipal(principal);
}
public void updatePrincipal(JetspeedPrincipal principal) throws SecurityException
{
+ EntityFactory entityFactory = ldapEntityManager.getEntityFactory(principal.getType().getName());
+ ldapEntityManager.updateEntity(entityFactory.createEntity(principal));
delegateJpsm.updatePrincipal(principal);
}
}
Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java?rev=700765&r1=700764&r2=700765&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-api/src/main/java/org/apache/jetspeed/security/JetspeedBeanInitializer.java Wed Oct 1 06:39:55 2008
@@ -22,5 +22,5 @@
*/
public interface JetspeedBeanInitializer
{
- void intialize();
+ void initialize();
}
Modified: portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml?rev=700765&r1=700764&r2=700765&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml (original)
+++ portals/jetspeed-2/portal/branches/security-refactoring/jetspeed-portal-resources/src/main/resources/assembly/security-ldap.xml Wed Oct 1 06:39:55 2008
@@ -20,7 +20,8 @@
<bean id="JetspeedPrincipalStorageManager" class="org.apache.jetspeed.security.spi.impl.JetspeedPrincipalLdapStorageManager">
<meta key="j2:cat" value="ldap" />
- <constructor-arg index="1" ref="org.apache.jetspeed.security.spi.JetspeedSecurityPersistenceManager" />
+ <constructor-arg index="0" ref="org.apache.jetspeed.security.spi.JetspeedSecurityPersistenceManager" />
+ <constructor-arg index="1" ref="org.apache.jetspeed.security.mapping.SecurityEntityManager" />
</bean>
<bean id="org.apache.jetspeed.security.spi.JetspeedPrincipalStorageManager" parent="baseTransactionProxy">
@@ -51,7 +52,7 @@
-->
<bean id="org.apache.jetspeed.security.spi.JetspeedPostContextLoader"
- class="org.apache.jetspeed.security.spi.JetspeedPostContextLoader" init-method="init">
+ class="org.apache.jetspeed.security.spi.JetspeedPostContextLoader">
<meta key="j2:cat" value="ldap" />
<constructor-arg index="0" ref="org.apache.jetspeed.security.spi.JetspeedSecuritySynchronizer" />
<constructor-arg index="1" ref="org.apache.jetspeed.security.UserManager" />
@@ -170,6 +171,7 @@
</property>
<property name="entityType" value="role" />
</bean>
+
<bean id="GroupDaoConfiguration" class="org.apache.jetspeed.security.mapping.ldap.dao.LDAPEntityDAOConfiguration">
<meta key="j2:cat" value="ldap" />
<property name="baseDN" value="${ldap.base}" />
@@ -211,7 +213,7 @@
</bean>
<bean id="UserDao" class="org.apache.jetspeed.security.mapping.ldap.dao.impl.SpringLDAPEntityDAO">
<meta key="j2:cat" value="ldap" />
- <constructor-arg index="1" ref="UserDaoConfiguration"/>
+ <constructor-arg ref="UserDaoConfiguration"/>
<property name="ldapTemplate">
<bean class="org.springframework.ldap.core.LdapTemplate">
<property name="contextSource" ref="LdapSpringContext" />
@@ -278,7 +280,7 @@
<bean id="RoleDao" class="org.apache.jetspeed.security.mapping.ldap.dao.impl.SpringLDAPEntityDAO">
<meta key="j2:cat" value="ldap" />
- <constructor-arg index="1" ref="RoleDaoConfiguration"/>
+ <constructor-arg ref="RoleDaoConfiguration"/>
<property name="ldapTemplate">
<bean class="org.springframework.ldap.core.LdapTemplate">
<property name="contextSource" ref="LdapSpringContext" />
@@ -288,7 +290,7 @@
<bean id="GroupDao" class="org.apache.jetspeed.security.mapping.ldap.dao.impl.SpringLDAPEntityDAO">
<meta key="j2:cat" value="ldap" />
- <constructor-arg index="1" ref="GroupDaoConfiguration"/>
+ <constructor-arg ref="GroupDaoConfiguration"/>
<property name="ldapTemplate">
<bean class="org.springframework.ldap.core.LdapTemplate">
<property name="contextSource" ref="LdapSpringContext" />
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org