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 B562B200C00 for ; Tue, 13 Dec 2016 17:14:29 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B4147160B37; Tue, 13 Dec 2016 16:14:29 +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 C7562160B3B for ; Tue, 13 Dec 2016 17:14:28 +0100 (CET) Received: (qmail 53022 invoked by uid 500); 13 Dec 2016 16:14:28 -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 52495 invoked by uid 99); 13 Dec 2016 16:14:27 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Dec 2016 16:14:27 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8DF06F2DCD; Tue, 13 Dec 2016 16:14:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shameera@apache.org To: commits@airavata.apache.org Date: Tue, 13 Dec 2016 16:14:38 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [12/13] airavata git commit: introducing summary type, dependencies and code clean up archived-at: Tue, 13 Dec 2016 16:14:29 -0000 introducing summary type, dependencies and code clean up Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/c1b696ba Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/c1b696ba Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/c1b696ba Branch: refs/heads/develop Commit: c1b696badd3ccfa686cdb21ab2da0012ec7dd354 Parents: 122fb8d Author: Anuj Bhandar Authored: Mon Dec 12 11:58:57 2016 -0500 Committer: Anuj Bhandar Committed: Mon Dec 12 11:58:57 2016 -0500 ---------------------------------------------------------------------- .../server/handler/AiravataServerHandler.java | 68 +- .../java/org/apache/airavata/api/Airavata.java | 766 +++++++----- .../credentialsummary/CredentialSummary.java | 927 --------------- .../credential/store/CredentialSummary.java | 1040 +++++++++++++++++ .../model/credential/store/SummaryType.java | 69 ++ .../server/CredentialStoreServerHandler.java | 143 ++- .../store/cpi/CredentialStoreService.java | 1093 ++++++++++++------ .../airavata-apis/airavata_api.thrift | 36 +- .../component-cpis/credential-store-cpi.thrift | 15 +- .../credential_store_data_models.thrift | 25 +- .../credential_summary.thrift | 33 - .../resource_catalog_models.thrift | 3 +- 12 files changed, 2505 insertions(+), 1713 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/c1b696ba/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java index c3a7dd1..827ba1a 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java @@ -31,10 +31,7 @@ import org.apache.airavata.common.utils.Constants; import org.apache.airavata.common.utils.ServerSettings; import org.apache.airavata.credential.store.client.CredentialStoreClientFactory; import org.apache.airavata.credential.store.cpi.CredentialStoreService; -import org.apache.airavata.model.credential.store.CredentialOwnerType; -import org.apache.airavata.model.credential.store.PasswordCredential; -import org.apache.airavata.model.credential.store.SSHCredential; -import org.apache.airavata.model.credential.store.SSHCredentialSummary; +import org.apache.airavata.model.credential.store.*; import org.apache.airavata.credential.store.exception.CredentialStoreException; import org.apache.airavata.messaging.core.MessageContext; import org.apache.airavata.messaging.core.MessagingFactory; @@ -45,7 +42,7 @@ import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentD import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule; import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription; import org.apache.airavata.model.appcatalog.computeresource.*; -import org.apache.airavata.model.appcatalog.credentialsummary.CredentialSummary; +import org.apache.airavata.model.credential.store.CredentialSummary; import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference; import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile; import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference; @@ -545,25 +542,21 @@ public class AiravataServerHandler implements Airavata.Iface { @Override @SecurityCheck - public List getAllGatewaySSHPubKeysSummary(AuthzToken authzToken, String gatewayId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException { + public List getAllCredentialSummaryForGateway(AuthzToken authzToken, SummaryType type, String gatewayId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException { try { - List allCredentialSummaries = new ArrayList<>(); - if (csClient == null){ - csClient = getCredentialStoreServiceClient(); - } - List sshSummaryList = csClient.getAllGatewaySSHCredentialSummary(gatewayId); - for(SSHCredentialSummary key : sshSummaryList){ - CredentialSummary summary = new CredentialSummary(); - summary.setGatewayId(key.getGatewayId()); - summary.setUsername(key.getUsername()); - summary.setPublicKey(key.getPublicKey()); - summary.setToken(key.getToken()); - summary.setDescription(key.getDescription()); - summary.setPersistedTime(key.getPersistedTime()); - allCredentialSummaries.add(summary); + if(type.equals(SummaryType.SSH)){ + if (csClient == null){ + csClient = getCredentialStoreServiceClient(); + } + logger.debug("Airavata will retrieve all SSH pub keys summaries for gateway Id : " + gatewayId); + return csClient.getAllCredentialSummaryForGateway(type, gatewayId); + } else { + logger.info("Summay Type"+ type.toString() + " not supported by Airavata"); + AiravataSystemException ex = new AiravataSystemException(); + ex.setAiravataErrorType(AiravataErrorType.UNSUPPORTED_OPERATION); + ex.setMessage("Summay Type"+ type.toString() + " not supported by Airavata"); + throw ex; } - logger.debug("Airavata retrieved all SSH pub keys summaries for gateway Id : " + gatewayId); - return allCredentialSummaries; }catch (Exception e){ logger.error("Error occurred while retrieving SSH public keys summaries for gateway : " + gatewayId , e); AiravataSystemException exception = new AiravataSystemException(); @@ -574,25 +567,22 @@ public class AiravataServerHandler implements Airavata.Iface { } @Override - public List getAllSSHPubKeysSummaryForUserInGateway(AuthzToken authzToken, String gatewayId, String userId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException { + @SecurityCheck + public List getAllCredentialSummaryForUsersInGateway(AuthzToken authzToken,SummaryType type, String gatewayId, String userId) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException { try { - List allCredentialSummaries = new ArrayList<>(); - if (csClient == null){ - csClient = getCredentialStoreServiceClient(); - } - List sshSummaryListForUser = csClient.getAllSSHCredentialSummaryForUserInGateway(gatewayId,userId); - for(SSHCredentialSummary key : sshSummaryListForUser){ - CredentialSummary userPubKeySummary = new CredentialSummary(); - userPubKeySummary.setGatewayId(key.getGatewayId()); - userPubKeySummary.setUsername(key.getUsername()); - userPubKeySummary.setPublicKey(key.getPublicKey()); - userPubKeySummary.setToken(key.getToken()); - userPubKeySummary.setDescription(key.getDescription()); - userPubKeySummary.setPersistedTime(key.getPersistedTime()); - allCredentialSummaries.add(userPubKeySummary); + if(type.equals(SummaryType.SSH)){ + if (csClient == null){ + csClient = getCredentialStoreServiceClient(); + } + logger.debug("Airavata will retrieve all SSH pub keys summaries for gateway Id : " + gatewayId); + return csClient.getAllCredentialSummaryForUserInGateway(type, gatewayId, userId); + } else { + logger.info("Summay Type"+ type.toString() + " not supported by Airavata"); + AiravataSystemException ex = new AiravataSystemException(); + ex.setAiravataErrorType(AiravataErrorType.UNSUPPORTED_OPERATION); + ex.setMessage("Summay Type"+ type.toString() + " not supported by Airavata"); + throw ex; } - logger.debug("Airavata retrieved all SSH pub keys summaries for gateway Id : " + gatewayId + " & user ID : " +userId); - return allCredentialSummaries; }catch (Exception e){ logger.error("Error occurred while retrieving SSH public keys summaries for user : " + userId , e); AiravataSystemException exception = new AiravataSystemException();