You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by is...@apache.org on 2021/06/16 12:17:36 UTC

[airavata-custos] branch develop updated: create defaukt permission types and entity types at tenant activation

This is an automated email from the ASF dual-hosted git repository.

isjarana pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git


The following commit(s) were added to refs/heads/develop by this push:
     new 4e85200  create defaukt permission types and entity types at tenant activation
     new d917703  Merge pull request #210 from isururanawaka/develop
4e85200 is described below

commit 4e8520047b36e8ce51876a060b4053b63f29be58
Author: Isuru Ranawaka <ir...@gmail.com>
AuthorDate: Wed Jun 16 08:16:38 2021 -0400

    create defaukt permission types and entity types at tenant activation
---
 .../resources/tenantManagementService.properties   |  4 +-
 .../tenant-management-service/pom.xml              | 11 ++++++
 .../management/tasks/TenantActivationTask.java     | 45 +++++++++++++++++++---
 3 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/custos-core-services/utility-services/custos-configuration-service/src/main/resources/tenantManagementService.properties b/custos-core-services/utility-services/custos-configuration-service/src/main/resources/tenantManagementService.properties
index 7d5b1a8..9a66b09 100644
--- a/custos-core-services/utility-services/custos-configuration-service/src/main/resources/tenantManagementService.properties
+++ b/custos-core-services/utility-services/custos-configuration-service/src/main/resources/tenantManagementService.properties
@@ -18,4 +18,6 @@ cluster.management.core.service.port=7000
 resource.secret.service.dns.name=resource-secret-core-service.custos.svc.cluster.local
 resource.secret.service.port=7000
 messaging.core.service.dns.name=custos-messaging-core-service.custos.svc.cluster.local
-messaging.core.service.port=7000
\ No newline at end of file
+messaging.core.service.port=7000
+sharing.core.service.dns.name=sharing-core-service.custos.svc.cluster.local
+sharing.core.service.port=7000
\ No newline at end of file
diff --git a/custos-integration-services/tenant-management-service-parent/tenant-management-service/pom.xml b/custos-integration-services/tenant-management-service-parent/tenant-management-service/pom.xml
index b8c7f72..25f082d 100644
--- a/custos-integration-services/tenant-management-service-parent/tenant-management-service/pom.xml
+++ b/custos-integration-services/tenant-management-service-parent/tenant-management-service/pom.xml
@@ -78,6 +78,11 @@
             <artifactId>custos-integration-services-commons</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-web</artifactId>
@@ -132,6 +137,12 @@
             <version>1.0-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-core-service-client-stub</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/tasks/TenantActivationTask.java b/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/tasks/TenantActivationTask.java
index 1aba81b..443d0e2 100644
--- a/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/tasks/TenantActivationTask.java
+++ b/custos-integration-services/tenant-management-service-parent/tenant-management-service/src/main/java/org/apache/custos/tenant/management/tasks/TenantActivationTask.java
@@ -33,13 +33,14 @@ import org.apache.custos.iam.service.SetUpTenantRequest;
 import org.apache.custos.iam.service.SetUpTenantResponse;
 import org.apache.custos.integration.core.ServiceException;
 import org.apache.custos.integration.core.ServiceTaskImpl;
+import org.apache.custos.sharing.client.SharingClient;
+import org.apache.custos.sharing.service.EntityType;
+import org.apache.custos.sharing.service.EntityTypeRequest;
+import org.apache.custos.sharing.service.PermissionType;
+import org.apache.custos.sharing.service.PermissionTypeRequest;
 import org.apache.custos.tenant.management.utils.Constants;
 import org.apache.custos.tenant.profile.client.async.TenantProfileClient;
 import org.apache.custos.tenant.profile.service.*;
-import org.apache.custos.user.profile.client.UserProfileClient;
-import org.apache.custos.user.profile.service.UserProfile;
-import org.apache.custos.user.profile.service.UserProfileRequest;
-import org.apache.custos.user.profile.service.UserStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -67,6 +68,9 @@ public class TenantActivationTask<T, U> extends ServiceTaskImpl<T, U> {
     @Autowired
     private TenantProfileClient profileClient;
 
+    @Autowired
+    private SharingClient sharingClient;
+
 
     @Override
     public void invokeService(T data) {
@@ -109,7 +113,7 @@ public class TenantActivationTask<T, U> extends ServiceTaskImpl<T, U> {
 
                         UpdateStatusResponse response = null;
                         if (iamMetadata == null || iamMetadata.getId() == null || iamMetadata.getId().equals("")) {
-                             response = this.activateTenant(newTenant, Constants.SYSTEM, false);
+                            response = this.activateTenant(newTenant, Constants.SYSTEM, false);
                         } else {
                             response = this.activateTenant(newTenant, Constants.SYSTEM, true);
                         }
@@ -192,7 +196,8 @@ public class TenantActivationTask<T, U> extends ServiceTaskImpl<T, U> {
                 .setOwnerId(tenant.getTenantId())
                 .setType(Type.CILOGON).build();
 
-        String ciLogonRedirectURI = iamAdminServiceClient.getIamServerURL() + "realms" + "/" + tenant.getTenantId() + "/" + "broker" + "/" + "oidc" + "/" + "endpoint";
+        String ciLogonRedirectURI = iamAdminServiceClient.getIamServerURL() +
+                "realms" + "/" + tenant.getTenantId() + "/" + "broker" + "/" + "oidc" + "/" + "endpoint";
 
 
         List<String> arrayList = new ArrayList<>();
@@ -242,6 +247,34 @@ public class TenantActivationTask<T, U> extends ServiceTaskImpl<T, U> {
                     .setType(FederatedIDPs.CILOGON)
                     .build();
             iamAdminServiceClient.configureFederatedIDP(request);
+
+            PermissionType permissionType = PermissionType
+                    .newBuilder()
+                    .setId("OWNER")
+                    .setName("OWNER")
+                    .setDescription("Owner permission type").build();
+
+            PermissionTypeRequest permissionTypeRequest = PermissionTypeRequest
+                    .newBuilder()
+                    .setPermissionType(permissionType)
+                    .setTenantId(tenant.getTenantId())
+                    .build();
+            sharingClient.createPermissionType(permissionTypeRequest);
+
+            EntityType entityType = EntityType
+                    .newBuilder()
+                    .setId("SECRET")
+                    .setName("SECRET")
+                    .setDescription("Secret entity type").build();
+
+            EntityTypeRequest entityTypeRequest = EntityTypeRequest
+                    .newBuilder()
+                    .setEntityType(entityType)
+                    .setTenantId(tenant.getTenantId())
+                    .build();
+            sharingClient.createEntityType(entityTypeRequest);
+
+
         }
 
         org.apache.custos.tenant.profile.service.UpdateStatusRequest updateTenantRequest =