Class AccessToken

java.lang.Object
com.jalios.jstore.BasicStorable
com.jalios.jcms.Data
com.jalios.jcms.authentication.accesstoken.AccessToken
All Implemented Interfaces:
DBData, JcmsConstants, ImportConstants, MashupConstants, Storable, JaliosConstants, LangPropertyArgument, Serializable, Cloneable, Comparable<BasicStorable>

public class AccessToken extends Data implements DBData
POJO use to store access token (authkey or JWT token) that were emitted to end user.

getFingerprint() is the only values for security check. All others field are only provided for information to track security constraint that were configured when token was emitted.

Since:
JCMS-4770
See Also:
  • Constructor Details

    • AccessToken

      public AccessToken()
    • AccessToken

      public AccessToken(AccessToken other)
  • Method Details

    • getMember

      public Member getMember()
      Returns the Member this token allows to sign in
      Returns:
      a Member id
    • setMember

      public void setMember(Member member)
      Set the Member this token allows to sign in
      Parameters:
      member -
    • getMemberId

      public String getMemberId()
      Returns the id of the member this token allows to sign in
      Returns:
      a Member id
    • setMemberId

      public void setMemberId(String memberId)
      Sets the id of the Member that this AccessToken allow to sign in
      Parameters:
      memberId - the id of the Member
    • getFingerprint

      public String getFingerprint()
      Retrieve the token fingerprint.
      Returns:
      a unique signature of the token
    • setFingerprint

      public void setFingerprint(String fingerprint)
      Set the token fingerprint.
      Parameters:
      fingerprint - a unique value identifying the token value (must fit in 256 characters)
    • getTokenType

      public String getTokenType()
      Retrieve the type of authentication Token (jwt/authkey)
      Returns:
      "JWT" or "AUTHKEY", null if unknown
    • setTokenType

      public void setTokenType(String tokenType)
      Set the type of authentication Token (jwt/authkey)
      Parameters:
      tokenType - "JWT" or "AUTHKEY", null if unknown
    • getName

      public String getName()
      Retrieve the name describing the token
      Returns:
      a name or null if it was not specified
    • setName

      public void setName(String name)
      Set the name describing the token
      Parameters:
      name - a text describing the token
    • getUrl

      public String getUrl()
      Retrieve the URL for which the token was emitted.
      Returns:
      an URL
    • setUrl

      public void setUrl(String url)
      Set the URL for which the token is emitted.
      Parameters:
      url - an URL
    • isPrefixMode

      public boolean isPrefixMode()
      Retrieve wether token was emitted in prefix or exact mode
      Returns:
      true if token is prefix mode, false if token is in exact mode
    • setPrefixMode

      public void setPrefixMode(Boolean prefixMode)
      Set wether token is in prefix or exact mode
      Parameters:
      prefixMode - true if token is prefix mode, false if token is in exact mode
    • getMethods

      public String getMethods()
      Retrieve methods accepted by token
      Returns:
      a coma separated list of HTTP methods accepted for token
    • setMethods

      public void setMethods(String methods)
      Set methods accepted by token
      Parameters:
      methods - a coma separated list of HTTP methods accepted for token
    • getIpMask

      public String getIpMask()
      Retrieve regular expression used to match IP authorized for this token
      Returns:
      a regular expression
    • setIpMask

      public void setIpMask(String ipMask)
      Set regular expression to use to match IP authorized for this token
      Parameters:
      ipMask - a regular expression
    • getExpirationDate

      public Date getExpirationDate()
      Retrieve the expiration date that was intially computed when the Authentication key was sent.

      This date is informative and is used for automatic purge of expired keys.
      However it may not be completely accurate if any max age configuration is changed, either globally for site settings or for the Member (though its groups).

      Returns:
      the Date at which the key is considered expired, may return null
    • setExpirationDate

      public void setExpirationDate(Date expirationDate)
      Set the expiration date of this AccessToken.
      Parameters:
      expirationDate - a Date after which this AccessToken can be deleted/purged.
    • isTechnical

      public boolean isTechnical()
      Check if this token was created manually or programmatically
      Returns:
      true if token was created automatically by a program, false if token was created manually by a user action in the token manager UI
    • setTechnical

      public void setTechnical(Boolean technical)
      Set if this token was created manually or programmatically
      Parameters:
      technical - true if token was created automatically by a program, false if token was created manually by a user action in the token manager UI
    • getLastUsedDate

      public Date getLastUsedDate()
      Retrieve the date this AccessToken was last used.
      Returns:
      a Date or null if it was never used.
    • setLastUsedDate

      public void setLastUsedDate(Date lastUsedDate)
      Set the date this AccessToken was last used.
      Parameters:
      lastUsedDate - Date or null to indicated it was never used.
    • getUseCount

      public long getUseCount()
      Retrieve the number of time this AccessToken was used
      Returns:
      a count
    • setUseCount

      public void setUseCount(Long useCount)
      Set the number of time this AccessToken was used
      Parameters:
      useCount - the use count to assign
    • incrementUseCount

      public void incrementUseCount()
      Increment the use count of this access token by one.
    • getDataName

      public String getDataName(String language)
      Description copied from class: Data
      Return the name of this Data, every sub class Data which will be displayed to user should implements this method already.
      • The Title (multi-language) for a Publication.
      • The Name (multi-language) for a Category.
      • The Name for a Group, a Member.
      • The Title (multi-language) for a Workspace.
      Can be seen as a smart multi-language toString(), but never returning null.
      Default behaviour is to return toFullString() of Data or empty string if toFullString is null.
      Overrides:
      getDataName in class Data
      Parameters:
      language - the language in which to return the name if multilang available for the data.
      Returns:
      a String, MUST NOT return null.
    • canBeReadBy

      public boolean canBeReadBy(Member member, boolean searchInGroups, RightInfo rightInfo)
      Description copied from class: Data
      Checks if the specified member is authorized to read this Data.
      Overrides:
      canBeReadBy in class Data
      Parameters:
      member - the member to check (may be null for anonymous user)
      searchInGroups - set to true to check for read right authorization using Member's group(s).
      rightInfo - a RightInfo instance in which explanation of read right authorization acceptance or refusal will be indicated. Value is required and cannot be null.
      Returns:
      true if the member can read this Data, false otherwise