added support for ASL Session replacement

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/portal-manager@134126 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-11-14 16:10:36 +00:00
parent 8ae42e335a
commit d034412bbe
1 changed files with 31 additions and 17 deletions

View File

@ -5,7 +5,6 @@ import static org.gcube.common.authorization.client.Constants.authorizationServi
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -18,7 +17,6 @@ import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys;
import org.gcube.vomanagement.usermanagement.model.Email;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -154,15 +152,14 @@ public class PortalContext {
}
/**
*
* @param httpServletRequest the httpServletRequest object
* @param scopeGroupId the liferay groupid number (as String) of the VRE/VO
* @return the scope (context)
*/
public String getCurrentScope(HttpServletRequest httpServletRequest) {
String groupIdNo = httpServletRequest.getHeader(VRE_ID_ATTR_NAME);
if (groupIdNo != null) {
public String getCurrentScope(String scopeGroupId) {
if (scopeGroupId != null) {
long groupId = -1;
try {
groupId = Long.parseLong(groupIdNo);
groupId = Long.parseLong(scopeGroupId);
LiferayGroupManager gm = new LiferayGroupManager();
if (gm.isRootVO(groupId)) {
return SCOPE_SEPARATOR + getInfrastructureName();
@ -183,6 +180,15 @@ public class PortalContext {
}
return null;
}
/**
*
* @param httpServletRequest the httpServletRequest object
* @return the scope (context)
*/
public String getCurrentScope(HttpServletRequest httpServletRequest) {
String scopeGroupId = httpServletRequest.getHeader(VRE_ID_ATTR_NAME);
return getCurrentScope(scopeGroupId);
}
/**
*
* @param httpServletRequest the httpServletRequest object
@ -591,7 +597,7 @@ public class PortalContext {
private static GCubeUser readUserFromPropertyFile() {
Properties props = new Properties();
try {
StringBuilder sb = new StringBuilder(getCatalinaHome());
StringBuilder sb = new StringBuilder(getGCubeDevHome());
sb.append(File.separator)
.append(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME);
String propertyfile = sb.toString();
@ -614,7 +620,7 @@ public class PortalContext {
return new GCubeUser(userId, username, email, firstName, middleName, lastName, fullname, registrationDate, userAvatarId, male, jobTitle, emailAddresses);
}
catch(IOException e) {
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $CATALINA_HOME dir");
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $GCUBE_DEV_HOME dir");
return null;
}
}
@ -624,7 +630,7 @@ public class PortalContext {
private static String readTokenPropertyFile() {
Properties props = new Properties();
try {
StringBuilder sb = new StringBuilder(getCatalinaHome());
StringBuilder sb = new StringBuilder(getGCubeDevHome());
sb.append(File.separator)
.append(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME);
String propertyfile = sb.toString();
@ -640,7 +646,7 @@ public class PortalContext {
}
}
catch(IOException e) {
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $CATALINA_HOME dir");
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $GCUBE_DEV_HOME dir");
return null;
}
}
@ -651,7 +657,7 @@ public class PortalContext {
private static String readContextPropertyFile() {
Properties props = new Properties();
try {
StringBuilder sb = new StringBuilder(getCatalinaHome());
StringBuilder sb = new StringBuilder(getGCubeDevHome());
sb.append(File.separator)
.append(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME);
String propertyfile = sb.toString();
@ -667,7 +673,7 @@ public class PortalContext {
}
}
catch(IOException e) {
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $CATALINA_HOME dir");
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $GCUBE_DEV_HOME dir");
return null;
}
}
@ -677,7 +683,7 @@ public class PortalContext {
private static String readGroupNamePropertyFile() {
Properties props = new Properties();
try {
StringBuilder sb = new StringBuilder(getCatalinaHome());
StringBuilder sb = new StringBuilder(getGCubeDevHome());
sb.append(File.separator)
.append(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME);
String propertyfile = sb.toString();
@ -693,7 +699,7 @@ public class PortalContext {
}
}
catch(IOException e) {
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $CATALINA_HOME dir");
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $GCUBE_DEV_HOME dir");
return null;
}
}
@ -704,7 +710,7 @@ public class PortalContext {
private static long readGroupIdPropertyFile() {
Properties props = new Properties();
try {
StringBuilder sb = new StringBuilder(getCatalinaHome());
StringBuilder sb = new StringBuilder(getGCubeDevHome());
sb.append(File.separator)
.append(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME);
String propertyfile = sb.toString();
@ -727,7 +733,7 @@ public class PortalContext {
}
}
catch(IOException e) {
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $CATALINA_HOME dir");
_log.error(GCUBE_DEV__CONTEXT_PROPERTY_FILENAME + " file not found under $GCUBE_DEV_HOME dir");
return -1L;
}
return -1L;
@ -741,6 +747,14 @@ public class PortalContext {
private static String getCatalinaHome() {
return (System.getenv("CATALINA_HOME").endsWith("/") ? System.getenv("CATALINA_HOME") : System.getenv("CATALINA_HOME")+"/");
}
/**
*
* @return $GCUBE-DEV-HOME
*/
private static String getGCubeDevHome() {
return (System.getenv("GCUBE_DEV_HOME").endsWith("/") ? System.getenv("GCUBE_DEV_HOME") : System.getenv("GCUBE_DEV_HOME")+"/");
}