/** * Checks that at least either Valid Until or Cache Duration is present when Entities Descriptor is root element. * * @param entitiesDescriptor * @throws ValidationException */ protected void validateRoot(EntitiesDescriptor entitiesDescriptor) throws ValidationException { if (entitiesDescriptor.getParent() == null && entitiesDescriptor.getValidUntil() == null && entitiesDescriptor.getCacheDuration() == null) { throw new ValidationException("Must have either ValidUntil or CacheDuration when is root element."); } } }
/** * Gets the validUntil time of the metadata, if present. * * @param metadata metadata from which to get the validUntil instant * * @return the valid until instant or null if it is not present * * @throws FilterException thrown if the given XML object is not an {@link EntitiesDescriptor} or * {@link EntityDescriptor} */ protected DateTime getValidUntil(XMLObject metadata) throws FilterException { if (metadata instanceof EntitiesDescriptor) { return ((EntitiesDescriptor) metadata).getValidUntil(); } else if (metadata instanceof EntityDescriptor) { return ((EntityDescriptor) metadata).getValidUntil(); } else { log.error("Metadata root element was not an EntitiesDescriptor or EntityDescriptor it was a {}", metadata .getElementQName()); throw new FilterException("Metadata root element was not an EntitiesDescriptor or EntityDescriptor"); } } }
if (entitiesDescriptor.getValidUntil() != null) { log.debug("Writting validUntil attribute to EntitiesDescriptor DOM element"); String validUntilStr = Configuration.getSAMLDateFormatter().print(entitiesDescriptor.getValidUntil()); domElement.setAttributeNS(null, TimeBoundSAMLObject.VALID_UNTIL_ATTRIB_NAME, validUntilStr);