public static void invokeClientManagementRequest(KeycloakDeployment deployment, String host, String endpointUrl) throws HttpFailure, IOException { if (endpointUrl == null) { throw new IOException("You need to configure URI for register/unregister node for application " + deployment.getResourceName()); } List<NameValuePair> formparams = new ArrayList<NameValuePair>(); formparams.add(new BasicNameValuePair(AdapterConstants.CLIENT_CLUSTER_HOST, host)); HttpPost post = new HttpPost(endpointUrl); ClientCredentialsProviderUtils.setClientCredentials(deployment, post, formparams); UrlEncodedFormEntity form = new UrlEncodedFormEntity(formparams, "UTF-8"); post.setEntity(form); HttpResponse response = deployment.getClient().execute(post); int status = response.getStatusLine().getStatusCode(); if (status != 204) { HttpEntity entity = response.getEntity(); error(status, entity); } }
public static void invokeLogout(KeycloakDeployment deployment, String refreshToken) throws IOException, HttpFailure { HttpClient client = deployment.getClient(); URI uri = deployment.getLogoutUrl().clone().build(); List<NameValuePair> formparams = new ArrayList<>(); formparams.add(new BasicNameValuePair(OAuth2Constants.REFRESH_TOKEN, refreshToken)); HttpPost post = new HttpPost(uri); ClientCredentialsProviderUtils.setClientCredentials(deployment, post, formparams); UrlEncodedFormEntity form = new UrlEncodedFormEntity(formparams, "UTF-8"); post.setEntity(form); HttpResponse response = client.execute(post); int status = response.getStatusLine().getStatusCode(); HttpEntity entity = response.getEntity(); if (status != 204) { error(status, entity); } if (entity == null) { return; } InputStream is = entity.getContent(); if (is != null) is.close(); }
HttpEntity entity = response.getEntity(); if (status != 200) { error(status, entity);
HttpEntity entity = response.getEntity(); if (status != 200) { error(status, entity);
HttpEntity entity = response.getEntity(); if (status != 200) { error(status, entity);