Package org.apache.ldap.common.name

Examples of org.apache.ldap.common.name.LdapName


     * operations replace RDN attributes.
     */
    public void testPreventRdnChangeOnModifyReplace() throws Exception
    {
        int mod = DirContext.REPLACE_ATTRIBUTE;
        Name name = new LdapName( "ou=user,dc=example,dc=com" );
        Attributes attributes = new BasicAttributes( true );
        attributes.put( "cn", "does not matter" );

        // postive test which should pass
        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes );

        // test should fail since we are removing the ou attribute
        attributes.put( new BasicAttribute( "ou" ) );
        try
        {
            SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes );
            fail( "should never get here due to a LdapSchemaViolationException being thrown" );
        }
        catch ( LdapSchemaViolationException e )
        {
            assertEquals( ResultCodeEnum.NOTALLOWEDONRDN, e.getResultCode() );
        }

        // test success using more than one attribute for the Rdn but not modifying rdn attribute
        name = new LdapName( "ou=users+cn=system users,dc=example,dc=com" );
        attributes = new BasicAttributes( true );
        attributes.put( "sn", "does not matter" );
        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes );

        // test for failure when modifying Rdn attribute in multi attribute Rdn
View Full Code Here


    public void testPreventStructuralClassRemovalOnModifyReplaceAttribute() throws Exception
    {
        ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();

        // this should pass
        Name name = new LdapName( "uid=akarasulu,ou=users,dc=example,dc=com" );
        int mod = DirContext.REPLACE_ATTRIBUTE;
        SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, mod, new BasicAttribute( "cn" ) );

        // this should succeed since person is still in replaced set and is structural
        BasicAttribute objectClassesReplaced = new BasicAttribute( "objectClass" );
View Full Code Here

     * Test case to check the schema checker operates correctly when modify
     * operations remove objectClasses.
     */
    public void testPreventStructuralClassRemovalOnModifyRemoveAttribute() throws Exception
    {
        Name name = new LdapName( "uid=akarasulu,ou=users,dc=example,dc=com" );
        int mod = DirContext.REMOVE_ATTRIBUTE;
        Attribute entryObjectClasses = new BasicAttribute( "objectClass" );
        entryObjectClasses.add( "top" );
        entryObjectClasses.add( "person" );
        entryObjectClasses.add( "organizationalPerson" );
View Full Code Here

     * operations remove RDN attributes.
     */
    public void testPreventRdnChangeOnModifyRemoveAttribute() throws Exception
    {
        int mod = DirContext.REMOVE_ATTRIBUTE;
        Name name = new LdapName( "ou=user,dc=example,dc=com" );

        // postive test which should pass
        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, new BasicAttribute( "cn", "does not matter" ) );

        // test should fail since we are removing the ou attribute
        try
        {
            SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, new BasicAttribute( "ou" ) );
            fail( "should never get here due to a LdapSchemaViolationException being thrown" );
        }
        catch ( LdapSchemaViolationException e )
        {
            assertEquals( ResultCodeEnum.NOTALLOWEDONRDN, e.getResultCode() );
        }

        // test success using more than one attribute for the Rdn but not modifying rdn attribute
        name = new LdapName( "ou=users+cn=system users,dc=example,dc=com" );
        SchemaChecker.preventRdnChangeOnModifyRemove( name, mod, new BasicAttribute( "sn", "does not matter" ) );

        // test for failure when modifying Rdn attribute in multi attribute Rdn
        try
        {
View Full Code Here

     * operations replace RDN attributes.
     */
    public void testPreventRdnChangeOnModifyReplaceAttribute() throws Exception
    {
        int mod = DirContext.REPLACE_ATTRIBUTE;
        Name name = new LdapName( "ou=user,dc=example,dc=com" );

        // postive test which should pass
        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, new BasicAttribute( "cn", "does not matter" ) );

        // test should fail since we are removing the ou attribute
        try
        {
            SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, new BasicAttribute( "ou" ) );
            fail( "should never get here due to a LdapSchemaViolationException being thrown" );
        }
        catch ( LdapSchemaViolationException e )
        {
            assertEquals( ResultCodeEnum.NOTALLOWEDONRDN, e.getResultCode() );
        }

        // test success using more than one attribute for the Rdn but not modifying rdn attribute
        name = new LdapName( "ou=users+cn=system users,dc=example,dc=com" );
        SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, new BasicAttribute( "sn", "does not matter" ) );

        // test for failure when modifying Rdn attribute in multi attribute Rdn
        try
        {
View Full Code Here

    }


    public void testNoBypass() throws NamingException
    {
        Name dn = new LdapName( "ou=system" );
        Context ctx = new DeadContext();
        DirectoryService ds = new MockDirectoryService();
        DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
        Invocation i = new Invocation( proxy, ctx, "lookup", new Object[]{ dn } );
        InvocationStack.getInstance().push( i );
View Full Code Here

    }


    public void testSingleBypass() throws NamingException
    {
        Name dn = new LdapName( "ou=system" );
        Context ctx = new DeadContext();
        DirectoryService ds = new MockDirectoryService();
        DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
        Invocation i = new Invocation( proxy, ctx, "lookup", new Object[]{ dn }, Collections.singleton( "0" ) );
        InvocationStack.getInstance().push( i );
View Full Code Here

    }


    public void testAdjacentDoubleBypass() throws NamingException
    {
        Name dn = new LdapName( "ou=system" );
        Context ctx = new DeadContext();
        DirectoryService ds = new MockDirectoryService();
        DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
        Collection bypass = new HashSet();
        bypass.add( "0" );
View Full Code Here

    }


    public void testFrontAndBackDoubleBypass() throws NamingException
    {
        Name dn = new LdapName( "ou=system" );
        Context ctx = new DeadContext();
        DirectoryService ds = new MockDirectoryService();
        DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
        Collection bypass = new HashSet();
        bypass.add( "0" );
View Full Code Here

    }


    public void testDoubleBypass() throws NamingException
    {
        Name dn = new LdapName( "ou=system" );
        Context ctx = new DeadContext();
        DirectoryService ds = new MockDirectoryService();
        DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
        Collection bypass = new HashSet();
        bypass.add( "1" );
View Full Code Here

TOP

Related Classes of org.apache.ldap.common.name.LdapName

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.