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;
|
2016-01-22 17:28:17 +01:00
|
|
|
import org.gcube.common.authorization.library.provider.UserInfo;
|
2015-05-18 19:15:58 +02:00
|
|
|
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-12-22 19:38:51 +01:00
|
|
|
//devsec cec80de1-0e1a-47be-81cd-e8534753bff7
|
2016-01-22 17:28:17 +01:00
|
|
|
System.out.println(authorizationService().get("6d17f525-02de-4786-b454-d24150af7d49"));
|
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-12-22 19:38:51 +01:00
|
|
|
//ScopeProvider.instance.set("/gcube/devsec");
|
2016-01-22 17:28:17 +01:00
|
|
|
String token = authorizationService().generateToken(new UserInfo("lucio.lelii", new ArrayList<String>()), "/gcube/devsec");
|
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
|
|
|
}
|