diff --git a/.classpath b/.classpath index 135f740..ce2d0c9 100644 --- a/.classpath +++ b/.classpath @@ -17,13 +17,13 @@ - + - + diff --git a/pom.xml b/pom.xml index 9d76bf3..ad8f0ef 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ org.gcube.dvos usermanagement-stub - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) @@ -97,85 +97,12 @@ 2.3.0 net.sourceforge.addressing addressing 1.1.1 - - - org.gcube.informationsystem - iscache - [1.2.0-SNAPSHOT,2.0.0-SNAPSHOT) - - - + --> diff --git a/src/main/java/org/gcube/application/framework/core/cache/RIsManager.java b/src/main/java/org/gcube/application/framework/core/cache/RIsManager.java index 988b366..63666d6 100644 --- a/src/main/java/org/gcube/application/framework/core/cache/RIsManager.java +++ b/src/main/java/org/gcube/application/framework/core/cache/RIsManager.java @@ -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 isCaches; - - protected HashMap caches; //(scope,iccache) pairs - - /** Object logger. */ - - protected static final Logger logger = LoggerFactory.getLogger(RIsManager.class); - - /** - * Initializes RIsManager - */ - private RIsManager() { - caches = new HashMap(); - } - - /** - * 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 isCaches; +// +// protected HashMap caches; //(scope,iccache) pairs +// +// /** Object logger. */ +// +// protected static final Logger logger = LoggerFactory.getLogger(RIsManager.class); +// +// /** +// * Initializes RIsManager +// */ +// private RIsManager() { +//// caches = new HashMap(); +// } +// +// /** +// * 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; +// } +// +//} diff --git a/src/main/java/org/gcube/application/framework/core/security/UsersManagementUtils.java b/src/main/java/org/gcube/application/framework/core/security/UsersManagementUtils.java index 06b510b..1c92880 100644 --- a/src/main/java/org/gcube/application/framework/core/security/UsersManagementUtils.java +++ b/src/main/java/org/gcube/application/framework/core/security/UsersManagementUtils.java @@ -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 getAllScopes(ASLSession session) { - EndpointReferenceType endpointUser = new EndpointReferenceType(); - ArrayList groupsNames = new ArrayList(); - 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 groupsNames = new ArrayList(); - 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 listGroupsByUser(String userId) { - EndpointReferenceType endpointUser = new EndpointReferenceType(); - List groupsByUser = new ArrayList(); - 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 listGroups() { - EndpointReferenceType endpointUser = new EndpointReferenceType(); - List groups = new ArrayList(); - 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 groups = new ArrayList(); - 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 getAllScopes(ASLSession session) { +// EndpointReferenceType endpointUser = new EndpointReferenceType(); +// ArrayList groupsNames = new ArrayList(); +// 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 groupsNames = new ArrayList(); +// 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 listGroupsByUser(String userId) { +// EndpointReferenceType endpointUser = new EndpointReferenceType(); +// List groupsByUser = new ArrayList(); +// 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 listGroups() { +// EndpointReferenceType endpointUser = new EndpointReferenceType(); +// List groups = new ArrayList(); +// 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 groups = new ArrayList(); +// 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; +// } +// +// +//} diff --git a/src/main/java/org/gcube/application/framework/core/security/VOMSAdminManager.java b/src/main/java/org/gcube/application/framework/core/security/VOMSAdminManager.java index 261ca9b..6301141 100644 --- a/src/main/java/org/gcube/application/framework/core/security/VOMSAdminManager.java +++ b/src/main/java/org/gcube/application/framework/core/security/VOMSAdminManager.java @@ -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;