Class DefaultActionToken

java.lang.Object
org.keycloak.representations.JsonWebToken
org.keycloak.models.DefaultActionTokenKey
org.keycloak.authentication.actiontoken.DefaultActionToken
All Implemented Interfaces:
Serializable, org.keycloak.models.SingleUseObjectKeyModel, org.keycloak.models.SingleUseObjectValueModel, org.keycloak.Token
Direct Known Subclasses:
CredentialOfferActionToken, ExecuteActionsActionToken, IdpVerifyAccountLinkActionToken, InviteOrgActionToken, ResetCredentialsActionToken, UpdateEmailActionToken, VerifyEmailActionToken

public class DefaultActionToken extends org.keycloak.models.DefaultActionTokenKey implements org.keycloak.models.SingleUseObjectValueModel
Part of action token that is intended to be used e.g. in link sent in password-reset email. The token encapsulates user, expected action and its time of expiry.
Author:
hmlnarik
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.keycloak.TokenVerifier.Predicate<org.keycloak.models.DefaultActionTokenKey>
     
    static final String
     
    static final String
     

    Fields inherited from class org.keycloak.models.DefaultActionTokenKey

    ACTION_TOKEN_USER_ID, JSON_FIELD_ACTION_VERIFICATION_NONCE

    Fields inherited from class org.keycloak.representations.JsonWebToken

    AUD, audience, AZP, exp, iat, id, issuedFor, issuer, nbf, otherClaims, subject, SUBJECT, type
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Single-use random value used for verification whether the relevant action is allowed.
    protected
    DefaultActionToken(String userId, String actionId, int absoluteExpirationInSecs, UUID actionVerificationNonce)
     
    protected
    DefaultActionToken(String userId, String actionId, int absoluteExpirationInSecs, UUID actionVerificationNonce, String compoundAuthenticationSessionId)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
     
     
    final String
    Removes given note, and returns original value (or null when no value was present)
    serialize(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, jakarta.ws.rs.core.UriInfo uri)
    Updates the following fields and serializes this token into a signed JWT.
    void
    setCompoundAuthenticationSessionId(String compoundAuthenticationSessionId)
     
    void
     
    final String
    setNote(String name, String value)
    Sets value of the given note

    Methods inherited from class org.keycloak.models.DefaultActionTokenKey

    from, getActionId, getActionVerificationNonce, getUserId

    Methods inherited from class org.keycloak.representations.JsonWebToken

    addAudience, audience, equals, exp, getAudience, getCategory, getExp, getIat, getId, getIssuedFor, getIssuer, getNbf, getOtherClaims, getSubject, getType, hasAnyAudience, hasAudience, hashCode, iat, id, isActive, isActive, isExpired, isIssuedBeforeSessionStart, isNotBefore, issuedFor, issuedNow, issuedNowWithTTL, issuer, nbf, setOtherClaims, setSubject, subject, toString, type

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.keycloak.models.SingleUseObjectKeyModel

    getExp, getExpiration, serializeKey
  • Field Details

    • JSON_FIELD_AUTHENTICATION_SESSION_ID

      public static final String JSON_FIELD_AUTHENTICATION_SESSION_ID
      See Also:
    • JSON_FIELD_EMAIL

      public static final String JSON_FIELD_EMAIL
      See Also:
    • ACTION_TOKEN_BASIC_CHECKS

      public static final org.keycloak.TokenVerifier.Predicate<org.keycloak.models.DefaultActionTokenKey> ACTION_TOKEN_BASIC_CHECKS
  • Constructor Details

    • DefaultActionToken

      public DefaultActionToken()
      Single-use random value used for verification whether the relevant action is allowed.
    • DefaultActionToken

      protected DefaultActionToken(String userId, String actionId, int absoluteExpirationInSecs, UUID actionVerificationNonce)
      Parameters:
      userId - User ID
      actionId - Action ID
      absoluteExpirationInSecs - Absolute expiration time in seconds in timezone of Keycloak.
      actionVerificationNonce -
    • DefaultActionToken

      protected DefaultActionToken(String userId, String actionId, int absoluteExpirationInSecs, UUID actionVerificationNonce, String compoundAuthenticationSessionId)
      Parameters:
      userId - User ID
      actionId - Action ID
      absoluteExpirationInSecs - Absolute expiration time in seconds in timezone of Keycloak.
      actionVerificationNonce -
  • Method Details

    • getCompoundAuthenticationSessionId

      public String getCompoundAuthenticationSessionId()
    • setCompoundAuthenticationSessionId

      public void setCompoundAuthenticationSessionId(String compoundAuthenticationSessionId)
    • getNotes

      public Map<String,String> getNotes()
      Specified by:
      getNotes in interface org.keycloak.models.SingleUseObjectValueModel
    • getNote

      public String getNote(String name)
      Specified by:
      getNote in interface org.keycloak.models.SingleUseObjectValueModel
    • setNote

      public final String setNote(String name, String value)
      Sets value of the given note
      Returns:
      original value (or null when no value was present)
    • removeNote

      public final String removeNote(String name)
      Removes given note, and returns original value (or null when no value was present)
      Returns:
      see description
    • setEmail

      public void setEmail(String email)
    • getEmail

      public String getEmail()
    • serialize

      public String serialize(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, jakarta.ws.rs.core.UriInfo uri)
      Updates the following fields and serializes this token into a signed JWT. The list of updated fields follows:
      • id: random nonce
      • issuedAt: Current time
      • issuer: URI of the given realm
      • audience: URI of the given realm (same as issuer)
      Parameters:
      session -
      realm -
      uri -
      Returns: