Class RequiredPrivileges

java.lang.Object
io.goobi.viewer.model.security.RequiredPrivileges

public final class RequiredPrivileges extends Object
Privileges required for accessing a content file, optionally depending on the SolrConstants.DocType of the Solr document that lists the file. This allows a single access check query to decide whether a file is e.g. a page image (SolrConstants.DocType.PAGE) or a born-digital download (SolrConstants.DocType.DOWNLOAD_RESOURCE) without knowing the document type beforehand. All privileges that apply to a document type must be granted. Instances are immutable.
  • Method Details

    • of

      public static RequiredPrivileges of(String... privileges)
      Parameters:
      privileges - privileges required for any document type that has no specific mapping
      Returns:
      new RequiredPrivileges
    • withDocType

      public RequiredPrivileges withDocType(SolrConstants.DocType docType, String... privileges)
      Parameters:
      docType - document type for which other privileges are required
      privileges - privileges required for files listed in documents of the given type
      Returns:
      new RequiredPrivileges containing the additional mapping; this instance remains unchanged
    • getPrivileges

      public String[] getPrivileges(SolrConstants.DocType docType)
      Parameters:
      docType - document type of the Solr document listing the file; may be null
      Returns:
      privileges mapped to docType, or the default privileges if there is no mapping
    • contains

      public boolean contains(String privilege)
      Parameters:
      privilege - privilege name to look for
      Returns:
      true if privilege is required for any document type; false otherwise
    • getCacheKey

      public String getCacheKey()
      Key identifying this privilege combination in cached permission session attributes. For a single privilege without document type mappings, this is the privilege name itself so that cache entries are shared with the single-privilege access check methods.
      Returns:
      Cache key
    • toString

      public String toString()
      Overrides:
      toString in class Object