Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Iturraspe Barturen, Urtza
PolicyEngine
Commits
41f5e216
Commit
41f5e216
authored
Sep 09, 2021
by
root
Browse files
Changes obtaining dataseeker information
parent
84bc2cfe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Docker_Tecnalia_PolicyEngine/policyengine/
swagger-spring-1.0.0
.jar
→
Docker_Tecnalia_PolicyEngine/policyengine/
policyengine
.jar
View file @
41f5e216
No preview for this file type
src/main/java/com/tecnalia/DVPolicyEngine/api/GetAccessApiController.java
View file @
41f5e216
...
...
@@ -69,6 +69,9 @@ public class GetAccessApiController implements GetAccessApi {
// organizationAttributesAsString="{\"name\":\"Test Organization\",\"sector\":\"Test Sector\",\"continent\":\"EU\",\"country\":\"GRE\",\"type\":\"Private Entity\",\"size\":\"medium\",\"reputation\":7}";
System
.
out
.
println
(
"organizationAttributesAsString:"
+
organizationAttributesAsString
);
/*"
...
...
src/main/java/com/tecnalia/DVPolicyEngine/service/PolicyService.java
View file @
41f5e216
...
...
@@ -49,8 +49,8 @@ public class PolicyService {
private
String
authGrantType
=
""
;
/* @Value("${datavaults.auth.username}")
private String authUsername = "";*/
@Value
(
"${datavaults.auth.password}"
)
private
String
authPassword
=
""
;
/*
@Value("${datavaults.auth.password}")
private String authPassword = "";
*/
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
PolicyService
.
class
);
...
...
@@ -76,7 +76,7 @@ public class PolicyService {
// organizationAttributesAsString =httpUtils.sendHttpPostRequestWithOAuth(datavaultsUrl,authServerUrl,authClientId,authClientSecret,authGrantType,authUsername,authPassword);
organizationAttributesAsString
=
httpUtils
.
sendHttpPostRequestWithOAuth
(
datavaultsUrl
,
authServerUrl
,
authClientId
,
authClientSecret
,
authGrantType
,
dataSeekerId
,
authPassword
);
organizationAttributesAsString
=
httpUtils
.
sendHttpPostRequestWithOAuth
(
datavaultsUrl
,
authServerUrl
,
authClientId
,
authClientSecret
,
authGrantType
,
dataSeekerId
);
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/tecnalia/DVPolicyEngine/utils/HttpUtils.java
View file @
41f5e216
...
...
@@ -264,7 +264,7 @@ public class HttpUtils {
public
String
sendHttpPostRequestWithOAuth
(
String
address
,
String
authServerUrl
,
String
authClientId
,
String
authClientSecret
,
String
authGrantType
,
String
username
,
String
password
)
throws
public
String
sendHttpPostRequestWithOAuth
(
String
address
,
String
authServerUrl
,
String
authClientId
,
String
authClientSecret
,
String
authGrantType
,
String
sDataseekerID
)
throws
RuntimeException
,
URISyntaxException
{
//Get access token from Auth. Server
...
...
@@ -272,8 +272,8 @@ public class HttpUtils {
authParams
.
put
(
"client_id"
,
authClientId
);
authParams
.
put
(
"client_secret"
,
authClientSecret
);
authParams
.
put
(
"grant_type"
,
authGrantType
);
authParams
.
put
(
"username"
,
username
);
authParams
.
put
(
"password"
,
password
);
/*
authParams.put("username", username);
authParams.put("password", password);
*/
...
...
@@ -288,16 +288,14 @@ public class HttpUtils {
OkHttpClient
client
=
new
OkHttpClient
();
try
{
HttpUrl
.
Builder
httpBuilder
=
HttpUrl
.
parse
(
address
).
newBuilder
();
/* if (params != null) {
for(Map.Entry<String, String> param : params.entrySet()) {
httpBuilder.addQueryParameter(param.getKey(),param.getValue());
}
}
RequestBody body = RequestBody.create(jsonData, MediaType.parse("application/json"));*/
String
jsonData
=
"{\"dataseekerID\":"
+
sDataseekerID
+
"}"
;
RequestBody
body
=
RequestBody
.
create
(
jsonData
,
MediaType
.
parse
(
"application/json"
));
Request
request
=
new
Request
.
Builder
()
.
url
(
httpBuilder
.
build
())
.
addHeader
(
"Authorization"
,
"Bearer "
+
accessToken
)
//
.post(body)
.
post
(
body
)
.
build
();
Response
response
=
client
.
newCall
(
request
).
execute
();
...
...
src/main/resources/application.properties
View file @
41f5e216
...
...
@@ -12,8 +12,12 @@ springdoc.swagger-ui.path=/swagger-ui.html
datavaults.api.url
=
https://platform.datavaults.eu/api/v1/group
datavaults.auth.server.url
=
https://datavaults-auth.euprojects.net/auth/realms/platform/protocol/openid-connect/token
datavaults.auth.client.id
=
backend-service
datavaults.auth.client.secret
=
04892d79-f600-4410-a9ac-6860aa5bdf3e
datavaults.auth.grant.type
=
password
#
datavaults.auth.client.id=backend-service
#
datavaults.auth.client.secret=04892d79-f600-4410-a9ac-6860aa5bdf3e
#
datavaults.auth.grant.type=password
#datavaults.auth.username=trainer
datavaults.auth.password
=
3
\ No newline at end of file
#datavaults.auth.password=3
datavaults.auth.grant.type
=
client_credentials
datavaults.auth.client.id
=
organizations_client
datavaults.auth.client.secret
=
45282a40-a18b-4981-8680-78950b6940d3
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment