コード例 #1
0
  /**
   * Base path for importing clients under this realm.
   *
   * @return
   */
  @Path("client-description-converter")
  @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
  @POST
  @Produces(MediaType.APPLICATION_JSON)
  public ClientRepresentation convertClientDescription(String description) {
    for (ProviderFactory<ClientDescriptionConverter> factory :
        session
            .getKeycloakSessionFactory()
            .getProviderFactories(ClientDescriptionConverter.class)) {
      if (((ClientDescriptionConverterFactory) factory).isSupported(description)) {
        return factory.create(session).convertToInternal(description);
      }
    }

    throw new BadRequestException("Unsupported format");
  }
コード例 #2
0
  /**
   * Base path for importing clients under this realm.
   *
   * @return
   */
  @Path("client-description-converter")
  @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN})
  @POST
  @Produces(MediaType.APPLICATION_JSON)
  public ClientRepresentation convertClientDescription(String description) {
    auth.init(Resource.CLIENT).requireManage();

    if (realm == null) {
      throw new NotFoundException("Realm not found.");
    }

    for (ProviderFactory<ClientDescriptionConverter> factory :
        session
            .getKeycloakSessionFactory()
            .getProviderFactories(ClientDescriptionConverter.class)) {
      if (((ClientDescriptionConverterFactory) factory).isSupported(description)) {
        return factory.create(session).convertToInternal(description);
      }
    }

    throw new BadRequestException("Unsupported format");
  }