private void validate()

in src/main/java/org/apache/directory/fortress/core/impl/PolicyP.java [235:366]


    private void validate( PwPolicy policy ) throws ValidationException
    {
        int length = policy.getName().length();

        if ( length < 1 || length > GlobalIds.PWPOLICY_NAME_LEN )
        {
            String error = "validate policy name [" + policy.getName() + "] INVALID LENGTH [" + length + "]";
            LOG.error( error );
            throw new ValidationException( GlobalErrIds.PSWD_NAME_INVLD_LEN, error );
        }

        if ( policy.getCheckQuality() != null )
        {
            try
            {
                if ( policy.getCheckQuality() < 0 || policy.getCheckQuality() > 2 )
                {
                    String error = "validate policy name [" + policy.getName() + "] value checkQuality ["
                        + policy.getCheckQuality() + "] INVALID INT VALUE";
                    LOG.error( error );
                    throw new ValidationException( GlobalErrIds.PSWD_QLTY_INVLD, error );
                }
            }
            catch ( java.lang.NumberFormatException nfe )
            {
                String error = "validate policy name [" + policy.getName() + "] value checkQuality ["
                    + policy.getCheckQuality() + "] INVALID INT VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_QLTY_INVLD, error );
            }
        }

        if ( policy.getMaxAge() != null )
        {
            if ( policy.getMaxAge() > MAX_AGE )
            {
                String error = "validate policy name [" + policy.getName() + "] value maxAge [" + policy.getMaxAge()
                    + "] INVALID INT VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_MAXAGE_INVLD, error );
            }
        }

        if ( policy.getMinAge() != null )
        {
            // policy.minAge
            if ( policy.getMinAge() > MAX_AGE )
            {
                String error = "validate policy name [" + policy.getName() + "] value minAge [" + policy.getMinAge()
                    + "] INVALID INT VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_MINAGE_INVLD, error );
            }
        }

        if ( policy.getMinLength() != null )
        {
            if ( policy.getMinLength() > MIN_PW_LEN )
            {
                String error = "validate policy name [" + policy.getName() + "] value minLength ["
                    + policy.getMinLength() + "] INVALID INT VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_MINLEN_INVLD, error );
            }
        }

        if ( policy.getFailureCountInterval() != null )
        {
            if ( policy.getFailureCountInterval() > MAX_AGE )
            {
                String error = "validate policy name [" + policy.getName() + "] value failureCountInterval ["
                    + policy.getFailureCountInterval() + "] INVALID INT VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_INTERVAL_INVLD, error );
            }
        }

        if ( policy.getMaxFailure() != null )
        {
            if ( policy.getMaxFailure() > MAX_FAILURE )
            {
                String error = "validate policy name [" + policy.getName() + "] value maxFailure ["
                    + policy.getMaxFailure() + "] INVALID INT VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_MAXFAIL_INVLD, error );
            }
        }

        if ( policy.getInHistory() != null )
        {
            if ( policy.getInHistory() > MAX_HISTORY )
            {
                String error = "validate policy name [" + policy.getName() + "] value inHistory ["
                    + policy.getInHistory() + "] INVALID VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_HISTORY_INVLD, error );
            }
        }

        if ( policy.getGraceLoginLimit() != null )
        {
            if ( policy.getGraceLoginLimit() > MAX_GRACE_COUNT )
            {
                String error = "validate policy name [" + policy.getName() + "] value graceLoginLimit ["
                    + policy.getGraceLoginLimit() + "] INVALID VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_GRACE_INVLD, error );
            }
        }

        if ( policy.getLockoutDuration() != null )
        {
            if ( policy.getLockoutDuration() > MAX_AGE )
            {
                String error = "validate policy name [" + policy.getName() + "] value lockoutDuration ["
                    + policy.getLockoutDuration() + "] INVALID VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_LOCKOUTDUR_INVLD, error );
            }
        }

        if ( policy.getExpireWarning() != null )
        {
            if ( policy.getExpireWarning() > MAX_AGE )
            {
                String error = "validate policy name [" + policy.getName() + "] value expireWarning ["
                    + policy.getExpireWarning() + "] INVALID VALUE";
                LOG.error( error );
                throw new ValidationException( GlobalErrIds.PSWD_EXPWARN_INVLD, error );
            }
        }
    }