nikolas.laskaris 2014-06-03 14:06:52 +00:00
parent e7e5ca1f41
commit c103b97609
5 changed files with 535 additions and 611 deletions

View File

@ -17,13 +17,13 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>

77
pom.xml
View File

@ -43,7 +43,7 @@
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-stub</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
@ -97,85 +97,12 @@
<version>2.3.0</version>
</dependency>
<!--
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.6.0</version>
</dependency>
-->
<dependency>
<groupId>net.sourceforge.addressing</groupId>
<artifactId>addressing</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.gcube.informationsystem</groupId>
<artifactId>iscache</artifactId>
<version>[1.2.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<!--
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.xml.rpc</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>common-gcore-resources</artifactId>
</dependency>
<dependency>
<groupId>backport-util-concurrent</groupId>
<artifactId>backport-util-concurrent</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.dvos.soa3</groupId>
<artifactId>gcube-security-utils</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>[1.0.1-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-gcore-stubs</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>common-gcore-resources</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.personalisation</groupId>
<artifactId>profileadministration-client-library</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.personalisation</groupId>
<artifactId>userprofileaccess-client-library</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
-->
-->
</dependencies>

View File

@ -1,96 +1,96 @@
package org.gcube.application.framework.core.cache;
import java.util.HashMap;
//import org.gcube.common.core.scope.GCUBEScope;
//import org.gcube.common.core.utils.logging.GCUBELog;
//package org.gcube.application.framework.core.cache;
//
//import java.util.HashMap;
////import org.gcube.common.core.scope.GCUBEScope;
////import org.gcube.common.core.utils.logging.GCUBELog;
////import org.gcube.informationsystem.cache.ISCache;
////import org.gcube.informationsystem.cache.ISCacheManager;
//import net.sf.ehcache.Cache;
//import net.sf.ehcache.CacheManager;
//
//import org.gcube.informationsystem.cache.ISCache;
//import org.gcube.informationsystem.cache.ISCacheManager;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import org.gcube.informationsystem.cache.ISCache;
import org.gcube.informationsystem.cache.ISCacheManager;
import org.gcube.resources.discovery.icclient.ICClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class manages the running harvester threads.
*
* @author Valia Tsagkalidou (KNUA)
*
*/
public class RIsManager {
/**
* Defines the manager's instance
*/
private static RIsManager instance = null;
/**
* keeps the ISCache per scope
*/
// protected HashMap<String, ISCache> isCaches;
protected HashMap<String, ISCache> caches; //(scope,iccache) pairs
/** Object logger. */
protected static final Logger logger = LoggerFactory.getLogger(RIsManager.class);
/**
* Initializes RIsManager
*/
private RIsManager() {
caches = new HashMap<String, ISCache>();
}
/**
* Retrieves the singleton
* @return the only instance of RIsManager
*/
synchronized public static RIsManager getInstance() {
if (instance == null)
instance = new RIsManager();
return instance;
}
/**
* @param scope the GGUBEScope for which the RIs are requested
* @return the ISCache for this specific scope
*/
public synchronized ISCache getISCache(String scope)
{
ISCache info = caches.get(scope);
// TODO: UNCOMMENT when ISCache is FeatherWeight Stack compatible
// if(info == null)
// {
// // If the ISCache in not already created, then it creates a new instance and adds it to the HashMap
// try {
// ISCacheManager.addManager(scope);
// info = ISCacheManager.getCacheManager(scope).getManager(scope).getCache();
// caches.put(scope, info);
// try {
// Thread.sleep(5000);
// } catch (InterruptedException e1) {
// logger.error("", e1);
// }
// } catch (Exception e) {
// logger.error("", e);
// }
// }
logger.debug("RI in cache is probably null");
logger.info("RI in cache is probably null");
return info;
}
}
//import org.gcube.resources.discovery.icclient.ICClient;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//
///**
// * This class manages the running harvester threads.
// *
// * @author Valia Tsagkalidou (KNUA)
// *
// */
//
//public class RIsManager {
//
//
// /**
// * Defines the manager's instance
// */
// private static RIsManager instance = null;
//
// /**
// * keeps the ISCache per scope
// */
//
//// protected HashMap<String, ISCache> isCaches;
//
// protected HashMap<String, ISCache> caches; //(scope,iccache) pairs
//
// /** Object logger. */
//
// protected static final Logger logger = LoggerFactory.getLogger(RIsManager.class);
//
// /**
// * Initializes RIsManager
// */
// private RIsManager() {
//// caches = new HashMap<String, ISCache>();
// }
//
// /**
// * Retrieves the singleton
// * @return the only instance of RIsManager
// */
// synchronized public static RIsManager getInstance() {
// if (instance == null)
// instance = new RIsManager();
// return instance;
// }
//
//
// /**
// * @param scope the GGUBEScope for which the RIs are requested
// * @return the ISCache for this specific scope
// */
// public synchronized ISCache getISCache(String scope)
// {
// ISCache info = caches.get(scope);
//
//// TODO: UNCOMMENT when ISCache is FeatherWeight Stack compatible
//
//// if(info == null)
//// {
//// // If the ISCache in not already created, then it creates a new instance and adds it to the HashMap
//// try {
//// ISCacheManager.addManager(scope);
//// info = ISCacheManager.getCacheManager(scope).getManager(scope).getCache();
//// caches.put(scope, info);
//// try {
//// Thread.sleep(5000);
//// } catch (InterruptedException e1) {
//// logger.error("", e1);
//// }
//// } catch (Exception e) {
//// logger.error("", e);
//// }
//// }
//
// logger.debug("RI in cache is probably null");
// logger.info("RI in cache is probably null");
//
// return info;
// }
//
//}

View File

@ -1,437 +1,437 @@
package org.gcube.application.framework.core.security;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.rpc.ServiceException;
import org.apache.axis.message.addressing.AttributedURI;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.apache.axis.types.URI.MalformedURIException;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.util.ASLGroupModel;
import org.gcube.application.framework.core.util.Settings;
import org.gcube.application.framework.core.util.UsersManagementServiceConstants;
import org.gcube.vomanagement.usermanagement.ws.GetGroupParentId;
import org.gcube.vomanagement.usermanagement.ws.GetRootVO;
import org.gcube.vomanagement.usermanagement.ws.GetScope;
import org.gcube.vomanagement.usermanagement.ws.GetUserId;
import org.gcube.vomanagement.usermanagement.ws.GroupModel;
import org.gcube.vomanagement.usermanagement.ws.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.ws.IsRootVO;
import org.gcube.vomanagement.usermanagement.ws.IsVO;
import org.gcube.vomanagement.usermanagement.ws.LiferaySOAPGroupManagerPortType;
import org.gcube.vomanagement.usermanagement.ws.LiferaySOAPUserManagerPortType;
import org.gcube.vomanagement.usermanagement.ws.ListGroups;
import org.gcube.vomanagement.usermanagement.ws.ListGroupsByUser;
import org.gcube.vomanagement.usermanagement.ws.ListGroupsResponse;
import org.gcube.vomanagement.usermanagement.ws.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.ws.service.LiferaySOAPGroupManagerServiceAddressingLocator;
import org.gcube.vomanagement.usermanagement.ws.service.LiferaySOAPUserManagerServiceAddressingLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UsersManagementUtils {
/** The logger. */
private static final Logger logger = LoggerFactory.getLogger(UsersManagementUtils.class);
String umServiceLocation = new String();
public UsersManagementUtils() {
StringBuffer fileData = new StringBuffer(1000);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(Settings.getInstance().getProperty("sharedDir")+ File.separator + "UMServiceLocation.config"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
int numRead = 0;
char[] buf = new char[1024];
try {
while((numRead=reader.read(buf)) != -1){
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
buf = new char[1024];
}
} catch (IOException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
try {
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
umServiceLocation = fileData.toString().trim();
}
public ArrayList<String> getAllScopes(ASLSession session) {
EndpointReferenceType endpointUser = new EndpointReferenceType();
ArrayList<String> groupsNames = new ArrayList<String>();
try {
//endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
} catch (MalformedURIException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
try {
LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
ListGroups groups = new ListGroups();
ListGroupsResponse resGroup = groupStub.listGroups(groups);
GroupModel[] groupList = resGroup.get_return();
for (GroupModel groupModel : groupList) {
logger.info("Group NAME " + groupModel.getGroupName());
GetRootVO rootVO = new GetRootVO();
if (!groupStub.getRootVO(rootVO).get_return().getGroupId().equals(groupModel.getGroupId())) {
String scope = null;
GetScope getScope = new GetScope();
getScope.setArg0(groupModel.getGroupId());
scope = groupStub.getScope(getScope).get_return();
if (scope.startsWith("/"))
groupsNames.add(scope);
}
}
} catch (ServiceException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
return groupsNames;
}
public String getRootVO() {
EndpointReferenceType endpointUser = new EndpointReferenceType();
ArrayList<String> groupsNames = new ArrayList<String>();
try {
//endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
} catch (MalformedURIException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
LiferaySOAPGroupManagerPortType groupStub = null;
try {
groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
} catch (ServiceException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
ListGroups groups = new ListGroups();
try {
ListGroupsResponse resGroup = groupStub.listGroups(groups);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
GetRootVO rootVO = new GetRootVO();
try {
String rootVo = groupStub.getRootVO(rootVO).get_return().getGroupId();
String rootVoName = getScope(rootVo);
logger.info("RootVo returning: " + rootVoName);
return rootVoName;
} catch (GroupRetrievalFault e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
return null;
}
public String getUserId(String username) {
EndpointReferenceType endpointUser = new EndpointReferenceType();
String userId = null;
try {
//endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPUserManager"));
endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPUserManager));
try {
LiferaySOAPUserManagerPortType userManagerStub = new LiferaySOAPUserManagerServiceAddressingLocator().getLiferaySOAPUserManagerPortTypePort(endpointUser);
GetUserId getUserId = new GetUserId();
getUserId.setArg0(username);
userId = userManagerStub.getUserId(getUserId).get_return();
} catch (ServiceException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
} catch (MalformedURIException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
return userId;
}
public List<ASLGroupModel> listGroupsByUser(String userId) {
EndpointReferenceType endpointUser = new EndpointReferenceType();
List<ASLGroupModel> groupsByUser = new ArrayList<ASLGroupModel>();
try {
//endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
} catch (MalformedURIException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
try {
LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
ListGroupsByUser listGroupsByUser = new ListGroupsByUser();
listGroupsByUser.setArg0(userId);
GroupModel[] groups = groupStub.listGroupsByUser(listGroupsByUser).get_return();
if(groups==null)
logger.debug("User is in no group.");
for (int i = 0; i < groups.length; i++) {
ASLGroupModel grm = new ASLGroupModel();
grm.setGroupId(new Long(groups[i].getGroupId()));
grm.setGroupName(groups[i].getGroupName());
grm.setDescription(groups[i].getDescription());
groupsByUser.add(grm);
}
} catch (ServiceException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
return groupsByUser;
}
public List<ASLGroupModel> listGroups() {
EndpointReferenceType endpointUser = new EndpointReferenceType();
List<ASLGroupModel> groups = new ArrayList<ASLGroupModel>();
try {
//endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
} catch (MalformedURIException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
try {
LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
ListGroups listGroups = new ListGroups();
GroupModel[] groupsArray = groupStub.listGroups(listGroups).get_return();
for (int i = 0; i < groupsArray.length; i++) {
ASLGroupModel gm = new ASLGroupModel();
gm.setGroupId(new Long(groupsArray[i].getGroupId()));
gm.setGroupName(groupsArray[i].getGroupName());
gm.setDescription(groupsArray[i].getDescription());
groups.add(gm);
}
} catch (ServiceException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
return groups;
}
public boolean isVO(String groupId) {
EndpointReferenceType endpointUser = new EndpointReferenceType();
List<GroupModel> groups = new ArrayList<GroupModel>();
boolean isVO = false;
try {
//endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
} catch (MalformedURIException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
try {
LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
IsVO isVo = new IsVO();
isVo.setArg0(groupId);
isVO = groupStub.isVO(isVo).get_return();
return isVO;
} catch (ServiceException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (GroupRetrievalFault e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
return false;
}
public boolean isRootVO(String groupId) {
EndpointReferenceType endpointUser = new EndpointReferenceType();
boolean isVO = false;
try {
//endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
} catch (MalformedURIException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
try {
LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
IsRootVO isRootVo = new IsRootVO();
isRootVo.setArg0(groupId);
isVO = groupStub.isRootVO(isRootVo).get_return();
return isVO;
} catch (ServiceException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (GroupRetrievalFault e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
return false;
}
public String getScope(String groupId) {
EndpointReferenceType endpointUser = new EndpointReferenceType();
try {
//endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
} catch (MalformedURIException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
try {
LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
GetScope getScope = new GetScope();
getScope.setArg0(groupId);
String scope = groupStub.getScope(getScope).get_return();
return scope;
} catch (ServiceException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (GroupRetrievalFault e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
return null;
}
public String getGroupParentId(String groupId) {
EndpointReferenceType endpointUser = new EndpointReferenceType();
try {
//endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
} catch (MalformedURIException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
try {
LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
GetGroupParentId getGroupParentId = new GetGroupParentId();
getGroupParentId.setArg0(groupId);
long parentId = groupStub.getGroupParentId(getGroupParentId).get_return();
return Long.toString(parentId);
} catch (ServiceException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (GroupRetrievalFault e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (UserManagementSystemException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
} catch (RemoteException e) {
// TODO Auto-generated catch block
logger.error("Exception:", e);
}
return null;
}
}
//package org.gcube.application.framework.core.security;
//
//import java.io.BufferedReader;
//import java.io.File;
//import java.io.FileNotFoundException;
//import java.io.FileReader;
//import java.io.IOException;
//import java.rmi.RemoteException;
//import java.util.ArrayList;
//import java.util.List;
//
//import javax.xml.rpc.ServiceException;
//
//import org.apache.axis.message.addressing.AttributedURI;
//import org.apache.axis.message.addressing.EndpointReferenceType;
//import org.apache.axis.types.URI.MalformedURIException;
//import org.gcube.application.framework.core.session.ASLSession;
//import org.gcube.application.framework.core.util.ASLGroupModel;
//import org.gcube.application.framework.core.util.Settings;
//import org.gcube.application.framework.core.util.UsersManagementServiceConstants;
//import org.gcube.vomanagement.usermanagement.ws.GetGroupParentId;
//import org.gcube.vomanagement.usermanagement.ws.GetRootVO;
//import org.gcube.vomanagement.usermanagement.ws.GetScope;
//import org.gcube.vomanagement.usermanagement.ws.GetUserId;
//import org.gcube.vomanagement.usermanagement.ws.GroupModel;
//import org.gcube.vomanagement.usermanagement.ws.GroupRetrievalFault;
//import org.gcube.vomanagement.usermanagement.ws.IsRootVO;
//import org.gcube.vomanagement.usermanagement.ws.IsVO;
//import org.gcube.vomanagement.usermanagement.ws.LiferaySOAPGroupManagerPortType;
//import org.gcube.vomanagement.usermanagement.ws.LiferaySOAPUserManagerPortType;
//import org.gcube.vomanagement.usermanagement.ws.ListGroups;
//import org.gcube.vomanagement.usermanagement.ws.ListGroupsByUser;
//import org.gcube.vomanagement.usermanagement.ws.ListGroupsResponse;
//import org.gcube.vomanagement.usermanagement.ws.UserManagementSystemException;
//import org.gcube.vomanagement.usermanagement.ws.service.LiferaySOAPGroupManagerServiceAddressingLocator;
//import org.gcube.vomanagement.usermanagement.ws.service.LiferaySOAPUserManagerServiceAddressingLocator;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//public class UsersManagementUtils {
//
// /** The logger. */
// private static final Logger logger = LoggerFactory.getLogger(UsersManagementUtils.class);
//
// String umServiceLocation = new String();
//
// public UsersManagementUtils() {
// StringBuffer fileData = new StringBuffer(1000);
// BufferedReader reader = null;
// try {
// reader = new BufferedReader(new FileReader(Settings.getInstance().getProperty("sharedDir")+ File.separator + "UMServiceLocation.config"));
// } catch (FileNotFoundException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// int numRead = 0;
// char[] buf = new char[1024];
// try {
// while((numRead=reader.read(buf)) != -1){
// String readData = String.valueOf(buf, 0, numRead);
// fileData.append(readData);
// buf = new char[1024];
// }
// } catch (IOException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// try {
// reader.close();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// umServiceLocation = fileData.toString().trim();
// }
//
// public ArrayList<String> getAllScopes(ASLSession session) {
// EndpointReferenceType endpointUser = new EndpointReferenceType();
// ArrayList<String> groupsNames = new ArrayList<String>();
// try {
// //endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
// endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
// } catch (MalformedURIException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
// try {
// LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
// ListGroups groups = new ListGroups();
//
// ListGroupsResponse resGroup = groupStub.listGroups(groups);
//
// GroupModel[] groupList = resGroup.get_return();
//
// for (GroupModel groupModel : groupList) {
// logger.info("Group NAME " + groupModel.getGroupName());
//
// GetRootVO rootVO = new GetRootVO();
// if (!groupStub.getRootVO(rootVO).get_return().getGroupId().equals(groupModel.getGroupId())) {
// String scope = null;
//
// GetScope getScope = new GetScope();
// getScope.setArg0(groupModel.getGroupId());
// scope = groupStub.getScope(getScope).get_return();
//
// if (scope.startsWith("/"))
// groupsNames.add(scope);
// }
// }
//
// } catch (ServiceException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// return groupsNames;
//
// }
//
//
// public String getRootVO() {
//
// EndpointReferenceType endpointUser = new EndpointReferenceType();
// ArrayList<String> groupsNames = new ArrayList<String>();
// try {
// //endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
// endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
// } catch (MalformedURIException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
// LiferaySOAPGroupManagerPortType groupStub = null;
// try {
// groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
// } catch (ServiceException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// ListGroups groups = new ListGroups();
//
// try {
// ListGroupsResponse resGroup = groupStub.listGroups(groups);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// GetRootVO rootVO = new GetRootVO();
// try {
// String rootVo = groupStub.getRootVO(rootVO).get_return().getGroupId();
// String rootVoName = getScope(rootVo);
// logger.info("RootVo returning: " + rootVoName);
// return rootVoName;
// } catch (GroupRetrievalFault e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// return null;
// }
//
//
// public String getUserId(String username) {
// EndpointReferenceType endpointUser = new EndpointReferenceType();
// String userId = null;
// try {
// //endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPUserManager"));
// endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPUserManager));
//
// try {
// LiferaySOAPUserManagerPortType userManagerStub = new LiferaySOAPUserManagerServiceAddressingLocator().getLiferaySOAPUserManagerPortTypePort(endpointUser);
// GetUserId getUserId = new GetUserId();
// getUserId.setArg0(username);
// userId = userManagerStub.getUserId(getUserId).get_return();
// } catch (ServiceException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// } catch (MalformedURIException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// return userId;
// }
//
//
// public List<ASLGroupModel> listGroupsByUser(String userId) {
// EndpointReferenceType endpointUser = new EndpointReferenceType();
// List<ASLGroupModel> groupsByUser = new ArrayList<ASLGroupModel>();
// try {
// //endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
// endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
// } catch (MalformedURIException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
// try {
// LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
// ListGroupsByUser listGroupsByUser = new ListGroupsByUser();
// listGroupsByUser.setArg0(userId);
// GroupModel[] groups = groupStub.listGroupsByUser(listGroupsByUser).get_return();
// if(groups==null)
// logger.debug("User is in no group.");
// for (int i = 0; i < groups.length; i++) {
// ASLGroupModel grm = new ASLGroupModel();
// grm.setGroupId(new Long(groups[i].getGroupId()));
// grm.setGroupName(groups[i].getGroupName());
// grm.setDescription(groups[i].getDescription());
// groupsByUser.add(grm);
// }
//
// } catch (ServiceException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// return groupsByUser;
// }
//
//
// public List<ASLGroupModel> listGroups() {
// EndpointReferenceType endpointUser = new EndpointReferenceType();
// List<ASLGroupModel> groups = new ArrayList<ASLGroupModel>();
// try {
// //endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
// endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
// } catch (MalformedURIException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
// try {
// LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
// ListGroups listGroups = new ListGroups();
// GroupModel[] groupsArray = groupStub.listGroups(listGroups).get_return();
// for (int i = 0; i < groupsArray.length; i++) {
// ASLGroupModel gm = new ASLGroupModel();
// gm.setGroupId(new Long(groupsArray[i].getGroupId()));
// gm.setGroupName(groupsArray[i].getGroupName());
// gm.setDescription(groupsArray[i].getDescription());
// groups.add(gm);
// }
//
// } catch (ServiceException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// return groups;
// }
//
//
// public boolean isVO(String groupId) {
// EndpointReferenceType endpointUser = new EndpointReferenceType();
// List<GroupModel> groups = new ArrayList<GroupModel>();
// boolean isVO = false;
// try {
// //endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
// endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
// } catch (MalformedURIException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
//
// try {
// LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
//
// IsVO isVo = new IsVO();
// isVo.setArg0(groupId);
// isVO = groupStub.isVO(isVo).get_return();
// return isVO;
// } catch (ServiceException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (GroupRetrievalFault e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// return false;
// }
//
//
// public boolean isRootVO(String groupId) {
// EndpointReferenceType endpointUser = new EndpointReferenceType();
// boolean isVO = false;
// try {
// //endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
// endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
// } catch (MalformedURIException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
//
// try {
// LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
//
// IsRootVO isRootVo = new IsRootVO();
// isRootVo.setArg0(groupId);
// isVO = groupStub.isRootVO(isRootVo).get_return();
// return isVO;
// } catch (ServiceException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (GroupRetrievalFault e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// return false;
// }
//
//
// public String getScope(String groupId) {
// EndpointReferenceType endpointUser = new EndpointReferenceType();
// try {
// //endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
// endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
// } catch (MalformedURIException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
// try {
// LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
//
// GetScope getScope = new GetScope();
// getScope.setArg0(groupId);
// String scope = groupStub.getScope(getScope).get_return();
// return scope;
// } catch (ServiceException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (GroupRetrievalFault e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// return null;
// }
//
//
// public String getGroupParentId(String groupId) {
// EndpointReferenceType endpointUser = new EndpointReferenceType();
// try {
// //endpointUser.setAddress(new AttributedURI("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager"));
// endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager));
// } catch (MalformedURIException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
// LiferaySOAPGroupManagerServiceAddressingLocator loc = new LiferaySOAPGroupManagerServiceAddressingLocator();
// try {
// LiferaySOAPGroupManagerPortType groupStub = loc.getLiferaySOAPGroupManagerPortTypePort(endpointUser);
//
// GetGroupParentId getGroupParentId = new GetGroupParentId();
// getGroupParentId.setArg0(groupId);
// long parentId = groupStub.getGroupParentId(getGroupParentId).get_return();
// return Long.toString(parentId);
// } catch (ServiceException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (GroupRetrievalFault e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (UserManagementSystemException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// } catch (RemoteException e) {
// // TODO Auto-generated catch block
// logger.error("Exception:", e);
// }
//
// return null;
// }
//
//
//}

View File

@ -3,9 +3,6 @@ package org.gcube.application.framework.core.security;
import java.io.File;
import javax.xml.rpc.ServiceException;
//import javax.xml.rpc.ServiceException;
import org.gcube.application.framework.core.util.Settings;
//import org.gcube.vomanagement.vomsapi.ExtendedVOMSAdmin;