org.keycloak.authorization.common

## Class UserModelIdentity

- java.lang.Object
- - org.keycloak.authorization.common.UserModelIdentity

- All Implemented Interfaces:
    Identity

      public class UserModelIdentity
      extends Object
      implements Identity

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RealmModel` | `realm`
    `protected UserModel` | `user`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UserModelIdentity(RealmModel realm, UserModel user)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Attributes` | `getAttributes()` Returns the attributes or claims associated with this identity.
    `String` | `getId()` Returns the unique identifier of this identity.
    `boolean` | `hasClientRole(String clientId, String roleName)` Indicates if this identity is granted with a client role with the given `roleName`.
    `boolean` | `hasRealmRole(String roleName)` Indicates if this identity is granted with a realm role with the given `roleName`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### realm

          protected RealmModel realm

    - #### user

          protected UserModel user

  - ### Constructor Detail

    - #### UserModelIdentity

          public UserModelIdentity(RealmModel realm,
                                   UserModel user)

  - ### Method Detail

    - #### 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

    - #### 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.

    - #### 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.

Copyright © 2021 JBoss by Red Hat. All rights reserved.