Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
Massimiliano Assante | b66763694b | |
Massimiliano Assante | d7621ccf83 | |
Massimiliano Assante | 1222051250 | |
Massimiliano Assante | ca364579c1 |
|
@ -1,45 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="VREApp-Integration-portlet">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<property name="context-root" value="VREApp-Integration-portlet"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<property name="java-output-path" value="/VREApp-Integration-portlet/target/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,9 +1,17 @@
|
|||
|
||||
# Changelog for VRE Definition Portlet
|
||||
# Changelog for VRE App Integration Portlet
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.2.1-SNAPSHOT] - 2022-07-13
|
||||
|
||||
- Weblet manager is now instanciable (can appear more than once on a page)
|
||||
|
||||
## [v1.2.0] - 2022-02-18
|
||||
|
||||
- Added Weblet support
|
||||
|
||||
## [v1.1.0] - 2021-07-13
|
||||
|
||||
- Ported to git
|
||||
|
|
13
pom.xml
13
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<artifactId>VREApp-Integration-portlet</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>VREApp-Integration-portlet Portlet</name>
|
||||
<version>1.1.0</version>
|
||||
<version>1.2.1-SNAPSHOT</version>
|
||||
<properties>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -89,6 +89,10 @@
|
|||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>oidc-library-portal</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
|
@ -124,6 +128,11 @@
|
|||
<artifactId>spymemcached</artifactId>
|
||||
<version>2.12.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
|
@ -141,7 +150,6 @@
|
|||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -159,7 +167,6 @@
|
|||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>util-java</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package org.gcube.portlets.user.weblet;
|
||||
|
||||
import javax.portlet.ActionRequest;
|
||||
import javax.portlet.ActionResponse;
|
||||
import javax.portlet.PortletConfig;
|
||||
import javax.portlet.PortletPreferences;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.kernel.portlet.DefaultConfigurationAction;
|
||||
|
||||
public class WebletConfigurationAction extends DefaultConfigurationAction {
|
||||
private static Log _log = LogFactoryUtil.getLog(WebletConfigurationAction.class);
|
||||
@Override
|
||||
public void processAction(
|
||||
PortletConfig portletConfig, ActionRequest actionRequest,
|
||||
ActionResponse actionResponse) throws Exception {
|
||||
|
||||
super.processAction(portletConfig, actionRequest, actionResponse);
|
||||
|
||||
PortletPreferences prefs = actionRequest.getPreferences();
|
||||
String bootURL = prefs.getValue("bootURL", "true");
|
||||
String managerURL = prefs.getValue("managerURL", "true");
|
||||
String iamClientId = prefs.getValue("iamClientId", "true");
|
||||
|
||||
_log.debug("bootURL = " + bootURL + " in PublicWebappConfigurationAction.processAction().");
|
||||
_log.debug("managerURL = " + managerURL + " in PublicWebappConfigurationAction.processAction().");
|
||||
_log.debug("iamClientId = " + iamClientId + " in PublicWebappConfigurationAction.processAction().");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String render(PortletConfig portletConfig,
|
||||
RenderRequest renderRequest, RenderResponse renderResponse)
|
||||
throws Exception {
|
||||
|
||||
return "/html/extappmanager/config.jsp";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package org.gcube.portlets.user.weblet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
|
||||
import javax.portlet.PortletException;
|
||||
import javax.portlet.PortletPreferences;
|
||||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.oidc.rest.JWTToken;
|
||||
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
|
||||
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.kernel.util.GetterUtil;
|
||||
import com.liferay.portal.kernel.util.StringPool;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
import com.liferay.util.bridges.mvc.MVCPortlet;
|
||||
|
||||
import okhttp3.*;
|
||||
|
||||
/**
|
||||
* Portlet implementation class WebletManager
|
||||
*/
|
||||
public class WebletManager extends MVCPortlet {
|
||||
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil.getLog(WebletManager.class);
|
||||
//final String D4S_BOOT_URL = "https://cdn.dev.d4science.org/visuals/d4s-cdn/d4s-boot";
|
||||
//final String EXT_APP_MANAGER_URL = "https://cdn.dev.d4science.org/visuals/d4s-vre-manager/ext-app-manager?app=_myextapp";
|
||||
|
||||
|
||||
public static final String D4S_BOOT_ATTR = "d4s-boot-div";
|
||||
public static final String EXT_APP_MANAGERATTR = "ext-app-div";
|
||||
|
||||
|
||||
@Override
|
||||
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
|
||||
|
||||
PortletPreferences portletPreferences = renderRequest.getPreferences();
|
||||
String D4S_BOOT_URL = GetterUtil.getString(portletPreferences.getValue("bootURL", StringPool.BLANK));
|
||||
String WEBLET_MANAGER_URL = GetterUtil.getString(portletPreferences.getValue("managerURL", StringPool.BLANK));
|
||||
String IAM_CLIENTID = GetterUtil.getString(portletPreferences.getValue("iamClientId", StringPool.BLANK));
|
||||
|
||||
String webletForIamClientURL = new StringBuilder(WEBLET_MANAGER_URL).append("?app=").append(IAM_CLIENTID).toString();
|
||||
|
||||
if (D4S_BOOT_URL.equals(StringPool.BLANK) || WEBLET_MANAGER_URL.equals(StringPool.BLANK) || IAM_CLIENTID.equals(StringPool.BLANK)) {
|
||||
_log.warn("Missing parameters in config");
|
||||
}
|
||||
else {
|
||||
JWTToken umaToken = null;
|
||||
try {
|
||||
String username = PortalUtil.getUser(renderRequest).getScreenName();
|
||||
HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
|
||||
String context = getCurrentContext(renderRequest);
|
||||
umaToken = OIDCUmaUtil.getUMAToken(httpReq, username, context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String token = umaToken.getAccessTokenString();
|
||||
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(D4S_BOOT_URL)
|
||||
.addHeader("cache-control", "no-cache")
|
||||
.addHeader("Authorization", "Bearer " + token)
|
||||
.build();
|
||||
Call call = client.newCall(request);
|
||||
Response response = call.execute();
|
||||
String d4sBootDIV = response.body().string();
|
||||
String encodedSd4sBootDIV = Base64.getEncoder().encodeToString(d4sBootDIV.getBytes());
|
||||
renderRequest.setAttribute(D4S_BOOT_ATTR, encodedSd4sBootDIV);
|
||||
request = new Request.Builder()
|
||||
.url(webletForIamClientURL)
|
||||
.addHeader("cache-control", "no-cache")
|
||||
.addHeader("Authorization", "Bearer " + token)
|
||||
.build();
|
||||
call = client.newCall(request);
|
||||
response = call.execute();
|
||||
String extAppDIV = response.body().string();
|
||||
String encodedextAppDIV = Base64.getEncoder().encodeToString(extAppDIV.getBytes());
|
||||
renderRequest.setAttribute(EXT_APP_MANAGERATTR, encodedextAppDIV);
|
||||
}
|
||||
super.render(renderRequest, renderResponse);
|
||||
}
|
||||
|
||||
public static String getCurrentContext(RenderRequest request) {
|
||||
long groupId = -1;
|
||||
try {
|
||||
groupId = PortalUtil.getScopeGroupId(request);
|
||||
return getCurrentContext(groupId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getCurrentContext(long groupId) {
|
||||
try {
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
return pContext.getCurrentScope(""+groupId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
<portlet id="vre-app-integration"></portlet>
|
||||
<portlet id="knime-app-integration"></portlet>
|
||||
<portlet id="ddas-vre-integration"></portlet>
|
||||
<portlet id="weblet-manager"></portlet>
|
||||
</category>
|
||||
<category name="OpenAIRE">
|
||||
<portlet id="box-open-aire-redirect"></portlet>
|
||||
|
|
|
@ -4,6 +4,6 @@ module-incremental-version=4
|
|||
tags=
|
||||
short-description=
|
||||
change-log=
|
||||
page-url=http://www.d4science.org
|
||||
page-url=https://code-repo.d4science.org/gCubeSystem/VREApp-Integration-portlet
|
||||
author=M.Assante
|
||||
licenses=EUPL
|
||||
|
|
|
@ -51,6 +51,18 @@
|
|||
ddas-vre-integration-portlet
|
||||
</css-class-wrapper>
|
||||
</portlet>
|
||||
<portlet>
|
||||
<portlet-name>weblet-manager</portlet-name>
|
||||
<icon>/icon.png</icon>
|
||||
<configuration-action-class>org.gcube.portlets.user.weblet.WebletConfigurationAction</configuration-action-class>
|
||||
<instanceable>true</instanceable>
|
||||
<requires-namespaced-parameters>false</requires-namespaced-parameters>
|
||||
<header-portlet-css>/css/main.css</header-portlet-css>
|
||||
<footer-portlet-javascript>
|
||||
/js/main.js
|
||||
</footer-portlet-javascript>
|
||||
<css-class-wrapper>ext-app-manager-portlet</css-class-wrapper>
|
||||
</portlet>
|
||||
<role-mapper>
|
||||
<role-name>administrator</role-name>
|
||||
<role-link>Administrator</role-link>
|
||||
|
|
|
@ -160,4 +160,41 @@
|
|||
<role-name>user</role-name>
|
||||
</security-role-ref>
|
||||
</portlet>
|
||||
<portlet>
|
||||
<portlet-name>weblet-manager</portlet-name>
|
||||
<display-name>Weblet Manager</display-name>
|
||||
<portlet-class>
|
||||
org.gcube.portlets.user.weblet.WebletManager
|
||||
</portlet-class>
|
||||
<init-param>
|
||||
<name>config-template</name>
|
||||
<value>/html/extappmanager/config.jsp</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<name>view-jsp</name>
|
||||
<value>/html/extappmanager/weblet.jsp</value>
|
||||
</init-param>
|
||||
<expiration-cache>0</expiration-cache>
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
<portlet-mode>view</portlet-mode>
|
||||
</supports>
|
||||
<portlet-info>
|
||||
<title>Weblet Manager</title>
|
||||
<short-title>Weblet Manager</short-title>
|
||||
<keywords></keywords>
|
||||
</portlet-info>
|
||||
<security-role-ref>
|
||||
<role-name>administrator</role-name>
|
||||
</security-role-ref>
|
||||
<security-role-ref>
|
||||
<role-name>guest</role-name>
|
||||
</security-role-ref>
|
||||
<security-role-ref>
|
||||
<role-name>power-user</role-name>
|
||||
</security-role-ref>
|
||||
<security-role-ref>
|
||||
<role-name>user</role-name>
|
||||
</security-role-ref>
|
||||
</portlet>
|
||||
</portlet-app>
|
|
@ -0,0 +1,48 @@
|
|||
<%@include file="/html/init.jsp"%>
|
||||
|
||||
<liferay-portlet:actionURL portletConfiguration="true"
|
||||
var="configurationURL" />
|
||||
|
||||
<%
|
||||
String bootURL_cfg = GetterUtil.getString(portletPreferences.getValue("bootURL", StringPool.BLANK));
|
||||
String managerURLcfg = GetterUtil.getString(portletPreferences.getValue("managerURL", StringPool.BLANK));
|
||||
String iamClientId_cfg = GetterUtil.getString(portletPreferences.getValue("iamClientId", StringPool.BLANK));
|
||||
%>
|
||||
|
||||
<aui:form action="<%=configurationURL%>" method="post" name="fm">
|
||||
<aui:input name="<%=Constants.CMD%>" type="hidden"
|
||||
value="<%=Constants.UPDATE%>" />
|
||||
|
||||
<!-- Boot URL -->
|
||||
<aui:field-wrapper cssClass="field-group">
|
||||
<aui:input style="width: 100%;" name="preferences--bootURL--"
|
||||
type="text" cssClass="text long-field" showRequiredLabel="true"
|
||||
label="D4Science Visuals CDN Boot URL" inlineField="true" inlineLabel="left"
|
||||
placeholder="e.g. https://cdn.d4science.org/visuals/d4s-cdn/d4s-boot"
|
||||
helpMessage="Actual endpoint of the cdn visuals on D4Science"
|
||||
value="<%=bootURL_cfg%>" required="true" />
|
||||
</aui:field-wrapper>
|
||||
<!-- manager URL -->
|
||||
<aui:field-wrapper cssClass="field-group">
|
||||
<aui:input style="width: 100%;" name="preferences--managerURL--"
|
||||
type="text" cssClass="text long-field" showRequiredLabel="true"
|
||||
label="D4Science Visuals CDN Manager URL" inlineField="true" inlineLabel="left"
|
||||
placeholder="e.g. https://cdn.d4science.org/visuals/d4s-vre-manager/ext-app-manager"
|
||||
helpMessage="Actual endpoint of the cdn visuals Manager on D4Science"
|
||||
value="<%=managerURLcfg%>" required="true" />
|
||||
</aui:field-wrapper>
|
||||
<!-- IAM Client ID (App Name) -->
|
||||
<aui:field-wrapper cssClass="field-group">
|
||||
<aui:input style="width: 100%;" name="preferences--iamClientId--"
|
||||
type="text" cssClass="text long-field" showRequiredLabel="true"
|
||||
label="IAM Client Id" inlineField="true" inlineLabel="left"
|
||||
placeholder="enter the IAM ClientId of the App here"
|
||||
helpMessage="Actual IAM Client Id for this app"
|
||||
value="<%=iamClientId_cfg%>" required="true" />
|
||||
</aui:field-wrapper>
|
||||
|
||||
<aui:button-row>
|
||||
<aui:button type="submit" />
|
||||
</aui:button-row>
|
||||
|
||||
</aui:form>
|
|
@ -0,0 +1,26 @@
|
|||
<%@include file="/html/init.jsp"%>
|
||||
|
||||
|
||||
<%@ page import="java.util.Base64"%>
|
||||
|
||||
<%
|
||||
String encodedD4sBootDIV = (String) request.getAttribute("d4s-boot-div");
|
||||
String encodedExtAppDIV = (String) request.getAttribute("ext-app-div");
|
||||
|
||||
if (encodedD4sBootDIV == null || encodedExtAppDIV == null) {
|
||||
String d4sBootDIV = new String(
|
||||
"Configuration is missing, please enter boot, manager urls and clientId name in portlet configuration");
|
||||
} else {
|
||||
byte[] decodedBytes = Base64.getDecoder().decode(encodedD4sBootDIV);
|
||||
String d4sBootDIV = new String(decodedBytes);
|
||||
|
||||
decodedBytes = Base64.getDecoder().decode(encodedExtAppDIV);
|
||||
String extAppDIV = new String(decodedBytes);
|
||||
|
||||
pageContext.setAttribute("d4sBootDIV", d4sBootDIV);
|
||||
pageContext.setAttribute("extAppDIV", extAppDIV);
|
||||
}
|
||||
%>
|
||||
${d4sBootDIV}
|
||||
|
||||
<div id="extAppDIV">${extAppDIV}</div>
|
Loading…
Reference in New Issue