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

Examples of org.apache.directory.api.ldap.model.message.Control


        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getName() );
        assertTrue( entry.isChangeDelete() );

        // Check the control
        Control control = entry.getControl( "1.2.840.113556.1.4.805" );

        assertEquals( "1.2.840.113556.1.4.805", control.getOid() );
        assertTrue( control.isCritical() );
    }
View Full Code Here


        assertEquals( "ou=Product Development, dc=airius, dc=com", entry.getDn().getName() );
        assertTrue( entry.isChangeDelete() );

        // Check the control
        Control control = entry.getControl( "1.2.840.113556.1.4.805" );

        assertEquals( "1.2.840.113556.1.4.805", control.getOid() );
        assertFalse( control.isCritical() );
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Message addControl( Control control ) throws MessageException
    {
        Control decorated;
        DsmlControl<? extends Control> decorator;

        if ( control instanceof DsmlControl )
        {
            decorator = ( DsmlControl<?> ) control;
View Full Code Here

    }


    private PasswordPolicy getPasswordPolicy( Response response )
    {
        Control control = response.getControls().get( passwordPolicyRequestControl.getOid() );
        return control == null
            ? null
            : ( ( PasswordPolicyDecorator ) control ).getDecorated();
    }
View Full Code Here

        // after a change operation
        boolean changeTypeSeen = false;

        ChangeType operation = ChangeType.Add;
        String lowerLine;
        Control control;

        while ( iter.hasNext() )
        {
            lineNumber++;
View Full Code Here


    @Test
    public void testFailureWithUnsupportedControl() throws Exception
    {
        Control unsupported = new OpaqueControl( "1.1.1.1" );
        unsupported.setCritical( true );

        getLdapServer().getDirectoryService().setAllowAnonymousAccess( true );

        Hashtable<String, Object> env = new Hashtable<String, Object>();

        env.put( Context.PROVIDER_URL, "ldap://localhost:" + getLdapServer().getPort() + "/ou=system" );
        env.put( "java.naming.ldap.version", "3" );
        env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
        env.put( Context.SECURITY_AUTHENTICATION, "simple" );
        env.put( Context.SECURITY_CREDENTIALS, "secret" );
        env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
        InitialLdapContext ctx = new InitialLdapContext( env, null );

        Attributes user = new BasicAttributes( "cn", "Kate Bush", true );
        Attribute oc = new BasicAttribute( "objectClass" );
        oc.add( "top" );
        oc.add( "person" );
        oc.add( "organizationalPerson" );
        oc.add( "inetOrgPerson" );
        user.put( oc );
        user.put( "sn", "Bush" );
        user.put( "userPassword", "Aerial" );
        ctx.setRequestControls( JndiUtils.toJndiControls( getLdapServer().getDirectoryService().getLdapCodecService(),
            new Control[]
                { unsupported } ) );

        try
        {
            ctx.createSubcontext( "cn=Kate Bush", user );
            fail();
        }
        catch ( OperationNotSupportedException e )
        {
        }

        unsupported.setCritical( false );
        ctx.setRequestControls( JndiUtils.toJndiControls( getLdapServer().getDirectoryService().getLdapCodecService(),
            new Control[]
                { unsupported } ) );

        DirContext kate = ctx.createSubcontext( "cn=Kate Bush", user );
View Full Code Here

        if ( connection.isControlSupported( "1.2.840.113556.1.4.805" ) )
        {
            DeleteRequest deleteRequest = new DeleteRequestImpl();
            deleteRequest.setName( new Dn( "cn=parent,ou=system" ) );
            Control deleteTreeControl = new OpaqueControl( "1.2.840.113556.1.4.805" );
            deleteRequest.addControl( deleteTreeControl );

            DeleteResponse deleteResponse = connection.delete( deleteRequest );

            assertNotNull( deleteResponse );
View Full Code Here

    public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
    {
        TLV tlv = container.getCurrentTLV();

        // Get the current control
        Control control = null;

        MessageDecorator<? extends Message> message = container.getMessage();
        control = message.getCurrentControl();

        // Store the criticality
        // We get the value. If it's a 0, it's a FALSE. If it's
        // a FF, it's a TRUE. Any other value should be an error,
        // but we could relax this constraint. So if we have
        // something
        // which is not 0, it will be interpreted as TRUE, but we
        // will generate a warning.
        BerValue value = tlv.getValue();

        try
        {
            control.setCritical( BooleanDecoder.parse( value ) );
        }
        catch ( BooleanDecoderException bde )
        {
            LOG.error( I18n
                .err( I18n.ERR_04100, Strings.dumpBytes( value.getData() ), bde.getMessage() ) );

            // This will generate a PROTOCOL_ERROR
            throw new DecoderException( bde.getMessage() );
        }

        // We can have an END transition
        container.setGrammarEndAllowed( true );

        if ( IS_DEBUG )
        {
            LOG.debug( "Control criticality : " + control.isCritical() );
        }
    }
View Full Code Here

     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    public Message addControl( Control control )
    {
        Control decorated;
        CodecControl<? extends Control> controlDecorator;

        if ( control instanceof ControlDecorator )
        {
            controlDecorator = ( org.apache.directory.api.ldap.codec.api.CodecControl<? extends Control> ) control;
View Full Code Here

            throw new DecoderException( I18n.err( I18n.ERR_04099, oidValue ) );
        }

        Message message = container.getMessage();

        Control control = container.getLdapCodecService().newControl( oidValue );

        message.addControl( control );

        // We can have an END transition
        container.setGrammarEndAllowed( true );
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.model.message.Control

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.