Example #1
0
  /**
   * Get representation of the client
   *
   * @return
   */
  @GET
  @NoCache
  @Produces(MediaType.APPLICATION_JSON)
  public ClientRepresentation getClient() {
    auth.requireView();

    if (client == null) {
      throw new NotFoundException("Could not find client");
    }

    ClientRepresentation representation = ModelToRepresentation.toRepresentation(client);

    if (Profile.isFeatureEnabled(Profile.Feature.AUTHORIZATION)) {
      representation.setAuthorizationServicesEnabled(authorization().isEnabled());
    }

    return representation;
  }
Example #2
0
  public void updateClientFromRep(
      ClientRepresentation rep, ClientModel client, KeycloakSession session)
      throws ModelDuplicateException {
    if (TRUE.equals(rep.isServiceAccountsEnabled()) && !client.isServiceAccountsEnabled()) {
      new ClientManager(new RealmManager(session)).enableServiceAccount(client);
    }

    if (!rep.getClientId().equals(client.getClientId())) {
      new ClientManager(new RealmManager(session)).clientIdChanged(client, rep.getClientId());
    }

    RepresentationToModel.updateClient(rep, client);

    if (Profile.isFeatureEnabled(Profile.Feature.AUTHORIZATION)) {
      if (TRUE.equals(rep.getAuthorizationServicesEnabled())) {
        authorization().enable();
      } else {
        authorization().disable();
      }
    }
  }