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
94ad583d
Commit
94ad583d
authored
Jul 22, 2021
by
root
Browse files
Errors management
parent
02cd3c2f
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/tecnalia/DVPolicyEngine/api/GetAccessApiController.java
View file @
94ad583d
...
...
@@ -64,7 +64,7 @@ public class GetAccessApiController implements GetAccessApi {
/* 1.-GetDataSeekersOrganisationPolicy (DataSeekerID) -> de aqui obtenemos los atributos de la organización
llamada a keycloak y obtener los atributos
*/
*/
String
organizationAttributesAsString
=
policyService
.
getDataSeekersOrganizationPolicy
(
dataSeekerID
);
...
...
src/main/java/com/tecnalia/DVPolicyEngine/service/PolicyService.java
View file @
94ad583d
...
...
@@ -46,6 +46,14 @@ public class PolicyService {
//connect usign Keycloak credentials url to GetDataSeekersOrganizationPolicy -> result organization attributes
//Aqui habrá que mirar cómo conectarse a Keycloak, sin con clientId o clientSecret, com user, password???, habrá que cambiar este método por otro
/* cape.enforce.usage.url=https://www.cape-suite.eu/cape-service-sdk/api/v2/services/consents/enforceUsageRules
cape.auth.server.url=https://www.cape-suite.eu/auth/realms/Cape/protocol/openid-connect/token
cape.auth.client.id=ids-usage-control
cape.auth.client.secret=579246ac-1adf-4c89-b94d-7f3613b3467b
cape.auth.grant.type=client_credentials
*/
organizationAttributesAsString
=
httpUtils
.
sendHttpPostRequestWithOAuthClientCredentials
(
"url_adressAPI"
,
"authServerUrl"
,
"authClientId"
,
"authClientSecret"
,
"authGrantType"
);
...
...
@@ -87,12 +95,21 @@ public class PolicyService {
try
{
JSONObject
organizationAttributesJson
=
new
JSONObject
();
organizationAttributesJson
=
new
JSONObject
(
organizationAttributesAsString
);
try
{
organizationAttributesJson
=
new
JSONObject
(
organizationAttributesAsString
);
}
catch
(
Exception
e
){
System
.
out
.
println
(
"Error"
);
}
JSONObject
accessPolicyasJSON
=
new
JSONObject
();
accessPolicyasJSON
=
new
JSONObject
(
accessPolicyasString
);
try
{
accessPolicyasJSON
=
new
JSONObject
(
accessPolicyasString
);
}
catch
(
Exception
e
){
System
.
out
.
println
(
"Error"
);
}
//check if any value in policy is same of the organization, if everything is on policy return true in granted value and conformities string is empty
//if one of the value is not the same return false and construct non conformities string
...
...
src/main/java/com/tecnalia/DVPolicyEngine/utils/HttpUtils.java
View file @
94ad583d
...
...
@@ -269,7 +269,11 @@ public class HttpUtils {
authParams
.
put
(
"client_id"
,
authClientId
);
authParams
.
put
(
"client_secret"
,
authClientSecret
);
authParams
.
put
(
"grant_type"
,
authGrantType
);
String
accessTokenJsonStr
=
sendHttpPostRequestFormEncoded
(
authServerUrl
,
authParams
);
JSONObject
accessTokenJson
=
new
JSONObject
(
accessTokenJsonStr
);
String
accessToken
=
accessTokenJson
.
getString
(
"access_token"
);
...
...
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