Class KeycloakIdentity

java.lang.Object
org.keycloak.authorization.common.KeycloakIdentity
All Implemented Interfaces:
Identity

public class KeycloakIdentity extends Object implements Identity
Author:
Pedro Igor
  • Field Details

  • Constructor Details

    • KeycloakIdentity

      public KeycloakIdentity(KeycloakSession keycloakSession)
    • KeycloakIdentity

      public KeycloakIdentity(KeycloakSession keycloakSession, IDToken token)
    • KeycloakIdentity

      public KeycloakIdentity(IDToken token, KeycloakSession keycloakSession, RealmModel realm)
    • KeycloakIdentity

      public KeycloakIdentity(AccessToken accessToken, KeycloakSession keycloakSession)
    • KeycloakIdentity

      public KeycloakIdentity(AccessToken accessToken, KeycloakSession keycloakSession, RealmModel realm, boolean ignoreTokenRoles)
    • KeycloakIdentity

      public KeycloakIdentity(AccessToken accessToken, KeycloakSession keycloakSession, RealmModel realm, boolean ignoreTokenRoles, UserModel tokenUser)
      Creates an identity for the given user, avoiding a lookup of the user from the token.
      Parameters:
      accessToken - the token
      keycloakSession - the session
      realm - the realm the user belongs to
      ignoreTokenRoles - if roles should be resolved from the user rather than from the token
      tokenUser - the user the token was issued to, or null to resolve the user from the token
  • Method Details

    • getId

      public String getId()
      Description copied from interface: Identity
      Returns the unique identifier of this identity.
      Specified by:
      getId in interface Identity
      Returns:
      the unique identifier of this identity
    • getAttributes

      public Attributes getAttributes()
      Description copied from interface: Identity
      Returns the attributes or claims associated with this identity.
      Specified by:
      getAttributes in interface Identity
      Returns:
      the attributes or claims associated with this identity
    • hasClientRole

      public boolean hasClientRole(String clientId, String roleName)
      Description copied from interface: Identity
      Indicates if this identity is granted with a client role with the given roleName.
      Specified by:
      hasClientRole in interface Identity
      Parameters:
      clientId - the client id
      roleName - the name of the role
      Returns:
      true if the identity has the given role. Otherwise, it returns false.
    • hasRealmRole

      public boolean hasRealmRole(String roleName)
      Description copied from interface: Identity
      Indicates if this identity is granted with a realm role with the given roleName.
      Specified by:
      hasRealmRole in interface Identity
      Parameters:
      roleName - the name of the role
      Returns:
      true if the identity has the given role. Otherwise, it returns false.
    • getAccessToken

      public AccessToken getAccessToken()
    • isResourceServer

      public boolean isResourceServer()