org.keycloak.services.resources.admin

## Class RealmAdminResource

- java.lang.Object
- - org.keycloak.services.resources.admin.RealmAdminResource

-     public class RealmAdminResource
      extends Object

  Base resource class for the admin REST api of one realm
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AdminPermissionEvaluator` | `auth`
    `protected ClientConnection` | `connection`
    `protected javax.ws.rs.core.HttpHeaders` | `headers`
    `protected static org.jboss.logging.Logger` | `logger`
    `protected RealmModel` | `realm`
    `protected KeycloakSession` | `session`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RealmAdminResource(AdminPermissionEvaluator auth, RealmModel realm, TokenManager tokenManager, AdminEventBuilder adminEvent)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDefaultDefaultClientScope(String clientScopeId)`
    `void` | `addDefaultGroup(String groupId)`
    `void` | `addDefaultOptionalClientScope(String clientScopeId)`
    `void` | `clearAdminEvents()` Delete all admin events
    `void` | `clearEvents()` Delete all events
    `void` | `clearKeysCache()` Clear cache of external public keys (Public keys of clients or Identity providers)
    `void` | `clearRealmCache()` Clear realm cache
    `void` | `clearUserCache()` Clear user cache
    `ClientRepresentation` | `convertClientDescription(String description)` Base path for importing clients under this realm.
    `void` | `deleteRealm()` Delete the realm
    `void` | `deleteSession(String sessionId)` Remove a specific user session.
    `AuthenticationManagementResource` | `flows()`
    `AttackDetectionResource` | `getAttackDetection()` Base path for managing attack detection.
    `ClientInitialAccessResource` | `getClientInitialAccess()` Base path for managing client initial access tokens
    `ClientRegistrationPolicyResource` | `getClientRegistrationPolicy()`
    `ClientsResource` | `getClients()` Base path for managing clients under this realm.
    `ClientScopesResource` | `getClientScopes()` Base path for managing client scopes under this realm.
    `Stream<Map<String,String>>` | `getClientSessionStats()` Get client session stats Returns a JSON map.
    `ClientScopesResource` | `getClientTemplates()` Deprecated.
    `ComponentResource` | `getComponents()` Base path for managing components under this realm.
    `Stream<String>` | `getCredentialRegistrators()`
    `Stream<ClientScopeRepresentation>` | `getDefaultDefaultClientScopes()` Get realm default client scopes.
    `Stream<GroupRepresentation>` | `getDefaultGroups()` Get group hierarchy.
    `Stream<ClientScopeRepresentation>` | `getDefaultOptionalClientScopes()` Get realm optional client scopes.
    `Stream<EventRepresentation>` | `getEvents(List<String> types, String client, String user, String dateFrom, String dateTo, String ipAddress, Integer firstResult, Integer maxResults)` Get events Returns all events, or filters them based on URL query parameters listed here
    `Stream<AdminEventRepresentation>` | `getEvents(List<String> operationTypes, String authRealm, String authClient, String authUser, String authIpAddress, String resourcePath, String dateFrom, String dateTo, Integer firstResult, Integer maxResults, List<String> resourceTypes)` Get admin events Returns all admin events, or filters events based on URL query parameters listed here
    `GroupRepresentation` | `getGroupByPath(String path)`
    `GroupsResource` | `getGroups()`
    `IdentityProvidersResource` | `getIdentityProviderResource()`
    `RealmLocalizationResource` | `getLocalization()` Base path for managing localization under this realm.
    `RealmRepresentation` | `getRealm()` Get the top-level representation of the realm It will not include nested information like User and Client representations.
    `RealmEventsConfigRepresentation` | `getRealmEventsConfig()` Get the events provider configuration Returns JSON object with events provider configuration
    `RoleContainerResource` | `getRoleContainerResource()` base path for managing realm-level roles of this realm
    `ManagementPermissionReference` | `getUserMgmtPermissions()`
    `KeyResource` | `keys()`
    `javax.ws.rs.core.Response` | `ldapServerCapabilities(TestLdapConnectionRepresentation config)` Get LDAP supported extensions.
    `GlobalRequestResult` | `logoutAll()` Removes all user sessions.
    `RealmRepresentation` | `partialExport(Boolean exportGroupsAndRoles, Boolean exportClients)` Partial export of existing realm into a JSON file.
    `javax.ws.rs.core.Response` | `partialImport(PartialImportRepresentation rep)` Partial import from a JSON file to an existing realm.
    `GlobalRequestResult` | `pushRevocation()` Push the realm's revocation policy to any client that has an admin url associated with it.
    `void` | `removeDefaultDefaultClientScope(String clientScopeId)`
    `void` | `removeDefaultGroup(String groupId)`
    `void` | `removeDefaultOptionalClientScope(String clientScopeId)`
    `RoleByIdResource` | `rolesById()` Path for managing all realm-level or client-level roles defined in this realm by its id.
    `ManagementPermissionReference` | `setUsersManagementPermissionsEnabled(ManagementPermissionReference ref)`
    `javax.ws.rs.core.Response` | `testLDAPConnection(String action, String connectionUrl, String bindDn, String bindCredential, String useTruststoreSpi, String connectionTimeout, String componentId, String startTls)` Deprecated.
    `javax.ws.rs.core.Response` | `testLDAPConnection(TestLdapConnectionRepresentation config)` Test LDAP connection
    `javax.ws.rs.core.Response` | `testSMTPConnection(Map<String,String> settings)`
    `javax.ws.rs.core.Response` | `testSMTPConnection(String config)` Deprecated.
    `static ManagementPermissionReference` | `toUsersMgmtRef(AdminPermissionManagement permissions)`
    `javax.ws.rs.core.Response` | `updateRealm(RealmRepresentation rep)` Update the top-level information of the realm Any user, roles or client information in the representation will be ignored.
    `void` | `updateRealmEventsConfig(RealmEventsConfigRepresentation rep)` Update the events provider Change the events provider and/or its configuration
    `UsersResource` | `users()` Base path for managing users in this realm.
    `UserStorageProviderResource` | `userStorage()`

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

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

