Class ClientApplication

java.lang.Object
io.goobi.viewer.model.security.user.AbstractLicensee
io.goobi.viewer.model.security.clients.ClientApplication
All Implemented Interfaces:
ILicensee, Serializable

@Entity public class ClientApplication extends AbstractLicensee implements Serializable
Author:
Florian Alpers Represents clients accessing the viewer not through web-browsers but using dedicated client-applications which must register with the server to view any data but which may also enjoy unique viewing rights via dedicated Licenses
See Also:
  • Constructor Details

    • ClientApplication

      public ClientApplication()
      Internal constructor for deserializing from database.
    • ClientApplication

      public ClientApplication(ClientApplication source)
      Cloning constructor.
      Parameters:
      source - client application instance to copy
    • ClientApplication

      public ClientApplication(String identifier)
      Constructor to create a new ClientApplication from a client request.
      Parameters:
      identifier - the client identifier
  • Method Details

    • getId

      public Long getId()
      Get the id.
      Returns:
      the id
    • setId

      public void setId(Long id)
      Set the id.
      Parameters:
      id - the id to set
    • getAccessStatus

      public ClientApplication.AccessStatus getAccessStatus()
      Get the current accessStatus.
      Returns:
      the accessStatus
    • setAccessStatus

      public void setAccessStatus(ClientApplication.AccessStatus accessStatus)
      Set the accessStatus.
      Parameters:
      accessStatus - the accessStatus to set
    • getClientIdentifier

      public String getClientIdentifier()
      Get the clientIdentifier.
      Returns:
      the clientIdentifier
    • setClientIdentifier

      public void setClientIdentifier(String clientIdentifier)
      Set the clientIdentifier.
      Parameters:
      clientIdentifier - the clientIdentifier to set
    • getClientIp

      public String getClientIp()
      Get the clientIp.
      Returns:
      the clientIp
    • setClientIp

      public void setClientIp(String clientIp)
      Set the clientIp.
      Parameters:
      clientIp - the clientIp to set
    • getDateRegistered

      public LocalDateTime getDateRegistered()
      Get the dateRegistered.
      Returns:
      the dateRegistered
    • setDateRegistered

      public void setDateRegistered(LocalDateTime dateRegistered)
      Get the dateRegistered.
      Parameters:
      dateRegistered - the dateRegistered to set
    • getDateLastAccess

      public LocalDateTime getDateLastAccess()
      Get the dateLastAccess.
      Returns:
      the dateLastAccess
    • setDateLastAccess

      public void setDateLastAccess(LocalDateTime dateLastAccess)
      Set the dateLastAccess.
      Parameters:
      dateLastAccess - the dateLastAccess to set
    • getName

      public String getName()
      Get the name.
      Specified by:
      getName in interface ILicensee
      Returns:
      the name
    • setName

      public void setName(String name)
      Set the name.
      Parameters:
      name - the name to set
    • getDescription

      public String getDescription()
      Get the description.
      Returns:
      the description
    • setDescription

      public void setDescription(String description)
      Set the description.
      Parameters:
      description - the description to set
    • getAccessType

      public License.AccessType getAccessType()
      Specified by:
      getAccessType in interface ILicensee
      Returns:
      AccessType corresponding to the licensee's class
    • matchesClientIdentifier

      public boolean matchesClientIdentifier(String identifier)
      Check if the given identifier matches this instances clientIdentifier.
      Parameters:
      identifier - client identifier string to compare
      Returns:
      true if the given identifier is not null and equals this instances clientIdentifier
    • isRegistrationPending

      public boolean isRegistrationPending()
      Checks if this client requires approval of its registration.
      Returns:
      true if the accessStatus is ClientApplication.AccessStatus.REQUESTED
    • isRegistrationPendingOrDenied

      public boolean isRegistrationPendingOrDenied()
      Checks if this client requires approval of its registration or this approval has been denied.
      Returns:
      true if the accessStatus is ClientApplication.AccessStatus.REQUESTED or ClientApplication.AccessStatus.DENIED
    • hashCode

      public int hashCode()
      Use hash code of the clientIdentifier.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this object
    • equals

      public boolean equals(Object obj)
      Two clients are equal if heir clientIdentifiers are equals.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare to this client
      Returns:
      true if the given object is equal to this instance, false otherwise
    • getSubnetMask

      public String getSubnetMask()
      Get the subnetMask.
      Returns:
      the subnetMask
    • setSubnetMask

      public void setSubnetMask(String subnetMask)
      Set the subnetMask.
      Parameters:
      subnetMask - the subnetMask to set
    • canSatisfyAllAccessConditions

      public AccessPermission canSatisfyAllAccessConditions(Set<String> requiredAccessConditions, String privilegeName, String pi) throws PresentationException, IndexUnreachableException, DAOException
      Check if this client has the privilege of the given privilegeName via its licenses.
      Parameters:
      requiredAccessConditions - List of access condition names to satisfy
      privilegeName - The privilege to check for
      pi - PI of a record to check
      Returns:
      true if the privilege should be granted to the client
      Throws:
      PresentationException
      IndexUnreachableException
      DAOException
    • hasLicense

      public AccessPermission hasLicense(String licenseName, String privilegeName, String pi) throws PresentationException, IndexUnreachableException
      Checks whether the licensee has a license with the given name. IF a privilege name is passed, the licensee must also have this privilege for that license.
      Specified by:
      hasLicense in interface ILicensee
      Overrides:
      hasLicense in class AbstractLicensee
      Parameters:
      licenseName - License name.
      privilegeName - Required privilege (optional).
      pi - Checks the privilege in connection with a specific record identifier (optional).
      Returns:
      true if the licensee holds a matching license (and the required privilege if specified), false otherwise
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • matchIp

      public boolean matchIp(String inIp)
      Checks if the given IP address matches the subnetMask of this client.
      Parameters:
      inIp - IP address of the connecting client
      Returns:
      true if the given IP address matches the subnet mask of this client application, false otherwise
    • initializeSubnetMask

      public void initializeSubnetMask()
      If no subnet mask has been set, use the clientIp if available with a '/32' mask.
    • isAccessGranted

      public boolean isAccessGranted()
    • mayLogIn

      public boolean mayLogIn(String remoteAddress)
      Parameters:
      remoteAddress - IP address of the connecting client
      Returns:
      true if remoteAddress may log in; false otherwise
    • isAllClients

      public boolean isAllClients() throws DAOException
      Throws:
      DAOException