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

Examples of org.apache.jetspeed.security.mapping.model.impl.EntityImpl


        sampleUser.setAttribute(UID_DEF.getName(), "jsmith");
        basicTestCases.testFetchSingleEntity(entityManager, sampleUser);
    }

    private EntityImpl getInitialRole1(){
        EntityImpl role1 = new EntityImpl("role", "Role1", roleAttrDefs);
        role1.setInternalId("cn=Role1, o=sevenSeas");
        role1.setAttribute(DESCRIPTION_ATTR_DEF.getName(), "Role 1");
        role1.setAttribute(CN_DEF.getName(), "Role1");
       
        role1.setAttribute(UNIQUEMEMBER_ATTR_DEF.getName(), Arrays.asList(new String[]{
                "cn=OrgUnit2User1,ou=People,ou=OrgUnit2,o=sevenSeas",
                "cn=jsmith,ou=People,ou=OrgUnit3,o=sevenSeas",
                "cn=OrgUnit2User2,ou=People,ou=OrgUnit2,o=sevenSeas"}) );
        return role1;
    }
View Full Code Here


        return role1;
    }
   
    private EntityImpl getDefaultJoeSmith(){
        // first assert that the sample user is equal to the corresponding user in LDAP
        EntityImpl sampleUser = new EntityImpl("user", "jsmith", userAttrDefs);
        sampleUser
                .setInternalId("cn=jsmith, ou=People, ou=OrgUnit3, o=sevenSeas");
        sampleUser.setAttribute(GIVEN_NAME_DEF.getName(), "Joe Smith");
        sampleUser.setAttribute(UID_DEF.getName(), "jsmith");
        sampleUser.setAttribute(CN_DEF.getName(), "jsmith");
        sampleUser.setAttribute(SN_DEF.getName(), "jsmith");
        return sampleUser;
    }
View Full Code Here

        return sampleUser;
    }
   
    private EntityImpl getDefaultJoeSmithOnlyMappedAttrs(){
        // first assert that the sample user is equal to the corresponding user in LDAP
        EntityImpl sampleUser = new EntityImpl("user", "jsmith", userAttrDefs);
        sampleUser.setInternalId("cn=jsmith, ou=People, ou=OrgUnit3, o=sevenSeas");
        sampleUser.setAttribute(GIVEN_NAME_DEF.getName(), "Joe Smith");
        return sampleUser;
    }
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[]{
                "cn=jsmith,ou=People,ou=OrgUnit3,o=sevenSeas"
        }));
        Collection<Entity> resultSet = new ArrayList<Entity>();
        resultSet.add(role1);
        resultSet.add(role3);
