static PasswordWarning newWarning( PasswordPolicy policy ) { PasswordPolicyResponse response = policy.getResponse(); if ( response != null ) { PasswordWarningImpl policyWarning = new PasswordWarningImpl(); policyWarning.timeBeforeExpiration = response.getTimeBeforeExpiration(); policyWarning.graceAuthNsRemaining = response.getGraceAuthNRemaining(); policyWarning.changeAfterReset = response.getPasswordPolicyError() == PasswordPolicyErrorEnum.CHANGE_AFTER_RESET; if ( policyWarning.timeBeforeExpiration >= 0 || policyWarning.graceAuthNsRemaining >= 0 || policyWarning.changeAfterReset ) { // it actually is a warning! return policyWarning; } } return null; }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, PasswordPolicyContainer ppolicyContainer ) { ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setGraceAuthNRemaining( value ); ppolicyContainer.setGrammarEndAllowed( true ); } }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, Asn1Container container ) { PasswordPolicyContainer ppolicyContainer = ( PasswordPolicyContainer ) container; PasswordPolicyErrorEnum error = PasswordPolicyErrorEnum.get( value ); ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setPasswordPolicyError( error ); ppolicyContainer.setGrammarEndAllowed( true ); } }
pwdRespCtrl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.get( ppe.getErrorCode() ) ); bindContext.addResponseControl( pwdRespCtrl ); mods.add( pwdAccountLockedMod ); pwdRespCtrl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.ACCOUNT_LOCKED ); pwdRespCtrl.getResponse().setGraceAuthNRemaining( numGraceAuth ); pwdRespCtrl.getResponse().setTimeBeforeExpiration( expiryWarnTime ); pwdRespCtrl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.CHANGE_AFTER_RESET ); bindContext.getSession().setPwdMustChange( true );
/** * Returns an exception to be thrown in the case of a non SUCCESS * <code>resultCode</code>. * * @param resultResponse The result response * @param passwordPolicy The password policy in use * @param resultCode The result * @return The created PasswordException */ protected PasswordException fail( ResultResponse resultResponse, PasswordPolicy passwordPolicy, ResultCodeEnum resultCode ) { PasswordException exception = new PasswordException(); exception.setResultCode( resultCode ); if ( passwordPolicy != null && passwordPolicy.getResponse() != null && passwordPolicy.getResponse().getPasswordPolicyError() != null ) { exception.setPasswordPolicyError( passwordPolicy.getResponse().getPasswordPolicyError() ); } return exception; }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, PasswordPolicyContainer ppolicyContainer ) { ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setTimeBeforeExpiration( value ); ppolicyContainer.setGrammarEndAllowed( true ); } }
/** * Returns an exception to be thrown in the case of a non SUCCESS * <code>resultCode</code>. * * @param resultResponse The result response * @param passwordPolicy The password policy in use * @param resultCode The result * @return The created PasswordException */ protected PasswordException fail( ResultResponse resultResponse, PasswordPolicy passwordPolicy, ResultCodeEnum resultCode ) { PasswordException exception = new PasswordException(); exception.setResultCode( resultCode ); if ( passwordPolicy != null && passwordPolicy.getResponse() != null && passwordPolicy.getResponse().getPasswordPolicyError() != null ) { exception.setPasswordPolicyError( passwordPolicy.getResponse().getPasswordPolicyError() ); } return exception; }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, PasswordPolicyContainer ppolicyContainer ) { ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setTimeBeforeExpiration( value ); ppolicyContainer.setGrammarEndAllowed( true ); } }
static PasswordWarning newWarning( PasswordPolicy policy ) { PasswordPolicyResponse response = policy.getResponse(); if ( response != null ) { PasswordWarningImpl policyWarning = new PasswordWarningImpl(); policyWarning.timeBeforeExpiration = response.getTimeBeforeExpiration(); policyWarning.graceAuthNsRemaining = response.getGraceAuthNRemaining(); policyWarning.changeAfterReset = response.getPasswordPolicyError() == PasswordPolicyErrorEnum.CHANGE_AFTER_RESET; if ( policyWarning.timeBeforeExpiration >= 0 || policyWarning.graceAuthNsRemaining >= 0 || policyWarning.changeAfterReset ) { // it actually is a warning! return policyWarning; } } return null; }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, Asn1Container container ) { PasswordPolicyContainer ppolicyContainer = ( PasswordPolicyContainer ) container; PasswordPolicyErrorEnum error = PasswordPolicyErrorEnum.get( value ); ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setPasswordPolicyError( error ); ppolicyContainer.setGrammarEndAllowed( true ); } }
/** * Returns an exception to be thrown in the case of a non SUCCESS * <code>resultCode</code>. * * @param resultResponse The result response * @param passwordPolicy The password policy in use * @param resultCode The result * @return The created PasswordException */ protected PasswordException fail( ResultResponse resultResponse, PasswordPolicy passwordPolicy, ResultCodeEnum resultCode ) { PasswordException exception = new PasswordException(); exception.setResultCode( resultCode ); if ( passwordPolicy != null && passwordPolicy.getResponse() != null && passwordPolicy.getResponse().getPasswordPolicyError() != null ) { exception.setPasswordPolicyError( passwordPolicy.getResponse().getPasswordPolicyError() ); } return exception; }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, PasswordPolicyContainer ppolicyContainer ) { ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setGraceAuthNRemaining( value ); ppolicyContainer.setGrammarEndAllowed( true ); } }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, PasswordPolicyContainer ppolicyContainer ) { ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setTimeBeforeExpiration( value ); ppolicyContainer.setGrammarEndAllowed( true ); } }
static PasswordWarning newWarning( PasswordPolicy policy ) { PasswordPolicyResponse response = policy.getResponse(); if ( response != null ) { PasswordWarningImpl policyWarning = new PasswordWarningImpl(); policyWarning.timeBeforeExpiration = response.getTimeBeforeExpiration(); policyWarning.graceAuthNsRemaining = response.getGraceAuthNRemaining(); policyWarning.changeAfterReset = response.getPasswordPolicyError() == PasswordPolicyErrorEnum.CHANGE_AFTER_RESET; if ( policyWarning.timeBeforeExpiration >= 0 || policyWarning.graceAuthNsRemaining >= 0 || policyWarning.changeAfterReset ) { // it actually is a warning! return policyWarning; } } return null; }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, Asn1Container container ) { PasswordPolicyContainer ppolicyContainer = ( PasswordPolicyContainer ) container; PasswordPolicyErrorEnum error = PasswordPolicyErrorEnum.get( value ); ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setPasswordPolicyError( error ); ppolicyContainer.setGrammarEndAllowed( true ); } }
/** * {@inheritDoc} */ @Override protected void setIntegerValue( int value, PasswordPolicyContainer ppolicyContainer ) { ppolicyContainer.getPasswordPolicyResponseControl().getResponse().setGraceAuthNRemaining( value ); ppolicyContainer.setGrammarEndAllowed( true ); } }
/** * {@inheritDoc} */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( " PasswordPolicyResponse control :\n" ); sb.append( " oid : '" ).append( getOid() ).append( '\n' ); if ( hasResponse() && getResponse().getTimeBeforeExpiration() >= 0 ) { sb.append( " timeBeforeExpiration : '" ).append( getResponse().getTimeBeforeExpiration() ) .append( '\n' ); } else if ( hasResponse() && getResponse().getGraceAuthNRemaining() >= 0 ) { sb.append( " graceAuthNsRemaining : '" ).append( getResponse().getGraceAuthNRemaining() ) .append( '\n' ); } if ( hasResponse() && getResponse().getPasswordPolicyError() != null ) { sb.append( " ppolicyError : '" ).append( getResponse().getPasswordPolicyError().toString() ) .append( '\n' ); } return sb.toString(); }
/** * If the PP config request it, the old password must be supplied in the modifications. Check that it * is present. */ private void checkOldPwdRequired( ModifyOperationContext modifyContext, PasswordPolicyConfiguration policyConfig, PwdModDetailsHolder pwdModDetails, boolean isPPolicyReqCtrlPresent ) throws LdapNoPermissionException { if ( policyConfig.isPwdSafeModify() && !pwdModDetails.isDelete() && pwdModDetails.isAddOrReplace() ) { String msg = "trying to update password attribute without the supplying the old password"; LOG.debug( msg ); if ( isPPolicyReqCtrlPresent ) { PasswordPolicyDecorator responseControl = new PasswordPolicyDecorator( directoryService.getLdapCodecService(), true ); responseControl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.MUST_SUPPLY_OLD_PASSWORD ); modifyContext.addResponseControl( responseControl ); } throw new LdapNoPermissionException( msg ); } }
/** * {@inheritDoc} */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( " PasswordPolicyResponse control :\n" ); sb.append( " oid : '" ).append( getOid() ).append( '\n' ); if ( hasResponse() && getResponse().getTimeBeforeExpiration() >= 0 ) { sb.append( " timeBeforeExpiration : '" ).append( getResponse().getTimeBeforeExpiration() ) .append( '\n' ); } else if ( hasResponse() && getResponse().getGraceAuthNRemaining() >= 0 ) { sb.append( " graceAuthNsRemaining : '" ).append( getResponse().getGraceAuthNRemaining() ) .append( '\n' ); } if ( hasResponse() && getResponse().getPasswordPolicyError() != null ) { sb.append( " ppolicyError : '" ).append( getResponse().getPasswordPolicyError().toString() ) .append( '\n' ); } return sb.toString(); }
responseControl.getResponse().setPasswordPolicyError( PasswordPolicyErrorEnum.PASSWORD_IN_HISTORY ); modifyContext.addResponseControl( responseControl );