72 lines
2.1 KiB
Java
72 lines
2.1 KiB
Java
package org.gcube.common.authorizationservice.cl;
|
|
|
|
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
import org.junit.Test;
|
|
public class CallTest {
|
|
|
|
|
|
@Test
|
|
public void call() throws Exception{
|
|
try{
|
|
//devsec cec80de1-0e1a-47be-81cd-e8534753bff7
|
|
System.out.println(authorizationService().get("870f409b-df3c-4c12-8063-6f9b0f414751"));
|
|
}catch(ObjectNotFound onf){
|
|
onf.printStackTrace();
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void requestToken() throws Exception {
|
|
|
|
//ScopeProvider.instance.set("/gcube/devsec");
|
|
String token = authorizationService().generate("lucio.lelii", "/gcube", new ArrayList<String>());
|
|
System.out.println("token is: "+token);
|
|
|
|
}
|
|
/*
|
|
@Test
|
|
public void denyService() throws Exception {
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
|
authorizationService().deny("giancarlo.panichi", "WPS", "DataMiner");
|
|
|
|
}
|
|
|
|
@Test
|
|
public void allowService() throws Exception{
|
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
|
authorizationService().allow("lucio.lelii", "Test", "AuthorizationTest");
|
|
|
|
}
|
|
|
|
@Test
|
|
public void getBannedServices() throws Exception{
|
|
|
|
ScopeProvider.instance.set("/gcube/devsec");
|
|
List<BannedService> bannedServices = authorizationService().getBannedServices("lucio.lelii");
|
|
for (BannedService banService : bannedServices)
|
|
System.out.println(banService);
|
|
|
|
}
|
|
|
|
@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()));
|
|
}
|
|
}
|
|
*/
|
|
}
|