funzionante
This commit is contained in:
parent
f997057b83
commit
8127a3bf98
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"java.configuration.updateBuildConfiguration": "interactive"
|
||||
"java.configuration.updateBuildConfiguration": "automatic"
|
||||
}
|
29
pom.xml
29
pom.xml
|
@ -100,6 +100,35 @@
|
|||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-authorization</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package org.gcube.portlets.user.cloudcomputing;
|
||||
|
||||
public class CloudComputingConfig {
|
||||
public String encoded_context = "%2Fgcube%2Fdevsec%2FdevVRE";
|
||||
public String gateway = "next.dev.d4science.org";
|
||||
|
||||
public String redirect_url = "https://next.dev.d4science.org/group/devvre/cloudcomputing";
|
||||
public String encoded_context = ""; // "%2Fgcube%2Fdevsec%2FdevVRE";
|
||||
public String gateway = ""; // "next.dev.d4science.org";
|
||||
|
||||
public String auth_url = "https://accounts.dev.d4science.org/auth";
|
||||
public String ccp_url = "https://ccp.cloud-dev.d4science.org";
|
||||
// public String cdn_url = "https://cdn.cloud.d4science.org";
|
||||
// //"https://cdn.cloud-dev.d4science.org";
|
||||
public String cdn_url = "https://cdn.cloud-dev.d4science.org";
|
||||
public String redirect_url = ""; // "https://next.dev.d4science.org/group/devvre/cloudcomputing";
|
||||
|
||||
public String auth_url = ""; // "https://accounts.dev.d4science.org/auth";
|
||||
public String ccp_url = ""; // "https://ccp.cloud-dev.d4science.org";
|
||||
|
||||
public String cdn_url = ""; // "https://cdn.cloud-dev.d4science.org";
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.cloudcomputing;
|
|||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.rmi.ServerException;
|
||||
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.RenderRequest;
|
||||
|
@ -10,20 +11,31 @@ import javax.portlet.RenderResponse;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portlets.user.cloudcomputing.is.InfrastrctureServiceClient;
|
||||
import org.gcube.portlets.user.cloudcomputing.is.IsServerConfig;
|
||||
|
||||
import com.liferay.portal.kernel.exception.PortalException;
|
||||
import com.liferay.portal.kernel.exception.SystemException;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
import com.liferay.util.bridges.mvc.MVCPortlet;
|
||||
|
||||
public class CloudComputingConfigPortlet extends MVCPortlet {
|
||||
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil.getLog(CloudComputingConfigPortlet.class);
|
||||
|
||||
public CloudComputingConfig getConfig(RenderRequest renderRequest) throws MalformedURLException {
|
||||
private static CloudComputingConfig configuration = null;
|
||||
|
||||
public final static String IS_AUTH_RESOURCE_NAME = "IAM";
|
||||
public final static String IS_AUTH_CATEGORY = "Service";
|
||||
public final static String IS_AUTH_ENTRYPOINT = "d4science";
|
||||
|
||||
public final static String IS_CCP_RESOURCE_NAME = "CCP";
|
||||
public final static String IS_CCP_CATEGORY = "DataAnalysis";
|
||||
public final static String IS_CDN_ENTRYPOINT = "cdn_url";
|
||||
public final static String IS_CCP_ENTRYPOINT = "ccp_url";
|
||||
|
||||
public CloudComputingConfig getConfig(RenderRequest renderRequest)
|
||||
throws MalformedURLException, ServerException {
|
||||
if (configuration == null) {
|
||||
try {
|
||||
CloudComputingConfig config = new CloudComputingConfig();
|
||||
|
||||
String currentContext = getCurrentContext(renderRequest);
|
||||
|
@ -45,31 +57,53 @@ public class CloudComputingConfigPortlet extends MVCPortlet {
|
|||
URL base_url = new URL(PortalUtil.getAbsoluteURL(httpReq, "/"));
|
||||
String host = base_url.getHost();
|
||||
config.gateway = host;
|
||||
return config;
|
||||
|
||||
IsServerConfig auth_config = InfrastrctureServiceClient.serviceConfigFromIS(IS_AUTH_RESOURCE_NAME,
|
||||
IS_AUTH_CATEGORY, IS_AUTH_ENTRYPOINT);
|
||||
config.auth_url = auth_config.getServerUrl();
|
||||
|
||||
IsServerConfig ccp_config = InfrastrctureServiceClient.serviceConfigFromIS(IS_CCP_RESOURCE_NAME,
|
||||
IS_CCP_CATEGORY, IS_CCP_ENTRYPOINT);
|
||||
config.ccp_url = ccp_config.getServerUrl();
|
||||
|
||||
IsServerConfig cdn_config = InfrastrctureServiceClient.serviceConfigFromIS(IS_CCP_RESOURCE_NAME,
|
||||
IS_CCP_CATEGORY, IS_CDN_ENTRYPOINT);
|
||||
config.cdn_url = cdn_config.getServerUrl();
|
||||
|
||||
configuration = config;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
_log.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
|
||||
protected String getCurrentContext(RenderRequest request) {
|
||||
protected static String getCurrentContext(RenderRequest request) {
|
||||
long groupId = -1;
|
||||
try {
|
||||
groupId = PortalUtil.getScopeGroupId(request);
|
||||
return getCurrentContext(groupId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
_log.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getCurrentContext(long groupId) {
|
||||
protected static String getCurrentContext(long groupId) {
|
||||
try {
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
return pContext.getCurrentScope("" + groupId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
_log.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getEncodedContext(String context) {
|
||||
protected static String getEncodedContext(String context) {
|
||||
return context.replace("/", "%2F");
|
||||
}
|
||||
|
||||
|
@ -94,92 +128,9 @@ public class CloudComputingConfigPortlet extends MVCPortlet {
|
|||
renderRequest.setAttribute("ccp_url", config.ccp_url);
|
||||
renderRequest.setAttribute("cdn_url", config.cdn_url);
|
||||
|
||||
String current_url = PortalUtil.getCurrentURL(renderRequest);
|
||||
renderRequest.setAttribute("current_url", current_url);
|
||||
|
||||
String infrastructure = PortalContext.getConfiguration().getInfrastructureName();
|
||||
renderRequest.setAttribute("infrastructure", infrastructure);
|
||||
|
||||
HttpServletRequest httpReq = PortalUtil
|
||||
.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
|
||||
String absolute_current_url = PortalUtil.getAbsoluteURL(httpReq, current_url);
|
||||
renderRequest.setAttribute("absolute_current_url", absolute_current_url);
|
||||
|
||||
String calculated_gateway = absolute_current_url
|
||||
.replace("https://", "")
|
||||
.replace("http://", "")
|
||||
.replace(current_url, "");
|
||||
renderRequest.setAttribute("calculated_gateway", calculated_gateway);
|
||||
|
||||
String base_url = PortalUtil.getAbsoluteURL(httpReq, "/");
|
||||
renderRequest.setAttribute("base_url", base_url);
|
||||
URL a = new URL(base_url);
|
||||
|
||||
renderRequest.setAttribute("host", a.getHost());
|
||||
|
||||
try {
|
||||
Group group = (Group) GroupLocalServiceUtil.getGroup(PortalUtil.getScopeGroupId(renderRequest));
|
||||
String group_url = group.getFriendlyURL();
|
||||
renderRequest.setAttribute("group_url", group_url);
|
||||
renderRequest.setAttribute("group_name", group.getName());
|
||||
|
||||
} catch (PortalException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SystemException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String completeURL = PortalUtil.getCurrentCompleteURL(httpReq);
|
||||
renderRequest.setAttribute("completeURL", completeURL);
|
||||
|
||||
// User theUser = PortalUtil.getUser(renderRequest);
|
||||
String currentContext = getCurrentContext(renderRequest);
|
||||
renderRequest.setAttribute("current_context", currentContext);
|
||||
|
||||
// ScopeBean bean = new ScopeBean(currentContext);
|
||||
// String context;
|
||||
// String excapedContext;
|
||||
// String gateway;
|
||||
// String redirect-url;
|
||||
// String
|
||||
|
||||
// List<String> userContexts = new ArrayList<String>();
|
||||
// List<String> vreContexts = new ArrayList<String>();
|
||||
// List<GCubeGroup> userGroups = gm.listGroupsByUser(theUser.getUserId());
|
||||
// if (bean.is(Type.VRE)) {
|
||||
// userContexts.add(currentContext);
|
||||
// vreContexts.add(currentContext);
|
||||
// } else {
|
||||
// for (GCubeGroup g : userGroups) {
|
||||
// // skipping these sites
|
||||
// if (!(g.getFriendlyURL().equals("/guest") ||
|
||||
// g.getFriendlyURL().equals("/global"))) {
|
||||
// if
|
||||
// (g.getGroupName().equals(PortalContext.getConfiguration().getInfrastructureName()))
|
||||
// {
|
||||
// String context = gm.getInfrastructureScope(g.getGroupId());
|
||||
// userContexts.add(context);
|
||||
// if (context.split("/").length == 4) {
|
||||
// vreContexts.add(context);
|
||||
// }
|
||||
// }
|
||||
// if (g.getParentGroupId() > 0) {
|
||||
// String context = gm.getInfrastructureScope(g.getGroupId());
|
||||
// userContexts.add(context);
|
||||
// if (context.split("/").length == 4) {
|
||||
// vreContexts.add(context);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// renderRequest.setAttribute("userGroups", userGroups);
|
||||
// renderRequest.setAttribute("userContexts", userContexts);
|
||||
// renderRequest.setAttribute("vreContexts", vreContexts);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
_log.error(e);
|
||||
}
|
||||
super.render(renderRequest, renderResponse);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
package org.gcube.portlets.user.cloudcomputing.boot;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.rmi.ServerException;
|
||||
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portlets.user.cloudcomputing.CloudComputingConfig;
|
||||
import org.gcube.portlets.user.cloudcomputing.CloudComputingConfigPortlet;
|
||||
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.model.Group;
|
||||
import com.liferay.portal.service.GroupLocalServiceUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
|
||||
public class CloudComputingBootPlatformPortlet extends CloudComputingConfigPortlet {
|
||||
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil
|
||||
|
@ -17,6 +26,76 @@ public class CloudComputingBootPlatformPortlet extends CloudComputingConfigPortl
|
|||
public void render(RenderRequest renderRequest, RenderResponse renderResponse)
|
||||
throws PortletException, IOException {
|
||||
super.render(renderRequest, renderResponse);
|
||||
|
||||
// addDebugParams(renderRequest);
|
||||
}
|
||||
|
||||
public void addDebugParams(RenderRequest renderRequest) {
|
||||
|
||||
try {
|
||||
CloudComputingConfig config = getConfig(renderRequest);
|
||||
renderRequest.setAttribute("encoded_context", config.encoded_context);
|
||||
renderRequest.setAttribute("gateway", config.gateway);
|
||||
renderRequest.setAttribute("redirect_url", config.redirect_url);
|
||||
renderRequest.setAttribute("auth_url", config.auth_url);
|
||||
renderRequest.setAttribute("ccp_url", config.ccp_url);
|
||||
renderRequest.setAttribute("cdn_url", config.cdn_url);
|
||||
|
||||
} catch (ServerException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String current_url = PortalUtil.getCurrentURL(renderRequest);
|
||||
renderRequest.setAttribute("current_url", current_url);
|
||||
|
||||
String infrastructure = PortalContext.getConfiguration().getInfrastructureName();
|
||||
renderRequest.setAttribute("infrastructure", infrastructure);
|
||||
|
||||
HttpServletRequest httpReq = PortalUtil
|
||||
.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
|
||||
String absolute_current_url = PortalUtil.getAbsoluteURL(httpReq, current_url);
|
||||
renderRequest.setAttribute("absolute_current_url", absolute_current_url);
|
||||
|
||||
String calculated_gateway = absolute_current_url
|
||||
.replace("https://", "")
|
||||
.replace("http://", "")
|
||||
.replace(current_url, "");
|
||||
renderRequest.setAttribute("calculated_gateway", calculated_gateway);
|
||||
|
||||
String base_url = PortalUtil.getAbsoluteURL(httpReq, "/");
|
||||
renderRequest.setAttribute("base_url", base_url);
|
||||
|
||||
try {
|
||||
URL burl = new URL(base_url);
|
||||
renderRequest.setAttribute("host", burl.getHost());
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
renderRequest.setAttribute("host", e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
Group group = (Group) GroupLocalServiceUtil.getGroup(PortalUtil.getScopeGroupId(renderRequest));
|
||||
String group_url = group.getFriendlyURL();
|
||||
renderRequest.setAttribute("group_url", group_url);
|
||||
renderRequest.setAttribute("group_name", group.getName());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
renderRequest.setAttribute("group_url", e.getMessage());
|
||||
renderRequest.setAttribute("group_name", e.getMessage());
|
||||
}
|
||||
|
||||
String completeURL = PortalUtil.getCurrentCompleteURL(httpReq);
|
||||
renderRequest.setAttribute("completeURL", completeURL);
|
||||
|
||||
// User theUser = PortalUtil.getUser(renderRequest);
|
||||
String currentContext = getCurrentContext(renderRequest);
|
||||
renderRequest.setAttribute("current_context", currentContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,203 @@
|
|||
package org.gcube.portlets.user.cloudcomputing.is;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.rmi.ServerException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
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.log.LogFactoryUtil;
|
||||
|
||||
// import org.gcube.common.security.AuthorizedTasks;
|
||||
// import org.gcube.common.security.secrets.Secret;
|
||||
|
||||
/**
|
||||
* Utility class to query EndPoints and search for AccessPoints from IS
|
||||
*
|
||||
* @author Alfredo Oliviero (ISTI - CNR)
|
||||
*/
|
||||
|
||||
public class InfrastrctureServiceClient {
|
||||
private static com.liferay.portal.kernel.log.Log logger = LogFactoryUtil.getLog(InfrastrctureServiceClient.class);
|
||||
|
||||
/**
|
||||
* obatins from IS the list of ServiceEndpoint matching the parameters
|
||||
*
|
||||
* @param resource_name
|
||||
* @param category
|
||||
* @param root_service
|
||||
* @param secret
|
||||
*
|
||||
* @return the list of EndPoints matching the parameters
|
||||
* @throws ServerException
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public static ServiceEndpoint getFirstEndopintsFromIS(String resource_name, String category)
|
||||
throws ServerException {
|
||||
|
||||
List<ServiceEndpoint> endpoints = getEndopintsFromIS(resource_name, category);
|
||||
if (endpoints == null || endpoints.size() == 0) {
|
||||
logger.error("Unable to retrieve service endpoint " + resource_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
return endpoints.get(0);
|
||||
|
||||
}
|
||||
|
||||
public static List<ServiceEndpoint> getEndopintsFromIS(String resource_name, String category
|
||||
/* , boolean root_service, Secret secret */) throws ServerException {
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
|
||||
if (resource_name != null) {
|
||||
query.addCondition("$resource/Profile/Name/text() eq '" + resource_name + "'");
|
||||
}
|
||||
if (category != null) {
|
||||
query.addCondition("$resource/Profile/Category/text() eq '" + category + "'");
|
||||
}
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
|
||||
List<ServiceEndpoint> endpoints = null;
|
||||
|
||||
String currentScope = ScopeProvider.instance.get();
|
||||
String infrastructure = "/" + PortalContext.getConfiguration().getInfrastructureName();
|
||||
ScopeProvider.instance.set(infrastructure);
|
||||
|
||||
try {
|
||||
// if (root_service) {
|
||||
|
||||
// endpoints = AuthorizedTasks.executeSafely(() -> {
|
||||
// // esegui la query
|
||||
// List<ServiceEndpoint> toReturn = client.submit(query);
|
||||
// return toReturn;
|
||||
// }, secret);
|
||||
// } else {
|
||||
endpoints = client.submit(query);
|
||||
// }
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new ServerException(e.getMessage());
|
||||
|
||||
} finally {
|
||||
ScopeProvider.instance.set(currentScope);
|
||||
}
|
||||
|
||||
return endpoints;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* obatains the list of AccessPoints matching the parameters
|
||||
*
|
||||
* @param resource_name
|
||||
* @param category
|
||||
* @param endPointName
|
||||
* @param is_root_service
|
||||
* @return the list of AccessPoints
|
||||
* @throws ServerException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static List<ServiceEndpoint.AccessPoint> getAccessPointsFromIS(String resource_name, String category,
|
||||
String endPointName/* , boolean is_root_service, Secret secret */) throws ServerException {
|
||||
|
||||
List<ServiceEndpoint> resources = getEndopintsFromIS(resource_name, category/* , is_root_service, secret */);
|
||||
|
||||
if (resources.size() == 0) {
|
||||
logger.error("There is no Runtime Resource having name " + resource_name + " and Category "
|
||||
+ category + " in this scope.");
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ServiceEndpoint.AccessPoint> response = new ArrayList<ServiceEndpoint.AccessPoint>();
|
||||
resources.forEach(res -> {
|
||||
Stream<ServiceEndpoint.AccessPoint> access_points_res = res.profile().accessPoints().stream();
|
||||
|
||||
if (endPointName == null) {
|
||||
access_points_res = access_points_res.filter(ap -> ap.name().equals(endPointName));
|
||||
}
|
||||
|
||||
access_points_res.forEach(a -> response.add(a));
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* obatains the list of AccessPoints matching the parameters, and returns the
|
||||
* first one
|
||||
*
|
||||
* @param resource_name
|
||||
* @param category
|
||||
* @param entryPointName
|
||||
* @return an AccessPoints matching the parameters
|
||||
* @throws ServerException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static ServiceEndpoint.AccessPoint getFirstAccessPointFromIS(String resource_name, String category,
|
||||
String entryPointName/* , boolean root_service, Secret secret */) throws ServerException {
|
||||
|
||||
List<ServiceEndpoint.AccessPoint> access_points = getAccessPointsFromIS(resource_name, category,
|
||||
entryPointName /* , root_service, secret */);
|
||||
|
||||
if (access_points == null || access_points.size() == 0) {
|
||||
logger.error("Unable to retrieve service endpoint " + entryPointName);
|
||||
return null;
|
||||
}
|
||||
|
||||
for (AccessPoint ap : access_points) {
|
||||
if (ap.name().equals(entryPointName)) {
|
||||
return ap;
|
||||
}
|
||||
}
|
||||
|
||||
logger.error("Unable to retrieve service endpoint " + entryPointName);
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the service configuration from the IS
|
||||
*
|
||||
* @param resourceName
|
||||
* @param category
|
||||
* @param endPointName
|
||||
* @param is_root_service
|
||||
* @param secret
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static IsServerConfig serviceConfigFromIS(String resourceName, String category, String endPointName
|
||||
/* , boolean is_root_service, Secret secret */)
|
||||
throws ServerException {
|
||||
|
||||
logger.info("Starting creating service credentials");
|
||||
ServiceEndpoint.AccessPoint accessPoint = InfrastrctureServiceClient.getFirstAccessPointFromIS(resourceName,
|
||||
category, endPointName/* , is_root_service, secret */);
|
||||
if (accessPoint == null) {
|
||||
String error_log = "Unable to retrieve service endpoint " + endPointName;
|
||||
|
||||
logger.error(error_log);
|
||||
throw new ServerException(error_log);
|
||||
}
|
||||
|
||||
try {
|
||||
IsServerConfig config = new IsServerConfig(accessPoint);
|
||||
return config;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("cannot create server config from" + accessPoint, e);
|
||||
|
||||
e.printStackTrace();
|
||||
throw new ServerException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package org.gcube.portlets.user.cloudcomputing.is;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||
// import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
|
||||
|
||||
public class IsServerConfig {
|
||||
private String serverUrl;
|
||||
private String name;
|
||||
private String clientId;
|
||||
|
||||
private Map<String, String> properties = new HashMap<String, String>();
|
||||
|
||||
private String clientSecret;
|
||||
|
||||
String CLIENT_CREDENTIALS = "client_credentials";
|
||||
|
||||
private String grantType = CLIENT_CREDENTIALS;
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public String getServerUrl() {
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return clientSecret;
|
||||
}
|
||||
|
||||
public String getGrantType() {
|
||||
return grantType;
|
||||
}
|
||||
|
||||
public boolean hasProperty(String key) {
|
||||
return this.properties.containsKey(key);
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
return this.properties.get(key);
|
||||
}
|
||||
|
||||
public IsServerConfig(String serverUrl) {
|
||||
this.serverUrl = serverUrl;
|
||||
}
|
||||
|
||||
public IsServerConfig(String serverUrl, String name, String clientId, String clientSecret) {
|
||||
this.serverUrl = serverUrl;
|
||||
this.name = name;
|
||||
this.clientId = clientId;
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
public IsServerConfig(String serverUrl, String name, String clientId, String clientSecret,
|
||||
Map<String, String> properties) {
|
||||
this(serverUrl, name, clientId, clientSecret);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public IsServerConfig(ServiceEndpoint.AccessPoint accessPoint) throws Exception {
|
||||
this.serverUrl = accessPoint.address();
|
||||
this.name = accessPoint.name();
|
||||
this.clientId = accessPoint.username();
|
||||
//this.clientSecret = StringEncrypter.getEncrypter().decrypt(accessPoint.password());
|
||||
|
||||
this.properties = new HashMap<String, String>();
|
||||
for (Property p : accessPoint.properties()) {
|
||||
String value = p.value();
|
||||
if (p.isEncrypted()) {
|
||||
value = StringEncrypter.getEncrypter().decrypt(value);
|
||||
}
|
||||
this.properties.put(p.name(), value);
|
||||
}
|
||||
}
|
||||
|
||||
public IsServerConfig(String serverUrl, String name, String clientId, String clientSecret,
|
||||
Map<String, String> properties,
|
||||
String grantType) {
|
||||
this(serverUrl, name, clientId, clientSecret, properties);
|
||||
this.grantType = grantType;
|
||||
}
|
||||
}
|
|
@ -1,16 +1,14 @@
|
|||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
|
||||
<%@include file="../init.jsp" %>
|
||||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
||||
<%@ include file="../init.jsp"%>
|
||||
|
||||
<%
|
||||
|
||||
|
||||
pageContext.setAttribute("current_context", request.getAttribute("current_context"));
|
||||
|
||||
pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context"));
|
||||
pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url"));
|
||||
pageContext.setAttribute("auth_url", request.getAttribute("auth_url"));
|
||||
pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url"));
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url"));
|
||||
|
||||
pageContext.setAttribute("current_context", request.getAttribute("current_context"));
|
||||
|
||||
pageContext.setAttribute("current_url", request.getAttribute("current_url"));
|
||||
pageContext.setAttribute("infrastructure", request.getAttribute("infrastructure"));
|
||||
|
@ -20,7 +18,6 @@ pageContext.setAttribute("base_url", request.getAttribute("base_url"));
|
|||
pageContext.setAttribute("group_url", request.getAttribute("group_url"));
|
||||
pageContext.setAttribute("group_name", request.getAttribute("group_name"));
|
||||
pageContext.setAttribute("host", request.getAttribute("host"));
|
||||
|
||||
%>
|
||||
|
||||
<script src="${cdn_url}/common/js/keycloak.js" type="text/javascript"></script>
|
||||
|
@ -39,7 +36,9 @@ pageContext.setAttribute("host", request.getAttribute("host"));
|
|||
|
||||
Boot Portlet
|
||||
|
||||
<ul>
|
||||
<div style="display:block">
|
||||
|
||||
<ul>
|
||||
|
||||
<li> current_context = ${current_context}</li>
|
||||
<li> encoded_context = ${encoded_context}</li>
|
||||
|
@ -59,4 +58,5 @@ Boot Portlet
|
|||
<li> group_url = ${group_url}</li>
|
||||
<li> group_name = ${group_name}</li>
|
||||
<li> host = ${host}</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
||||
<%@include file="../../init.jsp"%>
|
||||
|
||||
<%@ include file="../../init.jsp"%>
|
||||
|
||||
<%
|
||||
pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context"));
|
||||
pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url"));
|
||||
pageContext.setAttribute("auth_url", request.getAttribute("auth_url"));
|
||||
pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url"));
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); %>
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url"));
|
||||
%>
|
||||
|
||||
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
|
||||
<script src="${cdn_url}/ccp/js/inputwidgetcontroller.js"></script>
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
||||
<%@include file="../../init.jsp"%>
|
||||
|
||||
<%@ include file="../../init.jsp"%>
|
||||
|
||||
<%
|
||||
pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context"));
|
||||
pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url"));
|
||||
pageContext.setAttribute("auth_url", request.getAttribute("auth_url"));
|
||||
pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url"));
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); %>
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url"));
|
||||
%>
|
||||
|
||||
|
||||
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
|
||||
<div>
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
|
||||
<%@include file="../../init.jsp" %>
|
||||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
||||
|
||||
<%@ include file="../../init.jsp"%>
|
||||
|
||||
<%
|
||||
pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context"));
|
||||
pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url"));
|
||||
pageContext.setAttribute("auth_url", request.getAttribute("auth_url"));
|
||||
pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url"));
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); %>
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url"));
|
||||
%>
|
||||
|
||||
<div>
|
||||
<d4s-ccp-methodlist allow-execute="true" archive="true"
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
|
||||
<%@include file="../../init.jsp" %>
|
||||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
||||
|
||||
<%@ include file="../../init.jsp"%>
|
||||
|
||||
<%
|
||||
pageContext.setAttribute("encoded_context", request.getAttribute("encoded_context"));
|
||||
pageContext.setAttribute("redirect_url", request.getAttribute("redirect_url"));
|
||||
pageContext.setAttribute("auth_url", request.getAttribute("auth_url"));
|
||||
pageContext.setAttribute("ccp_url", request.getAttribute("ccp_url"));
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url")); %>
|
||||
pageContext.setAttribute("cdn_url", request.getAttribute("cdn_url"));
|
||||
%>
|
||||
|
||||
|
||||
<div><d4s-ccp-executionhistory archive="true" serviceurl="${ccp_url}">
|
||||
<script src="${cdn_url}/ccp/js/executionhistorycontroller.js"></script>
|
||||
|
|
Loading…
Reference in New Issue