Class ETagHandler

java.lang.Object
de.captaingoldfish.scim.sdk.server.etag.ETagHandler

public class ETagHandler extends Object
author Pascal Knueppel
created at: 21.11.2019 - 08:28

this class is used for handling entity tags
  • Constructor Details

    • ETagHandler

      public ETagHandler()
  • Method Details

    • getResourceVersion

      public static Optional<ETag> getResourceVersion(ServiceProvider serviceProvider, ResourceType resourceType, ResourceNode resourceNode)
      if the service provider has its support vor eTag set to true this method will return either the already set version from the meta-attribute of the resource node or will generate a version value by generating a base64 encoded SHA-1 hash of the resource
      Parameters:
      serviceProvider - the service provider configuration
      resourceNode - the current resource node
      Returns:
      the version set by the developer or a base64 encoded SHA-1 hash. An empty if etag is not supported
    • validateVersion

      public static void validateVersion(ServiceProvider serviceProvider, ResourceType resourceType, Supplier<ResourceNode> currentState, Map<String,String> httpHeaders)
      will validate if the given httpHeaders do contain an entity tag within the request and if this entity tag matches the state of the current resource
      Parameters:
      serviceProvider - the service provider configuration
      currentState - supplier that gives access to the resource that should be checked
      httpHeaders - the http headers that might contain the corresponding http request headers
    • getETagFromHeader

      protected static Optional<ETag> getETagFromHeader(Map<String,String> httpHeaders, boolean ifNot)
      will extract either the If-Match header from the request or the If-None-Match header if one of these do exist. If both headers exist an exception is thrown since these headers are mutually exclusive
      Parameters:
      httpHeaders - the http headers from the request that optionally have one of the entity tag headers
      ifNot - if set to true the If-None-Match header is extracted, the If-Match header if set to false
      Returns:
      an empty of the specified entity tag