Package org.apache.jetspeed.security.mapping.model

Examples of org.apache.jetspeed.security.mapping.model.Entity


   
    public Entity loadEntity(Object providerContext)
    {
        DirContextOperations ctx = (DirContextOperations)((SearchResult)(providerContext)).getObject();
        String entityId = null;
        Entity entity = null;
        String dn = ctx.getNameInNamespace();
        Set<Attribute> attributes = new HashSet<Attribute>();
        Attributes attrs = ctx.getAttributes();
        for (AttributeDef attrDef : searchConfiguration.getEntityAttributeDefinitionsMap().values())
        {
            List<String> values = null;
            values = getStringAttributes(attrs, attrDef.getName(), attrDef.requiresDnDefaultValue());
            if (values != null)
            {
                Attribute a = new AttributeImpl(attrDef);
                if (attrDef.isMultiValue())
                {
                    // remove the dummy value for required fields when present.
                    if (attrDef.isRequired())
                    {
                        String defaultValue = attrDef.requiresDnDefaultValue() ? dn : attrDef.getRequiredDefaultValue();
                        values.remove(defaultValue);
                    }
                       
                    if (values.size() != 0)
                    {
                        a.setValues(values);
                    }
                       
                    else
                    {
                        attributes.add(a);
                    }                       
                }
                else
                {
                    String value = values.get(0);
                    if (attrDef.isEntityIdAttribute())
                    {
                        entityId = value;
                    }
                    a.setValue(value);
                }
                attributes.add(a);
            }
        }
        if (entityId == null)
        {
            DistinguishedName name = new DistinguishedName(dn);           
            LdapRdn rdn = name.getLdapRdn(name.size()-1);
            if (rdn.getKey().equals(searchConfiguration.getLdapIdAttribute()))
            {
                entityId = rdn.getValue();
            }
            else
            {
                // TODO: throw exception???
                return null;
            }
        }
        entity = internalCreateEntity(entityId, dn, attributes);
        entity.setLive(true);
        return entity;
    }
View Full Code Here


        {
            if (logger.isDebugEnabled())
            {
                logger.debug("Synchronizing UserPrincipal("+name+")");
            }
            Entity userEntity = securityEntityManager.getEntity(JetspeedPrincipalType.USER, name);
            if (userEntity != null)
            {
                synchronizeEntity(userEntity, new HashMap<String,Set<String>>(), new HashMap<String,Map<String,String>>());
            }
            else
View Full Code Here

    public void addEntity(Entity entity, Entity parentEntity) throws SecurityException
    {
        EntityDAO parentEntityDao = getDAOForEntity(parentEntity);
        EntityDAO dao = getDAOForEntity(entity);
        Entity liveParentEntity = null;
        if (parentEntityDao != null && dao != null)
        {
            // fetch "live" entity from LDAP to
            // 1) check whether entity exists and
            // 2) fetch all LDAP attributes (mapped and not mapped) + fill the internal ID
View Full Code Here

    }

    public void testFetchSingleEntity(SecurityEntityManager entityManager,
            Entity sampleEntity) throws Exception
    {
        Entity resultUser = entityManager.getEntity(sampleEntity.getType(),
                sampleEntity.getId());
        TestCase.assertNotNull(resultUser);
        printDebug(resultUser);
        TestCase.assertEquals(true, resultUser.equals(sampleEntity));
    }
View Full Code Here

    public void testFetchRelatedEntitiesTo(String fromEntityType,
            String toEntityType, String relationType, String toEntityId,
            Collection<Entity> expectedEntities) throws Exception
    {
        Entity randomEntity = entityManager.getEntity(toEntityType,toEntityId);
        TestCase.assertNotNull(randomEntity);
        Collection<Entity> resultEntities = entityManager.getRelatedEntitiesTo(
                randomEntity, new SecurityEntityRelationTypeImpl(relationType,fromEntityType,toEntityType));

        basicEntityResultSetChecks(expectedEntities, resultEntities);
View Full Code Here

   
    public void testFetchRelatedEntitiesFrom(String fromEntityType,
            String toEntityType, String relationType, String fromEntityId,
            Collection<Entity> expectedEntities) throws Exception
    {
        Entity randomEntity = entityManager.getEntity(fromEntityType,fromEntityId);
        TestCase.assertNotNull(randomEntity);
        Collection<Entity> resultEntities = entityManager.getRelatedEntitiesFrom(
                randomEntity, new SecurityEntityRelationTypeImpl(relationType,fromEntityType,toEntityType));

        basicEntityResultSetChecks(expectedEntities, resultEntities);
View Full Code Here

    {
        if (debugMode)
        {
            for (Iterator iterator = entities.iterator(); iterator.hasNext();)
            {
                Entity entity = (Entity) iterator.next();
                System.out.println("================================");
                System.out.println("Found " + entities.size() + " entities: ");
                System.out.println("================================");
            }
        }
View Full Code Here

        group.setAttribute(CN_DEF.getName(), id);
        return group;
    }
   
    public void testAddNestedEntities() throws Exception {
        Entity marketingGroup = entityManager.getEntity("group", "Marketing");
       
        assertNotNull(marketingGroup);
       
        EntityImpl nestedGroup = getGroup("nestedGroup1", "Some Nested Group");
       
        entityManager.addEntity(nestedGroup, marketingGroup);
       
        Entity liveNestedGroup = entityManager.getEntity("group", nestedGroup.getId());
        assertNotNull(liveNestedGroup);
        String newDn = DnUtils.encodeDnUsingSeparator(",", marketingGroup.getInternalId(), "cn="+liveNestedGroup.getId());
        assertEquals("cn=nestedGroup1,cn=Marketing,ou=Groups,o=Jetspeed,o=sevenSeas", newDn);
    }
View Full Code Here

    {
        if (!SynchronizationStateAccess.isSynchronizing())
        {
            EntityFactory entityFactory = ldapEntityManager.getEntityFactory(from.getType().getName());
            EntityFactory relatedFactory = ldapEntityManager.getEntityFactory(to.getType().getName());
            Entity fromEntity = entityFactory.createEntity(from);
            Entity toEntity = relatedFactory.createEntity(to);
            SecurityEntityRelationType relationType = new SecurityEntityRelationTypeImpl(associationName, fromEntity.getType(), toEntity.getType());
            ldapEntityManager.addRelation(fromEntity, toEntity, relationType);
        }
        databaseStorageManager.addAssociation(from, to, associationName);
    }
View Full Code Here

    {
        if (!SynchronizationStateAccess.isSynchronizing())
        {
            EntityFactory entityFactory = ldapEntityManager.getEntityFactory(from.getType().getName());
            EntityFactory relatedFactory = ldapEntityManager.getEntityFactory(to.getType().getName());
            Entity fromEntity = entityFactory.createEntity(from);
            Entity toEntity = relatedFactory.createEntity(to);
            SecurityEntityRelationType relationType = new SecurityEntityRelationTypeImpl(associationName, fromEntity.getType(), toEntity.getType());
            ldapEntityManager.removeRelation(fromEntity, toEntity, relationType);
            databaseStorageManager.removeAssociation(from, to, associationName);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.security.mapping.model.Entity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.