Commit c65c7725 authored by Mahesh Maney R's avatar Mahesh Maney R
Browse files

adding logs while saving user to DB <ManeyMR>.

Showing with 4 additions and 1 deletion
+4 -1
......@@ -84,6 +84,7 @@ public class KeycloakUserCreator {
String password = ((ArrayNode)body.get("credentials")).get(0).get("value").asText();
responseBody = location;
try {
logger.info("syncing user {} with pwd {}",userName,password);
String strResponse = keycloakUserCredentialPersister.persistUserInfo(userName, password);
}catch (Exception ex){
ex.printStackTrace();
......
......@@ -43,7 +43,7 @@ public class KeycloakUserCredentialPersister {
return environment.getProperty(property);
}
public String persistUserInfo(final String userName, final String password) throws IOException {
logger.info("saving user info to endpoint {}",REGISTRYENDPOINTSAVEUSERINFO);
HttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(REGISTRYENDPOINTSAVEUSERINFO);
httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
......@@ -51,9 +51,11 @@ public class KeycloakUserCredentialPersister {
"\"username\": " + "\"" + userName + "\"" + "," +
"\"password\": " + "\"" + password + "\"" + "," +
"}";
logger.info("paayload to save user info {}",requestBody);
StringEntity entity = new StringEntity(requestBody);
httpPost.setEntity(entity);
org.apache.http.HttpResponse response = httpClient.execute(httpPost);
logger.info("Response from server {}",response);
String responseBody = EntityUtils.toString(response.getEntity());
return responseBody;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment