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

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


    {
        setSynchronizing(true);
        try
        {
            feedbackLogger.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


        attrDefs.add(new AttributeDefImpl("company"));       
       
        StubEntityFactory stubFactory = new StubEntityFactory();
        stubFactory.setAttributeDefs(attrDefs);
       
        Entity user_jsmith=stubFactory.createEntity("jsmith", "user", new String[]{"John Smith","IBM"});
        Entity user_jdoe=stubFactory.createEntity("jdoe", "user", new String[]{"Jane Doe","Apple"});

        StubEntityDAO userDao = new StubEntityDAO();
        userDao.addEntity(user_jsmith);
        userDao.addEntity(user_jdoe);
       
        Entity role_manager=stubFactory.createEntity("manager", "role", new String[]{"Manager Role",""});
        Entity role_admin=stubFactory.createEntity("admin", "role", new String[]{"Admin Role",""});
        Entity role_random=stubFactory.createEntity("random", "role", new String[]{"Random Role",""});
        Entity role_yetAnother=stubFactory.createEntity("yetAnotherRole", "role", new String[]{"Yet Another Role",""});
       
        StubEntityDAO roleDao = new StubEntityDAO();
        userDao.addEntity(role_manager);
        userDao.addEntity(role_admin);
        userDao.addEntity(role_random);
        userDao.addEntity(role_yetAnother);

       
        Entity group_programmers=stubFactory.createEntity("programmers", "group", new String[]{"Group for Programmers",""});
        Entity group_board=stubFactory.createEntity("boardOfDirectors", "group", new String[]{"Group for the board of directors",""});
        Entity group_random=stubFactory.createEntity("randomGroup", "group", new String[]{"Random Group",""});
        Entity group_yetAnother=stubFactory.createEntity("yetAnotherGroup", "group", new String[]{"Yet Another Group",""});

        StubEntityDAO groupDao = new StubEntityDAO();
        userDao.addEntity(group_programmers);
        userDao.addEntity(group_board);
        userDao.addEntity(group_random);
View Full Code Here

        return attributes;
    }
   
    public Entity loadEntity(Object providerContext)
    {
        Entity entity = null;
        DirContextOperations ctx = null;
       
        if (providerContext instanceof SearchResult)
        {
            ctx = (DirContextOperations) ((SearchResult) (providerContext)).getObject();
        }
        else if (providerContext instanceof DirContextAdapter)
        {
            ctx = (DirContextOperations) providerContext;
        }
        if (ctx != null)
        {
            String entityId = 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

    public void addEntity(Entity entity, Entity parentEntity) throws SecurityException
    {
        checkReadOnly("addEntity");
        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);
        CollectingEntitySearchResultHandler handler = new CollectingEntitySearchResultHandler();
        entityManager.getRelatedEntitiesTo(randomEntity, new SecurityEntityRelationTypeImpl(relationType,fromEntityType,toEntityType), handler);
        basicEntityResultSetChecks(expectedEntities, handler.getResults());
    }
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);
        CollectingEntitySearchResultHandler handler = new CollectingEntitySearchResultHandler();
        entityManager.getRelatedEntitiesFrom(randomEntity, new SecurityEntityRelationTypeImpl(relationType,fromEntityType,toEntityType), handler);
        basicEntityResultSetChecks(expectedEntities, handler.getResults());
    }
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);
        assertEquals("cn=nestedGroup1,cn=Marketing,ou=Groups,o=Jetspeed,o=sevenSeas", liveNestedGroup.getInternalId());
    }
View Full Code Here

    }
   
    public void testFetchRolesForUserByRoleAttribute() throws Exception
    {
      
        Entity role1 = getInitialRole1();
        EntityImpl role3 = new EntityImpl("role", "Role3", roleAttrDefs);
        role3.setInternalId("cn=Role3, o=sevenSeas");
        role3.setAttribute(DESCRIPTION_ATTR_DEF.getName(), "Role 3");
        role3.setAttribute(CN_DEF.getName(), "Role3");
        role3.setAttribute(UNIQUEMEMBER_ATTR_DEF.getName(), Arrays.asList(new String[]{
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.