git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/portal-auth-library@167852 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e54f61343c
commit
2249bb21cf
|
@ -1,5 +1,8 @@
|
|||
package org.gcube.portal.auth;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
|
@ -10,7 +13,11 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.LaxRedirectStrategy;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
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 com.liferay.portal.kernel.json.JSONObject;
|
||||
|
||||
|
@ -46,13 +53,15 @@ public class AppTest extends TestCase {
|
|||
public void testApp() {
|
||||
System.out.println("getAuthorisedRedirectURLsFromIs ... ");
|
||||
try {
|
||||
ServiceEndpoint authorisedApp = AuthUtil.getAuthorisedApplicationInfoFromIsICClient(PortalContext.getConfiguration().getInfrastructureName(), "c96d4477-236c-4f98-ba7d-7897991ef412");
|
||||
List<String> authorisedRedirectURLs = AuthUtil.getAuthorisedRedirectURLsFromIs(authorisedApp);
|
||||
|
||||
for (String red : authorisedRedirectURLs) {
|
||||
System.out.println(red);
|
||||
// ServiceEndpoint authorisedApp = AuthUtil.getAuthorisedApplicationInfoFromIsICClient(PortalContext.getConfiguration().getInfrastructureName(), "c96d4477-236c-4f98-ba7d-7897991ef412");
|
||||
// List<String> authorisedRedirectURLs = AuthUtil.getAuthorisedRedirectURLsFromIs(authorisedApp);
|
||||
//
|
||||
// for (String red : authorisedRedirectURLs) {
|
||||
System.out.println("");
|
||||
List<GCoreEndpoint> endpoints = getRStudioServiceEndpoints("/d4science.research-infrastructures.eu/D4Research/ICES_MSY");
|
||||
for (GCoreEndpoint gCoreEndpoint : endpoints) {
|
||||
System.out.println(gCoreEndpoint);
|
||||
}
|
||||
|
||||
String oauthendPoint = AuthUtil.getOAuthServiceEndPoint(PortalContext.getConfiguration().getInfrastructureName());
|
||||
System.out.println(oauthendPoint);
|
||||
} catch (Exception e) {
|
||||
|
@ -60,6 +69,24 @@ public class AppTest extends TestCase {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final String SERVICE_NAME = "RConnector";
|
||||
private static final String SERVICECLASS = "DataAnalysis";
|
||||
/**
|
||||
*
|
||||
* @return the
|
||||
* @throws Exception
|
||||
*/
|
||||
private List<GCoreEndpoint> getRStudioServiceEndpoints(String scope) throws Exception {
|
||||
String currScope = ScopeProvider.instance.get();
|
||||
ScopeProvider.instance.set(scope);
|
||||
SimpleQuery query = queryFor(GCoreEndpoint.class);
|
||||
query.addCondition("$resource/Profile/ServiceName/text() eq '"+ SERVICE_NAME +"'");
|
||||
query.addCondition("$resource/Profile/ServiceClass/text() eq '"+ SERVICECLASS +"'");
|
||||
DiscoveryClient<GCoreEndpoint> client = clientFor(GCoreEndpoint.class);
|
||||
List<GCoreEndpoint> toReturn = client.submit(query);
|
||||
ScopeProvider.instance.set(currScope);
|
||||
return toReturn;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue