Package org.apache.directory.api.ldap.model.name

Examples of org.apache.directory.api.ldap.model.name.Dn


        int nbLoop = 10;

        for ( ; i < nbLoop; i++ )
        {
            BindRequest bindRequest = new BindRequestImpl();
            bindRequest.setDn( new Dn( "uid=admin,ou=system" ) );
            bindRequest.setCredentials( "secret" );

            BindFuture bindFuture = connection.bindAsync( bindRequest );

            BindResponse bindResponse = bindFuture.get( 1000, TimeUnit.MILLISECONDS );
View Full Code Here


     */
    @Test
    public void testSimpleBindRequest() throws Exception
    {
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setDn( new Dn( "uid=admin,ou=system" ) );
        bindRequest.setCredentials( "secret" );

        BindResponse bindResponse = connection.bind( bindRequest );

        assertNotNull( bindResponse );
View Full Code Here

     */
    @Test
    public void testSimpleBindRequest2Passwords() throws Exception
    {
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setDn( new Dn( "uid=superUser2,ou=system" ) );
        bindRequest.setCredentials( "test1" );

        BindResponse bindResponse = connection.bind( bindRequest );

        assertNotNull( bindResponse );
        assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
        assertTrue( connection.isAuthenticated() );

        bindRequest = new BindRequestImpl();
        bindRequest.setDn( new Dn( "uid=superUser2,ou=system" ) );
        bindRequest.setCredentials( "test2" );

        bindResponse = connection.bind( bindRequest );

        assertNotNull( bindResponse );
View Full Code Here

     */
    @Test
    public void testDoubleSimpleBindValid() throws Exception
    {
        BindRequest br1 = new BindRequestImpl();
        br1.setDn( new Dn( "uid=admin,ou=system" ) );
        br1.setCredentials( Strings.getBytesUtf8( "secret" ) );

        BindResponse response1 = connection.bind( br1 );
        assertTrue( connection.isAuthenticated() );
        int messageId1 = response1.getMessageId();

        // The messageId must have been incremented
        BindRequest br2 = new BindRequestImpl();
        br2.setDn( new Dn( "uid=admin,ou=system" ) );
        br2.setCredentials( Strings.getBytesUtf8( "secret" ) );

        BindResponse response2 = connection.bind( br2 );
        int messageId2 = response2.getMessageId();

        assertTrue( messageId2 > messageId1 );
        assertTrue( connection.isAuthenticated() );

        // Now, unbind
        connection.unBind();
        assertFalse( connection.isAuthenticated() );
        assertFalse( connection.isConnected() );

        // And Bind again. The messageId should be 1
        BindRequest br3 = new BindRequestImpl();
        br3.setDn( new Dn( "uid=admin,ou=system" ) );
        br3.setCredentials( Strings.getBytesUtf8( "secret" ) );

        BindResponse response3 = connection.bind( br3 );
        int messageId = response3.getMessageId();
        assertEquals( 1, messageId );
View Full Code Here

     */
    private boolean checkCanSearchAs( String uid, String password, String filter, SearchScope scope, int resultSetSz )
        throws Exception
    {
   
        Dn base = new Dn( "ou=tests,ou=system" );
        Dn userDn = new Dn( "uid=" + uid + ",ou=users,ou=system" );
        results.clear();
        LdapConnection userCtx = getConnectionAs( userDn, password );
        EntryCursor cursor = userCtx.search( base.getName(), filter, scope, "*" );
        int counter = 0;
   
View Full Code Here

            getService().addFirst( interceptor );

            // Send another BindRequest
            BindRequest bindRequest = new BindRequestImpl();
            bindRequest.setDn( new Dn( "uid=admin,ou=system" ) );
            bindRequest.setCredentials( "secret" );

            BindFuture bindFuture = connection.bindAsync( bindRequest );

            // Wait a bit to be sure the server is processing the bind request
View Full Code Here

     * @throws Exception if there are problems conducting the search
     */
    private boolean checkSearchAsWithEntryACI( String uid, String password, SearchScope scope, Dn dn, String aci,
        int resultSetSz ) throws Exception
    {
        Dn base = new Dn( "ou=tests,ou=system" );
        addEntryACI( base, aci );
        Dn userDn = new Dn( "uid=" + uid + ",ou=users,ou=system" );
   
        results.clear();
        LdapConnection userCtx = getConnectionAs( userDn, password );
        EntryCursor cursor = userCtx.search( base.getName(), "(objectClass=*)", scope, "*" );
        int counter = 0;
View Full Code Here

                "    } " +
                "  } " +
                "}";
   
        // try a search operation which should fail without any prescriptive ACI
        Dn testsDn = new Dn( "ou=system" );
   
        assertFalse( checkSearchAsWithEntryACI( "billyd", "billyd", SearchScope.SUBTREE, testsDn, aci, 9 ) );
   
        // now add a subentry that enables anyone to search below ou=system
        createAccessControlSubentry( "anybodySearch",
View Full Code Here

                "    } " +
                "  } " +
                "}";
   
        // try a search operation which should fail without any prescriptive ACI
        Dn testsDn = new Dn( "ou=system" );
   
        assertFalse( checkSearchAsWithEntryACI( "billyd", "billyd", SearchScope.SUBTREE, testsDn, aci, 9 ) );
   
        // now add a subentry that enables anyone to search below ou=system
        createAccessControlSubentry( "anybodySearch",
View Full Code Here

     * @return the single search result if access is allowed or null
     * @throws Exception if the search fails w/ exception other than no permission
     */
    private Entry checkCanSearchSubentryAs( String uid, String password, Dn dn ) throws Exception
    {
        LdapConnection userCtx = getConnectionAs( new Dn( "uid=" + uid + ",ou=users,ou=system" ), password );
        Entry result = null;
        EntryCursor list = null;
   
        list = userCtx.search( dn.getName(), "(objectClass=*)", SearchScope.OBJECT, "*" );
   
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.name.Dn

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.