- - ### Field Detail

    - #### logger

          protected static final org.jboss.logging.Logger logger

    - #### auth

          protected AdminPermissionEvaluator auth

    - #### realm

          protected RealmModel realm

    - #### session

          @Context
          protected KeycloakSession session

    - #### connection

          @Context
          protected ClientConnection connection

    - #### headers

          @Context
          protected javax.ws.rs.core.HttpHeaders headers

  - ### Constructor Detail

    - #### RealmAdminResource

          public RealmAdminResource(AdminPermissionEvaluator auth,
                                    RealmModel realm,
                                    TokenManager tokenManager,
                                    AdminEventBuilder adminEvent)

  - ### Method Detail

    - #### convertClientDescription

          @Path(value="client-description-converter")
           @Consumes(value={"application/json","application/xml","text/plain"})
           @POST
           @Produces(value="application/json")
          public ClientRepresentation convertClientDescription(String description)

      Base path for importing clients under this realm.
      Returns:

    - #### getAttackDetection

          @Path(value="attack-detection")
          public AttackDetectionResource getAttackDetection()

      Base path for managing attack detection.
      Returns:

    - #### getClients

          @Path(value="clients")
          public ClientsResource getClients()

      Base path for managing clients under this realm.
      Returns:

    - #### getClientTemplates

          @Deprecated
           @Path(value="client-templates")
          public ClientScopesResource getClientTemplates()

      Deprecated.
      This endpoint is deprecated. It's here just because of backwards compatibility. Use `getClientScopes()` instead
      Returns:

    - #### getClientScopes

          @Path(value="client-scopes")
          public ClientScopesResource getClientScopes()

      Base path for managing client scopes under this realm.
      Returns:

    - #### getLocalization

          @Path(value="localization")
          public RealmLocalizationResource getLocalization()

      Base path for managing localization under this realm.

    - #### getDefaultDefaultClientScopes

          @GET
           @Produces(value="application/json")
           @Path(value="default-default-client-scopes")
          public Stream<ClientScopeRepresentation> getDefaultDefaultClientScopes()

      Get realm default client scopes. Only name and ids are returned.
      Returns:

    - #### addDefaultDefaultClientScope

          @PUT
           @Path(value="default-default-client-scopes/{clientScopeId}")
          public void addDefaultDefaultClientScope(@PathParam(value="clientScopeId")
                                                                                                                      String clientScopeId)

    - #### removeDefaultDefaultClientScope

          @DELETE
           @Path(value="default-default-client-scopes/{clientScopeId}")
          public void removeDefaultDefaultClientScope(@PathParam(value="clientScopeId")
                                                                                                                            String clientScopeId)

    - #### getDefaultOptionalClientScopes

          @GET
           @Produces(value="application/json")
           @Path(value="default-optional-client-scopes")
          public Stream<ClientScopeRepresentation> getDefaultOptionalClientScopes()

      Get realm optional client scopes. Only name and ids are returned.
      Returns:

    - #### addDefaultOptionalClientScope

          @PUT
           @Path(value="default-optional-client-scopes/{clientScopeId}")
          public void addDefaultOptionalClientScope(@PathParam(value="clientScopeId")
                                                                                                                        String clientScopeId)

    - #### removeDefaultOptionalClientScope

          @DELETE
           @Path(value="default-optional-client-scopes/{clientScopeId}")
          public void removeDefaultOptionalClientScope(@PathParam(value="clientScopeId")
                                                                                                                              String clientScopeId)

    - #### getClientInitialAccess

          @Path(value="clients-initial-access")
          public ClientInitialAccessResource getClientInitialAccess()

      Base path for managing client initial access tokens
      Returns:

    - #### getClientRegistrationPolicy

          @Path(value="client-registration-policy")
          public ClientRegistrationPolicyResource getClientRegistrationPolicy()

    - #### getComponents

          @Path(value="components")
          public ComponentResource getComponents()

      Base path for managing components under this realm.
      Returns:

    - #### getRoleContainerResource

          @Path(value="roles")
          public RoleContainerResource getRoleContainerResource()

      base path for managing realm-level roles of this realm
      Returns:

    - #### getRealm

          @GET
           @Produces(value="application/json")
          public RealmRepresentation getRealm()

      Get the top-level representation of the realm It will not include nested information like User and Client representations.
      Returns:

    - #### updateRealm

          @PUT
           @Consumes(value="application/json")
          public javax.ws.rs.core.Response updateRealm(RealmRepresentation rep)

      Update the top-level information of the realm Any user, roles or client information in the representation will be ignored. This will only update top-level attributes of the realm.
      Parameters:
        `rep` -
      Returns:

    - #### deleteRealm

          @DELETE
          public void deleteRealm()

      Delete the realm

    - #### users

          @Path(value="users")
          public UsersResource users()

      Base path for managing users in this realm.
      Returns:

    - #### getUserMgmtPermissions

          @GET
           @Produces(value="application/json")
           @Path(value="users-management-permissions")
          public ManagementPermissionReference getUserMgmtPermissions()

    - #### setUsersManagementPermissionsEnabled

          @PUT
           @Produces(value="application/json")
           @Consumes(value="application/json")
           @Path(value="users-management-permissions")
          public ManagementPermissionReference setUsersManagementPermissionsEnabled(ManagementPermissionReference ref)

    - #### toUsersMgmtRef

          public static ManagementPermissionReference toUsersMgmtRef(AdminPermissionManagement permissions)

    - #### userStorage

          @Path(value="user-storage")
          public UserStorageProviderResource userStorage()

    - #### flows

          @Path(value="authentication")
          public AuthenticationManagementResource flows()

    - #### rolesById

          @Path(value="roles-by-id")
          public RoleByIdResource rolesById()

      Path for managing all realm-level or client-level roles defined in this realm by its id.
      Returns:

    - #### pushRevocation

          @Path(value="push-revocation")
           @POST
          public GlobalRequestResult pushRevocation()

      Push the realm's revocation policy to any client that has an admin url associated with it.

    - #### logoutAll

          @Path(value="logout-all")
           @POST
          public GlobalRequestResult logoutAll()

      Removes all user sessions. Any client that has an admin url will also be told to invalidate any sessions they have.

    - #### deleteSession

          @Path(value="sessions/{session}")
           @DELETE
          public void deleteSession(@PathParam(value="session")
                                                                               String sessionId)

      Remove a specific user session. Any client that has an admin url will also be told to invalidate this particular session.
      Parameters:
        `sessionId` -

    - #### getClientSessionStats

          @Path(value="client-session-stats")
           @GET
           @Produces(value="application/json")
          public Stream<Map<String,String>> getClientSessionStats()

      Get client session stats Returns a JSON map. The key is the client id, the value is the number of sessions that currently are active with that client. Only clients that actually have a session associated with them will be in this map.
      Returns:

    - #### getRealmEventsConfig

          @GET
           @Path(value="events/config")
           @Produces(value="application/json")
          public RealmEventsConfigRepresentation getRealmEventsConfig()

      Get the events provider configuration Returns JSON object with events provider configuration
      Returns:

    - #### updateRealmEventsConfig

          @PUT
           @Path(value="events/config")
           @Consumes(value="application/json")
          public void updateRealmEventsConfig(RealmEventsConfigRepresentation rep)

      Update the events provider Change the events provider and/or its configuration
      Parameters:
        `rep` -

    - #### getEvents

          @Path(value="events")
           @GET
           @Produces(value="application/json")
          public Stream<EventRepresentation> getEvents(@QueryParam(value="type")
                                                                                                                        List<String> types,
                                                                                                                        @QueryParam(value="client")
                                                                                                                        String client,
                                                                                                                        @QueryParam(value="user")
                                                                                                                        String user,
                                                                                                                        @QueryParam(value="dateFrom")
                                                                                                                        String dateFrom,
                                                                                                                        @QueryParam(value="dateTo")
                                                                                                                        String dateTo,
                                                                                                                        @QueryParam(value="ipAddress")
                                                                                                                        String ipAddress,
                                                                                                                        @QueryParam(value="first")
                                                                                                                        Integer firstResult,
                                                                                                                        @QueryParam(value="max")
                                                                                                                        Integer maxResults)

      Get events Returns all events, or filters them based on URL query parameters listed here
      Parameters:
        `types` - The types of events to return
        `client` - App or oauth client name
        `user` - User id
        `ipAddress` - IP address
        `dateTo` - To date
        `dateFrom` - From date
        `firstResult` - Paging offset
        `maxResults` - Maximum results size (defaults to 100)
      Returns:

    - #### getEvents

          @Path(value="admin-events")
           @GET
           @Produces(value="application/json")
          public Stream<AdminEventRepresentation> getEvents(@QueryParam(value="operationTypes")
                                                                                                                                   List<String> operationTypes,
                                                                                                                                   @QueryParam(value="authRealm")
                                                                                                                                   String authRealm,
                                                                                                                                   @QueryParam(value="authClient")
                                                                                                                                   String authClient,
                                                                                                                                   @QueryParam(value="authUser")
                                                                                                                                   String authUser,
                                                                                                                                   @QueryParam(value="authIpAddress")
                                                                                                                                   String authIpAddress,
                                                                                                                                   @QueryParam(value="resourcePath")
                                                                                                                                   String resourcePath,
                                                                                                                                   @QueryParam(value="dateFrom")
                                                                                                                                   String dateFrom,
                                                                                                                                   @QueryParam(value="dateTo")
                                                                                                                                   String dateTo,
                                                                                                                                   @QueryParam(value="first")
                                                                                                                                   Integer firstResult,
                                                                                                                                   @QueryParam(value="max")
                                                                                                                                   Integer maxResults,
                                                                                                                                   @QueryParam(value="resourceTypes")
                                                                                                                                   List<String> resourceTypes)

      Get admin events Returns all admin events, or filters events based on URL query parameters listed here
      Parameters:
        `operationTypes` -
        `authRealm` -
        `authClient` -
        `authUser` - user id
        `authIpAddress` -
        `resourcePath` -
        `dateTo` -
        `dateFrom` -
        `firstResult` -
        `maxResults` - Maximum results size (defaults to 100)
      Returns:

    - #### clearEvents

          @Path(value="events")
           @DELETE
          public void clearEvents()

      Delete all events

    - #### clearAdminEvents

          @Path(value="admin-events")
           @DELETE
          public void clearAdminEvents()

      Delete all admin events

    - #### testLDAPConnection

          @Path(value="testLDAPConnection")
           @POST
           @Consumes(value="application/x-www-form-urlencoded")
           @Deprecated
          public javax.ws.rs.core.Response testLDAPConnection(@FormParam(value="action")
                                                                                                                                                                          String action,
                                                                                                                                                                          @FormParam(value="connectionUrl")
                                                                                                                                                                          String connectionUrl,
                                                                                                                                                                          @FormParam(value="bindDn")
                                                                                                                                                                          String bindDn,
                                                                                                                                                                          @FormParam(value="bindCredential")
                                                                                                                                                                          String bindCredential,
                                                                                                                                                                          @FormParam(value="useTruststoreSpi")
                                                                                                                                                                          String useTruststoreSpi,
                                                                                                                                                                          @FormParam(value="connectionTimeout")
                                                                                                                                                                          String connectionTimeout,
                                                                                                                                                                          @FormParam(value="componentId")
                                                                                                                                                                          String componentId,
                                                                                                                                                                          @FormParam(value="startTls")
                                                                                                                                                                          String startTls)

      Deprecated.
      Test LDAP connection
      Parameters:
        `action` -
        `connectionUrl` -
        `bindDn` -
        `bindCredential` -
      Returns:

    - #### testLDAPConnection

          @Path(value="testLDAPConnection")
           @POST
           @Consumes(value="application/json")
          public javax.ws.rs.core.Response testLDAPConnection(TestLdapConnectionRepresentation config)

      Test LDAP connection
      Returns:

    - #### ldapServerCapabilities

          @POST
           @Path(value="ldap-server-capabilities")
           @Consumes(value="application/json")
           @Produces(value="application/json")
          public javax.ws.rs.core.Response ldapServerCapabilities(TestLdapConnectionRepresentation config)

      Get LDAP supported extensions.
      Parameters:
        `config` - LDAP configuration
      Returns:

    - #### testSMTPConnection

          @Path(value="testSMTPConnection")
           @POST
           @Consumes(value="application/x-www-form-urlencoded")
           @Deprecated
          public javax.ws.rs.core.Response testSMTPConnection(@FormParam(value="config")
                                                                                                                                                                          String config)
                                                                                                                                                                   throws Exception

      Deprecated.
      Test SMTP connection with current logged in user
      Parameters:
        `config` - SMTP server configuration
      Returns:
      Throws:
        `Exception`

    - #### testSMTPConnection

          @Path(value="testSMTPConnection")
           @POST
           @Consumes(value="application/json")
          public javax.ws.rs.core.Response testSMTPConnection(Map<String,String> settings)
                                                                                                                                     throws Exception

      Throws:
        `Exception`

    - #### getIdentityProviderResource

          @Path(value="identity-provider")
          public IdentityProvidersResource getIdentityProviderResource()

    - #### getDefaultGroups

          @GET
           @Produces(value="application/json")
           @Path(value="default-groups")
          public Stream<GroupRepresentation> getDefaultGroups()

      Get group hierarchy. Only name and ids are returned.
      Returns:

    - #### addDefaultGroup

          @PUT
           @Path(value="default-groups/{groupId}")
          public void addDefaultGroup(@PathParam(value="groupId")
                                                                                    String groupId)

    - #### removeDefaultGroup

          @DELETE
           @Path(value="default-groups/{groupId}")
          public void removeDefaultGroup(@PathParam(value="groupId")
                                                                                          String groupId)

    - #### getGroups

          @Path(value="groups")
          public GroupsResource getGroups()

    - #### getGroupByPath

          @GET
           @Path(value="group-by-path/{path: .*}")
           @Produces(value="application/json")
          public GroupRepresentation getGroupByPath(@PathParam(value="path")
                                                                                                                                       String path)

    - #### partialImport

          @Path(value="partialImport")
           @POST
           @Consumes(value="application/json")
          public javax.ws.rs.core.Response partialImport(PartialImportRepresentation rep)

      Partial import from a JSON file to an existing realm.
      Parameters:
        `rep` -
      Returns:

    - #### partialExport

          @Path(value="partial-export")
           @POST
           @Produces(value="application/json")
          public RealmRepresentation partialExport(@QueryParam(value="exportGroupsAndRoles")
                                                                                                                             Boolean exportGroupsAndRoles,
                                                                                                                             @QueryParam(value="exportClients")
                                                                                                                             Boolean exportClients)

      Partial export of existing realm into a JSON file.
      Parameters:
        `exportGroupsAndRoles` -
        `exportClients` -
      Returns:

    - #### clearRealmCache

          @Path(value="clear-realm-cache")
           @POST
          public void clearRealmCache()

      Clear realm cache

    - #### clearUserCache

          @Path(value="clear-user-cache")
           @POST
          public void clearUserCache()

      Clear user cache

    - #### clearKeysCache

          @Path(value="clear-keys-cache")
           @POST
          public void clearKeysCache()

      Clear cache of external public keys (Public keys of clients or Identity providers)

    - #### keys

          @Path(value="keys")
          public KeyResource keys()

    - #### getCredentialRegistrators

          @GET
           @Path(value="credential-registrators")
           @Produces(value="application/json")
          public Stream<String> getCredentialRegistrators()

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