diff --git a/pom.xml b/pom.xml index 2603cb9..adbf992 100644 --- a/pom.xml +++ b/pom.xml @@ -45,14 +45,22 @@ org.gcube.common authorization-client + provided org.gcube.common common-authorization + provided org.gcube.common.portal portal-manager + provided + + + org.gcube.dvos + usermanagement-core + provided org.gcube.resources.discovery diff --git a/src/main/java/org/gcube/portal/auth/library/AuthUtil.java b/src/main/java/org/gcube/portal/auth/library/AuthUtil.java index 9de2cc5..2ac91fa 100644 --- a/src/main/java/org/gcube/portal/auth/library/AuthUtil.java +++ b/src/main/java/org/gcube/portal/auth/library/AuthUtil.java @@ -3,7 +3,6 @@ import static org.gcube.resources.discovery.icclient.ICFactory.clientFor; import static org.gcube.resources.discovery.icclient.ICFactory.queryFor; import java.io.UnsupportedEncodingException; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -14,10 +13,8 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; import org.gcube.common.resources.gcore.ServiceEndpoint.Property; import org.gcube.common.resources.gcore.utils.Group; 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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,12 +28,12 @@ import org.slf4j.LoggerFactory; */ public class AuthUtil { private static final Logger _log = LoggerFactory.getLogger(AuthUtil.class); - - final String REDIRECT_URL = "RedirectURL"; - final String SERVICE_ENDPOINT_CATEGORY = "OnlineService"; - final String LOGOURL_ATTR = "Logo"; - public List getPortalConfigurationFromIS(String infrastructureName, String clientId) + public final static String REDIRECT_URL = "RedirectURL"; + public final static String SERVICE_ENDPOINT_CATEGORY = "OnlineService"; + public final static String LOGOURL_ATTR = "Logo"; + + public static List getPortalConfigurationFromIS(String infrastructureName, String clientId) throws Exception { String scope = "/" + infrastructureName; String currScope = ScopeProvider.instance.get(); @@ -55,11 +52,11 @@ public class AuthUtil { * @param clientId * @return a RequestingApp contanining the application name, the description and the application logo URL if any, or null if non existent */ - private RequestingApp getAuthorisedApplicationInfoFromIs(String clientId) { + public static RequestingApp getAuthorisedApplicationInfoFromIs(String clientId) { RequestingApp toReturn = new RequestingApp(); String infraName = PortalContext.getConfiguration().getInfrastructureName(); System.out.println("infraName="+infraName); - + try { List list = getPortalConfigurationFromIS(infraName, clientId); if (list.size() > 1) { diff --git a/src/test/java/org/gcube/portal/auth/library/AppTest.java b/src/test/java/org/gcube/portal/auth/library/AppTest.java index 0ab5365..463db30 100644 --- a/src/test/java/org/gcube/portal/auth/library/AppTest.java +++ b/src/test/java/org/gcube/portal/auth/library/AppTest.java @@ -8,29 +8,33 @@ import junit.framework.TestSuite; * Unit test for simple App. */ public class AppTest extends TestCase { - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } + /** + * Rigourous Test :-) + */ + public void testApp() { + RequestingApp app = AuthUtil.getAuthorisedApplicationInfoFromIs("AnAppRequiringUserAuthN"); + if (app != null) { + System.out.println(app.getApplicationId()); + System.out.println(app.getLogoURL()); + } + //assertTrue( true ); + } }