diff --git a/src/main/java/org/gcube/common/portal/GCubePortalConstants.java b/src/main/java/org/gcube/common/portal/GCubePortalConstants.java index 18f04f6..fa9fd97 100644 --- a/src/main/java/org/gcube/common/portal/GCubePortalConstants.java +++ b/src/main/java/org/gcube/common/portal/GCubePortalConstants.java @@ -15,6 +15,8 @@ public class GCubePortalConstants { public static final String INFRASTRUCTURE_NAME = "infrastructure"; public static final String SCOPES = "scopes"; + public static final String PORTAL_APPLICATION_TOKEN = "portalAuthToken"; + public static final String ICPROXY_ENDPOINT_URL = "ic-proxy-endpointURL"; public static final String SENDER_EMAIL = "notificationSenderEmail"; public static final String GATEWAY_NAME = "portalinstancename"; public static final String ADMIN_USERNAME = "administratorUsername"; diff --git a/src/main/java/org/gcube/common/portal/PortalContext.java b/src/main/java/org/gcube/common/portal/PortalContext.java index 044ab39..58eb8de 100644 --- a/src/main/java/org/gcube/common/portal/PortalContext.java +++ b/src/main/java/org/gcube/common/portal/PortalContext.java @@ -691,6 +691,59 @@ public class PortalContext { return toReturn; } + /** + *

+ * read the portal application token valid in the root Virtual Organisation into a property file + *

+ * @return the portal application token valid in the root Virtual Organisation or null if the token could not be found + */ + public static String getPortalApplicationToken() { + //get the portles to look for from the property file + Properties props = new Properties(); + String toReturn = ""; + + try { + String propertyfile = getCatalinaHome() + File.separator + "conf" + File.separator + "gcube-data.properties"; + File propsFile = new File(propertyfile); + FileInputStream fis = new FileInputStream(propsFile); + props.load( fis); + toReturn = props.getProperty(GCubePortalConstants.PORTAL_APPLICATION_TOKEN); + } + //catch exception in case properties file does not exist + catch(IOException e) { + toReturn = null; + _log.error("gcube-data.properties file or portal app token not found under $CATALINA_HOME/conf dir, please add the property and or a valid token: " + GCubePortalConstants.PORTAL_APPLICATION_TOKEN); + return toReturn; + } + return toReturn; + } + /** + *

+ * read the IC Proxy endpoint from a property file, IC Proxy is needed to query the Information System via REST + * e.g. http://dev.d4science.org:8080/icproxy/gcube/service + *

+ * @return the IC Proxy endpoint or null if the IC Proxy could not be found + */ + public static String getICProxyEndPoint() { + //get the portles to look for from the property file + Properties props = new Properties(); + String toReturn = ""; + + try { + String propertyfile = getCatalinaHome() + File.separator + "conf" + File.separator + "gcube-data.properties"; + File propsFile = new File(propertyfile); + FileInputStream fis = new FileInputStream(propsFile); + props.load( fis); + toReturn = props.getProperty(GCubePortalConstants.ICPROXY_ENDPOINT_URL); + } + //catch exception in case properties file does not exist + catch(IOException e) { + toReturn = null; + _log.error("gcube-data.properties file or portal app token not found under $CATALINA_HOME/conf dir, please add the property and or a valid token: " + GCubePortalConstants.PORTAL_APPLICATION_TOKEN); + return toReturn; + } + return toReturn; + } /** * read the sender (from) email address for notifications name from a property file and returns it @@ -865,6 +918,8 @@ public class PortalContext { } return -1L; } + + /**