diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..e43402f
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..ea71595
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ authorization-common-client
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..29abf99
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,6 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
+encoding/=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..ec4300d
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/src/main/java/org/gcube/common/authorization/client/proxy/AuthorizationProxy.java b/src/main/java/org/gcube/common/authorization/client/proxy/AuthorizationProxy.java
index caa343f..51e7ebc 100644
--- a/src/main/java/org/gcube/common/authorization/client/proxy/AuthorizationProxy.java
+++ b/src/main/java/org/gcube/common/authorization/client/proxy/AuthorizationProxy.java
@@ -1,10 +1,15 @@
package org.gcube.common.authorization.client.proxy;
import org.gcube.common.authorization.library.AuthorizationEntry;
+import org.gcube.common.authorization.library.provider.Service;
public interface AuthorizationProxy {
String generate(String userName, String role);
AuthorizationEntry get(String token);
+
+ void deny(String userName, Service service);
+
+ void allow(String userName, Service service);
}
diff --git a/src/main/java/org/gcube/common/authorization/client/proxy/DefaultAuthorizationProxy.java b/src/main/java/org/gcube/common/authorization/client/proxy/DefaultAuthorizationProxy.java
index 49d9b38..ac47597 100644
--- a/src/main/java/org/gcube/common/authorization/client/proxy/DefaultAuthorizationProxy.java
+++ b/src/main/java/org/gcube/common/authorization/client/proxy/DefaultAuthorizationProxy.java
@@ -13,8 +13,10 @@ import java.util.Map;
import org.gcube.common.authorization.client.Binder;
import org.gcube.common.authorization.client.Constants;
import org.gcube.common.authorization.library.AuthorizationEntry;
+import org.gcube.common.authorization.library.provider.Service;
import org.gcube.common.clients.Call;
import org.gcube.common.clients.delegates.ProxyDelegate;
+import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty;
import org.gcube.common.scope.api.ScopeProvider;
public class DefaultAuthorizationProxy implements AuthorizationProxy {
@@ -47,6 +49,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
if (reader!=null)
reader.close();
}
+
return result.toString();
}
};
@@ -85,5 +88,45 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
throw again(e).asServiceException();
}
}
+
+ @Override
+ public void deny(final String userName, final Service service) {
+ Call call = new Call() {
+ @Override
+ public Empty call(String endpoint) throws Exception {
+ URL url = new URL(endpoint+"/deny/add/"+userName+"/"+service.getServiceClass()+"/"+service.getServiceName());
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setRequestMethod("GET");
+ return new Empty();
+ }
+ };
+
+ try {
+ delegate.make(call);
+ } catch (Exception e) {
+ throw again(e).asServiceException();
+ }
+ }
+
+ @Override
+ public void allow(final String userName, final Service service) {
+ Call call = new Call() {
+
+ @Override
+ public Empty call(String endpoint) throws Exception {
+ URL url = new URL(endpoint+"/deny/remove/"+userName+"/"+service.getServiceClass()+"/"+service.getServiceName());
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setRequestMethod("GET");
+ return new Empty();
+
+ }
+ };
+
+ try {
+ delegate.make(call);
+ } catch (Exception e) {
+ throw again(e).asServiceException();
+ }
+ }
}
diff --git a/src/test/java/org/gcube/common/authorizationservice/cl/CallTest.java b/src/test/java/org/gcube/common/authorizationservice/cl/CallTest.java
index d316ecd..4485730 100644
--- a/src/test/java/org/gcube/common/authorizationservice/cl/CallTest.java
+++ b/src/test/java/org/gcube/common/authorizationservice/cl/CallTest.java
@@ -2,24 +2,26 @@ package org.gcube.common.authorizationservice.cl;
import static org.gcube.common.authorization.client.Constants.authorizationService;
-import org.gcube.common.authorization.library.AuthorizationEntry;
-import org.gcube.common.scope.api.ScopeProvider;
-import org.junit.Test;
+import java.util.List;
+import org.gcube.common.resources.gcore.GenericResource;
+import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.resources.discovery.client.api.DiscoveryClient;
+import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
+import org.junit.Test;
+import static org.gcube.resources.discovery.icclient.ICFactory.*;
public class CallTest {
@Test
public void call(){
-
ScopeProvider.instance.set("/gcube/devsec");
- String token = authorizationService().build().generate("lucio.lelii", "God");
-
- System.out.println("token is "+token);
-
- AuthorizationEntry entry = authorizationService().build().get(token);
-
- System.out.println("entry is "+entry.toString());
+ SimpleQuery query = queryFor(GenericResource.class);
+ query.addCondition("$resource/Profile/SecondaryType eq 'StatisticalManagerAlgorithm' ");
+ DiscoveryClient client = clientFor(GenericResource.class);
+ List resources = client.submit(query);
+ for (GenericResource res : resources)
+ System.out.println(res);
}
@@ -27,7 +29,7 @@ public class CallTest {
public void requestToken(){
ScopeProvider.instance.set("/gcube/devsec");
- String token = authorizationService().build().generate("lucio.lelii", "God");
+ String token = authorizationService().build().generate("lucio.le", "User");
System.out.println("token is: "+token);
}