You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2022/05/03 15:23:17 UTC
[airavata-mft] branch master updated: Adding resource and secret apis for Openstack Swift
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
The following commit(s) were added to refs/heads/master by this push:
new 8838e55 Adding resource and secret apis for Openstack Swift
8838e55 is described below
commit 8838e550f3dffa9405b8aef68535bdf70117e434
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Tue May 3 11:23:08 2022 -0400
Adding resource and secret apis for Openstack Swift
---
.../mft/resource/client/StorageServiceClient.java | 5 +
.../resource/server/backend/ResourceBackend.java | 7 ++
.../backend/airavata/AiravataResourceBackend.java | 26 +++++
.../backend/datalake/DatalakeResourceBackend.java | 26 +++++
.../backend/file/FileBasedResourceBackend.java | 26 +++++
.../server/backend/sql/SQLResourceBackend.java | 36 +++++++
.../backend/sql/entity/GenericResourceEntity.java | 2 +-
.../backend/sql/entity/SwiftStorageEntity.java | 97 +++++++++++++++++
.../sql/repository/SwiftStorageRepository.java | 30 ++++++
.../server/handler/SwiftStorageHandler.java | 120 +++++++++++++++++++++
.../src/main/proto/resource/ResourceService.proto | 3 +
.../stub/src/main/proto/swift/SwiftStorage.proto | 73 +++++++++++++
.../src/main/proto/swift/SwiftStorageService.proto | 42 ++++++++
.../mft/secret/client/SecretServiceClient.java | 4 +
.../mft/secret/server/backend/SecretBackend.java | 6 ++
.../backend/airavata/AiravataSecretBackend.java | 21 ++++
.../server/backend/custos/CustosSecretBackend.java | 21 ++++
.../backend/file/FileBasedSecretBackend.java | 21 ++++
.../server/backend/sql/SQLSecretBackend.java | 119 ++++++++++++++++++++
.../swift/SwiftAuthCredentialSecretEntity.java | 65 +++++++++++
.../entity/swift/SwiftPasswordSecretEntity.java | 87 +++++++++++++++
.../sql/entity/swift/SwiftSecretEntity.java | 69 ++++++++++++
.../swift/SwiftAuthCredentialSecretRepository.java | 27 +++++
.../swift/SwiftPasswordSecretRepository.java | 28 +++++
.../repository/swift/SwiftSecretRepository.java | 27 +++++
.../secret/server/handler/SwiftServiceHandler.java | 82 ++++++++++++++
.../src/main/proto/swift/SwiftCredential.proto | 78 ++++++++++++++
.../src/main/proto/swift/SwiftSecretService.proto | 37 +++++++
28 files changed, 1184 insertions(+), 1 deletion(-)
diff --git a/services/resource-service/client/src/main/java/org/apache/airavata/mft/resource/client/StorageServiceClient.java b/services/resource-service/client/src/main/java/org/apache/airavata/mft/resource/client/StorageServiceClient.java
index b632b92..73ea91a 100644
--- a/services/resource-service/client/src/main/java/org/apache/airavata/mft/resource/client/StorageServiceClient.java
+++ b/services/resource-service/client/src/main/java/org/apache/airavata/mft/resource/client/StorageServiceClient.java
@@ -9,6 +9,7 @@ import org.apache.airavata.mft.resource.service.gcs.GCSStorageServiceGrpc;
import org.apache.airavata.mft.resource.service.local.LocalStorageServiceGrpc;
import org.apache.airavata.mft.resource.service.s3.S3StorageServiceGrpc;
import org.apache.airavata.mft.resource.service.scp.SCPStorageServiceGrpc;
+import org.apache.airavata.mft.resource.service.swift.SwiftStorageServiceGrpc;
import org.apache.airavata.mft.storage.stubs.storagesecret.StorageSecretServiceGrpc;
import java.io.Closeable;
@@ -58,6 +59,10 @@ public class StorageServiceClient implements Closeable {
return DropboxStorageServiceGrpc.newBlockingStub(channel);
}
+ public SwiftStorageServiceGrpc.SwiftStorageServiceBlockingStub swift() {
+ return SwiftStorageServiceGrpc.newBlockingStub(channel);
+ }
+
@Override
public void close() throws IOException {
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/ResourceBackend.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/ResourceBackend.java
index 2f5fa68..91d7d9f 100644
--- a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/ResourceBackend.java
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/ResourceBackend.java
@@ -26,6 +26,7 @@ import org.apache.airavata.mft.resource.stubs.gcs.storage.*;
import org.apache.airavata.mft.resource.stubs.local.storage.*;
import org.apache.airavata.mft.resource.stubs.s3.storage.*;
import org.apache.airavata.mft.resource.stubs.scp.storage.*;
+import org.apache.airavata.mft.resource.stubs.swift.storage.*;
import org.apache.airavata.mft.storage.stubs.storagesecret.*;
import java.util.Optional;
@@ -93,4 +94,10 @@ public interface ResourceBackend {
FTPStorage createFTPStorage(FTPStorageCreateRequest request) throws Exception;
boolean updateFTPStorage(FTPStorageUpdateRequest request) throws Exception;
boolean deleteFTPStorage(FTPStorageDeleteRequest request) throws Exception;
+
+ public SwiftStorageListResponse listSwiftStorage(SwiftStorageListRequest request) throws Exception;
+ Optional<SwiftStorage> getSwiftStorage(SwiftStorageGetRequest request) throws Exception;
+ SwiftStorage createSwiftStorage(SwiftStorageCreateRequest request) throws Exception;
+ boolean updateSwiftStorage(SwiftStorageUpdateRequest request) throws Exception;
+ boolean deleteSwiftStorage(SwiftStorageDeleteRequest request) throws Exception;
}
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/airavata/AiravataResourceBackend.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/airavata/AiravataResourceBackend.java
index 0656185..b2cedd6 100644
--- a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/airavata/AiravataResourceBackend.java
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/airavata/AiravataResourceBackend.java
@@ -27,6 +27,7 @@ import org.apache.airavata.mft.resource.stubs.gcs.storage.*;
import org.apache.airavata.mft.resource.stubs.local.storage.*;
import org.apache.airavata.mft.resource.stubs.s3.storage.*;
import org.apache.airavata.mft.resource.stubs.scp.storage.*;
+import org.apache.airavata.mft.resource.stubs.swift.storage.*;
import org.apache.airavata.mft.storage.stubs.storagesecret.*;
import org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription;
import org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
@@ -351,4 +352,29 @@ public class AiravataResourceBackend implements ResourceBackend {
public boolean deleteFTPStorage(FTPStorageDeleteRequest request) {
throw new UnsupportedOperationException("Operation is not supported in backend");
}
+
+ @Override
+ public SwiftStorageListResponse listSwiftStorage(SwiftStorageListRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public Optional<SwiftStorage> getSwiftStorage(SwiftStorageGetRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public SwiftStorage createSwiftStorage(SwiftStorageCreateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean updateSwiftStorage(SwiftStorageUpdateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean deleteSwiftStorage(SwiftStorageDeleteRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
}
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/datalake/DatalakeResourceBackend.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/datalake/DatalakeResourceBackend.java
index 360a824..6a39453 100644
--- a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/datalake/DatalakeResourceBackend.java
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/datalake/DatalakeResourceBackend.java
@@ -39,6 +39,7 @@ import org.apache.airavata.mft.resource.stubs.gcs.storage.*;
import org.apache.airavata.mft.resource.stubs.local.storage.*;
import org.apache.airavata.mft.resource.stubs.s3.storage.*;
import org.apache.airavata.mft.resource.stubs.scp.storage.*;
+import org.apache.airavata.mft.resource.stubs.swift.storage.*;
import org.apache.airavata.mft.storage.stubs.storagesecret.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -400,4 +401,29 @@ public class DatalakeResourceBackend implements ResourceBackend {
public boolean deleteFTPStorage(FTPStorageDeleteRequest request) throws Exception {
return false;
}
+
+ @Override
+ public SwiftStorageListResponse listSwiftStorage(SwiftStorageListRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public Optional<SwiftStorage> getSwiftStorage(SwiftStorageGetRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public SwiftStorage createSwiftStorage(SwiftStorageCreateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean updateSwiftStorage(SwiftStorageUpdateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean deleteSwiftStorage(SwiftStorageDeleteRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
}
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/file/FileBasedResourceBackend.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/file/FileBasedResourceBackend.java
index 0a9d9c0..3201a20 100644
--- a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/file/FileBasedResourceBackend.java
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/file/FileBasedResourceBackend.java
@@ -27,6 +27,7 @@ import org.apache.airavata.mft.resource.stubs.gcs.storage.*;
import org.apache.airavata.mft.resource.stubs.local.storage.*;
import org.apache.airavata.mft.resource.stubs.s3.storage.*;
import org.apache.airavata.mft.resource.stubs.scp.storage.*;
+import org.apache.airavata.mft.resource.stubs.swift.storage.*;
import org.apache.airavata.mft.storage.stubs.storagesecret.*;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -564,4 +565,29 @@ public class FileBasedResourceBackend implements ResourceBackend {
public boolean deleteFTPStorage(FTPStorageDeleteRequest request) {
throw new UnsupportedOperationException("Operation is not supported in backend");
}
+
+ @Override
+ public SwiftStorageListResponse listSwiftStorage(SwiftStorageListRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public Optional<SwiftStorage> getSwiftStorage(SwiftStorageGetRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public SwiftStorage createSwiftStorage(SwiftStorageCreateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean updateSwiftStorage(SwiftStorageUpdateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean deleteSwiftStorage(SwiftStorageDeleteRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
}
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/SQLResourceBackend.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/SQLResourceBackend.java
index 133c235..5194a21 100644
--- a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/SQLResourceBackend.java
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/SQLResourceBackend.java
@@ -29,6 +29,7 @@ import org.apache.airavata.mft.resource.stubs.gcs.storage.*;
import org.apache.airavata.mft.resource.stubs.local.storage.*;
import org.apache.airavata.mft.resource.stubs.s3.storage.*;
import org.apache.airavata.mft.resource.stubs.scp.storage.*;
+import org.apache.airavata.mft.resource.stubs.swift.storage.*;
import org.apache.airavata.mft.storage.stubs.storagesecret.*;
import org.dozer.DozerBeanMapper;
import org.slf4j.Logger;
@@ -53,6 +54,9 @@ public class SQLResourceBackend implements ResourceBackend {
@Autowired
private S3StorageRepository s3StorageRepository;
+ @Autowired
+ private SwiftStorageRepository swiftStorageRepository;
+
@Autowired
private FTPStorageRepository ftpStorageRepository;
@@ -451,4 +455,36 @@ public class SQLResourceBackend implements ResourceBackend {
return true;
}
+ @Override
+ public SwiftStorageListResponse listSwiftStorage(SwiftStorageListRequest request) throws Exception {
+ SwiftStorageListResponse.Builder respBuilder = SwiftStorageListResponse.newBuilder();
+ List<SwiftStorageEntity> all = swiftStorageRepository.findAll(PageRequest.of(request.getOffset(), request.getLimit()));
+ all.forEach(ety -> respBuilder.addStorages(mapper.map(ety, SwiftStorage.newBuilder().getClass())));
+ return respBuilder.build();
+ }
+
+ @Override
+ public Optional<SwiftStorage> getSwiftStorage(SwiftStorageGetRequest request) throws Exception {
+ Optional<SwiftStorageEntity> entity = swiftStorageRepository.findByStorageId(request.getStorageId());
+ return entity.map(e -> mapper.map(e, SwiftStorage.newBuilder().getClass()).build());
+ }
+
+ @Override
+ public SwiftStorage createSwiftStorage(SwiftStorageCreateRequest request) throws Exception {
+ SwiftStorageEntity savedEntity = swiftStorageRepository.save(mapper.map(request, SwiftStorageEntity.class));
+ return mapper.map(savedEntity, SwiftStorage.newBuilder().getClass()).build();
+ }
+
+ @Override
+ public boolean updateSwiftStorage(SwiftStorageUpdateRequest request) throws Exception {
+ swiftStorageRepository.save(mapper.map(request, SwiftStorageEntity.class));
+ return true;
+ }
+
+ @Override
+ public boolean deleteSwiftStorage(SwiftStorageDeleteRequest request) throws Exception {
+ swiftStorageRepository.deleteById(request.getStorageId());
+ resourceRepository.deleteByStorageIdAndStorageType(request.getStorageId(), GenericResourceEntity.StorageType.SWIFT);
+ return true;
+ }
}
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/entity/GenericResourceEntity.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/entity/GenericResourceEntity.java
index 4829fdc..4930cf3 100644
--- a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/entity/GenericResourceEntity.java
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/entity/GenericResourceEntity.java
@@ -15,7 +15,7 @@ public class GenericResourceEntity {
}
public enum StorageType {
- S3, SCP, LOCAL, FTP, BOX, DROPBOX, GCS, AZURE;
+ S3, SCP, LOCAL, FTP, BOX, DROPBOX, GCS, AZURE, SWIFT;
}
@Id
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/entity/SwiftStorageEntity.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/entity/SwiftStorageEntity.java
new file mode 100644
index 0000000..887c874
--- /dev/null
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/entity/SwiftStorageEntity.java
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+package org.apache.airavata.mft.resource.server.backend.sql.entity;
+
+import org.hibernate.annotations.GenericGenerator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class SwiftStorageEntity {
+ @Id
+ @Column(name = "SCP_STORAGE_ID")
+ @GeneratedValue(generator = "uuid")
+ @GenericGenerator(name = "uuid", strategy = "uuid2")
+ private String storageId;
+
+ @Column(name = "STORAGE_NAME")
+ private String name;
+
+ @Column(name = "CONTAINER")
+ String container;
+
+ @Column(name = "ENDPOINT")
+ String endpoint;
+
+ @Column(name = "REGION")
+ String region;
+
+ @Column(name = "KEYSTONE_VERSION")
+ int keystoneVersion;
+
+ public String getStorageId() {
+ return storageId;
+ }
+
+ public void setStorageId(String storageId) {
+ this.storageId = storageId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getContainer() {
+ return container;
+ }
+
+ public void setContainer(String container) {
+ this.container = container;
+ }
+
+ public String getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public String getRegion() {
+ return region;
+ }
+
+ public void setRegion(String region) {
+ this.region = region;
+ }
+
+ public int getKeystoneVersion() {
+ return keystoneVersion;
+ }
+
+ public void setKeystoneVersion(int keystoneVersion) {
+ this.keystoneVersion = keystoneVersion;
+ }
+}
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/repository/SwiftStorageRepository.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/repository/SwiftStorageRepository.java
new file mode 100644
index 0000000..fd69c11
--- /dev/null
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/backend/sql/repository/SwiftStorageRepository.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package org.apache.airavata.mft.resource.server.backend.sql.repository;
+
+import org.apache.airavata.mft.resource.server.backend.sql.entity.SwiftStorageEntity;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface SwiftStorageRepository extends CrudRepository<SwiftStorageEntity, String> {
+ Optional<SwiftStorageEntity> findByStorageId(String storageId);
+ List<SwiftStorageEntity> findAll(Pageable pageable);
+}
diff --git a/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/handler/SwiftStorageHandler.java b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/handler/SwiftStorageHandler.java
new file mode 100644
index 0000000..35b9d33
--- /dev/null
+++ b/services/resource-service/server/src/main/java/org/apache/airavata/mft/resource/server/handler/SwiftStorageHandler.java
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+package org.apache.airavata.mft.resource.server.handler;
+
+import io.grpc.Status;
+import io.grpc.stub.StreamObserver;
+import org.apache.airavata.mft.resource.server.backend.ResourceBackend;
+import org.apache.airavata.mft.resource.service.swift.SwiftStorageServiceGrpc;
+import org.apache.airavata.mft.resource.stubs.swift.storage.*;
+import org.lognet.springboot.grpc.GRpcService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+@GRpcService
+public class SwiftStorageHandler extends SwiftStorageServiceGrpc.SwiftStorageServiceImplBase {
+
+ private static final Logger logger = LoggerFactory.getLogger(SwiftStorageHandler.class);
+
+ @Autowired
+ private ResourceBackend backend;
+
+ @Override
+ public void listSwiftStorage(SwiftStorageListRequest request, StreamObserver<SwiftStorageListResponse> responseObserver) {
+ try {
+ SwiftStorageListResponse response = this.backend.listSwiftStorage(request);
+ responseObserver.onNext(response);
+ responseObserver.onCompleted();
+ } catch (Exception e) {
+ logger.error("Failed in retrieving Swift storage list", e);
+
+ responseObserver.onError(Status.INTERNAL.withCause(e)
+ .withDescription("Failed in retrieving Swift storage list")
+ .asRuntimeException());
+ }
+ }
+
+ @Override
+ public void getSwiftStorage(SwiftStorageGetRequest request, StreamObserver<SwiftStorage> responseObserver) {
+ try {
+ this.backend.getSwiftStorage(request).ifPresentOrElse(resource -> {
+ responseObserver.onNext(resource);
+ responseObserver.onCompleted();
+ }, () -> {
+ responseObserver.onError(Status.INTERNAL
+ .withDescription("No Swift storage with id " + request.getStorageId())
+ .asRuntimeException());
+ });
+ } catch (Exception e) {
+ logger.error("Failed in retrieving Swift storage with id {}", request.getStorageId(), e);
+
+ responseObserver.onError(Status.INTERNAL.withCause(e)
+ .withDescription("Failed in retrieving Swift storage with id " + request.getStorageId())
+ .asRuntimeException());
+ }
+ }
+
+ @Override
+ public void createSwiftStorage(SwiftStorageCreateRequest request, StreamObserver<SwiftStorage> responseObserver) {
+ try {
+ responseObserver.onNext(this.backend.createSwiftStorage(request));
+ responseObserver.onCompleted();
+ } catch (Exception e) {
+ logger.error("Failed in creating the Swift storage", e);
+
+ responseObserver.onError(Status.INTERNAL.withCause(e)
+ .withDescription("Failed in creating the Swift storage")
+ .asRuntimeException());
+ }
+ }
+
+ @Override
+ public void updateSwiftStorage(SwiftStorageUpdateRequest request, StreamObserver<SwiftStorageUpdateResponse> responseObserver) {
+ try {
+ this.backend.updateSwiftStorage(request);
+ responseObserver.onNext(SwiftStorageUpdateResponse.newBuilder().setStorageId(request.getStorageId()).build());
+ responseObserver.onCompleted();
+ } catch (Exception e) {
+ logger.error("Failed in updating the Swift storage {}", request.getStorageId(), e);
+
+ responseObserver.onError(Status.INTERNAL.withCause(e)
+ .withDescription("Failed in updating the Swift storage with id " + request.getStorageId())
+ .asRuntimeException());
+ }
+ }
+
+ @Override
+ public void deleteSwiftStorage(SwiftStorageDeleteRequest request, StreamObserver<SwiftStorageDeleteResponse> responseObserver) {
+ try {
+ boolean res = this.backend.deleteSwiftStorage(request);
+ if (res) {
+ responseObserver.onNext(SwiftStorageDeleteResponse.newBuilder().setStatus(true).build());
+ responseObserver.onCompleted();
+ } else {
+ responseObserver.onError(new Exception("Failed to delete Swift storage with id " + request.getStorageId()));
+ }
+ } catch (Exception e) {
+ logger.error("Failed in deleting the Swift storage {}", request.getStorageId(), e);
+
+ responseObserver.onError(Status.INTERNAL.withCause(e)
+ .withDescription("Failed in deleting the Swift storage with id " + request.getStorageId())
+ .asRuntimeException());
+ }
+ }
+}
diff --git a/services/resource-service/stub/src/main/proto/resource/ResourceService.proto b/services/resource-service/stub/src/main/proto/resource/ResourceService.proto
index 5002c4e..c79f1e3 100644
--- a/services/resource-service/stub/src/main/proto/resource/ResourceService.proto
+++ b/services/resource-service/stub/src/main/proto/resource/ResourceService.proto
@@ -28,6 +28,7 @@ import "gcs/GCSStorage.proto";
import "local/LocalStorage.proto";
import "s3/S3Storage.proto";
import "scp/SCPStorage.proto";
+import "swift/SwiftStorage.proto";
import "CredCommon.proto";
message FileResource {
@@ -56,6 +57,7 @@ message GenericResource {
org.apache.airavata.mft.resource.stubs.scp.storage.SCPStorage scpStorage = 9;
org.apache.airavata.mft.resource.stubs.box.storage.BoxStorage boxStorage = 10;
org.apache.airavata.mft.resource.stubs.azure.storage.AzureStorage azureStorage = 11;
+ org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorage swiftStorage = 12;
}
}
@@ -80,6 +82,7 @@ message GenericResourceCreateRequest {
DROPBOX = 5;
GCS = 6;
AZURE = 7;
+ SWIFT = 8;
}
StorageType storageType = 5;
diff --git a/services/resource-service/stub/src/main/proto/swift/SwiftStorage.proto b/services/resource-service/stub/src/main/proto/swift/SwiftStorage.proto
new file mode 100644
index 0000000..824491e
--- /dev/null
+++ b/services/resource-service/stub/src/main/proto/swift/SwiftStorage.proto
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+package org.apache.airavata.mft.resource.stubs.swift.storage;
+
+message SwiftStorage {
+ string storageId = 1;
+ string container = 2;
+ string name = 3;
+ string endpoint = 4;
+ string region = 5;
+ int32 keystoneVersion = 6;
+}
+
+message SwiftStorageListRequest {
+ int32 offset = 1;
+ int32 limit = 2;
+}
+
+message SwiftStorageListResponse {
+ repeated SwiftStorage storages = 1;
+}
+
+message SwiftStorageGetRequest {
+ string storageId = 1;
+}
+
+message SwiftStorageCreateRequest {
+ string storageId = 1;
+ string container = 2;
+ string name = 3;
+ string endpoint = 4;
+ string region = 5;
+ int32 keystoneVersion = 6;
+}
+
+message SwiftStorageUpdateRequest {
+ string storageId = 1;
+ string container = 2;
+ string name = 3;
+ string endpoint = 4;
+ string region = 5;
+ int32 keystoneVersion = 6;
+}
+
+message SwiftStorageUpdateResponse {
+ string storageId = 1;
+}
+
+message SwiftStorageDeleteRequest {
+ string storageId = 1;
+}
+
+message SwiftStorageDeleteResponse {
+ bool status = 1;
+}
\ No newline at end of file
diff --git a/services/resource-service/stub/src/main/proto/swift/SwiftStorageService.proto b/services/resource-service/stub/src/main/proto/swift/SwiftStorageService.proto
new file mode 100644
index 0000000..0bed7f8
--- /dev/null
+++ b/services/resource-service/stub/src/main/proto/swift/SwiftStorageService.proto
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+package org.apache.airavata.mft.resource.service.swift;
+
+import "swift/SwiftStorage.proto";
+
+service SwiftStorageService {
+
+ // Storage
+
+ rpc listSwiftStorage (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorageListRequest) returns (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorageListResponse);
+
+ rpc getSwiftStorage (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorageGetRequest) returns
+ (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorage);
+
+ rpc createSwiftStorage (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorageCreateRequest) returns
+ (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorage);
+
+ rpc updateSwiftStorage (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorageUpdateRequest) returns
+ (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorageUpdateResponse);
+
+ rpc deleteSwiftStorage (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorageDeleteRequest) returns
+ (org.apache.airavata.mft.resource.stubs.swift.storage.SwiftStorageDeleteResponse);
+}
\ No newline at end of file
diff --git a/services/secret-service/client/src/main/java/org/apache/airavata/mft/secret/client/SecretServiceClient.java b/services/secret-service/client/src/main/java/org/apache/airavata/mft/secret/client/SecretServiceClient.java
index f7299de..a93a590 100644
--- a/services/secret-service/client/src/main/java/org/apache/airavata/mft/secret/client/SecretServiceClient.java
+++ b/services/secret-service/client/src/main/java/org/apache/airavata/mft/secret/client/SecretServiceClient.java
@@ -25,6 +25,7 @@ import org.apache.airavata.mft.credential.service.ftp.FTPSecretServiceGrpc;
import org.apache.airavata.mft.credential.service.gcs.GCSSecretServiceGrpc;
import org.apache.airavata.mft.credential.service.s3.S3SecretServiceGrpc;
import org.apache.airavata.mft.credential.service.scp.SCPSecretServiceGrpc;
+import org.apache.airavata.mft.credential.service.swift.SwiftSecretServiceGrpc;
import java.io.Closeable;
import java.io.IOException;
@@ -65,6 +66,9 @@ public class SecretServiceClient implements Closeable {
return DropboxSecretServiceGrpc.newBlockingStub(channel);
}
+ public SwiftSecretServiceGrpc.SwiftSecretServiceBlockingStub swift() {
+ return SwiftSecretServiceGrpc.newBlockingStub(channel);
+ }
@Override
public void close() throws IOException {
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/SecretBackend.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/SecretBackend.java
index d75d789..7da5e14 100644
--- a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/SecretBackend.java
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/SecretBackend.java
@@ -24,6 +24,7 @@ import org.apache.airavata.mft.credential.stubs.ftp.*;
import org.apache.airavata.mft.credential.stubs.gcs.*;
import org.apache.airavata.mft.credential.stubs.s3.*;
import org.apache.airavata.mft.credential.stubs.scp.*;
+import org.apache.airavata.mft.credential.stubs.swift.*;
import java.util.Optional;
@@ -66,4 +67,9 @@ public interface SecretBackend {
FTPSecret createFTPSecret(FTPSecretCreateRequest request) throws Exception;
boolean updateFTPSecret(FTPSecretUpdateRequest request) throws Exception;
boolean deleteFTPSecret(FTPSecretDeleteRequest request) throws Exception;
+
+ Optional<SwiftSecret> getSwiftSecret(SwiftSecretGetRequest request) throws Exception;
+ SwiftSecret createSwiftSecret(SwiftSecretCreateRequest request) throws Exception;
+ boolean updateSwiftSecret(SwiftSecretUpdateRequest request) throws Exception;
+ boolean deleteSwiftSecret(SwiftSecretDeleteRequest request) throws Exception;
}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/airavata/AiravataSecretBackend.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/airavata/AiravataSecretBackend.java
index 2288293..0240b1e 100644
--- a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/airavata/AiravataSecretBackend.java
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/airavata/AiravataSecretBackend.java
@@ -26,6 +26,7 @@ import org.apache.airavata.mft.credential.stubs.ftp.*;
import org.apache.airavata.mft.credential.stubs.gcs.*;
import org.apache.airavata.mft.credential.stubs.s3.*;
import org.apache.airavata.mft.credential.stubs.scp.*;
+import org.apache.airavata.mft.credential.stubs.swift.*;
import org.apache.airavata.mft.secret.server.backend.SecretBackend;
import org.apache.airavata.model.credential.store.SSHCredential;
import org.slf4j.Logger;
@@ -206,4 +207,24 @@ public class AiravataSecretBackend implements SecretBackend {
throw new UnsupportedOperationException("Operation is not supported in backend");
}
+ @Override
+ public Optional<SwiftSecret> getSwiftSecret(SwiftSecretGetRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public SwiftSecret createSwiftSecret(SwiftSecretCreateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean updateSwiftSecret(SwiftSecretUpdateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean deleteSwiftSecret(SwiftSecretDeleteRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/custos/CustosSecretBackend.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/custos/CustosSecretBackend.java
index c71ef77..ea47c74 100644
--- a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/custos/CustosSecretBackend.java
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/custos/CustosSecretBackend.java
@@ -16,6 +16,7 @@ import org.apache.airavata.mft.credential.stubs.ftp.*;
import org.apache.airavata.mft.credential.stubs.gcs.*;
import org.apache.airavata.mft.credential.stubs.s3.*;
import org.apache.airavata.mft.credential.stubs.scp.*;
+import org.apache.airavata.mft.credential.stubs.swift.*;
import org.apache.airavata.mft.secret.server.backend.SecretBackend;
import org.apache.airavata.mft.secret.server.backend.custos.auth.AgentAuthenticationHandler;
import org.apache.airavata.mft.secret.server.backend.custos.auth.AuthConfig;
@@ -602,6 +603,26 @@ public class CustosSecretBackend implements SecretBackend {
return false;
}
+ @Override
+ public Optional<SwiftSecret> getSwiftSecret(SwiftSecretGetRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public SwiftSecret createSwiftSecret(SwiftSecretCreateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean updateSwiftSecret(SwiftSecretUpdateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean deleteSwiftSecret(SwiftSecretDeleteRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
private ResourceSecretManagementClient getTenantResourceSecretManagementClient(DelegateAuth delegateAuth) throws IOException {
CustosClientProvider custosClientProvider = custosClientsFactory
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/file/FileBasedSecretBackend.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/file/FileBasedSecretBackend.java
index c93c877..dc3dcc0 100644
--- a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/file/FileBasedSecretBackend.java
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/file/FileBasedSecretBackend.java
@@ -24,6 +24,7 @@ import org.apache.airavata.mft.credential.stubs.ftp.*;
import org.apache.airavata.mft.credential.stubs.gcs.*;
import org.apache.airavata.mft.credential.stubs.s3.*;
import org.apache.airavata.mft.credential.stubs.scp.*;
+import org.apache.airavata.mft.credential.stubs.swift.*;
import org.apache.airavata.mft.secret.server.backend.SecretBackend;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -341,4 +342,24 @@ public class FileBasedSecretBackend implements SecretBackend {
throw new UnsupportedOperationException("Operation is not supported in backend");
}
+ @Override
+ public Optional<SwiftSecret> getSwiftSecret(SwiftSecretGetRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public SwiftSecret createSwiftSecret(SwiftSecretCreateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean updateSwiftSecret(SwiftSecretUpdateRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
+ @Override
+ public boolean deleteSwiftSecret(SwiftSecretDeleteRequest request) throws Exception {
+ throw new UnsupportedOperationException("Operation is not supported in backend");
+ }
+
}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/SQLSecretBackend.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/SQLSecretBackend.java
index 197b004..4cea50d 100644
--- a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/SQLSecretBackend.java
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/SQLSecretBackend.java
@@ -24,13 +24,20 @@ import org.apache.airavata.mft.credential.stubs.ftp.*;
import org.apache.airavata.mft.credential.stubs.gcs.*;
import org.apache.airavata.mft.credential.stubs.s3.*;
import org.apache.airavata.mft.credential.stubs.scp.*;
+import org.apache.airavata.mft.credential.stubs.swift.*;
import org.apache.airavata.mft.secret.server.backend.SecretBackend;
import org.apache.airavata.mft.secret.server.backend.sql.entity.FTPSecretEntity;
import org.apache.airavata.mft.secret.server.backend.sql.entity.S3SecretEntity;
import org.apache.airavata.mft.secret.server.backend.sql.entity.SCPSecretEntity;
+import org.apache.airavata.mft.secret.server.backend.sql.entity.swift.SwiftAuthCredentialSecretEntity;
+import org.apache.airavata.mft.secret.server.backend.sql.entity.swift.SwiftPasswordSecretEntity;
+import org.apache.airavata.mft.secret.server.backend.sql.entity.swift.SwiftSecretEntity;
import org.apache.airavata.mft.secret.server.backend.sql.repository.FTPSecretRepository;
import org.apache.airavata.mft.secret.server.backend.sql.repository.S3SecretRepository;
import org.apache.airavata.mft.secret.server.backend.sql.repository.SCPSecretRepository;
+import org.apache.airavata.mft.secret.server.backend.sql.repository.swift.SwiftAuthCredentialSecretRepository;
+import org.apache.airavata.mft.secret.server.backend.sql.repository.swift.SwiftPasswordSecretRepository;
+import org.apache.airavata.mft.secret.server.backend.sql.repository.swift.SwiftSecretRepository;
import org.dozer.DozerBeanMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,6 +58,15 @@ public class SQLSecretBackend implements SecretBackend {
@Autowired
private S3SecretRepository s3SecretRepository;
+ @Autowired
+ private SwiftSecretRepository swiftSecretRepository;
+
+ @Autowired
+ private SwiftPasswordSecretRepository swiftPasswordSecretRepository;
+
+ @Autowired
+ private SwiftAuthCredentialSecretRepository swiftAuthCredentialSecretRepository;
+
private DozerBeanMapper mapper = new DozerBeanMapper();
@Override
@@ -191,6 +207,109 @@ public class SQLSecretBackend implements SecretBackend {
throw new UnsupportedOperationException("Operation is not supported in backend");
}
+ @Override
+ public Optional<SwiftSecret> getSwiftSecret(SwiftSecretGetRequest request) throws Exception {
+ Optional<SwiftSecretEntity> secEtyOp = swiftSecretRepository.findBySecretId(request.getSecretId());
+ if (secEtyOp.isPresent()) {
+ SwiftSecret.Builder secBuilder = SwiftSecret.newBuilder();
+ SwiftSecretEntity secEty = secEtyOp.get();
+ secBuilder.setSecretId(secEty.getSecretId());
+
+ switch (secEty.getInternalSecretType()) {
+ case PASSWORD:
+ Optional<SwiftPasswordSecretEntity> passSec = swiftPasswordSecretRepository
+ .findBySecretId(secEty.getInternalSecretId());
+ if (passSec.isPresent()) {
+ SwiftPasswordSecret.Builder passBuilder = SwiftPasswordSecret.newBuilder();
+ mapper.map(passSec.get(), passBuilder);
+ secBuilder.setPasswordSecret(passBuilder.build());
+ } else {
+ throw new Exception("Can not find a swift password secret with id " + secEty.getInternalSecretId());
+ }
+ break;
+ case AUTH_CREDENTIAL:
+ Optional<SwiftAuthCredentialSecretEntity> authCredSec = swiftAuthCredentialSecretRepository
+ .findBySecretId(secEty.getInternalSecretId());
+ if (authCredSec.isPresent()) {
+ SwiftAuthCredentialSecret.Builder authBuilder = SwiftAuthCredentialSecret.newBuilder();
+ mapper.map(authCredSec.get(), authBuilder);
+ secBuilder.setAuthCredentialSecret(authBuilder.build());
+ } else {
+ throw new Exception("Can not find a swift auth cred secret with id " + secEty.getInternalSecretId());
+ }
+ break;
+ default:
+ throw new Exception("Non compatible internal secret type : " + secEty.getInternalSecretType());
+ }
+ return Optional.of(secBuilder.build());
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public SwiftSecret createSwiftSecret(SwiftSecretCreateRequest request) throws Exception {
+
+ SwiftSecretEntity secEty = new SwiftSecretEntity();
+ SwiftAuthCredentialSecretEntity authCredSaved = null;
+ SwiftPasswordSecretEntity passSecSaved = null;
+
+ switch (request.getSecretCase()) {
+ case PASSWORDSECRET:
+ passSecSaved = swiftPasswordSecretRepository
+ .save(mapper.map(request.getPasswordSecret(), SwiftPasswordSecretEntity.class));
+ secEty.setInternalSecretId(passSecSaved.getSecretId());
+ secEty.setInternalSecretType(SwiftSecretEntity.InternalSecretType.PASSWORD);
+ break;
+ case AUTHCREDENTIALSECRET:
+ authCredSaved = swiftAuthCredentialSecretRepository
+ .save(mapper.map(request.getAuthCredentialSecret(), SwiftAuthCredentialSecretEntity.class));
+ secEty.setInternalSecretId(authCredSaved.getSecretId());
+ secEty.setInternalSecretType(SwiftSecretEntity.InternalSecretType.AUTH_CREDENTIAL);
+ break;
+ case SECRET_NOT_SET:
+ throw new Exception("No internal secret is set");
+ }
+
+ SwiftSecretEntity savedEty = swiftSecretRepository.save(secEty);
+ SwiftSecret.Builder secBuilder = SwiftSecret.newBuilder();
+ secBuilder.setSecretId(savedEty.getSecretId());
+ switch (savedEty.getInternalSecretType()) {
+ case PASSWORD:
+ secBuilder.setPasswordSecret(mapper.map(passSecSaved, SwiftPasswordSecret.newBuilder().getClass()));
+ break;
+ case AUTH_CREDENTIAL:
+ secBuilder.setAuthCredentialSecret(mapper.map(authCredSaved, SwiftAuthCredentialSecret.newBuilder().getClass()));
+ break;
+ }
+
+ return secBuilder.build();
+ }
+
+ @Override
+ public boolean updateSwiftSecret(SwiftSecretUpdateRequest request) throws Exception {
+ return false;
+ }
+
+ @Override
+ public boolean deleteSwiftSecret(SwiftSecretDeleteRequest request) throws Exception {
+ Optional<SwiftSecretEntity> secOp = swiftSecretRepository.findBySecretId(request.getSecretId());
+ if (secOp.isPresent()) {
+ swiftSecretRepository.deleteById(request.getSecretId());
+ switch (secOp.get().getInternalSecretType()) {
+ case AUTH_CREDENTIAL:
+ swiftAuthCredentialSecretRepository.deleteById(secOp.get().getInternalSecretId());
+ break;
+ case PASSWORD:
+ swiftPasswordSecretRepository.deleteById(secOp.get().getInternalSecretId());
+ break;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
@Override
public Optional<FTPSecret> getFTPSecret(FTPSecretGetRequest request) {
Optional<FTPSecretEntity> secretEty = ftpSecretRepository.findBySecretId(request.getSecretId());
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/swift/SwiftAuthCredentialSecretEntity.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/swift/SwiftAuthCredentialSecretEntity.java
new file mode 100644
index 0000000..7b07f94
--- /dev/null
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/swift/SwiftAuthCredentialSecretEntity.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+package org.apache.airavata.mft.secret.server.backend.sql.entity.swift;
+
+import org.hibernate.annotations.GenericGenerator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class SwiftAuthCredentialSecretEntity {
+
+ @Id
+ @Column(name = "SECRET_ID")
+ @GeneratedValue(generator = "uuid")
+ @GenericGenerator(name = "uuid", strategy = "uuid2")
+ private String secretId;
+
+ @Column(name = "CREDENTIAL_ID")
+ private String credentialId;
+
+ @Column(name = "CREDENTIAL_SECRET")
+ private String credentialSecret;
+
+ public String getSecretId() {
+ return secretId;
+ }
+
+ public void setSecretId(String secretId) {
+ this.secretId = secretId;
+ }
+
+ public String getCredentialId() {
+ return credentialId;
+ }
+
+ public void setCredentialId(String credentialId) {
+ this.credentialId = credentialId;
+ }
+
+ public String getCredentialSecret() {
+ return credentialSecret;
+ }
+
+ public void setCredentialSecret(String credentialSecret) {
+ this.credentialSecret = credentialSecret;
+ }
+}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/swift/SwiftPasswordSecretEntity.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/swift/SwiftPasswordSecretEntity.java
new file mode 100644
index 0000000..9157af5
--- /dev/null
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/swift/SwiftPasswordSecretEntity.java
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+package org.apache.airavata.mft.secret.server.backend.sql.entity.swift;
+
+import org.hibernate.annotations.GenericGenerator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class SwiftPasswordSecretEntity {
+
+ @Id
+ @Column(name = "SECRET_ID")
+ @GeneratedValue(generator = "uuid")
+ @GenericGenerator(name = "uuid", strategy = "uuid2")
+ private String secretId;
+
+ @Column(name = "USER_NAME")
+ String userName;
+
+ @Column(name = "PASSWORD")
+ String password;
+
+ @Column(name = "PROJECT_ID")
+ String projectId;
+
+ @Column(name = "DOMAIN_ID")
+ String domainId;
+
+ public String getSecretId() {
+ return secretId;
+ }
+
+ public void setSecretId(String secretId) {
+ this.secretId = secretId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getProjectId() {
+ return projectId;
+ }
+
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
+ }
+
+ public String getDomainId() {
+ return domainId;
+ }
+
+ public void setDomainId(String domainId) {
+ this.domainId = domainId;
+ }
+}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/swift/SwiftSecretEntity.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/swift/SwiftSecretEntity.java
new file mode 100644
index 0000000..203edec
--- /dev/null
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/entity/swift/SwiftSecretEntity.java
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+package org.apache.airavata.mft.secret.server.backend.sql.entity.swift;
+
+import org.hibernate.annotations.GenericGenerator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class SwiftSecretEntity {
+
+ public enum InternalSecretType {
+ PASSWORD, AUTH_CREDENTIAL;
+ }
+
+ @Id
+ @Column(name = "SECRET_ID")
+ @GeneratedValue(generator = "uuid")
+ @GenericGenerator(name = "uuid", strategy = "uuid2")
+ private String secretId;
+
+ @Column(name = "INTERNAL_SECRET_ID")
+ private String internalSecretId;
+
+ @Column(name = "INTERNAL_SECRET_TYPE")
+ private InternalSecretType internalSecretType;
+
+ public String getSecretId() {
+ return secretId;
+ }
+
+ public void setSecretId(String secretId) {
+ this.secretId = secretId;
+ }
+
+ public String getInternalSecretId() {
+ return internalSecretId;
+ }
+
+ public void setInternalSecretId(String internalSecretId) {
+ this.internalSecretId = internalSecretId;
+ }
+
+ public InternalSecretType getInternalSecretType() {
+ return internalSecretType;
+ }
+
+ public void setInternalSecretType(InternalSecretType internalSecretType) {
+ this.internalSecretType = internalSecretType;
+ }
+}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/repository/swift/SwiftAuthCredentialSecretRepository.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/repository/swift/SwiftAuthCredentialSecretRepository.java
new file mode 100644
index 0000000..9cda467
--- /dev/null
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/repository/swift/SwiftAuthCredentialSecretRepository.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+package org.apache.airavata.mft.secret.server.backend.sql.repository.swift;
+
+import org.apache.airavata.mft.secret.server.backend.sql.entity.swift.SwiftAuthCredentialSecretEntity;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.Optional;
+
+public interface SwiftAuthCredentialSecretRepository extends CrudRepository<SwiftAuthCredentialSecretEntity, String> {
+ Optional<SwiftAuthCredentialSecretEntity> findBySecretId(String secretId);
+}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/repository/swift/SwiftPasswordSecretRepository.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/repository/swift/SwiftPasswordSecretRepository.java
new file mode 100644
index 0000000..51ef5b4
--- /dev/null
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/repository/swift/SwiftPasswordSecretRepository.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+package org.apache.airavata.mft.secret.server.backend.sql.repository.swift;
+
+import org.apache.airavata.mft.secret.server.backend.sql.entity.swift.SwiftPasswordSecretEntity;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.Optional;
+
+public interface SwiftPasswordSecretRepository extends CrudRepository<SwiftPasswordSecretEntity, String> {
+ Optional<SwiftPasswordSecretEntity> findBySecretId(String secretId);
+
+}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/repository/swift/SwiftSecretRepository.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/repository/swift/SwiftSecretRepository.java
new file mode 100644
index 0000000..931b668
--- /dev/null
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/backend/sql/repository/swift/SwiftSecretRepository.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+package org.apache.airavata.mft.secret.server.backend.sql.repository.swift;
+
+import org.apache.airavata.mft.secret.server.backend.sql.entity.swift.SwiftSecretEntity;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.Optional;
+
+public interface SwiftSecretRepository extends CrudRepository<SwiftSecretEntity, String> {
+ Optional<SwiftSecretEntity> findBySecretId(String secretId);
+}
diff --git a/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/handler/SwiftServiceHandler.java b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/handler/SwiftServiceHandler.java
new file mode 100644
index 0000000..1963cc8
--- /dev/null
+++ b/services/secret-service/server/src/main/java/org/apache/airavata/mft/secret/server/handler/SwiftServiceHandler.java
@@ -0,0 +1,82 @@
+package org.apache.airavata.mft.secret.server.handler;
+
+import io.grpc.Status;
+import io.grpc.stub.StreamObserver;
+import org.apache.airavata.mft.credential.service.swift.SwiftSecretServiceGrpc;
+import org.apache.airavata.mft.credential.stubs.swift.*;
+import org.apache.airavata.mft.secret.server.backend.SecretBackend;
+import org.lognet.springboot.grpc.GRpcService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+@GRpcService
+public class SwiftServiceHandler extends SwiftSecretServiceGrpc.SwiftSecretServiceImplBase {
+
+ private static final Logger logger = LoggerFactory.getLogger(SwiftServiceHandler.class);
+
+ @Autowired
+ private SecretBackend backend;
+
+ @Override
+ public void getSwiftSecret(SwiftSecretGetRequest request, StreamObserver<SwiftSecret> responseObserver) {
+ try {
+ this.backend.getSwiftSecret(request).ifPresentOrElse(secret -> {
+ responseObserver.onNext(secret);
+ responseObserver.onCompleted();
+ }, () -> {
+ responseObserver.onError(Status.INTERNAL
+ .withDescription("No Swift Secret with id " + request.getSecretId())
+ .asRuntimeException());
+ });
+ } catch (Exception e) {
+
+ logger.error("Error in retrieving Swift Secret with id " + request.getSecretId(), e);
+ responseObserver.onError(Status.INTERNAL.withCause(e)
+ .withDescription("Error in retrieving Swift Secret with id " + request.getSecretId())
+ .asRuntimeException());
+ }
+ }
+
+ @Override
+ public void createSwiftSecret(SwiftSecretCreateRequest request, StreamObserver<SwiftSecret> responseObserver) {
+ try {
+ SwiftSecret swiftSecret = this.backend.createSwiftSecret(request);
+ responseObserver.onNext(swiftSecret);
+ responseObserver.onCompleted();
+ } catch (Exception e) {
+ logger.error("Error in creating Swift Secret", e);
+ responseObserver.onError(Status.INTERNAL.withCause(e)
+ .withDescription("Error in creating Swift Secret")
+ .asRuntimeException());
+ }
+ }
+
+ @Override
+ public void updateSwiftSecret(SwiftSecretUpdateRequest request, StreamObserver<SwiftSecretUpdateResponse> responseObserver) {
+ try {
+ this.backend.updateSwiftSecret(request);
+ responseObserver.onNext(SwiftSecretUpdateResponse.newBuilder().setSecretId(request.getSecretId()).build());
+ responseObserver.onCompleted();
+ } catch (Exception e) {
+ logger.error("Error in updating Swift Secret with id {}", request.getSecretId(), e);
+ responseObserver.onError(Status.INTERNAL.withCause(e)
+ .withDescription("Error in updating Swift Secret with id " + request.getSecretId())
+ .asRuntimeException());
+ }
+ }
+
+ @Override
+ public void deleteSwiftSecret(SwiftSecretDeleteRequest request, StreamObserver<SwiftSecretDeleteResponse> responseObserver) {
+ try {
+ this.backend.deleteSwiftSecret(request);
+ responseObserver.onNext(SwiftSecretDeleteResponse.newBuilder().setStatus(true).build());
+ responseObserver.onCompleted();
+ } catch (Exception e) {
+ logger.error("Error in deleting Swift Secret with id {}", request.getSecretId(), e);
+ responseObserver.onError(Status.INTERNAL.withCause(e)
+ .withDescription("Error in deleting Swift Secret with id " + request.getSecretId())
+ .asRuntimeException());
+ }
+ }
+}
diff --git a/services/secret-service/stub/src/main/proto/swift/SwiftCredential.proto b/services/secret-service/stub/src/main/proto/swift/SwiftCredential.proto
new file mode 100644
index 0000000..02f34d2
--- /dev/null
+++ b/services/secret-service/stub/src/main/proto/swift/SwiftCredential.proto
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+package org.apache.airavata.mft.credential.stubs.swift;
+
+import "CredCommon.proto";
+
+message SwiftPasswordSecret {
+ string userName = 1;
+ string password = 2;
+ string projectId = 3;
+ string domainId = 4;
+}
+
+message SwiftAuthCredentialSecret {
+ string credentialId = 1;
+ string credentialSecret = 2;
+}
+
+message SwiftSecret {
+ string secretId = 1;
+ oneof secret {
+ SwiftPasswordSecret passwordSecret = 2;
+ SwiftAuthCredentialSecret authCredentialSecret = 3;
+ }
+}
+
+message SwiftSecretGetRequest {
+ string secretId = 1;
+ org.apache.airavata.mft.common.AuthToken authzToken = 2;
+}
+
+message SwiftSecretCreateRequest {
+ oneof secret {
+ SwiftPasswordSecret passwordSecret = 1;
+ SwiftAuthCredentialSecret authCredentialSecret = 2;
+ }
+ org.apache.airavata.mft.common.AuthToken authzToken = 3;
+}
+
+message SwiftSecretUpdateRequest {
+ string secretId = 1;
+ oneof secret {
+ SwiftPasswordSecret passwordSecret = 2;
+ SwiftAuthCredentialSecret authCredentialSecret = 3;
+ }
+ org.apache.airavata.mft.common.AuthToken authzToken = 4;
+}
+
+message SwiftSecretUpdateResponse {
+ string secretId = 1;
+}
+
+message SwiftSecretDeleteRequest {
+ string secretId = 1;
+ org.apache.airavata.mft.common.AuthToken authzToken = 2;
+}
+
+message SwiftSecretDeleteResponse {
+ bool status = 1;
+}
diff --git a/services/secret-service/stub/src/main/proto/swift/SwiftSecretService.proto b/services/secret-service/stub/src/main/proto/swift/SwiftSecretService.proto
new file mode 100644
index 0000000..891ef66
--- /dev/null
+++ b/services/secret-service/stub/src/main/proto/swift/SwiftSecretService.proto
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+package org.apache.airavata.mft.credential.service.swift;
+
+import "swift/SwiftCredential.proto";
+
+service SwiftSecretService {
+ rpc getSwiftSecret (org.apache.airavata.mft.credential.stubs.swift.SwiftSecretGetRequest) returns
+ (org.apache.airavata.mft.credential.stubs.swift.SwiftSecret);
+
+ rpc createSwiftSecret (org.apache.airavata.mft.credential.stubs.swift.SwiftSecretCreateRequest) returns
+ (org.apache.airavata.mft.credential.stubs.swift.SwiftSecret);
+
+ rpc updateSwiftSecret (org.apache.airavata.mft.credential.stubs.swift.SwiftSecretUpdateRequest) returns
+ (org.apache.airavata.mft.credential.stubs.swift.SwiftSecretUpdateResponse);
+
+ rpc deleteSwiftSecret (org.apache.airavata.mft.credential.stubs.swift.SwiftSecretDeleteRequest) returns
+ (org.apache.airavata.mft.credential.stubs.swift.SwiftSecretDeleteResponse);
+}
\ No newline at end of file