org.keycloak.services.resources.admin

## Class ApplicationResource

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

-     public class ApplicationResource
      extends Object

  Base resource class for managing one particular application of a realm.
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ApplicationModel` | `application`
    `protected KeycloakApplication` | `keycloak`
    `protected static org.jboss.logging.Logger` | `logger`
    `protected RealmModel` | `realm`
    `protected KeycloakSession` | `session`
    `protected javax.ws.rs.core.UriInfo` | `uriInfo`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ApplicationResource(RealmModel realm, RealmAuth auth, ApplicationModel applicationModel, KeycloakSession session)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `deleteAllowedOrigins(Set<String> allowedOrigins)` Remove set of allowed origins from current allowed origins list.
    `void` | `deleteApplication()` Delete this application.
    `Set<String>` | `getAllowedOrigins()` Returns set of allowed origin.
    `ApplicationRepresentation` | `getApplication()` Get representation of the application.
    `Map<String,Integer>` | `getApplicationSessionCount()` Number of user sessions associated with this application { "count": number }
    `ClaimResource` | `getClaimResource()` base path for managing allowed application claims
    `CredentialRepresentation` | `getClientSecret()` Get the secret of this application
    `String` | `getInstallation()` Return keycloak.json file for this application to be used to configure the adapter of that application.
    `String` | `getJBossInstallation()` Return XML that can be included in the JBoss/Wildfly Keycloak subsystem to configure the adapter of that application.
    `protected KeycloakApplication` | `getKeycloakApplication()`
    `RoleContainerResource` | `getRoleContainerResource()`
    `ScopeMappedResource` | `getScopeMappedResource()` Base path for managing the scope mappings for this application
    `SessionStats` | `getSessionStats(boolean users)` If the application has an admin URL, query it directly for session stats.
    `List<UserSessionRepresentation>` | `getUserSessions(Integer firstResult, Integer maxResults)` Return a list of user sessions associated with this application
    `void` | `logout(String username)` If the application has an admin URL, invalidate the sessions for a particular user directly.
    `void` | `logoutAll()` If the application has an admin URL, invalidate all sessions associated with that application directly.
    `void` | `pushRevocation()` If the application has an admin URL, push the application's revocation policy to it.
    `CredentialRepresentation` | `regenerateSecret()` Generates a new secret for this application
    `javax.ws.rs.core.Response` | `update(ApplicationRepresentation rep)` Update the application.
    `void` | `updateAllowedOrigins(Set<String> allowedOrigins)` Change the set of allowed origins.

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

    - #### realm

          protected RealmModel realm

    - #### application

          protected ApplicationModel application

    - #### session

          protected KeycloakSession session

    - #### uriInfo

          @Context
          protected javax.ws.rs.core.UriInfo uriInfo

    - #### keycloak

          @Context
          protected KeycloakApplication keycloak

  - ### Constructor Detail

    - #### ApplicationResource

          public ApplicationResource(RealmModel realm,
                             RealmAuth auth,
                             ApplicationModel applicationModel,
                             KeycloakSession session)

  - ### Method Detail

    - #### getKeycloakApplication

          protected KeycloakApplication getKeycloakApplication()

    - #### getClaimResource

          @Path(value="claims")
          public ClaimResource getClaimResource()

      base path for managing allowed application claims
      Returns:

    - #### update

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

      Update the application.
      Parameters:
        `rep` -
      Returns:

    - #### getApplication

          @GET
          @Produces(value="application/json")
          public ApplicationRepresentation getApplication()

      Get representation of the application.
      Returns:

    - #### getInstallation

          @GET
          @Path(value="installation/json")
          @Produces(value="application/json")
          public String getInstallation()
                                 throws IOException

      Return keycloak.json file for this application to be used to configure the adapter of that application.
      Returns:
      Throws:
        `IOException`

    - #### getJBossInstallation

          @GET
          @Path(value="installation/jboss")
          @Produces(value="text/plain")
          public String getJBossInstallation()
                                      throws IOException

      Return XML that can be included in the JBoss/Wildfly Keycloak subsystem to configure the adapter of that application.
      Returns:
      Throws:
        `IOException`

    - #### deleteApplication

          @DELETE
          public void deleteApplication()

      Delete this application.

    - #### regenerateSecret

          @Path(value="client-secret")
          @POST
          @Produces(value="application/json")
          @Consumes(value="application/json")
          public CredentialRepresentation regenerateSecret()

      Generates a new secret for this application
      Returns:

    - #### getClientSecret

          @Path(value="client-secret")
          @GET
          @Produces(value="application/json")
          public CredentialRepresentation getClientSecret()

      Get the secret of this application
      Returns:

    - #### getScopeMappedResource

          @Path(value="scope-mappings")
          public ScopeMappedResource getScopeMappedResource()

      Base path for managing the scope mappings for this application
      Returns:

    - #### getRoleContainerResource

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

    - #### getAllowedOrigins

          @Path(value="allowed-origins")
          @GET
          @Produces(value="application/json")
          public Set<String> getAllowedOrigins()

      Returns set of allowed origin. This is used for CORS requests. Access tokens will have their allowedOrigins claim set to this value for tokens created for this application.
      Returns:

    - #### updateAllowedOrigins

          @Path(value="allowed-origins")
          @PUT
          @Consumes(value="application/json")
          public void updateAllowedOrigins(Set<String> allowedOrigins)

      Change the set of allowed origins. This is used for CORS requests. Access tokens will have their allowedOrigins claim set to this value for tokens created for this application.
      Parameters:
        `allowedOrigins` -

    - #### deleteAllowedOrigins

          @Path(value="allowed-origins")
          @DELETE
          @Consumes(value="application/json")
          public void deleteAllowedOrigins(Set<String> allowedOrigins)

      Remove set of allowed origins from current allowed origins list. This is used for CORS requests. Access tokens will have their allowedOrigins claim set to this value for tokens created for this application.
      Parameters:
        `allowedOrigins` -

    - #### pushRevocation

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

      If the application has an admin URL, push the application's revocation policy to it.

    - #### getSessionStats

          @Path(value="session-stats")
          @GET
          @Produces(value="application/json")
          public SessionStats getSessionStats(@QueryParam(value="users")@DefaultValue(value="false")
                                                       boolean users)

      If the application has an admin URL, query it directly for session stats.
      Parameters:
        `users` - whether to include users logged in.
      Returns:

    - #### getApplicationSessionCount

          @Path(value="session-count")
          @GET
          @Produces(value="application/json")
          public Map<String,Integer> getApplicationSessionCount()

      Number of user sessions associated with this application { "count": number }
      Returns:

    - #### getUserSessions

          @Path(value="user-sessions")
          @GET
          @Produces(value="application/json")
          public List<UserSessionRepresentation> getUserSessions(@QueryParam(value="first")
                                                                          Integer firstResult,
                                                                          @QueryParam(value="max")
                                                                          Integer maxResults)

      Return a list of user sessions associated with this application
      Returns:

    - #### logoutAll

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

      If the application has an admin URL, invalidate all sessions associated with that application directly.

    - #### logout

          @Path(value="logout-user/{username}")
          @POST
          public void logout(@PathParam(value="username")
                              String username)

      If the application has an admin URL, invalidate the sessions for a particular user directly.

Copyright © 2014. All Rights Reserved.