Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
userManagement
Commits
d6fc69c1
Commit
d6fc69c1
authored
1 year ago
by
shishir suman
Browse files
Options
Download
Patches
Plain Diff
changes for keycloak admin token method
parent
656e6c6a
uat
UAT_quick_fix_keycloak
UPHRH_8164_ErrorHandling
dev
dev_stable
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/tarento/upsmf/userManagement/utility/KeycloakTokenRetriever.java
+26
-1
.../upsmf/userManagement/utility/KeycloakTokenRetriever.java
with
26 additions
and
1 deletion
+26
-1
src/main/java/com/tarento/upsmf/userManagement/utility/KeycloakTokenRetriever.java
+
26
−
1
View file @
d6fc69c1
...
...
@@ -62,7 +62,7 @@ public class KeycloakTokenRetriever {
String
requestBody
=
"username="
+
ADMIN_USERNAME
+
"&password="
+
ADMIN_PASSWORD
+
"&grant_type=
password
"
+
"&grant_type=
client_credentials
"
+
"&client_id=admin-cli"
+
"&client_secret="
+
ADMIN_TOKEN_SECRET
;
logger
.
info
(
"Request body: {}"
,
requestBody
);
...
...
@@ -76,4 +76,29 @@ public class KeycloakTokenRetriever {
return
jsonNode
;
}
public
JsonNode
getAdminTokenRead
()
throws
IOException
{
String
tokenEndpoint
=
ADMIN_TOKEN_ENDPOINT
;
logger
.
info
(
"Token endpoint: {}"
,
tokenEndpoint
);
HttpClient
httpClient
=
HttpClients
.
createDefault
();
HttpPost
httpPost
=
new
HttpPost
(
tokenEndpoint
);
httpPost
.
setHeader
(
HttpHeaders
.
CONTENT_TYPE
,
"application/x-www-form-urlencoded"
);
String
requestBody
=
"username="
+
ADMIN_USERNAME
+
"&password="
+
ADMIN_PASSWORD
+
"&grant_type=password"
+
"&client_id=admin-cli"
+
"&client_secret="
+
ADMIN_TOKEN_SECRET
;
logger
.
info
(
"Request body: {}"
,
requestBody
);
StringEntity
entity
=
new
StringEntity
(
requestBody
);
httpPost
.
setEntity
(
entity
);
org
.
apache
.
http
.
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
String
responseBody
=
EntityUtils
.
toString
(
response
.
getEntity
());
JsonNode
jsonNode
=
mapper
.
readTree
(
responseBody
);
return
jsonNode
;
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets