class SamlEntityDescriptorValidator {

    public void validate(EntityDescriptor descriptor) {
        if (Strings.isNullOrEmpty(descriptor.getEntityID())) {
            SamlValidationSpecificationFailure failure = SamlTransformationErrorFactory.missingOrEmptyEntityID();
            throw new SamlTransformationErrorException(failure.getErrorMessage(), failure.getLogLevel());
        }

        if (descriptor.getCacheDuration() == null && descriptor.getValidUntil() == null) {
            SamlValidationSpecificationFailure failure = SamlTransformationErrorFactory.missingCacheDurationAndValidUntil();
            throw new SamlTransformationErrorException(failure.getErrorMessage(), failure.getLogLevel());
        }

        validateRoleDescriptor(descriptor);
    }

}