org.keycloak.services.clientpolicy

## Class DefaultClientPolicyManager

- java.lang.Object
- - org.keycloak.services.clientpolicy.DefaultClientPolicyManager

- All Implemented Interfaces:
    ClientPolicyManager

      public class DefaultClientPolicyManager
      extends Object
      implements ClientPolicyManager

  Author:
    Takashi Norimatsu

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CLIENT_POLICIES`
    `static String` | `CLIENT_PROFILES`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultClientPolicyManager(KeycloakSession session)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getClientPolicies(RealmModel realm)` when getting client policies via Admin REST API, returns the existing client policies set on the realm.
    `String` | `getClientPoliciesJsonString(RealmModel realm)` returns the json representation of the client policies set on the realm.
    `String` | `getClientPoliciesOnKeycloakApp()` returns the json representation of the builtin client policies set on keycloak application.
    `String` | `getClientProfiles(RealmModel realm)` when getting client profiles via Admin REST API, returns the existing client profiles set on the realm.
    `String` | `getClientProfilesJsonString(RealmModel realm)` returns the json representation of the client profiles set on the realm.
    `String` | `getClientProfilesOnKeycloakApp()` returns the json representation of the builtin client profiles set on keycloak application.
    `void` | `setupClientPoliciesOnCreatedRealm(RealmModel realm)` when creating a realm, reads the builtin client profiles and policies that have already been set on keycloak application on booting keycloak and put them onto the realm as its attribute.
    `void` | `setupClientPoliciesOnExportingRealm(RealmModel realm, RealmRepresentation rep)` when exporting realm the realm, prepares the exported representation of the client profiles and policies.
    `void` | `setupClientPoliciesOnImportedRealm(RealmModel realm, RealmRepresentation rep)` when importing a realm, reads the builtin client profiles and policies that have already been set on keycloak application on booting keycloak and override them with ones loaded from the imported realm json file.
    `void` | `setupClientPoliciesOnKeycloakApp(String profilesFilePath, String policiesFilePath)` when booting keycloak, reads json representations of the builtin client profiles and policies from files enclosed in keycloak-services jar file and put them onto the keycloak application.
    `void` | `triggerOnEvent(ClientPolicyContext context)` execute a method for handling an event defined in `ClientPolicyEvent`.
    `void` | `updateClientPolicies(RealmModel realm, String json)` when updating client policies via Admin REST API, reads the json representation of the client policies and overrides the existing client policies set on the realm with them.
    `void` | `updateClientProfiles(RealmModel realm, String json)` when updating client profiles via Admin REST API, reads the json representation of the client profiles and overrides the existing client profiles set on the realm with them.

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

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

