Class UserConsentManager

java.lang.Object
org.keycloak.services.managers.UserConsentManager

public class UserConsentManager extends Object
Author:
Marek Posolda
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addConsent(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user, org.keycloak.models.UserConsentModel consent)
    Add user consent for the user.
    static org.keycloak.models.UserConsentModel
    getConsentByClient(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user, String clientInternalId)
    Returns UserConsentModel given by a user for the client with clientInternalId
    static Stream<org.keycloak.models.UserConsentModel>
    getConsentsStream(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user)
    Obtains the consents associated with the user
    static boolean
    revokeConsentForClient(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user, String clientInternalId)
    Remove a user consent given by the user and client id
    static boolean
    revokeConsentToClient(org.keycloak.models.KeycloakSession session, org.keycloak.models.ClientModel client, org.keycloak.models.UserModel user)
    Revoke consent of given user to given client
    static void
    updateConsent(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user, org.keycloak.models.UserConsentModel consent)
    Update client scopes in the stored user consent

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UserConsentManager

      public UserConsentManager()
  • Method Details

    • revokeConsentToClient

      public static boolean revokeConsentToClient(org.keycloak.models.KeycloakSession session, org.keycloak.models.ClientModel client, org.keycloak.models.UserModel user)
      Revoke consent of given user to given client
      Parameters:
      session -
      client -
      user -
      Returns:
      true if either consent or offlineToken was revoked
    • addConsent

      public static void addConsent(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user, org.keycloak.models.UserConsentModel consent)
      Add user consent for the user.
      Parameters:
      realm - a reference to the realm
      user - user. Must not be null
      consent - all details corresponding to the granted consent
      Throws:
      org.keycloak.models.ModelException - If there is no user with userId
    • getConsentByClient

      public static org.keycloak.models.UserConsentModel getConsentByClient(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user, String clientInternalId)
      Returns UserConsentModel given by a user for the client with clientInternalId
      Parameters:
      realm - a reference to the realm
      user - user. Must not be null
      clientInternalId - id of the client
      Returns:
      consent given by the user to the client or null if no consent or user exists
      Throws:
      org.keycloak.models.ModelException - when there are more consents fulfilling specified parameters
    • getConsentsStream

      public static Stream<org.keycloak.models.UserConsentModel> getConsentsStream(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user)
      Obtains the consents associated with the user
      Parameters:
      realm - a reference to the realm.
      user - user. Must not be null
      Returns:
      a non-null Stream of consents associated with the user.
    • updateConsent

      public static void updateConsent(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user, org.keycloak.models.UserConsentModel consent)
      Update client scopes in the stored user consent
      Parameters:
      realm - a reference to the realm
      user - user. Must not be null
      consent - new details of the user consent
      Throws:
      org.keycloak.models.ModelException - when consent doesn't exist for the userId
    • revokeConsentForClient

      public static boolean revokeConsentForClient(org.keycloak.models.KeycloakSession session, org.keycloak.models.RealmModel realm, org.keycloak.models.UserModel user, String clientInternalId)
      Remove a user consent given by the user and client id
      Parameters:
      realm - a reference to the realm
      user - user. Must not be null
      clientInternalId - id of the client
      Returns:
      true if the consent was removed, false otherwise TODO: Make this method return Boolean so that store can return "I don't know" answer, this can be used for example in async stores