Package org.apache.directory.shared.ldap.model.message

Examples of org.apache.directory.shared.ldap.model.message.ModifyRequest


        Entry entry = connection.lookup( userDn );
        assertNotNull( entry );
        assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );

        // now modify the password for akarasulu : 'secret', encrypted using SHA
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( new Dn( userDn ) );
        modReq.replace( "userPassword", "{SHA}5en6G6MezRroT3XKqkdPOmY/BfQ=" );
        connection.modify( modReq );

        // close and try with old password (should fail)
        connection.close();
View Full Code Here


        Entry entry = connection.lookup( userDn );
        assertNotNull( entry );
        assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );

        // now modify the password for akarasulu : 'secret', encrypted using SHA
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( new Dn( userDn ) );
        modReq.replace( "userPassword", "{SSHA}mjVVxasFkk59wMW4L1Ldt+YCblfhULHs03WW7g==" );
        connection.modify( modReq );

        // close and try with old password (should fail)
        connection.close();
View Full Code Here

        Entry entry = connection.lookup( userDn );
        assertNotNull( entry );
        assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );

        // now modify the password for akarasulu : 'test123', encrypted using SHA with a 4 bytes salt
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( new Dn( userDn ) );
        modReq.replace( "userPassword", "{SSHA}0TT388zsWzHKtMEpIU/8/W68egchNEWp" );
        connection.modify( modReq );

        // close and try with old password (should fail)
        connection.close();
View Full Code Here

        Entry entry = connection.lookup( userDn );
        assertNotNull( entry );
        assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );

        // now modify the password for akarasulu : 'secret', encrypted using MD5
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( new Dn( userDn ) );
        modReq.replace( "userPassword", "{MD5}Xr4ilOzQ4PCOq3aQ0qbuaQ==" );
        connection.modify( modReq );

        // close and try with old password (should fail)
        connection.close();
View Full Code Here

        Entry entry = connection.lookup( userDn );
        assertNotNull( entry );
        assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );

        // now modify the password for akarasulu : 'secret', encrypted using SMD5
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( new Dn( userDn ) );
        modReq.replace( "userPassword", "{SMD5}tQ9wo/VBuKsqBtylMMCcORbnYOJFMyDJ" );
        connection.modify( modReq );

        // close and try with old password (should fail)
        connection.close();
View Full Code Here

        Entry entry = connection.lookup( userDn );
        assertNotNull( entry );
        assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );

        // now modify the password for akarasulu : 'secret', encrypted using CRYPT
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( new Dn( userDn ) );
        modReq.replace( "userPassword", "{crypt}qFkH8Z1woBlXw" );
        connection.modify( modReq );

        // close and try with old password (should fail)
        connection.close();
View Full Code Here

        // bind as admin
        String adminUserDn = "uid=admin,ou=system";
        connection.bind( adminUserDn, "secret" );

        // now modify the password for akarasulu (while we're admin)
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( new Dn( userDn ) );
        modReq.replace( "userPassword", "newpwd" );
        connection.modify( modReq );
        connection.close();

        try
        {
View Full Code Here

        // tag after the addition before modify ADD
        Tag t0 = getService().getChangeLog().tag();
        assertPresent( sysRoot, "ou=test5,ou=system" );

        // modify the test entry to add description and test new attr appears
        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( entry.getDn() );
        modReq.add( "description", "a desc value" );
        sysRoot.modify( modReq );

        Entry resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        Attribute description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "a desc value" ) );

        // now revert and assert that the added entry re-appears
        getService().revert( t0.getRevision() );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        assertNull( resusitated.get( "description" ) );

        // -------------------------------------------------------------------
        // Modify REPLACE Test
        // -------------------------------------------------------------------

        // add the attribute again and make sure it is old value
        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.add( "description", "old value" );
        sysRoot.modify( modReq );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "old value" ) );

        // now tag then replace the value to "new value" and confirm
        Tag t1 = getService().getChangeLog().tag();
        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.replace( "description", "new value" );
        sysRoot.modify( modReq );

        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        assertTrue( resusitated.containsAttribute( "description" ) );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "new value" ) );

        // now revert and assert the old value is now reverted
        getService().revert( t1.getRevision() );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "old value" ) );

        // -------------------------------------------------------------------
        // Modify REMOVE Test
        // -------------------------------------------------------------------

        Tag t2 = getService().getChangeLog().tag();
        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.remove( "description", "old value" );
        sysRoot.modify( modReq );

        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNull( description );

        // now revert and assert the old value is now reverted
        getService().revert( t2.getRevision() );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertNotNull( resusitated );
        description = resusitated.get( "description" );
        assertNotNull( description );
        assertTrue( description.contains( "old value" ) );

        // -------------------------------------------------------------------
        // Modify Multi Operation Test
        // -------------------------------------------------------------------

        // add a userPassword attribute so we can test replacing it
        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.add( "userPassword", "to be replaced" );
        sysRoot.modify( modReq );
        resusitated = sysRoot.lookup( "ou=test5,ou=system" );
        assertPassword( resusitated, "to be replaced" );

        modReq = new ModifyRequestImpl();
        modReq.setName( resusitated.getDn() );
        modReq.remove( "description", "old value" );
        modReq.add( "seeAlso", "ou=added" );
        modReq.replace( "userPassword", "a replaced value" );

        Tag t3 = getService().getChangeLog().tag();

        // now make the modification and check that description is gone,
        // seeAlso is added, and that the userPassword has been replaced
View Full Code Here

            if ( i == 5000 )
            {
                t00 = System.currentTimeMillis();
            }

            ModifyRequest modRequest = new ModifyRequestImpl();
            modRequest.setName( dn );
            Modification modification = new DefaultModification();
            Attribute attribute = new DefaultAttribute( "sn" );

            attribute.add( "test" + i );

            modification.setAttribute( attribute );
            modification.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
            modRequest.addModification( modification );

            long ttt0 = System.nanoTime();
            connection.modify( modRequest );
            long ttt1 = System.nanoTime();
            //System.out.println("added " + i + ", delta = " + (ttt1-ttt0)/1000);
View Full Code Here

    @Test
    public void testIllegalModification() throws Exception
    {
        LdapConnection con = getAdminConnection( getLdapServer() );

        ModifyRequest modReq = new ModifyRequestImpl();
        modReq.setName( new Dn( DN ) );
        modReq.add( "description", "" );

        ModifyResponse resp = con.modify( modReq );
        assertEquals( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, resp.getLdapResult().getResultCode() );

        // Check whether entry is unmodified, i.e. no description
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.message.ModifyRequest

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.