Esempio n. 1
0
  public static void profile() throws Exception {
    String accountUrl = keycloak.getDeployment().getAccountUrl();
    HttpGet get = new HttpGet(accountUrl);
    get.setHeader("Accept", "application/json");
    get.setHeader("Authorization", "Bearer " + keycloak.getTokenString(10, TimeUnit.SECONDS));

    HttpResponse response = keycloak.getDeployment().getClient().execute(get);
    if (response.getStatusLine().getStatusCode() == 200) {
      print(response.getEntity().getContent());
    } else {
      System.out.println(response.getStatusLine().toString());
    }
  }
Esempio n. 2
0
  public static void customers() throws Exception {
    String baseUrl = keycloak.getDeployment().getAuthServerBaseUrl();
    baseUrl = baseUrl.substring(0, baseUrl.indexOf('/', 8));

    String customersUrl = baseUrl + "/database/customers";
    HttpGet get = new HttpGet(customersUrl);
    get.setHeader("Accept", "application/json");
    get.setHeader("Authorization", "Bearer " + keycloak.getTokenString(10, TimeUnit.SECONDS));

    HttpResponse response = keycloak.getDeployment().getClient().execute(get);
    if (response.getStatusLine().getStatusCode() == 200) {
      print(response.getEntity().getContent());
    } else {
      System.out.println(response.getStatusLine().toString());
    }
  }