- - ### Field Detail

    - #### CLIENT_PROFILES

          public static final String CLIENT_PROFILES

      See Also:
        Constant Field Values

    - #### CLIENT_POLICIES

          public static final String CLIENT_POLICIES

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DefaultClientPolicyManager

          public DefaultClientPolicyManager(KeycloakSession session)

  - ### Method Detail

    - #### triggerOnEvent

          public void triggerOnEvent(ClientPolicyContext context)
                              throws ClientPolicyException

      Description copied from interface: `ClientPolicyManager`
      execute a method for handling an event defined in `ClientPolicyEvent`.
      Specified by:
        `triggerOnEvent` in interface `ClientPolicyManager`
      Parameters:
        `context` - - the context of the event.
      Throws:
        `ClientPolicyException`

    - #### setupClientPoliciesOnKeycloakApp

          public void setupClientPoliciesOnKeycloakApp(String profilesFilePath,
                                                       String policiesFilePath)

      Description copied from interface: `ClientPolicyManager`
      when booting keycloak, reads json representations of the builtin client profiles and policies from files enclosed in keycloak-services jar file and put them onto the keycloak application. if these operation fails, put null.
      Specified by:
        `setupClientPoliciesOnKeycloakApp` in interface `ClientPolicyManager`
      Parameters:
        `profilesFilePath` - - the file path for the builtin client profiles
        `policiesFilePath` - - the file path for the builtin client policies

    - #### setupClientPoliciesOnCreatedRealm

          public void setupClientPoliciesOnCreatedRealm(RealmModel realm)

      Description copied from interface: `ClientPolicyManager`
      when creating a realm, reads the builtin client profiles and policies that have already been set on keycloak application on booting keycloak and put them onto the realm as its attribute. if these operation fails, put null.
      Specified by:
        `setupClientPoliciesOnCreatedRealm` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the newly created realm

    - #### setupClientPoliciesOnImportedRealm

          public void setupClientPoliciesOnImportedRealm(RealmModel realm,
                                                         RealmRepresentation rep)

      Description copied from interface: `ClientPolicyManager`
      when importing a realm, reads the builtin client profiles and policies that have already been set on keycloak application on booting keycloak and override them with ones loaded from the imported realm json file. if these operation fails, rolls them back to the builtin client profiles and policies set on keycloak application.
      Specified by:
        `setupClientPoliciesOnImportedRealm` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the newly created realm to be overriden by imported realm's representation
        `rep` - - imported realm's representation

    - #### updateClientProfiles

          public void updateClientProfiles(RealmModel realm,
                                           String json)
                                    throws ClientPolicyException

      Description copied from interface: `ClientPolicyManager`
      when updating client profiles via Admin REST API, reads the json representation of the client profiles and overrides the existing client profiles set on the realm with them. if these operation fails, rolls them back to the existing client profiles and throw an exception.
      Specified by:
        `updateClientProfiles` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the realm whose client profiles is to be overriden by the new client profiles
        `json` - - the json representation of the new client profiles that overrides the existing client profiles set on the realm
      Throws:
        `ClientPolicyException`

    - #### getClientProfiles

          public String getClientProfiles(RealmModel realm)

      Description copied from interface: `ClientPolicyManager`
      when getting client profiles via Admin REST API, returns the existing client profiles set on the realm.
      Specified by:
        `getClientProfiles` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the realm whose client profiles is to be returned
      Returns:
        the json representation of the client profiles set on the realm

    - #### updateClientPolicies

          public void updateClientPolicies(RealmModel realm,
                                           String json)
                                    throws ClientPolicyException

      Description copied from interface: `ClientPolicyManager`
      when updating client policies via Admin REST API, reads the json representation of the client policies and overrides the existing client policies set on the realm with them. if these operation fails, rolls them back to the existing client policies and throw an exception.
      Specified by:
        `updateClientPolicies` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the realm whose client policies is to be overriden by the new client policies
        `json` - - the json representation of the new client policies that overrides the existing client policies set on the realm
      Throws:
        `ClientPolicyException`

    - #### setupClientPoliciesOnExportingRealm

          public void setupClientPoliciesOnExportingRealm(RealmModel realm,
                                                          RealmRepresentation rep)

      Description copied from interface: `ClientPolicyManager`
      when exporting realm the realm, prepares the exported representation of the client profiles and policies. E.g. the builtin client profiles and policies are filtered out and not exported.
      Specified by:
        `setupClientPoliciesOnExportingRealm` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the realm to be exported
        `rep` - - the realm's representation to be exported actually

    - #### getClientPolicies

          public String getClientPolicies(RealmModel realm)

      Description copied from interface: `ClientPolicyManager`
      when getting client policies via Admin REST API, returns the existing client policies set on the realm.
      Specified by:
        `getClientPolicies` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the realm whose client policies is to be returned
      Returns:
        the json representation of the client policies set on the realm

    - #### getClientProfilesOnKeycloakApp

          public String getClientProfilesOnKeycloakApp()

      Description copied from interface: `ClientPolicyManager`
      returns the json representation of the builtin client profiles set on keycloak application.
      Specified by:
        `getClientProfilesOnKeycloakApp` in interface `ClientPolicyManager`
      Returns:
        the json representation of the builtin client profiles set on keycloak application

    - #### getClientPoliciesOnKeycloakApp

          public String getClientPoliciesOnKeycloakApp()

      Description copied from interface: `ClientPolicyManager`
      returns the json representation of the builtin client policies set on keycloak application.
      Specified by:
        `getClientPoliciesOnKeycloakApp` in interface `ClientPolicyManager`
      Returns:
        the json representation of the builtin client policies set on keycloak application

    - #### getClientProfilesJsonString

          public String getClientProfilesJsonString(RealmModel realm)

      Description copied from interface: `ClientPolicyManager`
      returns the json representation of the client profiles set on the realm.
      Specified by:
        `getClientProfilesJsonString` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the realm whose client profiles is to be returned
      Returns:
        the json representation of the client profiles set on the realm

    - #### getClientPoliciesJsonString

          public String getClientPoliciesJsonString(RealmModel realm)

      Description copied from interface: `ClientPolicyManager`
      returns the json representation of the client policies set on the realm.
      Specified by:
        `getClientPoliciesJsonString` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the realm whose client policies is to be returned
      Returns:
        the json representation of the client policies set on the realm

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