refs 4172: Dataminer interface enhancements
Task-Url: https://support.d4science.org/issues/4172 Added Auth 2.0 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@131277 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f97c3bb15e
commit
9a0632b4cf
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/data-miner-manager-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/data-miner-manager-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/data-miner-manager-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"/>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/data-miner-manager-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
|
@ -26,5 +26,5 @@
|
|||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="target/data-miner-manager-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/data-miner-manager-1.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.data-miner-manager.1-1-0"
|
||||
date="2016-10-01">
|
||||
<Change>Updated to Auth 2.0</Change>
|
||||
<Change>Added Spatial data support [Ticket #4172]</Change>
|
||||
<Change>Added Temporal data support [Ticket #4172]</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.data-miner-manager.1-0-0"
|
||||
date="2012-10-18">
|
||||
date="2016-07-01">
|
||||
<Change>First release</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
2
pom.xml
2
pom.xml
|
@ -12,7 +12,7 @@
|
|||
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>data-miner-manager</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>data-miner-manager</name>
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package org.gcube.portlets.user.dataminermanager.server;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.accesslogger.library.impl.AccessLogger;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus;
|
||||
import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
|
||||
|
@ -44,7 +42,6 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|||
@SuppressWarnings("serial")
|
||||
public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
||||
DataMinerPortletService {
|
||||
public static AccessLogger accountinglog = AccessLogger.getAccessLogger();
|
||||
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(DataMinerManagerServiceImpl.class);
|
||||
|
|
|
@ -14,6 +14,7 @@ import javax.servlet.http.HttpSession;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.common.authorization.library.provider.UserInfo;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portlets.user.dataminermanager.server.smservice.SClient;
|
||||
import org.gcube.portlets.user.dataminermanager.server.smservice.SClient4WPSBuilder;
|
||||
|
@ -33,7 +34,7 @@ import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceExceptio
|
|||
public class SessionUtil {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(SessionUtil.class);
|
||||
|
||||
|
||||
public static ASLSession getASLSession(HttpSession httpSession)
|
||||
throws ServiceException {
|
||||
String username = (String) httpSession
|
||||
|
@ -67,61 +68,74 @@ public class SessionUtil {
|
|||
return aslSession;
|
||||
}
|
||||
|
||||
public static String getToken(ASLSession aslSession) {
|
||||
String token=null;
|
||||
public static String getToken(ASLSession aslSession) throws Exception {
|
||||
String token = null;
|
||||
if (Constants.DEBUG_MODE) {
|
||||
List<String> userRoles = new ArrayList<>();
|
||||
userRoles.add(Constants.DEFAULT_ROLE);
|
||||
/*if (aslSession.getUsername().compareTo("lucio.lelii") == 0)
|
||||
userRoles.add("VRE-Manager");*/
|
||||
token = authorizationService().build().generate(
|
||||
aslSession.getUsername(), userRoles);
|
||||
|
||||
/*
|
||||
* if (aslSession.getUsername().compareTo("lucio.lelii") == 0)
|
||||
* userRoles.add("VRE-Manager");
|
||||
*/
|
||||
try {
|
||||
token = authorizationService().generateUserToken(
|
||||
new UserInfo(aslSession.getUsername(), userRoles),
|
||||
aslSession.getScope());
|
||||
} catch (Exception e) {
|
||||
logger.error("Error generating the token for test: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new Exception("Error generating the token for test: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
} else {
|
||||
token = aslSession.getSecurityToken();
|
||||
}
|
||||
logger.info("received token: " + token);
|
||||
return token;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static SClient getSClient(ASLSession aslSession, HttpSession session)
|
||||
throws Exception {
|
||||
|
||||
if(aslSession==null){
|
||||
if (aslSession == null) {
|
||||
logger.error("ASLSession is null!");
|
||||
throw new SessionExpiredServiceException("Session Expired!");
|
||||
}
|
||||
SClient sClient;
|
||||
|
||||
Object obj=session.getAttribute(Constants.SClientMap);
|
||||
if(obj==null){
|
||||
}
|
||||
SClient sClient;
|
||||
|
||||
Object obj = session.getAttribute(Constants.SClientMap);
|
||||
if (obj == null) {
|
||||
logger.info("Create new SClientMap");
|
||||
HashMap<String,SClient> sClientMap=new HashMap<>();
|
||||
HashMap<String, SClient> sClientMap = new HashMap<>();
|
||||
logger.info("Create new SClient");
|
||||
ServiceCredential serviceCredential=new ServiceCredential(aslSession.getUsername(), aslSession.getScope(),
|
||||
ServiceCredential serviceCredential = new ServiceCredential(
|
||||
aslSession.getUsername(), aslSession.getScope(),
|
||||
SessionUtil.getToken(aslSession));
|
||||
SClientBuilder sBuilder = new SClient4WPSBuilder(serviceCredential);
|
||||
SClientDirector director = new SClientDirector();
|
||||
director.setSClientBuilder(sBuilder);
|
||||
director.constructSClient();
|
||||
sClient = director.getSClient();
|
||||
|
||||
|
||||
sClientMap.put(aslSession.getScope(), sClient);
|
||||
session.setAttribute(Constants.SClientMap, sClientMap);
|
||||
} else {
|
||||
if (obj instanceof HashMap<?, ?>) {
|
||||
@SuppressWarnings("unchecked")
|
||||
HashMap<String,SClient> sClientMap=(HashMap<String,SClient>) obj;
|
||||
if(sClientMap.containsKey(aslSession.getScope())){
|
||||
HashMap<String, SClient> sClientMap = (HashMap<String, SClient>) obj;
|
||||
if (sClientMap.containsKey(aslSession.getScope())) {
|
||||
logger.info("Use SClient in session");
|
||||
sClient=sClientMap.get(aslSession.getScope());
|
||||
sClient = sClientMap.get(aslSession.getScope());
|
||||
} else {
|
||||
logger.info("Create new SClient");
|
||||
ServiceCredential serviceCredential=new ServiceCredential(aslSession.getUsername(), aslSession.getScope(),
|
||||
ServiceCredential serviceCredential = new ServiceCredential(
|
||||
aslSession.getUsername(), aslSession.getScope(),
|
||||
SessionUtil.getToken(aslSession));
|
||||
SClientBuilder sBuilder = new SClient4WPSBuilder(serviceCredential);
|
||||
SClientBuilder sBuilder = new SClient4WPSBuilder(
|
||||
serviceCredential);
|
||||
|
||||
SClientDirector director = new SClientDirector();
|
||||
director.setSClientBuilder(sBuilder);
|
||||
|
@ -130,10 +144,11 @@ public class SessionUtil {
|
|||
sClientMap.put(aslSession.getScope(), sClient);
|
||||
session.setAttribute(Constants.SClientMap, sClientMap);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
logger.error("Attention no SClientMap in Session!");
|
||||
throw new ServiceException("Sign Out, portlet is changed, a new session is required!");
|
||||
throw new ServiceException(
|
||||
"Sign Out, portlet is changed, a new session is required!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import junit.framework.TestCase;
|
|||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.common.authorization.library.provider.UserInfo;
|
||||
import org.gcube.portlets.user.dataminermanager.server.is.InformationSystemUtils;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -61,8 +62,18 @@ public class TestDataMinerService extends TestCase {
|
|||
* if (aslSession.getUsername().compareTo("lucio.lelii") == 0)
|
||||
* userRoles.add("VRE-Manager");
|
||||
*/
|
||||
wpsToken = authorizationService().build().generate(wpsUser,
|
||||
userRoles);
|
||||
|
||||
try {
|
||||
wpsToken = authorizationService().generateUserToken(
|
||||
new UserInfo(aslSession.getUsername(), userRoles),
|
||||
aslSession.getScope());
|
||||
} catch (Exception e) {
|
||||
logger.error("Error generating the token for test: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new Exception("Error generating the token for test: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
List<String> serviceAddress = InformationSystemUtils
|
||||
.retrieveServiceAddress(
|
||||
|
|
Loading…
Reference in New Issue