From 2e05c239eb46ff2e21fe62fbe94466b225c57a7b Mon Sep 17 00:00:00 2001 From: Marcus Christie Date: Tue, 29 Nov 2016 09:30:00 -0500 Subject: [PATCH] AIRAVATA-2232 Add CredentialOwnerType to credential model Added date stripping from Thrift generated stub classes to credential-store-stubs/pom.xml. --- .../server/handler/AiravataServerHandler.java | 28 +- airavata-api/airavata-api-stubs/pom.xml | 7 +- .../org/apache/airavata/api/Airavata.java | 1806 +++-------------- .../resources/lib/Airavata/API/Airavata.php | 409 +--- .../Airavata/Model/Credential/Store/Types.php | 32 + .../store/credential/Credential.java | 4 + .../store/credential/CredentialOwnerType.java | 28 + .../server/CredentialStoreServerHandler.java | 12 +- .../store/store/impl/db/CredentialsDAO.java | 15 +- .../store/impl/db/CredentialsDAOTest.java | 7 + .../credential-store-stubs/pom.xml | 24 + .../store/cpi/CredentialStoreService.java | 2 +- .../store/datamodel/APICredential.java | 2 +- .../datamodel/CertificateCredential.java | 2 +- .../store/datamodel/CommunityUser.java | 2 +- .../store/datamodel/CredentialOwnerType.java | 61 + .../store/datamodel/PasswordCredential.java | 2 +- .../store/datamodel/SSHCredential.java | 136 +- .../store/datamodel/SSHCredentialSummary.java | 2 +- .../exception/CredentialStoreException.java | 2 +- .../src/main/resources/credstore-derby.sql | 2 + .../src/main/resources/credstore-mysql.sql | 2 + .../airavata-apis/airavata_api.thrift | 38 +- .../credential_store_data_models.thrift | 8 +- .../generate-thrift-stubs.sh | 24 - 25 files changed, 635 insertions(+), 2022 deletions(-) create mode 100644 modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/credential/CredentialOwnerType.java create mode 100644 modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CredentialOwnerType.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 f90517a3c5..10d2217d18 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,6 +31,7 @@ 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.credential.store.datamodel.CredentialOwnerType; import org.apache.airavata.credential.store.datamodel.PasswordCredential; import org.apache.airavata.credential.store.datamodel.SSHCredential; import org.apache.airavata.credential.store.datamodel.SSHCredentialSummary; @@ -441,7 +442,7 @@ public List getAllNotifications(AuthzToken authzToken, String gate @Override @SecurityCheck - public String generateAndRegisterSSHKeys(AuthzToken authzToken, String gatewayId, String userName) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException { + public String generateAndRegisterSSHKeys(AuthzToken authzToken, String gatewayId, String userName, String description, CredentialOwnerType credentialOwnerType) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException { try { if (csClient == null){ csClient = getCredentialStoreServiceClient(); @@ -449,29 +450,10 @@ public String generateAndRegisterSSHKeys(AuthzToken authzToken, String gatewayId SSHCredential sshCredential = new SSHCredential(); sshCredential.setUsername(userName); sshCredential.setGatewayId(gatewayId); - String key = csClient.addSSHCredential(sshCredential); - logger.debug("Airavata generated SSH keys for gateway : " + gatewayId + " and for user : " + userName); - return key; - }catch (Exception e){ - logger.error("Error occurred while registering SSH Credential", e); - AiravataSystemException exception = new AiravataSystemException(); - exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR); - exception.setMessage("Error occurred while registering SSH Credential. More info : " + e.getMessage()); - throw exception; - } - } - - @Override - @SecurityCheck - public String generateAndRegisterSSHKeysWithDescription(AuthzToken authzToken, String gatewayId, String userName, String desc) throws InvalidRequestException, AiravataClientException, AiravataSystemException, TException { - try { - if (csClient == null){ - csClient = getCredentialStoreServiceClient(); + sshCredential.setDescription(description); + if (credentialOwnerType != null) { + sshCredential.setCredentialOwnerType(credentialOwnerType); } - SSHCredential sshCredential = new SSHCredential(); - sshCredential.setUsername(userName); - sshCredential.setGatewayId(gatewayId); - sshCredential.setDescription(desc); String key = csClient.addSSHCredential(sshCredential); logger.debug("Airavata generated SSH keys for gateway : " + gatewayId + " and for user : " + userName); return key; diff --git a/airavata-api/airavata-api-stubs/pom.xml b/airavata-api/airavata-api-stubs/pom.xml index 7dbf8d4d43..0e23ec34c2 100644 --- a/airavata-api/airavata-api-stubs/pom.xml +++ b/airavata-api/airavata-api-stubs/pom.xml @@ -25,11 +25,16 @@ http://airavata.apache.org/ - + org.apache.airavata airavata-data-models ${project.version} + + org.apache.airavata + airavata-credential-store-stubs + ${project.version} + org.apache.thrift libthrift diff --git a/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java b/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java index 1b5a878b69..78d2810125 100644 --- a/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java +++ b/airavata-api/airavata-api-stubs/src/main/java/org/apache/airavata/api/Airavata.java @@ -208,28 +208,6 @@ public interface Iface { public List getAllNotifications(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException; - /** - * Generate and Register SSH Key Pair with Airavata Credential Store. - * - * @param gatewayId - * The identifier for the requested Gateway. - * - * @param userName - * The User for which the credential should be registered. For community accounts, this user is the name of the - * community user name. For computational resources, this user name need not be the same user name on resoruces. - * - * @return airavataCredStoreToken - * An SSH Key pair is generated and stored in the credential store and associated with users or community account - * belonging to a Gateway. - * - * - * - * @param authzToken - * @param gatewayId - * @param userName - */ - public String generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException; - /** * Generate and Register SSH Key Pair with Airavata Credential Store. * @@ -243,6 +221,9 @@ public interface Iface { * @param description * The description field for a credential type, all type of credential can have a description. * + * @param credentialOwnerType + * The type of owner of this credential. Two possible values: GATEWAY (default) and USER + * * @return airavataCredStoreToken * An SSH Key pair is generated and stored in the credential store and associated with users or community account * belonging to a Gateway. @@ -253,8 +234,9 @@ public interface Iface { * @param gatewayId * @param userName * @param description + * @param credentialOwnerType */ - public String generateAndRegisterSSHKeysWithDescription(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException; + public String generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description, org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException; /** * Generate and Register Username PWD Pair with Airavata Credential Store. @@ -3051,9 +3033,7 @@ public interface AsyncIface { public void getAllNotifications(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - public void generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - - public void generateAndRegisterSSHKeysWithDescription(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description, org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void registerPwdCredential(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String portalUserName, String loginUserName, String password, String description, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -3891,18 +3871,20 @@ public List recv_getAllNotific throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getAllNotifications failed: unknown result"); } - public String generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException + public String generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description, org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException { - send_generateAndRegisterSSHKeys(authzToken, gatewayId, userName); + send_generateAndRegisterSSHKeys(authzToken, gatewayId, userName, description, credentialOwnerType); return recv_generateAndRegisterSSHKeys(); } - public void send_generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName) throws org.apache.thrift.TException + public void send_generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description, org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType) throws org.apache.thrift.TException { generateAndRegisterSSHKeys_args args = new generateAndRegisterSSHKeys_args(); args.setAuthzToken(authzToken); args.setGatewayId(gatewayId); args.setUserName(userName); + args.setDescription(description); + args.setCredentialOwnerType(credentialOwnerType); sendBase("generateAndRegisterSSHKeys", args); } @@ -3925,41 +3907,6 @@ public String recv_generateAndRegisterSSHKeys() throws org.apache.airavata.model throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "generateAndRegisterSSHKeys failed: unknown result"); } - public String generateAndRegisterSSHKeysWithDescription(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException - { - send_generateAndRegisterSSHKeysWithDescription(authzToken, gatewayId, userName, description); - return recv_generateAndRegisterSSHKeysWithDescription(); - } - - public void send_generateAndRegisterSSHKeysWithDescription(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description) throws org.apache.thrift.TException - { - generateAndRegisterSSHKeysWithDescription_args args = new generateAndRegisterSSHKeysWithDescription_args(); - args.setAuthzToken(authzToken); - args.setGatewayId(gatewayId); - args.setUserName(userName); - args.setDescription(description); - sendBase("generateAndRegisterSSHKeysWithDescription", args); - } - - public String recv_generateAndRegisterSSHKeysWithDescription() throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException - { - generateAndRegisterSSHKeysWithDescription_result result = new generateAndRegisterSSHKeysWithDescription_result(); - receiveBase(result, "generateAndRegisterSSHKeysWithDescription"); - if (result.isSetSuccess()) { - return result.success; - } - if (result.ire != null) { - throw result.ire; - } - if (result.ace != null) { - throw result.ace; - } - if (result.ase != null) { - throw result.ase; - } - throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "generateAndRegisterSSHKeysWithDescription failed: unknown result"); - } - public String registerPwdCredential(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String portalUserName, String loginUserName, String password, String description) throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException { send_registerPwdCredential(authzToken, gatewayId, portalUserName, loginUserName, password, description); @@ -10142,71 +10089,36 @@ public List getResult() throws } } - public void generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + public void generateAndRegisterSSHKeys(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description, org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); - generateAndRegisterSSHKeys_call method_call = new generateAndRegisterSSHKeys_call(authzToken, gatewayId, userName, resultHandler, this, ___protocolFactory, ___transport); + generateAndRegisterSSHKeys_call method_call = new generateAndRegisterSSHKeys_call(authzToken, gatewayId, userName, description, credentialOwnerType, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class generateAndRegisterSSHKeys_call extends org.apache.thrift.async.TAsyncMethodCall { - private org.apache.airavata.model.security.AuthzToken authzToken; - private String gatewayId; - private String userName; - public generateAndRegisterSSHKeys_call(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { - super(client, protocolFactory, transport, resultHandler, false); - this.authzToken = authzToken; - this.gatewayId = gatewayId; - this.userName = userName; - } - - public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { - prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("generateAndRegisterSSHKeys", org.apache.thrift.protocol.TMessageType.CALL, 0)); - generateAndRegisterSSHKeys_args args = new generateAndRegisterSSHKeys_args(); - args.setAuthzToken(authzToken); - args.setGatewayId(gatewayId); - args.setUserName(userName); - args.write(prot); - prot.writeMessageEnd(); - } - - public String getResult() throws org.apache.airavata.model.error.InvalidRequestException, org.apache.airavata.model.error.AiravataClientException, org.apache.airavata.model.error.AiravataSystemException, org.apache.thrift.TException { - if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { - throw new IllegalStateException("Method call not finished!"); - } - org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); - org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); - return (new Client(prot)).recv_generateAndRegisterSSHKeys(); - } - } - - public void generateAndRegisterSSHKeysWithDescription(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { - checkReady(); - generateAndRegisterSSHKeysWithDescription_call method_call = new generateAndRegisterSSHKeysWithDescription_call(authzToken, gatewayId, userName, description, resultHandler, this, ___protocolFactory, ___transport); - this.___currentMethod = method_call; - ___manager.call(method_call); - } - - public static class generateAndRegisterSSHKeysWithDescription_call extends org.apache.thrift.async.TAsyncMethodCall { private org.apache.airavata.model.security.AuthzToken authzToken; private String gatewayId; private String userName; private String description; - public generateAndRegisterSSHKeysWithDescription_call(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + private org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType; + public generateAndRegisterSSHKeys_call(org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, String userName, String description, org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.authzToken = authzToken; this.gatewayId = gatewayId; this.userName = userName; this.description = description; + this.credentialOwnerType = credentialOwnerType; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { - prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("generateAndRegisterSSHKeysWithDescription", org.apache.thrift.protocol.TMessageType.CALL, 0)); - generateAndRegisterSSHKeysWithDescription_args args = new generateAndRegisterSSHKeysWithDescription_args(); + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("generateAndRegisterSSHKeys", org.apache.thrift.protocol.TMessageType.CALL, 0)); + generateAndRegisterSSHKeys_args args = new generateAndRegisterSSHKeys_args(); args.setAuthzToken(authzToken); args.setGatewayId(gatewayId); args.setUserName(userName); args.setDescription(description); + args.setCredentialOwnerType(credentialOwnerType); args.write(prot); prot.writeMessageEnd(); } @@ -10217,7 +10129,7 @@ public String getResult() throws org.apache.airavata.model.error.InvalidRequestE } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); - return (new Client(prot)).recv_generateAndRegisterSSHKeysWithDescription(); + return (new Client(prot)).recv_generateAndRegisterSSHKeys(); } } @@ -16029,7 +15941,6 @@ protected Processor(I iface, Map extends org.apache.thrift.ProcessFunction { - public generateAndRegisterSSHKeysWithDescription() { - super("generateAndRegisterSSHKeysWithDescription"); - } - - public generateAndRegisterSSHKeysWithDescription_args getEmptyArgsInstance() { - return new generateAndRegisterSSHKeysWithDescription_args(); - } - - protected boolean isOneway() { - return false; - } - - public generateAndRegisterSSHKeysWithDescription_result getResult(I iface, generateAndRegisterSSHKeysWithDescription_args args) throws org.apache.thrift.TException { - generateAndRegisterSSHKeysWithDescription_result result = new generateAndRegisterSSHKeysWithDescription_result(); - try { - result.success = iface.generateAndRegisterSSHKeysWithDescription(args.authzToken, args.gatewayId, args.userName, args.description); + result.success = iface.generateAndRegisterSSHKeys(args.authzToken, args.gatewayId, args.userName, args.description, args.credentialOwnerType); } catch (org.apache.airavata.model.error.InvalidRequestException ire) { result.ire = ire; } catch (org.apache.airavata.model.error.AiravataClientException ace) { @@ -21383,7 +21266,6 @@ protected AsyncProcessor(I iface, Map resultHandler) throws TException { - iface.generateAndRegisterSSHKeys(args.authzToken, args.gatewayId, args.userName,resultHandler); - } - } - - public static class generateAndRegisterSSHKeysWithDescription extends org.apache.thrift.AsyncProcessFunction { - public generateAndRegisterSSHKeysWithDescription() { - super("generateAndRegisterSSHKeysWithDescription"); - } - - public generateAndRegisterSSHKeysWithDescription_args getEmptyArgsInstance() { - return new generateAndRegisterSSHKeysWithDescription_args(); - } - - public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) { - final org.apache.thrift.AsyncProcessFunction fcall = this; - return new AsyncMethodCallback() { - public void onComplete(String o) { - generateAndRegisterSSHKeysWithDescription_result result = new generateAndRegisterSSHKeysWithDescription_result(); - result.success = o; - try { - fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); - return; - } catch (Exception e) { - LOGGER.error("Exception writing to internal frame buffer", e); - } - fb.close(); - } - public void onError(Exception e) { - byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; - org.apache.thrift.TBase msg; - generateAndRegisterSSHKeysWithDescription_result result = new generateAndRegisterSSHKeysWithDescription_result(); - if (e instanceof org.apache.airavata.model.error.InvalidRequestException) { - result.ire = (org.apache.airavata.model.error.InvalidRequestException) e; - result.setIreIsSet(true); - msg = result; - } - else if (e instanceof org.apache.airavata.model.error.AiravataClientException) { - result.ace = (org.apache.airavata.model.error.AiravataClientException) e; - result.setAceIsSet(true); - msg = result; - } - else if (e instanceof org.apache.airavata.model.error.AiravataSystemException) { - result.ase = (org.apache.airavata.model.error.AiravataSystemException) e; - result.setAseIsSet(true); - msg = result; - } - else - { - msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; - msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); - } - try { - fcall.sendResponse(fb,msg,msgType,seqid); - return; - } catch (Exception ex) { - LOGGER.error("Exception writing to internal frame buffer", ex); - } - fb.close(); - } - }; - } - - protected boolean isOneway() { - return false; - } - - public void start(I iface, generateAndRegisterSSHKeysWithDescription_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException { - iface.generateAndRegisterSSHKeysWithDescription(args.authzToken, args.gatewayId, args.userName, args.description,resultHandler); + iface.generateAndRegisterSSHKeys(args.authzToken, args.gatewayId, args.userName, args.description, args.credentialOwnerType,resultHandler); } } @@ -51736,6 +51551,8 @@ public static class generateAndRegisterSSHKeys_args implements org.apache.thrift private static final org.apache.thrift.protocol.TField AUTHZ_TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("authzToken", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.protocol.TField GATEWAY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("gatewayId", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("userName", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField DESCRIPTION_FIELD_DESC = new org.apache.thrift.protocol.TField("description", org.apache.thrift.protocol.TType.STRING, (short)4); + private static final org.apache.thrift.protocol.TField CREDENTIAL_OWNER_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("credentialOwnerType", org.apache.thrift.protocol.TType.I32, (short)5); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -51746,12 +51563,24 @@ public static class generateAndRegisterSSHKeys_args implements org.apache.thrift public org.apache.airavata.model.security.AuthzToken authzToken; // required public String gatewayId; // required public String userName; // required + public String description; // required + /** + * + * @see org.apache.airavata.credential.store.datamodel.CredentialOwnerType + */ + public org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { AUTHZ_TOKEN((short)1, "authzToken"), GATEWAY_ID((short)2, "gatewayId"), - USER_NAME((short)3, "userName"); + USER_NAME((short)3, "userName"), + DESCRIPTION((short)4, "description"), + /** + * + * @see org.apache.airavata.credential.store.datamodel.CredentialOwnerType + */ + CREDENTIAL_OWNER_TYPE((short)5, "credentialOwnerType"); private static final Map byName = new HashMap(); @@ -51772,6 +51601,10 @@ public static _Fields findByThriftId(int fieldId) { return GATEWAY_ID; case 3: // USER_NAME return USER_NAME; + case 4: // DESCRIPTION + return DESCRIPTION; + case 5: // CREDENTIAL_OWNER_TYPE + return CREDENTIAL_OWNER_TYPE; default: return null; } @@ -51821,6 +51654,10 @@ public String getFieldName() { new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("userName", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.DESCRIPTION, new org.apache.thrift.meta_data.FieldMetaData("description", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.CREDENTIAL_OWNER_TYPE, new org.apache.thrift.meta_data.FieldMetaData("credentialOwnerType", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, org.apache.airavata.credential.store.datamodel.CredentialOwnerType.class))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(generateAndRegisterSSHKeys_args.class, metaDataMap); } @@ -51831,12 +51668,16 @@ public generateAndRegisterSSHKeys_args() { public generateAndRegisterSSHKeys_args( org.apache.airavata.model.security.AuthzToken authzToken, String gatewayId, - String userName) + String userName, + String description, + org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType) { this(); this.authzToken = authzToken; this.gatewayId = gatewayId; this.userName = userName; + this.description = description; + this.credentialOwnerType = credentialOwnerType; } /** @@ -51852,6 +51693,12 @@ public generateAndRegisterSSHKeys_args(generateAndRegisterSSHKeys_args other) { if (other.isSetUserName()) { this.userName = other.userName; } + if (other.isSetDescription()) { + this.description = other.description; + } + if (other.isSetCredentialOwnerType()) { + this.credentialOwnerType = other.credentialOwnerType; + } } public generateAndRegisterSSHKeys_args deepCopy() { @@ -51863,6 +51710,8 @@ public void clear() { this.authzToken = null; this.gatewayId = null; this.userName = null; + this.description = null; + this.credentialOwnerType = null; } public org.apache.airavata.model.security.AuthzToken getAuthzToken() { @@ -51937,6 +51786,62 @@ public void setUserNameIsSet(boolean value) { } } + public String getDescription() { + return this.description; + } + + public generateAndRegisterSSHKeys_args setDescription(String description) { + this.description = description; + return this; + } + + public void unsetDescription() { + this.description = null; + } + + /** Returns true if field description is set (has been assigned a value) and false otherwise */ + public boolean isSetDescription() { + return this.description != null; + } + + public void setDescriptionIsSet(boolean value) { + if (!value) { + this.description = null; + } + } + + /** + * + * @see org.apache.airavata.credential.store.datamodel.CredentialOwnerType + */ + public org.apache.airavata.credential.store.datamodel.CredentialOwnerType getCredentialOwnerType() { + return this.credentialOwnerType; + } + + /** + * + * @see org.apache.airavata.credential.store.datamodel.CredentialOwnerType + */ + public generateAndRegisterSSHKeys_args setCredentialOwnerType(org.apache.airavata.credential.store.datamodel.CredentialOwnerType credentialOwnerType) { + this.credentialOwnerType = credentialOwnerType; + return this; + } + + public void unsetCredentialOwnerType() { + this.credentialOwnerType = null; + } + + /** Returns true if field credentialOwnerType is set (has been assigned a value) and false otherwise */ + public boolean isSetCredentialOwnerType() { + return this.credentialOwnerType != null; + } + + public void setCredentialOwnerTypeIsSet(boolean value) { + if (!value) { + this.credentialOwnerType = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case AUTHZ_TOKEN: @@ -51963,6 +51868,22 @@ public void setFieldValue(_Fields field, Object value) { } break; + case DESCRIPTION: + if (value == null) { + unsetDescription(); + } else { + setDescription((String)value); + } + break; + + case CREDENTIAL_OWNER_TYPE: + if (value == null) { + unsetCredentialOwnerType(); + } else { + setCredentialOwnerType((org.apache.airavata.credential.store.datamodel.CredentialOwnerType)value); + } + break; + } } @@ -51977,6 +51898,12 @@ public Object getFieldValue(_Fields field) { case USER_NAME: return getUserName(); + case DESCRIPTION: + return getDescription(); + + case CREDENTIAL_OWNER_TYPE: + return getCredentialOwnerType(); + } throw new IllegalStateException(); } @@ -51994,6 +51921,10 @@ public boolean isSet(_Fields field) { return isSetGatewayId(); case USER_NAME: return isSetUserName(); + case DESCRIPTION: + return isSetDescription(); + case CREDENTIAL_OWNER_TYPE: + return isSetCredentialOwnerType(); } throw new IllegalStateException(); } @@ -52038,6 +51969,24 @@ public boolean equals(generateAndRegisterSSHKeys_args that) { return false; } + boolean this_present_description = true && this.isSetDescription(); + boolean that_present_description = true && that.isSetDescription(); + if (this_present_description || that_present_description) { + if (!(this_present_description && that_present_description)) + return false; + if (!this.description.equals(that.description)) + return false; + } + + boolean this_present_credentialOwnerType = true && this.isSetCredentialOwnerType(); + boolean that_present_credentialOwnerType = true && that.isSetCredentialOwnerType(); + if (this_present_credentialOwnerType || that_present_credentialOwnerType) { + if (!(this_present_credentialOwnerType && that_present_credentialOwnerType)) + return false; + if (!this.credentialOwnerType.equals(that.credentialOwnerType)) + return false; + } + return true; } @@ -52060,6 +52009,16 @@ public int hashCode() { if (present_userName) list.add(userName); + boolean present_description = true && (isSetDescription()); + list.add(present_description); + if (present_description) + list.add(description); + + boolean present_credentialOwnerType = true && (isSetCredentialOwnerType()); + list.add(present_credentialOwnerType); + if (present_credentialOwnerType) + list.add(credentialOwnerType.getValue()); + return list.hashCode(); } @@ -52101,6 +52060,26 @@ public int compareTo(generateAndRegisterSSHKeys_args other) { return lastComparison; } } + lastComparison = Boolean.valueOf(isSetDescription()).compareTo(other.isSetDescription()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDescription()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.description, other.description); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCredentialOwnerType()).compareTo(other.isSetCredentialOwnerType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCredentialOwnerType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.credentialOwnerType, other.credentialOwnerType); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -52144,6 +52123,22 @@ public String toString() { sb.append(this.userName); } first = false; + if (!first) sb.append(", "); + sb.append("description:"); + if (this.description == null) { + sb.append("null"); + } else { + sb.append(this.description); + } + first = false; + if (!first) sb.append(", "); + sb.append("credentialOwnerType:"); + if (this.credentialOwnerType == null) { + sb.append("null"); + } else { + sb.append(this.credentialOwnerType); + } + first = false; sb.append(")"); return sb.toString(); } @@ -52224,6 +52219,22 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, generateAndRegister org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 4: // DESCRIPTION + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.description = iprot.readString(); + struct.setDescriptionIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // CREDENTIAL_OWNER_TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.credentialOwnerType = org.apache.airavata.credential.store.datamodel.CredentialOwnerType.findByValue(iprot.readI32()); + struct.setCredentialOwnerTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -52254,6 +52265,16 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, generateAndRegiste oprot.writeString(struct.userName); oprot.writeFieldEnd(); } + if (struct.description != null) { + oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC); + oprot.writeString(struct.description); + oprot.writeFieldEnd(); + } + if (struct.credentialOwnerType != null) { + oprot.writeFieldBegin(CREDENTIAL_OWNER_TYPE_FIELD_DESC); + oprot.writeI32(struct.credentialOwnerType.getValue()); + oprot.writeFieldEnd(); + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -52274,6 +52295,20 @@ public void write(org.apache.thrift.protocol.TProtocol prot, generateAndRegister struct.authzToken.write(oprot); oprot.writeString(struct.gatewayId); oprot.writeString(struct.userName); + BitSet optionals = new BitSet(); + if (struct.isSetDescription()) { + optionals.set(0); + } + if (struct.isSetCredentialOwnerType()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetDescription()) { + oprot.writeString(struct.description); + } + if (struct.isSetCredentialOwnerType()) { + oprot.writeI32(struct.credentialOwnerType.getValue()); + } } @Override @@ -52286,6 +52321,15 @@ public void read(org.apache.thrift.protocol.TProtocol prot, generateAndRegisterS struct.setGatewayIdIsSet(true); struct.userName = iprot.readString(); struct.setUserNameIsSet(true); + BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.description = iprot.readString(); + struct.setDescriptionIsSet(true); + } + if (incoming.get(1)) { + struct.credentialOwnerType = org.apache.airavata.credential.store.datamodel.CredentialOwnerType.findByValue(iprot.readI32()); + struct.setCredentialOwnerTypeIsSet(true); + } } } @@ -52973,1350 +53017,6 @@ public void read(org.apache.thrift.protocol.TProtocol prot, generateAndRegisterS } - public static class generateAndRegisterSSHKeysWithDescription_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("generateAndRegisterSSHKeysWithDescription_args"); - - private static final org.apache.thrift.protocol.TField AUTHZ_TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("authzToken", org.apache.thrift.protocol.TType.STRUCT, (short)1); - private static final org.apache.thrift.protocol.TField GATEWAY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("gatewayId", org.apache.thrift.protocol.TType.STRING, (short)2); - private static final org.apache.thrift.protocol.TField USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("userName", org.apache.thrift.protocol.TType.STRING, (short)3); - private static final org.apache.thrift.protocol.TField DESCRIPTION_FIELD_DESC = new org.apache.thrift.protocol.TField("description", org.apache.thrift.protocol.TType.STRING, (short)4); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new generateAndRegisterSSHKeysWithDescription_argsStandardSchemeFactory()); - schemes.put(TupleScheme.class, new generateAndRegisterSSHKeysWithDescription_argsTupleSchemeFactory()); - } - - public org.apache.airavata.model.security.AuthzToken authzToken; // required - public String gatewayId; // required - public String userName; // required - public String description; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - AUTHZ_TOKEN((short)1, "authzToken"), - GATEWAY_ID((short)2, "gatewayId"), - USER_NAME((short)3, "userName"), - DESCRIPTION((short)4, "description"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // AUTHZ_TOKEN - return AUTHZ_TOKEN; - case 2: // GATEWAY_ID - return GATEWAY_ID; - case 3: // USER_NAME - return USER_NAME; - case 4: // DESCRIPTION - return DESCRIPTION; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.AUTHZ_TOKEN, new org.apache.thrift.meta_data.FieldMetaData("authzToken", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.security.AuthzToken.class))); - tmpMap.put(_Fields.GATEWAY_ID, new org.apache.thrift.meta_data.FieldMetaData("gatewayId", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("userName", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.DESCRIPTION, new org.apache.thrift.meta_data.FieldMetaData("description", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(generateAndRegisterSSHKeysWithDescription_args.class, metaDataMap); - } - - public generateAndRegisterSSHKeysWithDescription_args() { - } - - public generateAndRegisterSSHKeysWithDescription_args( - org.apache.airavata.model.security.AuthzToken authzToken, - String gatewayId, - String userName, - String description) - { - this(); - this.authzToken = authzToken; - this.gatewayId = gatewayId; - this.userName = userName; - this.description = description; - } - - /** - * Performs a deep copy on other. - */ - public generateAndRegisterSSHKeysWithDescription_args(generateAndRegisterSSHKeysWithDescription_args other) { - if (other.isSetAuthzToken()) { - this.authzToken = new org.apache.airavata.model.security.AuthzToken(other.authzToken); - } - if (other.isSetGatewayId()) { - this.gatewayId = other.gatewayId; - } - if (other.isSetUserName()) { - this.userName = other.userName; - } - if (other.isSetDescription()) { - this.description = other.description; - } - } - - public generateAndRegisterSSHKeysWithDescription_args deepCopy() { - return new generateAndRegisterSSHKeysWithDescription_args(this); - } - - @Override - public void clear() { - this.authzToken = null; - this.gatewayId = null; - this.userName = null; - this.description = null; - } - - public org.apache.airavata.model.security.AuthzToken getAuthzToken() { - return this.authzToken; - } - - public generateAndRegisterSSHKeysWithDescription_args setAuthzToken(org.apache.airavata.model.security.AuthzToken authzToken) { - this.authzToken = authzToken; - return this; - } - - public void unsetAuthzToken() { - this.authzToken = null; - } - - /** Returns true if field authzToken is set (has been assigned a value) and false otherwise */ - public boolean isSetAuthzToken() { - return this.authzToken != null; - } - - public void setAuthzTokenIsSet(boolean value) { - if (!value) { - this.authzToken = null; - } - } - - public String getGatewayId() { - return this.gatewayId; - } - - public generateAndRegisterSSHKeysWithDescription_args setGatewayId(String gatewayId) { - this.gatewayId = gatewayId; - return this; - } - - public void unsetGatewayId() { - this.gatewayId = null; - } - - /** Returns true if field gatewayId is set (has been assigned a value) and false otherwise */ - public boolean isSetGatewayId() { - return this.gatewayId != null; - } - - public void setGatewayIdIsSet(boolean value) { - if (!value) { - this.gatewayId = null; - } - } - - public String getUserName() { - return this.userName; - } - - public generateAndRegisterSSHKeysWithDescription_args setUserName(String userName) { - this.userName = userName; - return this; - } - - public void unsetUserName() { - this.userName = null; - } - - /** Returns true if field userName is set (has been assigned a value) and false otherwise */ - public boolean isSetUserName() { - return this.userName != null; - } - - public void setUserNameIsSet(boolean value) { - if (!value) { - this.userName = null; - } - } - - public String getDescription() { - return this.description; - } - - public generateAndRegisterSSHKeysWithDescription_args setDescription(String description) { - this.description = description; - return this; - } - - public void unsetDescription() { - this.description = null; - } - - /** Returns true if field description is set (has been assigned a value) and false otherwise */ - public boolean isSetDescription() { - return this.description != null; - } - - public void setDescriptionIsSet(boolean value) { - if (!value) { - this.description = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case AUTHZ_TOKEN: - if (value == null) { - unsetAuthzToken(); - } else { - setAuthzToken((org.apache.airavata.model.security.AuthzToken)value); - } - break; - - case GATEWAY_ID: - if (value == null) { - unsetGatewayId(); - } else { - setGatewayId((String)value); - } - break; - - case USER_NAME: - if (value == null) { - unsetUserName(); - } else { - setUserName((String)value); - } - break; - - case DESCRIPTION: - if (value == null) { - unsetDescription(); - } else { - setDescription((String)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case AUTHZ_TOKEN: - return getAuthzToken(); - - case GATEWAY_ID: - return getGatewayId(); - - case USER_NAME: - return getUserName(); - - case DESCRIPTION: - return getDescription(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case AUTHZ_TOKEN: - return isSetAuthzToken(); - case GATEWAY_ID: - return isSetGatewayId(); - case USER_NAME: - return isSetUserName(); - case DESCRIPTION: - return isSetDescription(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof generateAndRegisterSSHKeysWithDescription_args) - return this.equals((generateAndRegisterSSHKeysWithDescription_args)that); - return false; - } - - public boolean equals(generateAndRegisterSSHKeysWithDescription_args that) { - if (that == null) - return false; - - boolean this_present_authzToken = true && this.isSetAuthzToken(); - boolean that_present_authzToken = true && that.isSetAuthzToken(); - if (this_present_authzToken || that_present_authzToken) { - if (!(this_present_authzToken && that_present_authzToken)) - return false; - if (!this.authzToken.equals(that.authzToken)) - return false; - } - - boolean this_present_gatewayId = true && this.isSetGatewayId(); - boolean that_present_gatewayId = true && that.isSetGatewayId(); - if (this_present_gatewayId || that_present_gatewayId) { - if (!(this_present_gatewayId && that_present_gatewayId)) - return false; - if (!this.gatewayId.equals(that.gatewayId)) - return false; - } - - boolean this_present_userName = true && this.isSetUserName(); - boolean that_present_userName = true && that.isSetUserName(); - if (this_present_userName || that_present_userName) { - if (!(this_present_userName && that_present_userName)) - return false; - if (!this.userName.equals(that.userName)) - return false; - } - - boolean this_present_description = true && this.isSetDescription(); - boolean that_present_description = true && that.isSetDescription(); - if (this_present_description || that_present_description) { - if (!(this_present_description && that_present_description)) - return false; - if (!this.description.equals(that.description)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_authzToken = true && (isSetAuthzToken()); - list.add(present_authzToken); - if (present_authzToken) - list.add(authzToken); - - boolean present_gatewayId = true && (isSetGatewayId()); - list.add(present_gatewayId); - if (present_gatewayId) - list.add(gatewayId); - - boolean present_userName = true && (isSetUserName()); - list.add(present_userName); - if (present_userName) - list.add(userName); - - boolean present_description = true && (isSetDescription()); - list.add(present_description); - if (present_description) - list.add(description); - - return list.hashCode(); - } - - @Override - public int compareTo(generateAndRegisterSSHKeysWithDescription_args other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetAuthzToken()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.authzToken, other.authzToken); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetGatewayId()).compareTo(other.isSetGatewayId()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetGatewayId()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.gatewayId, other.gatewayId); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetUserName()).compareTo(other.isSetUserName()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetUserName()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.userName, other.userName); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetDescription()).compareTo(other.isSetDescription()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetDescription()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.description, other.description); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("generateAndRegisterSSHKeysWithDescription_args("); - boolean first = true; - - sb.append("authzToken:"); - if (this.authzToken == null) { - sb.append("null"); - } else { - sb.append(this.authzToken); - } - first = false; - if (!first) sb.append(", "); - sb.append("gatewayId:"); - if (this.gatewayId == null) { - sb.append("null"); - } else { - sb.append(this.gatewayId); - } - first = false; - if (!first) sb.append(", "); - sb.append("userName:"); - if (this.userName == null) { - sb.append("null"); - } else { - sb.append(this.userName); - } - first = false; - if (!first) sb.append(", "); - sb.append("description:"); - if (this.description == null) { - sb.append("null"); - } else { - sb.append(this.description); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (authzToken == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'authzToken' was not present! Struct: " + toString()); - } - if (gatewayId == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'gatewayId' was not present! Struct: " + toString()); - } - if (userName == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'userName' was not present! Struct: " + toString()); - } - if (description == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'description' was not present! Struct: " + toString()); - } - // check for sub-struct validity - if (authzToken != null) { - authzToken.validate(); - } - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class generateAndRegisterSSHKeysWithDescription_argsStandardSchemeFactory implements SchemeFactory { - public generateAndRegisterSSHKeysWithDescription_argsStandardScheme getScheme() { - return new generateAndRegisterSSHKeysWithDescription_argsStandardScheme(); - } - } - - private static class generateAndRegisterSSHKeysWithDescription_argsStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, generateAndRegisterSSHKeysWithDescription_args struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // AUTHZ_TOKEN - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.authzToken = new org.apache.airavata.model.security.AuthzToken(); - struct.authzToken.read(iprot); - struct.setAuthzTokenIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // GATEWAY_ID - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.gatewayId = iprot.readString(); - struct.setGatewayIdIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // USER_NAME - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.userName = iprot.readString(); - struct.setUserNameIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 4: // DESCRIPTION - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.description = iprot.readString(); - struct.setDescriptionIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, generateAndRegisterSSHKeysWithDescription_args struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.authzToken != null) { - oprot.writeFieldBegin(AUTHZ_TOKEN_FIELD_DESC); - struct.authzToken.write(oprot); - oprot.writeFieldEnd(); - } - if (struct.gatewayId != null) { - oprot.writeFieldBegin(GATEWAY_ID_FIELD_DESC); - oprot.writeString(struct.gatewayId); - oprot.writeFieldEnd(); - } - if (struct.userName != null) { - oprot.writeFieldBegin(USER_NAME_FIELD_DESC); - oprot.writeString(struct.userName); - oprot.writeFieldEnd(); - } - if (struct.description != null) { - oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC); - oprot.writeString(struct.description); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class generateAndRegisterSSHKeysWithDescription_argsTupleSchemeFactory implements SchemeFactory { - public generateAndRegisterSSHKeysWithDescription_argsTupleScheme getScheme() { - return new generateAndRegisterSSHKeysWithDescription_argsTupleScheme(); - } - } - - private static class generateAndRegisterSSHKeysWithDescription_argsTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, generateAndRegisterSSHKeysWithDescription_args struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - struct.authzToken.write(oprot); - oprot.writeString(struct.gatewayId); - oprot.writeString(struct.userName); - oprot.writeString(struct.description); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, generateAndRegisterSSHKeysWithDescription_args struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.authzToken = new org.apache.airavata.model.security.AuthzToken(); - struct.authzToken.read(iprot); - struct.setAuthzTokenIsSet(true); - struct.gatewayId = iprot.readString(); - struct.setGatewayIdIsSet(true); - struct.userName = iprot.readString(); - struct.setUserNameIsSet(true); - struct.description = iprot.readString(); - struct.setDescriptionIsSet(true); - } - } - - } - - public static class generateAndRegisterSSHKeysWithDescription_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("generateAndRegisterSSHKeysWithDescription_result"); - - private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRING, (short)0); - private static final org.apache.thrift.protocol.TField IRE_FIELD_DESC = new org.apache.thrift.protocol.TField("ire", org.apache.thrift.protocol.TType.STRUCT, (short)1); - private static final org.apache.thrift.protocol.TField ACE_FIELD_DESC = new org.apache.thrift.protocol.TField("ace", org.apache.thrift.protocol.TType.STRUCT, (short)2); - private static final org.apache.thrift.protocol.TField ASE_FIELD_DESC = new org.apache.thrift.protocol.TField("ase", org.apache.thrift.protocol.TType.STRUCT, (short)3); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new generateAndRegisterSSHKeysWithDescription_resultStandardSchemeFactory()); - schemes.put(TupleScheme.class, new generateAndRegisterSSHKeysWithDescription_resultTupleSchemeFactory()); - } - - public String success; // required - public org.apache.airavata.model.error.InvalidRequestException ire; // required - public org.apache.airavata.model.error.AiravataClientException ace; // required - public org.apache.airavata.model.error.AiravataSystemException ase; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - SUCCESS((short)0, "success"), - IRE((short)1, "ire"), - ACE((short)2, "ace"), - ASE((short)3, "ase"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 0: // SUCCESS - return SUCCESS; - case 1: // IRE - return IRE; - case 2: // ACE - return ACE; - case 3: // ASE - return ASE; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.IRE, new org.apache.thrift.meta_data.FieldMetaData("ire", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); - tmpMap.put(_Fields.ACE, new org.apache.thrift.meta_data.FieldMetaData("ace", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); - tmpMap.put(_Fields.ASE, new org.apache.thrift.meta_data.FieldMetaData("ase", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(generateAndRegisterSSHKeysWithDescription_result.class, metaDataMap); - } - - public generateAndRegisterSSHKeysWithDescription_result() { - } - - public generateAndRegisterSSHKeysWithDescription_result( - String success, - org.apache.airavata.model.error.InvalidRequestException ire, - org.apache.airavata.model.error.AiravataClientException ace, - org.apache.airavata.model.error.AiravataSystemException ase) - { - this(); - this.success = success; - this.ire = ire; - this.ace = ace; - this.ase = ase; - } - - /** - * Performs a deep copy on other. - */ - public generateAndRegisterSSHKeysWithDescription_result(generateAndRegisterSSHKeysWithDescription_result other) { - if (other.isSetSuccess()) { - this.success = other.success; - } - if (other.isSetIre()) { - this.ire = new org.apache.airavata.model.error.InvalidRequestException(other.ire); - } - if (other.isSetAce()) { - this.ace = new org.apache.airavata.model.error.AiravataClientException(other.ace); - } - if (other.isSetAse()) { - this.ase = new org.apache.airavata.model.error.AiravataSystemException(other.ase); - } - } - - public generateAndRegisterSSHKeysWithDescription_result deepCopy() { - return new generateAndRegisterSSHKeysWithDescription_result(this); - } - - @Override - public void clear() { - this.success = null; - this.ire = null; - this.ace = null; - this.ase = null; - } - - public String getSuccess() { - return this.success; - } - - public generateAndRegisterSSHKeysWithDescription_result setSuccess(String success) { - this.success = success; - return this; - } - - public void unsetSuccess() { - this.success = null; - } - - /** Returns true if field success is set (has been assigned a value) and false otherwise */ - public boolean isSetSuccess() { - return this.success != null; - } - - public void setSuccessIsSet(boolean value) { - if (!value) { - this.success = null; - } - } - - public org.apache.airavata.model.error.InvalidRequestException getIre() { - return this.ire; - } - - public generateAndRegisterSSHKeysWithDescription_result setIre(org.apache.airavata.model.error.InvalidRequestException ire) { - this.ire = ire; - return this; - } - - public void unsetIre() { - this.ire = null; - } - - /** Returns true if field ire is set (has been assigned a value) and false otherwise */ - public boolean isSetIre() { - return this.ire != null; - } - - public void setIreIsSet(boolean value) { - if (!value) { - this.ire = null; - } - } - - public org.apache.airavata.model.error.AiravataClientException getAce() { - return this.ace; - } - - public generateAndRegisterSSHKeysWithDescription_result setAce(org.apache.airavata.model.error.AiravataClientException ace) { - this.ace = ace; - return this; - } - - public void unsetAce() { - this.ace = null; - } - - /** Returns true if field ace is set (has been assigned a value) and false otherwise */ - public boolean isSetAce() { - return this.ace != null; - } - - public void setAceIsSet(boolean value) { - if (!value) { - this.ace = null; - } - } - - public org.apache.airavata.model.error.AiravataSystemException getAse() { - return this.ase; - } - - public generateAndRegisterSSHKeysWithDescription_result setAse(org.apache.airavata.model.error.AiravataSystemException ase) { - this.ase = ase; - return this; - } - - public void unsetAse() { - this.ase = null; - } - - /** Returns true if field ase is set (has been assigned a value) and false otherwise */ - public boolean isSetAse() { - return this.ase != null; - } - - public void setAseIsSet(boolean value) { - if (!value) { - this.ase = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case SUCCESS: - if (value == null) { - unsetSuccess(); - } else { - setSuccess((String)value); - } - break; - - case IRE: - if (value == null) { - unsetIre(); - } else { - setIre((org.apache.airavata.model.error.InvalidRequestException)value); - } - break; - - case ACE: - if (value == null) { - unsetAce(); - } else { - setAce((org.apache.airavata.model.error.AiravataClientException)value); - } - break; - - case ASE: - if (value == null) { - unsetAse(); - } else { - setAse((org.apache.airavata.model.error.AiravataSystemException)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case SUCCESS: - return getSuccess(); - - case IRE: - return getIre(); - - case ACE: - return getAce(); - - case ASE: - return getAse(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case SUCCESS: - return isSetSuccess(); - case IRE: - return isSetIre(); - case ACE: - return isSetAce(); - case ASE: - return isSetAse(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof generateAndRegisterSSHKeysWithDescription_result) - return this.equals((generateAndRegisterSSHKeysWithDescription_result)that); - return false; - } - - public boolean equals(generateAndRegisterSSHKeysWithDescription_result that) { - if (that == null) - return false; - - boolean this_present_success = true && this.isSetSuccess(); - boolean that_present_success = true && that.isSetSuccess(); - if (this_present_success || that_present_success) { - if (!(this_present_success && that_present_success)) - return false; - if (!this.success.equals(that.success)) - return false; - } - - boolean this_present_ire = true && this.isSetIre(); - boolean that_present_ire = true && that.isSetIre(); - if (this_present_ire || that_present_ire) { - if (!(this_present_ire && that_present_ire)) - return false; - if (!this.ire.equals(that.ire)) - return false; - } - - boolean this_present_ace = true && this.isSetAce(); - boolean that_present_ace = true && that.isSetAce(); - if (this_present_ace || that_present_ace) { - if (!(this_present_ace && that_present_ace)) - return false; - if (!this.ace.equals(that.ace)) - return false; - } - - boolean this_present_ase = true && this.isSetAse(); - boolean that_present_ase = true && that.isSetAse(); - if (this_present_ase || that_present_ase) { - if (!(this_present_ase && that_present_ase)) - return false; - if (!this.ase.equals(that.ase)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_success = true && (isSetSuccess()); - list.add(present_success); - if (present_success) - list.add(success); - - boolean present_ire = true && (isSetIre()); - list.add(present_ire); - if (present_ire) - list.add(ire); - - boolean present_ace = true && (isSetAce()); - list.add(present_ace); - if (present_ace) - list.add(ace); - - boolean present_ase = true && (isSetAse()); - list.add(present_ase); - if (present_ase) - list.add(ase); - - return list.hashCode(); - } - - @Override - public int compareTo(generateAndRegisterSSHKeysWithDescription_result other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetSuccess()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetIre()).compareTo(other.isSetIre()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetIre()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ire, other.ire); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetAce()).compareTo(other.isSetAce()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetAce()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ace, other.ace); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetAse()).compareTo(other.isSetAse()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetAse()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ase, other.ase); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("generateAndRegisterSSHKeysWithDescription_result("); - boolean first = true; - - sb.append("success:"); - if (this.success == null) { - sb.append("null"); - } else { - sb.append(this.success); - } - first = false; - if (!first) sb.append(", "); - sb.append("ire:"); - if (this.ire == null) { - sb.append("null"); - } else { - sb.append(this.ire); - } - first = false; - if (!first) sb.append(", "); - sb.append("ace:"); - if (this.ace == null) { - sb.append("null"); - } else { - sb.append(this.ace); - } - first = false; - if (!first) sb.append(", "); - sb.append("ase:"); - if (this.ase == null) { - sb.append("null"); - } else { - sb.append(this.ase); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class generateAndRegisterSSHKeysWithDescription_resultStandardSchemeFactory implements SchemeFactory { - public generateAndRegisterSSHKeysWithDescription_resultStandardScheme getScheme() { - return new generateAndRegisterSSHKeysWithDescription_resultStandardScheme(); - } - } - - private static class generateAndRegisterSSHKeysWithDescription_resultStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, generateAndRegisterSSHKeysWithDescription_result struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 0: // SUCCESS - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.success = iprot.readString(); - struct.setSuccessIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 1: // IRE - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.ire = new org.apache.airavata.model.error.InvalidRequestException(); - struct.ire.read(iprot); - struct.setIreIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // ACE - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.ace = new org.apache.airavata.model.error.AiravataClientException(); - struct.ace.read(iprot); - struct.setAceIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // ASE - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.ase = new org.apache.airavata.model.error.AiravataSystemException(); - struct.ase.read(iprot); - struct.setAseIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, generateAndRegisterSSHKeysWithDescription_result struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.success != null) { - oprot.writeFieldBegin(SUCCESS_FIELD_DESC); - oprot.writeString(struct.success); - oprot.writeFieldEnd(); - } - if (struct.ire != null) { - oprot.writeFieldBegin(IRE_FIELD_DESC); - struct.ire.write(oprot); - oprot.writeFieldEnd(); - } - if (struct.ace != null) { - oprot.writeFieldBegin(ACE_FIELD_DESC); - struct.ace.write(oprot); - oprot.writeFieldEnd(); - } - if (struct.ase != null) { - oprot.writeFieldBegin(ASE_FIELD_DESC); - struct.ase.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class generateAndRegisterSSHKeysWithDescription_resultTupleSchemeFactory implements SchemeFactory { - public generateAndRegisterSSHKeysWithDescription_resultTupleScheme getScheme() { - return new generateAndRegisterSSHKeysWithDescription_resultTupleScheme(); - } - } - - private static class generateAndRegisterSSHKeysWithDescription_resultTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, generateAndRegisterSSHKeysWithDescription_result struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - BitSet optionals = new BitSet(); - if (struct.isSetSuccess()) { - optionals.set(0); - } - if (struct.isSetIre()) { - optionals.set(1); - } - if (struct.isSetAce()) { - optionals.set(2); - } - if (struct.isSetAse()) { - optionals.set(3); - } - oprot.writeBitSet(optionals, 4); - if (struct.isSetSuccess()) { - oprot.writeString(struct.success); - } - if (struct.isSetIre()) { - struct.ire.write(oprot); - } - if (struct.isSetAce()) { - struct.ace.write(oprot); - } - if (struct.isSetAse()) { - struct.ase.write(oprot); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, generateAndRegisterSSHKeysWithDescription_result struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(4); - if (incoming.get(0)) { - struct.success = iprot.readString(); - struct.setSuccessIsSet(true); - } - if (incoming.get(1)) { - struct.ire = new org.apache.airavata.model.error.InvalidRequestException(); - struct.ire.read(iprot); - struct.setIreIsSet(true); - } - if (incoming.get(2)) { - struct.ace = new org.apache.airavata.model.error.AiravataClientException(); - struct.ace.read(iprot); - struct.setAceIsSet(true); - } - if (incoming.get(3)) { - struct.ase = new org.apache.airavata.model.error.AiravataSystemException(); - struct.ase.read(iprot); - struct.setAseIsSet(true); - } - } - } - - } - public static class registerPwdCredential_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("registerPwdCredential_args"); diff --git a/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/API/Airavata.php b/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/API/Airavata.php index fe72dce1df..f235e4843d 100644 --- a/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/API/Airavata.php +++ b/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/API/Airavata.php @@ -243,31 +243,6 @@ public function getNotification(\Airavata\Model\Security\AuthzToken $authzToken, * @throws \Airavata\API\Error\AuthorizationException */ public function getAllNotifications(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId); - /** - * Generate and Register SSH Key Pair with Airavata Credential Store. - * - * @param gatewayId - * The identifier for the requested Gateway. - * - * @param userName - * The User for which the credential should be registered. For community accounts, this user is the name of the - * community user name. For computational resources, this user name need not be the same user name on resoruces. - * - * @return airavataCredStoreToken - * An SSH Key pair is generated and stored in the credential store and associated with users or community account - * belonging to a Gateway. - * - * - * - * @param \Airavata\Model\Security\AuthzToken $authzToken - * @param string $gatewayId - * @param string $userName - * @return string - * @throws \Airavata\API\Error\InvalidRequestException - * @throws \Airavata\API\Error\AiravataClientException - * @throws \Airavata\API\Error\AiravataSystemException - */ - public function generateAndRegisterSSHKeys(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName); /** * Generate and Register SSH Key Pair with Airavata Credential Store. * @@ -281,6 +256,9 @@ public function generateAndRegisterSSHKeys(\Airavata\Model\Security\AuthzToken $ * @param description * The description field for a credential type, all type of credential can have a description. * + * @param credentialOwnerType + * The type of owner of this credential. Two possible values: GATEWAY (default) and USER + * * @return airavataCredStoreToken * An SSH Key pair is generated and stored in the credential store and associated with users or community account * belonging to a Gateway. @@ -291,12 +269,13 @@ public function generateAndRegisterSSHKeys(\Airavata\Model\Security\AuthzToken $ * @param string $gatewayId * @param string $userName * @param string $description + * @param int $credentialOwnerType * @return string * @throws \Airavata\API\Error\InvalidRequestException * @throws \Airavata\API\Error\AiravataClientException * @throws \Airavata\API\Error\AiravataSystemException */ - public function generateAndRegisterSSHKeysWithDescription(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName, $description); + public function generateAndRegisterSSHKeys(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName, $description, $credentialOwnerType); /** * Generate and Register Username PWD Pair with Airavata Credential Store. * @@ -5007,18 +4986,20 @@ public function recv_getAllNotifications() throw new \Exception("getAllNotifications failed: unknown result"); } - public function generateAndRegisterSSHKeys(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName) + public function generateAndRegisterSSHKeys(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName, $description, $credentialOwnerType) { - $this->send_generateAndRegisterSSHKeys($authzToken, $gatewayId, $userName); + $this->send_generateAndRegisterSSHKeys($authzToken, $gatewayId, $userName, $description, $credentialOwnerType); return $this->recv_generateAndRegisterSSHKeys(); } - public function send_generateAndRegisterSSHKeys(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName) + public function send_generateAndRegisterSSHKeys(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName, $description, $credentialOwnerType) { $args = new \Airavata\API\Airavata_generateAndRegisterSSHKeys_args(); $args->authzToken = $authzToken; $args->gatewayId = $gatewayId; $args->userName = $userName; + $args->description = $description; + $args->credentialOwnerType = $credentialOwnerType; $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); if ($bin_accel) { @@ -5069,69 +5050,6 @@ public function recv_generateAndRegisterSSHKeys() throw new \Exception("generateAndRegisterSSHKeys failed: unknown result"); } - public function generateAndRegisterSSHKeysWithDescription(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName, $description) - { - $this->send_generateAndRegisterSSHKeysWithDescription($authzToken, $gatewayId, $userName, $description); - return $this->recv_generateAndRegisterSSHKeysWithDescription(); - } - - public function send_generateAndRegisterSSHKeysWithDescription(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $userName, $description) - { - $args = new \Airavata\API\Airavata_generateAndRegisterSSHKeysWithDescription_args(); - $args->authzToken = $authzToken; - $args->gatewayId = $gatewayId; - $args->userName = $userName; - $args->description = $description; - $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); - if ($bin_accel) - { - thrift_protocol_write_binary($this->output_, 'generateAndRegisterSSHKeysWithDescription', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); - } - else - { - $this->output_->writeMessageBegin('generateAndRegisterSSHKeysWithDescription', TMessageType::CALL, $this->seqid_); - $args->write($this->output_); - $this->output_->writeMessageEnd(); - $this->output_->getTransport()->flush(); - } - } - - public function recv_generateAndRegisterSSHKeysWithDescription() - { - $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); - if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Airavata\API\Airavata_generateAndRegisterSSHKeysWithDescription_result', $this->input_->isStrictRead()); - else - { - $rseqid = 0; - $fname = null; - $mtype = 0; - - $this->input_->readMessageBegin($fname, $mtype, $rseqid); - if ($mtype == TMessageType::EXCEPTION) { - $x = new TApplicationException(); - $x->read($this->input_); - $this->input_->readMessageEnd(); - throw $x; - } - $result = new \Airavata\API\Airavata_generateAndRegisterSSHKeysWithDescription_result(); - $result->read($this->input_); - $this->input_->readMessageEnd(); - } - if ($result->success !== null) { - return $result->success; - } - if ($result->ire !== null) { - throw $result->ire; - } - if ($result->ace !== null) { - throw $result->ace; - } - if ($result->ase !== null) { - throw $result->ase; - } - throw new \Exception("generateAndRegisterSSHKeysWithDescription failed: unknown result"); - } - public function registerPwdCredential(\Airavata\Model\Security\AuthzToken $authzToken, $gatewayId, $portalUserName, $loginUserName, $password, $description) { $this->send_registerPwdCredential($authzToken, $gatewayId, $portalUserName, $loginUserName, $password, $description); @@ -19181,286 +19099,14 @@ class Airavata_generateAndRegisterSSHKeys_args { * @var string */ public $userName = null; - - public function __construct($vals=null) { - if (!isset(self::$_TSPEC)) { - self::$_TSPEC = array( - 1 => array( - 'var' => 'authzToken', - 'type' => TType::STRUCT, - 'class' => '\Airavata\Model\Security\AuthzToken', - ), - 2 => array( - 'var' => 'gatewayId', - 'type' => TType::STRING, - ), - 3 => array( - 'var' => 'userName', - 'type' => TType::STRING, - ), - ); - } - if (is_array($vals)) { - if (isset($vals['authzToken'])) { - $this->authzToken = $vals['authzToken']; - } - if (isset($vals['gatewayId'])) { - $this->gatewayId = $vals['gatewayId']; - } - if (isset($vals['userName'])) { - $this->userName = $vals['userName']; - } - } - } - - public function getName() { - return 'Airavata_generateAndRegisterSSHKeys_args'; - } - - public function read($input) - { - $xfer = 0; - $fname = null; - $ftype = 0; - $fid = 0; - $xfer += $input->readStructBegin($fname); - while (true) - { - $xfer += $input->readFieldBegin($fname, $ftype, $fid); - if ($ftype == TType::STOP) { - break; - } - switch ($fid) - { - case 1: - if ($ftype == TType::STRUCT) { - $this->authzToken = new \Airavata\Model\Security\AuthzToken(); - $xfer += $this->authzToken->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - case 2: - if ($ftype == TType::STRING) { - $xfer += $input->readString($this->gatewayId); - } else { - $xfer += $input->skip($ftype); - } - break; - case 3: - if ($ftype == TType::STRING) { - $xfer += $input->readString($this->userName); - } else { - $xfer += $input->skip($ftype); - } - break; - default: - $xfer += $input->skip($ftype); - break; - } - $xfer += $input->readFieldEnd(); - } - $xfer += $input->readStructEnd(); - return $xfer; - } - - public function write($output) { - $xfer = 0; - $xfer += $output->writeStructBegin('Airavata_generateAndRegisterSSHKeys_args'); - if ($this->authzToken !== null) { - if (!is_object($this->authzToken)) { - throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); - } - $xfer += $output->writeFieldBegin('authzToken', TType::STRUCT, 1); - $xfer += $this->authzToken->write($output); - $xfer += $output->writeFieldEnd(); - } - if ($this->gatewayId !== null) { - $xfer += $output->writeFieldBegin('gatewayId', TType::STRING, 2); - $xfer += $output->writeString($this->gatewayId); - $xfer += $output->writeFieldEnd(); - } - if ($this->userName !== null) { - $xfer += $output->writeFieldBegin('userName', TType::STRING, 3); - $xfer += $output->writeString($this->userName); - $xfer += $output->writeFieldEnd(); - } - $xfer += $output->writeFieldStop(); - $xfer += $output->writeStructEnd(); - return $xfer; - } - -} - -class Airavata_generateAndRegisterSSHKeys_result { - static $_TSPEC; - /** * @var string */ - public $success = null; - /** - * @var \Airavata\API\Error\InvalidRequestException - */ - public $ire = null; - /** - * @var \Airavata\API\Error\AiravataClientException - */ - public $ace = null; - /** - * @var \Airavata\API\Error\AiravataSystemException - */ - public $ase = null; - - public function __construct($vals=null) { - if (!isset(self::$_TSPEC)) { - self::$_TSPEC = array( - 0 => array( - 'var' => 'success', - 'type' => TType::STRING, - ), - 1 => array( - 'var' => 'ire', - 'type' => TType::STRUCT, - 'class' => '\Airavata\API\Error\InvalidRequestException', - ), - 2 => array( - 'var' => 'ace', - 'type' => TType::STRUCT, - 'class' => '\Airavata\API\Error\AiravataClientException', - ), - 3 => array( - 'var' => 'ase', - 'type' => TType::STRUCT, - 'class' => '\Airavata\API\Error\AiravataSystemException', - ), - ); - } - if (is_array($vals)) { - if (isset($vals['success'])) { - $this->success = $vals['success']; - } - if (isset($vals['ire'])) { - $this->ire = $vals['ire']; - } - if (isset($vals['ace'])) { - $this->ace = $vals['ace']; - } - if (isset($vals['ase'])) { - $this->ase = $vals['ase']; - } - } - } - - public function getName() { - return 'Airavata_generateAndRegisterSSHKeys_result'; - } - - public function read($input) - { - $xfer = 0; - $fname = null; - $ftype = 0; - $fid = 0; - $xfer += $input->readStructBegin($fname); - while (true) - { - $xfer += $input->readFieldBegin($fname, $ftype, $fid); - if ($ftype == TType::STOP) { - break; - } - switch ($fid) - { - case 0: - if ($ftype == TType::STRING) { - $xfer += $input->readString($this->success); - } else { - $xfer += $input->skip($ftype); - } - break; - case 1: - if ($ftype == TType::STRUCT) { - $this->ire = new \Airavata\API\Error\InvalidRequestException(); - $xfer += $this->ire->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - case 2: - if ($ftype == TType::STRUCT) { - $this->ace = new \Airavata\API\Error\AiravataClientException(); - $xfer += $this->ace->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - case 3: - if ($ftype == TType::STRUCT) { - $this->ase = new \Airavata\API\Error\AiravataSystemException(); - $xfer += $this->ase->read($input); - } else { - $xfer += $input->skip($ftype); - } - break; - default: - $xfer += $input->skip($ftype); - break; - } - $xfer += $input->readFieldEnd(); - } - $xfer += $input->readStructEnd(); - return $xfer; - } - - public function write($output) { - $xfer = 0; - $xfer += $output->writeStructBegin('Airavata_generateAndRegisterSSHKeys_result'); - if ($this->success !== null) { - $xfer += $output->writeFieldBegin('success', TType::STRING, 0); - $xfer += $output->writeString($this->success); - $xfer += $output->writeFieldEnd(); - } - if ($this->ire !== null) { - $xfer += $output->writeFieldBegin('ire', TType::STRUCT, 1); - $xfer += $this->ire->write($output); - $xfer += $output->writeFieldEnd(); - } - if ($this->ace !== null) { - $xfer += $output->writeFieldBegin('ace', TType::STRUCT, 2); - $xfer += $this->ace->write($output); - $xfer += $output->writeFieldEnd(); - } - if ($this->ase !== null) { - $xfer += $output->writeFieldBegin('ase', TType::STRUCT, 3); - $xfer += $this->ase->write($output); - $xfer += $output->writeFieldEnd(); - } - $xfer += $output->writeFieldStop(); - $xfer += $output->writeStructEnd(); - return $xfer; - } - -} - -class Airavata_generateAndRegisterSSHKeysWithDescription_args { - static $_TSPEC; - - /** - * @var \Airavata\Model\Security\AuthzToken - */ - public $authzToken = null; - /** - * @var string - */ - public $gatewayId = null; - /** - * @var string - */ - public $userName = null; + public $description = null; /** - * @var string + * @var int */ - public $description = null; + public $credentialOwnerType = null; public function __construct($vals=null) { if (!isset(self::$_TSPEC)) { @@ -19482,6 +19128,10 @@ public function __construct($vals=null) { 'var' => 'description', 'type' => TType::STRING, ), + 5 => array( + 'var' => 'credentialOwnerType', + 'type' => TType::I32, + ), ); } if (is_array($vals)) { @@ -19497,11 +19147,14 @@ public function __construct($vals=null) { if (isset($vals['description'])) { $this->description = $vals['description']; } + if (isset($vals['credentialOwnerType'])) { + $this->credentialOwnerType = $vals['credentialOwnerType']; + } } } public function getName() { - return 'Airavata_generateAndRegisterSSHKeysWithDescription_args'; + return 'Airavata_generateAndRegisterSSHKeys_args'; } public function read($input) @@ -19548,6 +19201,13 @@ public function read($input) $xfer += $input->skip($ftype); } break; + case 5: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->credentialOwnerType); + } else { + $xfer += $input->skip($ftype); + } + break; default: $xfer += $input->skip($ftype); break; @@ -19560,7 +19220,7 @@ public function read($input) public function write($output) { $xfer = 0; - $xfer += $output->writeStructBegin('Airavata_generateAndRegisterSSHKeysWithDescription_args'); + $xfer += $output->writeStructBegin('Airavata_generateAndRegisterSSHKeys_args'); if ($this->authzToken !== null) { if (!is_object($this->authzToken)) { throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA); @@ -19584,6 +19244,11 @@ public function write($output) { $xfer += $output->writeString($this->description); $xfer += $output->writeFieldEnd(); } + if ($this->credentialOwnerType !== null) { + $xfer += $output->writeFieldBegin('credentialOwnerType', TType::I32, 5); + $xfer += $output->writeI32($this->credentialOwnerType); + $xfer += $output->writeFieldEnd(); + } $xfer += $output->writeFieldStop(); $xfer += $output->writeStructEnd(); return $xfer; @@ -19591,7 +19256,7 @@ public function write($output) { } -class Airavata_generateAndRegisterSSHKeysWithDescription_result { +class Airavata_generateAndRegisterSSHKeys_result { static $_TSPEC; /** @@ -19652,7 +19317,7 @@ public function __construct($vals=null) { } public function getName() { - return 'Airavata_generateAndRegisterSSHKeysWithDescription_result'; + return 'Airavata_generateAndRegisterSSHKeys_result'; } public function read($input) @@ -19713,7 +19378,7 @@ public function read($input) public function write($output) { $xfer = 0; - $xfer += $output->writeStructBegin('Airavata_generateAndRegisterSSHKeysWithDescription_result'); + $xfer += $output->writeStructBegin('Airavata_generateAndRegisterSSHKeys_result'); if ($this->success !== null) { $xfer += $output->writeFieldBegin('success', TType::STRING, 0); $xfer += $output->writeString($this->success); diff --git a/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Credential/Store/Types.php b/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Credential/Store/Types.php index 82139a3c04..d8e3f13854 100644 --- a/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Credential/Store/Types.php +++ b/airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib/Airavata/Model/Credential/Store/Types.php @@ -17,6 +17,15 @@ use Thrift\Exception\TApplicationException; +final class CredentialOwnerType { + const GATEWAY = 0; + const USER = 1; + static public $__names = array( + 0 => 'GATEWAY', + 1 => 'USER', + ); +} + class SSHCredential { static $_TSPEC; @@ -52,6 +61,10 @@ class SSHCredential { * @var string */ public $description = null; + /** + * @var int + */ + public $credentialOwnerType = 0; public function __construct($vals=null) { if (!isset(self::$_TSPEC)) { @@ -88,6 +101,10 @@ public function __construct($vals=null) { 'var' => 'description', 'type' => TType::STRING, ), + 9 => array( + 'var' => 'credentialOwnerType', + 'type' => TType::I32, + ), ); } if (is_array($vals)) { @@ -115,6 +132,9 @@ public function __construct($vals=null) { if (isset($vals['description'])) { $this->description = $vals['description']; } + if (isset($vals['credentialOwnerType'])) { + $this->credentialOwnerType = $vals['credentialOwnerType']; + } } } @@ -193,6 +213,13 @@ public function read($input) $xfer += $input->skip($ftype); } break; + case 9: + if ($ftype == TType::I32) { + $xfer += $input->readI32($this->credentialOwnerType); + } else { + $xfer += $input->skip($ftype); + } + break; default: $xfer += $input->skip($ftype); break; @@ -246,6 +273,11 @@ public function write($output) { $xfer += $output->writeString($this->description); $xfer += $output->writeFieldEnd(); } + if ($this->credentialOwnerType !== null) { + $xfer += $output->writeFieldBegin('credentialOwnerType', TType::I32, 9); + $xfer += $output->writeI32($this->credentialOwnerType); + $xfer += $output->writeFieldEnd(); + } $xfer += $output->writeFieldStop(); $xfer += $output->writeStructEnd(); return $xfer; diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/credential/Credential.java b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/credential/Credential.java index c6823e2b87..bef83639fc 100644 --- a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/credential/Credential.java +++ b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/credential/Credential.java @@ -35,6 +35,7 @@ public abstract class Credential implements Serializable { private String portalUserName; private Date persistedTime; private String token; + private CredentialOwnerType credentialOwnerType = CredentialOwnerType.GATEWAY; public String getDescription() { return description; @@ -71,4 +72,7 @@ public Date getCertificateRequestedTime() { return persistedTime; } + public CredentialOwnerType getCredentialOwnerType() { return credentialOwnerType; } + + public void setCredentialOwnerType(CredentialOwnerType credentialOwnerType) { this.credentialOwnerType = credentialOwnerType; } } diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/credential/CredentialOwnerType.java b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/credential/CredentialOwnerType.java new file mode 100644 index 0000000000..18f2ddf2d9 --- /dev/null +++ b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/credential/CredentialOwnerType.java @@ -0,0 +1,28 @@ +package org.apache.airavata.credential.store.credential; + +/** + * Created by marcus on 11/23/16. + */ +public enum CredentialOwnerType { + GATEWAY(org.apache.airavata.credential.store.datamodel.CredentialOwnerType.GATEWAY), + USER(org.apache.airavata.credential.store.datamodel.CredentialOwnerType.USER); + + private org.apache.airavata.credential.store.datamodel.CredentialOwnerType datamodelType; + private CredentialOwnerType(org.apache.airavata.credential.store.datamodel.CredentialOwnerType datamodelType) { + this.datamodelType = datamodelType; + } + + public org.apache.airavata.credential.store.datamodel.CredentialOwnerType getDatamodelType() { + return datamodelType; + } + + public static CredentialOwnerType findByDataModelType(org.apache.airavata.credential.store.datamodel.CredentialOwnerType datamodelType) { + for( CredentialOwnerType credentialOwnerType : CredentialOwnerType.values() ) { + if (credentialOwnerType.datamodelType == datamodelType) { + return credentialOwnerType; + } + } + + throw new RuntimeException("No CredentialOwnerType found for data model CredentialOwnerType " + datamodelType); + } +} diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServerHandler.java b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServerHandler.java index 49143958f2..387e2af1cc 100644 --- a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServerHandler.java +++ b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/server/CredentialStoreServerHandler.java @@ -27,6 +27,7 @@ import org.apache.airavata.credential.store.cpi.credential_store_cpiConstants; import org.apache.airavata.credential.store.credential.CommunityUser; import org.apache.airavata.credential.store.credential.Credential; +import org.apache.airavata.credential.store.credential.CredentialOwnerType; import org.apache.airavata.credential.store.datamodel.CertificateCredential; import org.apache.airavata.credential.store.datamodel.PasswordCredential; import org.apache.airavata.credential.store.datamodel.SSHCredential; @@ -101,6 +102,7 @@ public String addSSHCredential(SSHCredential sshCredential) throws org.apache.ai if (sshCredential.getPublicKey() == null || sshCredential.getPrivateKey() == null) { credential = Utility.generateKeyPair(credential); } + credential.setCredentialOwnerType(CredentialOwnerType.findByDataModelType(sshCredential.getCredentialOwnerType())); sshCredentialWriter.writeCredentials(credential); return token; } catch (CredentialStoreException e) { @@ -176,6 +178,7 @@ public SSHCredential getSSHCredential(String tokenId, String gatewayId) throws o sshCredential.setToken(credential1.getToken()); sshCredential.setPersistedTime(credential1.getCertificateRequestedTime().getTime()); sshCredential.setDescription(credential1.getDescription()); + sshCredential.setCredentialOwnerType(credential1.getCredentialOwnerType().getDatamodelType()); return sshCredential; } else { log.info("Could not find SSH credentials for token - " + tokenId + " and " @@ -283,7 +286,7 @@ public Map getAllSSHKeysForUser(String username) throws org.apac if (credential instanceof org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) { org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential sshCredential = (org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) credential; String portalUserName = sshCredential.getPortalUserName(); - if (portalUserName != null){ + if (portalUserName != null && sshCredential.getCredentialOwnerType() == CredentialOwnerType.USER){ if (portalUserName.equals(username)) { byte[] publicKey = sshCredential.getPublicKey(); if (publicKey != null) { @@ -311,7 +314,7 @@ public Map getAllSSHKeysForGateway(String gatewayId) throws org. if (credential instanceof org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) { org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential sshCredential = (org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) credential; byte[] publicKey = sshCredential.getPublicKey(); - if (publicKey != null) { + if (publicKey != null && sshCredential.getCredentialOwnerType() == CredentialOwnerType.GATEWAY) { sshKeyMap.put(sshCredential.getToken(), new String(publicKey)); } } @@ -333,7 +336,8 @@ public List getAllGatewaySSHCredentialSummary(String gatew List allCredentials = credentialReader.getAllCredentialsPerGateway(gatewayId); if (allCredentials != null && !allCredentials.isEmpty()){ for (Credential credential : allCredentials) { - if (credential instanceof org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) { + if (credential instanceof org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential + && credential.getCredentialOwnerType() == CredentialOwnerType.GATEWAY) { org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential sshCredential = (org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) credential; SSHCredentialSummary sshCredentialSummary = new SSHCredentialSummary(); sshCredentialSummary.setToken(sshCredential.getToken()); @@ -364,7 +368,7 @@ public List getAllSSHCredentialSummaryForUserInGateway(Str org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential sshCredential = (org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) credential; String portalUserName = sshCredential.getPortalUserName(); String gateway = sshCredential.getGateway(); - if (portalUserName != null && gateway != null){ + if (portalUserName != null && gateway != null && sshCredential.getCredentialOwnerType() == CredentialOwnerType.USER){ if (portalUserName.equals(userId) && gateway.equals(gatewayId)) { org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential sshCredentialKey = (org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential) credential; SSHCredentialSummary sshCredentialSummary = new SSHCredentialSummary(); diff --git a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAO.java b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAO.java index 4fbb17de65..7770590c6d 100644 --- a/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAO.java +++ b/modules/credential-store/credential-store-service/src/main/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAO.java @@ -25,6 +25,7 @@ import org.apache.airavata.common.utils.KeyStorePasswordCallback; import org.apache.airavata.common.utils.SecurityUtil; import org.apache.airavata.credential.store.credential.Credential; +import org.apache.airavata.credential.store.credential.CredentialOwnerType; import org.apache.airavata.credential.store.store.CredentialStoreException; import java.io.*; @@ -86,7 +87,7 @@ public void setKeyStorePasswordCallback(KeyStorePasswordCallback keyStorePasswor public void addCredentials(String gatewayId, Credential credential, Connection connection) throws CredentialStoreException { - String sql = "INSERT INTO CREDENTIALS VALUES (?, ?, ?, ?, ?, ?)"; + String sql = "INSERT INTO CREDENTIALS VALUES (?, ?, ?, ?, ?, ?, ?)"; PreparedStatement preparedStatement = null; @@ -108,6 +109,8 @@ public void addCredentials(String gatewayId, Credential credential, Connection c preparedStatement.setString(6,credential.getDescription()); + preparedStatement.setString(7, credential.getCredentialOwnerType().toString()); + preparedStatement.executeUpdate(); } catch (SQLException e) { @@ -163,7 +166,7 @@ public void deleteCredentials(String gatewayName, String tokenId, Connection con public void updateCredentials(String gatewayId, Credential credential, Connection connection) throws CredentialStoreException { - String sql = "UPDATE CREDENTIALS set CREDENTIAL = ?, PORTAL_USER_ID = ?, TIME_PERSISTED = ?, DESCRIPTION = ? where GATEWAY_ID = ? and TOKEN_ID = ?"; + String sql = "UPDATE CREDENTIALS set CREDENTIAL = ?, PORTAL_USER_ID = ?, TIME_PERSISTED = ?, DESCRIPTION = ?, CREDENTIAL_OWNER_TYPE = ? where GATEWAY_ID = ? and TOKEN_ID = ?"; PreparedStatement preparedStatement = null; @@ -177,8 +180,9 @@ public void updateCredentials(String gatewayId, Credential credential, Connectio preparedStatement.setTimestamp(3, new Timestamp(new java.util.Date().getTime())); preparedStatement.setString(4, credential.getDescription()); - preparedStatement.setString(5, gatewayId); - preparedStatement.setString(6, credential.getToken()); + preparedStatement.setString(5, credential.getCredentialOwnerType().toString()); + preparedStatement.setString(6, gatewayId); + preparedStatement.setString(7, credential.getToken()); preparedStatement.executeUpdate(); @@ -232,6 +236,7 @@ public Credential getCredential(String gatewayName, String tokenId, Connection c certificateCredential.setPortalUserName(resultSet.getString("PORTAL_USER_ID")); certificateCredential.setCertificateRequestedTime(resultSet.getTimestamp("TIME_PERSISTED")); certificateCredential.setDescription(resultSet.getString("DESCRIPTION")); + certificateCredential.setCredentialOwnerType(CredentialOwnerType.valueOf(resultSet.getString("CREDENTIAL_OWNER_TYPE"))); return certificateCredential; } @@ -320,6 +325,7 @@ public List getCredentials(String gatewayName, Connection connection certificateCredential.setPortalUserName(resultSet.getString("PORTAL_USER_ID")); certificateCredential.setCertificateRequestedTime(resultSet.getTimestamp("TIME_PERSISTED")); certificateCredential.setDescription(resultSet.getString("DESCRIPTION")); + certificateCredential.setCredentialOwnerType(CredentialOwnerType.valueOf(resultSet.getString("CREDENTIAL_OWNER_TYPE"))); credentialList.add(certificateCredential); } @@ -370,6 +376,7 @@ public List getCredentials(Connection connection) throws CredentialS certificateCredential.setPortalUserName(resultSet.getString("PORTAL_USER_ID")); certificateCredential.setCertificateRequestedTime(resultSet.getTimestamp("TIME_PERSISTED")); certificateCredential.setDescription(resultSet.getString("DESCRIPTION")); + certificateCredential.setCredentialOwnerType(CredentialOwnerType.valueOf(resultSet.getString("CREDENTIAL_OWNER_TYPE"))); credentialList.add(certificateCredential); } diff --git a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java index 0f6d493db4..63efb466fd 100644 --- a/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java +++ b/modules/credential-store/credential-store-service/src/test/java/org/apache/airavata/credential/store/store/impl/db/CredentialsDAOTest.java @@ -28,6 +28,7 @@ import org.apache.airavata.common.utils.KeyStorePasswordCallback; import org.apache.airavata.credential.store.credential.CommunityUser; import org.apache.airavata.credential.store.credential.Credential; +import org.apache.airavata.credential.store.credential.CredentialOwnerType; import org.apache.airavata.credential.store.credential.impl.certificate.CertificateCredential; import org.apache.airavata.credential.store.store.CredentialStoreException; import org.junit.AfterClass; @@ -81,6 +82,7 @@ public static void setUpDatabase() throws Exception { " CREDENTIAL BLOB NOT NULL,\n" + " PORTAL_USER_ID VARCHAR(256) NOT NULL,\n" + " TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n" + " DESCRIPTION VARCHAR(500),\n" + + " CREDENTIAL_OWNER_TYPE VARCHAR(10) DEFAULT 'GATEWAY' NOT NULL,\n" + " PRIMARY KEY (GATEWAY_ID, TOKEN_ID)\n" + ")"; String dropTable = "drop table CREDENTIALS"; @@ -196,6 +198,7 @@ public CertificateCredential getTestCredentialObject() { certificateCredential.setPortalUserName("jerry"); certificateCredential.setNotBefore("13 OCT 2012 5:34:23"); certificateCredential.setNotAfter("14 OCT 2012 5:34:23"); + certificateCredential.setCredentialOwnerType(CredentialOwnerType.GATEWAY); return certificateCredential; @@ -225,6 +228,7 @@ public void testSerialization() throws CredentialStoreException { Assert.assertEquals(certificateCredential.getNotAfter(), readCertificateCredential.getNotAfter()); Assert.assertEquals(certificateCredential.getNotBefore(), readCertificateCredential.getNotBefore()); Assert.assertEquals(certificateCredential.getPortalUserName(), readCertificateCredential.getPortalUserName()); + Assert.assertEquals(certificateCredential.getCredentialOwnerType(), readCertificateCredential.getCredentialOwnerType()); PrivateKey newKey = readCertificateCredential.getPrivateKey(); @@ -266,6 +270,7 @@ public void testSerializationWithEncryption() throws CredentialStoreException { Assert.assertEquals(certificateCredential.getNotAfter(), readCertificateCredential.getNotAfter()); Assert.assertEquals(certificateCredential.getNotBefore(), readCertificateCredential.getNotBefore()); Assert.assertEquals(certificateCredential.getPortalUserName(), readCertificateCredential.getPortalUserName()); + Assert.assertEquals(certificateCredential.getCredentialOwnerType(), readCertificateCredential.getCredentialOwnerType()); PrivateKey newKey = readCertificateCredential.getPrivateKey(); @@ -368,6 +373,7 @@ public void testUpdateCredentials() throws Exception { certificateCredential.setLifeTime(50); certificateCredential.setNotBefore("15 OCT 2012 5:34:23"); certificateCredential.setNotAfter("16 OCT 2012 5:34:23"); + certificateCredential.setCredentialOwnerType(CredentialOwnerType.USER); credentialsDAO.updateCredentials(communityUser.getGatewayName(), certificateCredential, connection); @@ -377,6 +383,7 @@ public void testUpdateCredentials() throws Exception { certificateCredential.getCertificates()[0].getIssuerDN().toString()); // Assert.assertNotNull(certificateCredential.getPrivateKey()); Assert.assertEquals("test2", certificateCredential.getPortalUserName()); + Assert.assertEquals(CredentialOwnerType.USER, certificateCredential.getCredentialOwnerType()); } finally { connection.close(); diff --git a/modules/credential-store/credential-store-stubs/pom.xml b/modules/credential-store/credential-store-stubs/pom.xml index 97ade9dc57..5c9f92af3f 100644 --- a/modules/credential-store/credential-store-stubs/pom.xml +++ b/modules/credential-store/credential-store-stubs/pom.xml @@ -52,4 +52,28 @@ UTF-8 + + + + com.google.code.maven-replacer-plugin + replacer + ${maven.replacer.plugin.version} + + + generate-sources + + replace + + + + + + ${basedir}/src/main/java/org/apache/airavata/**/*.java + + , date = ".*" + + + + + \ No newline at end of file diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/cpi/CredentialStoreService.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/cpi/CredentialStoreService.java index 4d2a456e67..1686c760ae 100644 --- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/cpi/CredentialStoreService.java +++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/cpi/CredentialStoreService.java @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-11-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") public class CredentialStoreService { public interface Iface { diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/APICredential.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/APICredential.java index b7a23d122a..27347e9a2d 100644 --- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/APICredential.java +++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/APICredential.java @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2015-12-21") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") public class APICredential implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("APICredential"); diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CertificateCredential.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CertificateCredential.java index d2e5d8541a..989b277f9f 100644 --- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CertificateCredential.java +++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CertificateCredential.java @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-11-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") public class CertificateCredential implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CertificateCredential"); diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CommunityUser.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CommunityUser.java index 9947b64fbb..ac117394fc 100644 --- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CommunityUser.java +++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CommunityUser.java @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-11-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") public class CommunityUser implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CommunityUser"); diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CredentialOwnerType.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CredentialOwnerType.java new file mode 100644 index 0000000000..745f92180f --- /dev/null +++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/CredentialOwnerType.java @@ -0,0 +1,61 @@ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Autogenerated by Thrift Compiler (0.9.3) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.airavata.credential.store.datamodel; + + +import java.util.Map; +import java.util.HashMap; +import org.apache.thrift.TEnum; + +public enum CredentialOwnerType implements org.apache.thrift.TEnum { + GATEWAY(0), + USER(1); + + private final int value; + + private CredentialOwnerType(int value) { + this.value = value; + } + + /** + * Get the integer value of this enum value, as defined in the Thrift IDL. + */ + public int getValue() { + return value; + } + + /** + * Find a the enum type by its integer value, as defined in the Thrift IDL. + * @return null if the value is not found. + */ + public static CredentialOwnerType findByValue(int value) { + switch (value) { + case 0: + return GATEWAY; + case 1: + return USER; + default: + return null; + } + } +} diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/PasswordCredential.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/PasswordCredential.java index 0e5775285b..44e15038b9 100644 --- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/PasswordCredential.java +++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/PasswordCredential.java @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-11-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") public class PasswordCredential implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PasswordCredential"); diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredential.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredential.java index 47b585b747..14fb1b12b1 100644 --- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredential.java +++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredential.java @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-11-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") public class SSHCredential implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SSHCredential"); @@ -62,6 +62,7 @@ public class SSHCredential implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -77,6 +78,11 @@ public class SSHCredential implements org.apache.thrift.TBase byName = new HashMap(); @@ -118,6 +129,8 @@ public static _Fields findByThriftId(int fieldId) { return TOKEN; case 8: // DESCRIPTION return DESCRIPTION; + case 9: // CREDENTIAL_OWNER_TYPE + return CREDENTIAL_OWNER_TYPE; default: return null; } @@ -160,7 +173,7 @@ public String getFieldName() { // isset id assignments private static final int __PERSISTEDTIME_ISSET_ID = 0; private byte __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.PASSPHRASE,_Fields.PUBLIC_KEY,_Fields.PRIVATE_KEY,_Fields.PERSISTED_TIME,_Fields.TOKEN,_Fields.DESCRIPTION}; + private static final _Fields optionals[] = {_Fields.PASSPHRASE,_Fields.PUBLIC_KEY,_Fields.PRIVATE_KEY,_Fields.PERSISTED_TIME,_Fields.TOKEN,_Fields.DESCRIPTION,_Fields.CREDENTIAL_OWNER_TYPE}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -180,11 +193,15 @@ public String getFieldName() { new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.DESCRIPTION, new org.apache.thrift.meta_data.FieldMetaData("description", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.CREDENTIAL_OWNER_TYPE, new org.apache.thrift.meta_data.FieldMetaData("credentialOwnerType", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, CredentialOwnerType.class))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SSHCredential.class, metaDataMap); } public SSHCredential() { + this.credentialOwnerType = org.apache.airavata.credential.store.datamodel.CredentialOwnerType.GATEWAY; + } public SSHCredential( @@ -223,6 +240,9 @@ public SSHCredential(SSHCredential other) { if (other.isSetDescription()) { this.description = other.description; } + if (other.isSetCredentialOwnerType()) { + this.credentialOwnerType = other.credentialOwnerType; + } } public SSHCredential deepCopy() { @@ -240,6 +260,8 @@ public void clear() { this.persistedTime = 0; this.token = null; this.description = null; + this.credentialOwnerType = org.apache.airavata.credential.store.datamodel.CredentialOwnerType.GATEWAY; + } public String getGatewayId() { @@ -433,6 +455,38 @@ public void setDescriptionIsSet(boolean value) { } } + /** + * + * @see CredentialOwnerType + */ + public CredentialOwnerType getCredentialOwnerType() { + return this.credentialOwnerType; + } + + /** + * + * @see CredentialOwnerType + */ + public SSHCredential setCredentialOwnerType(CredentialOwnerType credentialOwnerType) { + this.credentialOwnerType = credentialOwnerType; + return this; + } + + public void unsetCredentialOwnerType() { + this.credentialOwnerType = null; + } + + /** Returns true if field credentialOwnerType is set (has been assigned a value) and false otherwise */ + public boolean isSetCredentialOwnerType() { + return this.credentialOwnerType != null; + } + + public void setCredentialOwnerTypeIsSet(boolean value) { + if (!value) { + this.credentialOwnerType = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case GATEWAY_ID: @@ -499,6 +553,14 @@ public void setFieldValue(_Fields field, Object value) { } break; + case CREDENTIAL_OWNER_TYPE: + if (value == null) { + unsetCredentialOwnerType(); + } else { + setCredentialOwnerType((CredentialOwnerType)value); + } + break; + } } @@ -528,6 +590,9 @@ public Object getFieldValue(_Fields field) { case DESCRIPTION: return getDescription(); + case CREDENTIAL_OWNER_TYPE: + return getCredentialOwnerType(); + } throw new IllegalStateException(); } @@ -555,6 +620,8 @@ public boolean isSet(_Fields field) { return isSetToken(); case DESCRIPTION: return isSetDescription(); + case CREDENTIAL_OWNER_TYPE: + return isSetCredentialOwnerType(); } throw new IllegalStateException(); } @@ -644,6 +711,15 @@ public boolean equals(SSHCredential that) { return false; } + boolean this_present_credentialOwnerType = true && this.isSetCredentialOwnerType(); + boolean that_present_credentialOwnerType = true && that.isSetCredentialOwnerType(); + if (this_present_credentialOwnerType || that_present_credentialOwnerType) { + if (!(this_present_credentialOwnerType && that_present_credentialOwnerType)) + return false; + if (!this.credentialOwnerType.equals(that.credentialOwnerType)) + return false; + } + return true; } @@ -691,6 +767,11 @@ public int hashCode() { if (present_description) list.add(description); + boolean present_credentialOwnerType = true && (isSetCredentialOwnerType()); + list.add(present_credentialOwnerType); + if (present_credentialOwnerType) + list.add(credentialOwnerType.getValue()); + return list.hashCode(); } @@ -782,6 +863,16 @@ public int compareTo(SSHCredential other) { return lastComparison; } } + lastComparison = Boolean.valueOf(isSetCredentialOwnerType()).compareTo(other.isSetCredentialOwnerType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCredentialOwnerType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.credentialOwnerType, other.credentialOwnerType); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -873,6 +964,16 @@ public String toString() { } first = false; } + if (isSetCredentialOwnerType()) { + if (!first) sb.append(", "); + sb.append("credentialOwnerType:"); + if (this.credentialOwnerType == null) { + sb.append("null"); + } else { + sb.append(this.credentialOwnerType); + } + first = false; + } sb.append(")"); return sb.toString(); } @@ -988,6 +1089,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, SSHCredential struc org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 9: // CREDENTIAL_OWNER_TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.credentialOwnerType = org.apache.airavata.credential.store.datamodel.CredentialOwnerType.findByValue(iprot.readI32()); + struct.setCredentialOwnerTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -1053,6 +1162,13 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, SSHCredential stru oprot.writeFieldEnd(); } } + if (struct.credentialOwnerType != null) { + if (struct.isSetCredentialOwnerType()) { + oprot.writeFieldBegin(CREDENTIAL_OWNER_TYPE_FIELD_DESC); + oprot.writeI32(struct.credentialOwnerType.getValue()); + oprot.writeFieldEnd(); + } + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -1091,7 +1207,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, SSHCredential struc if (struct.isSetDescription()) { optionals.set(5); } - oprot.writeBitSet(optionals, 6); + if (struct.isSetCredentialOwnerType()) { + optionals.set(6); + } + oprot.writeBitSet(optionals, 7); if (struct.isSetPassphrase()) { oprot.writeString(struct.passphrase); } @@ -1110,6 +1229,9 @@ public void write(org.apache.thrift.protocol.TProtocol prot, SSHCredential struc if (struct.isSetDescription()) { oprot.writeString(struct.description); } + if (struct.isSetCredentialOwnerType()) { + oprot.writeI32(struct.credentialOwnerType.getValue()); + } } @Override @@ -1119,7 +1241,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, SSHCredential struct struct.setGatewayIdIsSet(true); struct.username = iprot.readString(); struct.setUsernameIsSet(true); - BitSet incoming = iprot.readBitSet(6); + BitSet incoming = iprot.readBitSet(7); if (incoming.get(0)) { struct.passphrase = iprot.readString(); struct.setPassphraseIsSet(true); @@ -1144,6 +1266,10 @@ public void read(org.apache.thrift.protocol.TProtocol prot, SSHCredential struct struct.description = iprot.readString(); struct.setDescriptionIsSet(true); } + if (incoming.get(6)) { + struct.credentialOwnerType = org.apache.airavata.credential.store.datamodel.CredentialOwnerType.findByValue(iprot.readI32()); + struct.setCredentialOwnerTypeIsSet(true); + } } } diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredentialSummary.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredentialSummary.java index a646a94485..49fc1006ab 100644 --- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredentialSummary.java +++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel/SSHCredentialSummary.java @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-11-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") public class SSHCredentialSummary implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SSHCredentialSummary"); diff --git a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/exception/CredentialStoreException.java b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/exception/CredentialStoreException.java index ce445ac324..5a1c748f42 100644 --- a/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/exception/CredentialStoreException.java +++ b/modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/exception/CredentialStoreException.java @@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-11-08") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)") public class CredentialStoreException extends TException implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CredentialStoreException"); diff --git a/modules/registry/registry-core/src/main/resources/credstore-derby.sql b/modules/registry/registry-core/src/main/resources/credstore-derby.sql index f600f249e6..7ccc001f88 100644 --- a/modules/registry/registry-core/src/main/resources/credstore-derby.sql +++ b/modules/registry/registry-core/src/main/resources/credstore-derby.sql @@ -12,6 +12,8 @@ CREATE TABLE CREDENTIALS ( CREDENTIAL BLOB NOT NULL, PORTAL_USER_ID VARCHAR(256) NOT NULL, TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + DESCRIPTION VARCHAR(500), + CREDENTIAL_OWNER_TYPE VARCHAR(10) DEFAULT 'GATEWAY' NOT NULL, PRIMARY KEY (GATEWAY_ID, TOKEN_ID) ); diff --git a/modules/registry/registry-core/src/main/resources/credstore-mysql.sql b/modules/registry/registry-core/src/main/resources/credstore-mysql.sql index a0cf815f37..a6c9144147 100644 --- a/modules/registry/registry-core/src/main/resources/credstore-mysql.sql +++ b/modules/registry/registry-core/src/main/resources/credstore-mysql.sql @@ -12,6 +12,8 @@ CREATE TABLE CREDENTIALS ( CREDENTIAL BLOB NOT NULL, PORTAL_USER_ID VARCHAR(256) NOT NULL, TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + DESCRIPTION VARCHAR(500), + CREDENTIAL_OWNER_TYPE VARCHAR(10) DEFAULT 'GATEWAY' NOT NULL, PRIMARY KEY (GATEWAY_ID, TOKEN_ID) ); diff --git a/thrift-interface-descriptions/airavata-apis/airavata_api.thrift b/thrift-interface-descriptions/airavata-apis/airavata_api.thrift index 9a07df0037..36b6fda353 100644 --- a/thrift-interface-descriptions/airavata-apis/airavata_api.thrift +++ b/thrift-interface-descriptions/airavata-apis/airavata_api.thrift @@ -27,6 +27,7 @@ include "airavata_errors.thrift" include "security_model.thrift" include "../data-models/airavata_data_models.thrift" +include "../data-models/credential-store-models/credential_store_data_models.thrift" include "../data-models/experiment-catalog-models/status_models.thrift" include "../data-models/experiment-catalog-models/job_model.thrift" include "../data-models/experiment-catalog-models/experiment_model.thrift" @@ -266,6 +267,12 @@ service Airavata { * The User for which the credential should be registered. For community accounts, this user is the name of the * community user name. For computational resources, this user name need not be the same user name on resoruces. * + * @param description + * The description field for a credential type, all type of credential can have a description. + * + * @param credentialOwnerType + * The type of owner of this credential. Two possible values: GATEWAY (default) and USER + * * @return airavataCredStoreToken * An SSH Key pair is generated and stored in the credential store and associated with users or community account * belonging to a Gateway. @@ -273,38 +280,13 @@ service Airavata { **/ string generateAndRegisterSSHKeys (1: required security_model.AuthzToken authzToken, 2: required string gatewayId, - 3: required string userName) + 3: required string userName, + 4: string description, + 5: credential_store_data_models.CredentialOwnerType credentialOwnerType) throws (1: airavata_errors.InvalidRequestException ire, 2: airavata_errors.AiravataClientException ace, 3: airavata_errors.AiravataSystemException ase) - /** - * Generate and Register SSH Key Pair with Airavata Credential Store. - * - * @param gatewayId - * The identifier for the requested Gateway. - * - * @param userName - * The User for which the credential should be registered. For community accounts, this user is the name of the - * community user name. For computational resources, this user name need not be the same user name on resoruces. - * - * @param description - * The description field for a credential type, all type of credential can have a description. - * - * @return airavataCredStoreToken - * An SSH Key pair is generated and stored in the credential store and associated with users or community account - * belonging to a Gateway. - * - **/ - string generateAndRegisterSSHKeysWithDescription (1: required security_model.AuthzToken authzToken, - 2: required string gatewayId, - 3: required string userName, - 4: required string description) - throws (1: airavata_errors.InvalidRequestException ire, - 2: airavata_errors.AiravataClientException ace, - 3: airavata_errors.AiravataSystemException ase) - - /** * Generate and Register Username PWD Pair with Airavata Credential Store. * diff --git a/thrift-interface-descriptions/data-models/credential-store-models/credential_store_data_models.thrift b/thrift-interface-descriptions/data-models/credential-store-models/credential_store_data_models.thrift index f2c2c7730c..d69c18edaa 100644 --- a/thrift-interface-descriptions/data-models/credential-store-models/credential_store_data_models.thrift +++ b/thrift-interface-descriptions/data-models/credential-store-models/credential_store_data_models.thrift @@ -24,6 +24,11 @@ namespace php Airavata.Model.Credential.Store const string DEFAULT_ID = "DO_NOT_SET_AT_CLIENTS" +enum CredentialOwnerType { + GATEWAY, + USER +} + struct SSHCredential { 1: required string gatewayId, 2: required string username, @@ -32,7 +37,8 @@ struct SSHCredential { 5: optional string privateKey, 6: optional i64 persistedTime, 7: optional string token, - 8: optional string description + 8: optional string description, + 9: optional CredentialOwnerType credentialOwnerType = CredentialOwnerType.GATEWAY } struct SSHCredentialSummary { diff --git a/thrift-interface-descriptions/generate-thrift-stubs.sh b/thrift-interface-descriptions/generate-thrift-stubs.sh index 949ce2e3a8..4a9550a8a3 100755 --- a/thrift-interface-descriptions/generate-thrift-stubs.sh +++ b/thrift-interface-descriptions/generate-thrift-stubs.sh @@ -69,14 +69,12 @@ DATAMODEL_THRIFT_FILE='data-models/airavata_data_models.thrift' APP_CATALOG_THRIFT_FILE='data-models/app-catalog-models/app_catalog_models.thrift' RESOURCE_CATALOG_THRIFT_FILE='data-models/resource-catalog-models/resource_catalog_models.thrift' WORKFLOW_THRIFT_FILE='data-models/workflow-models/workflow_data_model.thrift' -CREDENTIAL_STORE_DATAMODEL_THRIFT_FILE='data-models/credential-store-models/credential_store_data_models.thrift' DATAMODEL_SRC_DIR='../airavata-api/airavata-data-models/src/main/java' JAVA_API_SDK_DIR='../airavata-api/airavata-api-stubs/src/main/java' PHP_SDK_DIR='../airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib' CPP_SDK_DIR='../airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/' PYTHON_SDK_DIR='../airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/' -CREDENTIAL_DATAMODEL_SRC_DIR='../modules/credential-store/credential-store-stubs/src/main/java/org/apache/airavata/credential/store/datamodel' # Initialize the thrift arguments. # Since most of the Airavata API and Data Models have includes, use recursive option by default. @@ -186,27 +184,6 @@ generate_java_stubs() { # As a precaution remove and previously generated files if exists rm -rf ${JAVA_GEN_DIR} - # Generate the credential store data models in move them to respective modules/credential-store directory - - $THRIFT_EXEC ${THRIFT_ARGS} --gen java:beans ${CREDENTIAL_STORE_DATAMODEL_THRIFT_FILE} || fail unable to generate java bean thrift classes on app workflow data models - - # For the generated java beans add the ASF V2 License header - add_license_header $JAVA_BEAN_GEN_DIR - - # Compare the newly generated beans with existing sources and replace the changed ones. - copy_changed_files ${JAVA_BEAN_GEN_DIR}/org/apache/airavata/credential/store/datamodel} ${CREDENTIAL_DATAMODEL_SRC_DIR} - - ############################################################################### - # Generate/Update source used by Airavata Server Skeletons & Java Client Stubs # - # JAVA server and client both use generated api-boilerplate-code # - ############################################################################### - - #Java generation directory - JAVA_GEN_DIR=${BASE_TARGET_DIR}/gen-java - - # As a precaution remove and previously generated files if exists - rm -rf ${JAVA_GEN_DIR} - # Using thrift Java generator, generate the java classes based on Airavata API. This # The airavata_api.thrift includes rest of data models. $THRIFT_EXEC ${THRIFT_ARGS} --gen java ${AIRAVATA_API_THRIFT_FILE} || fail unable to generate java thrift classes on AiravataAPI @@ -239,7 +216,6 @@ generate_php_stubs() { $THRIFT_EXEC ${THRIFT_ARGS} --gen php:autoload ${APP_CATALOG_THRIFT_FILE} || fail unable to generate PHP thrift classes $THRIFT_EXEC ${THRIFT_ARGS} --gen php:autoload ${RESOURCE_CATALOG_THRIFT_FILE} || fail unable to generate PHP thrift classes $THRIFT_EXEC ${THRIFT_ARGS} --gen php:autoload ${AIRAVATA_API_THRIFT_FILE} || fail unable to generate PHP thrift classes - $THRIFT_EXEC ${THRIFT_ARGS} --gen php:autoload ${CREDENTIAL_STORE_DATAMODEL_THRIFT_FILE} || fail unable to generate PHP thrift classes # For the generated java classes add the ASF V2 License header ## TODO Write PHP license parser