2015-05-18 19:15:58 +02:00
|
|
|
package org.gcube.common.authorizationservice.cl;
|
|
|
|
|
|
|
|
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
|
|
|
|
2015-11-27 18:06:28 +01:00
|
|
|
import java.util.ArrayList;
|
2015-05-29 18:32:43 +02:00
|
|
|
|
2015-07-30 17:33:48 +02:00
|
|
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
2015-05-18 19:15:58 +02:00
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
import org.junit.Test;
|
|
|
|
public class CallTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
2015-11-24 19:26:37 +01:00
|
|
|
public void call() throws Exception{
|
2015-07-30 17:33:48 +02:00
|
|
|
try{
|
2015-11-24 19:26:37 +01:00
|
|
|
System.out.println(authorizationService().get("a00affeb-0b75-4152-a134-e5c432a9a70a"));
|
2015-07-30 17:33:48 +02:00
|
|
|
}catch(ObjectNotFound onf){
|
|
|
|
onf.printStackTrace();
|
|
|
|
}
|
2015-05-18 19:15:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2015-11-24 19:26:37 +01:00
|
|
|
public void requestToken() throws Exception {
|
2015-05-18 19:15:58 +02:00
|
|
|
|
2015-11-24 19:26:37 +01:00
|
|
|
ScopeProvider.instance.set("/gcube");
|
2015-11-27 18:06:28 +01:00
|
|
|
String token = authorizationService().generate("fabio.sinibaldi", new ArrayList<String>());
|
2015-05-18 19:15:58 +02:00
|
|
|
System.out.println("token is: "+token);
|
|
|
|
|
|
|
|
}
|
2015-11-24 19:26:37 +01:00
|
|
|
/*
|
2015-06-04 18:49:59 +02:00
|
|
|
@Test
|
2015-11-24 19:26:37 +01:00
|
|
|
public void denyService() throws Exception {
|
2015-06-04 18:49:59 +02:00
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
2015-11-24 19:26:37 +01:00
|
|
|
authorizationService().deny("giancarlo.panichi", "WPS", "DataMiner");
|
2015-06-04 18:49:59 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2015-11-24 19:26:37 +01:00
|
|
|
public void allowService() throws Exception{
|
2015-06-04 18:49:59 +02:00
|
|
|
|
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
2015-11-24 19:26:37 +01:00
|
|
|
authorizationService().allow("lucio.lelii", "Test", "AuthorizationTest");
|
2015-06-04 18:49:59 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2015-11-24 19:26:37 +01:00
|
|
|
public void getBannedServices() throws Exception{
|
2015-06-04 18:49:59 +02:00
|
|
|
|
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
2015-11-24 19:26:37 +01:00
|
|
|
List<BannedService> bannedServices = authorizationService().getBannedServices("lucio.lelii");
|
2015-06-04 18:49:59 +02:00
|
|
|
for (BannedService banService : bannedServices)
|
2015-07-21 12:39:32 +02:00
|
|
|
System.out.println(banService);
|
2015-06-04 18:49:59 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-11-24 19:26:37 +01:00
|
|
|
@Test
|
|
|
|
public void retreiveTest() throws Exception{
|
|
|
|
ScopeProvider.instance.set("/gcube");
|
|
|
|
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
|
|
|
query.addCondition("$resource/Profile/Category/text() eq 'Database'")
|
|
|
|
.addCondition("$resource/Profile/Name/text() eq 'AuthorizationDB'")
|
|
|
|
.setResult("$resource/Profile//AccessPoint[./Interface/Endpoint/@EntryName eq 'authorization']");
|
|
|
|
DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
|
|
|
|
List<AccessPoint> results = client.submit(query);
|
|
|
|
for (AccessPoint ap : results){
|
|
|
|
System.out.println(ap.username()+" "+StringEncrypter.getEncrypter().decrypt(ap.password()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2015-05-18 19:15:58 +02:00
|
|
|
}
|