Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FIT-Connect-SDK - Java
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIT-Connect
FIT-Connect-SDK - Java
Commits
892d828d
Commit
892d828d
authored
2 years ago
by
Martin Vogel
Browse files
Options
Downloads
Patches
Plain Diff
#414 Finalize vars and update named param
parent
80785696
No related branches found
No related tags found
2 merge requests
!2
#414 Remaining changes from MR
,
!1
planning#414 Methoden Signaturen (Zwischenstand)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/main/java/de/fitko/fitconnect/core/auth/DefaultOAuthService.java
+7
-7
7 additions, 7 deletions
...va/de/fitko/fitconnect/core/auth/DefaultOAuthService.java
with
7 additions
and
7 deletions
core/src/main/java/de/fitko/fitconnect/core/auth/DefaultOAuthService.java
+
7
−
7
View file @
892d828d
...
@@ -3,7 +3,7 @@ package de.fitko.fitconnect.core.auth;
...
@@ -3,7 +3,7 @@ package de.fitko.fitconnect.core.auth;
import
com.google.inject.Inject
;
import
com.google.inject.Inject
;
import
com.google.inject.name.Named
;
import
com.google.inject.name.Named
;
import
de.fitko.fitconnect.api.domain.auth.OAuthToken
;
import
de.fitko.fitconnect.api.domain.auth.OAuthToken
;
import
de.fitko.fitconnect.api.exceptions.
internal.
AuthenticationException
;
import
de.fitko.fitconnect.api.exceptions.AuthenticationException
;
import
de.fitko.fitconnect.api.services.auth.OAuthService
;
import
de.fitko.fitconnect.api.services.auth.OAuthService
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
...
@@ -25,26 +25,26 @@ public class DefaultOAuthService implements OAuthService {
...
@@ -25,26 +25,26 @@ public class DefaultOAuthService implements OAuthService {
private
final
String
tokenUrl
;
private
final
String
tokenUrl
;
@Inject
@Inject
public
DefaultOAuthService
(
final
RestTemplate
restTemplate
,
@Named
(
"authTokenUrl"
)
String
tokenUrl
)
{
public
DefaultOAuthService
(
final
RestTemplate
restTemplate
,
@Named
(
"
environment.
authTokenUrl"
)
final
String
tokenUrl
)
{
this
.
restTemplate
=
restTemplate
;
this
.
restTemplate
=
restTemplate
;
this
.
tokenUrl
=
tokenUrl
;
this
.
tokenUrl
=
tokenUrl
;
}
}
@Override
@Override
public
OAuthToken
authenticate
(
String
clientId
,
String
clientSecret
,
String
...
scope
)
throws
AuthenticationException
{
public
OAuthToken
authenticate
(
final
String
clientId
,
final
String
clientSecret
,
final
String
...
scope
)
throws
AuthenticationException
{
final
String
requestBody
=
buildRequestBody
(
clientId
,
clientSecret
,
scope
);
final
String
requestBody
=
buildRequestBody
(
clientId
,
clientSecret
,
scope
);
return
performTokenRequest
(
requestBody
);
return
performTokenRequest
(
requestBody
);
}
}
private
String
buildRequestBody
(
String
clientId
,
String
clientSecret
,
String
...
scope
)
{
private
String
buildRequestBody
(
final
String
clientId
,
final
String
clientSecret
,
final
String
...
scope
)
{
var
data
=
new
HashMap
<
String
,
String
>()
{{
final
var
data
=
new
HashMap
<
String
,
String
>()
{{
put
(
"grant_type"
,
"client_credentials"
);
put
(
"grant_type"
,
"client_credentials"
);
put
(
"client_id"
,
clientId
);
put
(
"client_id"
,
clientId
);
put
(
"client_secret"
,
clientSecret
);
put
(
"client_secret"
,
clientSecret
);
}};
}};
if
(
scope
.
length
>
0
){
if
(
scope
.
length
>
0
)
{
data
.
put
(
"scope"
,
String
.
join
(
","
,
scope
));
data
.
put
(
"scope"
,
String
.
join
(
","
,
scope
));
}
}
...
@@ -62,7 +62,7 @@ public class DefaultOAuthService implements OAuthService {
...
@@ -62,7 +62,7 @@ public class DefaultOAuthService implements OAuthService {
}
}
private
HttpHeaders
getHeaders
()
{
private
HttpHeaders
getHeaders
()
{
var
headers
=
new
HttpHeaders
();
final
var
headers
=
new
HttpHeaders
();
headers
.
setAccept
(
Collections
.
singletonList
(
MediaType
.
APPLICATION_JSON
));
headers
.
setAccept
(
Collections
.
singletonList
(
MediaType
.
APPLICATION_JSON
));
headers
.
setContentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
headers
.
setContentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
headers
.
setAcceptCharset
(
List
.
of
(
StandardCharsets
.
UTF_8
));
headers
.
setAcceptCharset
(
List
.
of
(
StandardCharsets
.
UTF_8
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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