Package org.apache.directory.api.ldap.extras.controls.ppolicy

Examples of org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy


        } );

        bb.flip();

        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
        PasswordPolicy passwordPolicy = ( PasswordPolicy ) control.decode( bb.array() );

        assertTrue( passwordPolicy.hasResponse() );
        assertEquals( 1, passwordPolicy.getResponse().getTimeBeforeExpiration() );
        assertEquals( 1, passwordPolicy.getResponse().getPasswordPolicyError().getValue() );

        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
        assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
    }
View Full Code Here


        } );

        bb.flip();

        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
        PasswordPolicy passwordPolicy = ( PasswordPolicy ) control.decode( bb.array() );

        assertTrue( passwordPolicy.hasResponse() );
        assertEquals( 1, passwordPolicy.getResponse().getGraceAuthNsRemaining() );
        assertEquals( 1, passwordPolicy.getResponse().getPasswordPolicyError().getValue() );

        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
        assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
    }
View Full Code Here

        } );

        bb.flip();

        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
        PasswordPolicy passwordPolicy = ( PasswordPolicy ) control.decode( bb.array() );

        assertTrue( passwordPolicy.hasResponse() );
        assertEquals( 1, passwordPolicy.getResponse().getTimeBeforeExpiration() );

        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
        assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
    }
View Full Code Here

        } );

        bb.flip();

        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
        PasswordPolicy passwordPolicy = ( PasswordPolicy ) control.decode( bb.array() );

        assertTrue( passwordPolicy.hasResponse() );
        assertEquals( 1, passwordPolicy.getResponse().getGraceAuthNsRemaining() );

        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
        assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
    }
View Full Code Here

        } );

        bb.flip();

        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
        PasswordPolicy passwordPolicy = ( PasswordPolicy ) control.decode( bb.array() );

        assertTrue( passwordPolicy.hasResponse() );
        assertEquals( 1, passwordPolicy.getResponse().getPasswordPolicyError().getValue() );

        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
        assertEquals( Strings.dumpBytes( bb.array() ), Strings.dumpBytes( encoded.array() ) );
    }
View Full Code Here

            } );

        bb.flip();

        PasswordPolicyDecorator control = new PasswordPolicyDecorator( codec, true );
        PasswordPolicy passwordPolicy = ( PasswordPolicy ) control.decode( bb.array() );

        assertNotNull( passwordPolicy );
        assertTrue( passwordPolicy.hasResponse() );

        ByteBuffer encoded = ( ( PasswordPolicyDecorator ) passwordPolicy ).encode(
            ByteBuffer.allocate( ( ( PasswordPolicyDecorator ) passwordPolicy ).computeLength() ) );
        assertEquals( "", Strings.dumpBytes( encoded.array() ) );
    }
View Full Code Here

        throws PasswordException
    {
        try
        {
            ResultResponse response = operation.process();
            PasswordPolicy passwordPolicy = getPasswordPolicy( response );
            ResultCodeEnum resultCode = response.getLdapResult().getResultCode();
            if ( resultCode == ResultCodeEnum.SUCCESS )
            {
                return success( passwordPolicy );
            }
View Full Code Here

        throws PasswordException
    {
        try
        {
            ResultResponse response = operation.process();
            PasswordPolicy passwordPolicy = getPasswordPolicy( response );

            ResultCodeEnum resultCode = response.getLdapResult().getResultCode();
            if ( resultCode == ResultCodeEnum.SUCCESS )
            {
                if ( passwordPolicy != null )
                {
                    return PasswordWarningImpl.newWarning( passwordPolicy );
                }
                return null;
            }
            else
            {
                PasswordException exception = new PasswordException();
                exception.setResultCode( resultCode );
                if ( passwordPolicy != null
                    && passwordPolicy.getResponse() != null
                    && passwordPolicy.getResponse().getPasswordPolicyError() != null )
                {
                    exception.setPasswordPolicyError( passwordPolicy.getResponse().getPasswordPolicyError() );
                }
                throw exception;
            }
        }
        catch ( LdapException e )
View Full Code Here

        addRequest.addControl( PP_REQ_CTRL );

        AddResponse addResp = connection.add( addRequest );
        assertEquals( ResultCodeEnum.CONSTRAINT_VIOLATION, addResp.getLdapResult().getResultCode() );

        PasswordPolicy respCtrl = getPwdRespCtrl( addResp );
        assertNotNull( respCtrl );
        assertEquals( PASSWORD_TOO_SHORT, respCtrl.getResponse().getPasswordPolicyError() );

        Attribute pwdAt = userEntry.get( SchemaConstants.USER_PASSWORD_AT );
        pwdAt.clear();
        pwdAt.add( "12345" );
View Full Code Here

        addRequest.addControl( PP_REQ_CTRL );

        AddResponse addResp = connection.add( addRequest );
        assertEquals( ResultCodeEnum.CONSTRAINT_VIOLATION, addResp.getLdapResult().getResultCode() );

        PasswordPolicy respCtrl = getPwdRespCtrl( addResp );
        assertNotNull( respCtrl );
        assertEquals( INSUFFICIENT_PASSWORD_QUALITY, respCtrl.getResponse().getPasswordPolicyError() );

        policyConfig.setPwdCheckQuality( 1 ); // allow the password if its quality can't be checked
        Attribute pwdAt = userEntry.get( SchemaConstants.USER_PASSWORD_AT );
        pwdAt.clear();
        pwdAt.add( password );
View Full Code Here

TOP

Related Classes of org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy

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.