View Full Code Here

    }

    public void testUpdateSingleValuedEntityAttr() throws Exception
    {
        // first assert that the sample user is equal to the corresponding user in LDAP
        EntityImpl sampleUser = getDefaultJoeSmith();
        basicTestCases.testFetchSingleEntity(entityManager, sampleUser);
       
        // next, try some identity transformation checks to assert that updating works
        // 1. test attribute modification
        sampleUser.setAttribute(GIVEN_NAME_DEF.getName(), "Joe Smith modified");
        entityManager.updateEntity(sampleUser);
       
       
        basicTestCases.testFetchSingleEntity(entityManager, sampleUser);

        // test attribute removal
        sampleUser = new EntityImpl("user", "jsmith", userAttrDefs);
        sampleUser
                .setInternalId("cn=jsmith, ou=People, ou=OrgUnit3, o=sevenSeas");
        sampleUser.setAttribute(UID_DEF.getName(), "jsmith");
        sampleUser.setAttribute(CN_DEF.getName(), "jsmith");
        sampleUser.setAttribute(SN_DEF.getName(), "jsmith");
       
        entityManager.updateEntity(sampleUser);
       
        basicTestCases.testFetchSingleEntity(entityManager, sampleUser);

        // add "lastname" attribute value
        sampleUser = new EntityImpl("user", "jsmith", userAttrDefs);
        sampleUser
                .setInternalId("cn=jsmith, ou=People, ou=OrgUnit3, o=sevenSeas");
        sampleUser.setAttribute(UID_DEF.getName(), "jsmith");
        sampleUser.setAttribute(CN_DEF.getName(), "jsmith");
        sampleUser.setAttribute(SN_DEF.getName(), "jsmith");
        sampleUser.setAttribute(LAST_NAME_DEF.getName(), "jsmith");
       
        entityManager.updateEntity(sampleUser);
       
        basicTestCases.testFetchSingleEntity(entityManager, sampleUser);

        // test attribute removal of required attribute ("lastname") with a required default value set for it
        sampleUser = new EntityImpl("user", "jsmith", userAttrDefs);
        sampleUser
                .setInternalId("cn=jsmith, ou=People, ou=OrgUnit3, o=sevenSeas");
        sampleUser.setAttribute(CN_DEF.getName(), "jsmith");
        sampleUser.setAttribute(SN_DEF.getName(), "jsmith");
        sampleUser.setAttribute(UID_DEF.getName(), "jsmith");
       
        entityManager.updateEntity(sampleUser);
       
        basicTestCases.testFetchSingleEntity(entityManager, sampleUser);
View Full Code Here

    }
   
    public void testUpdateMultivaluedEntityAttr() throws Exception
    {
        // first assert that the sample user is equal to the corresponding user in LDAP
        EntityImpl sampleRole = getInitialRole1();
       
        basicTestCases.testFetchSingleEntity(entityManager, sampleRole);
       
        // next, try some identity transformation checks to assert that updating works
        // 1. test attribute modification
        sampleRole.setAttribute(UNIQUEMEMBER_ATTR_DEF.getName(), Arrays.asList(new String[]{"cn=jsmith,ou=People,ou=OrgUnit3,o=sevenSeas"}) );
        entityManager.updateEntity(sampleRole);
       
       
        basicTestCases.testFetchSingleEntity(entityManager, sampleRole);

        sampleRole.setAttribute(UNIQUEMEMBER_ATTR_DEF.getName(), Arrays.asList(new String[]{"cn=jsmith,ou=People,ou=OrgUnit3,o=sevenSeas","cn=OrgUnit2User1,ou=People,ou=OrgUnit2,o=sevenSeas"}) );
        entityManager.updateEntity(sampleRole);
        basicTestCases.testFetchSingleEntity(entityManager, sampleRole);

        // 2. test attribute removal
        sampleRole = new EntityImpl("role", "Role1", roleAttrDefs);
        sampleRole.setInternalId("cn=Role1, o=sevenSeas");
        sampleRole.setAttribute(DESCRIPTION_ATTR_DEF.getName(), "Role 1");
        sampleRole.setAttribute(CN_DEF.getName(), "Role1");
        sampleRole.setAttribute(UNIQUEMEMBER_ATTR_DEF.getName(), Collections.EMPTY_LIST );
       
        // note: we call the user DAO directly, because updating internal
        // attributes is only meant to be used internally, e.g. from within an EntityRelationDAO
        entityManager.updateEntity(sampleRole);
       
View Full Code Here

       
        basicTestCases.testFetchSingleEntity(entityManager, sampleRole);
    }
   
    public void testAddEntity() throws Exception {
        EntityImpl jsmithCopy = getDefaultJoeSmithOnlyMappedAttrs();
        jsmithCopy.setId("jsmithCopy");
       
        entityManager.addEntity(jsmithCopy);
       
        jsmithCopy.setAttribute(UID_DEF.getName(), "jsmithCopy");
        jsmithCopy.setAttribute(CN_DEF.getName(), "jsmithCopy");
        jsmithCopy.setAttribute(SN_DEF.getName(), "jsmithCopy");
        jsmithCopy.setInternalId("uid=jsmithCopy, o=sevenSeas");
        basicTestCases.testFetchSingleEntity(entityManager, jsmithCopy);
    }
View Full Code Here

        jsmithCopy.setInternalId("uid=jsmithCopy, o=sevenSeas");
        basicTestCases.testFetchSingleEntity(entityManager, jsmithCopy);
    }
   
    public void testUpdateInternalAttrs() throws Exception {
        EntityImpl jsmith = getDefaultJoeSmith();
        jsmith.setAttribute(SN_DEF.getName(), "whatever");
        jsmith.setAttribute(GIVEN_NAME_DEF.getName(), "foobar");
       
        // note: we call the user DAO directly, because updating internal
        // attributes is only meant to be used internally, e.g. from within an EntityRelationDAO
        userDAO.updateInternalAttributes(jsmith);

        // reset given name to value in ldap, givenName should be unmodified
        // the (internal) sn attribute is modified in LDAP
        jsmith.setAttribute(GIVEN_NAME_DEF.getName(), "Joe Smith");
        basicTestCases.testFetchSingleEntity(entityManager, jsmith);
    }
View Full Code Here

        this.searchConfiguration = searchConfiguration;
    }

    protected EntityImpl internalCreateEntity(String entityId, String internalId, Set<Attribute> attributes)
    {
        EntityImpl entity = new EntityImpl(searchConfiguration.getEntityType(), entityId, searchConfiguration.getAttributeDefinitions());
        entity.setAttributes(attributes);
        if (internalId != null)
        {
            entity.setInternalId(internalId);
        }
        entity.setType(searchConfiguration.getEntityType());
        return entity;
    }
View Full Code Here

        }
    }
   
    public Entity createEntity(String id, String entityType, String[]... attrKeyValuePairs){
       
        EntityImpl stubEntity = new EntityImpl("user", id, attributeDefs);
        for (int i = 0; i < attrKeyValuePairs.length; i++)
        {
            AttributeDef def = attributeDefs.get(attrKeyValuePairs[i][0]);
            if (def!=null){
                stubEntity.setAttribute(def.getName(), attrKeyValuePairs[i][1]);
            }
        }
        stubEntity.setInternalId(id); // simply use the id
        return stubEntity;
    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.security.mapping.model.impl.EntityImpl

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.