Commit 94ad583d authored by root's avatar root
Browse files

Errors management

parent 02cd3c2f
......@@ -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);
......
......@@ -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
......
......@@ -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");
......
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