org.keycloak.services.clientpolicy

## Class DefaultClientPolicyManager

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

- All Implemented Interfaces:
    Provider, ClientPolicyManager

      public class DefaultClientPolicyManager
      extends Object
      implements ClientPolicyManager

  Author:
    Takashi Norimatsu

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultClientPolicyManager(KeycloakSession session, Supplier<List<ClientProfileRepresentation>> globalClientProfilesSupplier)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `ClientPoliciesRepresentation` | `getClientPolicies(RealmModel realm)` when getting client policies via Admin REST API, returns the existing client policies set on the realm.
    `ClientProfilesRepresentation` | `getClientProfiles(RealmModel realm, boolean includeGlobalProfiles)` when getting client profiles via Admin REST API, returns the existing client profiles set on the realm.
    `void` | `setupClientPoliciesOnCreatedRealm(RealmModel realm)` when creating a realm, adds the default client policies, which should be available on the realm and put them onto the realm as its attribute.
    `void` | `triggerOnEvent(ClientPolicyContext context)` execute a method for handling an event defined in `ClientPolicyEvent`.
    `void` | `updateClientPolicies(RealmModel realm, ClientPoliciesRepresentation clientPolicies)` 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, ClientProfilesRepresentation clientProfiles)` 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.
    `void` | `updateRealmModelFromRepresentation(RealmModel realm, RealmRepresentation rep)` when importing a realm, or updating a realm, update model from the representation object
    `void` | `updateRealmRepresentationFromModel(RealmModel realm, RealmRepresentation rep)` when exporting realm, or retrieve the realm for admin REST API, prepares the exported representation of the client profiles and policies.

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

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

- - ### Constructor Detail

    - #### DefaultClientPolicyManager

          public DefaultClientPolicyManager(KeycloakSession session,
                                            Supplier<List<ClientProfileRepresentation>> globalClientProfilesSupplier)

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

    - #### setupClientPoliciesOnCreatedRealm

          public void setupClientPoliciesOnCreatedRealm(RealmModel realm)

      Description copied from interface: `ClientPolicyManager`
      when creating a realm, adds the default client policies, which should be available on the realm 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

    - #### updateRealmModelFromRepresentation

          public void updateRealmModelFromRepresentation(RealmModel realm,
                                                         RealmRepresentation rep)

      Description copied from interface: `ClientPolicyManager`
      when importing a realm, or updating a realm, update model from the representation object
      Specified by:
        `updateRealmModelFromRepresentation` 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,
                                           ClientProfilesRepresentation clientProfiles)
                                    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. If the "clientProfiles" parameter contains the global client profiles, they won't be updated on the realm at all
      Specified by:
        `updateClientProfiles` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the realm whose client profiles is to be overriden by the new client profiles
        `clientProfiles` - - the json representation of the new client profiles that overrides the existing client profiles set on the realm. With the exception of global profiles, which are not overriden as mentioned above.
      Throws:
        `ClientPolicyException`

    - #### getClientProfiles

          public ClientProfilesRepresentation getClientProfiles(RealmModel realm,
                                                                boolean includeGlobalProfiles)
                                                         throws ClientPolicyException

      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
        `includeGlobalProfiles` - - If true, method will return realm profiles and global profiles as well. If false, then "globalProfiles" field would be null
      Returns:
        the json representation of the client profiles set on the realm
      Throws:
        `ClientPolicyException`

    - #### updateClientPolicies

          public void updateClientPolicies(RealmModel realm,
                                           ClientPoliciesRepresentation clientPolicies)
                                    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
        `clientPolicies` - - the json representation of the new client policies that overrides the existing client policies set on the realm
      Throws:
        `ClientPolicyException`

    - #### getClientPolicies

          public ClientPoliciesRepresentation getClientPolicies(RealmModel realm)
                                                         throws ClientPolicyException

      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
      Throws:
        `ClientPolicyException`

    - #### updateRealmRepresentationFromModel

          public void updateRealmRepresentationFromModel(RealmModel realm,
                                                         RealmRepresentation rep)

      Description copied from interface: `ClientPolicyManager`
      when exporting realm, or retrieve the realm for admin REST API, prepares the exported representation of the client profiles and policies. Global client profiles and policies are filtered out and not exported.
      Specified by:
        `updateRealmRepresentationFromModel` in interface `ClientPolicyManager`
      Parameters:
        `realm` - - the realm to be exported
        `rep` - - the realm's representation to be exported actually

    - #### close

          public void close()

      Specified by:
        `close` in interface `Provider`

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