ready to release
This commit is contained in:
parent
af432c083f
commit
ca364579c1
|
@ -1,45 +1,54 @@
|
|||
<?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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
5
pom.xml
5
pom.xml
|
@ -124,6 +124,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>
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package org.gcube.portlets.user;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
|
||||
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.oidc.rest.JWTToken;
|
||||
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
|
||||
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
import com.liferay.util.bridges.mvc.MVCPortlet;
|
||||
|
||||
import okhttp3.*;
|
||||
|
||||
/**
|
||||
* Portlet implementation class ExtAppManager
|
||||
*/
|
||||
public class ExtAppManager extends MVCPortlet {
|
||||
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil.getLog(ExtAppManager.class);
|
||||
final String D4S_BOOT_URL = "https://d4science-cdn.nubisware.cloud/d4s-cdn/visuals/d4s-boot";
|
||||
final String EXT_APP_MANAGER_URL = "https://d4science-cdn.nubisware.cloud/d4s-cdn/visuals/ext-app-manager";
|
||||
|
||||
|
||||
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 {
|
||||
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(EXT_APP_MANAGER_URL)
|
||||
.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="ext-app-manager"></portlet>
|
||||
</category>
|
||||
<category name="OpenAIRE">
|
||||
<portlet id="box-open-aire-redirect"></portlet>
|
||||
|
|
|
@ -51,6 +51,16 @@
|
|||
ddas-vre-integration-portlet
|
||||
</css-class-wrapper>
|
||||
</portlet>
|
||||
<portlet>
|
||||
<portlet-name>ext-app-manager</portlet-name>
|
||||
<icon>/icon.png</icon>
|
||||
<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,37 @@
|
|||
<role-name>user</role-name>
|
||||
</security-role-ref>
|
||||
</portlet>
|
||||
<portlet>
|
||||
<portlet-name>ext-app-manager</portlet-name>
|
||||
<display-name>Ext App Manager</display-name>
|
||||
<portlet-class>
|
||||
org.gcube.portlets.user.ExtAppManager
|
||||
</portlet-class>
|
||||
<init-param>
|
||||
<name>view-jsp</name>
|
||||
<value>/html/extappmanager/view.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>Ext App Manager</title>
|
||||
<short-title>Ext App 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,25 @@
|
|||
<%@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");
|
||||
|
||||
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