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

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


        addRequest.setEntry( userEntry );
        addRequest.addControl( PP_REQ_CTRL );

        AddResponse addResp = adminConnection.add( addRequest );
        assertEquals( ResultCodeEnum.SUCCESS, addResp.getLdapResult().getResultCode() );
        PasswordPolicy respCtrl = getPwdRespCtrl( addResp );
        assertNull( respCtrl );
    }
View Full Code Here


        // We should get a failure
        AddResponse addResp = adminConnection.add( addRequest );
        assertEquals( ResultCodeEnum.CONSTRAINT_VIOLATION, addResp.getLdapResult().getResultCode() );

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

        // Relax the Check Quality to CHECK_ACCEPT
        policyConfig.setPwdCheckQuality( CheckQualityEnum.CHECK_ACCEPT ); // allow the password if its quality can't be checked
        Attribute pwdAt = userEntry.get( SchemaConstants.USER_PASSWORD_AT );
        pwdAt.clear();
View Full Code Here

        addRequest.setEntry( userEntry );
        addRequest.addControl( PP_REQ_CTRL );

        AddResponse addResp = adminConnection.add( addRequest );
        assertEquals( ResultCodeEnum.SUCCESS, addResp.getLdapResult().getResultCode() );
        PasswordPolicy respCtrl = getPwdRespCtrl( addResp );
        assertNull( respCtrl );

        BindRequest bindReq = new BindRequestImpl();
        bindReq.setDn( userDn );
        bindReq.setCredentials( "1234" ); // wrong password
View Full Code Here

        Thread.sleep( 1000 ); // sleep for one second so that the password expire warning will be sent

        BindResponse bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );

        PasswordPolicy respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertTrue( respCtrl.getResponse().getTimeBeforeExpiration() > 0 );

        Thread.sleep( 4500 ); // sleep for four seconds and a half so that the password expires

        // this time it should fail
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );

        respCtrl = getPwdRespCtrl( bindResp );
        assertEquals( PASSWORD_EXPIRED, respCtrl.getResponse().getPasswordPolicyError() );
        adminConnection.close();
    }
View Full Code Here

        Thread.sleep( 1000 ); // sleep for one second so that the password expire warning will be sent

        BindResponse bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );

        PasswordPolicy respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertTrue( respCtrl.getResponse().getTimeBeforeExpiration() > 0 );

        Thread.sleep( 4500 ); // sleep for four seconds and a half so that the password expires

        // bind for one more time, should succeed
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
        respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertEquals( 1, respCtrl.getResponse().getGraceAuthNRemaining() );

        // bind for one last time, should succeed
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
        respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertEquals( 0, respCtrl.getResponse().getGraceAuthNRemaining() );

        // this time it should fail
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );

        respCtrl = getPwdRespCtrl( bindResp );
        assertEquals( PASSWORD_EXPIRED, respCtrl.getResponse().getPasswordPolicyError() );
        adminConnection.close();
    }
View Full Code Here

        Thread.sleep( 1000 ); // sleep for one second so that the password expire warning will be sent

        BindResponse bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );

        PasswordPolicy respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertTrue( respCtrl.getResponse().getTimeBeforeExpiration() > 0 );

        Thread.sleep( 4500 ); // sleep for four seconds and a half so that the password expires

        // bind for one more time, should succeed
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
        respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertEquals( 1, respCtrl.getResponse().getGraceAuthNRemaining() );

        // Wait 1 second, we should still be able to bind
        // bind for one last time, should succeed
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
        respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertEquals( 0, respCtrl.getResponse().getGraceAuthNRemaining() );

        // this time it should fail
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );

        respCtrl = getPwdRespCtrl( bindResp );
        assertEquals( PASSWORD_EXPIRED, respCtrl.getResponse().getPasswordPolicyError() );
        adminConnection.close();
    }
View Full Code Here

        Thread.sleep( 1000 ); // sleep for one second so that the password expire warning will be sent

        BindResponse bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );

        PasswordPolicy respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertTrue( respCtrl.getResponse().getTimeBeforeExpiration() > 0 );

        Thread.sleep( 4000 ); // sleep for four seconds so that the password expires

        // bind for two more times, should succeed
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
        respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertEquals( 1, respCtrl.getResponse().getGraceAuthNRemaining() );

        // this extra second sleep is necessary to modify pwdGraceUseTime attribute with a different timestamp
        Thread.sleep( 1000 );
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
        respCtrl = getPwdRespCtrl( bindResp );
        assertEquals( 0, respCtrl.getResponse().getGraceAuthNRemaining() );

        // this time it should fail
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );

        respCtrl = getPwdRespCtrl( bindResp );
        assertEquals( PASSWORD_EXPIRED, respCtrl.getResponse().getPasswordPolicyError() );
        adminConnection.close();
    }
View Full Code Here

        LdapConnection userConnection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );

        Thread.sleep( 2000 ); // let the password expire
        BindResponse bindResp = userConnection.bind( bindReq );
        assertTrue( userConnection.isAuthenticated() );
        PasswordPolicy ppolicy = getPwdRespCtrl( bindResp );
        assertEquals( 1, ppolicy.getResponse().getGraceAuthNRemaining() );

        Entry userEntry = adminConnection.lookup( userDn, "+" );
        Attribute pwdGraceAuthUseTime = userEntry.get( PasswordPolicySchemaConstants.PWD_GRACE_USE_TIME_AT );
        assertNotNull( pwdGraceAuthUseTime );
View Full Code Here

        for ( int i = 0; i < 5; i++ )
        {
            BindResponse bindResponse = userConnection.bind( bindReq );
            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );

            PasswordPolicy respCtrl = getPwdRespCtrl( bindResponse );
            assertNotNull( respCtrl );

            if ( i < 2 )
            {
                assertNull( respCtrl.getResponse() );
            }
            else
            {
                assertEquals( 5 - i, respCtrl.getResponse().getTimeBeforeExpiration() );
            }

            // Added an one second wait
            Thread.sleep( 1000 );
        }
View Full Code Here

            BindRequest bindReq = new BindRequestImpl();
            bindReq.setDn( userDn );
            bindReq.setCredentials( "12345" );
            bindReq.addControl( PP_REQ_CTRL );
            BindResponse bindResponse = userConnection2.bind( bindReq );
            PasswordPolicy respCtrl = getPwdRespCtrl( bindResponse );
            assertNotNull( respCtrl );
            assertNull( respCtrl.getResponse() );

            // now modify change time
            ModifyRequest modifyRequest = new ModifyRequestImpl();
            modifyRequest.setName( userDn );
            modifyRequest.replace( "pwdChangedTime", DateUtils.getGeneralizedTime( new Date().getTime() - 3100000 ) );
            adminConnection.modify( modifyRequest );

            BindRequest bindReq2 = new BindRequestImpl();
            bindReq2.setDn( userDn );
            bindReq2.setCredentials( "12345" );
            bindReq2.addControl( new PasswordPolicyImpl() );
            bindResponse = userConnection.bind( bindReq2 );
            respCtrl = getPwdRespCtrl( bindResponse );
            assertNotNull( respCtrl );
            assertNotNull( respCtrl.getResponse() );
            assertTrue( respCtrl.getResponse().getTimeBeforeExpiration() > 0 );
        }
        finally {
            safeCloseConnections( userConnection, userConnection2, adminConnection );
        }
    }  
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.