From 70d83b5d5d2445ed24f0a528a031c3f99fde3229 Mon Sep 17 00:00:00 2001 From: Rena Tsantouli Date: Thu, 7 Jul 2011 09:57:09 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerCore@42163 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../core/security/UsersManagementUtils.java | 87 +++++++++++++++---- 1 file changed, 69 insertions(+), 18 deletions(-) diff --git a/src/org/gcube/application/framework/core/security/UsersManagementUtils.java b/src/org/gcube/application/framework/core/security/UsersManagementUtils.java index 267a4c8..12b1b9d 100644 --- a/src/org/gcube/application/framework/core/security/UsersManagementUtils.java +++ b/src/org/gcube/application/framework/core/security/UsersManagementUtils.java @@ -1,5 +1,13 @@ package org.gcube.application.framework.core.security; +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.List; @@ -11,6 +19,8 @@ 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; @@ -30,11 +40,44 @@ import org.gcube.vomanagement.usermanagement.ws.service.LiferaySOAPUserManagerSe public class UsersManagementUtils { - public static ArrayList getAllScopes(ASLSession session) { + 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 + e.printStackTrace(); + } + 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 + e.printStackTrace(); + } + try { + reader.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + 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("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager")); + endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager)); } catch (MalformedURIException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -80,12 +123,13 @@ public class UsersManagementUtils { } - public static String getRootVO() { + 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("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager")); + endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager)); } catch (MalformedURIException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -130,11 +174,12 @@ public class UsersManagementUtils { } - public static String getUserId(String username) { + 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("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPUserManager")); + endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPUserManager)); try { LiferaySOAPUserManagerPortType userManagerStub = new LiferaySOAPUserManagerServiceAddressingLocator().getLiferaySOAPUserManagerPortTypePort(endpointUser); @@ -160,11 +205,12 @@ public class UsersManagementUtils { } - public static List listGroupsByUser(String 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("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager")); + endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager)); } catch (MalformedURIException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -198,11 +244,12 @@ public class UsersManagementUtils { } - public static List listGroups() { + 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("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager")); + endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager)); } catch (MalformedURIException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -235,12 +282,13 @@ public class UsersManagementUtils { } - public static boolean isVO(String groupId) { + 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("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager")); + endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager)); } catch (MalformedURIException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -272,11 +320,12 @@ public class UsersManagementUtils { } - public static boolean isRootVO(String groupId) { + 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("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager")); + endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager)); } catch (MalformedURIException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -308,10 +357,11 @@ public class UsersManagementUtils { } - public static String getScope(String groupId) { + 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("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager")); + endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager)); } catch (MalformedURIException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -342,10 +392,11 @@ public class UsersManagementUtils { } - public static String getGroupParentId(String groupId) { + 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("http://dl10.di.uoa.gr:8181/usermanagement-ws/LiferaySOAPGroupManager")); + endpointUser.setAddress(new AttributedURI(umServiceLocation + UsersManagementServiceConstants.LiferaySOAPGroupManager)); } catch (MalformedURIException e) { // TODO Auto-generated catch block e.printStackTrace();