org.keycloak.models.jpa

## Class UserAdapter

- java.lang.Object
- - org.keycloak.models.jpa.UserAdapter

- All Implemented Interfaces:
    JpaModel<UserEntity>, RoleMapperModel, UserModel

      public class UserAdapter
      extends Object
      implements UserModel, JpaModel<UserEntity>

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.keycloak.models.UserModel

      `UserModel.RequiredAction, UserModel.UserRemovedEvent`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected javax.persistence.EntityManager` | `em`
    `protected RealmModel` | `realm`
    `protected UserEntity` | `user`

    - ### Fields inherited from interface org.keycloak.models.UserModel

      `EMAIL, FIRST_NAME, LAST_NAME, LOCALE, USERNAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UserAdapter(KeycloakSession session, RealmModel realm, javax.persistence.EntityManager em, UserEntity user)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRequiredAction(String actionName)`
    `void` | `addRequiredAction(UserModel.RequiredAction action)`
    `void` | `deleteRoleMapping(RoleModel role)`
    `boolean` | `equals(Object o)`
    `List<String>` | `getAttribute(String name)`
    `Map<String,List<String>>` | `getAttributes()`
    `Set<RoleModel>` | `getClientRoleMappings(ClientModel app)`
    `Long` | `getCreatedTimestamp()` Get timestamp of user creation.
    `List<UserCredentialValueModel>` | `getCredentialsDirectly()`
    `String` | `getEmail()`
    `UserEntity` | `getEntity()`
    `String` | `getFederationLink()`
    `String` | `getFirstAttribute(String name)`
    `String` | `getFirstName()`
    `Set<GroupModel>` | `getGroups()`
    `String` | `getId()`
    `String` | `getLastName()`
    `Set<RoleModel>` | `getRealmRoleMappings()`
    `Set<String>` | `getRequiredActions()`
    `Set<RoleModel>` | `getRoleMappings()`
    `String` | `getServiceAccountClientLink()`
    `protected javax.persistence.TypedQuery<UserGroupMembershipEntity>` | `getUserGroupMappingQuery(GroupModel group)`
    `String` | `getUsername()`
    `protected javax.persistence.TypedQuery<UserRoleMappingEntity>` | `getUserRoleMappingEntityTypedQuery(RoleModel role)`
    `void` | `grantRole(RoleModel role)`
    `void` | `grantRoleImpl(RoleModel role)`
    `int` | `hashCode()`
    `boolean` | `hasRole(RoleModel role)`
    `boolean` | `isEmailVerified()`
    `boolean` | `isEnabled()`
    `boolean` | `isMemberOf(GroupModel group)`
    `boolean` | `isOtpEnabled()`
    `void` | `joinGroup(GroupModel group)`
    `protected void` | `joinGroupImpl(GroupModel group)`
    `void` | `leaveGroup(GroupModel group)`
    `void` | `removeAttribute(String name)`
    `void` | `removeRequiredAction(String actionName)`
    `void` | `removeRequiredAction(UserModel.RequiredAction action)`
    `void` | `setAttribute(String name, List<String> values)`
    `void` | `setCreatedTimestamp(Long timestamp)`
    `void` | `setEmail(String email)`
    `void` | `setEmailVerified(boolean verified)`
    `void` | `setEnabled(boolean enabled)`
    `void` | `setFederationLink(String link)`
    `void` | `setFirstName(String firstName)`
    `void` | `setLastName(String lastName)`
    `void` | `setOtpEnabled(boolean totp)`
    `void` | `setServiceAccountClientLink(String clientInternalId)`
    `void` | `setSingleAttribute(String name, String value)` Set single value of specified attribute.
    `void` | `setUsername(String username)`
    `void` | `updateCredential(UserCredentialModel cred)`
    `void` | `updateCredentialDirectly(UserCredentialValueModel credModel)`

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

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

- - ### Field Detail

    - #### user

          protected UserEntity user

    - #### em

          protected javax.persistence.EntityManager em

    - #### realm

          protected RealmModel realm

  - ### Constructor Detail

    - #### UserAdapter

          public UserAdapter(KeycloakSession session,
                             RealmModel realm,
                             javax.persistence.EntityManager em,
                             UserEntity user)

  - ### Method Detail

    - #### getEntity

          public UserEntity getEntity()

      Specified by:
        `getEntity` in interface `JpaModel<UserEntity>`

    - #### getId

          public String getId()

      Specified by:
        `getId` in interface `UserModel`

    - #### getUsername

          public String getUsername()

      Specified by:
        `getUsername` in interface `UserModel`

    - #### setUsername

          public void setUsername(String username)

      Specified by:
        `setUsername` in interface `UserModel`

    - #### getCreatedTimestamp

          public Long getCreatedTimestamp()

      Description copied from interface: `UserModel`
      Get timestamp of user creation. May be null for old users created before this feature introduction.
      Specified by:
        `getCreatedTimestamp` in interface `UserModel`

    - #### setCreatedTimestamp

          public void setCreatedTimestamp(Long timestamp)

      Specified by:
        `setCreatedTimestamp` in interface `UserModel`

    - #### isEnabled

          public boolean isEnabled()

      Specified by:
        `isEnabled` in interface `UserModel`

    - #### isOtpEnabled

          public boolean isOtpEnabled()

      Specified by:
        `isOtpEnabled` in interface `UserModel`

    - #### setEnabled

          public void setEnabled(boolean enabled)

      Specified by:
        `setEnabled` in interface `UserModel`

    - #### setSingleAttribute

          public void setSingleAttribute(String name,
                                         String value)

      Description copied from interface: `UserModel`
      Set single value of specified attribute. Remove all other existing values
      Specified by:
        `setSingleAttribute` in interface `UserModel`

    - #### setAttribute

          public void setAttribute(String name,
                                   List<String> values)

      Specified by:
        `setAttribute` in interface `UserModel`

    - #### removeAttribute

          public void removeAttribute(String name)

      Specified by:
        `removeAttribute` in interface `UserModel`

    - #### getFirstAttribute

          public String getFirstAttribute(String name)

      Specified by:
        `getFirstAttribute` in interface `UserModel`
      Returns:
        null if there is not any value of specified attribute or first value otherwise. Don't throw exception if there are more values of the attribute

    - #### getAttribute

          public List<String> getAttribute(String name)

      Specified by:
        `getAttribute` in interface `UserModel`
      Returns:
        list of all attribute values or empty list if there are not any values. Never return null

    - #### getAttributes

          public Map<String,List<String>> getAttributes()

      Specified by:
        `getAttributes` in interface `UserModel`

    - #### getRequiredActions

          public Set<String> getRequiredActions()

      Specified by:
        `getRequiredActions` in interface `UserModel`

    - #### addRequiredAction

          public void addRequiredAction(UserModel.RequiredAction action)

      Specified by:
        `addRequiredAction` in interface `UserModel`

    - #### addRequiredAction

          public void addRequiredAction(String actionName)

      Specified by:
        `addRequiredAction` in interface `UserModel`

    - #### removeRequiredAction

          public void removeRequiredAction(UserModel.RequiredAction action)

      Specified by:
        `removeRequiredAction` in interface `UserModel`

    - #### removeRequiredAction

          public void removeRequiredAction(String actionName)

      Specified by:
        `removeRequiredAction` in interface `UserModel`

    - #### getFirstName

          public String getFirstName()

      Specified by:
        `getFirstName` in interface `UserModel`

    - #### setFirstName

          public void setFirstName(String firstName)

      Specified by:
        `setFirstName` in interface `UserModel`

    - #### getLastName

          public String getLastName()

      Specified by:
        `getLastName` in interface `UserModel`

    - #### setLastName

          public void setLastName(String lastName)

      Specified by:
        `setLastName` in interface `UserModel`

    - #### getEmail

          public String getEmail()

      Specified by:
        `getEmail` in interface `UserModel`

    - #### setEmail

          public void setEmail(String email)

      Specified by:
        `setEmail` in interface `UserModel`

    - #### isEmailVerified

          public boolean isEmailVerified()

      Specified by:
        `isEmailVerified` in interface `UserModel`

    - #### setEmailVerified

          public void setEmailVerified(boolean verified)

      Specified by:
        `setEmailVerified` in interface `UserModel`

    - #### setOtpEnabled

          public void setOtpEnabled(boolean totp)

      Specified by:
        `setOtpEnabled` in interface `UserModel`

    - #### updateCredential

          public void updateCredential(UserCredentialModel cred)

      Specified by:
        `updateCredential` in interface `UserModel`

    - #### getCredentialsDirectly

          public List<UserCredentialValueModel> getCredentialsDirectly()

      Specified by:
        `getCredentialsDirectly` in interface `UserModel`

    - #### updateCredentialDirectly

          public void updateCredentialDirectly(UserCredentialValueModel credModel)

      Specified by:
        `updateCredentialDirectly` in interface `UserModel`

    - #### getGroups

          public Set<GroupModel> getGroups()

      Specified by:
        `getGroups` in interface `UserModel`

    - #### joinGroup

          public void joinGroup(GroupModel group)

      Specified by:
        `joinGroup` in interface `UserModel`

    - #### joinGroupImpl

          protected void joinGroupImpl(GroupModel group)

    - #### leaveGroup

          public void leaveGroup(GroupModel group)

      Specified by:
        `leaveGroup` in interface `UserModel`

    - #### isMemberOf

          public boolean isMemberOf(GroupModel group)

      Specified by:
        `isMemberOf` in interface `UserModel`

    - #### getUserGroupMappingQuery

          protected javax.persistence.TypedQuery<UserGroupMembershipEntity> getUserGroupMappingQuery(GroupModel group)

    - #### hasRole

          public boolean hasRole(RoleModel role)

      Specified by:
        `hasRole` in interface `RoleMapperModel`

    - #### getUserRoleMappingEntityTypedQuery

          protected javax.persistence.TypedQuery<UserRoleMappingEntity> getUserRoleMappingEntityTypedQuery(RoleModel role)

    - #### grantRole

          public void grantRole(RoleModel role)

      Specified by:
        `grantRole` in interface `RoleMapperModel`

    - #### grantRoleImpl

          public void grantRoleImpl(RoleModel role)

    - #### getRealmRoleMappings

          public Set<RoleModel> getRealmRoleMappings()

      Specified by:
        `getRealmRoleMappings` in interface `RoleMapperModel`

    - #### getRoleMappings

          public Set<RoleModel> getRoleMappings()

      Specified by:
        `getRoleMappings` in interface `RoleMapperModel`

    - #### deleteRoleMapping

          public void deleteRoleMapping(RoleModel role)

      Specified by:
        `deleteRoleMapping` in interface `RoleMapperModel`

    - #### getClientRoleMappings

          public Set<RoleModel> getClientRoleMappings(ClientModel app)

      Specified by:
        `getClientRoleMappings` in interface `RoleMapperModel`

    - #### getFederationLink

          public String getFederationLink()

      Specified by:
        `getFederationLink` in interface `UserModel`

    - #### setFederationLink

          public void setFederationLink(String link)

      Specified by:
        `setFederationLink` in interface `UserModel`

    - #### getServiceAccountClientLink

          public String getServiceAccountClientLink()

      Specified by:
        `getServiceAccountClientLink` in interface `UserModel`

    - #### setServiceAccountClientLink

          public void setServiceAccountClientLink(String clientInternalId)

      Specified by:
        `setServiceAccountClientLink` in interface `UserModel`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

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