Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3B03A200D64 for ; Mon, 11 Dec 2017 20:56:15 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 39C3D160C28; Mon, 11 Dec 2017 19:56:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 88325160C03 for ; Mon, 11 Dec 2017 20:56:14 +0100 (CET) Received: (qmail 27215 invoked by uid 500); 11 Dec 2017 19:56:13 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 27174 invoked by uid 99); 11 Dec 2017 19:56:13 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Dec 2017 19:56:13 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 6B8648204F; Mon, 11 Dec 2017 19:56:10 +0000 (UTC) Date: Mon, 11 Dec 2017 19:56:18 +0000 To: "commits@airavata.apache.org" Subject: [airavata] 13/13: Adding GroupManager client sample MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: smarru@apache.org In-Reply-To: <151302216581.5718.9854151141807674870@gitbox.apache.org> References: <151302216581.5718.9854151141807674870@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: airavata X-Git-Refname: refs/heads/develop X-Git-Reftype: branch X-Git-Rev: 4ec92a79afbbcf4ed0c92be69c33379065d60ae4 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20171211195610.6B8648204F@gitbox.apache.org> archived-at: Mon, 11 Dec 2017 19:56:15 -0000 This is an automated email from the ASF dual-hosted git repository. smarru pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/airavata.git commit 4ec92a79afbbcf4ed0c92be69c33379065d60ae4 Author: Sachin Kariyattin AuthorDate: Wed Dec 6 01:38:15 2017 -0500 Adding GroupManager client sample --- .../profile/client/samples/GroupManagerSample.java | 41 ++++++++++++++++++++++ .../client/ProfileServiceClientFactory.java | 15 ++++++++ 2 files changed, 56 insertions(+) diff --git a/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/GroupManagerSample.java b/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/GroupManagerSample.java new file mode 100644 index 0000000..71fdd70 --- /dev/null +++ b/airavata-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/airavata/service/profile/client/samples/GroupManagerSample.java @@ -0,0 +1,41 @@ +package org.apache.airavata.service.profile.client.samples; + +import org.apache.airavata.common.utils.Constants; +import org.apache.airavata.model.security.AuthzToken; +import org.apache.airavata.service.profile.client.ProfileServiceClientFactory; +import org.apache.airavata.service.profile.client.util.ProfileServiceClientUtil; +import org.apache.airavata.service.profile.groupmanager.cpi.GroupManagerService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; + +public class GroupManagerSample { + + private static final Logger logger = LoggerFactory.getLogger(UserProfileSample.class); + private static GroupManagerService.Client groupMangerClient; + private static String testGatewayId = "test-gateway-465"; + private static AuthzToken authzToken = new AuthzToken("empy_token"); + + public static void main(String args[]) throws Exception { + try { + String profileServiceServerHost = ProfileServiceClientUtil.getProfileServiceServerHost(); + int profileServiceServerPort = ProfileServiceClientUtil.getProfileServiceServerPort(); + + groupMangerClient = ProfileServiceClientFactory.createGroupManagerServiceClient(profileServiceServerHost, profileServiceServerPort); + Map claimsMap = new HashMap<>(); + claimsMap.put(Constants.GATEWAY_ID,testGatewayId); + authzToken.setClaimsMap(claimsMap); + + //NOTE: Only these two methods can be tested as other methods require us to create a group. + // createGroup() needs createUser() to be executed. Currently ownerId is set from createUser() + // method which requires a sharingServiceClient. Hence, verifying only this method for now. + System.out.println("hasAdminAccess() should return [false]: "+ groupMangerClient.hasAdminAccess(authzToken,"test-group-1", "test-user-1")); + } + catch (Exception ex) { + ex.printStackTrace(); + logger.error("GroupManager client-sample Exception: " + ex, ex); + } + } +} diff --git a/airavata-services/profile-service/profile-service-stubs/src/main/java/org/apache/airavata/service/profile/client/ProfileServiceClientFactory.java b/airavata-services/profile-service/profile-service-stubs/src/main/java/org/apache/airavata/service/profile/client/ProfileServiceClientFactory.java index f41bc77..f447327 100644 --- a/airavata-services/profile-service/profile-service-stubs/src/main/java/org/apache/airavata/service/profile/client/ProfileServiceClientFactory.java +++ b/airavata-services/profile-service/profile-service-stubs/src/main/java/org/apache/airavata/service/profile/client/ProfileServiceClientFactory.java @@ -20,6 +20,9 @@ */ package org.apache.airavata.service.profile.client; +import org.apache.airavata.service.profile.groupmanager.cpi.GroupManagerService; +import org.apache.airavata.service.profile.groupmanager.cpi.exception.GroupManagerServiceException; +import org.apache.airavata.service.profile.groupmanager.cpi.group_manager_cpiConstants; import org.apache.airavata.service.profile.iam.admin.services.cpi.IamAdminServices; import org.apache.airavata.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException; import org.apache.airavata.service.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants; @@ -75,4 +78,16 @@ public class ProfileServiceClientFactory { throw new IamAdminServicesException(e.getMessage()); } } + + public static GroupManagerService.Client createGroupManagerServiceClient(String serverHost, int serverPort) throws GroupManagerServiceException { + try { + TTransport transport = new TSocket(serverHost, serverPort); + transport.open(); + TProtocol protocol = new TBinaryProtocol(transport); + TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, group_manager_cpiConstants.GROUP_MANAGER_CPI_NAME); + return new GroupManagerService.Client(multiplexedProtocol); + } catch (TTransportException e) { + throw new GroupManagerServiceException(e.getMessage()); + } + } } \ No newline at end of file -- To stop receiving notification emails like this one, please contact "commits@airavata.apache.org" .