You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2019/09/09 19:17:04 UTC

[airavata-custos] branch develop updated (2e3135a -> a57cdd6)

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

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


    from 2e3135a  Merge pull request #5 from aarushiibisht/master
     new 7fee0b2  added validations and refactored exception handling
     new 240a19b  Added validations and refactored exception handling for sharing service
     new a57cdd6  Merge pull request #6 from aarushiibisht/master

The 48 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../service/api/controllers/DomainsController.java |  28 +-
 .../service/api/controllers/EntityController.java  |  27 +-
 .../api/controllers/EntityTypeController.java      |  41 +--
 .../service/api/controllers/GroupController.java   | 135 ++-----
 .../api/controllers/PermissionTypeController.java  |  40 +--
 .../service/api/controllers/UsersController.java   |  36 +-
 .../src/main/resources/application.properties      |   3 +-
 .../core/exceptions/InvalidRequestException.java   |  16 +
 .../custos/sharing/service/core/models/Domain.java |   2 +-
 .../core/service/SharingRegistryService.java       | 396 ++++++++++++++++-----
 pom.xml                                            |   5 +
 11 files changed, 399 insertions(+), 330 deletions(-)
 create mode 100644 custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/InvalidRequestException.java


[airavata-custos] 22/48: Merge branch 'custos-dev-abisht' of https://github.com/aarushiibisht/airavata-custos into custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ca8a8bb21298c8d4c1aefb46b1c5d9fb54d0fec5
Merge: b5260d9 cf853a8
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Aug 13 11:03:55 2019 -0400

    Merge branch 'custos-dev-abisht' of https://github.com/aarushiibisht/airavata-custos into custos-dev-abisht



[airavata-custos] 45/48: Merge pull request #5 from aarushiibisht/master

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2e3135a92bf4b3c3c222f8e77c91fe7f067ab299
Merge: 469150f 409ac82
Author: Suresh Marru <sm...@apache.org>
AuthorDate: Tue Sep 3 09:42:51 2019 -0400

    Merge pull request #5 from aarushiibisht/master
    
    Merging into PR, still pending to do a good review of all API's and code bases

 .../handler/CustosAuthenticationHandler.java       |    2 +-
 ...ctory.java => AuthenticationServiceClient.java} |    2 +-
 custos-commons/pom.xml                             |    6 +
 .../exceptions/ServiceConnectionException.java     |   14 +
 .../org/apache/custos/commons/utils/Constants.java |    4 +
 .../custos/commons/utils/ServerSettings.java       |    7 +-
 .../custos/commons/utils/ServiceRequestClient.java |  101 ++
 .../src/main/resources/custos-server.properties    |    9 +
 custos-sharing-registry-service/README             |    3 +
 .../pom.xml                                        |   16 +-
 .../sharing-service-api}/pom.xml                   |   12 +-
 .../custos/sharing/service/api/AppConfig.java      |    7 +
 .../custos/sharing/service/api/Application.java    |   32 +
 .../api/constants/SharingRegistryEndpoints.java    |   88 ++
 .../service/api/controllers/AccessController.java  |   72 ++
 .../service/api/controllers/DomainsController.java |   84 ++
 .../service/api/controllers/EntityController.java  |  120 ++
 .../api/controllers/EntityTypeController.java      |  100 ++
 .../service/api/controllers/GroupController.java   |  269 +++++
 .../api/controllers/PermissionTypeController.java  |   98 ++
 .../service/api/controllers/UsersController.java   |   97 ++
 .../src/main/resources/application.properties      |    2 +
 .../sharing-service-core/pom.xml                   |   95 ++
 .../service/core/db/entities/DomainEntity.java     |  115 ++
 .../service/core/db/entities/EntityEntity.java     |  219 ++++
 .../sharing/service/core/db/entities/EntityPK.java |   76 ++
 .../service/core/db/entities/EntityTypeEntity.java |  130 +++
 .../service/core/db/entities/EntityTypePK.java     |   76 ++
 .../service/core/db/entities/GroupAdminEntity.java |   80 ++
 .../service/core/db/entities/GroupAdminPK.java     |   66 ++
 .../core/db/entities/GroupMembershipEntity.java    |  126 ++
 .../core/db/entities/GroupMembershipPK.java        |   88 ++
 .../core/db/entities/PermissionTypeEntity.java     |  128 +++
 .../service/core/db/entities/PermissionTypePK.java |   76 ++
 .../service/core/db/entities/SharingEntity.java    |  149 +++
 .../service/core/db/entities/SharingPK.java        |  116 ++
 .../service/core/db/entities/UserEntity.java       |  161 +++
 .../service/core/db/entities/UserGroupEntity.java  |  178 +++
 .../service/core/db/entities/UserGroupPK.java      |   75 ++
 .../sharing/service/core/db/entities/UserPK.java   |   75 ++
 .../core/db/repositories/AbstractRepository.java   |  169 +++
 .../core/db/repositories/DomainRepository.java     |   33 +
 .../core/db/repositories/EntityRepository.java     |  180 +++
 .../core/db/repositories/EntityTypeRepository.java |   34 +
 .../core/db/repositories/GroupAdminRepository.java |   17 +
 .../db/repositories/GroupMembershipRepository.java |  105 ++
 .../db/repositories/PermissionTypeRepository.java  |   52 +
 .../core/db/repositories/SharingRepository.java    |  114 ++
 .../core/db/repositories/UserGroupRepository.java  |   95 ++
 .../core/db/repositories/UserRepository.java       |   79 ++
 .../sharing/service/core/db/utils/Committer.java   |   26 +
 .../sharing/service/core/db/utils/DBConstants.java |  106 ++
 .../sharing/service/core/db/utils/JPAUtils.java    |   35 +
 .../core/db/utils/ObjectMapperSingleton.java       |   38 +
 .../core/db/utils/SharingRegistryDBInitConfig.java |   50 +
 .../core/db/utils/SharingRegistryJDBCConfig.java   |   67 ++
 .../core/exceptions/DuplicateEntryException.java   |   15 +
 .../core/exceptions/ResourceNotFoundException.java |   16 +
 .../core/exceptions/SharingRegistryException.java  |   16 +
 .../custos/sharing/service/core/models/Domain.java |   58 +
 .../custos/sharing/service/core/models/Entity.java |  136 +++
 .../service/core/models/EntitySearchField.java     |   14 +
 .../sharing/service/core/models/EntityType.java    |   69 ++
 .../sharing/service/core/models/GroupAdmin.java    |   33 +
 .../service/core/models/GroupCardinality.java      |    6 +
 .../service/core/models/GroupChildType.java        |    6 +
 .../service/core/models/GroupMembership.java       |   60 +
 .../sharing/service/core/models/GroupType.java     |    6 +
 .../service/core/models/PermissionType.java        |   69 ++
 .../service/core/models/SearchCondition.java       |   10 +
 .../service/core/models/SearchCriteria.java        |   31 +
 .../sharing/service/core/models/Sharing.java       |   78 ++
 .../sharing/service/core/models/SharingType.java   |    7 +
 .../custos/sharing/service/core/models/User.java   |  100 ++
 .../sharing/service/core/models/UserGroup.java     |  113 ++
 .../core/service/SharingRegistryService.java       | 1212 ++++++++++++++++++++
 .../src/main/resources/META-INF/persistence.xml    |   16 +
 .../database_scripts/sharing-registry-derby.sql    |  147 +++
 .../database_scripts/sharing-registry-mysql.sql    |  146 +++
 ...verStarted.java => CustosAPIServerStarter.java} |    2 +-
 .../database_scripts/init/01-databases.sql         |  327 +++++-
 .../database_scripts/sharing-registry-mysql.sql    |  146 +++
 ide-integration/pom.xml                            |    8 +-
 .../custos-authentication-service-samples/pom.xml  |    2 +-
 .../sample/CustosAuthenticationServiceSample.java  |    4 +-
 .../samples/custos-profile-service-samples/pom.xml |    2 +-
 pom.xml                                            |    8 +
 87 files changed, 7212 insertions(+), 25 deletions(-)


[airavata-custos] 01/48: adding a readme and testing the repo

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3802acd4ad807696cbc58ee7537f796d35f7eb2c
Author: Suresh Marru <sm...@apache.org>
AuthorDate: Fri Feb 15 14:08:48 2019 -0500

    adding a readme and testing the repo
---
 README | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/README b/README
new file mode 100644
index 0000000..95a8c48
--- /dev/null
+++ b/README
@@ -0,0 +1,3 @@
+Apache Airavata Custos Security 
+
+Custos: Generalized versions of Apache Airavata Security server components and client libraries.


[airavata-custos] 25/48: refactored tenant profile and iam admin services service

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d2686411d8fc7053d2faa48a489e69dbb756e0fe
Author: Aarushi <aa...@gmail.com>
AuthorDate: Thu Aug 15 13:47:42 2019 -0400

    refactored tenant profile and iam admin services service
---
 .../{cpi => }/CustosAuthenticationService.java     |  238 +---
 .../cpi/CustosAuthenticationService.java           |  236 +---
 .../CustosAuthenticationServiceException.java      |    2 +-
 .../handler/CustosAuthenticationHandler.java       |    4 +-
 custos-connectors/pom.xml                          |    5 +
 .../manager/CustosSecurityManager.java             |    2 +-
 .../manager/KeyCloakSecurityManager.java           |   27 +-
 .../services/core/TenantManagementInterface.java   |   10 +
 .../core/TenantManagementKeycloakImpl.java         |   30 +
 .../iam/admin/services/cpi/IamAdminServices.java   | 1255 ++++++++++++++++++--
 .../services/handler/IamAdminServicesHandler.java  |   34 +-
 .../repositories}/TenantProfileRepository.java     |   19 +-
 .../repositories/UserProfileRepository.java        |    3 +-
 .../profile/tenant/client/TenantProfileClient.java |   26 +
 .../profile/tenant/cpi/TenantProfileService.java   | 1109 ++++++++++++++++-
 .../handler/TenantProfileServiceHandler.java       |   19 +-
 .../profile/user/client/UserProfileClient.java     |    4 +
 .../profile/user/cpi/UserProfileService.java       |  470 +-------
 .../user/handler/UserProfileServiceHandler.java    |   16 +-
 .../authentication-service-cpi.thrift              |    2 +-
 .../iam-admin-services-cpi.thrift                  |    6 +-
 .../profile-tenant/profile-tenant-cpi.thrift       |    4 +
 .../profile-user/profile-user-cpi.thrift           |    8 +-
 23 files changed, 2525 insertions(+), 1004 deletions(-)

diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java b/custos-authentication/src/main/java/org/apache/custos/authentication/CustosAuthenticationService.java
similarity index 92%
copy from custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
copy to custos-authentication/src/main/java/org/apache/custos/authentication/CustosAuthenticationService.java
index 396506a..9f9baca 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/CustosAuthenticationService.java
@@ -4,10 +4,10 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.authentication.cpi;
+package org.apache.custos.authentication;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-08")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-15")
 public class CustosAuthenticationService {
 
   public interface Iface {
@@ -16,7 +16,7 @@ public class CustosAuthenticationService {
 
     public org.apache.custos.commons.model.security.UserInfo getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
 
-    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
 
   }
 
@@ -26,7 +26,7 @@ public class CustosAuthenticationService {
 
     public void getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException;
 
-    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException;
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException;
 
   }
 
@@ -102,19 +102,17 @@ public class CustosAuthenticationService {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserInfoFromAuthzToken failed: unknown result");
     }
 
-    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
     {
-      send_getUserManagementServiceAccountAuthzToken(authzToken, gatewayId, clientId, clientSecret);
+      send_getUserManagementServiceAccountAuthzToken(authzToken, gatewayId);
       return recv_getUserManagementServiceAccountAuthzToken();
     }
 
-    public void send_getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws org.apache.thrift.TException
+    public void send_getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.thrift.TException
     {
       getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
       args.setAuthzToken(authzToken);
       args.setGatewayId(gatewayId);
-      args.setClientId(clientId);
-      args.setClientSecret(clientSecret);
       sendBase("getUserManagementServiceAccountAuthzToken", args);
     }
 
@@ -213,9 +211,9 @@ public class CustosAuthenticationService {
       }
     }
 
-    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      getUserManagementServiceAccountAuthzToken_call method_call = new getUserManagementServiceAccountAuthzToken_call(authzToken, gatewayId, clientId, clientSecret, resultHandler, this, ___protocolFactory, ___transport);
+      getUserManagementServiceAccountAuthzToken_call method_call = new getUserManagementServiceAccountAuthzToken_call(authzToken, gatewayId, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
@@ -223,14 +221,10 @@ public class CustosAuthenticationService {
     public static class getUserManagementServiceAccountAuthzToken_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.commons.model.security.AuthzToken> {
       private org.apache.custos.commons.model.security.AuthzToken authzToken;
       private String gatewayId;
-      private String clientId;
-      private String clientSecret;
-      public getUserManagementServiceAccountAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+      public getUserManagementServiceAccountAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> 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.clientId = clientId;
-        this.clientSecret = clientSecret;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -238,8 +232,6 @@ public class CustosAuthenticationService {
         getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
         args.setAuthzToken(authzToken);
         args.setGatewayId(gatewayId);
-        args.setClientId(clientId);
-        args.setClientSecret(clientSecret);
         args.write(prot);
         prot.writeMessageEnd();
       }
@@ -353,7 +345,7 @@ public class CustosAuthenticationService {
       public getUserManagementServiceAccountAuthzToken_result getResult(I iface, getUserManagementServiceAccountAuthzToken_args args) throws org.apache.thrift.TException {
         getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
         try {
-          result.success = iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId, args.clientId, args.clientSecret);
+          result.success = iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId);
         } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
           result.ae = ae;
         }
@@ -572,7 +564,7 @@ public class CustosAuthenticationService {
       }
 
       public void start(I iface, getUserManagementServiceAccountAuthzToken_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
-        iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId, args.clientId, args.clientSecret,resultHandler);
+        iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId,resultHandler);
       }
     }
 
@@ -2263,23 +2255,17 @@ public class CustosAuthenticationService {
 
     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 CLIENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("clientId", org.apache.thrift.protocol.TType.STRING, (short)3);
-    private static final org.apache.thrift.protocol.TField CLIENT_SECRET_FIELD_DESC = new org.apache.thrift.protocol.TField("clientSecret", org.apache.thrift.protocol.TType.STRING, (short)4);
 
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsTupleSchemeFactory();
 
     public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
     public @org.apache.thrift.annotation.Nullable String gatewayId; // required
-    public @org.apache.thrift.annotation.Nullable String clientId; // required
-    public @org.apache.thrift.annotation.Nullable String clientSecret; // 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"),
-      CLIENT_ID((short)3, "clientId"),
-      CLIENT_SECRET((short)4, "clientSecret");
+      GATEWAY_ID((short)2, "gatewayId");
 
       private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
@@ -2299,10 +2285,6 @@ public class CustosAuthenticationService {
             return AUTHZ_TOKEN;
           case 2: // GATEWAY_ID
             return GATEWAY_ID;
-          case 3: // CLIENT_ID
-            return CLIENT_ID;
-          case 4: // CLIENT_SECRET
-            return CLIENT_SECRET;
           default:
             return null;
         }
@@ -2351,10 +2333,6 @@ public class CustosAuthenticationService {
           new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.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.CLIENT_ID, new org.apache.thrift.meta_data.FieldMetaData("clientId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-      tmpMap.put(_Fields.CLIENT_SECRET, new org.apache.thrift.meta_data.FieldMetaData("clientSecret", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_args.class, metaDataMap);
     }
@@ -2364,15 +2342,11 @@ public class CustosAuthenticationService {
 
     public getUserManagementServiceAccountAuthzToken_args(
       org.apache.custos.commons.model.security.AuthzToken authzToken,
-      String gatewayId,
-      String clientId,
-      String clientSecret)
+      String gatewayId)
     {
       this();
       this.authzToken = authzToken;
       this.gatewayId = gatewayId;
-      this.clientId = clientId;
-      this.clientSecret = clientSecret;
     }
 
     /**
@@ -2385,12 +2359,6 @@ public class CustosAuthenticationService {
       if (other.isSetGatewayId()) {
         this.gatewayId = other.gatewayId;
       }
-      if (other.isSetClientId()) {
-        this.clientId = other.clientId;
-      }
-      if (other.isSetClientSecret()) {
-        this.clientSecret = other.clientSecret;
-      }
     }
 
     public getUserManagementServiceAccountAuthzToken_args deepCopy() {
@@ -2401,8 +2369,6 @@ public class CustosAuthenticationService {
     public void clear() {
       this.authzToken = null;
       this.gatewayId = null;
-      this.clientId = null;
-      this.clientSecret = null;
     }
 
     @org.apache.thrift.annotation.Nullable
@@ -2455,56 +2421,6 @@ public class CustosAuthenticationService {
       }
     }
 
-    @org.apache.thrift.annotation.Nullable
-    public String getClientId() {
-      return this.clientId;
-    }
-
-    public getUserManagementServiceAccountAuthzToken_args setClientId(@org.apache.thrift.annotation.Nullable String clientId) {
-      this.clientId = clientId;
-      return this;
-    }
-
-    public void unsetClientId() {
-      this.clientId = null;
-    }
-
-    /** Returns true if field clientId is set (has been assigned a value) and false otherwise */
-    public boolean isSetClientId() {
-      return this.clientId != null;
-    }
-
-    public void setClientIdIsSet(boolean value) {
-      if (!value) {
-        this.clientId = null;
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public String getClientSecret() {
-      return this.clientSecret;
-    }
-
-    public getUserManagementServiceAccountAuthzToken_args setClientSecret(@org.apache.thrift.annotation.Nullable String clientSecret) {
-      this.clientSecret = clientSecret;
-      return this;
-    }
-
-    public void unsetClientSecret() {
-      this.clientSecret = null;
-    }
-
-    /** Returns true if field clientSecret is set (has been assigned a value) and false otherwise */
-    public boolean isSetClientSecret() {
-      return this.clientSecret != null;
-    }
-
-    public void setClientSecretIsSet(boolean value) {
-      if (!value) {
-        this.clientSecret = null;
-      }
-    }
-
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case AUTHZ_TOKEN:
@@ -2523,22 +2439,6 @@ public class CustosAuthenticationService {
         }
         break;
 
-      case CLIENT_ID:
-        if (value == null) {
-          unsetClientId();
-        } else {
-          setClientId((String)value);
-        }
-        break;
-
-      case CLIENT_SECRET:
-        if (value == null) {
-          unsetClientSecret();
-        } else {
-          setClientSecret((String)value);
-        }
-        break;
-
       }
     }
 
@@ -2551,12 +2451,6 @@ public class CustosAuthenticationService {
       case GATEWAY_ID:
         return getGatewayId();
 
-      case CLIENT_ID:
-        return getClientId();
-
-      case CLIENT_SECRET:
-        return getClientSecret();
-
       }
       throw new IllegalStateException();
     }
@@ -2572,10 +2466,6 @@ public class CustosAuthenticationService {
         return isSetAuthzToken();
       case GATEWAY_ID:
         return isSetGatewayId();
-      case CLIENT_ID:
-        return isSetClientId();
-      case CLIENT_SECRET:
-        return isSetClientSecret();
       }
       throw new IllegalStateException();
     }
@@ -2613,24 +2503,6 @@ public class CustosAuthenticationService {
           return false;
       }
 
-      boolean this_present_clientId = true && this.isSetClientId();
-      boolean that_present_clientId = true && that.isSetClientId();
-      if (this_present_clientId || that_present_clientId) {
-        if (!(this_present_clientId && that_present_clientId))
-          return false;
-        if (!this.clientId.equals(that.clientId))
-          return false;
-      }
-
-      boolean this_present_clientSecret = true && this.isSetClientSecret();
-      boolean that_present_clientSecret = true && that.isSetClientSecret();
-      if (this_present_clientSecret || that_present_clientSecret) {
-        if (!(this_present_clientSecret && that_present_clientSecret))
-          return false;
-        if (!this.clientSecret.equals(that.clientSecret))
-          return false;
-      }
-
       return true;
     }
 
@@ -2646,14 +2518,6 @@ public class CustosAuthenticationService {
       if (isSetGatewayId())
         hashCode = hashCode * 8191 + gatewayId.hashCode();
 
-      hashCode = hashCode * 8191 + ((isSetClientId()) ? 131071 : 524287);
-      if (isSetClientId())
-        hashCode = hashCode * 8191 + clientId.hashCode();
-
-      hashCode = hashCode * 8191 + ((isSetClientSecret()) ? 131071 : 524287);
-      if (isSetClientSecret())
-        hashCode = hashCode * 8191 + clientSecret.hashCode();
-
       return hashCode;
     }
 
@@ -2685,26 +2549,6 @@ public class CustosAuthenticationService {
           return lastComparison;
         }
       }
-      lastComparison = Boolean.valueOf(isSetClientId()).compareTo(other.isSetClientId());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetClientId()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientId, other.clientId);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
-      lastComparison = Boolean.valueOf(isSetClientSecret()).compareTo(other.isSetClientSecret());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetClientSecret()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientSecret, other.clientSecret);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
       return 0;
     }
 
@@ -2741,22 +2585,6 @@ public class CustosAuthenticationService {
         sb.append(this.gatewayId);
       }
       first = false;
-      if (!first) sb.append(", ");
-      sb.append("clientId:");
-      if (this.clientId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.clientId);
-      }
-      first = false;
-      if (!first) sb.append(", ");
-      sb.append("clientSecret:");
-      if (this.clientSecret == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.clientSecret);
-      }
-      first = false;
       sb.append(")");
       return sb.toString();
     }
@@ -2769,12 +2597,6 @@ public class CustosAuthenticationService {
       if (gatewayId == null) {
         throw new org.apache.thrift.protocol.TProtocolException("Required field 'gatewayId' was not present! Struct: " + toString());
       }
-      if (clientId == null) {
-        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientId' was not present! Struct: " + toString());
-      }
-      if (clientSecret == null) {
-        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientSecret' was not present! Struct: " + toString());
-      }
       // check for sub-struct validity
       if (authzToken != null) {
         authzToken.validate();
@@ -2832,22 +2654,6 @@ public class CustosAuthenticationService {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
-            case 3: // CLIENT_ID
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-                struct.clientId = iprot.readString();
-                struct.setClientIdIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
-            case 4: // CLIENT_SECRET
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-                struct.clientSecret = iprot.readString();
-                struct.setClientSecretIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
             default:
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
           }
@@ -2873,16 +2679,6 @@ public class CustosAuthenticationService {
           oprot.writeString(struct.gatewayId);
           oprot.writeFieldEnd();
         }
-        if (struct.clientId != null) {
-          oprot.writeFieldBegin(CLIENT_ID_FIELD_DESC);
-          oprot.writeString(struct.clientId);
-          oprot.writeFieldEnd();
-        }
-        if (struct.clientSecret != null) {
-          oprot.writeFieldBegin(CLIENT_SECRET_FIELD_DESC);
-          oprot.writeString(struct.clientSecret);
-          oprot.writeFieldEnd();
-        }
         oprot.writeFieldStop();
         oprot.writeStructEnd();
       }
@@ -2902,8 +2698,6 @@ public class CustosAuthenticationService {
         org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         struct.authzToken.write(oprot);
         oprot.writeString(struct.gatewayId);
-        oprot.writeString(struct.clientId);
-        oprot.writeString(struct.clientSecret);
       }
 
       @Override
@@ -2914,10 +2708,6 @@ public class CustosAuthenticationService {
         struct.setAuthzTokenIsSet(true);
         struct.gatewayId = iprot.readString();
         struct.setGatewayIdIsSet(true);
-        struct.clientId = iprot.readString();
-        struct.setClientIdIsSet(true);
-        struct.clientSecret = iprot.readString();
-        struct.setClientSecretIsSet(true);
       }
     }
 
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
index 396506a..e6842d8 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
@@ -7,7 +7,7 @@
 package org.apache.custos.authentication.cpi;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-08")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-15")
 public class CustosAuthenticationService {
 
   public interface Iface {
@@ -16,7 +16,7 @@ public class CustosAuthenticationService {
 
     public org.apache.custos.commons.model.security.UserInfo getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
 
-    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
 
   }
 
@@ -26,7 +26,7 @@ public class CustosAuthenticationService {
 
     public void getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException;
 
-    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException;
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException;
 
   }
 
@@ -102,19 +102,17 @@ public class CustosAuthenticationService {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserInfoFromAuthzToken failed: unknown result");
     }
 
-    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
     {
-      send_getUserManagementServiceAccountAuthzToken(authzToken, gatewayId, clientId, clientSecret);
+      send_getUserManagementServiceAccountAuthzToken(authzToken, gatewayId);
       return recv_getUserManagementServiceAccountAuthzToken();
     }
 
-    public void send_getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws org.apache.thrift.TException
+    public void send_getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.thrift.TException
     {
       getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
       args.setAuthzToken(authzToken);
       args.setGatewayId(gatewayId);
-      args.setClientId(clientId);
-      args.setClientSecret(clientSecret);
       sendBase("getUserManagementServiceAccountAuthzToken", args);
     }
 
@@ -213,9 +211,9 @@ public class CustosAuthenticationService {
       }
     }
 
-    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      getUserManagementServiceAccountAuthzToken_call method_call = new getUserManagementServiceAccountAuthzToken_call(authzToken, gatewayId, clientId, clientSecret, resultHandler, this, ___protocolFactory, ___transport);
+      getUserManagementServiceAccountAuthzToken_call method_call = new getUserManagementServiceAccountAuthzToken_call(authzToken, gatewayId, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
@@ -223,14 +221,10 @@ public class CustosAuthenticationService {
     public static class getUserManagementServiceAccountAuthzToken_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.commons.model.security.AuthzToken> {
       private org.apache.custos.commons.model.security.AuthzToken authzToken;
       private String gatewayId;
-      private String clientId;
-      private String clientSecret;
-      public getUserManagementServiceAccountAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+      public getUserManagementServiceAccountAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> 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.clientId = clientId;
-        this.clientSecret = clientSecret;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -238,8 +232,6 @@ public class CustosAuthenticationService {
         getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
         args.setAuthzToken(authzToken);
         args.setGatewayId(gatewayId);
-        args.setClientId(clientId);
-        args.setClientSecret(clientSecret);
         args.write(prot);
         prot.writeMessageEnd();
       }
@@ -353,7 +345,7 @@ public class CustosAuthenticationService {
       public getUserManagementServiceAccountAuthzToken_result getResult(I iface, getUserManagementServiceAccountAuthzToken_args args) throws org.apache.thrift.TException {
         getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
         try {
-          result.success = iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId, args.clientId, args.clientSecret);
+          result.success = iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId);
         } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
           result.ae = ae;
         }
@@ -572,7 +564,7 @@ public class CustosAuthenticationService {
       }
 
       public void start(I iface, getUserManagementServiceAccountAuthzToken_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
-        iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId, args.clientId, args.clientSecret,resultHandler);
+        iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId,resultHandler);
       }
     }
 
@@ -2263,23 +2255,17 @@ public class CustosAuthenticationService {
 
     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 CLIENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("clientId", org.apache.thrift.protocol.TType.STRING, (short)3);
-    private static final org.apache.thrift.protocol.TField CLIENT_SECRET_FIELD_DESC = new org.apache.thrift.protocol.TField("clientSecret", org.apache.thrift.protocol.TType.STRING, (short)4);
 
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsTupleSchemeFactory();
 
     public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
     public @org.apache.thrift.annotation.Nullable String gatewayId; // required
-    public @org.apache.thrift.annotation.Nullable String clientId; // required
-    public @org.apache.thrift.annotation.Nullable String clientSecret; // 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"),
-      CLIENT_ID((short)3, "clientId"),
-      CLIENT_SECRET((short)4, "clientSecret");
+      GATEWAY_ID((short)2, "gatewayId");
 
       private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
@@ -2299,10 +2285,6 @@ public class CustosAuthenticationService {
             return AUTHZ_TOKEN;
           case 2: // GATEWAY_ID
             return GATEWAY_ID;
-          case 3: // CLIENT_ID
-            return CLIENT_ID;
-          case 4: // CLIENT_SECRET
-            return CLIENT_SECRET;
           default:
             return null;
         }
@@ -2351,10 +2333,6 @@ public class CustosAuthenticationService {
           new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.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.CLIENT_ID, new org.apache.thrift.meta_data.FieldMetaData("clientId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-      tmpMap.put(_Fields.CLIENT_SECRET, new org.apache.thrift.meta_data.FieldMetaData("clientSecret", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_args.class, metaDataMap);
     }
@@ -2364,15 +2342,11 @@ public class CustosAuthenticationService {
 
     public getUserManagementServiceAccountAuthzToken_args(
       org.apache.custos.commons.model.security.AuthzToken authzToken,
-      String gatewayId,
-      String clientId,
-      String clientSecret)
+      String gatewayId)
     {
       this();
       this.authzToken = authzToken;
       this.gatewayId = gatewayId;
-      this.clientId = clientId;
-      this.clientSecret = clientSecret;
     }
 
     /**
@@ -2385,12 +2359,6 @@ public class CustosAuthenticationService {
       if (other.isSetGatewayId()) {
         this.gatewayId = other.gatewayId;
       }
-      if (other.isSetClientId()) {
-        this.clientId = other.clientId;
-      }
-      if (other.isSetClientSecret()) {
-        this.clientSecret = other.clientSecret;
-      }
     }
 
     public getUserManagementServiceAccountAuthzToken_args deepCopy() {
@@ -2401,8 +2369,6 @@ public class CustosAuthenticationService {
     public void clear() {
       this.authzToken = null;
       this.gatewayId = null;
-      this.clientId = null;
-      this.clientSecret = null;
     }
 
     @org.apache.thrift.annotation.Nullable
@@ -2455,56 +2421,6 @@ public class CustosAuthenticationService {
       }
     }
 
-    @org.apache.thrift.annotation.Nullable
-    public String getClientId() {
-      return this.clientId;
-    }
-
-    public getUserManagementServiceAccountAuthzToken_args setClientId(@org.apache.thrift.annotation.Nullable String clientId) {
-      this.clientId = clientId;
-      return this;
-    }
-
-    public void unsetClientId() {
-      this.clientId = null;
-    }
-
-    /** Returns true if field clientId is set (has been assigned a value) and false otherwise */
-    public boolean isSetClientId() {
-      return this.clientId != null;
-    }
-
-    public void setClientIdIsSet(boolean value) {
-      if (!value) {
-        this.clientId = null;
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public String getClientSecret() {
-      return this.clientSecret;
-    }
-
-    public getUserManagementServiceAccountAuthzToken_args setClientSecret(@org.apache.thrift.annotation.Nullable String clientSecret) {
-      this.clientSecret = clientSecret;
-      return this;
-    }
-
-    public void unsetClientSecret() {
-      this.clientSecret = null;
-    }
-
-    /** Returns true if field clientSecret is set (has been assigned a value) and false otherwise */
-    public boolean isSetClientSecret() {
-      return this.clientSecret != null;
-    }
-
-    public void setClientSecretIsSet(boolean value) {
-      if (!value) {
-        this.clientSecret = null;
-      }
-    }
-
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case AUTHZ_TOKEN:
@@ -2523,22 +2439,6 @@ public class CustosAuthenticationService {
         }
         break;
 
-      case CLIENT_ID:
-        if (value == null) {
-          unsetClientId();
-        } else {
-          setClientId((String)value);
-        }
-        break;
-
-      case CLIENT_SECRET:
-        if (value == null) {
-          unsetClientSecret();
-        } else {
-          setClientSecret((String)value);
-        }
-        break;
-
       }
     }
 
@@ -2551,12 +2451,6 @@ public class CustosAuthenticationService {
       case GATEWAY_ID:
         return getGatewayId();
 
-      case CLIENT_ID:
-        return getClientId();
-
-      case CLIENT_SECRET:
-        return getClientSecret();
-
       }
       throw new IllegalStateException();
     }
@@ -2572,10 +2466,6 @@ public class CustosAuthenticationService {
         return isSetAuthzToken();
       case GATEWAY_ID:
         return isSetGatewayId();
-      case CLIENT_ID:
-        return isSetClientId();
-      case CLIENT_SECRET:
-        return isSetClientSecret();
       }
       throw new IllegalStateException();
     }
@@ -2613,24 +2503,6 @@ public class CustosAuthenticationService {
           return false;
       }
 
-      boolean this_present_clientId = true && this.isSetClientId();
-      boolean that_present_clientId = true && that.isSetClientId();
-      if (this_present_clientId || that_present_clientId) {
-        if (!(this_present_clientId && that_present_clientId))
-          return false;
-        if (!this.clientId.equals(that.clientId))
-          return false;
-      }
-
-      boolean this_present_clientSecret = true && this.isSetClientSecret();
-      boolean that_present_clientSecret = true && that.isSetClientSecret();
-      if (this_present_clientSecret || that_present_clientSecret) {
-        if (!(this_present_clientSecret && that_present_clientSecret))
-          return false;
-        if (!this.clientSecret.equals(that.clientSecret))
-          return false;
-      }
-
       return true;
     }
 
@@ -2646,14 +2518,6 @@ public class CustosAuthenticationService {
       if (isSetGatewayId())
         hashCode = hashCode * 8191 + gatewayId.hashCode();
 
-      hashCode = hashCode * 8191 + ((isSetClientId()) ? 131071 : 524287);
-      if (isSetClientId())
-        hashCode = hashCode * 8191 + clientId.hashCode();
-
-      hashCode = hashCode * 8191 + ((isSetClientSecret()) ? 131071 : 524287);
-      if (isSetClientSecret())
-        hashCode = hashCode * 8191 + clientSecret.hashCode();
-
       return hashCode;
     }
 
@@ -2685,26 +2549,6 @@ public class CustosAuthenticationService {
           return lastComparison;
         }
       }
-      lastComparison = Boolean.valueOf(isSetClientId()).compareTo(other.isSetClientId());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetClientId()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientId, other.clientId);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
-      lastComparison = Boolean.valueOf(isSetClientSecret()).compareTo(other.isSetClientSecret());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetClientSecret()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientSecret, other.clientSecret);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
       return 0;
     }
 
@@ -2741,22 +2585,6 @@ public class CustosAuthenticationService {
         sb.append(this.gatewayId);
       }
       first = false;
-      if (!first) sb.append(", ");
-      sb.append("clientId:");
-      if (this.clientId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.clientId);
-      }
-      first = false;
-      if (!first) sb.append(", ");
-      sb.append("clientSecret:");
-      if (this.clientSecret == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.clientSecret);
-      }
-      first = false;
       sb.append(")");
       return sb.toString();
     }
@@ -2769,12 +2597,6 @@ public class CustosAuthenticationService {
       if (gatewayId == null) {
         throw new org.apache.thrift.protocol.TProtocolException("Required field 'gatewayId' was not present! Struct: " + toString());
       }
-      if (clientId == null) {
-        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientId' was not present! Struct: " + toString());
-      }
-      if (clientSecret == null) {
-        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientSecret' was not present! Struct: " + toString());
-      }
       // check for sub-struct validity
       if (authzToken != null) {
         authzToken.validate();
@@ -2832,22 +2654,6 @@ public class CustosAuthenticationService {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
-            case 3: // CLIENT_ID
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-                struct.clientId = iprot.readString();
-                struct.setClientIdIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
-            case 4: // CLIENT_SECRET
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-                struct.clientSecret = iprot.readString();
-                struct.setClientSecretIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
             default:
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
           }
@@ -2873,16 +2679,6 @@ public class CustosAuthenticationService {
           oprot.writeString(struct.gatewayId);
           oprot.writeFieldEnd();
         }
-        if (struct.clientId != null) {
-          oprot.writeFieldBegin(CLIENT_ID_FIELD_DESC);
-          oprot.writeString(struct.clientId);
-          oprot.writeFieldEnd();
-        }
-        if (struct.clientSecret != null) {
-          oprot.writeFieldBegin(CLIENT_SECRET_FIELD_DESC);
-          oprot.writeString(struct.clientSecret);
-          oprot.writeFieldEnd();
-        }
         oprot.writeFieldStop();
         oprot.writeStructEnd();
       }
@@ -2902,8 +2698,6 @@ public class CustosAuthenticationService {
         org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         struct.authzToken.write(oprot);
         oprot.writeString(struct.gatewayId);
-        oprot.writeString(struct.clientId);
-        oprot.writeString(struct.clientSecret);
       }
 
       @Override
@@ -2914,10 +2708,6 @@ public class CustosAuthenticationService {
         struct.setAuthzTokenIsSet(true);
         struct.gatewayId = iprot.readString();
         struct.setGatewayIdIsSet(true);
-        struct.clientId = iprot.readString();
-        struct.setClientIdIsSet(true);
-        struct.clientSecret = iprot.readString();
-        struct.setClientSecretIsSet(true);
       }
     }
 
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/exception/CustosAuthenticationServiceException.java b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/exception/CustosAuthenticationServiceException.java
index 571f176..ad96056 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/exception/CustosAuthenticationServiceException.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/exception/CustosAuthenticationServiceException.java
@@ -7,7 +7,7 @@
 package org.apache.custos.authentication.cpi.exception;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-15")
 public class CustosAuthenticationServiceException extends org.apache.thrift.TException implements org.apache.thrift.TBase<CustosAuthenticationServiceException, CustosAuthenticationServiceException._Fields>, java.io.Serializable, Cloneable, Comparable<CustosAuthenticationServiceException> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CustosAuthenticationServiceException");
 
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
index 0a2f43c..8a7de8c 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
@@ -42,10 +42,10 @@ public class CustosAuthenticationHandler implements CustosAuthenticationService.
         }
     }
     @Override
-    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws CustosAuthenticationServiceException {
+    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosAuthenticationServiceException {
         try{
             CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
-            return securityManager.getUserManagementServiceAccountAuthzToken(authzToken, gatewayId, clientId, clientSecret);
+            return securityManager.getUserManagementServiceAccountAuthzToken(authzToken, gatewayId);
         }catch (CustosSecurityException e){
             logger.error(e.getMessage(), e);
             throw new CustosAuthenticationServiceException("Could get user management account authz token");
diff --git a/custos-connectors/pom.xml b/custos-connectors/pom.xml
index aa5f07c..44afda6 100644
--- a/custos-connectors/pom.xml
+++ b/custos-connectors/pom.xml
@@ -76,6 +76,11 @@
             <artifactId>keycloak-admin-client</artifactId>
             <version>2.5.5.Final</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>tenant-profile-service</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
index c18b8bc..4fbcc5d 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
@@ -48,7 +48,7 @@ public interface CustosSecurityManager {
      * @return
      * @throws CustosSecurityException
      */
-    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws CustosSecurityException;
+    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosSecurityException;
 
     /**
      * Get OpenID Connect user profile information from the given AuthzToken.
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
index 3550f4f..e7f8b30 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
@@ -26,6 +26,9 @@ import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.model.security.UserInfo;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.profile.model.workspace.Gateway;
+import org.apache.custos.profile.tenant.client.TenantProfileClient;
+import org.apache.custos.profile.tenant.cpi.TenantProfileService;
 import org.apache.custos.security.authzcache.*;
 import org.apache.custos.security.utils.TrustStoreManager;
 import org.apache.http.Consts;
@@ -38,6 +41,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.util.EntityUtils;
+import org.apache.thrift.TException;
 import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -54,10 +58,12 @@ import java.util.List;
 
 public class KeyCloakSecurityManager implements CustosSecurityManager {
     private final static Logger logger = LoggerFactory.getLogger(KeyCloakSecurityManager.class);
+    private static TenantProfileService.Client tenantProfileClient;
     public KeyCloakSecurityManager() throws CustosSecurityException {
         initializeSecurityInfra();
     }
 
+
     /**
      * Implement this method in your SecurityManager to perform necessary initializations at the server startup.
      *
@@ -128,16 +134,18 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
             throw new CustosSecurityException(e.getMessage(), e);
         }
     }
-    //TODO: no way to get gateway as tenant profile service has not been migrated. Check if clientId and clientSecret could be removed
+
     @Override
-    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws CustosSecurityException {
+    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosSecurityException {
         try {
+            tenantProfileClient = getTenantProfileServiceClient();
+            Gateway gateway = tenantProfileClient.getGatewayUsingGatewayId(authzToken, gatewayId);
             String tokenURL = getTokenEndpoint(gatewayId);
-            JSONObject clientCredentials = getClientCredentials(tokenURL, clientId, clientSecret);
+            JSONObject clientCredentials = getClientCredentials(tokenURL, gateway.getOauthClientId(), gateway.getOauthClientSecret());
             String accessToken = clientCredentials.getString("access_token");
             AuthzToken userManagementServiceAccountAuthzToken = new AuthzToken(accessToken);
             userManagementServiceAccountAuthzToken.putToClaimsMap(Constants.GATEWAY_ID, gatewayId);
-            userManagementServiceAccountAuthzToken.putToClaimsMap(Constants.USER_NAME, clientId);
+            userManagementServiceAccountAuthzToken.putToClaimsMap(Constants.USER_NAME, gateway.getOauthClientId());
             return userManagementServiceAccountAuthzToken;
         } catch (Exception e) {
             throw new CustosSecurityException(e);
@@ -237,4 +245,15 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
             }
         }
     }
+    private TenantProfileService.Client getTenantProfileServiceClient() throws Exception {
+
+        try {
+            String serverHost = ServerSettings.getProfileServiceServerHost();
+            String serverPort = ServerSettings.getProfileServiceServerPort();
+            TenantProfileService.Client client = TenantProfileClient.createCustosTenantProfileServiceClient(serverHost, Integer.parseInt(serverPort));
+            return client;
+        } catch (ApplicationSettingsException | TException e) {
+            throw new Exception("Could not create tenant profile client", e);
+        }
+    }
 }
diff --git a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementInterface.java b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementInterface.java
index fdd18de..8ee3af3 100644
--- a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementInterface.java
+++ b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementInterface.java
@@ -167,6 +167,16 @@ public interface TenantManagementInterface {
     void updateUserProfile(String accessToken, String tenantId, String username, UserProfile userDetails) throws IamAdminServicesException;
 
     /**
+     * Delete this user from the IAM service.
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @return
+     * @throws IamAdminServicesException
+     */
+    boolean deleteUser(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
      * Add the given role to the user.
      *
      * @param realmAdminCreds
diff --git a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementKeycloakImpl.java b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementKeycloakImpl.java
index efc82c2..0a8efa2 100644
--- a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementKeycloakImpl.java
+++ b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementKeycloakImpl.java
@@ -618,6 +618,36 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface {
     }
 
     @Override
+    public boolean deleteUser(String accessToken, String tenantId, String username) throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            if(userRepresentation != null)
+            {
+                client.realm(tenantId).users().delete(userRepresentation.getId());
+                return true;
+            }else{
+                throw new IamAdminServicesException("User [" + username + "] wasn't found in Keycloak!");
+            }
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } catch (Exception ex){
+            logger.error("Error deleting user in keycloak server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error deleting user in keycloak server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
     public boolean addRoleToUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException {
 
         Keycloak client = null;
diff --git a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/cpi/IamAdminServices.java b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/cpi/IamAdminServices.java
index d994d84..7a7e796 100644
--- a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/cpi/IamAdminServices.java
+++ b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/cpi/IamAdminServices.java
@@ -7,7 +7,7 @@
 package org.apache.custos.profile.iam.admin.services.cpi;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-10")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-15")
 public class IamAdminServices {
 
   public interface Iface {
@@ -20,7 +20,9 @@ public class IamAdminServices {
 
     public boolean registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
 
-    public boolean enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+    public boolean deleteUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public org.apache.custos.profile.model.user.UserProfile enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
 
     public boolean isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
 
@@ -54,7 +56,9 @@ public class IamAdminServices {
 
     public void registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
-    public void enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+    public void deleteUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
 
     public void isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
@@ -209,7 +213,34 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "registerUser failed: unknown result");
     }
 
-    public boolean enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    public boolean deleteUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_deleteUser(authzToken, username);
+      return recv_deleteUser();
+    }
+
+    public void send_deleteUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
+    {
+      deleteUser_args args = new deleteUser_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      sendBase("deleteUser", args);
+    }
+
+    public boolean recv_deleteUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      deleteUser_result result = new deleteUser_result();
+      receiveBase(result, "deleteUser");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "deleteUser failed: unknown result");
+    }
+
+    public org.apache.custos.profile.model.user.UserProfile enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
     {
       send_enableUser(authzToken, username);
       return recv_enableUser();
@@ -223,7 +254,7 @@ public class IamAdminServices {
       sendBase("enableUser", args);
     }
 
-    public boolean recv_enableUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    public org.apache.custos.profile.model.user.UserProfile recv_enableUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
     {
       enableUser_result result = new enableUser_result();
       receiveBase(result, "enableUser");
@@ -679,17 +710,52 @@ public class IamAdminServices {
       }
     }
 
-    public void enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+    public void deleteUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      deleteUser_call method_call = new deleteUser_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class deleteUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public deleteUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.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("deleteUser", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        deleteUser_args args = new deleteUser_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_deleteUser();
+      }
+    }
+
+    public void enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       enableUser_call method_call = new enableUser_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class enableUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+    public static class enableUser_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.profile.model.user.UserProfile> {
       private org.apache.custos.commons.model.security.AuthzToken authzToken;
       private String username;
-      public enableUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+      public enableUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> 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.username = username;
@@ -704,7 +770,7 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+      public org.apache.custos.profile.model.user.UserProfile getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
         if (getState() != State.RESPONSE_READ) {
           throw new IllegalStateException("Method call not finished!");
         }
@@ -1108,6 +1174,7 @@ public class IamAdminServices {
       processMap.put("setUpGateway", new setUpGateway());
       processMap.put("isUsernameAvailable", new isUsernameAvailable());
       processMap.put("registerUser", new registerUser());
+      processMap.put("deleteUser", new deleteUser());
       processMap.put("enableUser", new enableUser());
       processMap.put("isUserEnabled", new isUserEnabled());
       processMap.put("isUserExist", new isUserExist());
@@ -1240,6 +1307,36 @@ public class IamAdminServices {
       }
     }
 
+    public static class deleteUser<I extends Iface> extends org.apache.thrift.ProcessFunction<I, deleteUser_args> {
+      public deleteUser() {
+        super("deleteUser");
+      }
+
+      public deleteUser_args getEmptyArgsInstance() {
+        return new deleteUser_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public deleteUser_result getResult(I iface, deleteUser_args args) throws org.apache.thrift.TException {
+        deleteUser_result result = new deleteUser_result();
+        try {
+          result.success = iface.deleteUser(args.authzToken, args.username);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
     public static class enableUser<I extends Iface> extends org.apache.thrift.ProcessFunction<I, enableUser_args> {
       public enableUser() {
         super("enableUser");
@@ -1262,7 +1359,6 @@ public class IamAdminServices {
         enableUser_result result = new enableUser_result();
         try {
           result.success = iface.enableUser(args.authzToken, args.username);
-          result.setSuccessIsSet(true);
         } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
         }
@@ -1582,6 +1678,7 @@ public class IamAdminServices {
       processMap.put("setUpGateway", new setUpGateway());
       processMap.put("isUsernameAvailable", new isUsernameAvailable());
       processMap.put("registerUser", new registerUser());
+      processMap.put("deleteUser", new deleteUser());
       processMap.put("enableUser", new enableUser());
       processMap.put("isUserEnabled", new isUserEnabled());
       processMap.put("isUserExist", new isUserExist());
@@ -1858,7 +1955,73 @@ public class IamAdminServices {
       }
     }
 
-    public static class enableUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, enableUser_args, Boolean> {
+    public static class deleteUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, deleteUser_args, Boolean> {
+      public deleteUser() {
+        super("deleteUser");
+      }
+
+      public deleteUser_args getEmptyArgsInstance() {
+        return new deleteUser_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            deleteUser_result result = new deleteUser_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            deleteUser_result result = new deleteUser_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, deleteUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.deleteUser(args.authzToken, args.username,resultHandler);
+      }
+    }
+
+    public static class enableUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, enableUser_args, org.apache.custos.profile.model.user.UserProfile> {
       public enableUser() {
         super("enableUser");
       }
@@ -1867,13 +2030,12 @@ public class IamAdminServices {
         return new enableUser_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
-          public void onComplete(Boolean o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile>() { 
+          public void onComplete(org.apache.custos.profile.model.user.UserProfile o) {
             enableUser_result result = new enableUser_result();
             result.success = o;
-            result.setSuccessIsSet(true);
             try {
               fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
             } catch (org.apache.thrift.transport.TTransportException e) {
@@ -1919,7 +2081,7 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, enableUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, enableUser_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
         iface.enableUser(args.authzToken, args.username,resultHandler);
       }
     }
@@ -6642,14 +6804,14 @@ public class IamAdminServices {
     }
   }
 
-  public static class enableUser_args implements org.apache.thrift.TBase<enableUser_args, enableUser_args._Fields>, java.io.Serializable, Cloneable, Comparable<enableUser_args>   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("enableUser_args");
+  public static class deleteUser_args implements org.apache.thrift.TBase<deleteUser_args, deleteUser_args._Fields>, java.io.Serializable, Cloneable, Comparable<deleteUser_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("deleteUser_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 USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)2);
 
-    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new enableUser_argsStandardSchemeFactory();
-    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new enableUser_argsTupleSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new deleteUser_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new deleteUser_argsTupleSchemeFactory();
 
     public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
     public @org.apache.thrift.annotation.Nullable String username; // required
@@ -6726,13 +6888,13 @@ public class IamAdminServices {
       tmpMap.put(_Fields.USERNAME, 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)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(enableUser_args.class, metaDataMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(deleteUser_args.class, metaDataMap);
     }
 
-    public enableUser_args() {
+    public deleteUser_args() {
     }
 
-    public enableUser_args(
+    public deleteUser_args(
       org.apache.custos.commons.model.security.AuthzToken authzToken,
       String username)
     {
@@ -6744,7 +6906,7 @@ public class IamAdminServices {
     /**
      * Performs a deep copy on <i>other</i>.
      */
-    public enableUser_args(enableUser_args other) {
+    public deleteUser_args(deleteUser_args other) {
       if (other.isSetAuthzToken()) {
         this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
       }
@@ -6753,8 +6915,8 @@ public class IamAdminServices {
       }
     }
 
-    public enableUser_args deepCopy() {
-      return new enableUser_args(this);
+    public deleteUser_args deepCopy() {
+      return new deleteUser_args(this);
     }
 
     @Override
@@ -6768,7 +6930,7 @@ public class IamAdminServices {
       return this.authzToken;
     }
 
-    public enableUser_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken) {
+    public deleteUser_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken) {
       this.authzToken = authzToken;
       return this;
     }
@@ -6793,7 +6955,7 @@ public class IamAdminServices {
       return this.username;
     }
 
-    public enableUser_args setUsername(@org.apache.thrift.annotation.Nullable String username) {
+    public deleteUser_args setUsername(@org.apache.thrift.annotation.Nullable String username) {
       this.username = username;
       return this;
     }
@@ -6866,12 +7028,12 @@ public class IamAdminServices {
     public boolean equals(Object that) {
       if (that == null)
         return false;
-      if (that instanceof enableUser_args)
-        return this.equals((enableUser_args)that);
+      if (that instanceof deleteUser_args)
+        return this.equals((deleteUser_args)that);
       return false;
     }
 
-    public boolean equals(enableUser_args that) {
+    public boolean equals(deleteUser_args that) {
       if (that == null)
         return false;
       if (this == that)
@@ -6914,7 +7076,7 @@ public class IamAdminServices {
     }
 
     @Override
-    public int compareTo(enableUser_args other) {
+    public int compareTo(deleteUser_args other) {
       if (!getClass().equals(other.getClass())) {
         return getClass().getName().compareTo(other.getClass().getName());
       }
@@ -6959,7 +7121,7 @@ public class IamAdminServices {
 
     @Override
     public String toString() {
-      StringBuilder sb = new StringBuilder("enableUser_args(");
+      StringBuilder sb = new StringBuilder("deleteUser_args(");
       boolean first = true;
 
       sb.append("authzToken:");
@@ -7011,15 +7173,15 @@ public class IamAdminServices {
       }
     }
 
-    private static class enableUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public enableUser_argsStandardScheme getScheme() {
-        return new enableUser_argsStandardScheme();
+    private static class deleteUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public deleteUser_argsStandardScheme getScheme() {
+        return new deleteUser_argsStandardScheme();
       }
     }
 
-    private static class enableUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<enableUser_args> {
+    private static class deleteUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<deleteUser_args> {
 
-      public void read(org.apache.thrift.protocol.TProtocol iprot, enableUser_args struct) throws org.apache.thrift.TException {
+      public void read(org.apache.thrift.protocol.TProtocol iprot, deleteUser_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TField schemeField;
         iprot.readStructBegin();
         while (true)
@@ -7057,7 +7219,7 @@ public class IamAdminServices {
         struct.validate();
       }
 
-      public void write(org.apache.thrift.protocol.TProtocol oprot, enableUser_args struct) throws org.apache.thrift.TException {
+      public void write(org.apache.thrift.protocol.TProtocol oprot, deleteUser_args struct) throws org.apache.thrift.TException {
         struct.validate();
 
         oprot.writeStructBegin(STRUCT_DESC);
@@ -7077,23 +7239,23 @@ public class IamAdminServices {
 
     }
 
-    private static class enableUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public enableUser_argsTupleScheme getScheme() {
-        return new enableUser_argsTupleScheme();
+    private static class deleteUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public deleteUser_argsTupleScheme getScheme() {
+        return new deleteUser_argsTupleScheme();
       }
     }
 
-    private static class enableUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<enableUser_args> {
+    private static class deleteUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<deleteUser_args> {
 
       @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, enableUser_args struct) throws org.apache.thrift.TException {
+      public void write(org.apache.thrift.protocol.TProtocol prot, deleteUser_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         struct.authzToken.write(oprot);
         oprot.writeString(struct.username);
       }
 
       @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, enableUser_args struct) throws org.apache.thrift.TException {
+      public void read(org.apache.thrift.protocol.TProtocol prot, deleteUser_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
         struct.authzToken.read(iprot);
@@ -7108,14 +7270,14 @@ public class IamAdminServices {
     }
   }
 
-  public static class enableUser_result implements org.apache.thrift.TBase<enableUser_result, enableUser_result._Fields>, java.io.Serializable, Cloneable, Comparable<enableUser_result>   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("enableUser_result");
+  public static class deleteUser_result implements org.apache.thrift.TBase<deleteUser_result, deleteUser_result._Fields>, java.io.Serializable, Cloneable, Comparable<deleteUser_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("deleteUser_result");
 
     private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0);
     private static final org.apache.thrift.protocol.TField IDSE_FIELD_DESC = new org.apache.thrift.protocol.TField("Idse", org.apache.thrift.protocol.TType.STRUCT, (short)1);
 
-    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new enableUser_resultStandardSchemeFactory();
-    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new enableUser_resultTupleSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new deleteUser_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new deleteUser_resultTupleSchemeFactory();
 
     public boolean success; // required
     public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // required
@@ -7194,13 +7356,13 @@ public class IamAdminServices {
       tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
           new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(enableUser_result.class, metaDataMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(deleteUser_result.class, metaDataMap);
     }
 
-    public enableUser_result() {
+    public deleteUser_result() {
     }
 
-    public enableUser_result(
+    public deleteUser_result(
       boolean success,
       org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse)
     {
@@ -7213,7 +7375,7 @@ public class IamAdminServices {
     /**
      * Performs a deep copy on <i>other</i>.
      */
-    public enableUser_result(enableUser_result other) {
+    public deleteUser_result(deleteUser_result other) {
       __isset_bitfield = other.__isset_bitfield;
       this.success = other.success;
       if (other.isSetIdse()) {
@@ -7221,8 +7383,8 @@ public class IamAdminServices {
       }
     }
 
-    public enableUser_result deepCopy() {
-      return new enableUser_result(this);
+    public deleteUser_result deepCopy() {
+      return new deleteUser_result(this);
     }
 
     @Override
@@ -7236,7 +7398,7 @@ public class IamAdminServices {
       return this.success;
     }
 
-    public enableUser_result setSuccess(boolean success) {
+    public deleteUser_result setSuccess(boolean success) {
       this.success = success;
       setSuccessIsSet(true);
       return this;
@@ -7260,7 +7422,7 @@ public class IamAdminServices {
       return this.Idse;
     }
 
-    public enableUser_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+    public deleteUser_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
       this.Idse = Idse;
       return this;
     }
@@ -7333,12 +7495,12 @@ public class IamAdminServices {
     public boolean equals(Object that) {
       if (that == null)
         return false;
-      if (that instanceof enableUser_result)
-        return this.equals((enableUser_result)that);
+      if (that instanceof deleteUser_result)
+        return this.equals((deleteUser_result)that);
       return false;
     }
 
-    public boolean equals(enableUser_result that) {
+    public boolean equals(deleteUser_result that) {
       if (that == null)
         return false;
       if (this == that)
@@ -7379,7 +7541,7 @@ public class IamAdminServices {
     }
 
     @Override
-    public int compareTo(enableUser_result other) {
+    public int compareTo(deleteUser_result other) {
       if (!getClass().equals(other.getClass())) {
         return getClass().getName().compareTo(other.getClass().getName());
       }
@@ -7424,7 +7586,7 @@ public class IamAdminServices {
 
     @Override
     public String toString() {
-      StringBuilder sb = new StringBuilder("enableUser_result(");
+      StringBuilder sb = new StringBuilder("deleteUser_result(");
       boolean first = true;
 
       sb.append("success:");
@@ -7465,15 +7627,15 @@ public class IamAdminServices {
       }
     }
 
-    private static class enableUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public enableUser_resultStandardScheme getScheme() {
-        return new enableUser_resultStandardScheme();
+    private static class deleteUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public deleteUser_resultStandardScheme getScheme() {
+        return new deleteUser_resultStandardScheme();
       }
     }
 
-    private static class enableUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<enableUser_result> {
+    private static class deleteUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<deleteUser_result> {
 
-      public void read(org.apache.thrift.protocol.TProtocol iprot, enableUser_result struct) throws org.apache.thrift.TException {
+      public void read(org.apache.thrift.protocol.TProtocol iprot, deleteUser_result struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TField schemeField;
         iprot.readStructBegin();
         while (true)
@@ -7511,7 +7673,7 @@ public class IamAdminServices {
         struct.validate();
       }
 
-      public void write(org.apache.thrift.protocol.TProtocol oprot, enableUser_result struct) throws org.apache.thrift.TException {
+      public void write(org.apache.thrift.protocol.TProtocol oprot, deleteUser_result struct) throws org.apache.thrift.TException {
         struct.validate();
 
         oprot.writeStructBegin(STRUCT_DESC);
@@ -7531,16 +7693,16 @@ public class IamAdminServices {
 
     }
 
-    private static class enableUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public enableUser_resultTupleScheme getScheme() {
-        return new enableUser_resultTupleScheme();
+    private static class deleteUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public deleteUser_resultTupleScheme getScheme() {
+        return new deleteUser_resultTupleScheme();
       }
     }
 
-    private static class enableUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<enableUser_result> {
+    private static class deleteUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<deleteUser_result> {
 
       @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, enableUser_result struct) throws org.apache.thrift.TException {
+      public void write(org.apache.thrift.protocol.TProtocol prot, deleteUser_result struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         java.util.BitSet optionals = new java.util.BitSet();
         if (struct.isSetSuccess()) {
@@ -7559,7 +7721,7 @@ public class IamAdminServices {
       }
 
       @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, enableUser_result struct) throws org.apache.thrift.TException {
+      public void read(org.apache.thrift.protocol.TProtocol prot, deleteUser_result struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         java.util.BitSet incoming = iprot.readBitSet(2);
         if (incoming.get(0)) {
@@ -7579,6 +7741,951 @@ public class IamAdminServices {
     }
   }
 
+  public static class enableUser_args implements org.apache.thrift.TBase<enableUser_args, enableUser_args._Fields>, java.io.Serializable, Cloneable, Comparable<enableUser_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("enableUser_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 USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)2);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new enableUser_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new enableUser_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String username; // 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"),
+      USERNAME((short)2, "username");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          case 2: // USERNAME
+            return USERNAME;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
+      tmpMap.put(_Fields.USERNAME, 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)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(enableUser_args.class, metaDataMap);
+    }
+
+    public enableUser_args() {
+    }
+
+    public enableUser_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String username)
+    {
+      this();
+      this.authzToken = authzToken;
+      this.username = username;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public enableUser_args(enableUser_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+      if (other.isSetUsername()) {
+        this.username = other.username;
+      }
+    }
+
+    public enableUser_args deepCopy() {
+      return new enableUser_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+      this.username = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public enableUser_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getUsername() {
+      return this.username;
+    }
+
+    public enableUser_args setUsername(@org.apache.thrift.annotation.Nullable 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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case USERNAME:
+        if (value == null) {
+          unsetUsername();
+        } else {
+          setUsername((String)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      case USERNAME:
+        return getUsername();
+
+      }
+      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 USERNAME:
+        return isSetUsername();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof enableUser_args)
+        return this.equals((enableUser_args)that);
+      return false;
+    }
+
+    public boolean equals(enableUser_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetUsername()) ? 131071 : 524287);
+      if (isSetUsername())
+        hashCode = hashCode * 8191 + username.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(enableUser_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(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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("enableUser_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("username:");
+      if (this.username == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.username);
+      }
+      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 (username == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'username' 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 enableUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public enableUser_argsStandardScheme getScheme() {
+        return new enableUser_argsStandardScheme();
+      }
+    }
+
+    private static class enableUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<enableUser_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, enableUser_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.custos.commons.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 2: // USERNAME
+              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;
+            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, enableUser_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.username != null) {
+          oprot.writeFieldBegin(USERNAME_FIELD_DESC);
+          oprot.writeString(struct.username);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class enableUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public enableUser_argsTupleScheme getScheme() {
+        return new enableUser_argsTupleScheme();
+      }
+    }
+
+    private static class enableUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<enableUser_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, enableUser_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+        oprot.writeString(struct.username);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, enableUser_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+        struct.username = iprot.readString();
+        struct.setUsernameIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class enableUser_result implements org.apache.thrift.TBase<enableUser_result, enableUser_result._Fields>, java.io.Serializable, Cloneable, Comparable<enableUser_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("enableUser_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+    private static final org.apache.thrift.protocol.TField IDSE_FIELD_DESC = new org.apache.thrift.protocol.TField("Idse", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new enableUser_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new enableUser_resultTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.user.UserProfile success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // 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"),
+      IDSE((short)1, "Idse");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // IDSE
+            return IDSE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.user.UserProfile.class)));
+      tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(enableUser_result.class, metaDataMap);
+    }
+
+    public enableUser_result() {
+    }
+
+    public enableUser_result(
+      org.apache.custos.profile.model.user.UserProfile success,
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse)
+    {
+      this();
+      this.success = success;
+      this.Idse = Idse;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public enableUser_result(enableUser_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new org.apache.custos.profile.model.user.UserProfile(other.success);
+      }
+      if (other.isSetIdse()) {
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
+      }
+    }
+
+    public enableUser_result deepCopy() {
+      return new enableUser_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+      this.Idse = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.model.user.UserProfile getSuccess() {
+      return this.success;
+    }
+
+    public enableUser_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.user.UserProfile 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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
+      return this.Idse;
+    }
+
+    public enableUser_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+      this.Idse = Idse;
+      return this;
+    }
+
+    public void unsetIdse() {
+      this.Idse = null;
+    }
+
+    /** Returns true if field Idse is set (has been assigned a value) and false otherwise */
+    public boolean isSetIdse() {
+      return this.Idse != null;
+    }
+
+    public void setIdseIsSet(boolean value) {
+      if (!value) {
+        this.Idse = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.custos.profile.model.user.UserProfile)value);
+        }
+        break;
+
+      case IDSE:
+        if (value == null) {
+          unsetIdse();
+        } else {
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      case IDSE:
+        return getIdse();
+
+      }
+      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 IDSE:
+        return isSetIdse();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof enableUser_result)
+        return this.equals((enableUser_result)that);
+      return false;
+    }
+
+    public boolean equals(enableUser_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_Idse = true && this.isSetIdse();
+      boolean that_present_Idse = true && that.isSetIdse();
+      if (this_present_Idse || that_present_Idse) {
+        if (!(this_present_Idse && that_present_Idse))
+          return false;
+        if (!this.Idse.equals(that.Idse))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
+      if (isSetSuccess())
+        hashCode = hashCode * 8191 + success.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetIdse()) ? 131071 : 524287);
+      if (isSetIdse())
+        hashCode = hashCode * 8191 + Idse.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(enableUser_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(isSetIdse()).compareTo(other.isSetIdse());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetIdse()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.Idse, other.Idse);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("enableUser_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("Idse:");
+      if (this.Idse == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.Idse);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws org.apache.thrift.TException {
+      // check for required fields
+      // check for sub-struct validity
+      if (success != null) {
+        success.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 enableUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public enableUser_resultStandardScheme getScheme() {
+        return new enableUser_resultStandardScheme();
+      }
+    }
+
+    private static class enableUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<enableUser_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, enableUser_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.STRUCT) {
+                struct.success = new org.apache.custos.profile.model.user.UserProfile();
+                struct.success.read(iprot);
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // IDSE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+                struct.Idse.read(iprot);
+                struct.setIdseIsSet(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, enableUser_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.success != null) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          struct.success.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        if (struct.Idse != null) {
+          oprot.writeFieldBegin(IDSE_FIELD_DESC);
+          struct.Idse.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class enableUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public enableUser_resultTupleScheme getScheme() {
+        return new enableUser_resultTupleScheme();
+      }
+    }
+
+    private static class enableUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<enableUser_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, enableUser_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetIdse()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          struct.success.write(oprot);
+        }
+        if (struct.isSetIdse()) {
+          struct.Idse.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, enableUser_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = new org.apache.custos.profile.model.user.UserProfile();
+          struct.success.read(iprot);
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+          struct.Idse.read(iprot);
+          struct.setIdseIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
   public static class isUserEnabled_args implements org.apache.thrift.TBase<isUserEnabled_args, isUserEnabled_args._Fields>, java.io.Serializable, Cloneable, Comparable<isUserEnabled_args>   {
     private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isUserEnabled_args");
 
diff --git a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/handler/IamAdminServicesHandler.java b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/handler/IamAdminServicesHandler.java
index 5ccfd3a..0339b1c 100644
--- a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/handler/IamAdminServicesHandler.java
+++ b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/handler/IamAdminServicesHandler.java
@@ -24,7 +24,9 @@ package org.apache.custos.profile.iam.admin.services.handler;
 import org.apache.custos.commons.exceptions.ApplicationSettingsException;
 import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.utils.Constants;
+import org.apache.custos.commons.utils.CustosUtils;
 import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.profile.commons.repositories.UserProfileRepository;
 import org.apache.custos.profile.model.tenant.PasswordCredential;
 import org.apache.custos.profile.model.user.UserProfile;
 import org.apache.custos.profile.model.workspace.Gateway;
@@ -41,7 +43,7 @@ import java.util.List;
 public class IamAdminServicesHandler implements IamAdminServices.Iface {
 
     private final static Logger logger = LoggerFactory.getLogger(IamAdminServicesHandler.class);
-
+    private UserProfileRepository userProfileRepository = new UserProfileRepository();
 
     @Override
     public String getAPIVersion() throws IamAdminServicesException {
@@ -98,14 +100,25 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    public boolean enableUser(AuthzToken authzToken, String username) throws IamAdminServicesException {
+    public UserProfile enableUser(AuthzToken authzToken, String username) throws IamAdminServicesException, TException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
         try {
-            if (keycloakclient.enableUserAccount(authzToken.getAccessToken(), gatewayId, username))
-                return true;
-            else
-                return false;
+            if (keycloakclient.enableUserAccount(authzToken.getAccessToken(), gatewayId, username)) {
+                // Check if user profile exists, if not create it
+                UserProfile userProfile = userProfileRepository.getUserProfileByIdAndGateWay(username, gatewayId);
+                if (userProfile == null) {
+                    // Load basic user profile information from Keycloak and then save in UserProfileRepository
+                    userProfile = keycloakclient.getUser(authzToken.getAccessToken(), gatewayId, username);
+                    userProfile.setCreationTime(CustosUtils.getCurrentTimestamp().getTime());
+                    userProfile.setLastAccessTime(CustosUtils.getCurrentTimestamp().getTime());
+                    userProfile.setValidUntil(-1);
+                    userProfileRepository.createUserProfile(userProfile);
+                }
+                return userProfile;
+            } else {
+                return null;
+            }
         } catch (TException ex) {
             String msg = "Error while enabling user account, reason: " + ex.getMessage();
             logger.error(msg, ex);
@@ -207,6 +220,15 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
+    public boolean deleteUser(AuthzToken authzToken, String username) throws IamAdminServicesException, TException {
+
+        TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
+        String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
+
+        return keycloakclient.deleteUser(authzToken.getAccessToken(), gatewayId, username);
+    }
+
+    @Override
     @Deprecated
     //TODO: check if isRealmAdminCredentials required or not
     public boolean addRoleToUser(AuthzToken authzToken, String username, String roleName, PasswordCredential isRealmAdminCredentials) throws IamAdminServicesException, TException {
diff --git a/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/core/TenantProfileRepository.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/TenantProfileRepository.java
similarity index 85%
rename from custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/core/TenantProfileRepository.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/TenantProfileRepository.java
index b20f428..9aabf9d 100644
--- a/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/core/TenantProfileRepository.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/TenantProfileRepository.java
@@ -17,9 +17,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.custos.profile.tenant.core;
+package org.apache.custos.profile.commons.repositories;
 
-import org.apache.custos.profile.commons.repositories.AbstractRepository;
 import org.apache.custos.profile.commons.tenant.entities.GatewayEntity;
 import org.apache.custos.profile.commons.utils.QueryConstants;
 import org.apache.custos.profile.model.workspace.Gateway;
@@ -59,6 +58,22 @@ public class TenantProfileRepository extends AbstractRepository<Gateway, Gateway
         return gateway;
     }
 
+    public Gateway getGatewayUsingGatewayId (String gatewayId) throws Exception {
+        Gateway gateway = null;
+        try {
+            Map<String, Object> queryParam = new HashMap<String, Object>();
+            queryParam.put(Gateway._Fields.GATEWAY_ID.getFieldName(), gatewayId);
+            List<Gateway> gatewayList = select(QueryConstants.FIND_GATEWAY_BY_GATEWAY_ID, 1, 0, queryParam);
+            if (!gatewayList.isEmpty()) {
+                gateway = gatewayList.get(0);
+            }
+        } catch (Exception ex) {
+            logger.error("Error while getting gateway, reason: " + ex.getMessage(), ex);
+            throw ex;
+        }
+        return gateway;
+    }
+
     public List<Gateway> getAllGateways () throws Exception {
         try {
             List<Gateway> gatewayList = select(QueryConstants.GET_ALL_GATEWAYS);
diff --git a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/core/repositories/UserProfileRepository.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/UserProfileRepository.java
similarity index 97%
rename from custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/core/repositories/UserProfileRepository.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/UserProfileRepository.java
index 9f81813..fab458c 100644
--- a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/core/repositories/UserProfileRepository.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/UserProfileRepository.java
@@ -18,9 +18,8 @@
  * under the License.
  *
 */
-package org.apache.custos.profile.user.core.repositories;
+package org.apache.custos.profile.commons.repositories;
 
-import org.apache.custos.profile.commons.repositories.AbstractRepository;
 import org.apache.custos.profile.commons.user.entities.UserProfileEntity;
 import org.apache.custos.profile.commons.utils.JPAUtils;
 import org.apache.custos.profile.commons.utils.ObjectMapperSingleton;
diff --git a/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/client/TenantProfileClient.java b/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/client/TenantProfileClient.java
new file mode 100644
index 0000000..9e8a45c
--- /dev/null
+++ b/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/client/TenantProfileClient.java
@@ -0,0 +1,26 @@
+package org.apache.custos.profile.tenant.client;
+
+import org.apache.custos.profile.tenant.cpi.TenantProfileService;
+import org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException;
+import org.apache.custos.profile.tenant.cpi.profile_tenant_cpiConstants;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TMultiplexedProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+public class TenantProfileClient {
+
+    public static TenantProfileService.Client createCustosTenantProfileServiceClient(String serverHost, int serverPort) throws TenantProfileServiceException {
+        try {
+            TTransport transport = new TSocket(serverHost, serverPort);
+            transport.open();
+            TProtocol protocol = new TBinaryProtocol(transport);
+            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME);
+            return new TenantProfileService.Client(multiplexedProtocol);
+        } catch (TTransportException e) {
+            throw new TenantProfileServiceException(e.getMessage());
+        }
+    }
+}
diff --git a/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/cpi/TenantProfileService.java b/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/cpi/TenantProfileService.java
index b9402a7..c2150c1 100644
--- a/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/cpi/TenantProfileService.java
+++ b/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/cpi/TenantProfileService.java
@@ -7,7 +7,7 @@
 package org.apache.custos.profile.tenant.cpi;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-09")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-14")
 public class TenantProfileService {
 
   public interface Iface {
@@ -20,6 +20,8 @@ public class TenantProfileService {
 
     public org.apache.custos.profile.model.workspace.Gateway getGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.thrift.TException;
 
+    public org.apache.custos.profile.model.workspace.Gateway getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.thrift.TException;
+
     public org.apache.custos.profile.model.workspace.Gateway deleteGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId, String gatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.thrift.TException;
 
     public java.util.List<org.apache.custos.profile.model.workspace.Gateway> getAllGateways(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.thrift.TException;
@@ -42,6 +44,8 @@ public class TenantProfileService {
 
     public void getGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
 
+    public void getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
+
     public void deleteGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
 
     public void getAllGateways(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.workspace.Gateway>> resultHandler) throws org.apache.thrift.TException;
@@ -180,6 +184,33 @@ public class TenantProfileService {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getGateway failed: unknown result");
     }
 
+    public org.apache.custos.profile.model.workspace.Gateway getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.thrift.TException
+    {
+      send_getGatewayUsingGatewayId(authzToken, gatewayId);
+      return recv_getGatewayUsingGatewayId();
+    }
+
+    public void send_getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.thrift.TException
+    {
+      getGatewayUsingGatewayId_args args = new getGatewayUsingGatewayId_args();
+      args.setAuthzToken(authzToken);
+      args.setGatewayId(gatewayId);
+      sendBase("getGatewayUsingGatewayId", args);
+    }
+
+    public org.apache.custos.profile.model.workspace.Gateway recv_getGatewayUsingGatewayId() throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.thrift.TException
+    {
+      getGatewayUsingGatewayId_result result = new getGatewayUsingGatewayId_result();
+      receiveBase(result, "getGatewayUsingGatewayId");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.tpe != null) {
+        throw result.tpe;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getGatewayUsingGatewayId failed: unknown result");
+    }
+
     public org.apache.custos.profile.model.workspace.Gateway deleteGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId, String gatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.thrift.TException
     {
       send_deleteGateway(authzToken, custosInternalGatewayId, gatewayId);
@@ -467,6 +498,41 @@ public class TenantProfileService {
       }
     }
 
+    public void getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      getGatewayUsingGatewayId_call method_call = new getGatewayUsingGatewayId_call(authzToken, gatewayId, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class getGatewayUsingGatewayId_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.profile.model.workspace.Gateway> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String gatewayId;
+      public getGatewayUsingGatewayId_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> 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;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getGatewayUsingGatewayId", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        getGatewayUsingGatewayId_args args = new getGatewayUsingGatewayId_args();
+        args.setAuthzToken(authzToken);
+        args.setGatewayId(gatewayId);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public org.apache.custos.profile.model.workspace.Gateway getResult() throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.thrift.TException {
+        if (getState() != 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_getGatewayUsingGatewayId();
+      }
+    }
+
     public void deleteGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       deleteGateway_call method_call = new deleteGateway_call(authzToken, custosInternalGatewayId, gatewayId, resultHandler, this, ___protocolFactory, ___transport);
@@ -659,6 +725,7 @@ public class TenantProfileService {
       processMap.put("addGateway", new addGateway());
       processMap.put("updateGateway", new updateGateway());
       processMap.put("getGateway", new getGateway());
+      processMap.put("getGatewayUsingGatewayId", new getGatewayUsingGatewayId());
       processMap.put("deleteGateway", new deleteGateway());
       processMap.put("getAllGateways", new getAllGateways());
       processMap.put("isGatewayExist", new isGatewayExist());
@@ -783,6 +850,35 @@ public class TenantProfileService {
       }
     }
 
+    public static class getGatewayUsingGatewayId<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getGatewayUsingGatewayId_args> {
+      public getGatewayUsingGatewayId() {
+        super("getGatewayUsingGatewayId");
+      }
+
+      public getGatewayUsingGatewayId_args getEmptyArgsInstance() {
+        return new getGatewayUsingGatewayId_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public getGatewayUsingGatewayId_result getResult(I iface, getGatewayUsingGatewayId_args args) throws org.apache.thrift.TException {
+        getGatewayUsingGatewayId_result result = new getGatewayUsingGatewayId_result();
+        try {
+          result.success = iface.getGatewayUsingGatewayId(args.authzToken, args.gatewayId);
+        } catch (org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException tpe) {
+          result.tpe = tpe;
+        }
+        return result;
+      }
+    }
+
     public static class deleteGateway<I extends Iface> extends org.apache.thrift.ProcessFunction<I, deleteGateway_args> {
       public deleteGateway() {
         super("deleteGateway");
@@ -947,6 +1043,7 @@ public class TenantProfileService {
       processMap.put("addGateway", new addGateway());
       processMap.put("updateGateway", new updateGateway());
       processMap.put("getGateway", new getGateway());
+      processMap.put("getGatewayUsingGatewayId", new getGatewayUsingGatewayId());
       processMap.put("deleteGateway", new deleteGateway());
       processMap.put("getAllGateways", new getAllGateways());
       processMap.put("isGatewayExist", new isGatewayExist());
@@ -1215,6 +1312,71 @@ public class TenantProfileService {
       }
     }
 
+    public static class getGatewayUsingGatewayId<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getGatewayUsingGatewayId_args, org.apache.custos.profile.model.workspace.Gateway> {
+      public getGatewayUsingGatewayId() {
+        super("getGatewayUsingGatewayId");
+      }
+
+      public getGatewayUsingGatewayId_args getEmptyArgsInstance() {
+        return new getGatewayUsingGatewayId_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway>() { 
+          public void onComplete(org.apache.custos.profile.model.workspace.Gateway o) {
+            getGatewayUsingGatewayId_result result = new getGatewayUsingGatewayId_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            getGatewayUsingGatewayId_result result = new getGatewayUsingGatewayId_result();
+            if (e instanceof org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException) {
+              result.tpe = (org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException) e;
+              result.setTpeIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, getGatewayUsingGatewayId_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
+        iface.getGatewayUsingGatewayId(args.authzToken, args.gatewayId,resultHandler);
+      }
+    }
+
     public static class deleteGateway<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, deleteGateway_args, org.apache.custos.profile.model.workspace.Gateway> {
       public deleteGateway() {
         super("deleteGateway");
@@ -5117,6 +5279,951 @@ public class TenantProfileService {
     }
   }
 
+  public static class getGatewayUsingGatewayId_args implements org.apache.thrift.TBase<getGatewayUsingGatewayId_args, getGatewayUsingGatewayId_args._Fields>, java.io.Serializable, Cloneable, Comparable<getGatewayUsingGatewayId_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getGatewayUsingGatewayId_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getGatewayUsingGatewayId_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getGatewayUsingGatewayId_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String gatewayId; // 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");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          case 2: // GATEWAY_ID
+            return GATEWAY_ID;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.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)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getGatewayUsingGatewayId_args.class, metaDataMap);
+    }
+
+    public getGatewayUsingGatewayId_args() {
+    }
+
+    public getGatewayUsingGatewayId_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String gatewayId)
+    {
+      this();
+      this.authzToken = authzToken;
+      this.gatewayId = gatewayId;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getGatewayUsingGatewayId_args(getGatewayUsingGatewayId_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+      if (other.isSetGatewayId()) {
+        this.gatewayId = other.gatewayId;
+      }
+    }
+
+    public getGatewayUsingGatewayId_args deepCopy() {
+      return new getGatewayUsingGatewayId_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+      this.gatewayId = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public getGatewayUsingGatewayId_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getGatewayId() {
+      return this.gatewayId;
+    }
+
+    public getGatewayUsingGatewayId_args setGatewayId(@org.apache.thrift.annotation.Nullable 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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case GATEWAY_ID:
+        if (value == null) {
+          unsetGatewayId();
+        } else {
+          setGatewayId((String)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      case GATEWAY_ID:
+        return getGatewayId();
+
+      }
+      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();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getGatewayUsingGatewayId_args)
+        return this.equals((getGatewayUsingGatewayId_args)that);
+      return false;
+    }
+
+    public boolean equals(getGatewayUsingGatewayId_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetGatewayId()) ? 131071 : 524287);
+      if (isSetGatewayId())
+        hashCode = hashCode * 8191 + gatewayId.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getGatewayUsingGatewayId_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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getGatewayUsingGatewayId_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;
+      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());
+      }
+      // 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 getGatewayUsingGatewayId_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getGatewayUsingGatewayId_argsStandardScheme getScheme() {
+        return new getGatewayUsingGatewayId_argsStandardScheme();
+      }
+    }
+
+    private static class getGatewayUsingGatewayId_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getGatewayUsingGatewayId_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getGatewayUsingGatewayId_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.custos.commons.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;
+            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, getGatewayUsingGatewayId_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();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getGatewayUsingGatewayId_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getGatewayUsingGatewayId_argsTupleScheme getScheme() {
+        return new getGatewayUsingGatewayId_argsTupleScheme();
+      }
+    }
+
+    private static class getGatewayUsingGatewayId_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getGatewayUsingGatewayId_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getGatewayUsingGatewayId_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+        oprot.writeString(struct.gatewayId);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getGatewayUsingGatewayId_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+        struct.gatewayId = iprot.readString();
+        struct.setGatewayIdIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getGatewayUsingGatewayId_result implements org.apache.thrift.TBase<getGatewayUsingGatewayId_result, getGatewayUsingGatewayId_result._Fields>, java.io.Serializable, Cloneable, Comparable<getGatewayUsingGatewayId_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getGatewayUsingGatewayId_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+    private static final org.apache.thrift.protocol.TField TPE_FIELD_DESC = new org.apache.thrift.protocol.TField("tpe", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getGatewayUsingGatewayId_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getGatewayUsingGatewayId_resultTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException tpe; // 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"),
+      TPE((short)1, "tpe");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // TPE
+            return TPE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.workspace.Gateway.class)));
+      tmpMap.put(_Fields.TPE, new org.apache.thrift.meta_data.FieldMetaData("tpe", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getGatewayUsingGatewayId_result.class, metaDataMap);
+    }
+
+    public getGatewayUsingGatewayId_result() {
+    }
+
+    public getGatewayUsingGatewayId_result(
+      org.apache.custos.profile.model.workspace.Gateway success,
+      org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException tpe)
+    {
+      this();
+      this.success = success;
+      this.tpe = tpe;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getGatewayUsingGatewayId_result(getGatewayUsingGatewayId_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new org.apache.custos.profile.model.workspace.Gateway(other.success);
+      }
+      if (other.isSetTpe()) {
+        this.tpe = new org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException(other.tpe);
+      }
+    }
+
+    public getGatewayUsingGatewayId_result deepCopy() {
+      return new getGatewayUsingGatewayId_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+      this.tpe = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.model.workspace.Gateway getSuccess() {
+      return this.success;
+    }
+
+    public getGatewayUsingGatewayId_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway 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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException getTpe() {
+      return this.tpe;
+    }
+
+    public getGatewayUsingGatewayId_result setTpe(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException tpe) {
+      this.tpe = tpe;
+      return this;
+    }
+
+    public void unsetTpe() {
+      this.tpe = null;
+    }
+
+    /** Returns true if field tpe is set (has been assigned a value) and false otherwise */
+    public boolean isSetTpe() {
+      return this.tpe != null;
+    }
+
+    public void setTpeIsSet(boolean value) {
+      if (!value) {
+        this.tpe = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.custos.profile.model.workspace.Gateway)value);
+        }
+        break;
+
+      case TPE:
+        if (value == null) {
+          unsetTpe();
+        } else {
+          setTpe((org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      case TPE:
+        return getTpe();
+
+      }
+      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 TPE:
+        return isSetTpe();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getGatewayUsingGatewayId_result)
+        return this.equals((getGatewayUsingGatewayId_result)that);
+      return false;
+    }
+
+    public boolean equals(getGatewayUsingGatewayId_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_tpe = true && this.isSetTpe();
+      boolean that_present_tpe = true && that.isSetTpe();
+      if (this_present_tpe || that_present_tpe) {
+        if (!(this_present_tpe && that_present_tpe))
+          return false;
+        if (!this.tpe.equals(that.tpe))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
+      if (isSetSuccess())
+        hashCode = hashCode * 8191 + success.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetTpe()) ? 131071 : 524287);
+      if (isSetTpe())
+        hashCode = hashCode * 8191 + tpe.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getGatewayUsingGatewayId_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(isSetTpe()).compareTo(other.isSetTpe());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetTpe()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tpe, other.tpe);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getGatewayUsingGatewayId_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("tpe:");
+      if (this.tpe == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.tpe);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws org.apache.thrift.TException {
+      // check for required fields
+      // check for sub-struct validity
+      if (success != null) {
+        success.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 getGatewayUsingGatewayId_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getGatewayUsingGatewayId_resultStandardScheme getScheme() {
+        return new getGatewayUsingGatewayId_resultStandardScheme();
+      }
+    }
+
+    private static class getGatewayUsingGatewayId_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getGatewayUsingGatewayId_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getGatewayUsingGatewayId_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.STRUCT) {
+                struct.success = new org.apache.custos.profile.model.workspace.Gateway();
+                struct.success.read(iprot);
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // TPE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.tpe = new org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException();
+                struct.tpe.read(iprot);
+                struct.setTpeIsSet(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, getGatewayUsingGatewayId_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.success != null) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          struct.success.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        if (struct.tpe != null) {
+          oprot.writeFieldBegin(TPE_FIELD_DESC);
+          struct.tpe.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getGatewayUsingGatewayId_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getGatewayUsingGatewayId_resultTupleScheme getScheme() {
+        return new getGatewayUsingGatewayId_resultTupleScheme();
+      }
+    }
+
+    private static class getGatewayUsingGatewayId_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getGatewayUsingGatewayId_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getGatewayUsingGatewayId_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetTpe()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          struct.success.write(oprot);
+        }
+        if (struct.isSetTpe()) {
+          struct.tpe.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getGatewayUsingGatewayId_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = new org.apache.custos.profile.model.workspace.Gateway();
+          struct.success.read(iprot);
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.tpe = new org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException();
+          struct.tpe.read(iprot);
+          struct.setTpeIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
   public static class deleteGateway_args implements org.apache.thrift.TBase<deleteGateway_args, deleteGateway_args._Fields>, java.io.Serializable, Cloneable, Comparable<deleteGateway_args>   {
     private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("deleteGateway_args");
 
diff --git a/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/handler/TenantProfileServiceHandler.java b/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/handler/TenantProfileServiceHandler.java
index f194e84..b68a440 100644
--- a/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/handler/TenantProfileServiceHandler.java
+++ b/custos-profile-service/tenant-profile-service/src/main/java/org/apache/custos/profile/tenant/handler/TenantProfileServiceHandler.java
@@ -23,7 +23,7 @@ import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.profile.commons.tenant.entities.GatewayEntity;
 import org.apache.custos.profile.model.workspace.Gateway;
 import org.apache.custos.profile.model.workspace.GatewayApprovalStatus;
-import org.apache.custos.profile.tenant.core.TenantProfileRepository;
+import org.apache.custos.profile.commons.repositories.TenantProfileRepository;
 import org.apache.custos.profile.tenant.cpi.TenantProfileService;
 import org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException;
 import org.apache.custos.profile.tenant.cpi.profile_tenant_cpiConstants;
@@ -31,7 +31,6 @@ import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.persistence.metamodel.EntityType;
 import java.util.List;
 import java.util.UUID;
 
@@ -123,6 +122,22 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
     }
 
     @Override
+    public Gateway getGatewayUsingGatewayId(AuthzToken authzToken, String gatewayId) throws TenantProfileServiceException, TException {
+        try {
+            Gateway gateway = tenantProfileRepository.getGatewayUsingGatewayId(gatewayId);
+            if (gateway == null) {
+                throw new Exception("Could not find Gateway with ID: " + gatewayId);
+            }
+            return gateway;
+        } catch (Exception ex) {
+            logger.error("Error getting gateway-profile, reason: " + ex.getMessage(), ex);
+            TenantProfileServiceException exception = new TenantProfileServiceException();
+            exception.setMessage("Error getting gateway-profile, reason: " + ex.getMessage());
+            throw exception;
+        }
+    }
+
+    @Override
     public Gateway deleteGateway(AuthzToken authzToken, String custosInternalGatewayId, String gatewayId) throws TenantProfileServiceException, TException {
         try {
             logger.debug("Deleting Custos gateway-profile with ID: " + gatewayId + "Internal ID: " + custosInternalGatewayId);
diff --git a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/client/UserProfileClient.java b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/client/UserProfileClient.java
new file mode 100644
index 0000000..c5136c2
--- /dev/null
+++ b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/client/UserProfileClient.java
@@ -0,0 +1,4 @@
+package org.apache.custos.profile.user.client;
+
+public class UserProfileClient {
+}
diff --git a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/cpi/UserProfileService.java b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/cpi/UserProfileService.java
index 74df8c9..d05650c 100644
--- a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/cpi/UserProfileService.java
+++ b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/cpi/UserProfileService.java
@@ -7,7 +7,7 @@
 package org.apache.custos.profile.user.cpi;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-10")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-14")
 public class UserProfileService {
 
   public interface Iface {
@@ -21,9 +21,9 @@ public class UserProfileService {
      */
     public org.apache.custos.profile.model.user.UserProfile initializeUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException;
 
-    public org.apache.custos.profile.model.user.UserProfile addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException;
+    public org.apache.custos.profile.model.user.UserProfile addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException;
 
-    public org.apache.custos.profile.model.user.UserProfile updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException;
+    public org.apache.custos.profile.model.user.UserProfile updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException;
 
     public org.apache.custos.profile.model.user.UserProfile getUserProfileById(org.apache.custos.commons.model.security.AuthzToken authzToken, String userId, String gatewayId) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException;
 
@@ -41,9 +41,9 @@ public class UserProfileService {
 
     public void initializeUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
 
-    public void addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
+    public void addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
 
-    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
 
     public void getUserProfileById(org.apache.custos.commons.model.security.AuthzToken authzToken, String userId, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
 
@@ -126,19 +126,17 @@ public class UserProfileService {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "initializeUserProfile failed: unknown result");
     }
 
-    public org.apache.custos.profile.model.user.UserProfile addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException
+    public org.apache.custos.profile.model.user.UserProfile addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException
     {
-      send_addUserProfile(authzToken, userProfile, clientId, clientSecret);
+      send_addUserProfile(authzToken, userProfile);
       return recv_addUserProfile();
     }
 
-    public void send_addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret) throws org.apache.thrift.TException
+    public void send_addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile) throws org.apache.thrift.TException
     {
       addUserProfile_args args = new addUserProfile_args();
       args.setAuthzToken(authzToken);
       args.setUserProfile(userProfile);
-      args.setClientId(clientId);
-      args.setClientSecret(clientSecret);
       sendBase("addUserProfile", args);
     }
 
@@ -155,19 +153,17 @@ public class UserProfileService {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "addUserProfile failed: unknown result");
     }
 
-    public org.apache.custos.profile.model.user.UserProfile updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException
+    public org.apache.custos.profile.model.user.UserProfile updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile) throws org.apache.custos.profile.user.cpi.exception.UserProfileServiceException, org.apache.thrift.TException
     {
-      send_updateUserProfile(authzToken, userProfile, clientId, clientSecret);
+      send_updateUserProfile(authzToken, userProfile);
       return recv_updateUserProfile();
     }
 
-    public void send_updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret) throws org.apache.thrift.TException
+    public void send_updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile) throws org.apache.thrift.TException
     {
       updateUserProfile_args args = new updateUserProfile_args();
       args.setAuthzToken(authzToken);
       args.setUserProfile(userProfile);
-      args.setClientId(clientId);
-      args.setClientSecret(clientSecret);
       sendBase("updateUserProfile", args);
     }
 
@@ -376,9 +372,9 @@ public class UserProfileService {
       }
     }
 
-    public void addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
+    public void addUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      addUserProfile_call method_call = new addUserProfile_call(authzToken, userProfile, clientId, clientSecret, resultHandler, this, ___protocolFactory, ___transport);
+      addUserProfile_call method_call = new addUserProfile_call(authzToken, userProfile, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
@@ -386,14 +382,10 @@ public class UserProfileService {
     public static class addUserProfile_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.profile.model.user.UserProfile> {
       private org.apache.custos.commons.model.security.AuthzToken authzToken;
       private org.apache.custos.profile.model.user.UserProfile userProfile;
-      private String clientId;
-      private String clientSecret;
-      public addUserProfile_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.t [...]
+      public addUserProfile_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> 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.userProfile = userProfile;
-        this.clientId = clientId;
-        this.clientSecret = clientSecret;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -401,8 +393,6 @@ public class UserProfileService {
         addUserProfile_args args = new addUserProfile_args();
         args.setAuthzToken(authzToken);
         args.setUserProfile(userProfile);
-        args.setClientId(clientId);
-        args.setClientSecret(clientSecret);
         args.write(prot);
         prot.writeMessageEnd();
       }
@@ -417,9 +407,9 @@ public class UserProfileService {
       }
     }
 
-    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      updateUserProfile_call method_call = new updateUserProfile_call(authzToken, userProfile, clientId, clientSecret, resultHandler, this, ___protocolFactory, ___transport);
+      updateUserProfile_call method_call = new updateUserProfile_call(authzToken, userProfile, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
@@ -427,14 +417,10 @@ public class UserProfileService {
     public static class updateUserProfile_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.profile.model.user.UserProfile> {
       private org.apache.custos.commons.model.security.AuthzToken authzToken;
       private org.apache.custos.profile.model.user.UserProfile userProfile;
-      private String clientId;
-      private String clientSecret;
-      public updateUserProfile_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apach [...]
+      public updateUserProfile_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userProfile, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> 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.userProfile = userProfile;
-        this.clientId = clientId;
-        this.clientSecret = clientSecret;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -442,8 +428,6 @@ public class UserProfileService {
         updateUserProfile_args args = new updateUserProfile_args();
         args.setAuthzToken(authzToken);
         args.setUserProfile(userProfile);
-        args.setClientId(clientId);
-        args.setClientSecret(clientSecret);
         args.write(prot);
         prot.writeMessageEnd();
       }
@@ -716,7 +700,7 @@ public class UserProfileService {
       public addUserProfile_result getResult(I iface, addUserProfile_args args) throws org.apache.thrift.TException {
         addUserProfile_result result = new addUserProfile_result();
         try {
-          result.success = iface.addUserProfile(args.authzToken, args.userProfile, args.clientId, args.clientSecret);
+          result.success = iface.addUserProfile(args.authzToken, args.userProfile);
         } catch (org.apache.custos.profile.user.cpi.exception.UserProfileServiceException upe) {
           result.upe = upe;
         }
@@ -745,7 +729,7 @@ public class UserProfileService {
       public updateUserProfile_result getResult(I iface, updateUserProfile_args args) throws org.apache.thrift.TException {
         updateUserProfile_result result = new updateUserProfile_result();
         try {
-          result.success = iface.updateUserProfile(args.authzToken, args.userProfile, args.clientId, args.clientSecret);
+          result.success = iface.updateUserProfile(args.authzToken, args.userProfile);
         } catch (org.apache.custos.profile.user.cpi.exception.UserProfileServiceException upe) {
           result.upe = upe;
         }
@@ -1085,7 +1069,7 @@ public class UserProfileService {
       }
 
       public void start(I iface, addUserProfile_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
-        iface.addUserProfile(args.authzToken, args.userProfile, args.clientId, args.clientSecret,resultHandler);
+        iface.addUserProfile(args.authzToken, args.userProfile,resultHandler);
       }
     }
 
@@ -1150,7 +1134,7 @@ public class UserProfileService {
       }
 
       public void start(I iface, updateUserProfile_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
-        iface.updateUserProfile(args.authzToken, args.userProfile, args.clientId, args.clientSecret,resultHandler);
+        iface.updateUserProfile(args.authzToken, args.userProfile,resultHandler);
       }
     }
 
@@ -2994,23 +2978,17 @@ public class UserProfileService {
 
     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 USER_PROFILE_FIELD_DESC = new org.apache.thrift.protocol.TField("userProfile", org.apache.thrift.protocol.TType.STRUCT, (short)2);
-    private static final org.apache.thrift.protocol.TField CLIENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("clientId", org.apache.thrift.protocol.TType.STRING, (short)3);
-    private static final org.apache.thrift.protocol.TField CLIENT_SECRET_FIELD_DESC = new org.apache.thrift.protocol.TField("clientSecret", org.apache.thrift.protocol.TType.STRING, (short)4);
 
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new addUserProfile_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new addUserProfile_argsTupleSchemeFactory();
 
     public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
     public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.user.UserProfile userProfile; // required
-    public @org.apache.thrift.annotation.Nullable String clientId; // required
-    public @org.apache.thrift.annotation.Nullable String clientSecret; // 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"),
-      USER_PROFILE((short)2, "userProfile"),
-      CLIENT_ID((short)3, "clientId"),
-      CLIENT_SECRET((short)4, "clientSecret");
+      USER_PROFILE((short)2, "userProfile");
 
       private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
@@ -3030,10 +3008,6 @@ public class UserProfileService {
             return AUTHZ_TOKEN;
           case 2: // USER_PROFILE
             return USER_PROFILE;
-          case 3: // CLIENT_ID
-            return CLIENT_ID;
-          case 4: // CLIENT_SECRET
-            return CLIENT_SECRET;
           default:
             return null;
         }
@@ -3082,10 +3056,6 @@ public class UserProfileService {
           new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
       tmpMap.put(_Fields.USER_PROFILE, new org.apache.thrift.meta_data.FieldMetaData("userProfile", org.apache.thrift.TFieldRequirementType.REQUIRED, 
           new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.user.UserProfile.class)));
-      tmpMap.put(_Fields.CLIENT_ID, new org.apache.thrift.meta_data.FieldMetaData("clientId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-      tmpMap.put(_Fields.CLIENT_SECRET, new org.apache.thrift.meta_data.FieldMetaData("clientSecret", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(addUserProfile_args.class, metaDataMap);
     }
@@ -3095,15 +3065,11 @@ public class UserProfileService {
 
     public addUserProfile_args(
       org.apache.custos.commons.model.security.AuthzToken authzToken,
-      org.apache.custos.profile.model.user.UserProfile userProfile,
-      String clientId,
-      String clientSecret)
+      org.apache.custos.profile.model.user.UserProfile userProfile)
     {
       this();
       this.authzToken = authzToken;
       this.userProfile = userProfile;
-      this.clientId = clientId;
-      this.clientSecret = clientSecret;
     }
 
     /**
@@ -3116,12 +3082,6 @@ public class UserProfileService {
       if (other.isSetUserProfile()) {
         this.userProfile = new org.apache.custos.profile.model.user.UserProfile(other.userProfile);
       }
-      if (other.isSetClientId()) {
-        this.clientId = other.clientId;
-      }
-      if (other.isSetClientSecret()) {
-        this.clientSecret = other.clientSecret;
-      }
     }
 
     public addUserProfile_args deepCopy() {
@@ -3132,8 +3092,6 @@ public class UserProfileService {
     public void clear() {
       this.authzToken = null;
       this.userProfile = null;
-      this.clientId = null;
-      this.clientSecret = null;
     }
 
     @org.apache.thrift.annotation.Nullable
@@ -3186,56 +3144,6 @@ public class UserProfileService {
       }
     }
 
-    @org.apache.thrift.annotation.Nullable
-    public String getClientId() {
-      return this.clientId;
-    }
-
-    public addUserProfile_args setClientId(@org.apache.thrift.annotation.Nullable String clientId) {
-      this.clientId = clientId;
-      return this;
-    }
-
-    public void unsetClientId() {
-      this.clientId = null;
-    }
-
-    /** Returns true if field clientId is set (has been assigned a value) and false otherwise */
-    public boolean isSetClientId() {
-      return this.clientId != null;
-    }
-
-    public void setClientIdIsSet(boolean value) {
-      if (!value) {
-        this.clientId = null;
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public String getClientSecret() {
-      return this.clientSecret;
-    }
-
-    public addUserProfile_args setClientSecret(@org.apache.thrift.annotation.Nullable String clientSecret) {
-      this.clientSecret = clientSecret;
-      return this;
-    }
-
-    public void unsetClientSecret() {
-      this.clientSecret = null;
-    }
-
-    /** Returns true if field clientSecret is set (has been assigned a value) and false otherwise */
-    public boolean isSetClientSecret() {
-      return this.clientSecret != null;
-    }
-
-    public void setClientSecretIsSet(boolean value) {
-      if (!value) {
-        this.clientSecret = null;
-      }
-    }
-
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case AUTHZ_TOKEN:
@@ -3254,22 +3162,6 @@ public class UserProfileService {
         }
         break;
 
-      case CLIENT_ID:
-        if (value == null) {
-          unsetClientId();
-        } else {
-          setClientId((String)value);
-        }
-        break;
-
-      case CLIENT_SECRET:
-        if (value == null) {
-          unsetClientSecret();
-        } else {
-          setClientSecret((String)value);
-        }
-        break;
-
       }
     }
 
@@ -3282,12 +3174,6 @@ public class UserProfileService {
       case USER_PROFILE:
         return getUserProfile();
 
-      case CLIENT_ID:
-        return getClientId();
-
-      case CLIENT_SECRET:
-        return getClientSecret();
-
       }
       throw new IllegalStateException();
     }
@@ -3303,10 +3189,6 @@ public class UserProfileService {
         return isSetAuthzToken();
       case USER_PROFILE:
         return isSetUserProfile();
-      case CLIENT_ID:
-        return isSetClientId();
-      case CLIENT_SECRET:
-        return isSetClientSecret();
       }
       throw new IllegalStateException();
     }
@@ -3344,24 +3226,6 @@ public class UserProfileService {
           return false;
       }
 
-      boolean this_present_clientId = true && this.isSetClientId();
-      boolean that_present_clientId = true && that.isSetClientId();
-      if (this_present_clientId || that_present_clientId) {
-        if (!(this_present_clientId && that_present_clientId))
-          return false;
-        if (!this.clientId.equals(that.clientId))
-          return false;
-      }
-
-      boolean this_present_clientSecret = true && this.isSetClientSecret();
-      boolean that_present_clientSecret = true && that.isSetClientSecret();
-      if (this_present_clientSecret || that_present_clientSecret) {
-        if (!(this_present_clientSecret && that_present_clientSecret))
-          return false;
-        if (!this.clientSecret.equals(that.clientSecret))
-          return false;
-      }
-
       return true;
     }
 
@@ -3377,14 +3241,6 @@ public class UserProfileService {
       if (isSetUserProfile())
         hashCode = hashCode * 8191 + userProfile.hashCode();
 
-      hashCode = hashCode * 8191 + ((isSetClientId()) ? 131071 : 524287);
-      if (isSetClientId())
-        hashCode = hashCode * 8191 + clientId.hashCode();
-
-      hashCode = hashCode * 8191 + ((isSetClientSecret()) ? 131071 : 524287);
-      if (isSetClientSecret())
-        hashCode = hashCode * 8191 + clientSecret.hashCode();
-
       return hashCode;
     }
 
@@ -3416,26 +3272,6 @@ public class UserProfileService {
           return lastComparison;
         }
       }
-      lastComparison = Boolean.valueOf(isSetClientId()).compareTo(other.isSetClientId());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetClientId()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientId, other.clientId);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
-      lastComparison = Boolean.valueOf(isSetClientSecret()).compareTo(other.isSetClientSecret());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetClientSecret()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientSecret, other.clientSecret);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
       return 0;
     }
 
@@ -3472,22 +3308,6 @@ public class UserProfileService {
         sb.append(this.userProfile);
       }
       first = false;
-      if (!first) sb.append(", ");
-      sb.append("clientId:");
-      if (this.clientId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.clientId);
-      }
-      first = false;
-      if (!first) sb.append(", ");
-      sb.append("clientSecret:");
-      if (this.clientSecret == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.clientSecret);
-      }
-      first = false;
       sb.append(")");
       return sb.toString();
     }
@@ -3500,12 +3320,6 @@ public class UserProfileService {
       if (userProfile == null) {
         throw new org.apache.thrift.protocol.TProtocolException("Required field 'userProfile' was not present! Struct: " + toString());
       }
-      if (clientId == null) {
-        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientId' was not present! Struct: " + toString());
-      }
-      if (clientSecret == null) {
-        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientSecret' was not present! Struct: " + toString());
-      }
       // check for sub-struct validity
       if (authzToken != null) {
         authzToken.validate();
@@ -3567,22 +3381,6 @@ public class UserProfileService {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
-            case 3: // CLIENT_ID
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-                struct.clientId = iprot.readString();
-                struct.setClientIdIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
-            case 4: // CLIENT_SECRET
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-                struct.clientSecret = iprot.readString();
-                struct.setClientSecretIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
             default:
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
           }
@@ -3608,16 +3406,6 @@ public class UserProfileService {
           struct.userProfile.write(oprot);
           oprot.writeFieldEnd();
         }
-        if (struct.clientId != null) {
-          oprot.writeFieldBegin(CLIENT_ID_FIELD_DESC);
-          oprot.writeString(struct.clientId);
-          oprot.writeFieldEnd();
-        }
-        if (struct.clientSecret != null) {
-          oprot.writeFieldBegin(CLIENT_SECRET_FIELD_DESC);
-          oprot.writeString(struct.clientSecret);
-          oprot.writeFieldEnd();
-        }
         oprot.writeFieldStop();
         oprot.writeStructEnd();
       }
@@ -3637,8 +3425,6 @@ public class UserProfileService {
         org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         struct.authzToken.write(oprot);
         struct.userProfile.write(oprot);
-        oprot.writeString(struct.clientId);
-        oprot.writeString(struct.clientSecret);
       }
 
       @Override
@@ -3650,10 +3436,6 @@ public class UserProfileService {
         struct.userProfile = new org.apache.custos.profile.model.user.UserProfile();
         struct.userProfile.read(iprot);
         struct.setUserProfileIsSet(true);
-        struct.clientId = iprot.readString();
-        struct.setClientIdIsSet(true);
-        struct.clientSecret = iprot.readString();
-        struct.setClientSecretIsSet(true);
       }
     }
 
@@ -4146,23 +3928,17 @@ public class UserProfileService {
 
     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 USER_PROFILE_FIELD_DESC = new org.apache.thrift.protocol.TField("userProfile", org.apache.thrift.protocol.TType.STRUCT, (short)2);
-    private static final org.apache.thrift.protocol.TField CLIENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("clientId", org.apache.thrift.protocol.TType.STRING, (short)3);
-    private static final org.apache.thrift.protocol.TField CLIENT_SECRET_FIELD_DESC = new org.apache.thrift.protocol.TField("clientSecret", org.apache.thrift.protocol.TType.STRING, (short)4);
 
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new updateUserProfile_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new updateUserProfile_argsTupleSchemeFactory();
 
     public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
     public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.user.UserProfile userProfile; // required
-    public @org.apache.thrift.annotation.Nullable String clientId; // required
-    public @org.apache.thrift.annotation.Nullable String clientSecret; // 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"),
-      USER_PROFILE((short)2, "userProfile"),
-      CLIENT_ID((short)3, "clientId"),
-      CLIENT_SECRET((short)4, "clientSecret");
+      USER_PROFILE((short)2, "userProfile");
 
       private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
@@ -4182,10 +3958,6 @@ public class UserProfileService {
             return AUTHZ_TOKEN;
           case 2: // USER_PROFILE
             return USER_PROFILE;
-          case 3: // CLIENT_ID
-            return CLIENT_ID;
-          case 4: // CLIENT_SECRET
-            return CLIENT_SECRET;
           default:
             return null;
         }
@@ -4234,10 +4006,6 @@ public class UserProfileService {
           new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
       tmpMap.put(_Fields.USER_PROFILE, new org.apache.thrift.meta_data.FieldMetaData("userProfile", org.apache.thrift.TFieldRequirementType.REQUIRED, 
           new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.user.UserProfile.class)));
-      tmpMap.put(_Fields.CLIENT_ID, new org.apache.thrift.meta_data.FieldMetaData("clientId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-      tmpMap.put(_Fields.CLIENT_SECRET, new org.apache.thrift.meta_data.FieldMetaData("clientSecret", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(updateUserProfile_args.class, metaDataMap);
     }
@@ -4247,15 +4015,11 @@ public class UserProfileService {
 
     public updateUserProfile_args(
       org.apache.custos.commons.model.security.AuthzToken authzToken,
-      org.apache.custos.profile.model.user.UserProfile userProfile,
-      String clientId,
-      String clientSecret)
+      org.apache.custos.profile.model.user.UserProfile userProfile)
     {
       this();
       this.authzToken = authzToken;
       this.userProfile = userProfile;
-      this.clientId = clientId;
-      this.clientSecret = clientSecret;
     }
 
     /**
@@ -4268,12 +4032,6 @@ public class UserProfileService {
       if (other.isSetUserProfile()) {
         this.userProfile = new org.apache.custos.profile.model.user.UserProfile(other.userProfile);
       }
-      if (other.isSetClientId()) {
-        this.clientId = other.clientId;
-      }
-      if (other.isSetClientSecret()) {
-        this.clientSecret = other.clientSecret;
-      }
     }
 
     public updateUserProfile_args deepCopy() {
@@ -4284,8 +4042,6 @@ public class UserProfileService {
     public void clear() {
       this.authzToken = null;
       this.userProfile = null;
-      this.clientId = null;
-      this.clientSecret = null;
     }
 
     @org.apache.thrift.annotation.Nullable
@@ -4338,56 +4094,6 @@ public class UserProfileService {
       }
     }
 
-    @org.apache.thrift.annotation.Nullable
-    public String getClientId() {
-      return this.clientId;
-    }
-
-    public updateUserProfile_args setClientId(@org.apache.thrift.annotation.Nullable String clientId) {
-      this.clientId = clientId;
-      return this;
-    }
-
-    public void unsetClientId() {
-      this.clientId = null;
-    }
-
-    /** Returns true if field clientId is set (has been assigned a value) and false otherwise */
-    public boolean isSetClientId() {
-      return this.clientId != null;
-    }
-
-    public void setClientIdIsSet(boolean value) {
-      if (!value) {
-        this.clientId = null;
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public String getClientSecret() {
-      return this.clientSecret;
-    }
-
-    public updateUserProfile_args setClientSecret(@org.apache.thrift.annotation.Nullable String clientSecret) {
-      this.clientSecret = clientSecret;
-      return this;
-    }
-
-    public void unsetClientSecret() {
-      this.clientSecret = null;
-    }
-
-    /** Returns true if field clientSecret is set (has been assigned a value) and false otherwise */
-    public boolean isSetClientSecret() {
-      return this.clientSecret != null;
-    }
-
-    public void setClientSecretIsSet(boolean value) {
-      if (!value) {
-        this.clientSecret = null;
-      }
-    }
-
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case AUTHZ_TOKEN:
@@ -4406,22 +4112,6 @@ public class UserProfileService {
         }
         break;
 
-      case CLIENT_ID:
-        if (value == null) {
-          unsetClientId();
-        } else {
-          setClientId((String)value);
-        }
-        break;
-
-      case CLIENT_SECRET:
-        if (value == null) {
-          unsetClientSecret();
-        } else {
-          setClientSecret((String)value);
-        }
-        break;
-
       }
     }
 
@@ -4434,12 +4124,6 @@ public class UserProfileService {
       case USER_PROFILE:
         return getUserProfile();
 
-      case CLIENT_ID:
-        return getClientId();
-
-      case CLIENT_SECRET:
-        return getClientSecret();
-
       }
       throw new IllegalStateException();
     }
@@ -4455,10 +4139,6 @@ public class UserProfileService {
         return isSetAuthzToken();
       case USER_PROFILE:
         return isSetUserProfile();
-      case CLIENT_ID:
-        return isSetClientId();
-      case CLIENT_SECRET:
-        return isSetClientSecret();
       }
       throw new IllegalStateException();
     }
@@ -4496,24 +4176,6 @@ public class UserProfileService {
           return false;
       }
 
-      boolean this_present_clientId = true && this.isSetClientId();
-      boolean that_present_clientId = true && that.isSetClientId();
-      if (this_present_clientId || that_present_clientId) {
-        if (!(this_present_clientId && that_present_clientId))
-          return false;
-        if (!this.clientId.equals(that.clientId))
-          return false;
-      }
-
-      boolean this_present_clientSecret = true && this.isSetClientSecret();
-      boolean that_present_clientSecret = true && that.isSetClientSecret();
-      if (this_present_clientSecret || that_present_clientSecret) {
-        if (!(this_present_clientSecret && that_present_clientSecret))
-          return false;
-        if (!this.clientSecret.equals(that.clientSecret))
-          return false;
-      }
-
       return true;
     }
 
@@ -4529,14 +4191,6 @@ public class UserProfileService {
       if (isSetUserProfile())
         hashCode = hashCode * 8191 + userProfile.hashCode();
 
-      hashCode = hashCode * 8191 + ((isSetClientId()) ? 131071 : 524287);
-      if (isSetClientId())
-        hashCode = hashCode * 8191 + clientId.hashCode();
-
-      hashCode = hashCode * 8191 + ((isSetClientSecret()) ? 131071 : 524287);
-      if (isSetClientSecret())
-        hashCode = hashCode * 8191 + clientSecret.hashCode();
-
       return hashCode;
     }
 
@@ -4568,26 +4222,6 @@ public class UserProfileService {
           return lastComparison;
         }
       }
-      lastComparison = Boolean.valueOf(isSetClientId()).compareTo(other.isSetClientId());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetClientId()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientId, other.clientId);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
-      lastComparison = Boolean.valueOf(isSetClientSecret()).compareTo(other.isSetClientSecret());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetClientSecret()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientSecret, other.clientSecret);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
       return 0;
     }
 
@@ -4624,22 +4258,6 @@ public class UserProfileService {
         sb.append(this.userProfile);
       }
       first = false;
-      if (!first) sb.append(", ");
-      sb.append("clientId:");
-      if (this.clientId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.clientId);
-      }
-      first = false;
-      if (!first) sb.append(", ");
-      sb.append("clientSecret:");
-      if (this.clientSecret == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.clientSecret);
-      }
-      first = false;
       sb.append(")");
       return sb.toString();
     }
@@ -4652,12 +4270,6 @@ public class UserProfileService {
       if (userProfile == null) {
         throw new org.apache.thrift.protocol.TProtocolException("Required field 'userProfile' was not present! Struct: " + toString());
       }
-      if (clientId == null) {
-        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientId' was not present! Struct: " + toString());
-      }
-      if (clientSecret == null) {
-        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientSecret' was not present! Struct: " + toString());
-      }
       // check for sub-struct validity
       if (authzToken != null) {
         authzToken.validate();
@@ -4719,22 +4331,6 @@ public class UserProfileService {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
-            case 3: // CLIENT_ID
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-                struct.clientId = iprot.readString();
-                struct.setClientIdIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
-            case 4: // CLIENT_SECRET
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-                struct.clientSecret = iprot.readString();
-                struct.setClientSecretIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
             default:
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
           }
@@ -4760,16 +4356,6 @@ public class UserProfileService {
           struct.userProfile.write(oprot);
           oprot.writeFieldEnd();
         }
-        if (struct.clientId != null) {
-          oprot.writeFieldBegin(CLIENT_ID_FIELD_DESC);
-          oprot.writeString(struct.clientId);
-          oprot.writeFieldEnd();
-        }
-        if (struct.clientSecret != null) {
-          oprot.writeFieldBegin(CLIENT_SECRET_FIELD_DESC);
-          oprot.writeString(struct.clientSecret);
-          oprot.writeFieldEnd();
-        }
         oprot.writeFieldStop();
         oprot.writeStructEnd();
       }
@@ -4789,8 +4375,6 @@ public class UserProfileService {
         org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         struct.authzToken.write(oprot);
         struct.userProfile.write(oprot);
-        oprot.writeString(struct.clientId);
-        oprot.writeString(struct.clientSecret);
       }
 
       @Override
@@ -4802,10 +4386,6 @@ public class UserProfileService {
         struct.userProfile = new org.apache.custos.profile.model.user.UserProfile();
         struct.userProfile.read(iprot);
         struct.setUserProfileIsSet(true);
-        struct.clientId = iprot.readString();
-        struct.setClientIdIsSet(true);
-        struct.clientSecret = iprot.readString();
-        struct.setClientSecretIsSet(true);
       }
     }
 
diff --git a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java
index e72677c..317eb51 100644
--- a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java
+++ b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java
@@ -33,7 +33,7 @@ import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServic
 import org.apache.custos.profile.model.user.Status;
 import org.apache.custos.profile.model.user.UserProfile;
 import org.apache.custos.profile.model.user.user_profile_modelConstants;
-import org.apache.custos.profile.user.core.repositories.UserProfileRepository;
+import org.apache.custos.profile.commons.repositories.UserProfileRepository;
 import org.apache.custos.profile.user.cpi.UserProfileService;
 import org.apache.custos.profile.user.cpi.exception.UserProfileServiceException;
 import org.apache.custos.security.manager.CustosSecurityManager;
@@ -101,13 +101,12 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
 
     @Override
     //@SecurityCheck
-    //TODO: need to find alternative for clientId and clientSecret
-    public UserProfile addUserProfile(AuthzToken authzToken, UserProfile userProfile, String clientId, String clientSecret) throws UserProfileServiceException {
+    public UserProfile addUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException {
         try{
             // Lowercase user id and internal id
             userProfile.setUserId(userProfile.getUserId().toLowerCase());
             userProfile.setCustosInternalUserId(userProfile.getUserId() + "@" + userProfile.getGatewayId());
-            userProfile = userProfileRepository.updateUserProfile(userProfile, getIAMUserProfileUpdater(authzToken, userProfile, clientId, clientSecret));
+            userProfile = userProfileRepository.updateUserProfile(userProfile, getIAMUserProfileUpdater(authzToken, userProfile));
             if (null != userProfile) {
                 logger.info("Added UserProfile with userId: " + userProfile.getUserId());
                 return userProfile;
@@ -124,13 +123,12 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
 
     @Override
     //@SecurityCheck
-    //TODO: need to find alternative for clientId and secret
-    public UserProfile updateUserProfile(AuthzToken authzToken, UserProfile userProfile, String clientId, String clientSecret) throws UserProfileServiceException {
+    public UserProfile updateUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException {
         try {
             // After updating the user profile in the database but before committing the transaction, the
             // following will update the user profile in the IAM service also. If the update in the IAM service
             // fails then the transaction will be rolled back.
-            Runnable iamUserProfileUpdater = getIAMUserProfileUpdater(authzToken, userProfile, clientId, clientSecret);
+            Runnable iamUserProfileUpdater = getIAMUserProfileUpdater(authzToken, userProfile);
             if(userProfileRepository.updateUserProfile(userProfile, iamUserProfileUpdater) != null) {
                 logger.info("Updated UserProfile with userId: " + userProfile.getUserId());
                return userProfile;
@@ -144,12 +142,12 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
         throw new UserProfileServiceException("User update failed. Please try again.");
     }
 
-    private Runnable getIAMUserProfileUpdater(AuthzToken authzToken, UserProfile userProfile, String clientId, String clientSecret) throws UserProfileServiceException {
+    private Runnable getIAMUserProfileUpdater(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException {
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
         return () -> {
             try {
                 CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
-                AuthzToken serviceAccountAuthzToken = securityManager.getUserManagementServiceAccountAuthzToken(authzToken,gatewayId, clientId, clientSecret);
+                AuthzToken serviceAccountAuthzToken = securityManager.getUserManagementServiceAccountAuthzToken(authzToken,gatewayId);
                 IamAdminServices.Client iamAdminServicesClient = getIamAdminServicesClient();
                 iamAdminServicesClient.updateUserProfile(serviceAccountAuthzToken, userProfile);
             } catch (CustosSecurityException |TException e) {
diff --git a/thrift-interfaces/authentication-service/authentication-service-cpi.thrift b/thrift-interfaces/authentication-service/authentication-service-cpi.thrift
index ab6e3a8..b422f42 100644
--- a/thrift-interfaces/authentication-service/authentication-service-cpi.thrift
+++ b/thrift-interfaces/authentication-service/authentication-service-cpi.thrift
@@ -10,5 +10,5 @@ service CustosAuthenticationService {
     bool isUserAuthenticated(1: required security_model.AuthzToken authzToken)
                             throws (1: authentication_service_cpi_errors.CustosAuthenticationServiceException ae)
     userInfo_model.UserInfo getUserInfoFromAuthzToken(1: required security_model.AuthzToken authzToken) throws (1: authentication_service_cpi_errors.CustosAuthenticationServiceException ae)
-    security_model.AuthzToken getUserManagementServiceAccountAuthzToken(1: required security_model.AuthzToken authzToken, 2: required string gatewayId, 3:required string clientId, 4: required string clientSecret ) throws (1: authentication_service_cpi_errors.CustosAuthenticationServiceException ae)
+    security_model.AuthzToken getUserManagementServiceAccountAuthzToken(1: required security_model.AuthzToken authzToken, 2: required string gatewayId) throws (1: authentication_service_cpi_errors.CustosAuthenticationServiceException ae)
 }
diff --git a/thrift-interfaces/profile-service/iam-admin-services/iam-admin-services-cpi.thrift b/thrift-interfaces/profile-service/iam-admin-services/iam-admin-services-cpi.thrift
index 051d645..f028ab1 100644
--- a/thrift-interfaces/profile-service/iam-admin-services/iam-admin-services-cpi.thrift
+++ b/thrift-interfaces/profile-service/iam-admin-services/iam-admin-services-cpi.thrift
@@ -61,7 +61,11 @@ service IamAdminServices {
                         6: required string newPassword)
                         throws (1: iam_admin_services_cpi_errors.IamAdminServicesException Idse)
 
-    bool enableUser(1: required security_model.AuthzToken authzToken,
+    bool deleteUser(1: required security_model.AuthzToken authzToken,
+                                    2: required string username)
+                                    throws (1: iam_admin_services_cpi_errors.IamAdminServicesException Idse)
+
+    user_profile_model.UserProfile enableUser(1: required security_model.AuthzToken authzToken,
                         2: required string username)
                             throws (1: iam_admin_services_cpi_errors.IamAdminServicesException Idse)
 
diff --git a/thrift-interfaces/profile-service/profile-tenant/profile-tenant-cpi.thrift b/thrift-interfaces/profile-service/profile-tenant/profile-tenant-cpi.thrift
index c904418..7f7ddd2 100644
--- a/thrift-interfaces/profile-service/profile-tenant/profile-tenant-cpi.thrift
+++ b/thrift-interfaces/profile-service/profile-tenant/profile-tenant-cpi.thrift
@@ -53,6 +53,10 @@ service TenantProfileService {
                                         2: required string custosInternalGatewayId)
                                      throws (1: profile_tenant_cpi_errors.TenantProfileServiceException tpe)
 
+    workspace_model.Gateway getGatewayUsingGatewayId (1: required security_model.AuthzToken authzToken,
+                                            2: required string gatewayId)
+                                         throws (1: profile_tenant_cpi_errors.TenantProfileServiceException tpe)
+
     workspace_model.Gateway deleteGateway (1: required security_model.AuthzToken authzToken,
                         2: required string custosInternalGatewayId,
                         3: required string gatewayId)
diff --git a/thrift-interfaces/profile-service/profile-user/profile-user-cpi.thrift b/thrift-interfaces/profile-service/profile-user/profile-user-cpi.thrift
index efd2abd..b4405d0 100644
--- a/thrift-interfaces/profile-service/profile-user/profile-user-cpi.thrift
+++ b/thrift-interfaces/profile-service/profile-user/profile-user-cpi.thrift
@@ -48,15 +48,11 @@ service UserProfileService {
                             throws (1: profile_user_cpi_errors.UserProfileServiceException upe);
 
   user_profile_model.UserProfile addUserProfile (1: required security_model.AuthzToken authzToken,
-                         2: required user_profile_model.UserProfile userProfile,
-                         3: required string clientId,
-                         4: required string clientSecret)
+                         2: required user_profile_model.UserProfile userProfile)
                       throws (1: profile_user_cpi_errors.UserProfileServiceException upe);
 
   user_profile_model.UserProfile updateUserProfile (1: required security_model.AuthzToken authzToken,
-                          2: required user_profile_model.UserProfile userProfile,
-                          3: required string clientId,
-                          4: required string clientSecret)
+                          2: required user_profile_model.UserProfile userProfile)
                        throws (1: profile_user_cpi_errors.UserProfileServiceException upe);
 
   user_profile_model.UserProfile getUserProfileById (1: required security_model.AuthzToken authzToken,


[airavata-custos] 26/48: addes user profile test cases

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 20e50106dba1251e62abb74073aa5f675874e5a6
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Aug 19 21:27:55 2019 -0400

    addes user profile test cases
---
 .../src/main/resources/custos-server.properties    |   3 +-
 .../src/main/resources/META-INF/persistence.xml    |   1 -
 .../user-profile-service/pom.xml                   |  14 +++
 .../user/handler/UserProfileServiceHandler.java    |  18 ++--
 .../test/java/TestUserProfileServiceHandler.java   | 110 +++++++++++++++++++++
 .../src/main/resources/custos-server.properties    |   3 +-
 .../src/main/resources/docker-compose.yml          |   2 +-
 pom.xml                                            |   2 +
 8 files changed, 139 insertions(+), 14 deletions(-)

diff --git a/ide-integration/src/main/resources/custos-server.properties b/custos-commons/src/main/resources/custos-server.properties
similarity index 98%
copy from ide-integration/src/main/resources/custos-server.properties
copy to custos-commons/src/main/resources/custos-server.properties
index 4d75666..d9d59c3 100644
--- a/ide-integration/src/main/resources/custos-server.properties
+++ b/custos-commons/src/main/resources/custos-server.properties
@@ -54,8 +54,9 @@ in.memory.cache.size=1000
 # Profile Service Configuration
 ###########################################################################
 profile.service.server.host=0.0.0.0
-profile.service.server.port=8963
+profile.service.server.port=9092
 profile_service=org.apache.custos.profile.server.ProfileServiceServer
+
 # MariaDB properties
 profile.service.jdbc.url=jdbc:mariadb://localhost:13306/profile_service
 profile.service.jdbc.user=root
diff --git a/custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml b/custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
index f0a162e..4b92928 100644
--- a/custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
+++ b/custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
@@ -24,7 +24,6 @@
         <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
         <class>org.apache.custos.profile.commons.user.entities.UserProfileEntity</class>
         <class>org.apache.custos.profile.commons.user.entities.NSFDemographicsEntity</class>
-        <class>org.apache.custos.profile.commons.user.entities.CustomizedDashboardEntity</class>
         <class>org.apache.custos.profile.commons.tenant.entities.GatewayEntity</class>
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
 
diff --git a/custos-profile-service/user-profile-service/pom.xml b/custos-profile-service/user-profile-service/pom.xml
index 4afd95c..ec79614 100644
--- a/custos-profile-service/user-profile-service/pom.xml
+++ b/custos-profile-service/user-profile-service/pom.xml
@@ -34,6 +34,20 @@
             <artifactId>iam-admin-services</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.jmockit/jmockit -->
+        <dependency>
+            <groupId>org.jmockit</groupId>
+            <artifactId>jmockit</artifactId>
+            <version>${jmockit.version}</version>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 
 
diff --git a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java
index 317eb51..e29b39d 100644
--- a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java
+++ b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java
@@ -27,13 +27,13 @@ import org.apache.custos.commons.model.security.UserInfo;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.CustosUtils;
 import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.profile.commons.repositories.UserProfileRepository;
 import org.apache.custos.profile.iam.admin.services.client.CustosIamAdminServiceClient;
 import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
 import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
 import org.apache.custos.profile.model.user.Status;
 import org.apache.custos.profile.model.user.UserProfile;
 import org.apache.custos.profile.model.user.user_profile_modelConstants;
-import org.apache.custos.profile.commons.repositories.UserProfileRepository;
 import org.apache.custos.profile.user.cpi.UserProfileService;
 import org.apache.custos.profile.user.cpi.exception.UserProfileServiceException;
 import org.apache.custos.security.manager.CustosSecurityManager;
@@ -62,7 +62,6 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    //@SecurityCheck
     public UserProfile initializeUserProfile(AuthzToken authzToken) throws UserProfileServiceException {
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
         try {
@@ -100,7 +99,6 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    //@SecurityCheck
     public UserProfile addUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException {
         try{
             // Lowercase user id and internal id
@@ -122,7 +120,6 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    //@SecurityCheck
     public UserProfile updateUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException {
         try {
             // After updating the user profile in the database but before committing the transaction, the
@@ -157,8 +154,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    //@SecurityCheck
-    public UserProfile getUserProfileById(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException,TException {
+    public UserProfile getUserProfileById(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException {
         try{
             UserProfile userProfile = userProfileRepository.getUserProfileByIdAndGateWay(userId, gatewayId);
             if(userProfile != null)
@@ -174,8 +170,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    //@SecurityCheck
-    public UserProfile deleteUserProfile(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException,TException {
+    public UserProfile deleteUserProfile(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException {
         UserProfile userProfile = null;
         try{
             // find user-profile
@@ -184,17 +179,20 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
             // delete user
             boolean deleteSuccess = userProfileRepository.delete(userId);
             logger.info("Delete UserProfile with userId: " + userId + ", " + (deleteSuccess? "Success!" : "Failed!"));
+            if(deleteSuccess){
+                return userProfile;
+            }else {
+                throw new Exception("Deleting of user profile with userId: "+ userId + "was not successful");
+            }
         } catch (Exception e) {
             logger.error("Error while deleting user profile", e);
             UserProfileServiceException exception = new UserProfileServiceException();
             exception.setMessage("Error while deleting user profile. More info : " + e.getMessage());
             throw exception;
         }
-        return userProfile;
     }
 
     @Override
-    //@SecurityCheck
     public List<UserProfile> getAllUserProfilesInGateway(AuthzToken authzToken, String gatewayId, int offset, int limit) throws UserProfileServiceException {
         try{
             List<UserProfile> usersInGateway = userProfileRepository.getAllUserProfilesInGateway(gatewayId, offset, limit);
diff --git a/custos-profile-service/user-profile-service/src/test/java/TestUserProfileServiceHandler.java b/custos-profile-service/user-profile-service/src/test/java/TestUserProfileServiceHandler.java
new file mode 100644
index 0000000..b88cee2
--- /dev/null
+++ b/custos-profile-service/user-profile-service/src/test/java/TestUserProfileServiceHandler.java
@@ -0,0 +1,110 @@
+import mockit.*;
+import mockit.integration.junit4.JMockit;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.commons.model.security.UserInfo;
+import org.apache.custos.commons.utils.Constants;
+import org.apache.custos.profile.model.user.UserProfile;
+import org.apache.custos.profile.user.cpi.exception.UserProfileServiceException;
+import org.apache.custos.profile.user.handler.UserProfileServiceHandler;
+import org.apache.custos.security.manager.CustosSecurityManager;
+import org.apache.custos.security.manager.SecurityManagerFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.HashMap;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+@RunWith(JMockit.class)
+public class TestUserProfileServiceHandler {
+
+    private static String GATEWAY_ID = "test-gateway";
+    private static String USER_NAME = "default-user";
+    private static AuthzToken authzToken = new AuthzToken();
+    private static String NEW_USER_ID = "test-username";
+    private int NUMBER_OF_USERS = 1;
+    @Tested
+    private static UserProfileServiceHandler userProfileServiceHandler;
+    @Mocked
+    private static CustosSecurityManager mockedSecurityManager;
+
+    @Before
+    public void setUp() throws CustosSecurityException {
+        HashMap<String,String> map = new HashMap<>();
+        map.put(Constants.GATEWAY_ID, GATEWAY_ID);
+        map.put(Constants.USER_NAME, USER_NAME);
+        authzToken.setClaimsMap(map);
+        authzToken.setAccessToken("access token");
+    }
+    @After
+    public void cleanUp() {
+
+    }
+    @Test
+    public void testInitializeUserProfileWhenUserProfileDoesNotExist(@Mocked CustosSecurityManager mockedSecurityManager) throws UserProfileServiceException, CustosSecurityException {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUsername("test-username");
+        userInfo.setEmailAddress("test@test.com");
+        userInfo.setFirstName("test-first-name");
+        userInfo.setLastName("test-last-name");
+        new MockUp<SecurityManagerFactory>() {
+            @Mock
+            public CustosSecurityManager getSecurityManager(){return mockedSecurityManager;};
+        };
+        new Expectations() {{ mockedSecurityManager.getUserInfoFromAuthzToken(authzToken); result = userInfo;}};
+
+        UserProfile createdUserProfile = userProfileServiceHandler.initializeUserProfile(authzToken);
+        assertNotNull(createdUserProfile);
+        assertEquals(userInfo.getUsername().toLowerCase(), createdUserProfile.getUserId());
+        assertEquals(GATEWAY_ID,createdUserProfile.getGatewayId());
+    }
+    @Test
+    public void testInitializeUserProfileWhenUserProfileExists(@Mocked CustosSecurityManager mockedSecurityManager) throws UserProfileServiceException, CustosSecurityException{
+        UserInfo userInfo = new UserInfo();
+        userInfo.setUsername("test-username");
+        userInfo.setEmailAddress("some-other-test@test.com");
+        userInfo.setFirstName("someother-test-first-name");
+        userInfo.setLastName("someother-test-last-name");
+        String old_email_address = "test@test.com";
+        new MockUp<SecurityManagerFactory>() {
+            @Mock
+            public CustosSecurityManager getSecurityManager(){return mockedSecurityManager;};
+        };
+        new Expectations() {{ mockedSecurityManager.getUserInfoFromAuthzToken(authzToken); result = userInfo;}};
+
+        UserProfile createdUserProfile = userProfileServiceHandler.initializeUserProfile(authzToken);
+        assertNotNull(createdUserProfile);
+        assertEquals(old_email_address,createdUserProfile.getEmails().get(0));
+        assertEquals(userInfo.getUsername().toLowerCase(), createdUserProfile.getUserId());
+        assertEquals(GATEWAY_ID,createdUserProfile.getGatewayId());
+    }
+    @Test
+    public void testGetAllUserProfilesInGateway() throws UserProfileServiceException{
+        List<UserProfile> allGatewayUsers = userProfileServiceHandler.getAllUserProfilesInGateway(authzToken, GATEWAY_ID, 0, 0);
+        assertEquals(NUMBER_OF_USERS, allGatewayUsers.size());
+    }
+    @Test
+    public void testDoesUserExistWhenUserExists()throws UserProfileServiceException{
+        boolean shouldBeTrue = userProfileServiceHandler.doesUserExist(authzToken, "test-username", "test-gateway");
+        assertTrue(shouldBeTrue);
+    }
+    @Test
+    public void testDoesUserExistWhenUserDoesNotExist()throws UserProfileServiceException{
+        boolean shouldBeFalse = userProfileServiceHandler.doesUserExist(authzToken, "does-not-exist", "default");
+        assertFalse(shouldBeFalse);
+
+    }
+    @Test
+    //TODO: check
+    public void testDeleteUserProfile() throws UserProfileServiceException{
+        UserProfile userProfile = userProfileServiceHandler.deleteUserProfile(authzToken, NEW_USER_ID, GATEWAY_ID);
+        assertNotNull(userProfile);
+        assertEquals(NEW_USER_ID, userProfile.getUserId());
+        NUMBER_OF_USERS = 0;
+        //testGetAllUserProfilesInGateway();
+    }
+}
diff --git a/ide-integration/src/main/resources/custos-server.properties b/ide-integration/src/main/resources/custos-server.properties
index 4d75666..d9d59c3 100644
--- a/ide-integration/src/main/resources/custos-server.properties
+++ b/ide-integration/src/main/resources/custos-server.properties
@@ -54,8 +54,9 @@ in.memory.cache.size=1000
 # Profile Service Configuration
 ###########################################################################
 profile.service.server.host=0.0.0.0
-profile.service.server.port=8963
+profile.service.server.port=9092
 profile_service=org.apache.custos.profile.server.ProfileServiceServer
+
 # MariaDB properties
 profile.service.jdbc.url=jdbc:mariadb://localhost:13306/profile_service
 profile.service.jdbc.user=root
diff --git a/ide-integration/src/main/resources/docker-compose.yml b/ide-integration/src/main/resources/docker-compose.yml
index 7ede3bf..5ced9a8 100644
--- a/ide-integration/src/main/resources/docker-compose.yml
+++ b/ide-integration/src/main/resources/docker-compose.yml
@@ -23,5 +23,5 @@ services:
       - ./database_scripts/init:/docker-entrypoint-initdb.d
       - ./database_data:/var/lib/mysql
     ports:
-      - "13306:3307"
+      - "13306:3306"
     command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci', '--sql_mode=']
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 6979179..e0524c7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,6 +30,8 @@
         <log4j.version>1.2.17</log4j.version>
         <thrift.version>0.12.0</thrift.version>
         <openjpa.version>2.4.3</openjpa.version>
+        <junit.version>4.8.1</junit.version>
+        <jmockit.version>1.8</jmockit.version>
     </properties>
     <dependencies>
         <dependency>


[airavata-custos] 34/48: updated the branch with master

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 757fe559cd26b0d2545ce784328ed6625c7acab1
Merge: d89e0de a0b6462
Author: Aarushi <aa...@gmail.com>
AuthorDate: Sat Aug 31 13:15:23 2019 -0400

    updated the branch with master

 .../{cpi => }/CustosAuthenticationService.java     |  238 +---
 .../cpi/CustosAuthenticationService.java           |  236 +---
 .../CustosAuthenticationServiceException.java      |    2 +-
 .../handler/CustosAuthenticationHandler.java       |    6 +-
 ...ava => AuthenticationServiceClientFactory.java} |    2 +-
 .../custos/commons/utils/ServiceRequest.java       |   36 +
 .../src/main/resources/custos-server.properties    |   11 +-
 custos-connectors/pom.xml                          |    5 +
 .../manager/CustosSecurityManager.java             |    2 +-
 .../manager/KeyCloakSecurityManager.java           |   30 +-
 .../main/resources/keystores/client_truststore.jks |  Bin 0 -> 963 bytes
 custos-profile-service/README                      |    3 +
 .../group-profile-api/pom.xml                      |   21 +
 .../group-profile-core/pom.xml                     |   22 +
 .../exceptions/GroupManagerServiceException.java   |   16 +
 .../profile/service/core/models/GroupModel.java    |   73 ++
 .../service/core/service/GroupProfileService.java  |  390 ++++++
 .../group-profile-service/pom.xml                  |   20 +
 .../services/core/TenantManagementInterface.java   |   10 +
 .../core/TenantManagementKeycloakImpl.java         |   30 +
 .../iam/admin/services/cpi/IamAdminServices.java   | 1255 ++++++++++++++++++--
 .../services/handler/IamAdminServicesHandler.java  |   34 +-
 .../repositories}/TenantProfileRepository.java     |   19 +-
 .../repositories/UserProfileRepository.java        |    3 +-
 .../src/main/resources/META-INF/persistence.xml    |    1 -
 .../profile/tenant/client/TenantProfileClient.java |   26 +
 .../profile/tenant/cpi/TenantProfileService.java   | 1109 ++++++++++++++++-
 .../handler/TenantProfileServiceHandler.java       |   19 +-
 .../user-profile-service/pom.xml                   |   14 +
 .../profile/user/client/UserProfileClient.java     |    4 +
 .../profile/user/cpi/UserProfileService.java       |  470 +-------
 .../user/handler/UserProfileServiceHandler.java    |   42 +-
 .../test/java/TestUserProfileServiceHandler.java   |  120 ++
 .../sharing-service-api/pom.xml                    |   23 +
 .../custos/sharing/service/api/AppConfig.java      |   22 +
 .../custos/sharing/service/api/Application.java    |   32 +
 .../api/constants/SharingRegistryEndpoints.java    |   22 +
 .../service/api/controllers/AccessController.java  |   71 ++
 .../service/api/controllers/DomainsController.java |   79 ++
 .../service/api/controllers/EntityController.java  |  117 ++
 .../api/controllers/EntityTypeController.java      |   95 ++
 .../service/api/controllers/GroupController.java   |  244 ++++
 .../api/controllers/PermissionTypeController.java  |   94 ++
 .../service/api/controllers/UsersController.java   |   95 ++
 .../sharing-service-core/pom.xml                   |   58 +
 .../service/core/db/entities/DomainEntity.java     |  116 ++
 .../service/core/db/entities/EntityEntity.java     |  219 ++++
 .../sharing/service/core/db/entities/EntityPK.java |   76 ++
 .../service/core/db/entities/EntityTypeEntity.java |  130 ++
 .../service/core/db/entities/EntityTypePK.java     |   76 ++
 .../service/core/db/entities/GroupAdminEntity.java |   80 ++
 .../service/core/db/entities/GroupAdminPK.java     |   66 +
 .../core/db/entities/GroupMembershipEntity.java    |  126 ++
 .../core/db/entities/GroupMembershipPK.java        |   88 ++
 .../core/db/entities/PermissionTypeEntity.java     |  128 ++
 .../service/core/db/entities/PermissionTypePK.java |   76 ++
 .../service/core/db/entities/SharingEntity.java    |  149 +++
 .../service/core/db/entities/SharingPK.java        |  116 ++
 .../service/core/db/entities/UserEntity.java       |  161 +++
 .../service/core/db/entities/UserGroupEntity.java  |  178 +++
 .../service/core/db/entities/UserGroupPK.java      |   75 ++
 .../sharing/service/core/db/entities/UserPK.java   |   75 ++
 .../core/db/repositories/AbstractRepository.java   |  169 +++
 .../core/db/repositories/DomainRepository.java     |   33 +
 .../core/db/repositories/EntityRepository.java     |  180 +++
 .../core/db/repositories/EntityTypeRepository.java |   34 +
 .../core/db/repositories/GroupAdminRepository.java |   17 +
 .../db/repositories/GroupMembershipRepository.java |  105 ++
 .../db/repositories/PermissionTypeRepository.java  |   52 +
 .../core/db/repositories/SharingRepository.java    |  114 ++
 .../core/db/repositories/UserGroupRepository.java  |   95 ++
 .../core/db/repositories/UserRepository.java       |   79 ++
 .../sharing/service/core/db/utils/Committer.java   |   26 +
 .../sharing/service/core/db/utils/DBConstants.java |  106 ++
 .../sharing/service/core/db/utils/JPAUtils.java    |   35 +
 .../core/db/utils/ObjectMapperSingleton.java       |   38 +
 .../core/db/utils/SharingRegistryDBInitConfig.java |   50 +
 .../core/db/utils/SharingRegistryJDBCConfig.java   |   67 ++
 .../core/exceptions/DuplicateEntryException.java   |   15 +
 .../core/exceptions/ResourceNotFoundException.java |   16 +
 .../core/exceptions/SharingRegistryException.java  |   16 +
 .../custos/sharing/service/core/models/Domain.java |   49 +
 .../custos/sharing/service/core/models/Entity.java |  121 ++
 .../service/core/models/EntitySearchField.java     |   14 +
 .../sharing/service/core/models/EntityType.java    |   58 +
 .../sharing/service/core/models/GroupAdmin.java    |   33 +
 .../service/core/models/GroupCardinality.java      |    6 +
 .../service/core/models/GroupChildType.java        |    6 +
 .../service/core/models/GroupMembership.java       |   60 +
 .../sharing/service/core/models/GroupType.java     |    6 +
 .../service/core/models/PermissionType.java        |   60 +
 .../service/core/models/SearchCondition.java       |   10 +
 .../service/core/models/SearchCriteria.java        |   31 +
 .../sharing/service/core/models/Sharing.java       |   78 ++
 .../sharing/service/core/models/SharingType.java   |    7 +
 .../custos/sharing/service/core/models/User.java   |   85 ++
 .../sharing/service/core/models/UserGroup.java     |   97 ++
 .../core/service/SharingRegistryService.java       | 1216 +++++++++++++++++++
 ide-integration/README.md                          |   64 +
 ide-integration/custos-services/pom.xml            |   15 +
 .../server/start}/CustosAPIServerStarted.java      |    4 +-
 .../src/main/resources/custos-server.properties    |   28 +-
 .../database_scripts/init/01-databases.sql         |   43 +-
 .../user-profile-catalog-derby.sql                 |   30 -
 .../user-profile-catalog-mysql.sql                 |   30 -
 .../src/main/resources/docker-compose.yml          |    4 +-
 .../main/resources/keycloak/Default-export.json    |    0
 .../main/resources/keycloak/Default-export.json.bk |    0
 .../src/main/resources/keycloak/standalone.xml     |    2 +-
 .../src/main/resources/keystores/custos.jks        |  Bin 0 -> 2252 bytes
 .../src/main/resources}/log4j.properties           |    8 +-
 ide-integration/pom.xml                            |   17 +
 ide-integration/samples/commons/pom.xml            |   15 +
 .../org/apache/samples/common/SamplesCommon.java   |   60 +
 .../custos-authentication-service-samples/pom.xml  |   23 +
 .../sample/CustosAuthenticationServiceSample.java  |   64 +
 .../src/main/resources/log4j.properties            |   10 +-
 .../samples/custos-profile-service-samples/pom.xml |   22 +
 .../service/samples/TenantProfileSample.java       |   80 ++
 .../profile/service/samples/UserProfileSample.java |  160 +++
 .../samples/utils/ProfileServiceClientUtil.java    |   63 +
 .../src/main/resources/log4j.properties            |   10 +-
 .../resources/profile-client-sample.properties     |   29 +
 ide-integration/samples/pom.xml                    |   20 +
 .../src/main/resources/keystores/airavata.jks      |  Bin 2679 -> 0 bytes
 .../src/main/resources/keystores/airavata_sym.jks  |  Bin 501 -> 0 bytes
 .../main/resources/keystores/client_truststore.jks |  Bin 1027 -> 0 bytes
 pom.xml                                            |    3 +-
 .../authentication-service-cpi.thrift              |    2 +-
 .../iam-admin-services-cpi.thrift                  |    6 +-
 .../profile-tenant/profile-tenant-cpi.thrift       |    4 +
 .../profile-user/profile-user-cpi.thrift           |    8 +-
 132 files changed, 10015 insertions(+), 1149 deletions(-)

diff --cc custos-commons/src/main/java/org/apache/custos/commons/utils/ServiceRequest.java
index 0000000,0000000..23e0061
new file mode 100644
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServiceRequest.java
@@@ -1,0 -1,0 +1,36 @@@
++package org.apache.custos.commons.utils;
++
++import com.fasterxml.jackson.databind.ObjectMapper;
++import org.apache.http.entity.ContentType;
++import org.apache.http.entity.StringEntity;
++import org.springframework.stereotype.Component;
++
++import java.io.BufferedReader;
++import java.io.InputStreamReader;
++import java.net.HttpURLConnection;
++import java.net.URL;
++import java.util.Map;
++
++@Component
++public class ServiceRequest {
++
++    public String httpGet(String baseUrl, String requestUrl) throws Exception{
++            StringBuilder result = new StringBuilder();
++            URL url = new URL(baseUrl + requestUrl);
++            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
++            conn.setRequestMethod("GET");
++            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
++            String line;
++            while ((line = rd.readLine()) != null) {
++                result.append(line);
++            }
++            rd.close();
++            return result.toString();
++    }
++
++    public void httpPost(String baseUrl, String requestUrl, Object jsonObject){
++//        ObjectMapper obj = new ObjectMapper();
++//        String postBodyString = obj.writeValueAsString(jsonObject);
++//        StringEntity requestEntity = new StringEntity(postBodyString, ContentType.APPLICATION_JSON);
++    }
++}
diff --cc custos-profile-service/README
index 0000000,0000000..9d83e76
new file mode 100644
--- /dev/null
+++ b/custos-profile-service/README
@@@ -1,0 -1,0 +1,3 @@@
++Custos Profile Service
++
++The thrift files associated with Profile services are in thrift-interfaces/profile-service folder
diff --cc custos-profile-service/group-profile-service/group-profile-api/pom.xml
index 0000000,0000000..1c5e69f
new file mode 100644
--- /dev/null
+++ b/custos-profile-service/group-profile-service/group-profile-api/pom.xml
@@@ -1,0 -1,0 +1,21 @@@
++<?xml version="1.0" encoding="UTF-8"?>
++<project xmlns="http://maven.apache.org/POM/4.0.0"
++         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
++         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
++    <parent>
++        <artifactId>group-profile-service</artifactId>
++        <groupId>org.apache.custos</groupId>
++        <version>1.0-SNAPSHOT</version>
++    </parent>
++    <modelVersion>4.0.0</modelVersion>
++
++    <artifactId>group-profile-api</artifactId>
++    <dependencies>
++        <dependency>
++            <groupId>org.apache.custos</groupId>
++            <artifactId>group-profile-core</artifactId>
++            <version>${project.version}</version>
++        </dependency>
++    </dependencies>
++
++</project>
diff --cc custos-profile-service/group-profile-service/group-profile-core/pom.xml
index 0000000,0000000..49575e0
new file mode 100644
--- /dev/null
+++ b/custos-profile-service/group-profile-service/group-profile-core/pom.xml
@@@ -1,0 -1,0 +1,22 @@@
++<?xml version="1.0" encoding="UTF-8"?>
++<project xmlns="http://maven.apache.org/POM/4.0.0"
++         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
++         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
++    <parent>
++        <artifactId>group-profile-service</artifactId>
++        <groupId>org.apache.custos</groupId>
++        <version>1.0-SNAPSHOT</version>
++    </parent>
++    <modelVersion>4.0.0</modelVersion>
++
++    <artifactId>group-profile-core</artifactId>
++    <dependencies>
++        <dependency>
++            <groupId>org.apache.custos</groupId>
++            <artifactId>user-profile-service</artifactId>
++            <version>${project.version}</version>
++        </dependency>
++    </dependencies>
++
++
++</project>
diff --cc custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/exceptions/GroupManagerServiceException.java
index 0000000,0000000..6de6312
new file mode 100644
--- /dev/null
+++ b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/exceptions/GroupManagerServiceException.java
@@@ -1,0 -1,0 +1,16 @@@
++package org.apache.custos.profile.service.core.exceptions;
++
++import org.springframework.http.HttpStatus;
++import org.springframework.web.bind.annotation.ResponseStatus;
++
++@ResponseStatus(value= HttpStatus.INTERNAL_SERVER_ERROR, reason = "Request cannot be completed due to server error")
++public class GroupManagerServiceException extends RuntimeException {
++
++    public GroupManagerServiceException(String errorMessage) {
++        super(errorMessage);
++    }
++
++    public GroupManagerServiceException(String errorMessage, Throwable err) {
++        super(errorMessage, err);
++    }
++}
diff --cc custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/models/GroupModel.java
index 0000000,0000000..c36d520
new file mode 100644
--- /dev/null
+++ b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/models/GroupModel.java
@@@ -1,0 -1,0 +1,73 @@@
++package org.apache.custos.profile.service.core.models;
++
++import java.util.List;
++
++public class GroupModel {
++    private String id;
++    private String name;
++    private String ownerId;
++    private String description;
++    private String gatewayId;
++    private List<String> members;
++    /**
++     * Note: each admin must also be a member of the group.
++     */
++    private List<String> admins;
++
++    public String getId() {
++        return id;
++    }
++
++    public void setId(String id) {
++        this.id = id;
++    }
++
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    public String getOwnerId() {
++        return ownerId;
++    }
++
++    public void setOwnerId(String ownerId) {
++        this.ownerId = ownerId;
++    }
++
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    public List<String> getMembers() {
++        return members;
++    }
++
++    public void setMembers(List<String> members) {
++        this.members = members;
++    }
++
++    public List<String> getAdmins() {
++        return admins;
++    }
++
++    public void setAdmins(List<String> admins) {
++        this.admins = admins;
++    }
++
++
++    public String getGatewayId() {
++        return gatewayId;
++    }
++
++    public void setGatewayId(String gatewayId) {
++        this.gatewayId = gatewayId;
++    }
++}
diff --cc custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java
index 0000000,0000000..f4843cd
new file mode 100644
--- /dev/null
+++ b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java
@@@ -1,0 -1,0 +1,390 @@@
++//package org.apache.custos.profile.service.core.service;
++//
++//import org.apache.custos.commons.utils.ServiceRequest;
++//import org.apache.custos.profile.user.core.repositories.UserProfileRepository;
++//import org.apache.custos.sharing.service.api.constants.SharingRegistryEndpoints;
++//import org.apache.custos.sharing.service.core.models.GroupCardinality;
++//import org.apache.custos.sharing.service.core.models.GroupType;
++//import org.apache.custos.sharing.service.core.models.UserGroup;
++//import org.apache.custos.profile.service.core.models.*;
++//import org.apache.custos.profile.service.core.exceptions.*;
++//import org.slf4j.Logger;
++//import org.slf4j.LoggerFactory;
++//import org.springframework.beans.factory.annotation.Autowired;
++//
++//import java.util.ArrayList;
++//import java.util.List;
++//import java.util.UUID;
++//import java.util.stream.Collectors;
++//
++//public class GroupProfileService {
++//
++//    @Autowired
++//    private static ServiceRequest serviceRequest;
++//
++//    @Autowired
++//    private static SharingRegistryEndpoints SharingRegistryEndpoints;
++//
++//    private static final Logger logger = LoggerFactory.getLogger(GroupProfileService.class);
++//    private static final String GROUP_MANAGER_CPI_VERSION = "1.0";
++//    private UserProfileRepository userProfileRepository = new UserProfileRepository();
++//    private static final String SHARING_SERVICE_BASE_URL = SharingRegistryEndpoints.BASE_URL;
++//
++//    public String getAPIVersion() {
++//        return GROUP_MANAGER_CPI_VERSION;
++//    }
++//
++//    public String createGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
++//        try {
++//
++//            UserGroup sharingUserGroup = new UserGroup();
++//            sharingUserGroup.setGroupId(UUID.randomUUID().toString());
++//            sharingUserGroup.setName(groupModel.getName());
++//            sharingUserGroup.setDescription(groupModel.getDescription());
++//            sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
++//            sharingUserGroup.setGroupCardinality(GroupCardinality.MULTI_USER);
++//            sharingUserGroup.setDomainId(gatewayId);
++//            sharingUserGroup.setOwnerId(userId);
++//
++//            String groupId = serviceRequest.httpPost(SHARING_SERVICE_BASE_URL, SharingRegistryEndpoints.CREATE_GROUP, );
++//            //TODO: should happen in one rest call
++//            //internalAddUsersToGroup(sharingClient, gatewayId, groupModel.getMembers(), groupId);
++//            //addGroupAdmins(authzToken,groupId,groupModel.getAdmins());
++//            return groupId;
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Creating Group" ;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    public boolean updateGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
++//        try {
++//            if (!(sharingClient.hasOwnerAccess(domainId, groupModel.getId(), userId)
++//                    || sharingClient.hasAdminAccess(domainId, groupModel.getId(), userId))) {
++//                throw new GroupManagerServiceException("User does not have permission to update group");
++//            }
++//
++//            UserGroup sharingUserGroup = new UserGroup();
++//            sharingUserGroup.setGroupId(groupModel.getId());
++//            sharingUserGroup.setName(groupModel.getName());
++//            sharingUserGroup.setDescription(groupModel.getDescription());
++//            sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
++//            sharingUserGroup.setDomainId(gatewayId);
++//
++//            //adding and removal of users should be handle separately??
++//            String response = serviceRequest.httpPut(SHARING_SERVICE_BASE_URL, SharingRegistryEndpoints.UPDATE_GROUP);
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Updating Group" ;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    public boolean deleteGroup(AuthzToken authzToken, String groupId, String ownerId) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try {
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            String userId = getUserId(authzToken);
++//            String domainId = getDomainId(authzToken);
++//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId))) {
++//                throw new GroupManagerServiceException("User does not have permission to delete group");
++//            }
++//
++//            sharingClient.deleteGroup(getDomainId(authzToken), groupId);
++//            return true;
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Deleting Group. Group ID: " + groupId ;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    @Override
++//    @SecurityCheck
++//    public GroupModel getGroup(AuthzToken authzToken, String groupId) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try {
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            final String domainId = getDomainId(authzToken);
++//            UserGroup userGroup = sharingClient.getGroup(domainId, groupId);
++//
++//            GroupModel groupModel = convertToGroupModel(userGroup, sharingClient);
++//
++//            return groupModel;
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Retreiving Group. Group ID: " + groupId ;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    @Override
++//    @SecurityCheck
++//    public List<GroupModel> getGroups(AuthzToken authzToken) throws GroupManagerServiceException, AuthorizationException, TException {
++//        final String domainId = getDomainId(authzToken);
++//        SharingRegistryService.Client sharingClient = null;
++//        try {
++//            sharingClient = getSharingRegistryServiceClient();
++//            List<UserGroup> userGroups = sharingClient.getGroups(domainId, 0, -1);
++//
++//            return convertToGroupModels(userGroups, sharingClient);
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Retrieving Groups. Domain ID: " + domainId;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        } finally {
++//            closeSharingClient(sharingClient);
++//        }
++//    }
++//
++//    @Override
++//    @SecurityCheck
++//    public List<GroupModel> getAllGroupsUserBelongs(AuthzToken authzToken, String userName) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try {
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            List<GroupModel> groupModels = new ArrayList<GroupModel>();
++//            final String domainId = getDomainId(authzToken);
++//            List<UserGroup> userGroups = sharingClient.getAllMemberGroupsForUser(domainId, userName);
++//
++//            return convertToGroupModels(userGroups, sharingClient);
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Retreiving All Groups for User. User ID: " + userName ;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    @Override
++//    public boolean addUsersToGroup(AuthzToken authzToken, List<String> userIds, String groupId) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try {
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            String userId = getUserId(authzToken);
++//            String domainId = getDomainId(authzToken);
++//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId)
++//                    || sharingClient.hasAdminAccess(domainId, groupId, userId))) {
++//                throw new GroupManagerServiceException("User does not have access to add users to the group");
++//            }
++//            return internalAddUsersToGroup(sharingClient, domainId, userIds, groupId);
++//
++//        } catch (Exception e) {
++//            String msg = "Error adding users to group. Group ID: " + groupId ;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    @Override
++//    public boolean removeUsersFromGroup(AuthzToken authzToken, List<String> userIds, String groupId) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try {
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            String userId = getUserId(authzToken);
++//            String domainId = getDomainId(authzToken);
++//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId)
++//                    || sharingClient.hasAdminAccess(domainId, groupId, userId))) {
++//                throw new GroupManagerServiceException("User does not have access to remove users to the group");
++//            }
++//            return sharingClient.removeUsersFromGroup(domainId, userIds, groupId);
++//        } catch (Exception e) {
++//            String msg = "Error remove users to group. Group ID: " + groupId ;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    @Override
++//    @SecurityCheck
++//    public boolean transferGroupOwnership(AuthzToken authzToken, String groupId, String newOwnerId) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try{
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            String userId = getUserId(authzToken);
++//            String domainId = getDomainId(authzToken);
++//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId))) {
++//                throw new GroupManagerServiceException("User does not have Owner permission to transfer group ownership");
++//            }
++//            return sharingClient.transferGroupOwnership(getDomainId(authzToken), groupId, newOwnerId);
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Transferring Group Ownership";
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//
++//    }
++//
++//    @Override
++//    @SecurityCheck
++//    public boolean addGroupAdmins(AuthzToken authzToken, String groupId, List<String> adminIds) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try {
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            String userId = getUserId(authzToken);
++//            String domainId = getDomainId(authzToken);
++//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId))) {
++//                throw new GroupManagerServiceException("User does not have Owner permission to add group admins");
++//            }
++//            return sharingClient.addGroupAdmins(getDomainId(authzToken), groupId, adminIds);
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Adding Admins to Group. Group ID: " + groupId;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    @Override
++//    @SecurityCheck
++//    public boolean removeGroupAdmins(AuthzToken authzToken, String groupId, List<String> adminIds) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try {
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            String userId = getUserId(authzToken);
++//            String domainId = getDomainId(authzToken);
++//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId))) {
++//                throw new GroupManagerServiceException("User does not have Owner permission to remove group admins");
++//            }
++//            return sharingClient.removeGroupAdmins(getDomainId(authzToken), groupId, adminIds);
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Removing Admins from the Group. Group ID: " + groupId;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    @Override
++//    @SecurityCheck
++//    public boolean hasAdminAccess(AuthzToken authzToken, String groupId, String adminId) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try {
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            return sharingClient.hasAdminAccess(getDomainId(authzToken), groupId, adminId);
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Checking Admin Access for the Group. Group ID: " + groupId + " Admin ID: " + adminId;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    @Override
++//    @SecurityCheck
++//    public boolean hasOwnerAccess(AuthzToken authzToken, String groupId, String ownerId) throws GroupManagerServiceException, AuthorizationException, TException {
++//        try {
++//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
++//            return sharingClient.hasOwnerAccess(getDomainId(authzToken), groupId, ownerId);
++//        }
++//        catch (Exception e) {
++//            String msg = "Error Checking Owner Access for the Group. Group ID: " + groupId + " Owner ID: " + ownerId;
++//            logger.error(msg, e);
++//            GroupManagerServiceException exception = new GroupManagerServiceException();
++//            exception.setMessage(msg + " More info : " + e.getMessage());
++//            throw exception;
++//        }
++//    }
++//
++//    // TODO: replace these methods with ThriftClientPool (see AIRAVATA-2607)
++//    private SharingRegistryService.Client getSharingRegistryServiceClient() throws TException, ApplicationSettingsException {
++//        final int serverPort = Integer.parseInt(ServerSettings.getSharingRegistryPort());
++//        final String serverHost = ServerSettings.getSharingRegistryHost();
++//        try {
++//            return SharingRegistryServiceClientFactory.createSharingRegistryClient(serverHost, serverPort);
++//        } catch (SharingRegistryException e) {
++//            throw new TException("Unable to create sharing registry client...", e);
++//        }
++//    }
++//
++//    private String getDomainId(AuthzToken authzToken) {
++//        return authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
++//    }
++//
++//    private String getUserId(AuthzToken authzToken) {
++//        return authzToken.getClaimsMap().get(Constants.USER_NAME) + "@" + getDomainId(authzToken);
++//    }
++//
++//    private List<GroupModel> convertToGroupModels(List<UserGroup> userGroups, SharingRegistryService.Client sharingClient) throws TException {
++//
++//        List<GroupModel> groupModels = new ArrayList<>();
++//
++//        for (UserGroup userGroup: userGroups) {
++//            GroupModel groupModel = convertToGroupModel(userGroup, sharingClient);
++//
++//            groupModels.add(groupModel);
++//        }
++//        return groupModels;
++//    }
++//
++//    private GroupModel convertToGroupModel(UserGroup userGroup, SharingRegistryService.Client sharingClient) throws TException {
++//        GroupModel groupModel = new GroupModel();
++//        groupModel.setId(userGroup.getGroupId());
++//        groupModel.setName(userGroup.getName());
++//        groupModel.setDescription(userGroup.getDescription());
++//        groupModel.setOwnerId(userGroup.getOwnerId());
++//        final List<String> admins = userGroup.getGroupAdmins().stream()
++//                .map(groupAdmin -> groupAdmin.getAdminId())
++//                .collect(Collectors.toList());
++//        groupModel.setAdmins(admins);
++//
++//        sharingClient.getGroupMembersOfTypeUser(userGroup.getDomainId(), userGroup.getGroupId(), 0, -1).stream().forEach(user->
++//                groupModel.addToMembers(user.getUserId())
++//        );
++//        return groupModel;
++//    }
++//
++//    private void closeSharingClient(SharingRegistryService.Client sharingClient) {
++//        if (sharingClient != null) {
++//            if (sharingClient.getInputProtocol().getTransport().isOpen()) {
++//                sharingClient.getInputProtocol().getTransport().close();
++//            }
++//            if (sharingClient.getOutputProtocol().getTransport().isOpen()) {
++//                sharingClient.getOutputProtocol().getTransport().close();
++//            }
++//        }
++//    }
++//
++//    private boolean internalAddUsersToGroup(SharingRegistryService.Client sharingClient, String domainId, List<String> userIds, String groupId) throws SharingRegistryException, TException {
++//
++//        // FIXME: workaround for UserProfiles that failed to sync to the sharing
++//        // registry: create any missing users in the sharing registry
++//        for (String userId : userIds) {
++//            if (!sharingClient.isUserExists(domainId, userId)) {
++//                User user = new User();
++//                user.setDomainId(domainId);
++//                user.setUserId(userId);
++//                UserProfile userProfile = userProfileRepository.get(userId);
++//                user.setUserName(userProfile.getUserId());
++//                user.setCreatedTime(userProfile.getCreationTime());
++//                user.setEmail(userProfile.getEmailsSize() > 0 ? userProfile.getEmails().get(0) : null);
++//                user.setFirstName(userProfile.getFirstName());
++//                user.setLastName(userProfile.getLastName());
++//                sharingClient.createUser(user);
++//            }
++//        }
++//        return sharingClient.addUsersToGroup(domainId, userIds, groupId);
++//    }
++//}
++//
++//}
diff --cc custos-profile-service/group-profile-service/pom.xml
index 0000000,0000000..7d58503
new file mode 100644
--- /dev/null
+++ b/custos-profile-service/group-profile-service/pom.xml
@@@ -1,0 -1,0 +1,20 @@@
++<?xml version="1.0" encoding="UTF-8"?>
++<project xmlns="http://maven.apache.org/POM/4.0.0"
++         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
++         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
++    <parent>
++        <artifactId>custos-profile-service</artifactId>
++        <groupId>org.apache.custos</groupId>
++        <version>1.0-SNAPSHOT</version>
++    </parent>
++    <modelVersion>4.0.0</modelVersion>
++
++    <artifactId>group-profile-service</artifactId>
++    <packaging>pom</packaging>
++    <modules>
++        <module>group-profile-api</module>
++        <module>group-profile-core</module>
++    </modules>
++
++
++</project>
diff --cc custos-sharing-registry-service/sharing-service-api/pom.xml
index 0000000,0000000..5811ff9
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/pom.xml
@@@ -1,0 -1,0 +1,23 @@@
++<?xml version="1.0" encoding="UTF-8"?>
++<project xmlns="http://maven.apache.org/POM/4.0.0"
++         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
++         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
++    <parent>
++        <artifactId>custos-sharing-registry-service</artifactId>
++        <groupId>org.apache.custos</groupId>
++        <version>1.0-SNAPSHOT</version>
++    </parent>
++    <modelVersion>4.0.0</modelVersion>
++
++    <artifactId>sharing-service-api</artifactId>
++    <dependencies>
++        <dependency>
++            <groupId>org.apache.custos</groupId>
++            <artifactId>sharing-service-core</artifactId>
++            <version>1.0-SNAPSHOT</version>
++            <scope>compile</scope>
++        </dependency>
++    </dependencies>
++
++
++</project>
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/AppConfig.java
index 0000000,0000000..ecc0943
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/AppConfig.java
@@@ -1,0 -1,0 +1,22 @@@
++package org.apache.custos.sharing.service.api;
++
++import org.apache.custos.commons.exceptions.ApplicationSettingsException;
++import org.apache.custos.sharing.service.core.db.utils.SharingRegistryDBInitConfig;
++import org.apache.custos.sharing.service.core.service.SharingRegistryService;
++import org.springframework.beans.factory.annotation.Autowired;
++import org.springframework.context.annotation.Bean;
++import org.springframework.context.annotation.Configuration;
++
++@Configuration
++public class AppConfig {
++    @Autowired
++    SharingRegistryDBInitConfig sharingRegistryDBInitConfig;
++    @Bean
++    public SharingRegistryDBInitConfig SharingRegistryDBInitConfigBeanMapper(){
++        return new SharingRegistryDBInitConfig();
++    }
++    @Bean
++    public SharingRegistryService SharingRegistryServiceBeanMapper() throws ApplicationSettingsException {
++        return new SharingRegistryService(sharingRegistryDBInitConfig);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/Application.java
index 0000000,0000000..ebdd989
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/Application.java
@@@ -1,0 -1,0 +1,32 @@@
++/*
++ *
++ * 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.custos.sharing.service.api;
++
++import org.springframework.boot.SpringApplication;
++import org.springframework.boot.autoconfigure.SpringBootApplication;
++import org.springframework.context.annotation.ComponentScan;
++
++@SpringBootApplication
++@ComponentScan(basePackages = {"org.apache.custos.sharing.service.api.controllers"})
++public class Application {
++    public static void main(String[] args){
++        SpringApplication.run(Application.class, args);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/constants/SharingRegistryEndpoints.java
index 0000000,0000000..27f1b8c
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/constants/SharingRegistryEndpoints.java
@@@ -1,0 -1,0 +1,22 @@@
++package org.apache.custos.sharing.service.api.constants;
++
++import org.apache.custos.commons.exceptions.ApplicationSettingsException;
++import org.apache.custos.commons.utils.ServerSettings;
++import org.springframework.stereotype.Component;
++
++@Component
++public class SharingRegistryEndpoints {
++
++    public String BASE_URL;
++
++    //group APIs
++    public String CREATE_GROUP = "/group";
++    public String UPDATE_GROUP = "/group";
++    public String IS_GROUP_EXISTS = "/group/exists/id/{groupId}/domain/{domainId}";
++    public String DELETE_GROUP = "/group/id/{groupId}/domain/{domainId}";
++    public String GET_GROUP = "/group/id/{groupId}/domain/{domainId}";
++
++    SharingRegistryEndpoints() throws ApplicationSettingsException {
++        BASE_URL = ServerSettings.getSharingRegistryServerHost() + ":" + ServerSettings.getSharingRegistryServerPort();
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/AccessController.java
index 0000000,0000000..238c8d0
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/AccessController.java
@@@ -1,0 -1,0 +1,71 @@@
++package org.apache.custos.sharing.service.api.controllers;
++
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.service.SharingRegistryService;
++import org.springframework.beans.factory.annotation.Autowired;
++import org.springframework.http.HttpStatus;
++import org.springframework.http.ResponseEntity;
++import org.springframework.web.bind.annotation.*;
++
++import java.util.Collections;
++import java.util.List;
++import java.util.Map;
++
++@RestController
++public class AccessController {
++
++    @Autowired
++    SharingRegistryService sharingRegistryService;
++
++    /**
++     <p>API method to share an entity with users</p>
++     */
++    @RequestMapping(value = "share/users/domain/{domainId}/entity/{entityId}/permissionType/{permissionTypeId}/cascadePermission/{cascadePermission}", method = RequestMethod.PUT)
++    public ResponseEntity<String> shareEntityWithUsers(@RequestBody List<String> userList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId, @PathVariable("cascadePermission") boolean cascadePermission){
++
++        boolean response = sharingRegistryService.shareEntityWithUsers(domainId, entityId, userList, permissionTypeId, cascadePermission);
++        if(response) return new ResponseEntity<>(HttpStatus.OK);
++        else throw new SharingRegistryException("Sharing entity with users failed");
++
++    }
++
++    /**
++     <p>API method to revoke sharing from a list of users</p>
++     */
++    @RequestMapping(value = "revoke/users/domain/{domainId}/entity/{entityId}/permissionType/{permissionTypeId}", method = RequestMethod.PUT)
++    public ResponseEntity<String> revokeEntitySharingFromUsers(@RequestBody List<String> userList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId){
++        boolean response = sharingRegistryService.revokeEntitySharingFromUsers(domainId, entityId, userList, permissionTypeId);
++        if(response) return new ResponseEntity<>(HttpStatus.OK);
++        else throw new SharingRegistryException("Revoking entity sharing with users failed");
++    }
++
++    /**
++     <p>API method to share an entity with list of groups</p>
++     */
++    @RequestMapping(value = "share/groups/domain/{domainId}/entity/{entityId}/permissionType/{permissionTypeId}/cascadePermission/{cascadePermission}", method = RequestMethod.PUT)
++    public ResponseEntity<String> shareEntityWithGroups(@RequestBody List<String> groupList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId, @PathVariable("cascadePermission") boolean cascadePermission){
++       boolean response = sharingRegistryService.shareEntityWithGroups(domainId,entityId, groupList, permissionTypeId, cascadePermission);
++        if(response) return new ResponseEntity<>(HttpStatus.OK);
++        else throw new SharingRegistryException("Sharing entity with groups failed");
++    }
++
++    /**
++     <p>API method to revoke sharing from list of users</p>
++     */
++    @RequestMapping(value = "revoke/groups/domain/{domainId}/entity/{entityId}/permissionType/{permissionTypeId}", method = RequestMethod.PUT)
++    public ResponseEntity<String> revokeEntitySharingFromGroups(@RequestBody List<String> groupList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId){
++        boolean response = sharingRegistryService.revokeEntitySharingFromGroups(domainId, entityId, groupList, permissionTypeId);
++        if(response) return new ResponseEntity<>(HttpStatus.OK);
++        else throw new SharingRegistryException("Revoking entity sharing with groups failed");
++    }
++
++    /**
++     <p>API method to check whether a user has access to a specific entity</p>
++     */
++    @RequestMapping(value = "hasaccess/domain/{domainId}/user/{userId}/entity/{entityId}/permissionType/{permissionTypeId}", method = RequestMethod.PUT)
++    public @ResponseBody
++    Map<String, Boolean> userHasAccess(@PathVariable("domainId") String domainId, @PathVariable("userId") String userId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId){
++        boolean response = sharingRegistryService.userHasAccess(domainId, userId, entityId, permissionTypeId);
++        return Collections.singletonMap("access", response);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java
index 0000000,0000000..ccfbd16
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java
@@@ -1,0 -1,0 +1,79 @@@
++package org.apache.custos.sharing.service.api.controllers;
++
++import org.apache.custos.sharing.service.core.models.Domain;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.service.SharingRegistryService;
++import org.springframework.beans.factory.annotation.Autowired;
++import org.springframework.http.HttpStatus;
++import org.springframework.http.ResponseEntity;
++import org.springframework.web.bind.annotation.*;
++
++import java.util.Collections;
++import java.util.List;
++import java.util.Map;
++
++@RestController
++@RequestMapping("/domain")
++public class DomainsController {
++
++    @Autowired
++    private static SharingRegistryService sharingRegistryService;
++
++    /**
++     <p>API method to create a new domain</p>
++     */
++    @RequestMapping(value = "/create", method= RequestMethod.POST)
++    public ResponseEntity<String> createDomain(@RequestBody Domain domain){
++        String domainId = sharingRegistryService.createDomain(domain);
++        if(domainId.equals(domain.getDomainId())) return new ResponseEntity<>(HttpStatus.OK);
++        else throw new SharingRegistryException("Domain creation failed");
++    }
++
++    /**
++     <p>API method to update a domain</p>
++     */
++    @RequestMapping(value = "/update", method = RequestMethod.PUT)
++    public ResponseEntity<String> updateDomain(@RequestBody Domain domain){
++        boolean response = sharingRegistryService.updateDomain(domain);
++        if(response) return new ResponseEntity<>(HttpStatus.OK);
++        else throw new SharingRegistryException("Domain update failed");
++    }
++
++    /**
++     <p>API method to check Domain Exists</p>
++     */
++    @RequestMapping(value = "/exists/{domainId}", method = RequestMethod.GET)
++    public @ResponseBody
++    Map<String, Boolean> isDomainExists(@PathVariable("domainId") String domainId) {
++        boolean response = sharingRegistryService.isDomainExists(domainId);
++        return Collections.singletonMap("exists", response);
++    }
++
++    /**
++     <p>API method to retrieve a domain</p>
++     */
++    @RequestMapping(value = "/{domainId}",method = RequestMethod.GET)
++    public ResponseEntity<Domain> getDomain(@PathVariable("domainId") String domainId){
++        Domain domain = sharingRegistryService.getDomain(domainId);
++        if(domain != null) return new ResponseEntity<>(domain, HttpStatus.OK);
++        else return new ResponseEntity<>(HttpStatus.NOT_FOUND);
++    }
++
++    /**
++     <p>API method to delete domain</p>
++     */
++    @RequestMapping(value = "/{domainId}", method = RequestMethod.DELETE)
++    public @ResponseBody Map<String, Boolean> deleteDomain(@PathVariable("domainId") String domainId){
++        boolean response = sharingRegistryService.deleteDomain(domainId);
++        return Collections.singletonMap("success", response);
++    }
++
++    /**
++     <p>API method to get all domain.</p>
++     */
++    @RequestMapping(value = "/offset/{offset}/limit/{limit}", method = RequestMethod.GET)
++    public @ResponseBody List<Domain> getDomains(@PathVariable("offset") int offset, @PathVariable("limit") int limit){
++        return sharingRegistryService.getDomains(offset, limit);
++    }
++
++}
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java
index 0000000,0000000..60fdc6a
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java
@@@ -1,0 -1,0 +1,117 @@@
++package org.apache.custos.sharing.service.api.controllers;
++
++import org.apache.custos.sharing.service.core.models.Entity;
++import org.apache.custos.sharing.service.core.models.SearchCriteria;
++import org.apache.custos.sharing.service.core.models.User;
++import org.apache.custos.sharing.service.core.models.UserGroup;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.service.SharingRegistryService;
++import org.springframework.beans.factory.annotation.Autowired;
++import org.springframework.http.HttpStatus;
++import org.springframework.http.ResponseEntity;
++import org.springframework.web.bind.annotation.*;
++
++import java.util.Collections;
++import java.util.List;
++import java.util.Map;
++
++@RestController
++@RequestMapping("/entity")
++public class EntityController {
++
++    @Autowired
++    private SharingRegistryService sharingRegistryService;
++
++    /**
++     <p>API method to register new entity</p>
++     */
++    @RequestMapping(value = "/create", method = RequestMethod.POST)
++    public ResponseEntity<String> createEntity(@RequestBody Entity entity){
++        String createdEntityId = sharingRegistryService.createEntity(entity);
++        if(createdEntityId.equals(entity.getEntityId())){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else throw new SharingRegistryException("Failed to create the entity");
++    }
++
++    /**
++     <p>API method to update entity</p>
++     */
++    @RequestMapping(value = "/update", method = RequestMethod.PUT)
++    public ResponseEntity<String> updateEntity(@RequestBody Entity entity){
++        boolean response = sharingRegistryService.updateEntity(entity);
++        if(response) return new ResponseEntity<>(HttpStatus.OK);
++        else throw new SharingRegistryException("Failed to update the entity");
++    }
++
++    /**
++     <p>API method to check Entity Exists</p>
++     */
++    @RequestMapping(value = "/exists/id/{entityId}/domain/{domainId}", method = RequestMethod.GET)
++    public @ResponseBody Map<String, Boolean> isEntityExists(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
++        boolean response = sharingRegistryService.isEntityExists(entityId, domainId);
++        return Collections.singletonMap("exists", response);
++    }
++
++    /**
++     <p>API method to delete entity</p>
++     */
++    @RequestMapping(value = "/id/{entityId}/domain/{domainId}", method = RequestMethod.DELETE)
++    public ResponseEntity<String> deleteEntity(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
++        boolean response = sharingRegistryService.deleteEntity(domainId, entityId);
++        if(response) return new ResponseEntity<>(HttpStatus.OK);
++        else throw new SharingRegistryException("Could not delete the entity");
++    }
++
++    /**
++     <p>API method to get entity</p>
++     */
++    @RequestMapping(value = "/id/{entityId}/domain/{domainId}", method = RequestMethod.GET)
++    public @ResponseBody Entity getEntity(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
++        Entity entity = sharingRegistryService.getEntity(domainId, entityId);
++        if(entity != null) return entity;
++        //TODO: not found exception should be thrown??
++        else throw new SharingRegistryException("Could not retrieve the entity");
++    }
++
++    /**
++     <p>API method to search entities</p>
++     */
++    @RequestMapping(value = "/search/domain/{domainId}/user/{userId}/offset/{offset}/limit/{limit}", method = RequestMethod.POST)
++    public @ResponseBody List<Entity> searchEntities(@RequestBody List<SearchCriteria> filters, @PathVariable("domainId") String domainId, @PathVariable("userId") String userId, @PathVariable("offset") int offset, @PathVariable("limit") int limit){
++        List<Entity> entities = sharingRegistryService.searchEntities(domainId, userId, filters, offset, limit);
++        return entities;
++    }
++
++    /**
++     <p>API method to get a list of shared users given the entity id</p>
++     */
++    @RequestMapping(value = "/sharedUsers/id/{entityId}/domain/{domainId}/permissionType/{permissionTypeId}", method = RequestMethod.GET)
++    public @ResponseBody List<User> getListOfSharedUsers(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId, @PathVariable("permissionTypeId") String permissionTypeId){
++        return sharingRegistryService.getListOfSharedUsers(domainId, entityId, permissionTypeId);
++    }
++
++    /**
++     <p>API method to get a list of shared users given the entity id where the sharing type is directly applied</p>
++     */
++    @RequestMapping(value = "/directlySharedUsers/id/{entityId}/domain/{domainId}/permissionType/{permissionTypeId}", method = RequestMethod.GET)
++    public @ResponseBody List<User> getListOfDirectlySharedUsers(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId, @PathVariable("permissionTypeId") String permissionTypeId){
++        return sharingRegistryService.getListOfDirectlySharedUsers(domainId, entityId, permissionTypeId);
++    }
++
++    /**
++     <p>API method to get a list of shared groups given the entity id</p>
++     */
++    @RequestMapping(value = "/sharedGroups/id/{entityId}/domain/{domainId}/permissionType/{permissionTypeId}", method = RequestMethod.GET)
++    public @ResponseBody List<UserGroup> getListOfSharedGroups(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId, @PathVariable("permissionTypeId") String permissionTypeId){
++        return sharingRegistryService.getListOfSharedGroups(domainId, entityId, permissionTypeId);
++    }
++
++    /**
++     <p>API method to get a list of directly shared groups given the entity id where the sharing type is directly applied</p>
++     */
++    @RequestMapping(value = "/directlySharedGroups/id/{entityId}/domain/{domainId}/permissionType/{permissionTypeId}", method = RequestMethod.GET)
++    public @ResponseBody List<UserGroup> getListOfDirectlySharedGroups(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId, @PathVariable("permissionTypeId") String permissionTypeId){
++        return sharingRegistryService.getListOfDirectlySharedGroups(domainId, entityId, permissionTypeId);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java
index 0000000,0000000..a806c38
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java
@@@ -1,0 -1,0 +1,95 @@@
++package org.apache.custos.sharing.service.api.controllers;
++
++import org.apache.custos.sharing.service.core.models.EntityType;
++import org.apache.custos.sharing.service.core.exceptions.ResourceNotFoundException;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.service.SharingRegistryService;
++import org.springframework.beans.factory.annotation.Autowired;
++import org.springframework.http.HttpStatus;
++import org.springframework.http.ResponseEntity;
++import org.springframework.web.bind.annotation.*;
++
++import java.util.Collections;
++import java.util.List;
++import java.util.Map;
++
++@RestController
++@RequestMapping("/entityType")
++public class EntityTypeController {
++
++    @Autowired
++    private static SharingRegistryService sharingRegistryService;
++    /**
++     <p>API method to create a new entity type</p>
++     */
++    @RequestMapping(value = "/create", method = RequestMethod.POST)
++    public ResponseEntity<String> createEntityType(@RequestBody EntityType entityType){
++        String createdEntityTypeId = sharingRegistryService.createEntityType(entityType);
++        if(createdEntityTypeId.equals(entityType.getEntityTypeId())){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to create the entity type");
++        }
++    }
++
++    /**
++     <p>API method to update entity type</p>
++     */
++    @RequestMapping(value = "/update", method = RequestMethod.PUT)
++    public ResponseEntity<String> updateEntityType(@RequestBody EntityType entityType){
++        boolean response = sharingRegistryService.updateEntityType(entityType);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to updated the entity type");
++        }
++    }
++
++    /**
++     <p>API method to check EntityType Exists</p>
++     */
++    @RequestMapping(value = "/exists/id/{entityTypeId/domain/{domainId}", method = RequestMethod.GET)
++    public @ResponseBody Map<String, Boolean> isEntityTypeExists(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
++        boolean response = sharingRegistryService.isEntityTypeExists(domainId, entityTypeId);
++        return Collections.singletonMap("exists", response);
++    }
++
++    /**
++     <p>API method to delete entity type</p>
++     */
++    @RequestMapping(value = "/id/{entityTypeId}/domain/{domainId}", method = RequestMethod.DELETE)
++    public ResponseEntity<String> deleteEntityType(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
++        boolean response = sharingRegistryService.deleteEntityType(domainId, entityTypeId);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to delete the entity type");
++        }
++    }
++
++    /**
++     <p>API method to get an entity type</p>
++     */
++    @RequestMapping(value = "/id/{entityTypeId}/domain/{domainId}", method = RequestMethod.GET)
++    public @ResponseBody EntityType getEntityType(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
++        EntityType entityType = sharingRegistryService.getEntityType(domainId, entityTypeId);
++        if(entityType != null){
++            return entityType;
++        }
++        else{
++            throw new ResourceNotFoundException("Could not find the entity type with entityTypeId: " + entityTypeId + " in domainId: "+ domainId);
++        }
++    }
++
++    /**
++     <p>API method to get entity types in a domainId.</p>
++     */
++    @RequestMapping(value = "/domain/{domainId}/offset/{offset}/limit/{limit}", method = RequestMethod.GET)
++    public @ResponseBody List<EntityType> getEntityTypes(@PathVariable("domainId") String domainId, @PathVariable("offset") int offset, @PathVariable("limit") int limit){
++       List<EntityType> entityTypes = sharingRegistryService.getEntityTypes(domainId, offset, limit);
++       return entityTypes;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java
index 0000000,0000000..0c1eced
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java
@@@ -1,0 -1,0 +1,244 @@@
++package org.apache.custos.sharing.service.api.controllers;
++
++import org.apache.custos.sharing.service.core.models.GroupAdmin;
++import org.apache.custos.sharing.service.core.models.User;
++import org.apache.custos.sharing.service.core.models.UserGroup;
++import org.apache.custos.sharing.service.core.exceptions.ResourceNotFoundException;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.service.SharingRegistryService;
++import org.springframework.beans.factory.annotation.Autowired;
++import org.springframework.http.HttpStatus;
++import org.springframework.http.ResponseEntity;
++import org.springframework.web.bind.annotation.*;
++
++import java.util.Collections;
++import java.util.List;
++import java.util.Map;
++
++@RestController
++public class GroupController {
++
++    @Autowired
++    private static SharingRegistryService sharingRegistryService;
++
++    /**
++     <p>API method to create a new group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups", method = RequestMethod.POST)
++    public ResponseEntity<String> createGroup(@RequestBody UserGroup group){
++        String createdGroupId = sharingRegistryService.createGroup(group);
++        if(createdGroupId.equals(group.getGroupId())){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }else{
++            throw new SharingRegistryException("Failed to create group");
++        }
++    }
++
++    /**
++     <p>API method to update a group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups", method = RequestMethod.PUT)
++    public ResponseEntity<String> updateGroup(@RequestBody UserGroup group){
++        boolean response = sharingRegistryService.updateGroup(group);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to update the group");
++        }
++    }
++
++    /**
++     <p>API method to check Group Exists</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}", method = RequestMethod.HEAD)
++    public ResponseEntity<String> isGroupExists(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId){
++        boolean response = sharingRegistryService.isGroupExists(domainId, groupId);
++        HttpStatus status = HttpStatus.NOT_FOUND;
++        if(response){
++            status = HttpStatus.OK;
++        }
++        return new ResponseEntity<>(status);
++    }
++
++    /**
++     <p>API method to delete a group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}", method = RequestMethod.DELETE)
++    public ResponseEntity<String> deleteGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId){
++        boolean response = sharingRegistryService.deleteGroup(domainId, groupId);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to delete the group");
++        }
++    }
++
++    /**
++     <p>API method to get a group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}", method = RequestMethod.GET)
++    public @ResponseBody UserGroup getGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId){
++        UserGroup userGroup = sharingRegistryService.getGroup(domainId,groupId);
++        if(userGroup != null){
++            return userGroup;
++        }else{
++            throw new ResourceNotFoundException("Could not find the user group with groupId: "+ groupId + " in domainId: "+ domainId);
++        }
++    }
++
++    /**
++     <p>API method to get groups in a domainId.</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups",method = RequestMethod.GET)
++    public @ResponseBody List<UserGroup> getGroups(@PathVariable("domainId") String domainId, @RequestParam int offset, @RequestParam int limit){
++        return sharingRegistryService.getGroups(domainId, offset, limit);
++    }
++
++    /**
++     <p>API method to add list of users to a group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/users", method = RequestMethod.POST)
++    public ResponseEntity<String> addUsersToGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId, @RequestBody List<String> userIds){
++        boolean response = sharingRegistryService.addUsersToGroup(domainId, userIds, groupId);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to add users to the group");
++        }
++    }
++
++    /**
++     <p>API method to remove users from a group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/users", method = RequestMethod.DELETE)
++    public ResponseEntity<String> removeUsersFromGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId, @RequestBody List<String> userIds){
++        boolean response = sharingRegistryService.removeUsersFromGroup(domainId, userIds, groupId);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to remove users from the group");
++        }
++    }
++
++    /**
++     <p>API method to transfer group ownership</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/owners/{ownerId}", method = RequestMethod.PUT)
++    public ResponseEntity<String> transferGroupOwnership(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @PathVariable("ownerId") String newOwnerId){
++        boolean response = sharingRegistryService.transferGroupOwnership(domainId,groupId, newOwnerId);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to change group owner");
++        }
++    }
++
++    /**
++     <p>API method to add Admin for a group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/admins", method = RequestMethod.POST)
++    public ResponseEntity<String> addGroupAdmins(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @RequestBody List<GroupAdmin> admins){
++        boolean response = sharingRegistryService.addGroupAdmins(domainId,groupId, admins);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to add group admins");
++        }
++    }
++
++    /**
++     <p>API method to remove Admin for a group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/admins", method = RequestMethod.DELETE)
++    public ResponseEntity<String> removeGroupAdmins(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @RequestBody List<String> adminIds){
++        boolean response = sharingRegistryService.removeGroupAdmins(domainId,groupId, adminIds);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }
++        else{
++            throw new SharingRegistryException("Failed to remove group admins");
++        }
++    }
++
++    /**
++     <p>API method to check whether the user has Admin access for the group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/admin/{adminId}", method = RequestMethod.HEAD)
++    public ResponseEntity<String> hasAdminAccess(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @PathVariable("adminId") String adminId){
++        boolean response = sharingRegistryService.hasAdminAccess(domainId, groupId, adminId);
++        HttpStatus status = HttpStatus.NOT_FOUND;
++        if(response){
++            status = HttpStatus.OK;
++        }
++        return new ResponseEntity<>(status);
++    }
++
++    /**
++     <p>API method to check whether the user has Owner access for the group</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/owner/{ownerId}", method = RequestMethod.HEAD)
++    public ResponseEntity<String> hasOwnerAccess(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
++        boolean response = sharingRegistryService.hasOwnerAccess(domainId, groupId, ownerId);
++        HttpStatus status = HttpStatus.NOT_FOUND;
++        if(response){
++            status = HttpStatus.OK;
++        }
++        return new ResponseEntity<>(status);
++    }
++
++    /**
++     <p>API method to get list of child users in a group. Only the direct members will be returned.</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/users", method = RequestMethod.GET)
++    public List<User> getGroupMembersOfTypeUser(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
++        return sharingRegistryService.getGroupMembersOfTypeUser(domainId, groupId, offset, limit);
++    }
++
++    /**
++     <p>API method to get list of child groups in a group. Only the direct members will be returned.</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/subgroups", method = RequestMethod.GET)
++    public List<UserGroup> getGroupMembersOfTypeGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
++        return sharingRegistryService.getGroupMembersOfTypeGroup(domainId, groupId, offset, limit);
++    }
++
++    /**
++     <p>API method to add a child group to a parent group.</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/subgroups", method = RequestMethod.POST)
++    public ResponseEntity<String> addChildGroupsToParentGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestBody List<String> childIds){
++        boolean response = sharingRegistryService.addChildGroupsToParentGroup(domainId, childIds, groupId);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }else{
++            throw new SharingRegistryException("Failed to add child groups to parent group");
++        }
++    }
++
++    /**
++     <p>API method to remove a child group from parent group.</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/subgroups", method = RequestMethod.DELETE)
++    public ResponseEntity<String> removeChildGroupFromParentGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @PathVariable("childGroupId") String childGroupId){
++        boolean response = sharingRegistryService.removeChildGroupFromParentGroup(domainId, childGroupId, groupId);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }else{
++            throw new SharingRegistryException("Failed to remove child groups from parent group");
++        }
++    }
++
++    /**
++     <p>API method to get all groups user is a member of.</p>
++     */
++    @RequestMapping(value = "/domains/{domainId}/users/{userId}/groups", method = RequestMethod.PUT)
++    public @ResponseBody List<UserGroup> getAllMemberGroupsForUser(@PathVariable("domainId") String domainId, @PathVariable("userId") String userId){
++        return sharingRegistryService.getAllMemberGroupsForUser(domainId, userId);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java
index 0000000,0000000..cfcf567
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java
@@@ -1,0 -1,0 +1,94 @@@
++package org.apache.custos.sharing.service.api.controllers;
++
++import org.apache.custos.sharing.service.core.models.PermissionType;
++import org.apache.custos.sharing.service.core.exceptions.ResourceNotFoundException;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.service.SharingRegistryService;
++import org.springframework.beans.factory.annotation.Autowired;
++import org.springframework.http.HttpStatus;
++import org.springframework.http.ResponseEntity;
++import org.springframework.web.bind.annotation.*;
++
++import java.util.Collections;
++import java.util.List;
++import java.util.Map;
++
++@RestController
++@RequestMapping("/permissionType")
++public class PermissionTypeController {
++
++    @Autowired
++    private static SharingRegistryService sharingRegistryService;
++    /**
++     <p>API method to create permission type</p>
++     */
++    @RequestMapping(value= "/create", method = RequestMethod.POST)
++    public ResponseEntity<String> createPermissionType(@RequestBody PermissionType permissionType){
++        String permissionTypeId = sharingRegistryService.createPermissionType(permissionType);
++        if(permissionTypeId.equals(permissionType.getPermissionTypeId())){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }else{
++            throw new SharingRegistryException("Could not create the permission type");
++        }
++    }
++
++    /**
++     <p>API method to update permission type</p>
++     */
++    @RequestMapping(value= "/update", method = RequestMethod.PUT)
++    public ResponseEntity<String> updatePermissionType(@RequestBody PermissionType permissionType){
++
++        boolean response = sharingRegistryService.updatePermissionType(permissionType);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }else{
++            throw new SharingRegistryException("Could not update the permission type");
++        }
++    }
++
++    /**
++     <p>API method to check Permission Exists</p>
++     */
++    @RequestMapping(value= "/exists/id/{permissionId}/domain/{domainId}", method = RequestMethod.GET)
++    public @ResponseBody
++    Map<String, Boolean> isPermissionExists(@PathVariable("permissionId") String permissionId, @PathVariable("domainId") String domainId){
++        boolean response = sharingRegistryService.isPermissionExists(domainId, permissionId);
++        return Collections.singletonMap("exists", response);
++    }
++
++    /**
++     <p>API method to delete permission type</p>
++     */
++    @RequestMapping(value= "/id/{permissionTypeId}/domain/{domainId}", method = RequestMethod.DELETE)
++    public ResponseEntity<String> deletePermissionType(@PathVariable("permissionTypeId") String permissionTypeId, @PathVariable("domainId") String domainId){
++        boolean response = sharingRegistryService.deletePermissionType(domainId,permissionTypeId);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }else{
++            throw new SharingRegistryException("Could not delete the permission type");
++        }
++    }
++
++    /**
++     <p>API method to get permission type</p>
++     */
++    @RequestMapping(value= "/id/{permissionTypeId}/domain/{domainId}", method = RequestMethod.GET)
++    public @ResponseBody PermissionType getPermissionType(@PathVariable("permissionTypeId") String permissionTypeId, @PathVariable("domainId") String domainId){
++        PermissionType permissionType = sharingRegistryService.getPermissionType(domainId, permissionTypeId);
++        if(permissionType != null){
++            return permissionType;
++        }else{
++            throw new ResourceNotFoundException("Could not find the permission type with permission Id: "+ permissionTypeId + " in domainId: " + domainId);
++        }
++    }
++
++    /**
++     <p>API method to get list of permission types in a given domainId.</p>
++     */
++    @RequestMapping(value= "/domain/{domainId}/offset/{offset}/limit/{limit}", method = RequestMethod.GET)
++    public @ResponseBody
++    List<PermissionType> getPermissionTypes(@PathVariable("domainId") String domainId, @PathVariable("offset") int offset, @PathVariable("limit") int limit){
++        return sharingRegistryService.getPermissionTypes(domainId, offset, limit);
++    }
++
++}
diff --cc custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java
index 0000000,0000000..00ef0a4
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java
@@@ -1,0 -1,0 +1,95 @@@
++package org.apache.custos.sharing.service.api.controllers;
++
++import org.apache.custos.sharing.service.core.models.User;
++import org.apache.custos.sharing.service.core.exceptions.ResourceNotFoundException;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.service.SharingRegistryService;
++import org.springframework.beans.factory.annotation.Autowired;
++import org.springframework.http.HttpStatus;
++import org.springframework.http.ResponseEntity;
++import org.springframework.web.bind.annotation.*;
++
++import java.util.Collections;
++import java.util.List;
++import java.util.Map;
++
++@RestController
++@RequestMapping("/user")
++public class UsersController {
++
++    @Autowired
++    private static SharingRegistryService sharingRegistryService;
++
++    /**
++     <p>API method to register a user in the system</p>
++     */
++    @RequestMapping(method = RequestMethod.POST)
++    public ResponseEntity<String> createUser(@RequestBody User user){
++        String userId = sharingRegistryService.createUser(user);
++        if(userId.equals(user.getUserId())){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }else{
++            throw new SharingRegistryException("Failed to create the user");
++        }
++    }
++
++    /**
++     <p>API method to update existing user</p>
++     */
++    @RequestMapping(method = RequestMethod.PUT)
++    public ResponseEntity<String> updateUser(@RequestBody User user){
++        boolean response = sharingRegistryService.updatedUser(user);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }else{
++            throw new SharingRegistryException("Failed to update the user");
++        }
++    }
++
++    /**
++     <p>API method to check User Exists</p>
++     */
++    @RequestMapping(value = "/exists/domainId/{domainId}/userId/{userId}", method = RequestMethod.GET)
++    public @ResponseBody
++    Map<String, Boolean> isUserExists(@PathVariable("domainId") String domainId, @PathVariable("userId") String userId){
++        boolean response = sharingRegistryService.isUserExists(domainId, userId);
++        return Collections.singletonMap("exists", response);
++    }
++
++    /**
++     <p>API method to delete user</p>
++     */
++    @RequestMapping(value="/id/{userId}/domain/{domainId}",method = RequestMethod.DELETE)
++    public ResponseEntity<String> deleteUser(@PathVariable("userId") String userId, @PathVariable("domainId") String domainId){
++        boolean response = sharingRegistryService.deleteUser(domainId, userId);
++        if(response){
++            return new ResponseEntity<>(HttpStatus.OK);
++        }else{
++            throw new SharingRegistryException("Failed to delete the user");
++        }
++    }
++
++    /**
++     <p>API method to get a user</p>
++     */
++    @RequestMapping(value = "/domain/{domainId}/user/{userId}", method = RequestMethod.GET)
++    public User getUser(@PathVariable("domainId") String domainId,@PathVariable("userId") String userId){
++        User user = sharingRegistryService.getUser(domainId, userId);
++        if(user != null){
++            return user;
++        }else {
++            throw new ResourceNotFoundException("Could not find the user with userId: "+ userId + " for domainId: "+ domainId);
++        }
++    }
++
++    /**
++     <p>API method to get a list of users in a specific domain.</p>
++     <li>domainId : Domain id</li>
++     <li>offset : Starting result number</li>
++     <li>limit : Number of max results to be sent</li>
++     */
++    @RequestMapping(value = "/domainId/{domainId}/offset/{offset}/limit/{limit}")
++    public List<User> getUsers(@PathVariable("domainId") String domainId, @PathVariable("offset") int offset, @PathVariable("limit") int limit){
++        return sharingRegistryService.getUsers(domainId,offset, limit);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/pom.xml
index 0000000,0000000..7922b89
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/pom.xml
@@@ -1,0 -1,0 +1,58 @@@
++<?xml version="1.0" encoding="UTF-8"?>
++<project xmlns="http://maven.apache.org/POM/4.0.0"
++         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
++         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
++    <parent>
++        <artifactId>custos-sharing-registry-service</artifactId>
++        <groupId>org.apache.custos</groupId>
++        <version>1.0-SNAPSHOT</version>
++    </parent>
++    <modelVersion>4.0.0</modelVersion>
++
++    <artifactId>sharing-service-core</artifactId>
++    <dependencies>
++        <dependency>
++            <groupId>org.slf4j</groupId>
++            <artifactId>slf4j-api</artifactId>
++            <version>1.7.10</version>
++        </dependency>
++        <dependency>
++            <groupId>net.sf.dozer</groupId>
++            <artifactId>dozer</artifactId>
++            <version>5.4.0</version>
++            <exclusions>
++                <exclusion>
++                    <groupId>org.slf4j</groupId>
++                    <artifactId>slf4j-log4j12</artifactId>
++                </exclusion>
++            </exclusions>
++        </dependency>
++        <dependency>
++            <groupId>org.apache.openjpa</groupId>
++            <artifactId>openjpa</artifactId>
++            <version>${openjpa.version}</version>
++        </dependency>
++        <dependency>
++            <groupId>mysql</groupId>
++            <artifactId>mysql-connector-java</artifactId>
++            <version>${mysql.connector.version}</version>
++        </dependency>
++        <dependency>
++            <groupId>org.databene</groupId>
++            <artifactId>contiperf</artifactId>
++            <version>2.3.4</version>
++        </dependency>
++        <dependency>
++            <groupId>org.apache.custos</groupId>
++            <artifactId>custos-commons</artifactId>
++            <version>${project.version}</version>
++        </dependency>
++        <dependency>
++            <groupId>junit</groupId>
++            <artifactId>junit</artifactId>
++            <version>${junit.version}</version>
++            <scope>test</scope>
++        </dependency>
++    </dependencies>
++
++</project>
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/DomainEntity.java
index 0000000,0000000..ad960a5
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/DomainEntity.java
@@@ -1,0 -1,0 +1,116 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.*;
++
++@Entity
++@Table(name = "DOMAIN", schema = "" )
++public class DomainEntity {
++    private final static Logger logger = LoggerFactory.getLogger(DomainEntity.class);
++    private String domainId;
++    private String name;
++    private String description;
++    private Long createdTime;
++    private Long updatedTime;
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Basic
++    @Column(name = "NAME")
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    @Basic
++    @Column(name = "DESCRIPTION")
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    @Basic
++    @Column(name = "CREATED_TIME")
++    public Long getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(Long createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    @Basic
++    @Column(name = "UPDATED_TIME")
++    public Long getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(Long updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        DomainEntity that = (DomainEntity) o;
++
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
++        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
++            return false;
++        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
++            return false;
++        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getDomainId() != null ? getDomainId().hashCode() : 0;
++        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
++        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
++        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
++        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/EntityEntity.java
index 0000000,0000000..9340c43
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/EntityEntity.java
@@@ -1,0 -1,0 +1,219 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.*;
++import java.nio.ByteBuffer;
++
++@Entity
++@Table(name = "ENTITY", schema = "")
++@IdClass(EntityPK.class)
++public class EntityEntity {
++    private final static Logger logger = LoggerFactory.getLogger(EntityEntity.class);
++    private String entityId;
++    private String domainId;
++    private String entityTypeId;
++    private String ownerId;
++    private String parentEntityId;
++    private String name;
++    private String description;
++    private ByteBuffer binaryData;
++    private String fullText;
++    private Long originalEntityCreationTime;
++    private Long sharedCount;
++    private Long createdTime;
++    private Long updatedTime;
++
++    @Id
++    @Column(name = "ENTITY_ID")
++    public String getEntityId() {
++        return entityId;
++    }
++
++    public void setEntityId(String entityId) {
++        this.entityId = entityId;
++    }
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Basic
++    @Column(name = "ENTITY_TYPE_ID")
++    public String getEntityTypeId() {
++        return entityTypeId;
++    }
++
++    public void setEntityTypeId(String entityTypeId) {
++        this.entityTypeId = entityTypeId;
++    }
++
++    @Basic
++    @Column(name = "OWNER_ID")
++    public String getOwnerId() {
++        return ownerId;
++    }
++
++    public void setOwnerId(String ownerId) {
++        this.ownerId = ownerId;
++    }
++
++    @Basic
++    @Column(name = "PARENT_ENTITY_ID")
++    public String getParentEntityId() {
++        return parentEntityId;
++    }
++
++    public void setParentEntityId(String parentEntityId) {
++        this.parentEntityId = parentEntityId;
++    }
++
++    @Basic
++    @Column(name = "NAME")
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    @Basic
++    @Column(name = "DESCRIPTION")
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    @Lob
++    @Column(name="BINARY_DATA")
++    public ByteBuffer getBinaryData() {
++        return binaryData;
++    }
++
++    public void setBinaryData(ByteBuffer binaryData) {
++        this.binaryData = binaryData;
++    }
++
++    @Basic
++    @Column(name = "FULL_TEXT")
++    public String getFullText() {
++        return fullText;
++    }
++
++    public void setFullText(String fullText) {
++        this.fullText = fullText;
++    }
++
++    @Basic
++    @Column(name = "ORIGINAL_ENTITY_CREATION_TIME")
++    public Long getOriginalEntityCreationTime() {
++        return originalEntityCreationTime;
++    }
++
++    public void setOriginalEntityCreationTime(Long originalEntityCreationTime) {
++        this.originalEntityCreationTime = originalEntityCreationTime;
++    }
++
++    @Basic
++    @Column(name = "SHARED_COUNT")
++    public Long getSharedCount() {
++        return sharedCount;
++    }
++
++    public void setSharedCount(Long sharedCount) {
++        this.sharedCount = sharedCount;
++    }
++
++    @Basic
++    @Column(name = "CREATED_TIME")
++    public Long getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(Long createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    @Basic
++    @Column(name = "UPDATED_TIME")
++    public Long getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(Long updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        EntityEntity that = (EntityEntity) o;
++
++        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
++            return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++        if (getParentEntityId() != null ? !getParentEntityId().equals(that.getParentEntityId()) : that.getParentEntityId() != null)
++            return false;
++        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
++        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
++            return false;
++        if (getBinaryData().equals(that.getBinaryData())) return false;
++        if (getFullText() != null ? !getFullText().equals(that.getFullText()) : that.getFullText() != null)
++            return false;
++        if (getOriginalEntityCreationTime() != null ? !getOriginalEntityCreationTime().equals(that.getOriginalEntityCreationTime())
++                : that.getOriginalEntityCreationTime() != null) return false;
++        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
++            return false;
++        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
++            return false;
++        if (getOwnerId() != null ? !getOwnerId().equals(that.getOwnerId()) : that.getOwnerId() != null) return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getEntityId() != null ? getEntityId().hashCode() : 0;
++        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
++        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
++        result = 31 * result + (getBinaryData() != null ? getBinaryData().hashCode() : 0);
++        result = 31 * result + (getFullText() != null ? getFullText().hashCode() : 0);
++        result = 31 * result + (getOriginalEntityCreationTime() != null ? getOriginalEntityCreationTime().hashCode() : 0);
++        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
++        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/EntityPK.java
index 0000000,0000000..f3badf0
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/EntityPK.java
@@@ -1,0 -1,0 +1,76 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.Column;
++import javax.persistence.Id;
++import java.io.Serializable;
++
++public class EntityPK implements Serializable {
++    private final static Logger logger = LoggerFactory.getLogger(EntityPK.class);
++    private String entityId;
++    private String domainId;
++
++
++    @Column(name = "ENTITY_ID")
++    @Id
++    public String getEntityId() {
++        return entityId;
++    }
++
++    public void setEntityId(String entityId) {
++        this.entityId = entityId;
++    }
++
++    @Column(name = "DOMAIN_ID")
++    @Id
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        EntityPK that = (EntityPK) o;
++
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getDomainId() != null ? getDomainId().hashCode() : 0;
++        result = 31 * result + (getEntityId() != null ? getEntityId().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/EntityTypeEntity.java
index 0000000,0000000..8412e9c
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/EntityTypeEntity.java
@@@ -1,0 -1,0 +1,130 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.*;
++
++@Entity
++@Table(name = "ENTITY_TYPE", schema = "")
++@IdClass(EntityTypePK.class)
++public class EntityTypeEntity {
++    private final static Logger logger = LoggerFactory.getLogger(EntityTypeEntity.class);
++    private String entityTypeId;
++    private String domainId;
++    private String name;
++    private String description;
++    private Long createdTime;
++    private Long updatedTime;
++
++    @Id
++    @Column(name = "ENTITY_TYPE_ID")
++    public String getEntityTypeId() {
++        return entityTypeId;
++    }
++
++    public void setEntityTypeId(String entityTypeId) {
++        this.entityTypeId = entityTypeId;
++    }
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Basic
++    @Column(name = "NAME")
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    @Basic
++    @Column(name = "DESCRIPTION")
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    @Basic
++    @Column(name = "CREATED_TIME")
++    public Long getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(Long createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    @Basic
++    @Column(name = "UPDATED_TIME")
++    public Long getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(Long updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        EntityTypeEntity that = (EntityTypeEntity) o;
++
++        if (getEntityTypeId() != null ? !getEntityTypeId().equals(that.getEntityTypeId()) : that.getEntityTypeId() != null)
++            return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
++        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
++            return false;
++        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
++            return false;
++        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getEntityTypeId() != null ? getEntityTypeId().hashCode() : 0;
++        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
++        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
++        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
++        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/EntityTypePK.java
index 0000000,0000000..bf92438
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/EntityTypePK.java
@@@ -1,0 -1,0 +1,76 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.Column;
++import javax.persistence.Id;
++import java.io.Serializable;
++
++public class EntityTypePK implements Serializable {
++    private final static Logger logger = LoggerFactory.getLogger(EntityTypePK.class);
++    private String entityTypeId;
++    private String domainId;
++
++
++    @Column(name = "ENTITY_TYPE_ID")
++    @Id
++    public String getEntityTypeId() {
++        return entityTypeId;
++    }
++
++    public void setEntityTypeId(String entityTypeId) {
++        this.entityTypeId = entityTypeId;
++    }
++
++    @Column(name = "DOMAIN_ID")
++    @Id
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        EntityTypePK that = (EntityTypePK) o;
++
++        if (getEntityTypeId() != null ? !getEntityTypeId().equals(that.getEntityTypeId()) : that.getEntityTypeId() != null)
++            return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getEntityTypeId() != null ? getEntityTypeId().hashCode() : 0;
++        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/GroupAdminEntity.java
index 0000000,0000000..cc0e1c7
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/GroupAdminEntity.java
@@@ -1,0 -1,0 +1,80 @@@
++package org.apache.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.*;
++
++@Entity
++@Table(name = "GROUP_ADMIN", schema = "")
++@IdClass(GroupAdminPK.class)
++public class GroupAdminEntity {
++    private final static Logger logger = LoggerFactory.getLogger(GroupAdminEntity.class);
++    private String groupId;
++    private String domainId;
++    private String adminId;
++    private UserGroupEntity userGroup;
++
++    @Id
++    @Column(name = "GROUP_ID")
++    public String getGroupId() {
++        return groupId;
++    }
++
++    public void setGroupId(String groupId) {
++        this.groupId = groupId;
++    }
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Id
++    @Column(name = "ADMIN_ID")
++    public String getAdminId() {
++        return adminId;
++    }
++
++    public void setAdminId(String adminId) {
++        this.adminId = adminId;
++    }
++
++    @ManyToOne(targetEntity = UserGroupEntity.class, cascade = CascadeType.MERGE)
++    @JoinColumns({
++            @JoinColumn(name="GROUP_ID", referencedColumnName="GROUP_ID"),
++            @JoinColumn(name="DOMAIN_ID", referencedColumnName="DOMAIN_ID")
++    })
++    public UserGroupEntity getUserGroup() {
++        return userGroup;
++    }
++
++    public void setUserGroup(UserGroupEntity userGroup) {
++        this.userGroup = userGroup;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        GroupAdminEntity that = (GroupAdminEntity) o;
++
++        if (!getGroupId().equals(that.getGroupId())) return false;
++        if (!getDomainId().equals(that.getDomainId())) return false;
++        return getAdminId().equals(that.getAdminId());
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getGroupId().hashCode();
++        result = 31 * result + getDomainId().hashCode();
++        result = 31 * result + getAdminId().hashCode();
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/GroupAdminPK.java
index 0000000,0000000..73e8ea2
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/GroupAdminPK.java
@@@ -1,0 -1,0 +1,66 @@@
++package org.apache.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.Column;
++import javax.persistence.Id;
++import java.io.Serializable;
++
++public class GroupAdminPK implements Serializable{
++
++    private final static Logger logger = LoggerFactory.getLogger(GroupAdminPK.class);
++    private String groupId;
++    private String domainId;
++    private String adminId;
++
++    @Id
++    @Column(name = "GROUP_ID")
++    public String getGroupId() {
++        return groupId;
++    }
++
++    public void setGroupId(String groupId) {
++        this.groupId = groupId;
++    }
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Id
++    @Column(name = "ADMIN_ID")
++    public String getAdminId() {
++        return adminId;
++    }
++
++    public void setAdminId(String adminId) {
++        this.adminId = adminId;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        GroupAdminPK groupAdminPK = (GroupAdminPK) o;
++
++        if (!getGroupId().equals(groupAdminPK.getGroupId())) return false;
++        if (!getDomainId().equals(groupAdminPK.getDomainId())) return false;
++        return getAdminId().equals(groupAdminPK.getAdminId());
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getGroupId().hashCode();
++        result = 31 * result + getDomainId().hashCode();
++        result = 31 * result + getAdminId().hashCode();
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/GroupMembershipEntity.java
index 0000000,0000000..a25b5d4
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/GroupMembershipEntity.java
@@@ -1,0 -1,0 +1,126 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.*;
++
++@Entity
++@Table(name = "GROUP_MEMBERSHIP", schema = "")
++@IdClass(GroupMembershipPK.class)
++public class GroupMembershipEntity {
++    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipEntity.class);
++    private String parentId;
++    private String childId;
++    private String childType;
++    private String domainId;
++    private Long createdTime;
++    private Long updatedTime;
++
++    @Id
++    @Column(name = "PARENT_ID")
++    public String getParentId() {
++        return parentId;
++    }
++
++    public void setParentId(String parentId) {
++        this.parentId = parentId;
++    }
++
++    @Id
++    @Column(name = "CHILD_ID")
++    public String getChildId() {
++        return childId;
++    }
++
++    public void setChildId(String childId) {
++        this.childId = childId;
++    }
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Basic
++    @Column(name = "CHILD_TYPE")
++    public String getChildType() {
++        return childType;
++    }
++
++    public void setChildType(String childType) {
++        this.childType = childType;
++    }
++
++    @Basic
++    @Column(name = "CREATED_TIME")
++    public Long getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(Long createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    @Basic
++    @Column(name = "UPDATED_TIME")
++    public Long getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(Long updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        GroupMembershipEntity that = (GroupMembershipEntity) o;
++
++        if (getParentId() != null ? !getParentId().equals(that.getParentId()) : that.getParentId() != null)
++            return false;
++        if (getChildId() != null ? !getChildId().equals(that.getChildId()) : that.getChildId() != null) return false;
++        if (getChildType() != null ? !getChildType().equals(that.getChildType()) : that.getChildType() != null)
++            return false;
++        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
++            return false;
++        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getParentId() != null ? getParentId().hashCode() : 0;
++        result = 31 * result + (getChildId() != null ? getChildId().hashCode() : 0);
++        result = 31 * result + (getChildType() != null ? getChildType().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/GroupMembershipPK.java
index 0000000,0000000..08a5e4f
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/GroupMembershipPK.java
@@@ -1,0 -1,0 +1,88 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.Column;
++import javax.persistence.Id;
++import java.io.Serializable;
++
++public class GroupMembershipPK implements Serializable {
++    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipPK.class);
++    private String parentId;
++    private String childId;
++    private String domainId;
++
++    @Column(name = "PARENT_ID")
++    @Id
++    public String getParentId() {
++        return parentId;
++    }
++
++    public void setParentId(String parentId) {
++        this.parentId = parentId;
++    }
++
++    @Column(name = "CHILD_ID")
++    @Id
++    public String getChildId() {
++        return childId;
++    }
++
++    public void setChildId(String childId) {
++        this.childId = childId;
++    }
++
++    @Column(name = "DOMAIN_ID")
++    @Id
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        GroupMembershipPK that = (GroupMembershipPK) o;
++
++        if (getParentId() != null ? !getParentId().equals(that.getParentId()) : that.getParentId() != null)
++            return false;
++        if (getChildId() != null ? !getChildId().equals(that.getChildId()) : that.getChildId() != null) return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getParentId() != null ? getParentId().hashCode() : 0;
++        result = 31 * result + (getChildId() != null ? getChildId().hashCode() : 0);
++        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/PermissionTypeEntity.java
index 0000000,0000000..9c8dfb3
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/PermissionTypeEntity.java
@@@ -1,0 -1,0 +1,128 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.*;
++
++@Entity
++@Table(name = "PERMISSION_TYPE", schema = "")
++@IdClass(PermissionTypePK.class)
++public class PermissionTypeEntity {
++    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeEntity.class);
++    private String permissionTypeId;
++    private String domainId;
++    private String name;
++    private String description;
++    private Long createdTime;
++    private Long updatedTime;
++
++    @Id
++    @Column(name = "PERMISSION_TYPE_ID")
++    public String getPermissionTypeId() {
++        return permissionTypeId;
++    }
++
++    public void setPermissionTypeId(String permissionTypeId) {
++        this.permissionTypeId = permissionTypeId;
++    }
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Basic
++    @Column(name = "NAME")
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++
++    @Basic
++    @Column(name = "DESCRIPTION")
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    @Basic
++    @Column(name = "CREATED_TIME")
++    public Long getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(Long createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    @Basic
++    @Column(name = "UPDATED_TIME")
++    public Long getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(Long updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        PermissionTypeEntity that = (PermissionTypeEntity) o;
++
++        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
++            return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
++        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
++            return false;
++        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
++        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
++        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
++        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/PermissionTypePK.java
index 0000000,0000000..1d3dda3
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/PermissionTypePK.java
@@@ -1,0 -1,0 +1,76 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.Column;
++import javax.persistence.Id;
++import java.io.Serializable;
++
++public class PermissionTypePK implements Serializable {
++    private final static Logger logger = LoggerFactory.getLogger(PermissionTypePK.class);
++    private String permissionTypeId;
++    private String domainId;
++
++
++    @Column(name = "PERMISSION_TYPE_ID")
++    @Id
++    public String getPermissionTypeId() {
++        return permissionTypeId;
++    }
++
++    public void setPermissionTypeId(String permissionTypeId) {
++        this.permissionTypeId = permissionTypeId;
++    }
++
++    @Column(name = "DOMAIN_ID")
++    @Id
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        PermissionTypePK that = (PermissionTypePK) o;
++
++        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
++            return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
++        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/SharingEntity.java
index 0000000,0000000..a48364b
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/SharingEntity.java
@@@ -1,0 -1,0 +1,149 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.*;
++
++@Entity
++@Table(name = "SHARING", schema = "")
++@IdClass(SharingPK.class)
++public class SharingEntity {
++    private final static Logger logger = LoggerFactory.getLogger(SharingEntity.class);
++    private String permissionTypeId;
++    private String entityId;
++    private String groupId;
++    private String domainId;
++    private String sharingType;
++    private String inheritedParentId;
++    private Long createdTime;
++    private Long updatedTime;
++
++    @Id
++    @Column(name = "PERMISSION_TYPE_ID")
++    public String getPermissionTypeId() {
++        return permissionTypeId;
++    }
++
++    public void setPermissionTypeId(String permissionTypeId) {
++        this.permissionTypeId = permissionTypeId;
++    }
++
++    @Id
++    @Column(name = "ENTITY_ID")
++    public String getEntityId() {
++        return entityId;
++    }
++
++    public void setEntityId(String entityId) {
++        this.entityId = entityId;
++    }
++
++    @Id
++    @Column(name = "GROUP_ID")
++    public String getGroupId() {
++        return groupId;
++    }
++
++    public void setGroupId(String groupId) {
++        this.groupId = groupId;
++    }
++
++
++    @Id
++    @Column(name = "INHERITED_PARENT_ID")
++    public String getInheritedParentId() {
++        return inheritedParentId;
++    }
++
++    public void setInheritedParentId(String inheritedParentId) {
++        this.inheritedParentId = inheritedParentId;
++    }
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Basic
++    @Column(name = "SHARING_TYPE")
++    public String getSharingType() {
++        return sharingType;
++    }
++
++    public void setSharingType(String sharingType) {
++        this.sharingType = sharingType;
++    }
++
++    @Basic
++    @Column(name = "CREATED_TIME")
++    public Long getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(Long createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    @Basic
++    @Column(name = "UPDATED_TIME")
++    public Long getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(Long updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        SharingEntity that = (SharingEntity) o;
++
++        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
++            return false;
++        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
++            return false;
++        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
++        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
++            return false;
++        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
++        result = 31 * result + (getEntityId() != null ? getEntityId().hashCode() : 0);
++        result = 31 * result + (getGroupId() != null ? getGroupId().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/SharingPK.java
index 0000000,0000000..85764bd
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/SharingPK.java
@@@ -1,0 -1,0 +1,116 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.Column;
++import javax.persistence.Id;
++import java.io.Serializable;
++
++public class SharingPK implements Serializable {
++    private final static Logger logger = LoggerFactory.getLogger(SharingPK.class);
++    private String permissionTypeId;
++    private String entityId;
++    private String groupId;
++    private String inheritedParentId;
++    private String domainId;
++
++    @Column(name = "PERMISSION_TYPE_ID")
++    @Id
++    public String getPermissionTypeId() {
++        return permissionTypeId;
++    }
++
++    public void setPermissionTypeId(String permissionTypeId) {
++        this.permissionTypeId = permissionTypeId;
++    }
++
++    @Column(name = "ENTITY_ID")
++    @Id
++    public String getEntityId() {
++        return entityId;
++    }
++
++    public void setEntityId(String entityId) {
++        this.entityId = entityId;
++    }
++
++    @Column(name = "GROUP_ID")
++    @Id
++    public String getGroupId() {
++        return groupId;
++    }
++
++    public void setGroupId(String groupId) {
++        this.groupId = groupId;
++    }
++
++    @Column(name = "INHERITED_PARENT_ID")
++    @Id
++    public String getInheritedParentId() {
++        return inheritedParentId;
++    }
++
++    public void setInheritedParentId(String inheritedParentId) {
++        this.inheritedParentId = inheritedParentId;
++    }
++
++    @Column(name = "DOMAIN_ID")
++    @Id
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        SharingPK that = (SharingPK) o;
++
++        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
++            return false;
++        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
++            return false;
++        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
++        if (getInheritedParentId() != null ? !getInheritedParentId().equals(that.getInheritedParentId()) : that.getInheritedParentId() != null)
++            return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
++        result = 31 * result + (getEntityId() != null ? getEntityId().hashCode() : 0);
++        result = 31 * result + (getGroupId() != null ? getGroupId().hashCode() : 0);
++        result = 31 * result + (getInheritedParentId() != null ? getInheritedParentId().hashCode() : 0);
++        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/UserEntity.java
index 0000000,0000000..fea6250
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/UserEntity.java
@@@ -1,0 -1,0 +1,161 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.*;
++import java.nio.ByteBuffer;
++
++@Entity
++@Table(name = "SHARING_USER", schema = "") // USER is a reserved term in derby
++@IdClass(UserPK.class)
++public class UserEntity {
++    private final static Logger logger = LoggerFactory.getLogger(UserEntity.class);
++    private String userId;
++    private String domainId;
++    private String userName;
++    private String firstName;
++    private String lastName;
++    private String email;
++    private ByteBuffer icon;
++    private Long createdTime;
++    private Long updatedTime;
++
++    @Id
++    @Column(name = "USER_ID")
++    public String getUserId() {
++        return userId;
++    }
++
++    public void setUserId(String userId) {
++        this.userId = userId;
++    }
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Basic
++    @Column(name = "USER_NAME")
++    public String getUserName() {
++        return userName;
++    }
++
++    public void setUserName(String userName) {
++        this.userName = userName;
++    }
++
++    @Basic
++    @Column(name = "FIRST_NAME")
++    public String getFirstName() {
++        return firstName;
++    }
++
++    public void setFirstName(String firstName) {
++        this.firstName = firstName;
++    }
++
++    @Basic
++    @Column(name = "LAST_NAME")
++    public String getLastName() {
++        return lastName;
++    }
++
++    public void setLastName(String lastName) {
++        this.lastName = lastName;
++    }
++
++    @Basic
++    @Column(name = "EMAIL")
++    public String getEmail() {
++        return email;
++    }
++
++    public void setEmail(String email) {
++        this.email = email;
++    }
++
++    @Lob
++    @Column(name = "ICON")
++    public ByteBuffer getIcon() {
++        return icon;
++    }
++
++    public void setIcon(ByteBuffer icon) {
++        this.icon = icon;
++    }
++
++    @Basic
++    @Column(name = "CREATED_TIME")
++    public Long getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(Long createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    @Basic
++    @Column(name = "UPDATED_TIME")
++    public Long getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(Long updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        UserEntity that = (UserEntity) o;
++
++        if (getUserId() != null ? !getUserId().equals(that.getUserId()) : that.getUserId() != null) return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++        if (getUserName() != null ? !getUserName().equals(that.getUserName()) : that.getUserName() != null)
++            return false;
++        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
++            return false;
++        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getUserId() != null ? getUserId().hashCode() : 0;
++        result = 31 * result + (getUserName() != null ? getUserName().hashCode() : 0);
++        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
++        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/UserGroupEntity.java
index 0000000,0000000..d3fe9bb
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/UserGroupEntity.java
@@@ -1,0 -1,0 +1,178 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.*;
++import java.util.List;
++
++@Entity
++@Table(name = "USER_GROUP", schema = "")
++@IdClass(UserGroupPK.class)
++public class UserGroupEntity {
++    private final static Logger logger = LoggerFactory.getLogger(UserGroupEntity.class);
++    private String groupId;
++    private String domainId;
++    private String name;
++    private String description;
++    private String ownerId;
++    private String groupType;
++    private String groupCardinality;
++    private Long createdTime;
++    private Long updatedTime;
++    private List<GroupAdminEntity> groupAdmins;
++
++    @Id
++    @Column(name = "GROUP_ID")
++    public String getGroupId() {
++        return groupId;
++    }
++
++    public void setGroupId(String groupId) {
++        this.groupId = groupId;
++    }
++
++    @Id
++    @Column(name = "DOMAIN_ID")
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Basic
++    @Column(name = "OWNER_ID")
++    public String getOwnerId() {
++        return ownerId;
++    }
++
++    public void setOwnerId(String ownerId) {
++        this.ownerId = ownerId;
++    }
++
++    @Basic
++    @Column(name = "NAME")
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    @Basic
++    @Column(name = "DESCRIPTION")
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    @Basic
++    @Column(name = "GROUP_CARDINALITY")
++    public String getGroupCardinality() {
++        return groupCardinality;
++    }
++
++    public void setGroupCardinality(String groupCardinality) {
++        this.groupCardinality = groupCardinality;
++    }
++
++    @Basic
++    @Column(name = "GROUP_TYPE")
++    public String getGroupType() {
++        return groupType;
++    }
++
++    public void setGroupType(String type) {
++        this.groupType = type;
++    }
++
++    @Basic
++    @Column(name = "CREATED_TIME")
++    public Long getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(Long createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    @Basic
++    @Column(name = "UPDATED_TIME")
++    public Long getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(Long updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++    @OneToMany(targetEntity = GroupAdminEntity.class, cascade = CascadeType.ALL,
++            mappedBy = "userGroup", fetch = FetchType.EAGER)
++    public List<GroupAdminEntity> getGroupAdmins() {
++        return groupAdmins;
++    }
++
++    public void setGroupAdmins(List<GroupAdminEntity> groupAdmins) {
++        this.groupAdmins = groupAdmins;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        UserGroupEntity that = (UserGroupEntity) o;
++
++        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++        if (getOwnerId() != null ? !getOwnerId().equals(that.getOwnerId()) : that.getOwnerId() != null) return false;
++        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
++        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
++            return false;
++        if (getGroupType() != null ? !getGroupType().equals(that.getGroupType()) : that.getGroupType() != null)
++            return false;
++        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
++            return false;
++        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getGroupId() != null ? getGroupId().hashCode() : 0;
++        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
++        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
++        result = 31 * result + (getGroupType() != null ? getGroupType().hashCode() : 0);
++        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
++        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/UserGroupPK.java
index 0000000,0000000..4395b1d
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/UserGroupPK.java
@@@ -1,0 -1,0 +1,75 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.Column;
++import javax.persistence.Id;
++import java.io.Serializable;
++
++public class UserGroupPK implements Serializable {
++    private final static Logger logger = LoggerFactory.getLogger(UserGroupPK.class);
++    private String groupId;
++    private String domainId;
++
++    @Column(name = "GROUP_ID")
++    @Id
++    public String getGroupId() {
++        return groupId;
++    }
++
++    public void setGroupId(String groupId) {
++        this.groupId = groupId;
++    }
++
++    @Column(name = "DOMAIN_ID")
++    @Id
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        UserGroupPK that = (UserGroupPK) o;
++
++        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null)
++            return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getGroupId() != null ? getGroupId().hashCode() : 0;
++        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/UserPK.java
index 0000000,0000000..a7c7090
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/UserPK.java
@@@ -1,0 -1,0 +1,75 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.entities;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.Column;
++import javax.persistence.Id;
++import java.io.Serializable;
++
++public class UserPK implements Serializable {
++    private final static Logger logger = LoggerFactory.getLogger(UserPK.class);
++    private String userId;
++    private String domainId;
++
++    @Column(name = "USER_ID")
++    @Id
++    public String getUserId() {
++        return userId;
++    }
++
++    public void setUserId(String userId) {
++        this.userId = userId;
++    }
++
++    @Column(name = "DOMAIN_ID")
++    @Id
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    @Override
++    public boolean equals(Object o) {
++        if (this == o) return true;
++        if (o == null || getClass() != o.getClass()) return false;
++
++        UserPK that = (UserPK) o;
++
++        if (getUserId() != null ? !getUserId().equals(that.getUserId()) : that.getUserId() != null)
++            return false;
++        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
++            return false;
++
++        return true;
++    }
++
++    @Override
++    public int hashCode() {
++        int result = getUserId() != null ? getUserId().hashCode() : 0;
++        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
++        return result;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/AbstractRepository.java
index 0000000,0000000..c70998b
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/AbstractRepository.java
@@@ -1,0 -1,0 +1,169 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.repositories;
++
++
++import org.apache.custos.sharing.service.core.db.utils.Committer;
++import org.apache.custos.sharing.service.core.db.utils.DBConstants;
++import org.apache.custos.sharing.service.core.db.utils.JPAUtils;
++import org.apache.custos.sharing.service.core.db.utils.ObjectMapperSingleton;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.dozer.Mapper;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.EntityManager;
++import javax.persistence.Query;
++import java.util.ArrayList;
++import java.util.List;
++import java.util.Map;
++
++public abstract class AbstractRepository<T, E, Id> {
++    private final static Logger logger = LoggerFactory.getLogger(AbstractRepository.class);
++
++    private Class<T> genericClass;
++    private Class<E> dbEntityGenericClass;
++
++    public AbstractRepository(Class<T> genericClass, Class<E> dbEntityGenericClass){
++        this.genericClass = genericClass;
++        this.dbEntityGenericClass = dbEntityGenericClass;
++    }
++
++    public T create(T t) throws SharingRegistryException {
++        return update(t);
++    }
++
++    //FIXME do a bulk insert
++    public List<T> create(List<T> tList) throws SharingRegistryException {
++        return update(tList);
++    }
++
++    public  T update(T t) throws SharingRegistryException {
++        Mapper mapper = ObjectMapperSingleton.getInstance();
++        E entity = mapper.map(t, dbEntityGenericClass);
++        E persistedCopy = execute(entityManager -> entityManager.merge(entity));
++        return mapper.map(persistedCopy, genericClass);
++    }
++
++    //FIXME do a bulk update
++    public  List<T> update(List<T> tList) throws SharingRegistryException {
++        List<T> returnList = new ArrayList<>();
++        for(T temp : tList)
++            returnList.add(update(temp));
++        return returnList;
++    }
++
++    public boolean delete(Id id) throws SharingRegistryException {
++        execute(entityManager -> {
++             E entity = entityManager.find(dbEntityGenericClass, id);
++             entityManager.remove(entity);
++             return entity;
++         });
++        return true;
++    }
++
++    public boolean delete(List<Id> idList) throws SharingRegistryException {
++        for(Id id : idList)
++            delete(id);
++        return true;
++    }
++
++    public T get(Id id) throws SharingRegistryException {
++        E entity = execute(entityManager -> entityManager
++                .find(dbEntityGenericClass, id));
++        Mapper mapper = ObjectMapperSingleton.getInstance();
++        if(entity == null)
++            return null;
++        return mapper.map(entity, genericClass);
++    }
++
++    public boolean isExists(Id id) throws SharingRegistryException {
++        return get(id) != null;
++    }
++
++    public List<T> get(List<Id> idList) throws SharingRegistryException {
++        List<T> returnList = new ArrayList<>();
++        for(Id id : idList)
++            returnList.add(get(id));
++        return returnList;
++    }
++
++    public List<T> select(Map<String, String> filters, int offset, int limit) throws SharingRegistryException {
++        String query = "SELECT DISTINCT p from " + dbEntityGenericClass.getSimpleName() + " as p";
++        ArrayList<String> parameters = new ArrayList<>();
++        int parameterCount = 1;
++        if (filters != null && filters.size() != 0) {
++            query += " WHERE ";
++            for (String k : filters.keySet()) {
++                query += "p." + k + " = ?" + parameterCount + " AND ";
++                parameters.add(filters.get(k));
++                parameterCount++;
++            }
++            query = query.substring(0, query.length() - 5);
++        }
++
++        query += " ORDER BY p.createdTime DESC";
++        String queryString = query;
++        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
++        List resultSet = execute(entityManager -> {
++            javax.persistence.Query q = entityManager.createQuery(queryString);
++            for (int i = 0; i < parameters.size(); i++) {
++                q.setParameter(i + 1, parameters.get(i));
++            }
++            return q.setFirstResult(offset).setMaxResults(newLimit).getResultList();
++        });
++        Mapper mapper = ObjectMapperSingleton.getInstance();
++        List<T> gatewayList = new ArrayList<>();
++        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, genericClass)));
++        return gatewayList;
++    }
++
++    public List<T> select(String queryString, Map<String,Object> queryParameters, int offset, int limit) throws SharingRegistryException {
++        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
++        List resultSet = execute(entityManager -> {
++            Query q =  entityManager.createQuery(queryString);
++            for(Map.Entry<String, Object> queryParam : queryParameters.entrySet()){
++                q.setParameter(queryParam.getKey(), queryParam.getValue());
++            }
++            return q.setFirstResult(offset).setMaxResults(newLimit).getResultList();
++        });
++        Mapper mapper = ObjectMapperSingleton.getInstance();
++        List<T> gatewayList = new ArrayList<>();
++        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, genericClass)));
++        return gatewayList;
++    }
++
++    public <R> R execute(Committer<EntityManager, R> committer) throws SharingRegistryException {
++        EntityManager entityManager = JPAUtils.getEntityManager();
++        try {
++            entityManager.getTransaction().begin();
++            R r = committer.commit(entityManager);
++            entityManager.getTransaction().commit();
++            return r;
++        } finally {
++            if (entityManager.isOpen()) {
++                if (entityManager.getTransaction().isActive()) {
++                    entityManager.getTransaction().rollback();
++                }
++                entityManager.close();
++            }
++        }
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/DomainRepository.java
index 0000000,0000000..6db47bb
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/DomainRepository.java
@@@ -1,0 -1,0 +1,33 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.repositories;
++
++import org.apache.custos.sharing.service.core.db.entities.DomainEntity;
++import org.apache.custos.sharing.service.core.models.Domain;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class DomainRepository extends AbstractRepository<Domain, DomainEntity, String> {
++    private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
++
++    public DomainRepository(){
++        super(Domain.class, DomainEntity.class);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/EntityRepository.java
index 0000000,0000000..2f16f60
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/EntityRepository.java
@@@ -1,0 -1,0 +1,180 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.repositories;
++
++import org.apache.custos.sharing.service.core.db.entities.EntityEntity;
++import org.apache.custos.sharing.service.core.db.entities.EntityPK;
++import org.apache.custos.sharing.service.core.db.utils.DBConstants;
++import org.apache.custos.sharing.service.core.db.utils.SharingRegistryJDBCConfig;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.models.Entity;
++import org.apache.custos.sharing.service.core.models.EntitySearchField;
++import org.apache.custos.sharing.service.core.models.SearchCondition;
++import org.apache.custos.sharing.service.core.models.SearchCriteria;
++
++import java.util.ArrayList;
++import java.util.HashMap;
++import java.util.List;
++import java.util.Map;
++
++public class EntityRepository extends AbstractRepository<Entity, EntityEntity, EntityPK> {
++
++    public EntityRepository() {
++        super(Entity.class, EntityEntity.class);
++    }
++
++    public List<Entity> getChildEntities(String domainId, String parentId) throws SharingRegistryException {
++        HashMap<String, String> filters = new HashMap<>();
++        filters.put(DBConstants.EntityTable.DOMAIN_ID, domainId);
++        filters.put(DBConstants.EntityTable.PARENT_ENTITY_ID, parentId);
++        return select(filters, 0, -1);
++    }
++
++    //TODO Replace with prepared statements
++    public List<Entity> searchEntities(String domainId, List<String> groupIds, List<SearchCriteria> filters,
++                                       int offset, int limit) throws SharingRegistryException {
++        String groupIdString = "'";
++        for(String groupId : groupIds)
++            groupIdString += groupId + "','";
++        groupIdString = groupIdString.substring(0, groupIdString.length()-2);
++
++        String query = "SELECT ENTITY.* FROM ENTITY WHERE ENTITY.ENTITY_ID IN (SELECT DISTINCT E.ENTITY_ID FROM ENTITY AS E INNER JOIN SHARING AS S ON (E.ENTITY_ID=S.ENTITY_ID AND E.DOMAIN_ID=S.DOMAIN_ID) WHERE " +
++                "E.DOMAIN_ID = '" + domainId + "' AND " + "S.GROUP_ID IN(" + groupIdString + ") AND ";
++
++        for(SearchCriteria searchCriteria : filters){
++            if(searchCriteria.getSearchField().equals(EntitySearchField.NAME)){
++                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
++                    query += "E.NAME != '" + searchCriteria.getValue() + "' AND ";
++                } else {
++                    query += "E.NAME LIKE '%" + searchCriteria.getValue() + "%' AND ";
++                }
++            }else if(searchCriteria.getSearchField().equals(EntitySearchField.DESCRIPTION)){
++                query += "E.DESCRIPTION LIKE '%" + searchCriteria.getValue() + "%' AND ";
++            }else if(searchCriteria.getSearchField().equals(EntitySearchField.PERMISSION_TYPE_ID)){
++                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
++                    query += "S.PERMISSION_TYPE_ID != '" + searchCriteria.getValue() + "' AND ";
++                } else {
++                    query += "S.PERMISSION_TYPE_ID IN ('" + searchCriteria.getValue() + "', '"
++                            + (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId) + "') AND ";
++                }
++            }else if(searchCriteria.getSearchField().equals(EntitySearchField.FULL_TEXT)){
++                if (new SharingRegistryJDBCConfig().getDriver().contains("derby")) {
++                    query += "E.FULL_TEXT LIKE '%" + searchCriteria.getValue() + "%' AND ";
++                } else {
++                    // FULL TEXT Search with Query Expansion
++                    String queryTerms = "";
++                    for (String word : searchCriteria.getValue().trim().replaceAll(" +", " ").split(" ")) {
++                        queryTerms += queryTerms + " +" + word;
++                    }
++                    queryTerms = queryTerms.trim();
++                    query += "MATCH(E.FULL_TEXT) AGAINST ('" + queryTerms + "' IN BOOLEAN MODE) AND ";
++                }
++            }else if(searchCriteria.getSearchField().equals(EntitySearchField.PARRENT_ENTITY_ID)){
++                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
++                    query += "E.PARENT_ENTITY_ID != '" + searchCriteria.getValue() + "' AND ";
++                } else {
++                    query += "E.PARENT_ENTITY_ID = '" + searchCriteria.getValue() + "' AND ";
++                }
++            }else if(searchCriteria.getSearchField().equals(EntitySearchField.OWNER_ID)){
++                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
++                    query += "E.OWNER_ID != '" + searchCriteria.getValue() + "' AND ";
++                } else {
++                    query += "E.OWNER_ID = '" + searchCriteria.getValue() + "' AND ";
++                }
++            } else if (searchCriteria.getSearchField().equals(EntitySearchField.ENTITY_TYPE_ID)) {
++                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
++                    query += "E.ENTITY_TYPE_ID != '" + searchCriteria.getValue() + "' AND ";
++                } else {
++                    query += "E.ENTITY_TYPE_ID = '" + searchCriteria.getValue() + "' AND ";
++                }
++            }else if(searchCriteria.getSearchField().equals(EntitySearchField.CREATED_TIME)){
++                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
++                    query += "E.CREATED_TIME >= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
++                }else{
++                    query += "E.CREATED_TIME <= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
++                }
++            }else if(searchCriteria.getSearchField().equals(EntitySearchField.UPDATED_TIME)){
++                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
++                    query += "E.UPDATED_TIME >= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
++                }else{
++                    query += "E.UPDATED_TIME <= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
++                }
++            } else if (searchCriteria.getSearchField().equals(EntitySearchField.SHARED_COUNT)) {
++                if (searchCriteria.getSearchCondition().equals(SearchCondition.GTE)) {
++                    query += "E.SHARED_COUNT >= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
++                } else {
++                    query += "E.SHARED_COUNT <= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
++                }
++            }
++        }
++
++        query = query.substring(0, query.length() - 5);
++        query += ") ORDER BY ENTITY.CREATED_TIME DESC";
++
++        final String nativeQuery = query;
++        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
++
++        List<Object[]> temp = execute(entityManager -> entityManager.createNativeQuery(nativeQuery).setFirstResult(offset)
++                .setMaxResults(newLimit).getResultList());
++        List<Entity> resultSet = new ArrayList<>();
++
++        HashMap<String, Object> keys = new HashMap<>();
++
++        temp.stream().forEach(rs->{
++            Entity entity = new Entity();
++            entity.setEntityId((String)(rs[0]));
++            entity.setDomainId((String) (rs[1]));
++            entity.setEntityTypeId((String) (rs[2]));
++            entity.setOwnerId((String) (rs[3]));
++            entity.setParentEntityId((String) (rs[4]));
++            entity.setName((String) (rs[5]));
++            entity.setDescription((String)(rs[6]));
++            entity.setBinaryData((byte[]) (rs[7]));
++            entity.setFullText((String) (rs[8]));
++            entity.setSharedCount((long) rs[9]);
++            entity.setOriginalEntityCreationTime((long) (rs[10]));
++            entity.setCreatedTime((long) (rs[11]));
++            entity.setUpdatedTime((long) (rs[12]));
++
++            //Removing duplicates. Another option is to change the query to remove duplicates.
++            if (!keys.containsKey(entity + domainId + "," + entity.getEntityId())) {
++                resultSet.add(entity);
++                keys.put(entity + domainId + "," + entity.getEntityId(), null);
++            }
++        });
++
++        return resultSet;
++    }
++
++    public String getSelectQuery(Map<String, String> filters){
++        String query = "SELECT p from " + EntityEntity.class.getSimpleName() + " as p";
++        if(filters != null && filters.size() != 0){
++            query += " WHERE ";
++            for(String k : filters.keySet()){
++                query += "p." + k + " = '" + filters.get(k) + "' AND ";
++            }
++            query = query.substring(0, query.length()-5);
++        }
++
++        query += " ORDER BY p."+DBConstants.EntityTable.ORIGINAL_ENTITY_CREATION_TIME+" DESC";
++
++        return query;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/EntityTypeRepository.java
index 0000000,0000000..0512f12
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/EntityTypeRepository.java
@@@ -1,0 -1,0 +1,34 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.repositories;
++
++import org.apache.custos.sharing.service.core.db.entities.EntityTypeEntity;
++import org.apache.custos.sharing.service.core.db.entities.EntityTypePK;
++import org.apache.custos.sharing.service.core.models.EntityType;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class EntityTypeRepository extends AbstractRepository<EntityType, EntityTypeEntity, EntityTypePK> {
++    private final static Logger logger = LoggerFactory.getLogger(EntityTypeRepository.class);
++
++    public EntityTypeRepository() {
++        super(EntityType.class, EntityTypeEntity.class);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/GroupAdminRepository.java
index 0000000,0000000..643378f
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/GroupAdminRepository.java
@@@ -1,0 -1,0 +1,17 @@@
++package org.apache.custos.sharing.service.core.db.repositories;
++
++import org.apache.custos.sharing.service.core.models.GroupAdmin;
++import org.apache.custos.sharing.service.core.db.entities.GroupAdminEntity;
++import org.apache.custos.sharing.service.core.db.entities.GroupAdminPK;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class GroupAdminRepository extends AbstractRepository<GroupAdmin, GroupAdminEntity, GroupAdminPK> {
++
++    private final static Logger logger = LoggerFactory.getLogger(GroupAdminRepository.class);
++
++    public GroupAdminRepository() {
++        super(GroupAdmin.class, GroupAdminEntity.class);
++    }
++
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/GroupMembershipRepository.java
index 0000000,0000000..b3cf11d
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/GroupMembershipRepository.java
@@@ -1,0 -1,0 +1,105 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.repositories;
++
++import org.apache.custos.sharing.service.core.models.*;
++import org.apache.custos.sharing.service.core.db.entities.GroupMembershipEntity;
++import org.apache.custos.sharing.service.core.db.entities.GroupMembershipPK;
++import org.apache.custos.sharing.service.core.db.entities.UserEntity;
++import org.apache.custos.sharing.service.core.db.entities.UserGroupEntity;
++import org.apache.custos.sharing.service.core.db.utils.DBConstants;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++
++import java.util.*;
++
++public class GroupMembershipRepository extends AbstractRepository<GroupMembership, GroupMembershipEntity, GroupMembershipPK> {
++
++    public GroupMembershipRepository() {
++        super(GroupMembership.class, GroupMembershipEntity.class);
++    }
++
++    public List<User> getAllChildUsers(String domainId, String groupId) throws SharingRegistryException {
++        String queryString = "SELECT DISTINCT U FROM " + UserEntity.class.getSimpleName() + " U, " + GroupMembershipEntity.class.getSimpleName()
++                + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = U." + DBConstants.UserTable.USER_ID + " AND " +
++                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = U." + DBConstants.UserTable.DOMAIN_ID + " AND " +
++                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + "=:" + DBConstants.GroupMembershipTable.DOMAIN_ID + " AND "+
++                "GM." + DBConstants.GroupMembershipTable.PARENT_ID + "=:" + DBConstants.GroupMembershipTable.PARENT_ID + " AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
++                + "=:" + DBConstants.GroupMembershipTable.CHILD_TYPE;
++        Map<String,Object> queryParameters = new HashMap<>();
++        queryParameters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
++        queryParameters.put(DBConstants.GroupMembershipTable.PARENT_ID, groupId);
++        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_TYPE, GroupChildType.USER.toString());
++        UserRepository userRepository = new UserRepository();
++        List<User> users = userRepository.select(queryString, queryParameters, 0, -1);
++        return users;
++    }
++
++    public List<UserGroup> getAllChildGroups(String domainId, String groupId) throws SharingRegistryException {
++        String queryString = "SELECT DISTINCT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName()
++                + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = G." + DBConstants.UserGroupTable.GROUP_ID + " AND " +
++                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = G." + DBConstants.UserGroupTable.DOMAIN_ID + " AND " +
++                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID+"=:"+DBConstants.GroupMembershipTable.DOMAIN_ID + " AND "+
++                "GM." + DBConstants.GroupMembershipTable.PARENT_ID+"=:"+DBConstants.GroupMembershipTable.PARENT_ID + " AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
++                + "=:" + DBConstants.GroupMembershipTable.CHILD_TYPE;
++        Map<String,Object> queryParameters = new HashMap<>();
++        queryParameters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
++        queryParameters.put(DBConstants.GroupMembershipTable.PARENT_ID, groupId);
++        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_TYPE, GroupChildType.GROUP.toString());
++        UserGroupRepository userGroupRepository = new UserGroupRepository();
++        List<UserGroup> groups = userGroupRepository.select(queryString, queryParameters,0, -1);
++        return groups;
++    }
++
++    public List<UserGroup> getAllMemberGroupsForUser(String domainId, String userId) throws SharingRegistryException {
++        String queryString = "SELECT DISTINCT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName()
++                + " GM WHERE GM." + DBConstants.GroupMembershipTable.PARENT_ID + " = G." + DBConstants.UserGroupTable.GROUP_ID + " AND " +
++                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = G." + DBConstants.UserGroupTable.DOMAIN_ID + " AND " +
++                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID+"=:"+DBConstants.GroupMembershipTable.DOMAIN_ID + " AND "+
++                "GM." + DBConstants.GroupMembershipTable.CHILD_ID+"=:"+DBConstants.GroupMembershipTable.CHILD_ID + " AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
++                + "=:" + DBConstants.GroupMembershipTable.CHILD_TYPE + " AND " +
++                "G." + DBConstants.UserGroupTable.GROUP_CARDINALITY + "=:" + DBConstants.UserGroupTable.GROUP_CARDINALITY;
++        Map<String,Object> queryParameters = new HashMap<>();
++        queryParameters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
++        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_ID, userId);
++        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_TYPE, GroupChildType.USER.toString());
++        queryParameters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.name());
++        UserGroupRepository userGroupRepository = new UserGroupRepository();
++        List<UserGroup> groups = userGroupRepository.select(queryString, queryParameters, 0, -1);
++        return groups;
++    }
++
++    public List<GroupMembership> getAllParentMembershipsForChild(String domainId, String childId) throws SharingRegistryException {
++        List<GroupMembership> finalParentGroups = new ArrayList<>();
++        Map<String, String> filters = new HashMap<>();
++        filters.put(DBConstants.GroupMembershipTable.CHILD_ID, childId);
++        filters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
++        LinkedList<GroupMembership> temp = new LinkedList<>();
++        select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
++        while (temp.size() > 0){
++            GroupMembership gm = temp.pop();
++            filters = new HashMap<>();
++            filters.put(DBConstants.GroupMembershipTable.CHILD_ID, gm.getParentId());
++            filters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
++            select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
++            finalParentGroups.add(gm);
++        }
++        return finalParentGroups;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/PermissionTypeRepository.java
index 0000000,0000000..d5a650e
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/PermissionTypeRepository.java
@@@ -1,0 -1,0 +1,52 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.repositories;
++
++import org.apache.custos.sharing.service.core.models.PermissionType;
++import org.apache.custos.sharing.service.core.db.entities.PermissionTypeEntity;
++import org.apache.custos.sharing.service.core.db.entities.PermissionTypePK;
++import org.apache.custos.sharing.service.core.db.utils.DBConstants;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.service.SharingRegistryService;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import java.util.HashMap;
++import java.util.List;
++
++public class PermissionTypeRepository extends AbstractRepository<PermissionType, PermissionTypeEntity, PermissionTypePK> {
++    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeRepository.class);
++
++    public PermissionTypeRepository() {
++        super(PermissionType.class, PermissionTypeEntity.class);
++    }
++
++    public String getOwnerPermissionTypeIdForDomain(String domainId) throws SharingRegistryException {
++        HashMap<String, String> filters = new HashMap<>();
++        filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domainId);
++        filters.put(DBConstants.PermissionTypeTable.NAME, SharingRegistryService.OWNER_PERMISSION_NAME);
++        List<PermissionType> permissionTypeList = select(filters, 0, -1);
++        if(permissionTypeList.size() != 1){
++            throw new SharingRegistryException("GLOBAL Permission inconsistency. Found " + permissionTypeList.size()
++                    + " records with " + SharingRegistryService.OWNER_PERMISSION_NAME + " name");
++        }
++        return permissionTypeList.get(0).getPermissionTypeId();
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/SharingRepository.java
index 0000000,0000000..bd32d25
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/SharingRepository.java
@@@ -1,0 -1,0 +1,114 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.repositories;
++
++import org.apache.custos.sharing.service.core.models.Sharing;
++import org.apache.custos.sharing.service.core.models.SharingType;
++import org.apache.custos.sharing.service.core.db.entities.SharingEntity;
++import org.apache.custos.sharing.service.core.db.entities.SharingPK;
++import org.apache.custos.sharing.service.core.db.utils.DBConstants;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import javax.persistence.Query;
++import java.util.HashMap;
++import java.util.List;
++import java.util.Map;
++
++public class SharingRepository extends AbstractRepository<Sharing, SharingEntity, SharingPK> {
++    private final static Logger logger = LoggerFactory.getLogger(SharingRepository.class);
++
++    public SharingRepository() {
++        super(Sharing.class, SharingEntity.class);
++    }
++
++    public List<Sharing> getIndirectSharedChildren(String domainId, String parentId, String permissionTypeId) throws SharingRegistryException {
++        HashMap<String, String> filters = new HashMap<>();
++        filters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
++        filters.put(DBConstants.SharingTable.INHERITED_PARENT_ID, parentId);
++        filters.put(DBConstants.SharingTable.SHARING_TYPE, SharingType.INDIRECT_CASCADING.toString());
++        filters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
++
++        return select(filters, 0, -1);
++    }
++
++    public List<Sharing> getCascadingPermissionsForEntity(String domainId, String entityId) throws SharingRegistryException {
++        String query = "SELECT DISTINCT p from " + SharingEntity.class.getSimpleName() + " as p";
++        query += " WHERE ";
++        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
++        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
++        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " IN('" + SharingType.DIRECT_CASCADING.toString()
++                + "', '" + SharingType.INDIRECT_CASCADING + "') ";
++        query += " ORDER BY p.createdTime DESC";
++        Map<String,Object> queryParameters = new HashMap<>();
++        queryParameters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
++        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
++        return select(query, queryParameters, 0, -1);
++    }
++
++    public boolean hasAccess(String domainId, String entityId, List<String> groupIds, List<String> permissionTypeIds) throws SharingRegistryException {
++        Map<String,Object> queryParameters = new HashMap<>();
++        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
++        query += " WHERE ";
++        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
++        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
++        queryParameters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
++        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
++        query += "p." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " IN :" + DBConstants.SharingTable.PERMISSION_TYPE_ID + " AND ";
++        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeIds);
++        query += "p." + DBConstants.SharingTable.GROUP_ID + " IN :" + DBConstants.SharingTable.GROUP_ID + " ";
++        queryParameters.put(DBConstants.SharingTable.GROUP_ID, groupIds);
++        query += " ORDER BY p.createdTime DESC";
++        return select(query, queryParameters, 0, -1).size() > 0;
++    }
++
++    public int getSharedCount(String domainId, String entityId) throws SharingRegistryException {
++        Map<String,Object> queryParameters = new HashMap<>();
++        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
++        query += " WHERE ";
++        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
++        queryParameters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
++        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
++        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
++        String permissionTypeIdString = (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId);
++        query += "p." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " <> :" + DBConstants.SharingTable.PERMISSION_TYPE_ID + " AND ";
++        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeIdString);
++        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " <> :" + DBConstants.SharingTable.SHARING_TYPE;
++        queryParameters.put(DBConstants.SharingTable.SHARING_TYPE, SharingType.INDIRECT_CASCADING.toString());
++        return select(query, queryParameters, 0, -1).size();
++    }
++
++    public void removeAllIndirectCascadingPermissionsForEntity(String domainId, String entityId) throws SharingRegistryException {
++        String query = "DELETE from " + SharingEntity.class.getSimpleName() + " as p";
++        query += " WHERE ";
++        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
++        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
++        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " = '" + SharingType.INDIRECT_CASCADING.toString() + "' ";
++        final String finalQuery = query;
++        execute(em -> {
++            Query q = em.createQuery(finalQuery);
++            q.setParameter(DBConstants.SharingTable.DOMAIN_ID, domainId);
++            q.setParameter(DBConstants.SharingTable.ENTITY_ID, entityId);
++            q.executeUpdate();
++            return true;
++        });
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/UserGroupRepository.java
index 0000000,0000000..a581df4
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/UserGroupRepository.java
@@@ -1,0 -1,0 +1,95 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.repositories;
++
++import org.apache.custos.sharing.service.core.models.GroupCardinality;
++import org.apache.custos.sharing.service.core.models.SharingType;
++import org.apache.custos.sharing.service.core.models.UserGroup;
++import org.apache.custos.sharing.service.core.db.entities.SharingEntity;
++import org.apache.custos.sharing.service.core.db.entities.UserGroupEntity;
++import org.apache.custos.sharing.service.core.db.entities.UserGroupPK;
++import org.apache.custos.sharing.service.core.db.utils.DBConstants;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import java.util.Arrays;
++import java.util.HashMap;
++import java.util.List;
++import java.util.Map;
++import java.util.stream.Collectors;
++
++public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroupEntity, UserGroupPK> {
++    private final static Logger logger = LoggerFactory.getLogger(UserGroupRepository.class);
++
++    public UserGroupRepository() {
++        super(UserGroup.class, UserGroupEntity.class);
++    }
++
++    public List<UserGroup> getAccessibleGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
++        return getAccessibleGroupsInternal(domainId, entityId, permissionTypeId);
++    }
++
++    public List<UserGroup> getDirectlyAccessibleGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
++        return getAccessibleGroupsInternal(domainId, entityId, permissionTypeId, SharingType.DIRECT_CASCADING, SharingType.DIRECT_NON_CASCADING);
++    }
++
++    private List<UserGroup> getAccessibleGroupsInternal(String domainId, String entityId, String permissionTypeId, SharingType... sharingTypes) throws SharingRegistryException {
++        String query = "SELECT DISTINCT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
++        query += " WHERE ";
++        query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
++        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
++        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = :" + DBConstants.UserGroupTable.DOMAIN_ID + " AND ";
++        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
++        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = :" + DBConstants.SharingTable.PERMISSION_TYPE_ID + " AND ";
++        query += "g." + DBConstants.UserGroupTable.GROUP_CARDINALITY + " = :" + DBConstants.UserGroupTable.GROUP_CARDINALITY;
++        if (!Arrays.asList(sharingTypes).isEmpty()) {
++            query += " AND s." + DBConstants.SharingTable.SHARING_TYPE + " IN :" + DBConstants.SharingTable.SHARING_TYPE;
++        }
++        query += " ORDER BY s.createdTime DESC";
++        Map<String,Object> queryParameters = new HashMap<>();
++        queryParameters.put(DBConstants.UserGroupTable.DOMAIN_ID, domainId);
++        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
++        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
++        queryParameters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.toString());
++        if (!Arrays.asList(sharingTypes).isEmpty()) {
++            queryParameters.put(DBConstants.SharingTable.SHARING_TYPE, Arrays.asList(sharingTypes).stream().map(s -> s.name()).collect(Collectors.toList()));
++        }
++        return select(query, queryParameters, 0, -1);
++    }
++
++    //checks whether is shared with any user or group with any permission
++    public boolean isShared(String domainId, String entityId) throws SharingRegistryException {
++        String query = "SELECT DISTINCT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
++        query += " WHERE ";
++        query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
++        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
++        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = :" + DBConstants.UserGroupTable.DOMAIN_ID + " AND ";
++        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
++        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " <> :" + DBConstants.SharingTable.PERMISSION_TYPE_ID;
++        query += " ORDER BY s.createdTime DESC";
++        Map<String,Object> queryParameters = new HashMap<>();
++        queryParameters.put(DBConstants.UserGroupTable.DOMAIN_ID, domainId);
++        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
++        String ownerPermissionTypeIdForDomain = (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId);
++        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, ownerPermissionTypeIdForDomain);
++        return select(query, queryParameters, 0, -1).size() != 0;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/UserRepository.java
index 0000000,0000000..f4ff512
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/UserRepository.java
@@@ -1,0 -1,0 +1,79 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.repositories;
++
++import org.apache.custos.sharing.service.core.db.entities.SharingEntity;
++import org.apache.custos.sharing.service.core.db.entities.UserEntity;
++import org.apache.custos.sharing.service.core.db.entities.UserPK;
++import org.apache.custos.sharing.service.core.db.utils.DBConstants;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.custos.sharing.service.core.models.SharingType;
++import org.apache.custos.sharing.service.core.models.User;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++import java.util.Arrays;
++import java.util.HashMap;
++import java.util.List;
++import java.util.Map;
++import java.util.stream.Collectors;
++
++public class UserRepository extends AbstractRepository<User, UserEntity, UserPK> {
++    private final static Logger logger = LoggerFactory.getLogger(UserRepository.class);
++
++    public UserRepository() {
++        super(User.class, UserEntity.class);
++    }
++
++
++    public List<User> getAccessibleUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
++        if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
++            return getAccessibleUsersInternal(domainId, entityId, permissionTypeId, SharingType.DIRECT_CASCADING, SharingType.DIRECT_NON_CASCADING);
++        } else {
++            return getAccessibleUsersInternal(domainId, entityId, permissionTypeId);
++        }
++    }
++
++    public List<User> getDirectlyAccessibleUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
++        return getAccessibleUsersInternal(domainId, entityId, permissionTypeId, SharingType.DIRECT_CASCADING, SharingType.DIRECT_NON_CASCADING);
++    }
++
++    private List<User> getAccessibleUsersInternal(String domainId, String entityId, String permissionTypeId, SharingType... sharingTypes) throws SharingRegistryException {
++        Map<String,Object> queryParameters = new HashMap<>();
++        String query = "SELECT DISTINCT u from " + UserEntity.class.getSimpleName() + " u, " + SharingEntity.class.getSimpleName() + " s";
++        query += " WHERE ";
++        query += "u." + DBConstants.UserTable.USER_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
++        query += "u." + DBConstants.UserTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
++        query += "u." + DBConstants.UserTable.DOMAIN_ID + " = :" + DBConstants.UserTable.DOMAIN_ID + " AND ";
++        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
++        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = :" + DBConstants.SharingTable.PERMISSION_TYPE_ID;
++        queryParameters.put(DBConstants.UserTable.DOMAIN_ID, domainId);
++        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
++        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
++
++        if (!Arrays.asList(sharingTypes).isEmpty()) {
++            query += " AND s." + DBConstants.SharingTable.SHARING_TYPE + " IN :" + DBConstants.SharingTable.SHARING_TYPE;
++            queryParameters.put(DBConstants.SharingTable.SHARING_TYPE, Arrays.asList(sharingTypes).stream().map(s -> s.name()).collect(Collectors.toList()));
++        }
++
++        query += " ORDER BY s.createdTime DESC";
++        return select(query, queryParameters,0, -1);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/Committer.java
index 0000000,0000000..0f20997
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/Committer.java
@@@ -1,0 -1,0 +1,26 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.utils;
++
++@FunctionalInterface
++public interface Committer<T, R>  {
++
++    R commit(T t);
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/DBConstants.java
index 0000000,0000000..d57c5c8
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/DBConstants.java
@@@ -1,0 -1,0 +1,106 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.utils;
++
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class DBConstants {
++    private final static Logger logger = LoggerFactory.getLogger(DBConstants.class);
++
++    public static int SELECT_MAX_ROWS = 1000;
++
++    public static class DomainTable {
++        public static final String DOMAIN_ID = "domainId";
++        public static final String NAME = "name";
++        public static final String DESCRIPTION = "description";
++        public static final String CREATED_TIME = "createdTime";
++        public static final String UPDATED_TIME = "updatedTime";
++    }
++
++    public static class UserTable {
++        public static final String USER_ID = "userId";
++        public static final String DOMAIN_ID = "domainId";
++        public static final String USER_NAME = "userName";
++        public static final String CREATED_TIME = "createdTime";
++        public static final String UPDATED_TIME = "updatedTime";
++    }
++
++    public static class UserGroupTable {
++        public static final String GROUP_ID = "groupId";
++        public static final String DOMAIN_ID = "domainId";
++        public static final String NAME = "name";
++        public static final String DESCRIPTION = "description";
++        public static final String OWNER_ID = "ownerId";
++        public static final String GROUP_TYPE = "groupType";
++        public static final String GROUP_CARDINALITY = "groupCardinality";
++        public static final String CREATED_TIME = "createdTime";
++        public static final String UPDATED_TIME = "updatedTime";
++    }
++
++    public static class GroupMembershipTable {
++        public static final String PARENT_ID = "parentId";
++        public static final String CHILD_ID = "childId";
++        public static final String CHILD_TYPE = "childType";
++        public static final String DOMAIN_ID = "domainId";
++        public static final String CREATED_TIME = "createdTime";
++        public static final String UPDATED_TIME = "updatedTime";
++    }
++
++    public static class EntityTypeTable {
++        public static final String ENTITY_TYPE_ID = "entityTypeId";
++        public static final String DOMAIN_ID = "domainId";
++        public static final String CREATED_TIME = "createdTime";
++        public static final String UPDATED_TIME = "updatedTime";
++    }
++
++    public static class PermissionTypeTable {
++        public static final String ENTITY_TYPE_ID = "permissionTypeId";
++        public static final String DOMAIN_ID = "domainId";
++        public static final String NAME = "name";
++        public static final String CREATED_TIME = "createdTime";
++        public static final String UPDATED_TIME = "updatedTime";
++    }
++
++    public static class EntityTable {
++        public static final String ENTITY_ID = "entityId";
++        public static final String PARENT_ENTITY_ID = "parentEntityId";
++        public static final String ENTITY_TYPE_ID = "entityTypeId";
++        public static final String NAME = "name";
++        public static final String DESCRIPTION = "description";
++        public static final String FULL_TEXT = "fullText";
++        public static final String CREATED_TIME = "createdTime";
++        public static final String UPDATED_TIME = "updatedTime";
++        public static final String DOMAIN_ID = "domainId";
++        public static final String ORIGINAL_ENTITY_CREATION_TIME = "originalEntityCreationTime";
++        public static final String SHARED = "shared";
++    }
++
++    public static class SharingTable {
++        public static final String DOMAIN_ID = "domainId";
++        public static final String PERMISSION_TYPE_ID = "permissionTypeId";
++        public static final String ENTITY_ID = "entityId";
++        public static final String GROUP_ID = "groupId";
++        public static final String INHERITED_PARENT_ID = "inheritedParentId";
++        public static final String SHARING_TYPE = "sharingType";
++        public static final String CREATED_TIME = "createdTime";
++        public static final String UPDATED_TIME = "updatedTime";
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/JPAUtils.java
index 0000000,0000000..6640c46
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/JPAUtils.java
@@@ -1,0 -1,0 +1,35 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.utils;
++
++import org.apache.custos.commons.utils.JDBCConfig;
++
++import javax.persistence.EntityManager;
++import javax.persistence.EntityManagerFactory;
++
++public class JPAUtils {
++    public static final String PERSISTENCE_UNIT_NAME = "airavata-sharing-registry";
++    private static final JDBCConfig JDBC_CONFIG = new SharingRegistryJDBCConfig();
++    private static final EntityManagerFactory factory = org.apache.custos.commons.utils.JPAUtils.getEntityManagerFactory(PERSISTENCE_UNIT_NAME, JDBC_CONFIG);
++
++    public static EntityManager getEntityManager() {
++        return factory.createEntityManager();
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/ObjectMapperSingleton.java
index 0000000,0000000..2cbade7
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/ObjectMapperSingleton.java
@@@ -1,0 -1,0 +1,38 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.db.utils;
++
++import org.dozer.DozerBeanMapper;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class ObjectMapperSingleton extends DozerBeanMapper{
++    private final static Logger logger = LoggerFactory.getLogger(ObjectMapperSingleton.class);
++
++    private static ObjectMapperSingleton instance;
++
++    private ObjectMapperSingleton(){}
++
++    public static ObjectMapperSingleton getInstance(){
++        if(instance == null)
++            instance = new ObjectMapperSingleton();
++        return instance;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/SharingRegistryDBInitConfig.java
index 0000000,0000000..44cf9a5
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/SharingRegistryDBInitConfig.java
@@@ -1,0 -1,0 +1,50 @@@
++/*
++ * 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.custos.sharing.service.core.db.utils;
++
++
++import org.apache.custos.commons.utils.DBInitConfig;
++import org.apache.custos.commons.utils.JDBCConfig;
++import org.springframework.stereotype.Component;
++
++@Component
++public class SharingRegistryDBInitConfig implements DBInitConfig {
++    //TODO: check if this field should be read from configuration file
++    private String dbInitScriptPrefix = "database_scripts/sharing-registry";
++
++    @Override
++    public JDBCConfig getJDBCConfig() {
++        return new SharingRegistryJDBCConfig();
++    }
++
++    @Override
++    public String getDBInitScriptPrefix() {
++        return this.dbInitScriptPrefix;
++    }
++
++    @Override
++    public String getCheckTableName() {
++        return "CONFIGURATION";
++    }
++
++    public void setDBInitScriptPrefix(String dbInitScriptPrefix) {
++        this.dbInitScriptPrefix = dbInitScriptPrefix;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/SharingRegistryJDBCConfig.java
index 0000000,0000000..8bfa5ec
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/SharingRegistryJDBCConfig.java
@@@ -1,0 -1,0 +1,67 @@@
++/*
++ * 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.custos.sharing.service.core.db.utils;
++
++import org.apache.custos.commons.exceptions.ApplicationSettingsException;
++import org.apache.custos.commons.utils.JDBCConfig;
++import org.apache.custos.commons.utils.ServerSettings;
++
++public class SharingRegistryJDBCConfig implements JDBCConfig {
++
++    private static final String SHARING_REG_JDBC_DRIVER = "sharingcatalog.jdbc.driver";
++    private static final String SHARING_REG_JDBC_URL = "sharingcatalog.jdbc.url";
++    private static final String SHARING_REG_JDBC_USER = "sharingcatalog.jdbc.user";
++    private static final String SHARING_REG_JDBC_PWD = "sharingcatalog.jdbc.password";
++    private static final String SHARING_REG_VALIDATION_QUERY = "sharingcatalog.validationQuery";
++
++    @Override
++    public String getURL() {
++        return readServerProperties(SHARING_REG_JDBC_URL);
++    }
++
++    @Override
++    public String getDriver() {
++        return readServerProperties(SHARING_REG_JDBC_DRIVER);
++    }
++
++    @Override
++    public String getUser() {
++        return readServerProperties(SHARING_REG_JDBC_USER);
++    }
++
++    @Override
++    public String getPassword() {
++        return readServerProperties(SHARING_REG_JDBC_PWD);
++    }
++
++    @Override
++    public String getValidationQuery() {
++        return readServerProperties(SHARING_REG_VALIDATION_QUERY);
++    }
++
++    private String readServerProperties(String propertyName) {
++        try {
++            return ServerSettings.getSetting(propertyName);
++        } catch (ApplicationSettingsException e) {
++            throw new RuntimeException("Unable to read server.properties...", e);
++        }
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/DuplicateEntryException.java
index 0000000,0000000..8f79a0c
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/DuplicateEntryException.java
@@@ -1,0 -1,0 +1,15 @@@
++package org.apache.custos.sharing.service.core.exceptions;
++
++import org.springframework.http.HttpStatus;
++import org.springframework.web.bind.annotation.ResponseStatus;
++
++@ResponseStatus(value= HttpStatus.CONFLICT, reason = "Request cannot be completed because a duplicate entry is requested")
++public class DuplicateEntryException extends RuntimeException {
++
++    public DuplicateEntryException(String errorMessage, Throwable err) {
++        super(errorMessage, err);
++    }
++    public DuplicateEntryException(String errorMessage) {
++        super(errorMessage);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/ResourceNotFoundException.java
index 0000000,0000000..df5dbbb
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/ResourceNotFoundException.java
@@@ -1,0 -1,0 +1,16 @@@
++package org.apache.custos.sharing.service.core.exceptions;
++
++import org.springframework.http.HttpStatus;
++import org.springframework.web.bind.annotation.ResponseStatus;
++
++@ResponseStatus(value= HttpStatus.NOT_FOUND, reason = "Request cannot be completed because the server could not find the resource")
++public class ResourceNotFoundException extends RuntimeException{
++
++    public ResourceNotFoundException(String errorMessage) {
++        super(errorMessage);
++    }
++
++    public ResourceNotFoundException(String errorMessage, Throwable err) {
++        super(errorMessage, err);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/SharingRegistryException.java
index 0000000,0000000..a38ee8c
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/SharingRegistryException.java
@@@ -1,0 -1,0 +1,16 @@@
++package org.apache.custos.sharing.service.core.exceptions;
++
++import org.springframework.http.HttpStatus;
++import org.springframework.web.bind.annotation.ResponseStatus;
++
++@ResponseStatus(value= HttpStatus.INTERNAL_SERVER_ERROR, reason = "Request cannot be completed due to server error")
++public class SharingRegistryException extends RuntimeException {
++
++    public SharingRegistryException(String errorMessage) {
++        super(errorMessage);
++    }
++
++    public SharingRegistryException(String errorMessage, Throwable err) {
++        super(errorMessage, err);
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java
index 0000000,0000000..b7f8733
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java
@@@ -1,0 -1,0 +1,49 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public class Domain {
++    private String domainId = "DO_NOT_SET_AT_CLIENTS_ID";
++    private String name;
++    private String description;
++    private double createdTime;
++    private double updatedTime;
++
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    public double getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(double createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    public double getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(double updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Entity.java
index 0000000,0000000..0410130
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Entity.java
@@@ -1,0 -1,0 +1,121 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public class Entity {
++    private String entityId;
++    private String domainId;
++    private String entityTypeId;
++    private String ownerId;
++    private String parentEntityId;
++    private String name;
++    private String description;
++    private byte[] binaryData;
++    private String fullText;
++    private double sharedCount = 0;
++    private double originalEntityCreationTime;
++    private double createdTime;
++    private double updatedTime;
++
++    public String getEntityId() {
++        return entityId;
++    }
++
++    public void setEntityId(String entityId) {
++        this.entityId = entityId;
++    }
++
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    public String getEntityTypeId() {
++        return entityTypeId;
++    }
++
++    public void setEntityTypeId(String entityTypeId) {
++        this.entityTypeId = entityTypeId;
++    }
++
++    public String getOwnerId() {
++        return ownerId;
++    }
++
++    public void setOwnerId(String ownerId) {
++        this.ownerId = ownerId;
++    }
++
++    public String getParentEntityId() {
++        return parentEntityId;
++    }
++
++    public void setParentEntityId(String parentEntityId) {
++        this.parentEntityId = parentEntityId;
++    }
++
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    public byte[] getBinaryData() {
++        return binaryData;
++    }
++
++    public void setBinaryData(byte[] binaryData) {
++        this.binaryData = binaryData;
++    }
++
++    public String getFullText() {
++        return fullText;
++    }
++
++    public void setFullText(String fullText) {
++        this.fullText = fullText;
++    }
++
++    public double getSharedCount() {
++        return sharedCount;
++    }
++
++    public void setSharedCount(double sharedCount) {
++        this.sharedCount = sharedCount;
++    }
++
++    public double getOriginalEntityCreationTime() {
++        return originalEntityCreationTime;
++    }
++
++    public void setOriginalEntityCreationTime(double originalEntityCreationTime) {
++        this.originalEntityCreationTime = originalEntityCreationTime;
++    }
++
++    public double getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(double createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    public double getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(double updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/EntitySearchField.java
index 0000000,0000000..7adc461
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/EntitySearchField.java
@@@ -1,0 -1,0 +1,14 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public enum EntitySearchField {
++    NAME,
++    DESCRIPTION,
++    FULL_TEXT,
++    PARRENT_ENTITY_ID,
++    OWNER_ID,
++    PERMISSION_TYPE_ID,
++    CREATED_TIME,
++    UPDATED_TIME,
++    ENTITY_TYPE_ID,
++    SHARED_COUNT
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/EntityType.java
index 0000000,0000000..1df393d
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/EntityType.java
@@@ -1,0 -1,0 +1,58 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public class EntityType {
++    private String entityTypeId;
++    private String domainId;
++    private String name;
++    private String description;
++    private double createdTime;
++    private double updatedTime;
++
++    public String getEntityTypeId() {
++        return entityTypeId;
++    }
++
++    public void setEntityTypeId(String entityTypeId) {
++        this.entityTypeId = entityTypeId;
++    }
++
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    public double getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(double createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    public double getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(double updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupAdmin.java
index 0000000,0000000..613e806
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupAdmin.java
@@@ -1,0 -1,0 +1,33 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public class GroupAdmin {
++    private String groupId;
++    private String domainId;
++    private String adminId;
++
++    public String getGroupId() {
++        return groupId;
++    }
++
++    public void setGroupId(String groupId) {
++        this.groupId = groupId;
++    }
++
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    public String getAdminId() {
++        return adminId;
++    }
++
++    public void setAdminId(String adminId) {
++        this.adminId = adminId;
++    }
++
++
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupCardinality.java
index 0000000,0000000..cf4d1e2
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupCardinality.java
@@@ -1,0 -1,0 +1,6 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public enum GroupCardinality {
++    SINGLE_USER,
++    MULTI_USER
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupChildType.java
index 0000000,0000000..de7a887
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupChildType.java
@@@ -1,0 -1,0 +1,6 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public enum GroupChildType {
++        USER,
++        GROUP
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupMembership.java
index 0000000,0000000..d07a002
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupMembership.java
@@@ -1,0 -1,0 +1,60 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public class GroupMembership {
++
++    private String parentId;
++    private String childId;
++    private String domainId;
++    private GroupChildType childType;
++    private double createdTime;
++    private double updatedTime;
++
++    public String getParentId() {
++        return parentId;
++    }
++
++    public void setParentId(String parentId) {
++        this.parentId = parentId;
++    }
++
++    public String getChildId() {
++        return childId;
++    }
++
++    public void setChildId(String childId) {
++        this.childId = childId;
++    }
++
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    public GroupChildType getChildType() {
++        return childType;
++    }
++
++    public void setChildType(GroupChildType childType) {
++        this.childType = childType;
++    }
++
++    public double getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(double createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    public double getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(double updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupType.java
index 0000000,0000000..9b00cff
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupType.java
@@@ -1,0 -1,0 +1,6 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public enum GroupType {
++    DOMAIN_LEVEL_GROUP,
++    USER_LEVEL_GROUP
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/PermissionType.java
index 0000000,0000000..1ae87c2
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/PermissionType.java
@@@ -1,0 -1,0 +1,60 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public class PermissionType {
++
++    private String permissionTypeId;
++    private String domainId;
++    private String name;
++    private String description;
++    private double createdTime;
++    private double updatedTime;
++
++    public String getPermissionTypeId() {
++        return permissionTypeId;
++    }
++
++    public void setPermissionTypeId(String permissionTypeId) {
++        this.permissionTypeId = permissionTypeId;
++    }
++
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    public double getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(double createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    public double getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(double updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/SearchCondition.java
index 0000000,0000000..3b227a2
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/SearchCondition.java
@@@ -1,0 -1,0 +1,10 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public enum SearchCondition {
++    EQUAL,
++    LIKE,
++    FULL_TEXT,
++    GTE,
++    LTE,
++    NOT
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/SearchCriteria.java
index 0000000,0000000..f053527
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/SearchCriteria.java
@@@ -1,0 -1,0 +1,31 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public class SearchCriteria {
++    private EntitySearchField searchField;
++    private String value;
++    private SearchCondition searchCondition;
++
++    public EntitySearchField getSearchField() {
++        return searchField;
++    }
++
++    public void setSearchField(EntitySearchField searchField) {
++        this.searchField = searchField;
++    }
++
++    public String getValue() {
++        return value;
++    }
++
++    public void setValue(String value) {
++        this.value = value;
++    }
++
++    public SearchCondition getSearchCondition() {
++        return searchCondition;
++    }
++
++    public void setSearchCondition(SearchCondition searchCondition) {
++        this.searchCondition = searchCondition;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Sharing.java
index 0000000,0000000..83f22ee
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Sharing.java
@@@ -1,0 -1,0 +1,78 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public class Sharing {
++
++    private String permissionTypeId;
++    private String entityId;
++    private String groupId;
++    private SharingType sharingType;
++    private String domainId;
++    private String inheritedParentId;
++    private double createdTime;
++    private double updatedTime;
++
++    public String getPermissionTypeId() {
++        return permissionTypeId;
++    }
++
++    public void setPermissionTypeId(String permissionTypeId) {
++        this.permissionTypeId = permissionTypeId;
++    }
++
++    public String getEntityId() {
++        return entityId;
++    }
++
++    public void setEntityId(String entityId) {
++        this.entityId = entityId;
++    }
++
++    public String getGroupId() {
++        return groupId;
++    }
++
++    public void setGroupId(String groupId) {
++        this.groupId = groupId;
++    }
++
++    public SharingType getSharingType() {
++        return sharingType;
++    }
++
++    public void setSharingType(SharingType sharingType) {
++        this.sharingType = sharingType;
++    }
++
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    public String getInheritedParentId() {
++        return inheritedParentId;
++    }
++
++    public void setInheritedParentId(String inheritedParentId) {
++        this.inheritedParentId = inheritedParentId;
++    }
++
++    public double getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(double createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    public double getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(double updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/SharingType.java
index 0000000,0000000..ccc9a59
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/SharingType.java
@@@ -1,0 -1,0 +1,7 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public enum SharingType {
++    DIRECT_NON_CASCADING,
++    DIRECT_CASCADING,
++    INDIRECT_CASCADING
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/User.java
index 0000000,0000000..f4f2174
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/User.java
@@@ -1,0 -1,0 +1,85 @@@
++package org.apache.custos.sharing.service.core.models;
++
++public class User {
++    private String userId;
++    private String domainId;
++    private String userName;
++    private String firstName;
++    private String lastName;
++    private String email;
++    private byte icon;
++    private double createdTime;
++    private double updatedTime;
++
++    public String getUserId() {
++        return userId;
++    }
++
++    public void setUserId(String userId) {
++        this.userId = userId;
++    }
++
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    public String getUserName() {
++        return userName;
++    }
++
++    public void setUserName(String userName) {
++        this.userName = userName;
++    }
++
++    public String getFirstName() {
++        return firstName;
++    }
++
++    public void setFirstName(String firstName) {
++        this.firstName = firstName;
++    }
++
++    public String getLastName() {
++        return lastName;
++    }
++
++    public void setLastName(String lastName) {
++        this.lastName = lastName;
++    }
++
++    public String getEmail() {
++        return email;
++    }
++
++    public void setEmail(String email) {
++        this.email = email;
++    }
++
++    public byte getIcon() {
++        return icon;
++    }
++
++    public void setIcon(byte icon) {
++        this.icon = icon;
++    }
++
++    public double getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(double createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    public double getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(double updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/UserGroup.java
index 0000000,0000000..16457f0
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/UserGroup.java
@@@ -1,0 -1,0 +1,97 @@@
++package org.apache.custos.sharing.service.core.models;
++
++import java.util.List;
++
++public class UserGroup {
++
++    private String groupId;
++    private String domainId;
++    private String name;
++    private String description;
++    private String ownerId;
++    private GroupType groupType;
++    private GroupCardinality groupCardinality;
++    private double createdTime;
++    private double updatedTime;
++    private List<GroupAdmin> groupAdmins;
++
++    public String getGroupId() {
++        return groupId;
++    }
++
++    public void setGroupId(String groupId) {
++        this.groupId = groupId;
++    }
++
++    public String getDomainId() {
++        return domainId;
++    }
++
++    public void setDomainId(String domainId) {
++        this.domainId = domainId;
++    }
++
++    public String getName() {
++        return name;
++    }
++
++    public void setName(String name) {
++        this.name = name;
++    }
++
++    public String getDescription() {
++        return description;
++    }
++
++    public void setDescription(String description) {
++        this.description = description;
++    }
++
++    public String getOwnerId() {
++        return ownerId;
++    }
++
++    public void setOwnerId(String ownerId) {
++        this.ownerId = ownerId;
++    }
++
++    public GroupType getGroupType() {
++        return groupType;
++    }
++
++    public void setGroupType(GroupType groupType) {
++        this.groupType = groupType;
++    }
++
++    public GroupCardinality getGroupCardinality() {
++        return groupCardinality;
++    }
++
++    public void setGroupCardinality(GroupCardinality groupCardinality) {
++        this.groupCardinality = groupCardinality;
++    }
++
++    public double getCreatedTime() {
++        return createdTime;
++    }
++
++    public void setCreatedTime(double createdTime) {
++        this.createdTime = createdTime;
++    }
++
++    public double getUpdatedTime() {
++        return updatedTime;
++    }
++
++    public void setUpdatedTime(double updatedTime) {
++        this.updatedTime = updatedTime;
++    }
++
++    public List<GroupAdmin> getGroupAdmins() {
++        return groupAdmins;
++    }
++
++    public void setGroupAdmins(List<GroupAdmin> groupAdmins) {
++        this.groupAdmins = groupAdmins;
++    }
++}
diff --cc custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java
index 0000000,0000000..fef39c9
new file mode 100644
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java
@@@ -1,0 -1,0 +1,1216 @@@
++/**
++ *
++ * 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.custos.sharing.service.core.service;
++
++import org.apache.commons.lang.exception.ExceptionUtils;
++import org.apache.custos.commons.exceptions.ApplicationSettingsException;
++import org.apache.custos.commons.utils.DBInitializer;
++import org.apache.custos.sharing.service.core.models.*;
++import org.apache.custos.sharing.service.core.db.entities.*;
++import org.apache.custos.sharing.service.core.db.repositories.*;
++import org.apache.custos.sharing.service.core.db.utils.DBConstants;
++import org.apache.custos.sharing.service.core.db.utils.SharingRegistryDBInitConfig;
++import org.apache.custos.sharing.service.core.exceptions.DuplicateEntryException;
++import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
++import org.apache.thrift.TException;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++import org.springframework.beans.factory.annotation.Autowired;
++import org.springframework.stereotype.Service;
++
++import java.lang.reflect.Field;
++import java.lang.reflect.Modifier;
++import java.util.*;
++
++@Service
++public class SharingRegistryService {
++    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryService.class);
++
++    public static String OWNER_PERMISSION_NAME = "OWNER";
++    public static String SHARING_CPI_VERSION = "1.0";
++
++    public SharingRegistryService(SharingRegistryDBInitConfig sharingRegistryDBInitConfig)  throws ApplicationSettingsException {
++        DBInitializer.initializeDB(sharingRegistryDBInitConfig);
++    }
++
++    public String getAPIVersion() {
++        return SHARING_CPI_VERSION;
++    }
++
++    /**
++     * * Domain Operations
++     * *
++     */
++
++    public String createDomain(Domain domain) throws SharingRegistryException, DuplicateEntryException {
++        try{
++            domain.setDomainId(domain.getName());
++            if((new DomainRepository()).get(domain.getDomainId()) != null)
++                throw new DuplicateEntryException("There exist domain with given domain id");
++
++            domain.setCreatedTime(System.currentTimeMillis());
++            domain.setUpdatedTime(System.currentTimeMillis());
++            (new DomainRepository()).create(domain);
++
++            //create the global permission for the domain
++            PermissionType permissionType = new PermissionType();
++            permissionType.setPermissionTypeId(domain.getDomainId() + ":" + OWNER_PERMISSION_NAME);
++            permissionType.setDomainId(domain.getDomainId());
++            permissionType.setName(OWNER_PERMISSION_NAME);
++            permissionType.setDescription("GLOBAL permission to " + domain.getDomainId());
++            permissionType.setCreatedTime(System.currentTimeMillis());
++            permissionType.setUpdatedTime(System.currentTimeMillis());
++            (new PermissionTypeRepository()).create(permissionType);
++
++            return domain.getDomainId();
++        }catch (Throwable ex){
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean updateDomain(Domain domain) throws SharingRegistryException {
++        try{
++            Domain oldDomain = (new DomainRepository()).get(domain.getDomainId());
++            domain.setCreatedTime(oldDomain.getCreatedTime());
++            domain.setUpdatedTime(System.currentTimeMillis());
++            domain = getUpdatedObject(oldDomain, domain);
++            (new DomainRepository()).update(domain);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * <p>API method to check Domain Exists</p>
++     *
++     * @param domainId
++     */
++    public boolean isDomainExists(String domainId) throws SharingRegistryException {
++        try{
++            return (new DomainRepository()).isExists(domainId);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean deleteDomain(String domainId) throws SharingRegistryException {
++        try{
++            (new DomainRepository()).delete(domainId);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public Domain getDomain(String domainId) throws SharingRegistryException {
++        try{
++            return (new DomainRepository()).get(domainId);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<Domain> getDomains(int offset, int limit) throws SharingRegistryException {
++        try{
++            return (new DomainRepository()).select(new HashMap<>(), offset, limit);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * * User Operations
++     * *
++     */
++    public String createUser(User user) throws SharingRegistryException, DuplicateEntryException {
++        try{
++            UserPK userPK = new UserPK();
++            userPK.setUserId(user.getUserId());
++            userPK.setDomainId(user.getDomainId());
++            if((new UserRepository()).get(userPK) != null)
++                throw new DuplicateEntryException("There exist user with given user id");
++
++            user.setCreatedTime(System.currentTimeMillis());
++            user.setUpdatedTime(System.currentTimeMillis());
++            (new UserRepository()).create(user);
++
++            UserGroup userGroup = new UserGroup();
++            userGroup.setGroupId(user.getUserId());
++            userGroup.setDomainId(user.getDomainId());
++            userGroup.setName(user.getUserName());
++            userGroup.setDescription("user " + user.getUserName() + " group");
++            userGroup.setOwnerId(user.getUserId());
++            userGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
++            userGroup.setGroupCardinality(GroupCardinality.SINGLE_USER);
++            (new UserGroupRepository()).create(userGroup);
++
++            return user.getUserId();
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean updatedUser(User user) throws SharingRegistryException {
++        try{
++            UserPK userPK = new UserPK();
++            userPK.setUserId(user.getUserId());
++            userPK.setDomainId(user.getDomainId());
++            User oldUser = (new UserRepository()).get(userPK);
++            user.setCreatedTime(oldUser.getCreatedTime());
++            user.setUpdatedTime(System.currentTimeMillis());
++            user = getUpdatedObject(oldUser, user);
++            (new UserRepository()).update(user);
++
++            UserGroupPK userGroupPK = new UserGroupPK();
++            userGroupPK.setGroupId(user.getUserId());
++            userGroupPK.setDomainId(user.getDomainId());
++            UserGroup userGroup = (new UserGroupRepository()).get(userGroupPK);
++            userGroup.setName(user.getUserName());
++            userGroup.setDescription("user " + user.getUserName() + " group");
++            updateGroup(userGroup);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * <p>API method to check User Exists</p>
++     *
++     * @param userId
++     */
++    public boolean isUserExists(String domainId, String userId) throws SharingRegistryException {
++        try{
++            UserPK userPK = new UserPK();
++            userPK.setDomainId(domainId);
++            userPK.setUserId(userId);
++            return (new UserRepository()).isExists(userPK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean deleteUser(String domainId, String userId) throws SharingRegistryException {
++        try{
++            UserPK userPK = new UserPK();
++            userPK.setUserId(userId);
++            userPK.setDomainId(domainId);
++            (new UserRepository()).delete(userPK);
++
++            UserGroupPK userGroupPK = new UserGroupPK();
++            userGroupPK.setGroupId(userId);
++            userGroupPK.setDomainId(domainId);
++            (new UserGroupRepository()).delete(userGroupPK);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public User getUser(String domainId, String userId) throws SharingRegistryException {
++        try{
++            UserPK userPK = new UserPK();
++            userPK.setUserId(userId);
++            userPK.setDomainId(domainId);
++            return (new UserRepository()).get(userPK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<User> getUsers(String domain, int offset, int limit) throws SharingRegistryException {
++        try{
++            HashMap<String, String> filters = new HashMap<>();
++            filters.put(DBConstants.UserTable.DOMAIN_ID, domain);
++            return (new UserRepository()).select(filters, offset, limit);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * * Group Operations
++     * *
++     */
++    public String createGroup(UserGroup group) throws DuplicateEntryException, SharingRegistryException{
++        try {
++            UserGroupPK userGroupPK = new UserGroupPK();
++            userGroupPK.setGroupId(group.getGroupId());
++            userGroupPK.setDomainId(group.getDomainId());
++            if ((new UserGroupRepository()).get(userGroupPK) != null)
++                throw new DuplicateEntryException("There exists group with given group id");
++            //Client created groups are always of type MULTI_USER
++            group.setGroupCardinality(GroupCardinality.MULTI_USER);
++            group.setCreatedTime(System.currentTimeMillis());
++            group.setUpdatedTime(System.currentTimeMillis());
++            //Add group admins once the group is created
++            //group.unsetGroupAdmins();
++            (new UserGroupRepository()).create(group);
++
++            addUsersToGroup(group.getDomainId(), Arrays.asList(group.getOwnerId()), group.getGroupId());
++            addGroupAdmins(group.getDomainId(), group.getGroupId(), group.getGroupAdmins());
++            return group.getGroupId();
++        } catch (DuplicateEntryException ex) {
++            logger.error(ex.getMessage(), ex);
++            throw ex;
++        } catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean updateGroup(UserGroup group) throws SharingRegistryException {
++        try{
++            group.setUpdatedTime(System.currentTimeMillis());
++            UserGroupPK userGroupPK = new UserGroupPK();
++            userGroupPK.setGroupId(group.getGroupId());
++            userGroupPK.setDomainId(group.getDomainId());
++            UserGroup oldGroup = (new UserGroupRepository()).get(userGroupPK);
++            group.setGroupCardinality(oldGroup.getGroupCardinality());
++            group.setCreatedTime(oldGroup.getCreatedTime());
++            group = getUpdatedObject(oldGroup, group);
++
++            if(!group.getOwnerId().equals(oldGroup.getOwnerId()))
++                throw new SharingRegistryException("Group owner cannot be changed");
++
++            (new UserGroupRepository()).update(group);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * API method to check Group Exists
++     * @param domainId
++     * @param groupId
++     * @return
++     * @throws SharingRegistryException
++     */
++
++    public boolean isGroupExists(String domainId, String groupId) throws SharingRegistryException {
++        try{
++            UserGroupPK userGroupPK = new UserGroupPK();
++            userGroupPK.setDomainId(domainId);
++            userGroupPK.setGroupId(groupId);
++            return (new UserGroupRepository()).isExists(userGroupPK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean deleteGroup(String domainId, String groupId) throws SharingRegistryException {
++        try{
++            UserGroupPK userGroupPK = new UserGroupPK();
++            userGroupPK.setGroupId(groupId);
++            userGroupPK.setDomainId(domainId);
++            (new UserGroupRepository()).delete(userGroupPK);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public UserGroup getGroup(String domainId, String groupId) throws SharingRegistryException {
++        try{
++            UserGroupPK userGroupPK = new UserGroupPK();
++            userGroupPK.setGroupId(groupId);
++            userGroupPK.setDomainId(domainId);
++            return (new UserGroupRepository()).get(userGroupPK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<UserGroup> getGroups(String domain, int offset, int limit) throws SharingRegistryException {
++        try{
++            HashMap<String, String> filters = new HashMap<>();
++            filters.put(DBConstants.UserGroupTable.DOMAIN_ID, domain);
++            // Only return groups with MULTI_USER cardinality which is the only type of cardinality allowed for client created groups
++            filters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.name());
++            return (new UserGroupRepository()).select(filters, offset, limit);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean addUsersToGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException {
++        try{
++            for(int i=0; i < userIds.size(); i++){
++                GroupMembership groupMembership = new GroupMembership();
++                groupMembership.setParentId(groupId);
++                groupMembership.setChildId(userIds.get(i));
++                groupMembership.setChildType(GroupChildType.USER);
++                groupMembership.setDomainId(domainId);
++                groupMembership.setCreatedTime(System.currentTimeMillis());
++                groupMembership.setUpdatedTime(System.currentTimeMillis());
++                (new GroupMembershipRepository()).create(groupMembership);
++            }
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean removeUsersFromGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException {
++        try{
++            for (String userId: userIds) {
++                if (hasOwnerAccess(domainId, groupId, userId)) {
++                    throw new SharingRegistryException("List of User Ids contains Owner Id. Cannot remove owner from the group");
++                }
++            }
++
++            for(int i=0; i < userIds.size(); i++){
++                GroupMembershipPK groupMembershipPK = new GroupMembershipPK();
++                groupMembershipPK.setParentId(groupId);
++                groupMembershipPK.setChildId(userIds.get(i));
++                groupMembershipPK.setDomainId(domainId);
++                (new GroupMembershipRepository()).delete(groupMembershipPK);
++            }
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean transferGroupOwnership(String domainId, String groupId, String newOwnerId) throws SharingRegistryException {
++        try {
++            List<User> groupUser = getGroupMembersOfTypeUser(domainId, groupId, 0, -1);
++            if (!isUserBelongsToGroup(groupUser, newOwnerId)) {
++                throw new SharingRegistryException("New group owner is not part of the group");
++            }
++
++            if (hasOwnerAccess(domainId, groupId, newOwnerId)) {
++                throw new DuplicateEntryException("User already the current owner of the group");
++            }
++            // remove the new owner as Admin if present
++            if (hasAdminAccess(domainId, groupId, newOwnerId)) {
++                removeGroupAdmins(domainId, groupId, Arrays.asList(newOwnerId));
++            }
++
++            UserGroupPK userGroupPK = new UserGroupPK();
++            userGroupPK.setGroupId(groupId);
++            userGroupPK.setDomainId(domainId);
++            UserGroup userGroup = (new UserGroupRepository()).get(userGroupPK);
++            UserGroup newUserGroup = new UserGroup();
++            newUserGroup.setUpdatedTime(System.currentTimeMillis());
++            newUserGroup.setOwnerId(newOwnerId);
++            newUserGroup.setGroupCardinality(GroupCardinality.MULTI_USER);
++            newUserGroup.setCreatedTime(userGroup.getCreatedTime());
++            newUserGroup = getUpdatedObject(userGroup, newUserGroup);
++
++            (new UserGroupRepository()).update(newUserGroup);
++
++            return true;
++        }
++        catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    private boolean isUserBelongsToGroup(List<User> groupUser, String newOwnerId) {
++        for (User user: groupUser) {
++            if (user.getUserId().equals(newOwnerId)) {
++                return true;
++            }
++        }
++        return false;
++    }
++
++    public boolean addGroupAdmins(String domainId, String groupId, List<GroupAdmin> admins) throws SharingRegistryException {
++        try{
++            List<User> groupUser = getGroupMembersOfTypeUser(domainId, groupId, 0, -1);
++
++            for (GroupAdmin admin: admins) {
++                String adminId = admin.getAdminId();
++                if (! isUserBelongsToGroup(groupUser, adminId)) {
++                    throw new SharingRegistryException("Admin not the user of the group. GroupId : "+ groupId + ", AdminId : "+ adminId);
++                }
++                GroupAdminPK groupAdminPK = new GroupAdminPK();
++                groupAdminPK.setGroupId(groupId);
++                groupAdminPK.setAdminId(adminId);
++                groupAdminPK.setDomainId(domainId);
++
++                if((new GroupAdminRepository()).get(groupAdminPK) != null)
++                    throw new DuplicateEntryException("User already an admin for the group");
++
++                (new GroupAdminRepository()).create(admin);
++            }
++            return true;
++        }
++        catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean removeGroupAdmins(String domainId, String groupId, List<String> adminIds) throws SharingRegistryException {
++        try {
++            for (String adminId: adminIds) {
++                GroupAdminPK groupAdminPK = new GroupAdminPK();
++                groupAdminPK.setAdminId(adminId);
++                groupAdminPK.setDomainId(domainId);
++                groupAdminPK.setGroupId(groupId);
++                (new GroupAdminRepository()).delete(groupAdminPK);
++            }
++            return true;
++        }
++        catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean hasAdminAccess(String domainId, String groupId, String adminId) throws SharingRegistryException {
++        try{
++            GroupAdminPK groupAdminPK = new GroupAdminPK();
++            groupAdminPK.setGroupId(groupId);
++            groupAdminPK.setAdminId(adminId);
++            groupAdminPK.setDomainId(domainId);
++
++            if((new GroupAdminRepository()).get(groupAdminPK) != null)
++                return true;
++            return false;
++        }
++        catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean hasOwnerAccess(String domainId, String groupId, String ownerId) throws SharingRegistryException {
++        try {
++            UserGroupPK userGroupPK = new UserGroupPK();
++            userGroupPK.setGroupId(groupId);
++            userGroupPK.setDomainId(domainId);
++            UserGroup getGroup = (new UserGroupRepository()).get(userGroupPK);
++
++            if(getGroup.getOwnerId().equals(ownerId))
++                return true;
++            return false;
++        }
++        catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<User> getGroupMembersOfTypeUser(String domainId, String groupId, int offset, int limit) throws SharingRegistryException {
++        try{
++            //TODO limit offset
++            List<User> groupMemberUsers = (new GroupMembershipRepository()).getAllChildUsers(domainId, groupId);
++            return groupMemberUsers;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<UserGroup> getGroupMembersOfTypeGroup(String domainId, String groupId, int offset, int limit) throws SharingRegistryException {
++        try{
++            //TODO limit offset
++            List<UserGroup> groupMemberGroups = (new GroupMembershipRepository()).getAllChildGroups(domainId, groupId);
++            return groupMemberGroups;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean addChildGroupsToParentGroup(String domainId, List<String> childIds, String groupId) throws SharingRegistryException {
++        try{
++            for(String childId : childIds) {
++                //Todo check for cyclic dependencies
++                GroupMembership groupMembership = new GroupMembership();
++                groupMembership.setParentId(groupId);
++                groupMembership.setChildId(childId);
++                groupMembership.setChildType(GroupChildType.GROUP);
++                groupMembership.setDomainId(domainId);
++                groupMembership.setCreatedTime(System.currentTimeMillis());
++                groupMembership.setUpdatedTime(System.currentTimeMillis());
++                (new GroupMembershipRepository()).create(groupMembership);
++            }
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean removeChildGroupFromParentGroup(String domainId, String childId, String groupId) throws SharingRegistryException {
++        try{
++            GroupMembershipPK groupMembershipPK = new GroupMembershipPK();
++            groupMembershipPK.setParentId(groupId);
++            groupMembershipPK.setChildId(childId);
++            groupMembershipPK.setDomainId(domainId);
++            (new GroupMembershipRepository()).delete(groupMembershipPK);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<UserGroup> getAllMemberGroupsForUser(String domainId, String userId) throws SharingRegistryException {
++        try{
++            GroupMembershipRepository groupMembershipRepository = new GroupMembershipRepository();
++            return groupMembershipRepository.getAllMemberGroupsForUser(domainId, userId);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * * EntityType Operations
++     * *
++     */
++    public String createEntityType(EntityType entityType) throws SharingRegistryException, DuplicateEntryException {
++        try{
++            EntityTypePK entityTypePK = new EntityTypePK();
++            entityTypePK.setDomainId(entityType.getDomainId());
++            entityTypePK.setEntityTypeId(entityType.getEntityTypeId());
++            if((new EntityTypeRepository()).get(entityTypePK) != null)
++                throw new DuplicateEntryException("There exist EntityType with given EntityType id");
++
++            entityType.setCreatedTime(System.currentTimeMillis());
++            entityType.setUpdatedTime(System.currentTimeMillis());
++            (new EntityTypeRepository()).create(entityType);
++            return entityType.getEntityTypeId();
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean updateEntityType(EntityType entityType) throws SharingRegistryException {
++        try{
++            entityType.setUpdatedTime(System.currentTimeMillis());
++            EntityTypePK entityTypePK = new EntityTypePK();
++            entityTypePK.setDomainId(entityType.getDomainId());
++            entityTypePK.setEntityTypeId(entityType.getEntityTypeId());
++            EntityType oldEntityType = (new EntityTypeRepository()).get(entityTypePK);
++            entityType.setCreatedTime(oldEntityType.getCreatedTime());
++            entityType = getUpdatedObject(oldEntityType, entityType);
++            (new EntityTypeRepository()).update(entityType);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * <p>API method to check EntityType Exists</p>
++     *
++     * @param entityTypeId
++     */
++    public boolean isEntityTypeExists(String domainId, String entityTypeId) throws SharingRegistryException {
++        try{
++            EntityTypePK entityTypePK = new EntityTypePK();
++            entityTypePK.setDomainId(domainId);
++            entityTypePK.setEntityTypeId(entityTypeId);
++            return (new EntityTypeRepository()).isExists(entityTypePK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean deleteEntityType(String domainId, String entityTypeId) throws SharingRegistryException {
++        try{
++            EntityTypePK entityTypePK = new EntityTypePK();
++            entityTypePK.setDomainId(domainId);
++            entityTypePK.setEntityTypeId(entityTypeId);
++            (new EntityTypeRepository()).delete(entityTypePK);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public EntityType getEntityType(String domainId, String entityTypeId) throws SharingRegistryException {
++        try{
++            EntityTypePK entityTypePK = new EntityTypePK();
++            entityTypePK.setDomainId(domainId);
++            entityTypePK.setEntityTypeId(entityTypeId);
++            return (new EntityTypeRepository()).get(entityTypePK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<EntityType> getEntityTypes(String domain, int offset, int limit) throws SharingRegistryException {
++        try{
++            HashMap<String, String> filters = new HashMap<>();
++            filters.put(DBConstants.EntityTypeTable.DOMAIN_ID, domain);
++            return (new EntityTypeRepository()).select(filters, offset, limit);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * * Permission Operations
++     * *
++     */
++    public String createPermissionType(PermissionType permissionType) throws SharingRegistryException, DuplicateEntryException {
++        try{
++            PermissionTypePK permissionTypePK =  new PermissionTypePK();
++            permissionTypePK.setDomainId(permissionType.getDomainId());
++            permissionTypePK.setPermissionTypeId(permissionType.getPermissionTypeId());
++            if((new PermissionTypeRepository()).get(permissionTypePK) != null)
++                throw new DuplicateEntryException("There exist PermissionType with given PermissionType id");
++            permissionType.setCreatedTime(System.currentTimeMillis());
++            permissionType.setUpdatedTime(System.currentTimeMillis());
++            (new PermissionTypeRepository()).create(permissionType);
++            return permissionType.getPermissionTypeId();
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean updatePermissionType(PermissionType permissionType) throws SharingRegistryException {
++        try{
++            permissionType.setUpdatedTime(System.currentTimeMillis());
++            PermissionTypePK permissionTypePK =  new PermissionTypePK();
++            permissionTypePK.setDomainId(permissionType.getDomainId());
++            permissionTypePK.setPermissionTypeId(permissionType.getPermissionTypeId());
++            PermissionType oldPermissionType = (new PermissionTypeRepository()).get(permissionTypePK);
++            permissionType = getUpdatedObject(oldPermissionType, permissionType);
++            (new PermissionTypeRepository()).update(permissionType);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * <p>API method to check Permission Exists</p>
++     *
++     * @param permissionId
++     */
++    public boolean isPermissionExists(String domainId, String permissionId) throws SharingRegistryException {
++        try{
++            PermissionTypePK permissionTypePK = new PermissionTypePK();
++            permissionTypePK.setDomainId(domainId);
++            permissionTypePK.setPermissionTypeId(permissionId);
++            return (new PermissionTypeRepository()).isExists(permissionTypePK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean deletePermissionType(String domainId, String permissionTypeId) throws SharingRegistryException {
++        try{
++            PermissionTypePK permissionTypePK =  new PermissionTypePK();
++            permissionTypePK.setDomainId(domainId);
++            permissionTypePK.setPermissionTypeId(permissionTypeId);
++            (new PermissionTypeRepository()).delete(permissionTypePK);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public PermissionType getPermissionType(String domainId, String permissionTypeId) throws SharingRegistryException {
++        try{
++            PermissionTypePK permissionTypePK =  new PermissionTypePK();
++            permissionTypePK.setDomainId(domainId);
++            permissionTypePK.setPermissionTypeId(permissionTypeId);
++            return (new PermissionTypeRepository()).get(permissionTypePK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws SharingRegistryException {
++        try{
++            HashMap<String, String> filters = new HashMap<>();
++            filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domain);
++            return (new PermissionTypeRepository()).select(filters, offset, limit);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * * Entity Operations
++     * *
++     */
++    public String createEntity(Entity entity) throws SharingRegistryException, DuplicateEntryException {
++        try{
++            EntityPK entityPK = new EntityPK();
++            entityPK.setDomainId(entity.getDomainId());
++            entityPK.setEntityId(entity.getEntityId());
++            if((new EntityRepository()).get(entityPK) != null)
++                throw new DuplicateEntryException("There exist Entity with given Entity id");
++
++            UserPK userPK = new UserPK();
++            userPK.setDomainId(entity.getDomainId());
++            userPK.setUserId(entity.getOwnerId());
++            if(!(new UserRepository()).isExists(userPK)){
++                //Todo this is for Airavata easy integration. Proper thing is to throw an exception here
++                User user = new User();
++                user.setUserId(entity.getOwnerId());
++                user.setDomainId(entity.getDomainId());
++                user.setUserName(user.getUserId().split("@")[0]);
++
++                createUser(user);
++            }
++            entity.setCreatedTime(System.currentTimeMillis());
++            entity.setUpdatedTime(System.currentTimeMillis());
++
++            if(entity.getOriginalEntityCreationTime()==0){
++                entity.setOriginalEntityCreationTime(entity.getCreatedTime());
++            }
++            (new EntityRepository()).create(entity);
++
++            //Assigning global permission for the owner
++            Sharing newSharing = new Sharing();
++            newSharing.setPermissionTypeId((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(entity.getDomainId()));
++            newSharing.setEntityId(entity.getEntityId());
++            newSharing.setGroupId(entity.getOwnerId());
++            newSharing.setSharingType(SharingType.DIRECT_CASCADING);
++            newSharing.setInheritedParentId(entity.getEntityId());
++            newSharing.setDomainId(entity.getDomainId());
++            newSharing.setCreatedTime(System.currentTimeMillis());
++            newSharing.setUpdatedTime(System.currentTimeMillis());
++
++            (new SharingRepository()).create(newSharing);
++
++            // creating records for inherited permissions
++            if (entity.getParentEntityId() != null && entity.getParentEntityId() != "") {
++                addCascadingPermissionsForEntity(entity);
++            }
++
++            return entity.getEntityId();
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    private void addCascadingPermissionsForEntity(Entity entity) throws SharingRegistryException {
++        Sharing newSharing;
++        List<Sharing> sharings = (new SharingRepository()).getCascadingPermissionsForEntity(entity.getDomainId(),
++                entity.getParentEntityId());
++        for (Sharing sharing : sharings) {
++                    newSharing = new Sharing();
++                    newSharing.setPermissionTypeId(sharing.getPermissionTypeId());
++                    newSharing.setEntityId(entity.getEntityId());
++                    newSharing.setGroupId(sharing.getGroupId());
++                    newSharing.setInheritedParentId(sharing.getInheritedParentId());
++                    newSharing.setSharingType(SharingType.INDIRECT_CASCADING);
++                    newSharing.setDomainId(entity.getDomainId());
++                    newSharing.setCreatedTime(System.currentTimeMillis());
++                    newSharing.setUpdatedTime(System.currentTimeMillis());
++
++                    (new SharingRepository()).create(newSharing);
++                }
++            }
++
++    public boolean updateEntity(Entity entity) throws SharingRegistryException {
++        try{
++            //TODO Check for permission changes
++            entity.setUpdatedTime(System.currentTimeMillis());
++            EntityPK entityPK = new EntityPK();
++            entityPK.setDomainId(entity.getDomainId());
++            entityPK.setEntityId(entity.getEntityId());
++            Entity oldEntity = (new EntityRepository()).get(entityPK);
++            entity.setCreatedTime(oldEntity.getCreatedTime());
++            // check if parent entity changed and re-add inherited permissions
++            if (!Objects.equals(oldEntity.getParentEntityId(), entity.getParentEntityId())) {
++                logger.debug("Parent entity changed for {}, updating inherited permissions", entity.getEntityId());
++                if (oldEntity.getParentEntityId() != null && oldEntity.getParentEntityId() != "") {
++                    logger.debug("Removing inherited permissions from {} that were inherited from parent {}", entity.getEntityId(), oldEntity.getParentEntityId());
++                    (new SharingRepository()).removeAllIndirectCascadingPermissionsForEntity(entity.getDomainId(), entity.getEntityId());
++                }
++                if (entity.getParentEntityId() != null && entity.getParentEntityId() != "") {
++                    // re-add INDIRECT_CASCADING permissions
++                    logger.debug("Adding inherited permissions to {} that are inherited from parent {}", entity.getEntityId(), entity.getParentEntityId());
++                    addCascadingPermissionsForEntity(entity);
++                }
++            }
++            entity = getUpdatedObject(oldEntity, entity);
++            entity.setSharedCount((new SharingRepository()).getSharedCount(entity.getDomainId(), entity.getEntityId()));
++            (new EntityRepository()).update(entity);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * <p>API method to check Entity Exists</p>
++     *
++     * @param entityId
++     */
++    public boolean isEntityExists(String domainId, String entityId) throws SharingRegistryException {
++        try{
++            EntityPK entityPK = new EntityPK();
++            entityPK.setDomainId(domainId);
++            entityPK.setEntityId(entityId);
++            return (new EntityRepository()).isExists(entityPK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean deleteEntity(String domainId, String entityId) throws SharingRegistryException {
++        try{
++            //TODO Check for permission changes
++            EntityPK entityPK = new EntityPK();
++            entityPK.setDomainId(domainId);
++            entityPK.setEntityId(entityId);
++            (new EntityRepository()).delete(entityPK);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public Entity getEntity(String domainId, String entityId) throws SharingRegistryException {
++        try{
++            EntityPK entityPK = new EntityPK();
++            entityPK.setDomainId(domainId);
++            entityPK.setEntityId(entityId);
++            return (new EntityRepository()).get(entityPK);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<Entity> searchEntities(String domainId, String userId, List<SearchCriteria> filters,
++                                       int offset, int limit) throws SharingRegistryException {
++        try{
++            List<String> groupIds = new ArrayList<>();
++            groupIds.add(userId);
++            (new GroupMembershipRepository()).getAllParentMembershipsForChild(domainId, userId).stream().forEach(gm -> groupIds.add(gm.getParentId()));
++            return (new EntityRepository()).searchEntities(domainId, groupIds, filters, offset, limit);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<User> getListOfSharedUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
++        try{
++            return (new UserRepository()).getAccessibleUsers(domainId, entityId, permissionTypeId);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<User> getListOfDirectlySharedUsers(String domainId, String entityId, String permissionTypeId)
++            throws SharingRegistryException {
++        try{
++            return (new UserRepository()).getDirectlyAccessibleUsers(domainId, entityId, permissionTypeId);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<UserGroup> getListOfSharedGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
++        try{
++            return (new UserGroupRepository()).getAccessibleGroups(domainId, entityId, permissionTypeId);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public List<UserGroup> getListOfDirectlySharedGroups(String domainId, String entityId, String permissionTypeId)
++            throws SharingRegistryException {
++        try{
++            return (new UserGroupRepository()).getDirectlyAccessibleGroups(domainId, entityId, permissionTypeId);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    /**
++     * Sharing Entity with Users and Groups
++     * @param domainId
++     * @param entityId
++     * @param userList
++     * @param permissionTypeId
++     * @param cascadePermission
++     * @return
++     * @throws SharingRegistryException
++     * @throws TException
++     */
++    public boolean shareEntityWithUsers(String domainId, String entityId, List<String> userList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException {
++        try{
++            return shareEntity(domainId, entityId, userList, permissionTypeId, cascadePermission);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean shareEntityWithGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException {
++        try{
++            return shareEntity(domainId, entityId, groupList, permissionTypeId, cascadePermission);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    private boolean shareEntity(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId, boolean cascadePermission)  throws SharingRegistryException {
++        try{
++            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
++                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
++            }
++
++            List<Sharing> sharings = new ArrayList<>();
++
++            //Adding permission for the specified users/groups for the specified entity
++            LinkedList<Entity> temp = new LinkedList<>();
++            for(String userId : groupOrUserList){
++                Sharing sharing = new Sharing();
++                sharing.setPermissionTypeId(permissionTypeId);
++                sharing.setEntityId(entityId);
++                sharing.setGroupId(userId);
++                sharing.setInheritedParentId(entityId);
++                sharing.setDomainId(domainId);
++                if(cascadePermission) {
++                    sharing.setSharingType(SharingType.DIRECT_CASCADING);
++                }else {
++                    sharing.setSharingType(SharingType.DIRECT_NON_CASCADING);
++                }
++                sharing.setCreatedTime(System.currentTimeMillis());
++                sharing.setUpdatedTime(System.currentTimeMillis());
++
++                sharings.add(sharing);
++            }
++
++            if(cascadePermission){
++                //Adding permission for the specified users/groups for all child entities
++                (new EntityRepository()).getChildEntities(domainId, entityId).stream().forEach(e -> temp.addLast(e));
++                while(temp.size() > 0){
++                    Entity entity = temp.pop();
++                    String childEntityId = entity.getEntityId();
++                    for(String userId : groupOrUserList){
++                        Sharing sharing = new Sharing();
++                        sharing.setPermissionTypeId(permissionTypeId);
++                        sharing.setEntityId(childEntityId);
++                        sharing.setGroupId(userId);
++                        sharing.setInheritedParentId(entityId);
++                        sharing.setSharingType(SharingType.INDIRECT_CASCADING);
++                        sharing.setInheritedParentId(entityId);
++                        sharing.setDomainId(domainId);
++                        sharing.setCreatedTime(System.currentTimeMillis());
++                        sharing.setUpdatedTime(System.currentTimeMillis());
++                        sharings.add(sharing);
++                        (new EntityRepository()).getChildEntities(domainId, childEntityId).stream().forEach(e -> temp.addLast(e));
++                    }
++                }
++            }
++            (new SharingRepository()).create(sharings);
++
++            EntityPK entityPK = new EntityPK();
++            entityPK.setDomainId(domainId);
++            entityPK.setEntityId(entityId);
++            Entity entity = (new EntityRepository()).get(entityPK);
++            entity.setSharedCount((new SharingRepository()).getSharedCount(domainId, entityId));
++            (new EntityRepository()).update(entity);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean revokeEntitySharingFromUsers(String domainId, String entityId, List<String> userList, String permissionTypeId) throws SharingRegistryException {
++        try{
++            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
++                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
++            }
++            return revokeEntitySharing(domainId, entityId, userList, permissionTypeId);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++
++    public boolean revokeEntitySharingFromGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId) throws SharingRegistryException {
++        try{
++            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
++                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
++            }
++            return revokeEntitySharing(domainId, entityId, groupList, permissionTypeId);
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++
++    public boolean userHasAccess(String domainId, String userId, String entityId, String permissionTypeId) throws SharingRegistryException {
++        try{
++            //check whether the user has permission directly or indirectly
++            List<GroupMembership> parentMemberships = (new GroupMembershipRepository()).getAllParentMembershipsForChild(domainId, userId);
++            List<String> groupIds = new ArrayList<>();
++            parentMemberships.stream().forEach(pm->groupIds.add(pm.getParentId()));
++            groupIds.add(userId);
++            return (new SharingRepository()).hasAccess(domainId, entityId, groupIds, Arrays.asList(permissionTypeId,
++                    (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId)));
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++    }
++
++    public boolean revokeEntitySharing(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId) throws SharingRegistryException {
++        try{
++            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
++                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be removed");
++            }
++
++            //revoking permission for the entity
++            for(String groupId : groupOrUserList){
++                SharingPK sharingPK = new SharingPK();
++                sharingPK.setEntityId(entityId);
++                sharingPK.setGroupId(groupId);
++                sharingPK.setPermissionTypeId(permissionTypeId);
++                sharingPK.setInheritedParentId(entityId);
++                sharingPK.setDomainId(domainId);
++
++                (new SharingRepository()).delete(sharingPK);
++            }
++
++            //revoking permission from inheritance
++            List<Sharing> temp = new ArrayList<>();
++            (new SharingRepository()).getIndirectSharedChildren(domainId, entityId, permissionTypeId).stream().forEach(s -> temp.add(s));
++            for(Sharing sharing : temp){
++                String childEntityId = sharing.getEntityId();
++                for(String groupId : groupOrUserList){
++                    SharingPK sharingPK = new SharingPK();
++                    sharingPK.setEntityId(childEntityId);
++                    sharingPK.setGroupId(groupId);
++                    sharingPK.setPermissionTypeId(permissionTypeId);
++                    sharingPK.setInheritedParentId(entityId);
++                    sharingPK.setDomainId(domainId);
++
++                    (new SharingRepository()).delete(sharingPK);
++                }
++            }
++
++            EntityPK entityPK = new EntityPK();
++            entityPK.setDomainId(domainId);
++            entityPK.setEntityId(entityId);
++            Entity entity = (new EntityRepository()).get(entityPK);
++            entity.setSharedCount((new SharingRepository()).getSharedCount(domainId, entityId));
++            (new EntityRepository()).update(entity);
++            return true;
++        }catch (Throwable ex) {
++            logger.error(ex.getMessage(), ex);
++            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
++        }
++
++    }
++
++
++
++    private <T> T getUpdatedObject(T oldEntity, T newEntity) throws SharingRegistryException {
++        Field[] newEntityFields = newEntity.getClass().getDeclaredFields();
++        Hashtable newHT = fieldsToHT(newEntityFields, newEntity);
++
++        Class oldEntityClass = oldEntity.getClass();
++        Field[] oldEntityFields = oldEntityClass.getDeclaredFields();
++
++        for (Field field : oldEntityFields){
++            if (!Modifier.isFinal(field.getModifiers())) {
++                field.setAccessible(true);
++                Object o = newHT.get(field.getName());
++                if (o != null) {
++                    Field f = null;
++                    try {
++                        f = oldEntityClass.getDeclaredField(field.getName());
++                        f.setAccessible(true);
++                        logger.debug("setting " + f.getName());
++                        f.set(oldEntity, o);
++                    } catch (Exception e) {
++                        throw new SharingRegistryException(e.getMessage());
++                    }
++                }
++            }
++        }
++        return oldEntity;
++    }
++
++    private static Hashtable<String, Object> fieldsToHT(Field[] fields, Object obj){
++        Hashtable<String,Object> hashtable = new Hashtable<>();
++        for (Field field: fields){
++            field.setAccessible(true);
++            try {
++                Object retrievedObject = field.get(obj);
++                if (retrievedObject != null){
++                    logger.debug("scanning " + field.getName());
++                    hashtable.put(field.getName(), field.get(obj));
++                }
++            } catch (IllegalAccessException e) {
++                e.printStackTrace();
++            }
++        }
++        return hashtable;
++    }
++
++}
diff --cc pom.xml
index 2a1519b,e0524c7..5168d60
--- a/pom.xml
+++ b/pom.xml
@@@ -31,9 -30,8 +31,10 @@@
          <log4j.version>1.2.17</log4j.version>
          <thrift.version>0.12.0</thrift.version>
          <openjpa.version>2.4.3</openjpa.version>
-         <junit.version>4.12</junit.version>
 +        <mysql.connector.version>5.1.34</mysql.connector.version>
 +        <maven.assembly.plugin>3.1.1</maven.assembly.plugin>
+         <junit.version>4.8.1</junit.version>
+         <jmockit.version>1.8</jmockit.version>
      </properties>
      <dependencies>
          <dependency>


[airavata-custos] 46/48: added validations and refactored exception handling

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7fee0b2b119b427a58e6a995fc5c0a8ba96dd2c8
Author: Aarushi <aa...@gmail.com>
AuthorDate: Thu Sep 5 11:29:47 2019 -0400

    added validations and refactored exception handling
---
 .../service/api/controllers/DomainsController.java |  28 +-
 .../service/api/controllers/EntityController.java  |  27 +-
 .../api/controllers/EntityTypeController.java      |  41 +--
 .../service/api/controllers/GroupController.java   | 135 ++-----
 .../api/controllers/PermissionTypeController.java  |  40 +--
 .../service/api/controllers/UsersController.java   |  36 +-
 .../src/main/resources/application.properties      |   3 +-
 .../core/exceptions/InvalidRequestException.java   |  16 +
 .../custos/sharing/service/core/models/Domain.java |   2 +-
 .../core/service/SharingRegistryService.java       | 396 ++++++++++++++++-----
 pom.xml                                            |   5 +
 11 files changed, 399 insertions(+), 330 deletions(-)

diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java
index 9ab93e9..8de7bec 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java
@@ -1,7 +1,6 @@
 package org.apache.custos.sharing.service.api.controllers;
 
 import org.apache.custos.sharing.service.core.models.Domain;
-import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
 import org.apache.custos.sharing.service.core.service.SharingRegistryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -21,10 +20,9 @@ public class DomainsController {
      <p>API method to create a new domain</p>
      */
     @RequestMapping(method= RequestMethod.POST)
-    public @ResponseBody Domain createDomain(@Valid @RequestBody Domain domain){
-        Domain createdDomain = sharingRegistryService.createDomain(domain);
-        if(createdDomain != null) return createdDomain;
-        else throw new SharingRegistryException("Domain creation failed");
+    public ResponseEntity<Domain> createDomain(@Valid @RequestBody Domain domain){
+        Domain createdDomain  = sharingRegistryService.createDomain(domain);
+        return new ResponseEntity<>(createdDomain, HttpStatus.CREATED);
     }
 
     /**
@@ -32,9 +30,8 @@ public class DomainsController {
      */
     @RequestMapping(method = RequestMethod.PUT)
     public ResponseEntity<String> updateDomain(@Valid @RequestBody Domain domain){
-        boolean response = sharingRegistryService.updateDomain(domain);
-        if(response) return new ResponseEntity<>(HttpStatus.OK);
-        else throw new SharingRegistryException("Domain update failed");
+        sharingRegistryService.updateDomain(domain);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -56,8 +53,7 @@ public class DomainsController {
     @RequestMapping(value = "/{domainId}",method = RequestMethod.GET)
     public ResponseEntity<Domain> getDomain(@PathVariable("domainId") String domainId){
         Domain domain = sharingRegistryService.getDomain(domainId);
-        if(domain != null) return new ResponseEntity<>(domain, HttpStatus.OK);
-        else return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        return new ResponseEntity<>(domain, HttpStatus.OK);
     }
 
     /**
@@ -65,19 +61,15 @@ public class DomainsController {
      */
     @RequestMapping(value = "/{domainId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> deleteDomain(@PathVariable("domainId") String domainId){
-        boolean response = sharingRegistryService.deleteDomain(domainId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }else{
-            throw new SharingRegistryException("Could not delete the domain");
-        }
+        sharingRegistryService.deleteDomain(domainId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
-     <p>API method to get all domain.</p>
+     <p>API method to get all domains.</p>
      */
     @RequestMapping(method = RequestMethod.GET)
-    public @ResponseBody List<Domain> getDomains(@RequestParam(value = "offset") int offset, @RequestParam(value = "limit") int limit){
+    public @ResponseBody List<Domain> getDomains(@RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "-1") int limit){
         return sharingRegistryService.getDomains(offset, limit);
     }
 
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java
index b155fd7..ab39521 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java
@@ -26,12 +26,9 @@ public class EntityController {
      <p>API method to register new entity</p>
      */
     @RequestMapping(method = RequestMethod.POST)
-    public @ResponseBody Entity createEntity(@Valid @RequestBody Entity entity){
+    public ResponseEntity<Entity> createEntity(@Valid @RequestBody Entity entity){
         Entity createdEntity = sharingRegistryService.createEntity(entity);
-        if(createdEntity != null){
-            return createdEntity;
-        }
-        else throw new SharingRegistryException("Failed to create the entity");
+        return new ResponseEntity<>(createdEntity, HttpStatus.CREATED);
     }
 
     /**
@@ -39,9 +36,8 @@ public class EntityController {
      */
     @RequestMapping(method = RequestMethod.PUT)
     public ResponseEntity<String> updateEntity(@Valid @RequestBody Entity entity){
-        boolean response = sharingRegistryService.updateEntity(entity);
-        if(response) return new ResponseEntity<>(HttpStatus.OK);
-        else throw new SharingRegistryException("Failed to update the entity");
+        sharingRegistryService.updateEntity(entity);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -62,28 +58,25 @@ public class EntityController {
      */
     @RequestMapping(value = "/{entityId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> deleteEntity(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
-        boolean response = sharingRegistryService.deleteEntity(domainId, entityId);
-        if(response) return new ResponseEntity<>(HttpStatus.OK);
-        else throw new SharingRegistryException("Could not delete the entity");
+        sharingRegistryService.deleteEntity(domainId, entityId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
      <p>API method to get entity</p>
      */
     @RequestMapping(value = "/{entityId}", method = RequestMethod.GET)
-    public @ResponseBody Entity getEntity(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
+    public ResponseEntity<Entity> getEntity(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
         Entity entity = sharingRegistryService.getEntity(domainId, entityId);
-        if(entity != null) return entity;
-        else throw new ResourceNotFoundException("Could not find entity with entityId:" + entityId + " in domain:" + domainId);
+        return new ResponseEntity<>(entity, HttpStatus.OK);
     }
 
     /**
      <p>API method to search entities</p>
      */
     @RequestMapping(value = "/users/{userId}", method = RequestMethod.GET)
-    public @ResponseBody List<Entity> searchEntities(@RequestBody List<SearchCriteria> filters, @PathVariable("domainId") String domainId, @PathVariable("userId") String userId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
-        List<Entity> entities = sharingRegistryService.searchEntities(domainId, userId, filters, offset, limit);
-        return entities;
+    public @ResponseBody List<Entity> searchEntities(@RequestBody List<SearchCriteria> filters, @PathVariable("domainId") String domainId, @PathVariable("userId") String userId, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "-1") int limit){
+        return sharingRegistryService.searchEntities(domainId, userId, filters, offset, limit);
     }
 
     /**
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java
index 1b8624b..234012a 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java
@@ -24,14 +24,9 @@ public class EntityTypeController {
      <p>API method to create a new entity type</p>
      */
     @RequestMapping(method = RequestMethod.POST)
-    public EntityType createEntityType(@Valid @RequestBody EntityType entityType){
+    public ResponseEntity<EntityType> createEntityType(@Valid @RequestBody EntityType entityType){
         EntityType createdEntityType = sharingRegistryService.createEntityType(entityType);
-        if(createdEntityType != null){
-            return createdEntityType;
-        }
-        else{
-            throw new SharingRegistryException("Failed to create the entity type");
-        }
+        return new ResponseEntity<>(createdEntityType, HttpStatus.CREATED);
     }
 
     /**
@@ -39,13 +34,8 @@ public class EntityTypeController {
      */
     @RequestMapping(method = RequestMethod.PUT)
     public ResponseEntity<String> updateEntityType(@Valid @RequestBody EntityType entityType){
-        boolean response = sharingRegistryService.updateEntityType(entityType);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        else{
-            throw new SharingRegistryException("Failed to updated the entity type");
-        }
+        sharingRegistryService.updateEntityType(entityType);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -66,35 +56,24 @@ public class EntityTypeController {
      */
     @RequestMapping(value = "/{entityTypeId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> deleteEntityType(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
-        boolean response = sharingRegistryService.deleteEntityType(domainId, entityTypeId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        else{
-            throw new SharingRegistryException("Failed to delete the entity type");
-        }
+        sharingRegistryService.deleteEntityType(domainId, entityTypeId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
      <p>API method to get an entity type</p>
      */
     @RequestMapping(value = "/{entityTypeId}", method = RequestMethod.GET)
-    public @ResponseBody EntityType getEntityType(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
+    public ResponseEntity<EntityType> getEntityType(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
         EntityType entityType = sharingRegistryService.getEntityType(domainId, entityTypeId);
-        if(entityType != null){
-            return entityType;
-        }
-        else{
-            throw new ResourceNotFoundException("Could not find the entity type with entityTypeId: " + entityTypeId + " in domainId: "+ domainId);
-        }
+        return new ResponseEntity<>(entityType, HttpStatus.OK);
     }
 
     /**
      <p>API method to get entity types in a domainId.</p>
      */
     @RequestMapping(method = RequestMethod.GET)
-    public @ResponseBody List<EntityType> getEntityTypes(@PathVariable("domainId") String domainId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
-       List<EntityType> entityTypes = sharingRegistryService.getEntityTypes(domainId, offset, limit);
-       return entityTypes;
+    public @ResponseBody List<EntityType> getEntityTypes(@PathVariable("domainId") String domainId, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "-1") int limit){
+       return sharingRegistryService.getEntityTypes(domainId, offset, limit);
     }
 }
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java
index 6dbc993..5860644 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java
@@ -1,10 +1,7 @@
 package org.apache.custos.sharing.service.api.controllers;
 
-import org.apache.custos.sharing.service.core.models.GroupAdmin;
 import org.apache.custos.sharing.service.core.models.User;
 import org.apache.custos.sharing.service.core.models.UserGroup;
-import org.apache.custos.sharing.service.core.exceptions.ResourceNotFoundException;
-import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
 import org.apache.custos.sharing.service.core.service.SharingRegistryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -25,13 +22,9 @@ public class GroupController {
      <p>API method to create a new group</p>
      */
     @RequestMapping(method = RequestMethod.POST)
-    public @ResponseBody UserGroup createGroup(@Valid @RequestBody UserGroup group){
+    public ResponseEntity<UserGroup> createGroup(@Valid @RequestBody UserGroup group){
         UserGroup createdUserGroup = sharingRegistryService.createGroup(group);
-        if(createdUserGroup != null){
-            return createdUserGroup;
-        }else{
-            throw new SharingRegistryException("Failed to create group");
-        }
+        return new ResponseEntity<>(createdUserGroup, HttpStatus.CREATED);
     }
 
     /**
@@ -39,13 +32,8 @@ public class GroupController {
      */
     @RequestMapping(method = RequestMethod.PUT)
     public ResponseEntity<String> updateGroup(@Valid @RequestBody UserGroup group){
-        boolean response = sharingRegistryService.updateGroup(group);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        else{
-            throw new SharingRegistryException("Failed to update the group");
-        }
+        sharingRegistryService.updateGroup(group);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -66,26 +54,17 @@ public class GroupController {
      */
     @RequestMapping(value = "/{groupId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> deleteGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId){
-        boolean response = sharingRegistryService.deleteGroup(domainId, groupId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        else{
-            throw new SharingRegistryException("Failed to delete the group");
-        }
+        sharingRegistryService.deleteGroup(domainId, groupId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
      <p>API method to get a group</p>
      */
     @RequestMapping(value = "/{groupId}", method = RequestMethod.GET)
-    public @ResponseBody UserGroup getGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId){
+    public ResponseEntity<UserGroup> getGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId){
         UserGroup userGroup = sharingRegistryService.getGroup(domainId,groupId);
-        if(userGroup != null){
-            return userGroup;
-        }else{
-            throw new ResourceNotFoundException("Could not find the user group with groupId: "+ groupId + " in domainId: "+ domainId);
-        }
+        return new ResponseEntity<>(userGroup,HttpStatus.OK);
     }
 
     /**
@@ -100,14 +79,9 @@ public class GroupController {
      <p>API method to add list of users to a group</p>
      */
     @RequestMapping(value = "/{groupId}/users", method = RequestMethod.POST)
-    public ResponseEntity<String> addUsersToGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId, @RequestBody List<String> userIds){
-        boolean response = sharingRegistryService.addUsersToGroup(domainId, userIds, groupId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        else{
-            throw new SharingRegistryException("Failed to add users to the group");
-        }
+    public ResponseEntity<String> addUsersToGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId, @RequestParam("ids") List<String> userIds){
+        sharingRegistryService.addUsersToGroup(domainId, userIds, groupId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -115,13 +89,8 @@ public class GroupController {
      */
     @RequestMapping(value = "/{groupId}/users", method = RequestMethod.DELETE)
     public ResponseEntity<String> removeUsersFromGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId, @RequestParam("ids") List<String> userIds){
-        boolean response = sharingRegistryService.removeUsersFromGroup(domainId, userIds, groupId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        else{
-            throw new SharingRegistryException("Failed to remove users from the group");
-        }
+        sharingRegistryService.removeUsersFromGroup(domainId, userIds, groupId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -129,41 +98,26 @@ public class GroupController {
      */
     @RequestMapping(value = "/{groupId}/owners/{ownerId}", method = RequestMethod.PUT)
     public ResponseEntity<String> transferGroupOwnership(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @PathVariable("ownerId") String newOwnerId){
-        boolean response = sharingRegistryService.transferGroupOwnership(domainId,groupId, newOwnerId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        else{
-            throw new SharingRegistryException("Failed to change group owner");
-        }
+        sharingRegistryService.transferGroupOwnership(domainId,groupId, newOwnerId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
      <p>API method to add Admin for a group</p>
      */
     @RequestMapping(value = "/{groupId}/admins", method = RequestMethod.POST)
-    public ResponseEntity<String> addGroupAdmins(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @RequestBody List<GroupAdmin> admins){
-        boolean response = sharingRegistryService.addGroupAdmins(domainId,groupId, admins);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        else{
-            throw new SharingRegistryException("Failed to add group admins");
-        }
+    public ResponseEntity<String> addGroupAdmins(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @RequestParam("adminIds") List<String> admins){
+        sharingRegistryService.addGroupAdmins(domainId,groupId, admins);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
      <p>API method to remove Admin for a group</p>
      */
     @RequestMapping(value = "/{groupId}/admins", method = RequestMethod.DELETE)
-    public ResponseEntity<String> removeGroupAdmins(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @RequestParam("ids") List<String> adminIds){
-        boolean response = sharingRegistryService.removeGroupAdmins(domainId,groupId, adminIds);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }
-        else{
-            throw new SharingRegistryException("Failed to remove group admins");
-        }
+    public ResponseEntity<String> removeGroupAdmins(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @RequestParam("adminIds") List<String> adminIds){
+        sharingRegistryService.removeGroupAdmins(domainId,groupId, adminIds);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -196,7 +150,7 @@ public class GroupController {
      <p>API method to get list of child users in a group. Only the direct members will be returned.</p>
      */
     @RequestMapping(value = "/{groupId}/users", method = RequestMethod.GET)
-    public @ResponseBody List<User> getGroupMembersOfTypeUser(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
+    public @ResponseBody List<User> getGroupMembersOfTypeUser(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(value = "limit", defaultValue = "-1") int limit){
         return sharingRegistryService.getGroupMembersOfTypeUser(domainId, groupId, offset, limit);
     }
 
@@ -204,7 +158,7 @@ public class GroupController {
      <p>API method to get list of child groups in a group. Only the direct members will be returned.</p>
      */
     @RequestMapping(value = "/{groupId}/subgroups", method = RequestMethod.GET)
-    public @ResponseBody List<UserGroup> getGroupMembersOfTypeGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
+    public @ResponseBody List<UserGroup> getGroupMembersOfTypeGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam(name= "offset", defaultValue = "0") int offset, @RequestParam(value = "limit", defaultValue = "-1") int limit){
         return sharingRegistryService.getGroupMembersOfTypeGroup(domainId, groupId, offset, limit);
     }
 
@@ -212,13 +166,9 @@ public class GroupController {
      <p>API method to add a child group to a parent group.</p>
      */
     @RequestMapping(value = "/{groupId}/subgroups", method = RequestMethod.POST)
-    public ResponseEntity<String> addChildGroupsToParentGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestBody List<String> childIds){
-        boolean response = sharingRegistryService.addChildGroupsToParentGroup(domainId, childIds, groupId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }else{
-            throw new SharingRegistryException("Failed to add child groups to parent group");
-        }
+    public ResponseEntity<String> addChildGroupsToParentGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam("subgroupIds") List<String> childIds){
+        sharingRegistryService.addChildGroupsToParentGroup(domainId, childIds, groupId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -226,12 +176,8 @@ public class GroupController {
      */
     @RequestMapping(value = "/{groupId}/subgroups/{childGroupId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> removeChildGroupFromParentGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @PathVariable("childGroupId") String childGroupId){
-        boolean response = sharingRegistryService.removeChildGroupFromParentGroup(domainId, childGroupId, groupId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }else{
-            throw new SharingRegistryException("Failed to remove child groups from parent group");
-        }
+        sharingRegistryService.removeChildGroupFromParentGroup(domainId, childGroupId, groupId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -241,29 +187,4 @@ public class GroupController {
     public @ResponseBody List<UserGroup> getAllMemberGroupsForUser(@PathVariable("domainId") String domainId, @PathVariable("userId") String userId){
         return sharingRegistryService.getAllMemberGroupsForUser(domainId, userId);
     }
-
-//    public static void main(String[] args) throws Exception{
-//        String url = "http://localhost:7070";
-//        String r = "/domains/default/groups";
-//        UserGroup test = new UserGroup();
-//        test.setGroupId("teqq1");
-//        test.setDomainId("default");
-//        test.setOwnerId("default-admin@default");
-//        test.setName("");
-//        test.setGroupType(GroupType.USER_LEVEL_GROUP);
-//        ServiceRequest serviceRequest = new ServiceRequest();
-//        HttpResponse response = serviceRequest.httpPost(url, r, test);
-//        System.out.println(response);
-//        if(response.getStatusLine().getStatusCode() == org.apache.http.HttpStatus.SC_OK) {
-//            BufferedReader rd = new BufferedReader(
-//                    new InputStreamReader(response.getEntity().getContent()));
-//            StringBuffer result = new StringBuffer();
-//            String line = "";
-//            while ((line = rd.readLine()) != null) {
-//                result.append(line);
-//            }
-//            JSONObject jsonObject = new JSONObject(result.toString());
-//            System.out.println(jsonObject.get("groupId"));
-//        }
-//    }
 }
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java
index 81c9941..e7d66fb 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java
@@ -1,18 +1,13 @@
 package org.apache.custos.sharing.service.api.controllers;
 
 import org.apache.custos.sharing.service.core.models.PermissionType;
-import org.apache.custos.sharing.service.core.exceptions.ResourceNotFoundException;
-import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
 import org.apache.custos.sharing.service.core.service.SharingRegistryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
-
 import javax.validation.Valid;
-import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
 @RestController
 @RequestMapping("domain/{domainId}/permissionTypes")
@@ -24,13 +19,9 @@ public class PermissionTypeController {
      <p>API method to create permission type</p>
      */
     @RequestMapping(method = RequestMethod.POST)
-    public @ResponseBody PermissionType createPermissionType(@Valid @RequestBody PermissionType permissionType){
+    public ResponseEntity<PermissionType> createPermissionType(@Valid @RequestBody PermissionType permissionType){
         PermissionType createdPermissionType = sharingRegistryService.createPermissionType(permissionType);
-        if(createdPermissionType != null){
-            return createdPermissionType;
-        }else{
-            throw new SharingRegistryException("Could not create the permission type");
-        }
+        return new ResponseEntity<>(createdPermissionType, HttpStatus.CREATED);
     }
 
     /**
@@ -38,13 +29,8 @@ public class PermissionTypeController {
      */
     @RequestMapping(method = RequestMethod.PUT)
     public ResponseEntity<String> updatePermissionType(@Valid @RequestBody PermissionType permissionType){
-
-        boolean response = sharingRegistryService.updatePermissionType(permissionType);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }else{
-            throw new SharingRegistryException("Could not update the permission type");
-        }
+        sharingRegistryService.updatePermissionType(permissionType);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -65,25 +51,17 @@ public class PermissionTypeController {
      */
     @RequestMapping(value= "/{permissionTypeId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> deletePermissionType(@PathVariable("permissionTypeId") String permissionTypeId, @PathVariable("domainId") String domainId){
-        boolean response = sharingRegistryService.deletePermissionType(domainId,permissionTypeId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }else{
-            throw new SharingRegistryException("Could not delete the permission type");
-        }
+        sharingRegistryService.deletePermissionType(domainId,permissionTypeId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
      <p>API method to get permission type</p>
      */
     @RequestMapping(value= "/{permissionTypeId}", method = RequestMethod.GET)
-    public @ResponseBody PermissionType getPermissionType(@PathVariable("permissionTypeId") String permissionTypeId, @PathVariable("domainId") String domainId){
+    public ResponseEntity<PermissionType> getPermissionType(@PathVariable("permissionTypeId") String permissionTypeId, @PathVariable("domainId") String domainId){
         PermissionType permissionType = sharingRegistryService.getPermissionType(domainId, permissionTypeId);
-        if(permissionType != null){
-            return permissionType;
-        }else{
-            throw new ResourceNotFoundException("Could not find the permission type with permission Id: "+ permissionTypeId + " in domainId: " + domainId);
-        }
+        return new ResponseEntity<>(permissionType, HttpStatus.OK);
     }
 
     /**
@@ -91,7 +69,7 @@ public class PermissionTypeController {
      */
     @RequestMapping(method = RequestMethod.GET)
     public @ResponseBody
-    List<PermissionType> getPermissionTypes(@PathVariable("domainId") String domainId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
+    List<PermissionType> getPermissionTypes(@PathVariable("domainId") String domainId, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "-1") int limit){
         return sharingRegistryService.getPermissionTypes(domainId, offset, limit);
     }
 
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java
index b880170..f9b3e06 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java
@@ -1,8 +1,6 @@
 package org.apache.custos.sharing.service.api.controllers;
 
 import org.apache.custos.sharing.service.core.models.User;
-import org.apache.custos.sharing.service.core.exceptions.ResourceNotFoundException;
-import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
 import org.apache.custos.sharing.service.core.service.SharingRegistryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -23,13 +21,9 @@ public class UsersController {
      <p>API method to register a user in the system</p>
      */
     @RequestMapping(method = RequestMethod.POST)
-    public @ResponseBody User createUser(@Valid @RequestBody User user){
+    public ResponseEntity<User> createUser(@Valid @RequestBody User user){
         User createdUser = sharingRegistryService.createUser(user);
-        if(createdUser != null){
-            return createdUser;
-        }else{
-            throw new SharingRegistryException("Failed to create the user");
-        }
+        return new ResponseEntity<>(createdUser, HttpStatus.CREATED);
     }
 
     /**
@@ -37,12 +31,8 @@ public class UsersController {
      */
     @RequestMapping(method = RequestMethod.PUT)
     public ResponseEntity<String> updateUser(@Valid @RequestBody User user){
-        boolean response = sharingRegistryService.updatedUser(user);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }else{
-            throw new SharingRegistryException("Failed to update the user");
-        }
+        sharingRegistryService.updatedUser(user);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
@@ -63,25 +53,17 @@ public class UsersController {
      */
     @RequestMapping(value="/{userId}",method = RequestMethod.DELETE)
     public ResponseEntity<String> deleteUser(@PathVariable("userId") String userId, @PathVariable("domainId") String domainId){
-        boolean response = sharingRegistryService.deleteUser(domainId, userId);
-        if(response){
-            return new ResponseEntity<>(HttpStatus.OK);
-        }else{
-            throw new SharingRegistryException("Failed to delete the user");
-        }
+        sharingRegistryService.deleteUser(domainId, userId);
+        return new ResponseEntity<>(HttpStatus.OK);
     }
 
     /**
      <p>API method to get a user</p>
      */
     @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
-    public User getUser(@PathVariable("domainId") String domainId,@PathVariable("userId") String userId){
+    public ResponseEntity<User> getUser(@PathVariable("domainId") String domainId,@PathVariable("userId") String userId){
         User user = sharingRegistryService.getUser(domainId, userId);
-        if(user != null){
-            return user;
-        }else {
-            throw new ResourceNotFoundException("Could not find the user with userId: "+ userId + " for domainId: "+ domainId);
-        }
+        return new ResponseEntity<>(user, HttpStatus.OK);
     }
 
     /**
@@ -91,7 +73,7 @@ public class UsersController {
      <li>limit : Number of max results to be sent</li>
      */
     @RequestMapping(method = RequestMethod.GET)
-    public List<User> getUsers(@PathVariable("domainId") String domainId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
+    public List<User> getUsers(@PathVariable("domainId") String domainId, @RequestParam(name = "offset", defaultValue = "0") int offset, @RequestParam(name = "limit", defaultValue = "-1") int limit){
         return sharingRegistryService.getUsers(domainId,offset, limit);
     }
 }
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/resources/application.properties b/custos-sharing-registry-service/sharing-service-api/src/main/resources/application.properties
index 2d64be9..56037ac 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/resources/application.properties
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/resources/application.properties
@@ -1,2 +1,3 @@
 server.address=0.0.0.0
-server.port= 7070
\ No newline at end of file
+server.port= 7070
+management.endpoints.web.exposure.include=info,health,mappings
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/InvalidRequestException.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/InvalidRequestException.java
new file mode 100644
index 0000000..e15e0a2
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/exceptions/InvalidRequestException.java
@@ -0,0 +1,16 @@
+package org.apache.custos.sharing.service.core.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(value= HttpStatus.BAD_REQUEST, reason = "Request cannot be completed because the server refused to fulfill the request.")
+public class InvalidRequestException extends RuntimeException{
+
+    public InvalidRequestException(String errorMessage) {
+        super(errorMessage);
+    }
+
+    public InvalidRequestException(String errorMessage, Throwable err) {
+        super(errorMessage, err);
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java
index fe71464..15734d8 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java
@@ -48,7 +48,7 @@ public class Domain {
         this.createdTime = createdTime;
     }
 
-    public double getUpdatedTime() {
+    public Long getUpdatedTime() {
         return updatedTime;
     }
 
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java
index 921adc5..c9d0ecc 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java
@@ -21,6 +21,8 @@ package org.apache.custos.sharing.service.core.service;
 
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.custos.commons.utils.DBInitializer;
+import org.apache.custos.sharing.service.core.exceptions.InvalidRequestException;
+import org.apache.custos.sharing.service.core.exceptions.ResourceNotFoundException;
 import org.apache.custos.sharing.service.core.models.*;
 import org.apache.custos.sharing.service.core.db.entities.*;
 import org.apache.custos.sharing.service.core.db.repositories.*;
@@ -28,14 +30,13 @@ import org.apache.custos.sharing.service.core.db.utils.DBConstants;
 import org.apache.custos.sharing.service.core.db.utils.SharingRegistryDBInitConfig;
 import org.apache.custos.sharing.service.core.exceptions.DuplicateEntryException;
 import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
-import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
-
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class SharingRegistryService {
@@ -59,7 +60,6 @@ public class SharingRegistryService {
 
     public Domain createDomain(Domain domain) throws SharingRegistryException, DuplicateEntryException {
         try{
-            domain.setDomainId(domain.getDomainId());
             if((new DomainRepository()).get(domain.getDomainId()) != null)
                 throw new DuplicateEntryException("There exist domain with given domain id");
 
@@ -78,21 +78,31 @@ public class SharingRegistryService {
             (new PermissionTypeRepository()).create(permissionType);
 
             return createdDomain;
+        }catch(DuplicateEntryException ex){
+            throw ex;
         }catch (Throwable ex){
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean updateDomain(Domain domain) throws SharingRegistryException {
+    public boolean updateDomain(Domain domain) throws SharingRegistryException, ResourceNotFoundException {
         try{
             Domain oldDomain = (new DomainRepository()).get(domain.getDomainId());
+            if(oldDomain == null){
+                throw new ResourceNotFoundException("Could not find the domain with domainId: "+ domain.getDomainId());
+            }
             domain.setCreatedTime(oldDomain.getCreatedTime());
             domain.setUpdatedTime(System.currentTimeMillis());
             domain = getUpdatedObject(oldDomain, domain);
-            (new DomainRepository()).update(domain);
-            return true;
-        }catch (Throwable ex) {
+            Domain updatedDomain = (new DomainRepository()).update(domain);
+            if(updatedDomain != null && updatedDomain.getDomainId().equals(oldDomain.getDomainId())){
+                return true;
+            }
+            throw new SharingRegistryException("Could not update the domain with domainId: "+ oldDomain.getDomainId());
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
+        }catch(Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
@@ -112,19 +122,32 @@ public class SharingRegistryService {
         }
     }
 
-    public boolean deleteDomain(String domainId) throws SharingRegistryException {
+    public boolean deleteDomain(String domainId) throws SharingRegistryException, ResourceNotFoundException {
         try{
-            return (new DomainRepository()).delete(domainId);
+            if(!isDomainExists(domainId)){
+                throw new ResourceNotFoundException("Could not find domain with domainId: "+ domainId);
+            }
+            boolean deleted = (new DomainRepository()).delete(domainId);
+            if(deleted) return true;
+            else throw new SharingRegistryException("Could not delete the domain with domainId: "+ domainId);
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public Domain getDomain(String domainId) throws SharingRegistryException {
+    public Domain getDomain(String domainId) throws SharingRegistryException, ResourceNotFoundException {
         try{
-            return (new DomainRepository()).get(domainId);
-        }catch (Throwable ex) {
+            Domain domain = (new DomainRepository()).get(domainId);
+            if(domain == null){
+                throw new ResourceNotFoundException("Could not find domain with domainId:" + domainId);
+            }
+            return domain;
+        }catch (ResourceNotFoundException ex){
+            throw ex;
+        } catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
@@ -163,9 +186,13 @@ public class SharingRegistryService {
             userGroup.setOwnerId(user.getUserId());
             userGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
             userGroup.setGroupCardinality(GroupCardinality.SINGLE_USER);
+            userGroup.setCreatedTime(System.currentTimeMillis());
+            userGroup.setUpdatedTime(System.currentTimeMillis());
             (new UserGroupRepository()).create(userGroup);
 
             return createdUser;
+        }catch(DuplicateEntryException ex){
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -174,6 +201,9 @@ public class SharingRegistryService {
 
     public boolean updatedUser(User user) throws SharingRegistryException {
         try{
+            if(!isUserExists(user.getDomainId(), user.getUserId())){
+                throw new ResourceNotFoundException("Could not find user with userId: " + user.getUserId());
+            }
             UserPK userPK = new UserPK();
             userPK.setUserId(user.getUserId());
             userPK.setDomainId(user.getDomainId());
@@ -181,7 +211,7 @@ public class SharingRegistryService {
             user.setCreatedTime(oldUser.getCreatedTime());
             user.setUpdatedTime(System.currentTimeMillis());
             user = getUpdatedObject(oldUser, user);
-            (new UserRepository()).update(user);
+            User updatedUser = (new UserRepository()).update(user);
 
             UserGroupPK userGroupPK = new UserGroupPK();
             userGroupPK.setGroupId(user.getUserId());
@@ -190,7 +220,10 @@ public class SharingRegistryService {
             userGroup.setName(user.getUserName());
             userGroup.setDescription("user " + user.getUserName() + " group");
             updateGroup(userGroup);
-            return true;
+            if(updatedUser != null && updatedUser.getUserId().equals(user.getUserId())){
+                return true;
+            }
+            throw new SharingRegistryException("Could not update user with userId: " + user.getUserId());
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -214,41 +247,52 @@ public class SharingRegistryService {
         }
     }
 
-    public boolean deleteUser(String domainId, String userId) throws SharingRegistryException {
+    public boolean deleteUser(String domainId, String userId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isUserExists(domainId, userId)) throw new ResourceNotFoundException("Could not find userId: "+userId +" in domainId:" + domainId);
             UserPK userPK = new UserPK();
             userPK.setUserId(userId);
             userPK.setDomainId(domainId);
-            (new UserRepository()).delete(userPK);
+            boolean deleteuser = (new UserRepository()).delete(userPK);
 
             UserGroupPK userGroupPK = new UserGroupPK();
             userGroupPK.setGroupId(userId);
             userGroupPK.setDomainId(domainId);
-            (new UserGroupRepository()).delete(userGroupPK);
-            return true;
-        }catch (Throwable ex) {
+            boolean deleteusergroup = (new UserGroupRepository()).delete(userGroupPK);
+            if(deleteuser && deleteusergroup) return true;
+            throw new SharingRegistryException("Could not delete user: "+ userId);
+        }catch (ResourceNotFoundException ex){
+            throw ex;
+        }
+        catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public User getUser(String domainId, String userId) throws SharingRegistryException {
+    public User getUser(String domainId, String userId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isUserExists(domainId, userId)) throw new ResourceNotFoundException("Could not find userId: "+userId +" in domainId:" + domainId);
             UserPK userPK = new UserPK();
             userPK.setUserId(userId);
             userPK.setDomainId(domainId);
             return (new UserRepository()).get(userPK);
+        }catch (ResourceNotFoundException ex){
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public List<User> getUsers(String domain, int offset, int limit) throws SharingRegistryException {
+    public List<User> getUsers(String domain, int offset, int limit) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domain)) throw new ResourceNotFoundException("Could not find domain with domainId: "+ domain);
             HashMap<String, String> filters = new HashMap<>();
             filters.put(DBConstants.UserTable.DOMAIN_ID, domain);
             return (new UserRepository()).select(filters, offset, limit);
+        }catch (ResourceNotFoundException ex){
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -275,10 +319,9 @@ public class SharingRegistryService {
             UserGroup createdUserGroup = (new UserGroupRepository()).create(group);
 
             addUsersToGroup(group.getDomainId(), Arrays.asList(group.getOwnerId()), group.getGroupId());
-            addGroupAdmins(group.getDomainId(), group.getGroupId(), group.getGroupAdmins());
+            addGroupAdmins(group.getDomainId(), group.getGroupId(), group.getGroupAdmins().stream().map(y->y.getAdminId()).collect(Collectors.toList()));
             return createdUserGroup;
         } catch (DuplicateEntryException ex) {
-            logger.error(ex.getMessage(), ex);
             throw ex;
         } catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
@@ -286,22 +329,27 @@ public class SharingRegistryService {
         }
     }
 
-    public boolean updateGroup(UserGroup group) throws SharingRegistryException {
-        try{
+    public boolean updateGroup(UserGroup group) throws SharingRegistryException, ResourceNotFoundException, InvalidRequestException {
+        try {
+            if (isGroupExists(group.getDomainId(), group.getGroupId())) {
+                throw new ResourceNotFoundException("Could not find the group with groupId: " + group.getGroupId());
+            }
             group.setUpdatedTime(System.currentTimeMillis());
             UserGroupPK userGroupPK = new UserGroupPK();
             userGroupPK.setGroupId(group.getGroupId());
             userGroupPK.setDomainId(group.getDomainId());
             UserGroup oldGroup = (new UserGroupRepository()).get(userGroupPK);
+            if(!group.getOwnerId().equals(oldGroup.getOwnerId()))
+                throw new InvalidRequestException("Group owner cannot be changed");
             group.setGroupCardinality(oldGroup.getGroupCardinality());
             group.setCreatedTime(oldGroup.getCreatedTime());
             group = getUpdatedObject(oldGroup, group);
-
-            if(!group.getOwnerId().equals(oldGroup.getOwnerId()))
-                throw new SharingRegistryException("Group owner cannot be changed");
-
-            (new UserGroupRepository()).update(group);
+            UserGroup updatedGroup = (new UserGroupRepository()).update(group);
+            if (!updatedGroup.getGroupId().equals(oldGroup.getGroupId()))
+                throw new SharingRegistryException("Group could not be updated");
             return true;
+        }catch (InvalidRequestException | ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -318,56 +366,76 @@ public class SharingRegistryService {
 
     public boolean isGroupExists(String domainId, String groupId) throws SharingRegistryException {
         try{
+            if (isGroupExists(domainId, groupId)) {
+                throw new ResourceNotFoundException("Could not find the group with groupId: " + groupId);
+            }
             UserGroupPK userGroupPK = new UserGroupPK();
             userGroupPK.setDomainId(domainId);
             userGroupPK.setGroupId(groupId);
             return (new UserGroupRepository()).isExists(userGroupPK);
-        }catch (Throwable ex) {
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
+        }
+        catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean deleteGroup(String domainId, String groupId) throws SharingRegistryException {
+    public boolean deleteGroup(String domainId, String groupId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if (isGroupExists(domainId, groupId)) {
+                throw new ResourceNotFoundException("Could not find the group with groupId: " + groupId);
+            }
             UserGroupPK userGroupPK = new UserGroupPK();
             userGroupPK.setGroupId(groupId);
             userGroupPK.setDomainId(domainId);
-            (new UserGroupRepository()).delete(userGroupPK);
+            boolean deleted = (new UserGroupRepository()).delete(userGroupPK);
+            if(!deleted) throw new SharingRegistryException("Could not deleted the group with groupId: " + groupId);
             return true;
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public UserGroup getGroup(String domainId, String groupId) throws SharingRegistryException {
+    public UserGroup getGroup(String domainId, String groupId) throws SharingRegistryException, ResourceNotFoundException {
         try{
             UserGroupPK userGroupPK = new UserGroupPK();
             userGroupPK.setGroupId(groupId);
             userGroupPK.setDomainId(domainId);
-            return (new UserGroupRepository()).get(userGroupPK);
+            UserGroup userGroup = (new UserGroupRepository()).get(userGroupPK);
+            if(userGroup != null) return userGroup;
+            throw new ResourceNotFoundException("Could not find the group with groupId: " + groupId);
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public List<UserGroup> getGroups(String domain, int offset, int limit) throws SharingRegistryException {
+    public List<UserGroup> getGroups(String domain, int offset, int limit) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domain)) throw new ResourceNotFoundException("Could not find the domain with domainId: "+domain);
             HashMap<String, String> filters = new HashMap<>();
             filters.put(DBConstants.UserGroupTable.DOMAIN_ID, domain);
             // Only return groups with MULTI_USER cardinality which is the only type of cardinality allowed for client created groups
             filters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.name());
             return (new UserGroupRepository()).select(filters, offset, limit);
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean addUsersToGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException {
+    public boolean addUsersToGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domainId)) throw new ResourceNotFoundException("Could not find the domain with domainId: "+domainId);
             for(int i=0; i < userIds.size(); i++){
                 GroupMembership groupMembership = new GroupMembership();
                 groupMembership.setParentId(groupId);
@@ -379,17 +447,20 @@ public class SharingRegistryService {
                 (new GroupMembershipRepository()).create(groupMembership);
             }
             return true;
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean removeUsersFromGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException {
+    public boolean removeUsersFromGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException, ResourceNotFoundException, InvalidRequestException{
         try{
+            if(!isDomainExists(domainId)) throw new ResourceNotFoundException("Could not find the domain with domainId: "+domainId);
             for (String userId: userIds) {
                 if (hasOwnerAccess(domainId, groupId, userId)) {
-                    throw new SharingRegistryException("List of User Ids contains Owner Id. Cannot remove owner from the group");
+                    throw new InvalidRequestException("List of User Ids contains Owner Id. Cannot remove owner from the group");
                 }
             }
 
@@ -401,6 +472,8 @@ public class SharingRegistryService {
                 (new GroupMembershipRepository()).delete(groupMembershipPK);
             }
             return true;
+        }catch (ResourceNotFoundException | InvalidRequestException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -409,13 +482,14 @@ public class SharingRegistryService {
 
     public boolean transferGroupOwnership(String domainId, String groupId, String newOwnerId) throws SharingRegistryException {
         try {
+            if(!isDomainExists(domainId) || !isGroupExists(domainId, groupId) || !isUserExists(domainId, newOwnerId)) throw new ResourceNotFoundException("Could not find resource");
             List<User> groupUser = getGroupMembersOfTypeUser(domainId, groupId, 0, -1);
             if (!isUserBelongsToGroup(groupUser, newOwnerId)) {
-                throw new SharingRegistryException("New group owner is not part of the group");
+                throw new InvalidRequestException("New group owner is not part of the group");
             }
 
             if (hasOwnerAccess(domainId, groupId, newOwnerId)) {
-                throw new DuplicateEntryException("User already the current owner of the group");
+                throw new InvalidRequestException("User already the current owner of the group");
             }
             // remove the new owner as Admin if present
             if (hasAdminAccess(domainId, groupId, newOwnerId)) {
@@ -436,8 +510,9 @@ public class SharingRegistryService {
             (new UserGroupRepository()).update(newUserGroup);
 
             return true;
-        }
-        catch (Throwable ex) {
+        }catch (ResourceNotFoundException | InvalidRequestException ex) {
+            throw ex;
+        }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
@@ -452,28 +527,32 @@ public class SharingRegistryService {
         return false;
     }
 
-    public boolean addGroupAdmins(String domainId, String groupId, List<GroupAdmin> admins) throws SharingRegistryException {
+    public boolean addGroupAdmins(String domainId, String groupId, List<String> admins) throws SharingRegistryException, ResourceNotFoundException,DuplicateEntryException, InvalidRequestException  {
         try{
+            if(!isDomainExists(domainId) || !isGroupExists(domainId, groupId)) throw new ResourceNotFoundException("Could not find resource");
             List<User> groupUser = getGroupMembersOfTypeUser(domainId, groupId, 0, -1);
 
-            for (GroupAdmin admin: admins) {
-                String adminId = admin.getAdminId();
+            for (String adminId: admins) {
                 if (! isUserBelongsToGroup(groupUser, adminId)) {
-                    throw new SharingRegistryException("Admin not the user of the group. GroupId : "+ groupId + ", AdminId : "+ adminId);
+                    throw new InvalidRequestException("Admin not the user of the group. GroupId : "+ groupId + ", AdminId : "+ adminId);
                 }
                 GroupAdminPK groupAdminPK = new GroupAdminPK();
                 groupAdminPK.setGroupId(groupId);
                 groupAdminPK.setAdminId(adminId);
                 groupAdminPK.setDomainId(domainId);
-
+                GroupAdmin groupAdmin = new GroupAdmin();
+                groupAdmin.setAdminId(adminId);
+                groupAdmin.setDomainId(domainId);
+                groupAdmin.setGroupId(groupId);
                 if((new GroupAdminRepository()).get(groupAdminPK) != null)
                     throw new DuplicateEntryException("User already an admin for the group");
 
-                (new GroupAdminRepository()).create(admin);
+                (new GroupAdminRepository()).create(groupAdmin);
             }
             return true;
-        }
-        catch (Throwable ex) {
+        }catch (ResourceNotFoundException | DuplicateEntryException | InvalidRequestException ex) {
+            throw ex;
+        }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
@@ -496,8 +575,9 @@ public class SharingRegistryService {
         }
     }
 
-    public boolean hasAdminAccess(String domainId, String groupId, String adminId) throws SharingRegistryException {
+    public boolean hasAdminAccess(String domainId, String groupId, String adminId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domainId) || !isGroupExists(domainId, groupId) || !isUserExists(domainId, adminId)) throw new ResourceNotFoundException("Could not find resource");
             GroupAdminPK groupAdminPK = new GroupAdminPK();
             groupAdminPK.setGroupId(groupId);
             groupAdminPK.setAdminId(adminId);
@@ -506,8 +586,9 @@ public class SharingRegistryService {
             if((new GroupAdminRepository()).get(groupAdminPK) != null)
                 return true;
             return false;
-        }
-        catch (Throwable ex) {
+        }catch (ResourceNotFoundException ex){
+            throw ex;
+        }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
@@ -515,6 +596,7 @@ public class SharingRegistryService {
 
     public boolean hasOwnerAccess(String domainId, String groupId, String ownerId) throws SharingRegistryException {
         try {
+            if(!isDomainExists(domainId) || !isGroupExists(domainId, groupId) || !isUserExists(domainId, ownerId)) throw new ResourceNotFoundException("Could not find resource");
             UserGroupPK userGroupPK = new UserGroupPK();
             userGroupPK.setGroupId(groupId);
             userGroupPK.setDomainId(domainId);
@@ -523,8 +605,9 @@ public class SharingRegistryService {
             if(getGroup.getOwnerId().equals(ownerId))
                 return true;
             return false;
-        }
-        catch (Throwable ex) {
+        }catch (ResourceNotFoundException ex){
+            throw ex;
+        }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
@@ -532,30 +615,38 @@ public class SharingRegistryService {
 
     public List<User> getGroupMembersOfTypeUser(String domainId, String groupId, int offset, int limit) throws SharingRegistryException {
         try{
+            if(!isDomainExists(domainId) || !isGroupExists(domainId, groupId)) throw new ResourceNotFoundException("Could not find resource");
             //TODO limit offset
             List<User> groupMemberUsers = (new GroupMembershipRepository()).getAllChildUsers(domainId, groupId);
             return groupMemberUsers;
+        }catch (ResourceNotFoundException ex){
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public List<UserGroup> getGroupMembersOfTypeGroup(String domainId, String groupId, int offset, int limit) throws SharingRegistryException {
+    public List<UserGroup> getGroupMembersOfTypeGroup(String domainId, String groupId, int offset, int limit) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domainId) || !isGroupExists(domainId, groupId)) throw new ResourceNotFoundException("Could not find resource");
             //TODO limit offset
             List<UserGroup> groupMemberGroups = (new GroupMembershipRepository()).getAllChildGroups(domainId, groupId);
             return groupMemberGroups;
+        }catch (ResourceNotFoundException ex){
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean addChildGroupsToParentGroup(String domainId, List<String> childIds, String groupId) throws SharingRegistryException {
+    public boolean addChildGroupsToParentGroup(String domainId, List<String> childIds, String groupId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domainId) || !isGroupExists(domainId, groupId)) throw new ResourceNotFoundException("Could not find resource");
             for(String childId : childIds) {
                 //Todo check for cyclic dependencies
+                if(!isGroupExists(domainId, childId)) throw new ResourceNotFoundException("Could not find resource");
                 GroupMembership groupMembership = new GroupMembership();
                 groupMembership.setParentId(groupId);
                 groupMembership.setChildId(childId);
@@ -566,6 +657,8 @@ public class SharingRegistryService {
                 (new GroupMembershipRepository()).create(groupMembership);
             }
             return true;
+        }catch (ResourceNotFoundException ex){
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -574,22 +667,28 @@ public class SharingRegistryService {
 
     public boolean removeChildGroupFromParentGroup(String domainId, String childId, String groupId) throws SharingRegistryException {
         try{
+            if(!isDomainExists(domainId) || !isGroupExists(domainId, groupId) || !isGroupExists(domainId, childId)) throw new ResourceNotFoundException("Could not find resource");
             GroupMembershipPK groupMembershipPK = new GroupMembershipPK();
             groupMembershipPK.setParentId(groupId);
             groupMembershipPK.setChildId(childId);
             groupMembershipPK.setDomainId(domainId);
             (new GroupMembershipRepository()).delete(groupMembershipPK);
             return true;
+        }catch (ResourceNotFoundException ex){
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public List<UserGroup> getAllMemberGroupsForUser(String domainId, String userId) throws SharingRegistryException {
+    public List<UserGroup> getAllMemberGroupsForUser(String domainId, String userId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domainId) || !isUserExists(domainId, userId)) throw new ResourceNotFoundException("Could not find resource");
             GroupMembershipRepository groupMembershipRepository = new GroupMembershipRepository();
             return groupMembershipRepository.getAllMemberGroupsForUser(domainId, userId);
+        }catch (ResourceNotFoundException ex){
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -611,14 +710,17 @@ public class SharingRegistryService {
             entityType.setCreatedTime(System.currentTimeMillis());
             entityType.setUpdatedTime(System.currentTimeMillis());
             return (new EntityTypeRepository()).create(entityType);
-        }catch (Throwable ex) {
+        }catch (DuplicateEntryException ex) {
+            throw ex;
+        }catch(Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean updateEntityType(EntityType entityType) throws SharingRegistryException {
+    public boolean updateEntityType(EntityType entityType) throws SharingRegistryException, ResourceNotFoundException{
         try{
+            if(!isEntityTypeExists(entityType.getDomainId(), entityType.getEntityTypeId())) throw new ResourceNotFoundException("Could not find entity type with id: " + entityType.getEntityTypeId());
             entityType.setUpdatedTime(System.currentTimeMillis());
             EntityTypePK entityTypePK = new EntityTypePK();
             entityTypePK.setDomainId(entityType.getDomainId());
@@ -626,8 +728,11 @@ public class SharingRegistryService {
             EntityType oldEntityType = (new EntityTypeRepository()).get(entityTypePK);
             entityType.setCreatedTime(oldEntityType.getCreatedTime());
             entityType = getUpdatedObject(oldEntityType, entityType);
-            (new EntityTypeRepository()).update(entityType);
-            return true;
+            EntityType updatedEntityType = (new EntityTypeRepository()).update(entityType);
+            if(updatedEntityType != null && updatedEntityType.getEntityTypeId().equals(entityType.getEntityTypeId())) return true;
+            throw new SharingRegistryException("Could not update the entity type");
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -639,48 +744,60 @@ public class SharingRegistryService {
      *
      * @param entityTypeId
      */
-    public boolean isEntityTypeExists(String domainId, String entityTypeId) throws SharingRegistryException {
+    public boolean isEntityTypeExists(String domainId, String entityTypeId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityTypeExists(domainId, entityTypeId)) throw new ResourceNotFoundException("Could not find entity type with id: " + entityTypeId);
             EntityTypePK entityTypePK = new EntityTypePK();
             entityTypePK.setDomainId(domainId);
             entityTypePK.setEntityTypeId(entityTypeId);
             return (new EntityTypeRepository()).isExists(entityTypePK);
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean deleteEntityType(String domainId, String entityTypeId) throws SharingRegistryException {
+    public boolean deleteEntityType(String domainId, String entityTypeId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityTypeExists(domainId, entityTypeId)) throw new ResourceNotFoundException("Could not find entity type with id: " + entityTypeId);
             EntityTypePK entityTypePK = new EntityTypePK();
             entityTypePK.setDomainId(domainId);
             entityTypePK.setEntityTypeId(entityTypeId);
             (new EntityTypeRepository()).delete(entityTypePK);
             return true;
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public EntityType getEntityType(String domainId, String entityTypeId) throws SharingRegistryException {
+    public EntityType getEntityType(String domainId, String entityTypeId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityTypeExists(domainId, entityTypeId)) throw new ResourceNotFoundException("Could not find entity type with id: " + entityTypeId);
             EntityTypePK entityTypePK = new EntityTypePK();
             entityTypePK.setDomainId(domainId);
             entityTypePK.setEntityTypeId(entityTypeId);
             return (new EntityTypeRepository()).get(entityTypePK);
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public List<EntityType> getEntityTypes(String domain, int offset, int limit) throws SharingRegistryException {
+    public List<EntityType> getEntityTypes(String domain, int offset, int limit) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domain)) throw new ResourceNotFoundException("Could not find domain with id: " + domain);
             HashMap<String, String> filters = new HashMap<>();
             filters.put(DBConstants.EntityTypeTable.DOMAIN_ID, domain);
             return (new EntityTypeRepository()).select(filters, offset, limit);
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -702,22 +819,28 @@ public class SharingRegistryService {
             permissionType.setUpdatedTime(System.currentTimeMillis());
             (new PermissionTypeRepository()).create(permissionType);
             return permissionType;
+        }catch (DuplicateEntryException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean updatePermissionType(PermissionType permissionType) throws SharingRegistryException {
+    public boolean updatePermissionType(PermissionType permissionType) throws SharingRegistryException, ResourceNotFoundException{
         try{
+            if(!isPermissionExists(permissionType.getDomainId(), permissionType.getPermissionTypeId())) throw new ResourceNotFoundException("Permission Type not found");
             permissionType.setUpdatedTime(System.currentTimeMillis());
             PermissionTypePK permissionTypePK =  new PermissionTypePK();
             permissionTypePK.setDomainId(permissionType.getDomainId());
             permissionTypePK.setPermissionTypeId(permissionType.getPermissionTypeId());
             PermissionType oldPermissionType = (new PermissionTypeRepository()).get(permissionTypePK);
             permissionType = getUpdatedObject(oldPermissionType, permissionType);
-            (new PermissionTypeRepository()).update(permissionType);
-            return true;
+            PermissionType updatedPermissionType = (new PermissionTypeRepository()).update(permissionType);
+            if(updatedPermissionType != null && updatedPermissionType.getPermissionTypeId().equals(permissionType.getPermissionTypeId())) return true;
+            throw new SharingRegistryException("Could not update the permission type");
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -729,48 +852,60 @@ public class SharingRegistryService {
      *
      * @param permissionId
      */
-    public boolean isPermissionExists(String domainId, String permissionId) throws SharingRegistryException {
+    public boolean isPermissionExists(String domainId, String permissionId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isPermissionExists(domainId, permissionId)) throw new ResourceNotFoundException("Permission Type not found");
             PermissionTypePK permissionTypePK = new PermissionTypePK();
             permissionTypePK.setDomainId(domainId);
             permissionTypePK.setPermissionTypeId(permissionId);
             return (new PermissionTypeRepository()).isExists(permissionTypePK);
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean deletePermissionType(String domainId, String permissionTypeId) throws SharingRegistryException {
+    public boolean deletePermissionType(String domainId, String permissionTypeId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Permission Type not found");
             PermissionTypePK permissionTypePK =  new PermissionTypePK();
             permissionTypePK.setDomainId(domainId);
             permissionTypePK.setPermissionTypeId(permissionTypeId);
             (new PermissionTypeRepository()).delete(permissionTypePK);
             return true;
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public PermissionType getPermissionType(String domainId, String permissionTypeId) throws SharingRegistryException {
+    public PermissionType getPermissionType(String domainId, String permissionTypeId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Permission Type not found");
             PermissionTypePK permissionTypePK =  new PermissionTypePK();
             permissionTypePK.setDomainId(domainId);
             permissionTypePK.setPermissionTypeId(permissionTypeId);
             return (new PermissionTypeRepository()).get(permissionTypePK);
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws SharingRegistryException {
+    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domain)) throw new ResourceNotFoundException("Could not find the domain");
             HashMap<String, String> filters = new HashMap<>();
             filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domain);
             return (new PermissionTypeRepository()).select(filters, offset, limit);
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -828,7 +963,9 @@ public class SharingRegistryService {
             }
 
             return createdEntity;
-        }catch (Throwable ex) {
+        }catch(DuplicateEntryException ex) {
+            throw ex;
+        }catch(Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
@@ -853,8 +990,9 @@ public class SharingRegistryService {
                 }
             }
 
-    public boolean updateEntity(Entity entity) throws SharingRegistryException {
+    public boolean updateEntity(Entity entity) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityExists(entity.getDomainId(), entity.getEntityId())) throw new ResourceNotFoundException("Could not find entity with entityId: " + entity.getEntityId());
             //TODO Check for permission changes
             entity.setUpdatedTime(System.currentTimeMillis());
             EntityPK entityPK = new EntityPK();
@@ -877,8 +1015,11 @@ public class SharingRegistryService {
             }
             entity = getUpdatedObject(oldEntity, entity);
             entity.setSharedCount((new SharingRepository()).getSharedCount(entity.getDomainId(), entity.getEntityId()));
-            (new EntityRepository()).update(entity);
-            return true;
+            Entity updatedEntity = (new EntityRepository()).update(entity);
+            if(updatedEntity != null && updatedEntity.getEntityId().equals(entity.getEntityId())) return true;
+            throw new SharingRegistryException("Could not update the entity");
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -902,26 +1043,32 @@ public class SharingRegistryService {
         }
     }
 
-    public boolean deleteEntity(String domainId, String entityId) throws SharingRegistryException {
+    public boolean deleteEntity(String domainId, String entityId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityExists(domainId, entityId)) throw new ResourceNotFoundException("Could not find entity with entityId:" + entityId + " in domain:" + domainId);
             //TODO Check for permission changes
             EntityPK entityPK = new EntityPK();
             entityPK.setDomainId(domainId);
             entityPK.setEntityId(entityId);
             (new EntityRepository()).delete(entityPK);
             return true;
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public Entity getEntity(String domainId, String entityId) throws SharingRegistryException {
+    public Entity getEntity(String domainId, String entityId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityExists(domainId, entityId)) throw new ResourceNotFoundException("Could not find entity with entityId:" + entityId + " in domain:" + domainId);
             EntityPK entityPK = new EntityPK();
             entityPK.setDomainId(domainId);
             entityPK.setEntityId(entityId);
             return (new EntityRepository()).get(entityPK);
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -929,21 +1076,27 @@ public class SharingRegistryService {
     }
 
     public List<Entity> searchEntities(String domainId, String userId, List<SearchCriteria> filters,
-                                       int offset, int limit) throws SharingRegistryException {
+                                       int offset, int limit) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isUserExists(domainId, userId)) throw new ResourceNotFoundException("Could not find user:" + userId + " in domain:" + domainId);
             List<String> groupIds = new ArrayList<>();
             groupIds.add(userId);
             (new GroupMembershipRepository()).getAllParentMembershipsForChild(domainId, userId).stream().forEach(gm -> groupIds.add(gm.getParentId()));
             return (new EntityRepository()).searchEntities(domainId, groupIds, filters, offset, limit);
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public List<User> getListOfSharedUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
+    public List<User> getListOfSharedUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the resource");
             return (new UserRepository()).getAccessibleUsers(domainId, entityId, permissionTypeId);
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -951,18 +1104,24 @@ public class SharingRegistryService {
     }
 
     public List<User> getListOfDirectlySharedUsers(String domainId, String entityId, String permissionTypeId)
-            throws SharingRegistryException {
+            throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the resource");
             return (new UserRepository()).getDirectlyAccessibleUsers(domainId, entityId, permissionTypeId);
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public List<UserGroup> getListOfSharedGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
+    public List<UserGroup> getListOfSharedGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the resource");
             return (new UserGroupRepository()).getAccessibleGroups(domainId, entityId, permissionTypeId);
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -970,9 +1129,12 @@ public class SharingRegistryService {
     }
 
     public List<UserGroup> getListOfDirectlySharedGroups(String domainId, String entityId, String permissionTypeId)
-            throws SharingRegistryException {
+            throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the resource");
             return (new UserGroupRepository()).getDirectlyAccessibleGroups(domainId, entityId, permissionTypeId);
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -988,28 +1150,45 @@ public class SharingRegistryService {
      * @param cascadePermission
      * @return
      * @throws SharingRegistryException
-     * @throws TException
+     * @throws ResourceNotFoundException
      */
-    public boolean shareEntityWithUsers(String domainId, String entityId, List<String> userList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException {
+
+    public boolean shareEntityWithUsers(String domainId, String entityId, List<String> userList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            for(String user: userList){
+                if(!isUserExists(domainId, user)) throw new ResourceNotFoundException("Could not find the user");
+            }
+            if(!isDomainExists(domainId) || !isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the user");
             return shareEntity(domainId, entityId, userList, permissionTypeId, cascadePermission);
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean shareEntityWithGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException {
+    public boolean shareEntityWithGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            for(String group: groupList){
+                if(!isGroupExists(domainId, group)) throw new ResourceNotFoundException("Could not find the group");
+            }
+            if(!isDomainExists(domainId) || !isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the user");
             return shareEntity(domainId, entityId, groupList, permissionTypeId, cascadePermission);
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    private boolean shareEntity(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId, boolean cascadePermission)  throws SharingRegistryException {
+    private boolean shareEntity(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId, boolean cascadePermission)  throws SharingRegistryException, ResourceNotFoundException {
         try{
+            for(String groupOrUser: groupOrUserList){
+                if(!isUserExists(domainId, groupOrUser) && !isGroupExists(domainId, groupOrUser)) throw new ResourceNotFoundException("Could not find the user");
+            }
+            if(!isDomainExists(domainId) || !isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the user");
             if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
                 throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
             }
@@ -1067,31 +1246,45 @@ public class SharingRegistryService {
             entity.setSharedCount((new SharingRepository()).getSharedCount(domainId, entityId));
             (new EntityRepository()).update(entity);
             return true;
+        }catch(ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean revokeEntitySharingFromUsers(String domainId, String entityId, List<String> userList, String permissionTypeId) throws SharingRegistryException {
+    public boolean revokeEntitySharingFromUsers(String domainId, String entityId, List<String> userList, String permissionTypeId) throws SharingRegistryException, ResourceNotFoundException, InvalidRequestException {
         try{
+            for(String user: userList){
+                if(!isUserExists(domainId, user)) throw new ResourceNotFoundException("Could not find the user");
+            }
+            if(!isDomainExists(domainId) || !isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the user");
             if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
-                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
+                throw new InvalidRequestException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
             }
             return revokeEntitySharing(domainId, entityId, userList, permissionTypeId);
-        }catch (Throwable ex) {
+        }catch (InvalidRequestException | ResourceNotFoundException ex) {
+            throw ex;
+        }catch(Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
 
-    public boolean revokeEntitySharingFromGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId) throws SharingRegistryException {
+    public boolean revokeEntitySharingFromGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId) throws SharingRegistryException, ResourceNotFoundException, InvalidRequestException {
         try{
+            for(String group: groupList){
+                if(!isGroupExists(domainId, group)) throw new ResourceNotFoundException("Could not find the group");
+            }
+            if(!isDomainExists(domainId) || !isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the user");
             if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
-                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
+                throw new InvalidRequestException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
             }
             return revokeEntitySharing(domainId, entityId, groupList, permissionTypeId);
+        }catch (InvalidRequestException | ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -1099,8 +1292,9 @@ public class SharingRegistryService {
     }
 
 
-    public boolean userHasAccess(String domainId, String userId, String entityId, String permissionTypeId) throws SharingRegistryException {
+    public boolean userHasAccess(String domainId, String userId, String entityId, String permissionTypeId) throws SharingRegistryException, ResourceNotFoundException {
         try{
+            if(!isDomainExists(domainId) || !isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId) || !isUserExists(domainId, userId)) throw new ResourceNotFoundException("Could not find the resource");
             //check whether the user has permission directly or indirectly
             List<GroupMembership> parentMemberships = (new GroupMembershipRepository()).getAllParentMembershipsForChild(domainId, userId);
             List<String> groupIds = new ArrayList<>();
@@ -1108,16 +1302,22 @@ public class SharingRegistryService {
             groupIds.add(userId);
             return (new SharingRepository()).hasAccess(domainId, entityId, groupIds, Arrays.asList(permissionTypeId,
                     (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId)));
+        }catch (ResourceNotFoundException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
         }
     }
 
-    public boolean revokeEntitySharing(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId) throws SharingRegistryException {
+    public boolean revokeEntitySharing(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId) throws SharingRegistryException, InvalidRequestException, ResourceNotFoundException {
         try{
+            for(String groupOrUser: groupOrUserList){
+                if(!isUserExists(domainId, groupOrUser) && !isGroupExists(domainId, groupOrUser)) throw new ResourceNotFoundException("Could not find the user");
+            }
+            if(!isDomainExists(domainId) || !isEntityExists(domainId, entityId) || !isPermissionExists(domainId, permissionTypeId)) throw new ResourceNotFoundException("Could not find the user");
             if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
-                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be removed");
+                throw new InvalidRequestException(OWNER_PERMISSION_NAME + " permission cannot be removed");
             }
 
             //revoking permission for the entity
@@ -1156,6 +1356,8 @@ public class SharingRegistryService {
             entity.setSharedCount((new SharingRepository()).getSharedCount(domainId, entityId));
             (new EntityRepository()).update(entity);
             return true;
+        }catch (ResourceNotFoundException | InvalidRequestException ex) {
+            throw ex;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
diff --git a/pom.xml b/pom.xml
index 1ba86f7..0169baf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,6 +52,11 @@
             <artifactId>spring-boot-starter-web</artifactId>
             <version>2.1.6.RELEASE</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+            <version>2.1.6.RELEASE</version>
+        </dependency>
     </dependencies>
     <build>
         <plugins>


[airavata-custos] 42/48: Merge pull request #10 from aarushiibisht/custos_sharing_registry_changes

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5fe0bee995c3f3e4e39ef52077d3e63f72f7c22b
Merge: da05787 fc08910
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Mon Sep 2 20:20:36 2019 -0400

    Merge pull request #10 from aarushiibisht/custos_sharing_registry_changes
    
    code refactoring

 .../custos/authentication/handler/CustosAuthenticationHandler.java  | 2 +-
 custos-client/pom.xml                                               | 6 ------
 ...onServiceClientFactory.java => AuthenticationServiceClient.java} | 2 +-
 .../custos/commons/exceptions/ServiceConnectionException.java       | 3 +++
 .../{CustosAPIServerStarted.java => CustosAPIServerStarter.java}    | 2 +-
 .../service/sample/CustosAuthenticationServiceSample.java           | 4 ++--
 6 files changed, 8 insertions(+), 11 deletions(-)


[airavata-custos] 41/48: code refactoring

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fc0891017df4b9f75bc4798c46a897c5f353c6e3
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Sep 2 20:14:07 2019 -0400

    code refactoring
---
 .../custos/authentication/handler/CustosAuthenticationHandler.java  | 2 +-
 custos-client/pom.xml                                               | 6 ------
 ...onServiceClientFactory.java => AuthenticationServiceClient.java} | 2 +-
 .../custos/commons/exceptions/ServiceConnectionException.java       | 3 +++
 .../{CustosAPIServerStarted.java => CustosAPIServerStarter.java}    | 2 +-
 .../service/sample/CustosAuthenticationServiceSample.java           | 4 ++--
 6 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
index 8706071..8a7de8c 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
@@ -20,7 +20,7 @@ public class CustosAuthenticationHandler implements CustosAuthenticationService.
             CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
             boolean isAuth = securityManager.isUserAuthenticated(authzToken);
                 if (isAuth) {
-                    logger.info("User " + authzToken.getClaimsMap().get(Constants.USER_NAME) + " in gateway " + authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + " is authenticated");
+                    logger.info("User" + authzToken.getClaimsMap().get(Constants.USER_NAME) + "in gateway" + authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + "is authenticated");
                     return isAuth;
                 }
                 else{
diff --git a/custos-client/pom.xml b/custos-client/pom.xml
index 58f34c4..7c241a8 100644
--- a/custos-client/pom.xml
+++ b/custos-client/pom.xml
@@ -30,12 +30,6 @@
             <artifactId>tenant-profile-service</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>custos-sharing-registry-stubs</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
-        </dependency>
     </dependencies>
     <properties>
         <maven.compiler.source>1.8</maven.compiler.source>
diff --git a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClientFactory.java b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
similarity index 95%
rename from custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClientFactory.java
rename to custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
index 734e55e..4fc0444 100644
--- a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClientFactory.java
+++ b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
@@ -8,7 +8,7 @@ import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 
-public class AuthenticationServiceClientFactory {
+public class AuthenticationServiceClient {
 
     public static CustosAuthenticationService.Client createAuthenticationServiceClient(String serverHost, int serverPort)  throws CustosAuthenticationServiceException {
         try {
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ServiceConnectionException.java b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ServiceConnectionException.java
index bdfaf29..06e0314 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ServiceConnectionException.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ServiceConnectionException.java
@@ -1,4 +1,7 @@
 package org.apache.custos.commons.exceptions;
+/*
+This exception is thrown when client fails to make the Http call
+*/
 
 public class ServiceConnectionException extends RuntimeException {
 
diff --git a/ide-integration/custos-services/src/main/java/org/apache/custos/server/start/CustosAPIServerStarted.java b/ide-integration/custos-services/src/main/java/org/apache/custos/server/start/CustosAPIServerStarter.java
similarity index 93%
rename from ide-integration/custos-services/src/main/java/org/apache/custos/server/start/CustosAPIServerStarted.java
rename to ide-integration/custos-services/src/main/java/org/apache/custos/server/start/CustosAPIServerStarter.java
index 81dd02b..9edcdef 100644
--- a/ide-integration/custos-services/src/main/java/org/apache/custos/server/start/CustosAPIServerStarted.java
+++ b/ide-integration/custos-services/src/main/java/org/apache/custos/server/start/CustosAPIServerStarter.java
@@ -3,7 +3,7 @@ package org.apache.custos.server.start;
 import org.apache.custos.authentication.server.CustosAuthenticationServer;
 import org.apache.custos.profile.server.ProfileServiceServer;
 
-public class CustosAPIServerStarted {
+public class CustosAPIServerStarter {
     public static void main(String args[]) throws Exception {
         CustosAuthenticationServer custosAuthenticationServer = new CustosAuthenticationServer();
         ProfileServiceServer custosProfileServer = new ProfileServiceServer();
diff --git a/ide-integration/samples/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java b/ide-integration/samples/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java
index 4fb0be0..5403862 100644
--- a/ide-integration/samples/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java
+++ b/ide-integration/samples/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java
@@ -1,7 +1,7 @@
 package org.apache.custos.authentication.service.sample;
 
 import org.apache.custos.authentication.cpi.CustosAuthenticationService;
-import org.apache.custos.client.authentication.service.AuthenticationServiceClientFactory;
+import org.apache.custos.client.authentication.service.AuthenticationServiceClient;
 import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.ServerSettings;
@@ -24,7 +24,7 @@ public class CustosAuthenticationServiceSample {
         try {
             String serverHost = ServerSettings.getAuthenticationServerHost();
             int serverPort = Integer.parseInt(ServerSettings.getAuthenticationServerPort());
-            CustosAuthenticationService.Client client = AuthenticationServiceClientFactory.createAuthenticationServiceClient(serverHost, serverPort);
+            CustosAuthenticationService.Client client = AuthenticationServiceClient.createAuthenticationServiceClient(serverHost, serverPort);
             testUserAuthentication(client);
         }catch (Exception e){
            log.error("Error setting up the authentication server");


[airavata-custos] 24/48: migrated sharing registry service into custos

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit daf1e71468bd6370f06a3f4d5f5ab06ab8ad04cd
Author: Aarushi <aa...@gmail.com>
AuthorDate: Wed Aug 14 14:34:33 2019 -0400

    migrated sharing registry service into custos
---
 custos-client/pom.xml                              |     6 +
 .../SharingRegistryServiceClientFactory.java       |    44 +
 custos-commons/custos-server.properties            |     0
 .../org/apache/custos/commons/utils/Constants.java |     4 +
 .../custos/commons/utils/ServerSettings.java       |     7 +-
 custos-sharing-registry-service/pom.xml            |    21 +
 .../sharing-registry-distribution/pom.xml          |    87 +
 .../src/main/assembly/bin-assembly.xml             |    75 +
 .../src/main/resources/bin/setenv.sh               |    61 +
 .../src/main/resources/bin/sharing-registry.sh     |    90 +
 .../sharing-registry-server/pom.xml                |   130 +
 .../sharing/registry/db/entities/DomainEntity.java |   116 +
 .../sharing/registry/db/entities/EntityEntity.java |   219 +
 .../sharing/registry/db/entities/EntityPK.java     |    76 +
 .../registry/db/entities/EntityTypeEntity.java     |   130 +
 .../sharing/registry/db/entities/EntityTypePK.java |    76 +
 .../registry/db/entities/GroupAdminEntity.java     |    80 +
 .../sharing/registry/db/entities/GroupAdminPK.java |    66 +
 .../db/entities/GroupMembershipEntity.java         |   126 +
 .../registry/db/entities/GroupMembershipPK.java    |    88 +
 .../registry/db/entities/PermissionTypeEntity.java |   128 +
 .../registry/db/entities/PermissionTypePK.java     |    76 +
 .../registry/db/entities/SharingEntity.java        |   149 +
 .../sharing/registry/db/entities/SharingPK.java    |   116 +
 .../sharing/registry/db/entities/UserEntity.java   |   161 +
 .../registry/db/entities/UserGroupEntity.java      |   178 +
 .../sharing/registry/db/entities/UserGroupPK.java  |    75 +
 .../sharing/registry/db/entities/UserPK.java       |    75 +
 .../db/repositories/AbstractRepository.java        |   168 +
 .../registry/db/repositories/DomainRepository.java |    33 +
 .../registry/db/repositories/EntityRepository.java |   173 +
 .../db/repositories/EntityTypeRepository.java      |    34 +
 .../db/repositories/GroupAdminRepository.java      |    17 +
 .../db/repositories/GroupMembershipRepository.java |   104 +
 .../db/repositories/PermissionTypeRepository.java  |    52 +
 .../db/repositories/SharingRepository.java         |   115 +
 .../db/repositories/UserGroupRepository.java       |    95 +
 .../registry/db/repositories/UserRepository.java   |    79 +
 .../sharing/registry/db/utils/Committer.java       |    26 +
 .../sharing/registry/db/utils/DBConstants.java     |   106 +
 .../custos/sharing/registry/db/utils/JPAUtils.java |    35 +
 .../registry/db/utils/ObjectMapperSingleton.java   |    38 +
 .../db/utils/SharingRegistryDBInitConfig.java      |    47 +
 .../db/utils/SharingRegistryJDBCConfig.java        |    67 +
 .../custos/sharing/registry/server/ServerMain.java |   101 +
 .../registry/server/SharingRegistryServer.java     |   191 +
 .../server/SharingRegistryServerHandler.java       |  1273 +
 .../src/main/resources/META-INF/persistence.xml    |    16 +
 .../src/main/resources/airavata.jks                |   Bin 0 -> 1410 bytes
 .../src/main/resources/client_truststore.jks       |   Bin 0 -> 5312 bytes
 .../src/main/resources/sharing-registry-derby.sql  |   147 +
 .../src/main/resources/sharing-registry-mysql.sql  |   146 +
 .../apache/custos/sharing/registry/CipresTest.java |   632 +
 .../registry/SharingRegistryServerHandlerTest.java |   386 +
 .../registry/SharingRegistryServiceTest.java       |   419 +
 .../src/test/resources/airavata.jks                |   Bin 0 -> 1410 bytes
 .../src/test/resources/client_truststore.jks       |   Bin 0 -> 5312 bytes
 .../src/test/resources/logback.xml                 |    31 +
 .../sharing-registry-stubs/pom.xml                 |    77 +
 .../SharingRegistryServiceClientFactory.java       |    44 +
 .../custos/sharing/registry/models/Domain.java     |   805 +
 .../registry/models/DuplicateEntryException.java   |   377 +
 .../custos/sharing/registry/models/Entity.java     |  1663 +
 .../sharing/registry/models/EntitySearchField.java |    79 +
 .../custos/sharing/registry/models/EntityType.java |   908 +
 .../custos/sharing/registry/models/GroupAdmin.java |   589 +
 .../sharing/registry/models/GroupCardinality.java  |    48 +
 .../sharing/registry/models/GroupChildType.java    |    47 +
 .../sharing/registry/models/GroupMembership.java   |   918 +
 .../custos/sharing/registry/models/GroupType.java  |    47 +
 .../sharing/registry/models/PermissionType.java    |   908 +
 .../sharing/registry/models/SearchCondition.java   |    64 +
 .../sharing/registry/models/SearchCriteria.java    |   628 +
 .../custos/sharing/registry/models/Sharing.java    |  1132 +
 .../registry/models/SharingRegistryException.java  |   374 +
 .../sharing/registry/models/SharingType.java       |    50 +
 .../custos/sharing/registry/models/User.java       |  1246 +
 .../custos/sharing/registry/models/UserGroup.java  |  1427 +
 .../registry/models/sharing_modelsConstants.java   |    14 +
 .../service/cpi/SharingRegistryService.java        | 67599 +++++++++++++++++++
 .../registry/service/cpi/sharing_cpiConstants.java |    14 +
 .../sharing-service-docs/api-docs/index.html       |   104 +
 .../sharing-service-docs/api-docs/sharing_cpi.html |   389 +
 .../api-docs/sharing_models.html                   |   308 +
 .../sharing-service-docs/api-docs/style.css        |   184 +
 .../sharing-service-docs/index.html                |   389 +
 .../sharing-service-docs/sharing_overview.png      |   Bin 0 -> 49205 bytes
 .../sharing-service-docs/style.css                 |   194 +
 .../thrift_models/thrift-gen.sh                    |    43 +
 .../src/main/resources/custos-server.properties    |    17 +
 .../database_scripts/init/01-databases.sql         |   326 +-
 pom.xml                                            |     4 +
 .../sharing-service/sharing-cpi/sharing_cpi.thrift |   274 +
 .../sharing-models/sharing_models.thrift           |   303 +
 94 files changed, 88582 insertions(+), 2 deletions(-)

diff --git a/custos-client/pom.xml b/custos-client/pom.xml
index 7c241a8..58f34c4 100644
--- a/custos-client/pom.xml
+++ b/custos-client/pom.xml
@@ -30,6 +30,12 @@
             <artifactId>tenant-profile-service</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-sharing-registry-stubs</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
     <properties>
         <maven.compiler.source>1.8</maven.compiler.source>
diff --git a/custos-client/src/main/java/org/apache/custos/client/sharing/service/SharingRegistryServiceClientFactory.java b/custos-client/src/main/java/org/apache/custos/client/sharing/service/SharingRegistryServiceClientFactory.java
new file mode 100644
index 0000000..3fc60a4
--- /dev/null
+++ b/custos-client/src/main/java/org/apache/custos/client/sharing/service/SharingRegistryServiceClientFactory.java
@@ -0,0 +1,44 @@
+/**
+ *
+ * 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.custos.client.sharing.service;
+
+import org.apache.custos.sharing.registry.models.SharingRegistryException;
+import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransportException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SharingRegistryServiceClientFactory {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServiceClientFactory.class);
+
+    public static SharingRegistryService.Client createSharingRegistryClient(String serverHost, int serverPort) throws SharingRegistryException {
+        try {
+            TSocket e = new TSocket(serverHost, serverPort);
+            e.open();
+            TBinaryProtocol protocol = new TBinaryProtocol(e);
+            return new SharingRegistryService.Client(protocol);
+        } catch (TTransportException var4) {
+            logger.error("failed to create sharing registry client", var4);
+            throw new SharingRegistryException();
+        }
+    }
+}
\ No newline at end of file
diff --git a/custos-commons/custos-server.properties b/custos-commons/custos-server.properties
deleted file mode 100644
index e69de29..0000000
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
index 7bb6c8e..ace2e06 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
@@ -36,4 +36,8 @@ public final class Constants {
 
     //constants in XACML authorization response.
     public static final String PERMIT = "Permit";
+
+    //security related constants
+    public static final String IS_SHARING_TLS_ENABLED = "sharing.tls.enabled";
+    public static final String TLS_CLIENT_TIMEOUT = "TLS.client.timeout";
 }
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
index 7397d51..46f0453 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
@@ -88,5 +88,10 @@ public class ServerSettings extends ApplicationSettings {
     public static String getProfileServiceServerPort() throws ApplicationSettingsException {
         return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_PORT);
     }
-
+    public static boolean isSharingTLSEnabled() throws ApplicationSettingsException {
+        return Boolean.valueOf(getSetting(Constants.IS_SHARING_TLS_ENABLED));
+    }
+    public static int getTLSClientTimeout() throws ApplicationSettingsException {
+        return Integer.valueOf(getSetting(Constants.TLS_CLIENT_TIMEOUT));
+    }
 }
diff --git a/custos-sharing-registry-service/pom.xml b/custos-sharing-registry-service/pom.xml
new file mode 100644
index 0000000..9637a81
--- /dev/null
+++ b/custos-sharing-registry-service/pom.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>custos</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-sharing-registry-service</artifactId>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>sharing-registry-distribution</module>
+        <module>sharing-registry-server</module>
+        <module>sharing-registry-stubs</module>
+    </modules>
+
+</project>
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-distribution/pom.xml b/custos-sharing-registry-service/sharing-registry-distribution/pom.xml
new file mode 100644
index 0000000..3e709f6
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-distribution/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>custos-sharing-registry-service</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-sharing-registry-distribution</artifactId>
+    <packaging>jar</packaging>
+    <name>Sharing Registry Distribution</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.10</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.dozer</groupId>
+            <artifactId>dozer</artifactId>
+            <version>5.4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa</artifactId>
+            <version>${openjpa.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>${mysql.connector.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>${thrift.version}</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>${maven.assembly.plugin}</version>
+                <executions>
+                    <execution>
+                        <id>distribution-package</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                        <configuration>
+                            <descriptors>
+                                <descriptor>src/main/assembly/bin-assembly.xml</descriptor>
+                            </descriptors>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/custos-sharing-registry-service/sharing-registry-distribution/src/main/assembly/bin-assembly.xml b/custos-sharing-registry-service/sharing-registry-distribution/src/main/assembly/bin-assembly.xml
new file mode 100644
index 0000000..038a065
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-distribution/src/main/assembly/bin-assembly.xml
@@ -0,0 +1,75 @@
+<!--
+
+
+    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.
+
+-->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
+          http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+    <id>bin</id>
+    <includeBaseDirectory>true</includeBaseDirectory>
+    <baseDirectory>sharing-registry</baseDirectory>
+    <formats>
+        <format>tar.gz</format>
+    </formats>
+
+    <fileSets>
+        <fileSet>
+            <directory>src/main/resources/bin</directory>
+            <outputDirectory>bin</outputDirectory>
+            <includes>
+                <include>*.sh</include>
+            </includes>
+            <fileMode>755</fileMode>
+        </fileSet>
+
+        <!-- ********************** copy airavata-server.properties and key stores ********************** -->
+        <fileSet>
+            <directory>../../configuration/server/src/main/resources/</directory>
+            <outputDirectory>bin</outputDirectory>
+            <includes>
+                <include>airavata-server.properties</include>
+                <include>log4j.properties</include>
+                <include>airavata.jks</include>
+                <include>client_truststore.jks</include>
+            </includes>
+        </fileSet>
+
+        <!-- ********************** copy database scripts ********************** -->
+        <fileSet>
+            <directory>../sharing-registry-server/src/main/resources/
+            </directory>
+            <outputDirectory>bin/database_scripts
+            </outputDirectory>
+            <includes>
+                <include>*sql*</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+
+    <dependencySets>
+        <dependencySet>
+            <outputDirectory>/lib</outputDirectory>
+            <includes>
+                <include>*:jar:*</include>
+            </includes>
+        </dependencySet>
+    </dependencySets>
+</assembly>
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/setenv.sh b/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/setenv.sh
new file mode 100644
index 0000000..1e5475d
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/setenv.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# 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.
+
+# Get standard environment variables
+# if JAVA_HOME is not set we're not happy
+if [ -z "$JAVA_HOME" ]; then
+  echo "You must set the JAVA_HOME variable before running sharing-registry scripts."
+  exit 1
+fi
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false
+os400=false
+case "`uname`" in
+CYGWIN*) cygwin=true;;
+OS400*) os400=true;;
+esac
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ]; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '.*/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "$PRG"`/"$link"
+  fi
+done
+
+PRGDIR=`dirname "$PRG"`
+
+# Only set SHARING_REGISTRY_HOME if not already set
+[ -z "$SHARING_REGISTRY_HOME" ] && SHARING_REGISTRY_HOME=`cd "$PRGDIR/.." ; pwd`
+
+SHARING_REGISTRY_CLASSPATH=""
+
+for f in "$SHARING_REGISTRY_HOME"/lib/*.jar
+do
+  SHARING_REGISTRY_CLASSPATH="$SHARING_REGISTRY_CLASSPATH":$f
+done
+
+export SHARING_REGISTRY_HOME
+export SHARING_REGISTRY_CLASSPATH
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh b/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh
new file mode 100644
index 0000000..07c7612
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+# 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.
+
+. `dirname $0`/setenv.sh
+cd $SHARING_REGISTRY_HOME/bin
+
+IS_DAEMON_MODE=false
+SHARING_REGISTRY_COMMAND=""
+STOP=false
+FORCE=false
+JAVA_OPTS=""
+
+for var in "$@"
+do
+    case $var in
+    -xdebug)
+        	AIRAVATA_COMMAND="${AIRAVATA_COMMAND}"
+            JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000"
+            shift
+        ;;
+	start)
+	    IS_DAEMON_MODE=true
+            shift
+        ;;
+	stop)
+	    STOP=true
+	    SHARING_REGISTRY_COMMAND="$
+	    SHARING_REGISTRY_COMMAND $var"
+            shift
+        ;;
+        -h)
+            echo "Usage: sharing-registry.sh [command-options]"
+            echo "command options:"
+	    echo "  start              Start server in daemon mode"
+	    echo "  stop               Stop server."
+	    echo "  -xdebug			   Start Sharing Registry Server under JPDA debugger"
+	    echo "  -h                 Display this help and exit"
+	        shift
+            exit 0
+        ;;
+	*)
+	    SHARING_REGISTRY_COMMAND="$SHARING_REGISTRY_COMMAND $var"
+            shift
+    esac
+done
+
+if $STOP;
+then
+	for f in `find . -name "server_start_*"`; do
+		IFS='_' read -a f_split <<< "$f"
+		echo "Found process file : $f"
+		echo -n "    Sending kill signals to process ${f_split[2]}..."
+		out=`kill -9 ${f_split[2]} 2>&1`
+		if [ -z "$out" ]; then
+		    echo "done"
+		else
+		    echo "failed (REASON: $out)"
+		fi
+		echo -n "    Removing process file..."
+		out=`rm $f 2>&1`
+		if [ -z "$out" ]; then
+		    echo "done"
+		else
+		    echo "failed (REASON: $out)"
+		fi
+	done
+else
+	if $IS_DAEMON_MODE ; then
+		echo "Starting Sharing Registry Server in daemon mode..."
+		$JAVA_HOME/bin/java ${JAVA_OPTS} -classpath "$SHARING_REGISTRY_CLASSPATH"  org.apache.airavata.sharing.registry.server.ServerMain $* > /dev/null 2>&1 &
+	else
+		$JAVA_HOME/bin/java ${JAVA_OPTS} -classpath "$SHARING_REGISTRY_CLASSPATH"  org.apache.airavata.sharing.registry.server.ServerMain $*
+	fi
+fi
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/pom.xml b/custos-sharing-registry-service/sharing-registry-server/pom.xml
new file mode 100644
index 0000000..d530cd7
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/pom.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>custos-sharing-registry-service</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <relativePath>../pom.xml</relativePath>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-sharing-registry-server</artifactId>
+    <packaging>jar</packaging>
+    <name>Sharing Registry Server</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.10</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.dozer</groupId>
+            <artifactId>dozer</artifactId>
+            <version>5.4.0</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa</artifactId>
+            <version>${openjpa.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>${mysql.connector.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>${thrift.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.databene</groupId>
+            <artifactId>contiperf</artifactId>
+            <version>2.3.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-commons</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-sharing-registry-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.5.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.3.2</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.openjpa</groupId>
+                <artifactId>openjpa-maven-plugin</artifactId>
+                <version>${openjpa.version}</version>
+                <configuration>
+                    <includes>**/entities/*.class</includes>
+                    <excludes>**/entities/XML*.class</excludes>
+                    <addDefaultConstructor>true</addDefaultConstructor>
+                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>enhancer</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/DomainEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/DomainEntity.java
new file mode 100644
index 0000000..620c9b4
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/DomainEntity.java
@@ -0,0 +1,116 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "DOMAIN", schema = "" )
+public class DomainEntity {
+    private final static Logger logger = LoggerFactory.getLogger(DomainEntity.class);
+    private String domainId;
+    private String name;
+    private String description;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        DomainEntity that = (DomainEntity) o;
+
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
+        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
+            return false;
+        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
+            return false;
+        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getDomainId() != null ? getDomainId().hashCode() : 0;
+        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
+        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
+        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
+        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityEntity.java
new file mode 100644
index 0000000..a87fbf4
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityEntity.java
@@ -0,0 +1,219 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.nio.ByteBuffer;
+
+@Entity
+@Table(name = "ENTITY", schema = "")
+@IdClass(EntityPK.class)
+public class EntityEntity {
+    private final static Logger logger = LoggerFactory.getLogger(EntityEntity.class);
+    private String entityId;
+    private String domainId;
+    private String entityTypeId;
+    private String ownerId;
+    private String parentEntityId;
+    private String name;
+    private String description;
+    private ByteBuffer binaryData;
+    private String fullText;
+    private Long originalEntityCreationTime;
+    private Long sharedCount;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "ENTITY_ID")
+    public String getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityId(String entityId) {
+        this.entityId = entityId;
+    }
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "ENTITY_TYPE_ID")
+    public String getEntityTypeId() {
+        return entityTypeId;
+    }
+
+    public void setEntityTypeId(String entityTypeId) {
+        this.entityTypeId = entityTypeId;
+    }
+
+    @Basic
+    @Column(name = "OWNER_ID")
+    public String getOwnerId() {
+        return ownerId;
+    }
+
+    public void setOwnerId(String ownerId) {
+        this.ownerId = ownerId;
+    }
+
+    @Basic
+    @Column(name = "PARENT_ENTITY_ID")
+    public String getParentEntityId() {
+        return parentEntityId;
+    }
+
+    public void setParentEntityId(String parentEntityId) {
+        this.parentEntityId = parentEntityId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Lob
+    @Column(name="BINARY_DATA")
+    public ByteBuffer getBinaryData() {
+        return binaryData;
+    }
+
+    public void setBinaryData(ByteBuffer binaryData) {
+        this.binaryData = binaryData;
+    }
+
+    @Basic
+    @Column(name = "FULL_TEXT")
+    public String getFullText() {
+        return fullText;
+    }
+
+    public void setFullText(String fullText) {
+        this.fullText = fullText;
+    }
+
+    @Basic
+    @Column(name = "ORIGINAL_ENTITY_CREATION_TIME")
+    public Long getOriginalEntityCreationTime() {
+        return originalEntityCreationTime;
+    }
+
+    public void setOriginalEntityCreationTime(Long originalEntityCreationTime) {
+        this.originalEntityCreationTime = originalEntityCreationTime;
+    }
+
+    @Basic
+    @Column(name = "SHARED_COUNT")
+    public Long getSharedCount() {
+        return sharedCount;
+    }
+
+    public void setSharedCount(Long sharedCount) {
+        this.sharedCount = sharedCount;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        EntityEntity that = (EntityEntity) o;
+
+        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
+            return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+        if (getParentEntityId() != null ? !getParentEntityId().equals(that.getParentEntityId()) : that.getParentEntityId() != null)
+            return false;
+        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
+        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
+            return false;
+        if (getBinaryData().equals(that.getBinaryData())) return false;
+        if (getFullText() != null ? !getFullText().equals(that.getFullText()) : that.getFullText() != null)
+            return false;
+        if (getOriginalEntityCreationTime() != null ? !getOriginalEntityCreationTime().equals(that.getOriginalEntityCreationTime())
+                : that.getOriginalEntityCreationTime() != null) return false;
+        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
+            return false;
+        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
+            return false;
+        if (getOwnerId() != null ? !getOwnerId().equals(that.getOwnerId()) : that.getOwnerId() != null) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getEntityId() != null ? getEntityId().hashCode() : 0;
+        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
+        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
+        result = 31 * result + (getBinaryData() != null ? getBinaryData().hashCode() : 0);
+        result = 31 * result + (getFullText() != null ? getFullText().hashCode() : 0);
+        result = 31 * result + (getOriginalEntityCreationTime() != null ? getOriginalEntityCreationTime().hashCode() : 0);
+        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
+        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityPK.java
new file mode 100644
index 0000000..9999743
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityPK.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class EntityPK implements Serializable {
+    private final static Logger logger = LoggerFactory.getLogger(EntityPK.class);
+    private String entityId;
+    private String domainId;
+
+
+    @Column(name = "ENTITY_ID")
+    @Id
+    public String getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityId(String entityId) {
+        this.entityId = entityId;
+    }
+
+    @Column(name = "DOMAIN_ID")
+    @Id
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        EntityPK that = (EntityPK) o;
+
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getDomainId() != null ? getDomainId().hashCode() : 0;
+        result = 31 * result + (getEntityId() != null ? getEntityId().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypeEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypeEntity.java
new file mode 100644
index 0000000..458a4a9
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypeEntity.java
@@ -0,0 +1,130 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "ENTITY_TYPE", schema = "")
+@IdClass(EntityTypePK.class)
+public class EntityTypeEntity {
+    private final static Logger logger = LoggerFactory.getLogger(EntityTypeEntity.class);
+    private String entityTypeId;
+    private String domainId;
+    private String name;
+    private String description;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "ENTITY_TYPE_ID")
+    public String getEntityTypeId() {
+        return entityTypeId;
+    }
+
+    public void setEntityTypeId(String entityTypeId) {
+        this.entityTypeId = entityTypeId;
+    }
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        EntityTypeEntity that = (EntityTypeEntity) o;
+
+        if (getEntityTypeId() != null ? !getEntityTypeId().equals(that.getEntityTypeId()) : that.getEntityTypeId() != null)
+            return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
+        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
+            return false;
+        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
+            return false;
+        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getEntityTypeId() != null ? getEntityTypeId().hashCode() : 0;
+        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
+        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
+        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
+        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypePK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypePK.java
new file mode 100644
index 0000000..f162b3b
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypePK.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class EntityTypePK implements Serializable {
+    private final static Logger logger = LoggerFactory.getLogger(EntityTypePK.class);
+    private String entityTypeId;
+    private String domainId;
+
+
+    @Column(name = "ENTITY_TYPE_ID")
+    @Id
+    public String getEntityTypeId() {
+        return entityTypeId;
+    }
+
+    public void setEntityTypeId(String entityTypeId) {
+        this.entityTypeId = entityTypeId;
+    }
+
+    @Column(name = "DOMAIN_ID")
+    @Id
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        EntityTypePK that = (EntityTypePK) o;
+
+        if (getEntityTypeId() != null ? !getEntityTypeId().equals(that.getEntityTypeId()) : that.getEntityTypeId() != null)
+            return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getEntityTypeId() != null ? getEntityTypeId().hashCode() : 0;
+        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminEntity.java
new file mode 100644
index 0000000..26fe095
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminEntity.java
@@ -0,0 +1,80 @@
+package org.apache.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "GROUP_ADMIN", schema = "")
+@IdClass(GroupAdminPK.class)
+public class GroupAdminEntity {
+    private final static Logger logger = LoggerFactory.getLogger(GroupAdminEntity.class);
+    private String groupId;
+    private String domainId;
+    private String adminId;
+    private UserGroupEntity userGroup;
+
+    @Id
+    @Column(name = "GROUP_ID")
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Id
+    @Column(name = "ADMIN_ID")
+    public String getAdminId() {
+        return adminId;
+    }
+
+    public void setAdminId(String adminId) {
+        this.adminId = adminId;
+    }
+
+    @ManyToOne(targetEntity = UserGroupEntity.class, cascade = CascadeType.MERGE)
+    @JoinColumns({
+            @JoinColumn(name="GROUP_ID", referencedColumnName="GROUP_ID"),
+            @JoinColumn(name="DOMAIN_ID", referencedColumnName="DOMAIN_ID")
+    })
+    public UserGroupEntity getUserGroup() {
+        return userGroup;
+    }
+
+    public void setUserGroup(UserGroupEntity userGroup) {
+        this.userGroup = userGroup;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        GroupAdminEntity that = (GroupAdminEntity) o;
+
+        if (!getGroupId().equals(that.getGroupId())) return false;
+        if (!getDomainId().equals(that.getDomainId())) return false;
+        return getAdminId().equals(that.getAdminId());
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getGroupId().hashCode();
+        result = 31 * result + getDomainId().hashCode();
+        result = 31 * result + getAdminId().hashCode();
+        return result;
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminPK.java
new file mode 100644
index 0000000..a036cf9
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminPK.java
@@ -0,0 +1,66 @@
+package org.apache.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class GroupAdminPK implements Serializable{
+
+    private final static Logger logger = LoggerFactory.getLogger(GroupAdminPK.class);
+    private String groupId;
+    private String domainId;
+    private String adminId;
+
+    @Id
+    @Column(name = "GROUP_ID")
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Id
+    @Column(name = "ADMIN_ID")
+    public String getAdminId() {
+        return adminId;
+    }
+
+    public void setAdminId(String adminId) {
+        this.adminId = adminId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        GroupAdminPK groupAdminPK = (GroupAdminPK) o;
+
+        if (!getGroupId().equals(groupAdminPK.getGroupId())) return false;
+        if (!getDomainId().equals(groupAdminPK.getDomainId())) return false;
+        return getAdminId().equals(groupAdminPK.getAdminId());
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getGroupId().hashCode();
+        result = 31 * result + getDomainId().hashCode();
+        result = 31 * result + getAdminId().hashCode();
+        return result;
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipEntity.java
new file mode 100644
index 0000000..692411d
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipEntity.java
@@ -0,0 +1,126 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "GROUP_MEMBERSHIP", schema = "")
+@IdClass(GroupMembershipPK.class)
+public class GroupMembershipEntity {
+    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipEntity.class);
+    private String parentId;
+    private String childId;
+    private String childType;
+    private String domainId;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "PARENT_ID")
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    @Id
+    @Column(name = "CHILD_ID")
+    public String getChildId() {
+        return childId;
+    }
+
+    public void setChildId(String childId) {
+        this.childId = childId;
+    }
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "CHILD_TYPE")
+    public String getChildType() {
+        return childType;
+    }
+
+    public void setChildType(String childType) {
+        this.childType = childType;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        GroupMembershipEntity that = (GroupMembershipEntity) o;
+
+        if (getParentId() != null ? !getParentId().equals(that.getParentId()) : that.getParentId() != null)
+            return false;
+        if (getChildId() != null ? !getChildId().equals(that.getChildId()) : that.getChildId() != null) return false;
+        if (getChildType() != null ? !getChildType().equals(that.getChildType()) : that.getChildType() != null)
+            return false;
+        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
+            return false;
+        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getParentId() != null ? getParentId().hashCode() : 0;
+        result = 31 * result + (getChildId() != null ? getChildId().hashCode() : 0);
+        result = 31 * result + (getChildType() != null ? getChildType().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipPK.java
new file mode 100644
index 0000000..37c83c0
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipPK.java
@@ -0,0 +1,88 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class GroupMembershipPK implements Serializable {
+    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipPK.class);
+    private String parentId;
+    private String childId;
+    private String domainId;
+
+    @Column(name = "PARENT_ID")
+    @Id
+    public String getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(String parentId) {
+        this.parentId = parentId;
+    }
+
+    @Column(name = "CHILD_ID")
+    @Id
+    public String getChildId() {
+        return childId;
+    }
+
+    public void setChildId(String childId) {
+        this.childId = childId;
+    }
+
+    @Column(name = "DOMAIN_ID")
+    @Id
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        GroupMembershipPK that = (GroupMembershipPK) o;
+
+        if (getParentId() != null ? !getParentId().equals(that.getParentId()) : that.getParentId() != null)
+            return false;
+        if (getChildId() != null ? !getChildId().equals(that.getChildId()) : that.getChildId() != null) return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getParentId() != null ? getParentId().hashCode() : 0;
+        result = 31 * result + (getChildId() != null ? getChildId().hashCode() : 0);
+        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypeEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypeEntity.java
new file mode 100644
index 0000000..53882c0
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypeEntity.java
@@ -0,0 +1,128 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "PERMISSION_TYPE", schema = "")
+@IdClass(PermissionTypePK.class)
+public class PermissionTypeEntity {
+    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeEntity.class);
+    private String permissionTypeId;
+    private String domainId;
+    private String name;
+    private String description;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "PERMISSION_TYPE_ID")
+    public String getPermissionTypeId() {
+        return permissionTypeId;
+    }
+
+    public void setPermissionTypeId(String permissionTypeId) {
+        this.permissionTypeId = permissionTypeId;
+    }
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        PermissionTypeEntity that = (PermissionTypeEntity) o;
+
+        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
+            return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
+        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
+            return false;
+        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
+        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
+        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
+        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypePK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypePK.java
new file mode 100644
index 0000000..836316f
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypePK.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class PermissionTypePK implements Serializable {
+    private final static Logger logger = LoggerFactory.getLogger(PermissionTypePK.class);
+    private String permissionTypeId;
+    private String domainId;
+
+
+    @Column(name = "PERMISSION_TYPE_ID")
+    @Id
+    public String getPermissionTypeId() {
+        return permissionTypeId;
+    }
+
+    public void setPermissionTypeId(String permissionTypeId) {
+        this.permissionTypeId = permissionTypeId;
+    }
+
+    @Column(name = "DOMAIN_ID")
+    @Id
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        PermissionTypePK that = (PermissionTypePK) o;
+
+        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
+            return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
+        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingEntity.java
new file mode 100644
index 0000000..f52f574
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingEntity.java
@@ -0,0 +1,149 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "SHARING", schema = "")
+@IdClass(SharingPK.class)
+public class SharingEntity {
+    private final static Logger logger = LoggerFactory.getLogger(SharingEntity.class);
+    private String permissionTypeId;
+    private String entityId;
+    private String groupId;
+    private String domainId;
+    private String sharingType;
+    private String inheritedParentId;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "PERMISSION_TYPE_ID")
+    public String getPermissionTypeId() {
+        return permissionTypeId;
+    }
+
+    public void setPermissionTypeId(String permissionTypeId) {
+        this.permissionTypeId = permissionTypeId;
+    }
+
+    @Id
+    @Column(name = "ENTITY_ID")
+    public String getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityId(String entityId) {
+        this.entityId = entityId;
+    }
+
+    @Id
+    @Column(name = "GROUP_ID")
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+
+    @Id
+    @Column(name = "INHERITED_PARENT_ID")
+    public String getInheritedParentId() {
+        return inheritedParentId;
+    }
+
+    public void setInheritedParentId(String inheritedParentId) {
+        this.inheritedParentId = inheritedParentId;
+    }
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "SHARING_TYPE")
+    public String getSharingType() {
+        return sharingType;
+    }
+
+    public void setSharingType(String sharingType) {
+        this.sharingType = sharingType;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        SharingEntity that = (SharingEntity) o;
+
+        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
+            return false;
+        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
+            return false;
+        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
+        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
+            return false;
+        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
+        result = 31 * result + (getEntityId() != null ? getEntityId().hashCode() : 0);
+        result = 31 * result + (getGroupId() != null ? getGroupId().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingPK.java
new file mode 100644
index 0000000..506b486
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingPK.java
@@ -0,0 +1,116 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class SharingPK implements Serializable {
+    private final static Logger logger = LoggerFactory.getLogger(SharingPK.class);
+    private String permissionTypeId;
+    private String entityId;
+    private String groupId;
+    private String inheritedParentId;
+    private String domainId;
+
+    @Column(name = "PERMISSION_TYPE_ID")
+    @Id
+    public String getPermissionTypeId() {
+        return permissionTypeId;
+    }
+
+    public void setPermissionTypeId(String permissionTypeId) {
+        this.permissionTypeId = permissionTypeId;
+    }
+
+    @Column(name = "ENTITY_ID")
+    @Id
+    public String getEntityId() {
+        return entityId;
+    }
+
+    public void setEntityId(String entityId) {
+        this.entityId = entityId;
+    }
+
+    @Column(name = "GROUP_ID")
+    @Id
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    @Column(name = "INHERITED_PARENT_ID")
+    @Id
+    public String getInheritedParentId() {
+        return inheritedParentId;
+    }
+
+    public void setInheritedParentId(String inheritedParentId) {
+        this.inheritedParentId = inheritedParentId;
+    }
+
+    @Column(name = "DOMAIN_ID")
+    @Id
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        SharingPK that = (SharingPK) o;
+
+        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
+            return false;
+        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
+            return false;
+        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
+        if (getInheritedParentId() != null ? !getInheritedParentId().equals(that.getInheritedParentId()) : that.getInheritedParentId() != null)
+            return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
+        result = 31 * result + (getEntityId() != null ? getEntityId().hashCode() : 0);
+        result = 31 * result + (getGroupId() != null ? getGroupId().hashCode() : 0);
+        result = 31 * result + (getInheritedParentId() != null ? getInheritedParentId().hashCode() : 0);
+        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserEntity.java
new file mode 100644
index 0000000..25fd4a5
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserEntity.java
@@ -0,0 +1,161 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.nio.ByteBuffer;
+
+@Entity
+@Table(name = "SHARING_USER", schema = "") // USER is a reserved term in derby
+@IdClass(UserPK.class)
+public class UserEntity {
+    private final static Logger logger = LoggerFactory.getLogger(UserEntity.class);
+    private String userId;
+    private String domainId;
+    private String userName;
+    private String firstName;
+    private String lastName;
+    private String email;
+    private ByteBuffer icon;
+    private Long createdTime;
+    private Long updatedTime;
+
+    @Id
+    @Column(name = "USER_ID")
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "USER_NAME")
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    @Basic
+    @Column(name = "FIRST_NAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Basic
+    @Column(name = "LAST_NAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    @Basic
+    @Column(name = "EMAIL")
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    @Lob
+    @Column(name = "ICON")
+    public ByteBuffer getIcon() {
+        return icon;
+    }
+
+    public void setIcon(ByteBuffer icon) {
+        this.icon = icon;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        UserEntity that = (UserEntity) o;
+
+        if (getUserId() != null ? !getUserId().equals(that.getUserId()) : that.getUserId() != null) return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+        if (getUserName() != null ? !getUserName().equals(that.getUserName()) : that.getUserName() != null)
+            return false;
+        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
+            return false;
+        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getUserId() != null ? getUserId().hashCode() : 0;
+        result = 31 * result + (getUserName() != null ? getUserName().hashCode() : 0);
+        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
+        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupEntity.java
new file mode 100644
index 0000000..9d8a3ea
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupEntity.java
@@ -0,0 +1,178 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.util.List;
+
+@Entity
+@Table(name = "USER_GROUP", schema = "")
+@IdClass(UserGroupPK.class)
+public class UserGroupEntity {
+    private final static Logger logger = LoggerFactory.getLogger(UserGroupEntity.class);
+    private String groupId;
+    private String domainId;
+    private String name;
+    private String description;
+    private String ownerId;
+    private String groupType;
+    private String groupCardinality;
+    private Long createdTime;
+    private Long updatedTime;
+    private List<GroupAdminEntity> groupAdmins;
+
+    @Id
+    @Column(name = "GROUP_ID")
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    @Id
+    @Column(name = "DOMAIN_ID")
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Basic
+    @Column(name = "OWNER_ID")
+    public String getOwnerId() {
+        return ownerId;
+    }
+
+    public void setOwnerId(String ownerId) {
+        this.ownerId = ownerId;
+    }
+
+    @Basic
+    @Column(name = "NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Basic
+    @Column(name = "DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Basic
+    @Column(name = "GROUP_CARDINALITY")
+    public String getGroupCardinality() {
+        return groupCardinality;
+    }
+
+    public void setGroupCardinality(String groupCardinality) {
+        this.groupCardinality = groupCardinality;
+    }
+
+    @Basic
+    @Column(name = "GROUP_TYPE")
+    public String getGroupType() {
+        return groupType;
+    }
+
+    public void setGroupType(String type) {
+        this.groupType = type;
+    }
+
+    @Basic
+    @Column(name = "CREATED_TIME")
+    public Long getCreatedTime() {
+        return createdTime;
+    }
+
+    public void setCreatedTime(Long createdTime) {
+        this.createdTime = createdTime;
+    }
+
+    @Basic
+    @Column(name = "UPDATED_TIME")
+    public Long getUpdatedTime() {
+        return updatedTime;
+    }
+
+    public void setUpdatedTime(Long updatedTime) {
+        this.updatedTime = updatedTime;
+    }
+
+    @OneToMany(targetEntity = GroupAdminEntity.class, cascade = CascadeType.ALL,
+            mappedBy = "userGroup", fetch = FetchType.EAGER)
+    public List<GroupAdminEntity> getGroupAdmins() {
+        return groupAdmins;
+    }
+
+    public void setGroupAdmins(List<GroupAdminEntity> groupAdmins) {
+        this.groupAdmins = groupAdmins;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        UserGroupEntity that = (UserGroupEntity) o;
+
+        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+        if (getOwnerId() != null ? !getOwnerId().equals(that.getOwnerId()) : that.getOwnerId() != null) return false;
+        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
+        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
+            return false;
+        if (getGroupType() != null ? !getGroupType().equals(that.getGroupType()) : that.getGroupType() != null)
+            return false;
+        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
+            return false;
+        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getGroupId() != null ? getGroupId().hashCode() : 0;
+        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
+        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
+        result = 31 * result + (getGroupType() != null ? getGroupType().hashCode() : 0);
+        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
+        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupPK.java
new file mode 100644
index 0000000..dc12feb
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupPK.java
@@ -0,0 +1,75 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class UserGroupPK implements Serializable {
+    private final static Logger logger = LoggerFactory.getLogger(UserGroupPK.class);
+    private String groupId;
+    private String domainId;
+
+    @Column(name = "GROUP_ID")
+    @Id
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    @Column(name = "DOMAIN_ID")
+    @Id
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        UserGroupPK that = (UserGroupPK) o;
+
+        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null)
+            return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getGroupId() != null ? getGroupId().hashCode() : 0;
+        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserPK.java
new file mode 100644
index 0000000..9f68aa0
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserPK.java
@@ -0,0 +1,75 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class UserPK implements Serializable {
+    private final static Logger logger = LoggerFactory.getLogger(UserPK.class);
+    private String userId;
+    private String domainId;
+
+    @Column(name = "USER_ID")
+    @Id
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    @Column(name = "DOMAIN_ID")
+    @Id
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        UserPK that = (UserPK) o;
+
+        if (getUserId() != null ? !getUserId().equals(that.getUserId()) : that.getUserId() != null)
+            return false;
+        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = getUserId() != null ? getUserId().hashCode() : 0;
+        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
+        return result;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/AbstractRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/AbstractRepository.java
new file mode 100644
index 0000000..3823faa
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/AbstractRepository.java
@@ -0,0 +1,168 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.utils.Committer;
+import org.apache.custos.sharing.registry.db.utils.DBConstants;
+import org.apache.custos.sharing.registry.db.utils.JPAUtils;
+import org.apache.custos.sharing.registry.db.utils.ObjectMapperSingleton;
+import org.apache.custos.sharing.registry.models.SharingRegistryException;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractRepository<T, E, Id> {
+    private final static Logger logger = LoggerFactory.getLogger(AbstractRepository.class);
+
+    private Class<T> thriftGenericClass;
+    private Class<E> dbEntityGenericClass;
+
+    public AbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass){
+        this.thriftGenericClass = thriftGenericClass;
+        this.dbEntityGenericClass = dbEntityGenericClass;
+    }
+
+    public T create(T t) throws SharingRegistryException {
+        return update(t);
+    }
+
+    //FIXME do a bulk insert
+    public List<T> create(List<T> tList) throws SharingRegistryException {
+        return update(tList);
+    }
+
+    public  T update(T t) throws SharingRegistryException {
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        E entity = mapper.map(t, dbEntityGenericClass);
+        E persistedCopy = execute(entityManager -> entityManager.merge(entity));
+        return mapper.map(persistedCopy, thriftGenericClass);
+    }
+
+    //FIXME do a bulk update
+    public  List<T> update(List<T> tList) throws SharingRegistryException {
+        List<T> returnList = new ArrayList<>();
+        for(T temp : tList)
+            returnList.add(update(temp));
+        return returnList;
+    }
+
+    public boolean delete(Id id) throws SharingRegistryException {
+        execute(entityManager -> {
+             E entity = entityManager.find(dbEntityGenericClass, id);
+             entityManager.remove(entity);
+             return entity;
+         });
+        return true;
+    }
+
+    public boolean delete(List<Id> idList) throws SharingRegistryException {
+        for(Id id : idList)
+            delete(id);
+        return true;
+    }
+
+    public T get(Id id) throws SharingRegistryException {
+        E entity = execute(entityManager -> entityManager
+                .find(dbEntityGenericClass, id));
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        if(entity == null)
+            return null;
+        return mapper.map(entity, thriftGenericClass);
+    }
+
+    public boolean isExists(Id id) throws SharingRegistryException {
+        return get(id) != null;
+    }
+
+    public List<T> get(List<Id> idList) throws SharingRegistryException {
+        List<T> returnList = new ArrayList<>();
+        for(Id id : idList)
+            returnList.add(get(id));
+        return returnList;
+    }
+
+    public List<T> select(Map<String, String> filters, int offset, int limit) throws SharingRegistryException {
+        String query = "SELECT DISTINCT p from " + dbEntityGenericClass.getSimpleName() + " as p";
+        ArrayList<String> parameters = new ArrayList<>();
+        int parameterCount = 1;
+        if (filters != null && filters.size() != 0) {
+            query += " WHERE ";
+            for (String k : filters.keySet()) {
+                query += "p." + k + " = ?" + parameterCount + " AND ";
+                parameters.add(filters.get(k));
+                parameterCount++;
+            }
+            query = query.substring(0, query.length() - 5);
+        }
+
+        query += " ORDER BY p.createdTime DESC";
+        String queryString = query;
+        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+        List resultSet = execute(entityManager -> {
+            javax.persistence.Query q = entityManager.createQuery(queryString);
+            for (int i = 0; i < parameters.size(); i++) {
+                q.setParameter(i + 1, parameters.get(i));
+            }
+            return q.setFirstResult(offset).setMaxResults(newLimit).getResultList();
+        });
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> gatewayList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+        return gatewayList;
+    }
+
+    public List<T> select(String queryString, Map<String,Object> queryParameters, int offset, int limit) throws SharingRegistryException {
+        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+        List resultSet = execute(entityManager -> {
+            Query q =  entityManager.createQuery(queryString);
+            for(Map.Entry<String, Object> queryParam : queryParameters.entrySet()){
+                q.setParameter(queryParam.getKey(), queryParam.getValue());
+            }
+            return q.setFirstResult(offset).setMaxResults(newLimit).getResultList();
+        });
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> gatewayList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
+        return gatewayList;
+    }
+
+    public <R> R execute(Committer<EntityManager, R> committer) throws SharingRegistryException {
+        EntityManager entityManager = JPAUtils.getEntityManager();
+        try {
+            entityManager.getTransaction().begin();
+            R r = committer.commit(entityManager);
+            entityManager.getTransaction().commit();
+            return r;
+        } finally {
+            if (entityManager.isOpen()) {
+                if (entityManager.getTransaction().isActive()) {
+                    entityManager.getTransaction().rollback();
+                }
+                entityManager.close();
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/DomainRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/DomainRepository.java
new file mode 100644
index 0000000..beb4be3
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/DomainRepository.java
@@ -0,0 +1,33 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.entities.DomainEntity;
+import org.apache.custos.sharing.registry.models.Domain;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DomainRepository extends AbstractRepository<Domain, DomainEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
+
+    public DomainRepository(){
+        super(Domain.class, DomainEntity.class);
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityRepository.java
new file mode 100644
index 0000000..8c16ab1
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityRepository.java
@@ -0,0 +1,173 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.entities.EntityEntity;
+import org.apache.custos.sharing.registry.db.entities.EntityPK;
+import org.apache.custos.sharing.registry.db.utils.DBConstants;
+import org.apache.custos.sharing.registry.db.utils.SharingRegistryJDBCConfig;
+import org.apache.custos.sharing.registry.models.*;
+
+import java.util.*;
+
+public class EntityRepository extends AbstractRepository<Entity, EntityEntity, EntityPK> {
+
+    public EntityRepository() {
+        super(Entity.class, EntityEntity.class);
+    }
+
+    public List<Entity> getChildEntities(String domainId, String parentId) throws SharingRegistryException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.EntityTable.DOMAIN_ID, domainId);
+        filters.put(DBConstants.EntityTable.PARENT_ENTITY_ID, parentId);
+        return select(filters, 0, -1);
+    }
+
+    //TODO Replace with prepared statements
+    public List<Entity> searchEntities(String domainId, List<String> groupIds, List<SearchCriteria> filters,
+                                       int offset, int limit) throws SharingRegistryException {
+        String groupIdString = "'";
+        for(String groupId : groupIds)
+            groupIdString += groupId + "','";
+        groupIdString = groupIdString.substring(0, groupIdString.length()-2);
+
+        String query = "SELECT ENTITY.* FROM ENTITY WHERE ENTITY.ENTITY_ID IN (SELECT DISTINCT E.ENTITY_ID FROM ENTITY AS E INNER JOIN SHARING AS S ON (E.ENTITY_ID=S.ENTITY_ID AND E.DOMAIN_ID=S.DOMAIN_ID) WHERE " +
+                "E.DOMAIN_ID = '" + domainId + "' AND " + "S.GROUP_ID IN(" + groupIdString + ") AND ";
+
+        for(SearchCriteria searchCriteria : filters){
+            if(searchCriteria.getSearchField().equals(EntitySearchField.NAME)){
+                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
+                    query += "E.NAME != '" + searchCriteria.getValue() + "' AND ";
+                } else {
+                    query += "E.NAME LIKE '%" + searchCriteria.getValue() + "%' AND ";
+                }
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.DESCRIPTION)){
+                query += "E.DESCRIPTION LIKE '%" + searchCriteria.getValue() + "%' AND ";
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.PERMISSION_TYPE_ID)){
+                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
+                    query += "S.PERMISSION_TYPE_ID != '" + searchCriteria.getValue() + "' AND ";
+                } else {
+                    query += "S.PERMISSION_TYPE_ID IN ('" + searchCriteria.getValue() + "', '"
+                            + (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId) + "') AND ";
+                }
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.FULL_TEXT)){
+                if (new SharingRegistryJDBCConfig().getDriver().contains("derby")) {
+                    query += "E.FULL_TEXT LIKE '%" + searchCriteria.getValue() + "%' AND ";
+                } else {
+                    // FULL TEXT Search with Query Expansion
+                    String queryTerms = "";
+                    for (String word : searchCriteria.getValue().trim().replaceAll(" +", " ").split(" ")) {
+                        queryTerms += queryTerms + " +" + word;
+                    }
+                    queryTerms = queryTerms.trim();
+                    query += "MATCH(E.FULL_TEXT) AGAINST ('" + queryTerms + "' IN BOOLEAN MODE) AND ";
+                }
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.PARRENT_ENTITY_ID)){
+                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
+                    query += "E.PARENT_ENTITY_ID != '" + searchCriteria.getValue() + "' AND ";
+                } else {
+                    query += "E.PARENT_ENTITY_ID = '" + searchCriteria.getValue() + "' AND ";
+                }
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.OWNER_ID)){
+                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
+                    query += "E.OWNER_ID != '" + searchCriteria.getValue() + "' AND ";
+                } else {
+                    query += "E.OWNER_ID = '" + searchCriteria.getValue() + "' AND ";
+                }
+            } else if (searchCriteria.getSearchField().equals(EntitySearchField.ENTITY_TYPE_ID)) {
+                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
+                    query += "E.ENTITY_TYPE_ID != '" + searchCriteria.getValue() + "' AND ";
+                } else {
+                    query += "E.ENTITY_TYPE_ID = '" + searchCriteria.getValue() + "' AND ";
+                }
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.CREATED_TIME)){
+                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
+                    query += "E.CREATED_TIME >= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
+                }else{
+                    query += "E.CREATED_TIME <= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
+                }
+            }else if(searchCriteria.getSearchField().equals(EntitySearchField.UPDATED_TIME)){
+                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
+                    query += "E.UPDATED_TIME >= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
+                }else{
+                    query += "E.UPDATED_TIME <= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
+                }
+            } else if (searchCriteria.getSearchField().equals(EntitySearchField.SHARED_COUNT)) {
+                if (searchCriteria.getSearchCondition().equals(SearchCondition.GTE)) {
+                    query += "E.SHARED_COUNT >= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
+                } else {
+                    query += "E.SHARED_COUNT <= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
+                }
+            }
+        }
+
+        query = query.substring(0, query.length() - 5);
+        query += ") ORDER BY ENTITY.CREATED_TIME DESC";
+
+        final String nativeQuery = query;
+        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+
+        List<Object[]> temp = execute(entityManager -> entityManager.createNativeQuery(nativeQuery).setFirstResult(offset)
+                .setMaxResults(newLimit).getResultList());
+        List<Entity> resultSet = new ArrayList<>();
+
+        HashMap<String, Object> keys = new HashMap<>();
+
+        temp.stream().forEach(rs->{
+            Entity entity = new Entity();
+            entity.setEntityId((String)(rs[0]));
+            entity.setDomainId((String) (rs[1]));
+            entity.setEntityTypeId((String) (rs[2]));
+            entity.setOwnerId((String) (rs[3]));
+            entity.setParentEntityId((String) (rs[4]));
+            entity.setName((String) (rs[5]));
+            entity.setDescription((String)(rs[6]));
+            entity.setBinaryData((byte[]) (rs[7]));
+            entity.setFullText((String) (rs[8]));
+            entity.setSharedCount((long) rs[9]);
+            entity.setOriginalEntityCreationTime((long) (rs[10]));
+            entity.setCreatedTime((long) (rs[11]));
+            entity.setUpdatedTime((long) (rs[12]));
+
+            //Removing duplicates. Another option is to change the query to remove duplicates.
+            if (!keys.containsKey(entity + domainId + "," + entity.getEntityId())) {
+                resultSet.add(entity);
+                keys.put(entity + domainId + "," + entity.getEntityId(), null);
+            }
+        });
+
+        return resultSet;
+    }
+
+    public String getSelectQuery(Map<String, String> filters){
+        String query = "SELECT p from " + EntityEntity.class.getSimpleName() + " as p";
+        if(filters != null && filters.size() != 0){
+            query += " WHERE ";
+            for(String k : filters.keySet()){
+                query += "p." + k + " = '" + filters.get(k) + "' AND ";
+            }
+            query = query.substring(0, query.length()-5);
+        }
+
+        query += " ORDER BY p."+DBConstants.EntityTable.ORIGINAL_ENTITY_CREATION_TIME+" DESC";
+
+        return query;
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityTypeRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityTypeRepository.java
new file mode 100644
index 0000000..8bbc083
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityTypeRepository.java
@@ -0,0 +1,34 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.entities.EntityTypeEntity;
+import org.apache.custos.sharing.registry.db.entities.EntityTypePK;
+import org.apache.custos.sharing.registry.models.EntityType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EntityTypeRepository extends AbstractRepository<EntityType, EntityTypeEntity, EntityTypePK> {
+    private final static Logger logger = LoggerFactory.getLogger(EntityTypeRepository.class);
+
+    public EntityTypeRepository() {
+        super(EntityType.class, EntityTypeEntity.class);
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupAdminRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupAdminRepository.java
new file mode 100644
index 0000000..a7b94a2
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupAdminRepository.java
@@ -0,0 +1,17 @@
+package org.apache.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.entities.GroupAdminEntity;
+import org.apache.custos.sharing.registry.db.entities.GroupAdminPK;
+import org.apache.custos.sharing.registry.models.GroupAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GroupAdminRepository extends AbstractRepository<GroupAdmin, GroupAdminEntity, GroupAdminPK> {
+
+    private final static Logger logger = LoggerFactory.getLogger(GroupAdminRepository.class);
+
+    public GroupAdminRepository() {
+        super(GroupAdmin.class, GroupAdminEntity.class);
+    }
+
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupMembershipRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupMembershipRepository.java
new file mode 100644
index 0000000..a260400
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupMembershipRepository.java
@@ -0,0 +1,104 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.entities.GroupMembershipEntity;
+import org.apache.custos.sharing.registry.db.entities.GroupMembershipPK;
+import org.apache.custos.sharing.registry.db.entities.UserEntity;
+import org.apache.custos.sharing.registry.db.entities.UserGroupEntity;
+import org.apache.custos.sharing.registry.db.utils.DBConstants;
+import org.apache.custos.sharing.registry.models.*;
+
+import java.util.*;
+
+public class GroupMembershipRepository extends AbstractRepository<GroupMembership, GroupMembershipEntity, GroupMembershipPK> {
+
+    public GroupMembershipRepository() {
+        super(GroupMembership.class, GroupMembershipEntity.class);
+    }
+
+    public List<User> getAllChildUsers(String domainId, String groupId) throws SharingRegistryException {
+        String queryString = "SELECT DISTINCT U FROM " + UserEntity.class.getSimpleName() + " U, " + GroupMembershipEntity.class.getSimpleName()
+                + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = U." + DBConstants.UserTable.USER_ID + " AND " +
+                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = U." + DBConstants.UserTable.DOMAIN_ID + " AND " +
+                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + "=:" + DBConstants.GroupMembershipTable.DOMAIN_ID + " AND "+
+                "GM." + DBConstants.GroupMembershipTable.PARENT_ID + "=:" + DBConstants.GroupMembershipTable.PARENT_ID + " AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
+                + "=:" + DBConstants.GroupMembershipTable.CHILD_TYPE;
+        Map<String,Object> queryParameters = new HashMap<>();
+        queryParameters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
+        queryParameters.put(DBConstants.GroupMembershipTable.PARENT_ID, groupId);
+        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_TYPE, GroupChildType.USER.toString());
+        UserRepository userRepository = new UserRepository();
+        List<User> users = userRepository.select(queryString, queryParameters, 0, -1);
+        return users;
+    }
+
+    public List<UserGroup> getAllChildGroups(String domainId, String groupId) throws SharingRegistryException {
+        String queryString = "SELECT DISTINCT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName()
+                + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = G." + DBConstants.UserGroupTable.GROUP_ID + " AND " +
+                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = G." + DBConstants.UserGroupTable.DOMAIN_ID + " AND " +
+                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID+"=:"+DBConstants.GroupMembershipTable.DOMAIN_ID + " AND "+
+                "GM." + DBConstants.GroupMembershipTable.PARENT_ID+"=:"+DBConstants.GroupMembershipTable.PARENT_ID + " AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
+                + "=:" + DBConstants.GroupMembershipTable.CHILD_TYPE;
+        Map<String,Object> queryParameters = new HashMap<>();
+        queryParameters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
+        queryParameters.put(DBConstants.GroupMembershipTable.PARENT_ID, groupId);
+        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_TYPE, GroupChildType.GROUP.toString());
+        UserGroupRepository userGroupRepository = new UserGroupRepository();
+        List<UserGroup> groups = userGroupRepository.select(queryString, queryParameters,0, -1);
+        return groups;
+    }
+
+    public List<UserGroup> getAllMemberGroupsForUser(String domainId, String userId) throws SharingRegistryException {
+        String queryString = "SELECT DISTINCT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName()
+                + " GM WHERE GM." + DBConstants.GroupMembershipTable.PARENT_ID + " = G." + DBConstants.UserGroupTable.GROUP_ID + " AND " +
+                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = G." + DBConstants.UserGroupTable.DOMAIN_ID + " AND " +
+                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID+"=:"+DBConstants.GroupMembershipTable.DOMAIN_ID + " AND "+
+                "GM." + DBConstants.GroupMembershipTable.CHILD_ID+"=:"+DBConstants.GroupMembershipTable.CHILD_ID + " AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
+                + "=:" + DBConstants.GroupMembershipTable.CHILD_TYPE + " AND " +
+                "G." + DBConstants.UserGroupTable.GROUP_CARDINALITY + "=:" + DBConstants.UserGroupTable.GROUP_CARDINALITY;
+        Map<String,Object> queryParameters = new HashMap<>();
+        queryParameters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
+        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_ID, userId);
+        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_TYPE, GroupChildType.USER.toString());
+        queryParameters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.name());
+        UserGroupRepository userGroupRepository = new UserGroupRepository();
+        List<UserGroup> groups = userGroupRepository.select(queryString, queryParameters, 0, -1);
+        return groups;
+    }
+
+    public List<GroupMembership> getAllParentMembershipsForChild(String domainId, String childId) throws SharingRegistryException {
+        List<GroupMembership> finalParentGroups = new ArrayList<>();
+        Map<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.GroupMembershipTable.CHILD_ID, childId);
+        filters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
+        LinkedList<GroupMembership> temp = new LinkedList<>();
+        select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
+        while (temp.size() > 0){
+            GroupMembership gm = temp.pop();
+            filters = new HashMap<>();
+            filters.put(DBConstants.GroupMembershipTable.CHILD_ID, gm.getParentId());
+            filters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
+            select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
+            finalParentGroups.add(gm);
+        }
+        return finalParentGroups;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/PermissionTypeRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/PermissionTypeRepository.java
new file mode 100644
index 0000000..c3c4a67
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/PermissionTypeRepository.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.entities.PermissionTypeEntity;
+import org.apache.custos.sharing.registry.db.entities.PermissionTypePK;
+import org.apache.custos.sharing.registry.db.utils.DBConstants;
+import org.apache.custos.sharing.registry.models.PermissionType;
+import org.apache.custos.sharing.registry.models.SharingRegistryException;
+import org.apache.custos.sharing.registry.server.SharingRegistryServerHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+
+public class PermissionTypeRepository extends AbstractRepository<PermissionType, PermissionTypeEntity, PermissionTypePK> {
+    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeRepository.class);
+
+    public PermissionTypeRepository() {
+        super(PermissionType.class, PermissionTypeEntity.class);
+    }
+
+    public String getOwnerPermissionTypeIdForDomain(String domainId) throws SharingRegistryException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domainId);
+        filters.put(DBConstants.PermissionTypeTable.NAME, SharingRegistryServerHandler.OWNER_PERMISSION_NAME);
+        List<PermissionType> permissionTypeList = select(filters, 0, -1);
+        if(permissionTypeList.size() != 1){
+            throw new SharingRegistryException("GLOBAL Permission inconsistency. Found " + permissionTypeList.size()
+                    + " records with " + SharingRegistryServerHandler.OWNER_PERMISSION_NAME + " name");
+        }
+        return permissionTypeList.get(0).getPermissionTypeId();
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/SharingRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/SharingRepository.java
new file mode 100644
index 0000000..29ee9a9
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/SharingRepository.java
@@ -0,0 +1,115 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.entities.SharingEntity;
+import org.apache.custos.sharing.registry.db.entities.SharingPK;
+import org.apache.custos.sharing.registry.db.utils.DBConstants;
+import org.apache.custos.sharing.registry.models.Sharing;
+import org.apache.custos.sharing.registry.models.SharingRegistryException;
+import org.apache.custos.sharing.registry.models.SharingType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.Query;
+
+public class SharingRepository extends AbstractRepository<Sharing, SharingEntity, SharingPK> {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRepository.class);
+
+    public SharingRepository() {
+        super(Sharing.class, SharingEntity.class);
+    }
+
+    public List<Sharing> getIndirectSharedChildren(String domainId, String parentId, String permissionTypeId) throws SharingRegistryException {
+        HashMap<String, String> filters = new HashMap<>();
+        filters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
+        filters.put(DBConstants.SharingTable.INHERITED_PARENT_ID, parentId);
+        filters.put(DBConstants.SharingTable.SHARING_TYPE, SharingType.INDIRECT_CASCADING.toString());
+        filters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
+
+        return select(filters, 0, -1);
+    }
+
+    public List<Sharing> getCascadingPermissionsForEntity(String domainId, String entityId) throws SharingRegistryException {
+        String query = "SELECT DISTINCT p from " + SharingEntity.class.getSimpleName() + " as p";
+        query += " WHERE ";
+        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
+        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
+        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " IN('" + SharingType.DIRECT_CASCADING.toString()
+                + "', '" + SharingType.INDIRECT_CASCADING + "') ";
+        query += " ORDER BY p.createdTime DESC";
+        Map<String,Object> queryParameters = new HashMap<>();
+        queryParameters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
+        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
+        return select(query, queryParameters, 0, -1);
+    }
+
+    public boolean hasAccess(String domainId, String entityId, List<String> groupIds, List<String> permissionTypeIds) throws SharingRegistryException {
+        Map<String,Object> queryParameters = new HashMap<>();
+        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
+        query += " WHERE ";
+        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
+        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
+        queryParameters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
+        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
+        query += "p." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " IN :" + DBConstants.SharingTable.PERMISSION_TYPE_ID + " AND ";
+        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeIds);
+        query += "p." + DBConstants.SharingTable.GROUP_ID + " IN :" + DBConstants.SharingTable.GROUP_ID + " ";
+        queryParameters.put(DBConstants.SharingTable.GROUP_ID, groupIds);
+        query += " ORDER BY p.createdTime DESC";
+        return select(query, queryParameters, 0, -1).size() > 0;
+    }
+
+    public int getSharedCount(String domainId, String entityId) throws SharingRegistryException {
+        Map<String,Object> queryParameters = new HashMap<>();
+        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
+        query += " WHERE ";
+        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
+        queryParameters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
+        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
+        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
+        String permissionTypeIdString = (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId);
+        query += "p." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " <> :" + DBConstants.SharingTable.PERMISSION_TYPE_ID + " AND ";
+        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeIdString);
+        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " <> :" + DBConstants.SharingTable.SHARING_TYPE;
+        queryParameters.put(DBConstants.SharingTable.SHARING_TYPE, SharingType.INDIRECT_CASCADING.toString());
+        return select(query, queryParameters, 0, -1).size();
+    }
+
+    public void removeAllIndirectCascadingPermissionsForEntity(String domainId, String entityId) throws SharingRegistryException {
+        String query = "DELETE from " + SharingEntity.class.getSimpleName() + " as p";
+        query += " WHERE ";
+        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
+        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
+        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " = '" + SharingType.INDIRECT_CASCADING.toString() + "' ";
+        final String finalQuery = query;
+        execute(em -> {
+            Query q = em.createQuery(finalQuery);
+            q.setParameter(DBConstants.SharingTable.DOMAIN_ID, domainId);
+            q.setParameter(DBConstants.SharingTable.ENTITY_ID, entityId);
+            q.executeUpdate();
+            return true;
+        });
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserGroupRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserGroupRepository.java
new file mode 100644
index 0000000..9cac79c
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserGroupRepository.java
@@ -0,0 +1,95 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.entities.SharingEntity;
+import org.apache.custos.sharing.registry.db.entities.UserGroupEntity;
+import org.apache.custos.sharing.registry.db.entities.UserGroupPK;
+import org.apache.custos.sharing.registry.db.utils.DBConstants;
+import org.apache.custos.sharing.registry.models.GroupCardinality;
+import org.apache.custos.sharing.registry.models.SharingRegistryException;
+import org.apache.custos.sharing.registry.models.SharingType;
+import org.apache.custos.sharing.registry.models.UserGroup;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroupEntity, UserGroupPK> {
+    private final static Logger logger = LoggerFactory.getLogger(UserGroupRepository.class);
+
+    public UserGroupRepository() {
+        super(UserGroup.class, UserGroupEntity.class);
+    }
+
+    public List<UserGroup> getAccessibleGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
+        return getAccessibleGroupsInternal(domainId, entityId, permissionTypeId);
+    }
+
+    public List<UserGroup> getDirectlyAccessibleGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
+        return getAccessibleGroupsInternal(domainId, entityId, permissionTypeId, SharingType.DIRECT_CASCADING, SharingType.DIRECT_NON_CASCADING);
+    }
+
+    private List<UserGroup> getAccessibleGroupsInternal(String domainId, String entityId, String permissionTypeId, SharingType... sharingTypes) throws SharingRegistryException {
+        String query = "SELECT DISTINCT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
+        query += " WHERE ";
+        query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
+        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
+        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = :" + DBConstants.UserGroupTable.DOMAIN_ID + " AND ";
+        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
+        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = :" + DBConstants.SharingTable.PERMISSION_TYPE_ID + " AND ";
+        query += "g." + DBConstants.UserGroupTable.GROUP_CARDINALITY + " = :" + DBConstants.UserGroupTable.GROUP_CARDINALITY;
+        if (!Arrays.asList(sharingTypes).isEmpty()) {
+            query += " AND s." + DBConstants.SharingTable.SHARING_TYPE + " IN :" + DBConstants.SharingTable.SHARING_TYPE;
+        }
+        query += " ORDER BY s.createdTime DESC";
+        Map<String,Object> queryParameters = new HashMap<>();
+        queryParameters.put(DBConstants.UserGroupTable.DOMAIN_ID, domainId);
+        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
+        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
+        queryParameters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.toString());
+        if (!Arrays.asList(sharingTypes).isEmpty()) {
+            queryParameters.put(DBConstants.SharingTable.SHARING_TYPE, Arrays.asList(sharingTypes).stream().map(s -> s.name()).collect(Collectors.toList()));
+        }
+        return select(query, queryParameters, 0, -1);
+    }
+
+    //checks whether is shared with any user or group with any permission
+    public boolean isShared(String domainId, String entityId) throws SharingRegistryException {
+        String query = "SELECT DISTINCT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
+        query += " WHERE ";
+        query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
+        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
+        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = :" + DBConstants.UserGroupTable.DOMAIN_ID + " AND ";
+        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
+        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " <> :" + DBConstants.SharingTable.PERMISSION_TYPE_ID;
+        query += " ORDER BY s.createdTime DESC";
+        Map<String,Object> queryParameters = new HashMap<>();
+        queryParameters.put(DBConstants.UserGroupTable.DOMAIN_ID, domainId);
+        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
+        String ownerPermissionTypeIdForDomain = (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId);
+        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, ownerPermissionTypeIdForDomain);
+        return select(query, queryParameters, 0, -1).size() != 0;
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserRepository.java
new file mode 100644
index 0000000..4d28229
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserRepository.java
@@ -0,0 +1,79 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.repositories;
+
+import org.apache.custos.sharing.registry.db.entities.SharingEntity;
+import org.apache.custos.sharing.registry.db.entities.UserEntity;
+import org.apache.custos.sharing.registry.db.entities.UserPK;
+import org.apache.custos.sharing.registry.db.utils.DBConstants;
+import org.apache.custos.sharing.registry.models.SharingRegistryException;
+import org.apache.custos.sharing.registry.models.SharingType;
+import org.apache.custos.sharing.registry.models.User;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class UserRepository extends AbstractRepository<User, UserEntity, UserPK> {
+    private final static Logger logger = LoggerFactory.getLogger(UserRepository.class);
+
+    public UserRepository() {
+        super(User.class, UserEntity.class);
+    }
+
+
+    public List<User> getAccessibleUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
+        if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
+            return getAccessibleUsersInternal(domainId, entityId, permissionTypeId, SharingType.DIRECT_CASCADING, SharingType.DIRECT_NON_CASCADING);
+        } else {
+            return getAccessibleUsersInternal(domainId, entityId, permissionTypeId);
+        }
+    }
+
+    public List<User> getDirectlyAccessibleUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
+        return getAccessibleUsersInternal(domainId, entityId, permissionTypeId, SharingType.DIRECT_CASCADING, SharingType.DIRECT_NON_CASCADING);
+    }
+
+    private List<User> getAccessibleUsersInternal(String domainId, String entityId, String permissionTypeId, SharingType... sharingTypes) throws SharingRegistryException {
+        Map<String,Object> queryParameters = new HashMap<>();
+        String query = "SELECT DISTINCT u from " + UserEntity.class.getSimpleName() + " u, " + SharingEntity.class.getSimpleName() + " s";
+        query += " WHERE ";
+        query += "u." + DBConstants.UserTable.USER_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
+        query += "u." + DBConstants.UserTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
+        query += "u." + DBConstants.UserTable.DOMAIN_ID + " = :" + DBConstants.UserTable.DOMAIN_ID + " AND ";
+        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
+        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = :" + DBConstants.SharingTable.PERMISSION_TYPE_ID;
+        queryParameters.put(DBConstants.UserTable.DOMAIN_ID, domainId);
+        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
+        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
+
+        if (!Arrays.asList(sharingTypes).isEmpty()) {
+            query += " AND s." + DBConstants.SharingTable.SHARING_TYPE + " IN :" + DBConstants.SharingTable.SHARING_TYPE;
+            queryParameters.put(DBConstants.SharingTable.SHARING_TYPE, Arrays.asList(sharingTypes).stream().map(s -> s.name()).collect(Collectors.toList()));
+        }
+
+        query += " ORDER BY s.createdTime DESC";
+        return select(query, queryParameters,0, -1);
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/Committer.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/Committer.java
new file mode 100644
index 0000000..28d2e09
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/Committer.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.utils;
+
+@FunctionalInterface
+public interface Committer<T, R>  {
+
+    R commit(T t);
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/DBConstants.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/DBConstants.java
new file mode 100644
index 0000000..5f8f549
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/DBConstants.java
@@ -0,0 +1,106 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DBConstants {
+    private final static Logger logger = LoggerFactory.getLogger(DBConstants.class);
+
+    public static int SELECT_MAX_ROWS = 1000;
+
+    public static class DomainTable {
+        public static final String DOMAIN_ID = "domainId";
+        public static final String NAME = "name";
+        public static final String DESCRIPTION = "description";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class UserTable {
+        public static final String USER_ID = "userId";
+        public static final String DOMAIN_ID = "domainId";
+        public static final String USER_NAME = "userName";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class UserGroupTable {
+        public static final String GROUP_ID = "groupId";
+        public static final String DOMAIN_ID = "domainId";
+        public static final String NAME = "name";
+        public static final String DESCRIPTION = "description";
+        public static final String OWNER_ID = "ownerId";
+        public static final String GROUP_TYPE = "groupType";
+        public static final String GROUP_CARDINALITY = "groupCardinality";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class GroupMembershipTable {
+        public static final String PARENT_ID = "parentId";
+        public static final String CHILD_ID = "childId";
+        public static final String CHILD_TYPE = "childType";
+        public static final String DOMAIN_ID = "domainId";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class EntityTypeTable {
+        public static final String ENTITY_TYPE_ID = "entityTypeId";
+        public static final String DOMAIN_ID = "domainId";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class PermissionTypeTable {
+        public static final String ENTITY_TYPE_ID = "permissionTypeId";
+        public static final String DOMAIN_ID = "domainId";
+        public static final String NAME = "name";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+
+    public static class EntityTable {
+        public static final String ENTITY_ID = "entityId";
+        public static final String PARENT_ENTITY_ID = "parentEntityId";
+        public static final String ENTITY_TYPE_ID = "entityTypeId";
+        public static final String NAME = "name";
+        public static final String DESCRIPTION = "description";
+        public static final String FULL_TEXT = "fullText";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+        public static final String DOMAIN_ID = "domainId";
+        public static final String ORIGINAL_ENTITY_CREATION_TIME = "originalEntityCreationTime";
+        public static final String SHARED = "shared";
+    }
+
+    public static class SharingTable {
+        public static final String DOMAIN_ID = "domainId";
+        public static final String PERMISSION_TYPE_ID = "permissionTypeId";
+        public static final String ENTITY_ID = "entityId";
+        public static final String GROUP_ID = "groupId";
+        public static final String INHERITED_PARENT_ID = "inheritedParentId";
+        public static final String SHARING_TYPE = "sharingType";
+        public static final String CREATED_TIME = "createdTime";
+        public static final String UPDATED_TIME = "updatedTime";
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/JPAUtils.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/JPAUtils.java
new file mode 100644
index 0000000..f562c15
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/JPAUtils.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.utils;
+
+import org.apache.custos.commons.utils.JDBCConfig;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+public class JPAUtils {
+    public static final String PERSISTENCE_UNIT_NAME = "airavata-sharing-registry";
+    private static final JDBCConfig JDBC_CONFIG = new SharingRegistryJDBCConfig();
+    private static final EntityManagerFactory factory = org.apache.custos.commons.utils.JPAUtils.getEntityManagerFactory(PERSISTENCE_UNIT_NAME, JDBC_CONFIG);
+
+    public static EntityManager getEntityManager() {
+        return factory.createEntityManager();
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/ObjectMapperSingleton.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/ObjectMapperSingleton.java
new file mode 100644
index 0000000..935e949
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/ObjectMapperSingleton.java
@@ -0,0 +1,38 @@
+/**
+ *
+ * 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.custos.sharing.registry.db.utils;
+
+import org.dozer.DozerBeanMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ObjectMapperSingleton extends DozerBeanMapper{
+    private final static Logger logger = LoggerFactory.getLogger(ObjectMapperSingleton.class);
+
+    private static ObjectMapperSingleton instance;
+
+    private ObjectMapperSingleton(){}
+
+    public static ObjectMapperSingleton getInstance(){
+        if(instance == null)
+            instance = new ObjectMapperSingleton();
+        return instance;
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryDBInitConfig.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryDBInitConfig.java
new file mode 100644
index 0000000..f95246a
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryDBInitConfig.java
@@ -0,0 +1,47 @@
+/*
+ * 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.custos.sharing.registry.db.utils;
+
+
+import org.apache.custos.commons.utils.DBInitConfig;
+import org.apache.custos.commons.utils.JDBCConfig;
+
+public class SharingRegistryDBInitConfig implements DBInitConfig {
+    private String dbInitScriptPrefix = "database_scripts/sharing-registry";
+
+    @Override
+    public JDBCConfig getJDBCConfig() {
+        return new SharingRegistryJDBCConfig();
+    }
+
+    @Override
+    public String getDBInitScriptPrefix() {
+        return this.dbInitScriptPrefix;
+    }
+
+    @Override
+    public String getCheckTableName() {
+        return "CONFIGURATION";
+    }
+
+    public void setDBInitScriptPrefix(String dbInitScriptPrefix) {
+        this.dbInitScriptPrefix = dbInitScriptPrefix;
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryJDBCConfig.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryJDBCConfig.java
new file mode 100644
index 0000000..747d93f
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryJDBCConfig.java
@@ -0,0 +1,67 @@
+/*
+ * 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.custos.sharing.registry.db.utils;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.utils.JDBCConfig;
+import org.apache.custos.commons.utils.ServerSettings;
+
+public class SharingRegistryJDBCConfig implements JDBCConfig {
+
+    private static final String SHARING_REG_JDBC_DRIVER = "sharingcatalog.jdbc.driver";
+    private static final String SHARING_REG_JDBC_URL = "sharingcatalog.jdbc.url";
+    private static final String SHARING_REG_JDBC_USER = "sharingcatalog.jdbc.user";
+    private static final String SHARING_REG_JDBC_PWD = "sharingcatalog.jdbc.password";
+    private static final String SHARING_REG_VALIDATION_QUERY = "sharingcatalog.validationQuery";
+
+    @Override
+    public String getURL() {
+        return readServerProperties(SHARING_REG_JDBC_URL);
+    }
+
+    @Override
+    public String getDriver() {
+        return readServerProperties(SHARING_REG_JDBC_DRIVER);
+    }
+
+    @Override
+    public String getUser() {
+        return readServerProperties(SHARING_REG_JDBC_USER);
+    }
+
+    @Override
+    public String getPassword() {
+        return readServerProperties(SHARING_REG_JDBC_PWD);
+    }
+
+    @Override
+    public String getValidationQuery() {
+        return readServerProperties(SHARING_REG_VALIDATION_QUERY);
+    }
+
+    private String readServerProperties(String propertyName) {
+        try {
+            return ServerSettings.getSetting(propertyName);
+        } catch (ApplicationSettingsException e) {
+            throw new RuntimeException("Unable to read server.properties...", e);
+        }
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/ServerMain.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/ServerMain.java
new file mode 100644
index 0000000..0128361
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/ServerMain.java
@@ -0,0 +1,101 @@
+/**
+ *
+ * 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.custos.sharing.registry.server;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+public class ServerMain {
+    private final static Logger logger = LoggerFactory.getLogger(ServerMain.class);
+
+    private static int serverPID = -1;
+    private static final String stopFileNamePrefix = "server_stop";
+    private static final String serverStartedFileNamePrefix = "server_start";
+
+    public static void main(String[] args) {
+        try {
+            setServerStarted();
+            new SharingRegistryServer().start();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+        }
+    }
+
+    @SuppressWarnings({"resource"})
+    private static void setServerStarted() {
+        try {
+            serverPID = getPID();
+            deleteOldStopRequests();
+            File serverStartedFile = null;
+            serverStartedFile = new File(getServerStartedFileName());
+            serverStartedFile.createNewFile();
+            serverStartedFile.deleteOnExit();
+            new RandomAccessFile(serverStartedFile, "rw").getChannel().lock();
+        } catch (FileNotFoundException e) {
+            logger.warn(e.getMessage(), e);
+        } catch (IOException e) {
+            logger.warn(e.getMessage(), e);
+        }
+    }
+
+    private static String getServerStartedFileName() {
+        String SHARING_REGISTRY_HOME = System.getenv("" +"SHARING_REGISTRY_HOME");
+        if(SHARING_REGISTRY_HOME==null)
+            SHARING_REGISTRY_HOME = "/tmp";
+        else
+            SHARING_REGISTRY_HOME = SHARING_REGISTRY_HOME + "/bin";
+        return new File(SHARING_REGISTRY_HOME, serverStartedFileNamePrefix + "_" + Integer.toString(serverPID)).toString();
+    }
+
+    private static int getPID() {
+        try {
+            java.lang.management.RuntimeMXBean runtime = java.lang.management.ManagementFactory
+                    .getRuntimeMXBean();
+            java.lang.reflect.Field jvm = runtime.getClass()
+                    .getDeclaredField("jvm");
+            jvm.setAccessible(true);
+            sun.management.VMManagement mgmt = (sun.management.VMManagement) jvm
+                    .get(runtime);
+            java.lang.reflect.Method pid_method = mgmt.getClass()
+                    .getDeclaredMethod("getProcessId");
+            pid_method.setAccessible(true);
+
+            int pid = (Integer) pid_method.invoke(mgmt);
+            return pid;
+        } catch (Exception e) {
+            return -1;
+        }
+    }
+
+    private static void deleteOldStopRequests() {
+        File[] files = new File(".").listFiles();
+        for (File file : files) {
+            if (file.getName().contains(stopFileNamePrefix)) {
+                file.delete();
+            }
+
+        }
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServer.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServer.java
new file mode 100644
index 0000000..78fbb51
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServer.java
@@ -0,0 +1,191 @@
+/**
+ *
+ * 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.custos.sharing.registry.server;
+
+import org.apache.custos.commons.exceptions.CustosException;
+import org.apache.custos.commons.utils.IServer;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.sharing.registry.db.utils.SharingRegistryDBInitConfig;
+import org.apache.custos.sharing.registry.models.SharingRegistryException;
+import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TSSLTransportFactory;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TServerTransport;
+import org.apache.thrift.transport.TTransportException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+
+public class SharingRegistryServer implements IServer {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServer.class);
+
+    public static final String SHARING_REG_SERVER_HOST = "sharing.registry.server.host";
+    public static final String SHARING_REG_SERVER_PORT = "sharing.registry.server.port";
+
+    private static final String SERVER_NAME = "Sharing Registry Server";
+    private static final String SERVER_VERSION = "1.0";
+
+    private IServer.ServerStatus status;
+    private TServer server;
+    private boolean testMode = false;
+
+    public SharingRegistryServer() {
+        setStatus(IServer.ServerStatus.STOPPED);
+    }
+
+    @Override
+    public String getName() {
+        return SERVER_NAME;
+    }
+
+    @Override
+    public String getVersion() {
+        return SERVER_VERSION;
+    }
+
+    @Override
+    public void start() throws Exception {
+        try {
+            setStatus(IServer.ServerStatus.STARTING);
+
+            final int serverPort = Integer.parseInt(ServerSettings.getSetting(SHARING_REG_SERVER_PORT));
+            final String serverHost = ServerSettings.getSetting(SHARING_REG_SERVER_HOST);
+            SharingRegistryService.Processor processor = new SharingRegistryService.Processor(
+                    new SharingRegistryServerHandler(createSharingRegistryDBInitConfig()));
+
+            TServerTransport serverTransport;
+
+            if (!ServerSettings.isSharingTLSEnabled()) {
+                InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
+                serverTransport = new TServerSocket(inetSocketAddress);
+                TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
+                options.minWorkerThreads = 30;
+                server = new TThreadPoolServer(options.processor(processor));
+            }else{
+                TSSLTransportFactory.TSSLTransportParameters TLSParams =
+                        new TSSLTransportFactory.TSSLTransportParameters();
+                TLSParams.requireClientAuth(true);
+                TLSParams.setKeyStore(ServerSettings.getKeyStorePath(), ServerSettings.getKeyStorePassword());
+                TLSParams.setTrustStore(ServerSettings.getTrustStorePath(), ServerSettings.getTrustStorePassword());
+                TServerSocket TLSServerTransport = TSSLTransportFactory.getServerSocket(
+                        serverPort, ServerSettings.getTLSClientTimeout(),
+                        InetAddress.getByName(serverHost), TLSParams);
+                TThreadPoolServer.Args options = new TThreadPoolServer.Args(TLSServerTransport);
+                options.minWorkerThreads = 30;
+                server = new TThreadPoolServer(options.processor(processor));
+            }
+
+            new Thread() {
+                public void run() {
+                    server.serve();
+                    setStatus(IServer.ServerStatus.STOPPED);
+                    logger.info("Sharing Registry Server Stopped.");
+                }
+            }.start();
+            new Thread() {
+                public void run() {
+                    while (!server.isServing()) {
+                        try {
+                            Thread.sleep(500);
+                        } catch (InterruptedException e) {
+                            break;
+                        }
+                    }
+                    if (server.isServing()) {
+//                        try {
+//                            logger.info("Register sharing service with DB Event publishers");
+//                            //SharingServiceDBEventMessagingFactory.registerSharingServiceWithPublishers(Constants.PUBLISHERS);
+//
+//                            logger.info("Start sharing service DB Event subscriber");
+//                            //SharingServiceDBEventMessagingFactory.getDBEventSubscriber();
+//                        } catch (CustosException | SharingRegistryException e) {
+//                            logger.error("Error starting sharing service. Error setting up DB event services.");
+//                            server.stop();
+//                        }
+                        setStatus(IServer.ServerStatus.STARTED);
+                        logger.info("Starting Sharing Registry Server on Port " + serverPort);
+                        logger.info("Listening to Sharing Registry server clients ....");
+                    }
+                }
+            }.start();
+
+        } catch (TTransportException e) {
+            setStatus(IServer.ServerStatus.FAILED);
+            throw new Exception("Error while starting the Sharing Registry service", e);
+        }
+    }
+
+    @Override
+    public void stop() throws Exception {
+        if (server!=null && server.isServing()){
+            setStatus(IServer.ServerStatus.STOPING);
+            server.stop();
+        }
+    }
+
+    @Override
+    public void restart() throws Exception {
+        stop();
+        start();
+    }
+
+    @Override
+    public void configure() throws Exception {
+
+    }
+
+    @Override
+    public IServer.ServerStatus getStatus() throws Exception {
+        return status;
+    }
+
+    private void setStatus(IServer.ServerStatus stat){
+        status=stat;
+        status.updateTime();
+    }
+
+    public TServer getServer() {
+        return server;
+    }
+
+    public void setServer(TServer server) {
+        this.server = server;
+    }
+
+    public boolean isTestMode() {
+        return testMode;
+    }
+
+    public void setTestMode(boolean testMode) {
+        this.testMode = testMode;
+    }
+
+    private SharingRegistryDBInitConfig createSharingRegistryDBInitConfig() {
+        SharingRegistryDBInitConfig sharingRegistryDBInitConfig = new SharingRegistryDBInitConfig();
+        if (this.testMode) {
+            sharingRegistryDBInitConfig.setDBInitScriptPrefix("sharing-registry");
+        }
+        return sharingRegistryDBInitConfig;
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServerHandler.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServerHandler.java
new file mode 100644
index 0000000..fa9fa3b
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServerHandler.java
@@ -0,0 +1,1273 @@
+/**
+ *
+ * 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.custos.sharing.registry.server;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.utils.DBInitializer;
+import org.apache.custos.sharing.registry.db.entities.*;
+import org.apache.custos.sharing.registry.db.repositories.*;
+import org.apache.custos.sharing.registry.db.utils.DBConstants;
+import org.apache.custos.sharing.registry.db.utils.SharingRegistryDBInitConfig;
+import org.apache.custos.sharing.registry.models.*;
+import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
+import org.apache.custos.sharing.registry.service.cpi.sharing_cpiConstants;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.*;
+
+public class SharingRegistryServerHandler implements SharingRegistryService.Iface{
+    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServerHandler.class);
+
+    public static String OWNER_PERMISSION_NAME = "OWNER";
+
+    public SharingRegistryServerHandler(SharingRegistryDBInitConfig sharingRegistryDBInitConfig)  throws ApplicationSettingsException, TException {
+        DBInitializer.initializeDB(sharingRegistryDBInitConfig);
+    }
+
+    @Override
+    public String getAPIVersion() throws TException {
+        return sharing_cpiConstants.SHARING_CPI_VERSION;
+    }
+
+    /**
+     * * Domain Operations
+     * *
+     */
+    @Override
+    public String createDomain(Domain domain) throws SharingRegistryException, DuplicateEntryException, TException {
+        try{
+            domain.setDomainId(domain.getName());
+            if((new DomainRepository()).get(domain.getDomainId()) != null)
+                throw new DuplicateEntryException("There exist domain with given domain id");
+
+            domain.setCreatedTime(System.currentTimeMillis());
+            domain.setUpdatedTime(System.currentTimeMillis());
+            (new DomainRepository()).create(domain);
+
+            //create the global permission for the domain
+            PermissionType permissionType = new PermissionType();
+            permissionType.setPermissionTypeId(domain.getDomainId() + ":" + OWNER_PERMISSION_NAME);
+            permissionType.setDomainId(domain.getDomainId());
+            permissionType.setName(OWNER_PERMISSION_NAME);
+            permissionType.setDescription("GLOBAL permission to " + domain.getDomainId());
+            permissionType.setCreatedTime(System.currentTimeMillis());
+            permissionType.setUpdatedTime(System.currentTimeMillis());
+            (new PermissionTypeRepository()).create(permissionType);
+
+            return domain.getDomainId();
+        }catch (Throwable ex){
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean updateDomain(Domain domain) throws SharingRegistryException, TException {
+        try{
+            Domain oldDomain = (new DomainRepository()).get(domain.getDomainId());
+            domain.setCreatedTime(oldDomain.getCreatedTime());
+            domain.setUpdatedTime(System.currentTimeMillis());
+            domain = getUpdatedObject(oldDomain, domain);
+            (new DomainRepository()).update(domain);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * <p>API method to check Domain Exists</p>
+     *
+     * @param domainId
+     */
+    @Override
+    public boolean isDomainExists(String domainId) throws SharingRegistryException, TException {
+        try{
+            return (new DomainRepository()).isExists(domainId);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean deleteDomain(String domainId) throws SharingRegistryException, TException {
+        try{
+            (new DomainRepository()).delete(domainId);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public Domain getDomain(String domainId) throws SharingRegistryException, TException {
+        try{
+            return (new DomainRepository()).get(domainId);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<Domain> getDomains(int offset, int limit) throws TException {
+        try{
+            return (new DomainRepository()).select(new HashMap<>(), offset, limit);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * * User Operations
+     * *
+     */
+    @Override
+    public String createUser(User user) throws SharingRegistryException, DuplicateEntryException, TException {
+        try{
+            UserPK userPK = new UserPK();
+            userPK.setUserId(user.getUserId());
+            userPK.setDomainId(user.getDomainId());
+            if((new UserRepository()).get(userPK) != null)
+                throw new DuplicateEntryException("There exist user with given user id");
+
+            user.setCreatedTime(System.currentTimeMillis());
+            user.setUpdatedTime(System.currentTimeMillis());
+            (new UserRepository()).create(user);
+
+            UserGroup userGroup = new UserGroup();
+            userGroup.setGroupId(user.getUserId());
+            userGroup.setDomainId(user.getDomainId());
+            userGroup.setName(user.getUserName());
+            userGroup.setDescription("user " + user.getUserName() + " group");
+            userGroup.setOwnerId(user.getUserId());
+            userGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
+            userGroup.setGroupCardinality(GroupCardinality.SINGLE_USER);
+            (new UserGroupRepository()).create(userGroup);
+
+            return user.getUserId();
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean updatedUser(User user) throws SharingRegistryException, TException {
+        try{
+            UserPK userPK = new UserPK();
+            userPK.setUserId(user.getUserId());
+            userPK.setDomainId(user.getDomainId());
+            User oldUser = (new UserRepository()).get(userPK);
+            user.setCreatedTime(oldUser.getCreatedTime());
+            user.setUpdatedTime(System.currentTimeMillis());
+            user = getUpdatedObject(oldUser, user);
+            (new UserRepository()).update(user);
+
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setGroupId(user.getUserId());
+            userGroupPK.setDomainId(user.getDomainId());
+            UserGroup userGroup = (new UserGroupRepository()).get(userGroupPK);
+            userGroup.setName(user.getUserName());
+            userGroup.setDescription("user " + user.getUserName() + " group");
+            updateGroup(userGroup);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * <p>API method to check User Exists</p>
+     *
+     * @param userId
+     */
+    @Override
+    public boolean isUserExists(String domainId, String userId) throws SharingRegistryException, TException {
+        try{
+            UserPK userPK = new UserPK();
+            userPK.setDomainId(domainId);
+            userPK.setUserId(userId);
+            return (new UserRepository()).isExists(userPK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean deleteUser(String domainId, String userId) throws SharingRegistryException, TException {
+        try{
+            UserPK userPK = new UserPK();
+            userPK.setUserId(userId);
+            userPK.setDomainId(domainId);
+            (new UserRepository()).delete(userPK);
+
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setGroupId(userId);
+            userGroupPK.setDomainId(domainId);
+            (new UserGroupRepository()).delete(userGroupPK);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public User getUser(String domainId, String userId) throws SharingRegistryException, TException {
+        try{
+            UserPK userPK = new UserPK();
+            userPK.setUserId(userId);
+            userPK.setDomainId(domainId);
+            return (new UserRepository()).get(userPK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<User> getUsers(String domain, int offset, int limit) throws SharingRegistryException, TException {
+        try{
+            HashMap<String, String> filters = new HashMap<>();
+            filters.put(DBConstants.UserTable.DOMAIN_ID, domain);
+            return (new UserRepository()).select(filters, offset, limit);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * * Group Operations
+     * *
+     */
+    @Override
+    public String createGroup(UserGroup group) throws SharingRegistryException, TException {
+        try{
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setGroupId(group.getGroupId());
+            userGroupPK.setDomainId(group.getDomainId());
+            if((new UserGroupRepository()).get(userGroupPK) != null)
+                throw new SharingRegistryException("There exist group with given group id");
+            //Client created groups are always of type MULTI_USER
+            group.setGroupCardinality(GroupCardinality.MULTI_USER);
+            group.setCreatedTime(System.currentTimeMillis());
+            group.setUpdatedTime(System.currentTimeMillis());
+            //Add group admins once the group is created
+            group.unsetGroupAdmins();
+            (new UserGroupRepository()).create(group);
+
+            addUsersToGroup(group.getDomainId(), Arrays.asList(group.getOwnerId()), group.getGroupId());
+            return group.getGroupId();
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean updateGroup(UserGroup group) throws SharingRegistryException, TException {
+        try{
+            group.setUpdatedTime(System.currentTimeMillis());
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setGroupId(group.getGroupId());
+            userGroupPK.setDomainId(group.getDomainId());
+            UserGroup oldGroup = (new UserGroupRepository()).get(userGroupPK);
+            group.setGroupCardinality(oldGroup.getGroupCardinality());
+            group.setCreatedTime(oldGroup.getCreatedTime());
+            group = getUpdatedObject(oldGroup, group);
+
+            if(!group.getOwnerId().equals(oldGroup.getOwnerId()))
+                throw new SharingRegistryException("Group owner cannot be changed");
+
+            (new UserGroupRepository()).update(group);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * API method to check Group Exists
+     * @param domainId
+     * @param groupId
+     * @return
+     * @throws SharingRegistryException
+     * @throws TException
+     */
+    @Override
+    public boolean isGroupExists(String domainId, String groupId) throws SharingRegistryException, TException {
+        try{
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setDomainId(domainId);
+            userGroupPK.setGroupId(groupId);
+            return (new UserGroupRepository()).isExists(userGroupPK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean deleteGroup(String domainId, String groupId) throws SharingRegistryException, TException {
+        try{
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setGroupId(groupId);
+            userGroupPK.setDomainId(domainId);
+            (new UserGroupRepository()).delete(userGroupPK);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public UserGroup getGroup(String domainId, String groupId) throws SharingRegistryException, TException {
+        try{
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setGroupId(groupId);
+            userGroupPK.setDomainId(domainId);
+            return (new UserGroupRepository()).get(userGroupPK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<UserGroup> getGroups(String domain, int offset, int limit) throws TException {
+        try{
+            HashMap<String, String> filters = new HashMap<>();
+            filters.put(DBConstants.UserGroupTable.DOMAIN_ID, domain);
+            // Only return groups with MULTI_USER cardinality which is the only type of cardinality allowed for client created groups
+            filters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.name());
+            return (new UserGroupRepository()).select(filters, offset, limit);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean addUsersToGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException, TException {
+        try{
+            for(int i=0; i < userIds.size(); i++){
+                GroupMembership groupMembership = new GroupMembership();
+                groupMembership.setParentId(groupId);
+                groupMembership.setChildId(userIds.get(i));
+                groupMembership.setChildType(GroupChildType.USER);
+                groupMembership.setDomainId(domainId);
+                groupMembership.setCreatedTime(System.currentTimeMillis());
+                groupMembership.setUpdatedTime(System.currentTimeMillis());
+                (new GroupMembershipRepository()).create(groupMembership);
+            }
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean removeUsersFromGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException, TException {
+        try{
+            for (String userId: userIds) {
+                if (hasOwnerAccess(domainId, groupId, userId)) {
+                    throw new SharingRegistryException("List of User Ids contains Owner Id. Cannot remove owner from the group");
+                }
+            }
+
+            for(int i=0; i < userIds.size(); i++){
+                GroupMembershipPK groupMembershipPK = new GroupMembershipPK();
+                groupMembershipPK.setParentId(groupId);
+                groupMembershipPK.setChildId(userIds.get(i));
+                groupMembershipPK.setDomainId(domainId);
+                (new GroupMembershipRepository()).delete(groupMembershipPK);
+            }
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean transferGroupOwnership(String domainId, String groupId, String newOwnerId) throws SharingRegistryException, TException {
+        try {
+            List<User> groupUser = getGroupMembersOfTypeUser(domainId, groupId, 0, -1);
+            if (!isUserBelongsToGroup(groupUser, newOwnerId)) {
+                throw new SharingRegistryException("New group owner is not part of the group");
+            }
+
+            if (hasOwnerAccess(domainId, groupId, newOwnerId)) {
+                throw new DuplicateEntryException("User already the current owner of the group");
+            }
+            // remove the new owner as Admin if present
+            if (hasAdminAccess(domainId, groupId, newOwnerId)) {
+                removeGroupAdmins(domainId, groupId, Arrays.asList(newOwnerId));
+            }
+
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setGroupId(groupId);
+            userGroupPK.setDomainId(domainId);
+            UserGroup userGroup = (new UserGroupRepository()).get(userGroupPK);
+            UserGroup newUserGroup = new UserGroup();
+            newUserGroup.setUpdatedTime(System.currentTimeMillis());
+            newUserGroup.setOwnerId(newOwnerId);
+            newUserGroup.setGroupCardinality(GroupCardinality.MULTI_USER);
+            newUserGroup.setCreatedTime(userGroup.getCreatedTime());
+            newUserGroup = getUpdatedObject(userGroup, newUserGroup);
+
+            (new UserGroupRepository()).update(newUserGroup);
+
+            return true;
+        }
+        catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    private boolean isUserBelongsToGroup(List<User> groupUser, String newOwnerId) {
+        for (User user: groupUser) {
+            if (user.getUserId().equals(newOwnerId)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public boolean addGroupAdmins(String domainId, String groupId, List<String> adminIds) throws SharingRegistryException, TException {
+        try{
+            List<User> groupUser = getGroupMembersOfTypeUser(domainId, groupId, 0, -1);
+
+            for (String adminId: adminIds) {
+                if (! isUserBelongsToGroup(groupUser, adminId)) {
+                    throw new SharingRegistryException("Admin not the user of the group. GroupId : "+ groupId + ", AdminId : "+ adminId);
+                }
+                GroupAdminPK groupAdminPK = new GroupAdminPK();
+                groupAdminPK.setGroupId(groupId);
+                groupAdminPK.setAdminId(adminId);
+                groupAdminPK.setDomainId(domainId);
+
+                if((new GroupAdminRepository()).get(groupAdminPK) != null)
+                    throw new DuplicateEntryException("User already an admin for the group");
+
+                GroupAdmin admin = new GroupAdmin();
+                admin.setAdminId(adminId);
+                admin.setDomainId(domainId);
+                admin.setGroupId(groupId);
+                (new GroupAdminRepository()).create(admin);
+            }
+            return true;
+        }
+        catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean removeGroupAdmins(String domainId, String groupId, List<String> adminIds) throws SharingRegistryException, TException {
+        try {
+            for (String adminId: adminIds) {
+                GroupAdminPK groupAdminPK = new GroupAdminPK();
+                groupAdminPK.setAdminId(adminId);
+                groupAdminPK.setDomainId(domainId);
+                groupAdminPK.setGroupId(groupId);
+                (new GroupAdminRepository()).delete(groupAdminPK);
+            }
+            return true;
+        }
+        catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean hasAdminAccess(String domainId, String groupId, String adminId) throws SharingRegistryException, TException {
+        try{
+            GroupAdminPK groupAdminPK = new GroupAdminPK();
+            groupAdminPK.setGroupId(groupId);
+            groupAdminPK.setAdminId(adminId);
+            groupAdminPK.setDomainId(domainId);
+
+            if((new GroupAdminRepository()).get(groupAdminPK) != null)
+                return true;
+            return false;
+        }
+        catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean hasOwnerAccess(String domainId, String groupId, String ownerId) throws SharingRegistryException, TException {
+        try {
+            UserGroupPK userGroupPK = new UserGroupPK();
+            userGroupPK.setGroupId(groupId);
+            userGroupPK.setDomainId(domainId);
+            UserGroup getGroup = (new UserGroupRepository()).get(userGroupPK);
+
+            if(getGroup.getOwnerId().equals(ownerId))
+                return true;
+            return false;
+        }
+        catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<User> getGroupMembersOfTypeUser(String domainId, String groupId, int offset, int limit) throws SharingRegistryException, TException {
+        try{
+            //TODO limit offset
+            List<User> groupMemberUsers = (new GroupMembershipRepository()).getAllChildUsers(domainId, groupId);
+            return groupMemberUsers;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<UserGroup> getGroupMembersOfTypeGroup(String domainId, String groupId, int offset, int limit) throws SharingRegistryException, TException {
+        try{
+            //TODO limit offset
+            List<UserGroup> groupMemberGroups = (new GroupMembershipRepository()).getAllChildGroups(domainId, groupId);
+            return groupMemberGroups;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean addChildGroupsToParentGroup(String domainId, List<String> childIds, String groupId) throws SharingRegistryException, TException {
+        try{
+            for(String childId : childIds) {
+                //Todo check for cyclic dependencies
+                GroupMembership groupMembership = new GroupMembership();
+                groupMembership.setParentId(groupId);
+                groupMembership.setChildId(childId);
+                groupMembership.setChildType(GroupChildType.GROUP);
+                groupMembership.setDomainId(domainId);
+                groupMembership.setCreatedTime(System.currentTimeMillis());
+                groupMembership.setUpdatedTime(System.currentTimeMillis());
+                (new GroupMembershipRepository()).create(groupMembership);
+            }
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean removeChildGroupFromParentGroup(String domainId, String childId, String groupId) throws SharingRegistryException, TException {
+        try{
+            GroupMembershipPK groupMembershipPK = new GroupMembershipPK();
+            groupMembershipPK.setParentId(groupId);
+            groupMembershipPK.setChildId(childId);
+            groupMembershipPK.setDomainId(domainId);
+            (new GroupMembershipRepository()).delete(groupMembershipPK);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<UserGroup> getAllMemberGroupsForUser(String domainId, String userId) throws SharingRegistryException, TException {
+        try{
+            GroupMembershipRepository groupMembershipRepository = new GroupMembershipRepository();
+            return groupMembershipRepository.getAllMemberGroupsForUser(domainId, userId);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * * EntityType Operations
+     * *
+     */
+    @Override
+    public String createEntityType(EntityType entityType) throws SharingRegistryException, DuplicateEntryException, TException {
+        try{
+            EntityTypePK entityTypePK = new EntityTypePK();
+            entityTypePK.setDomainId(entityType.getDomainId());
+            entityTypePK.setEntityTypeId(entityType.getEntityTypeId());
+            if((new EntityTypeRepository()).get(entityTypePK) != null)
+                throw new DuplicateEntryException("There exist EntityType with given EntityType id");
+
+            entityType.setCreatedTime(System.currentTimeMillis());
+            entityType.setUpdatedTime(System.currentTimeMillis());
+            (new EntityTypeRepository()).create(entityType);
+            return entityType.getEntityTypeId();
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean updateEntityType(EntityType entityType) throws SharingRegistryException, TException {
+        try{
+            entityType.setUpdatedTime(System.currentTimeMillis());
+            EntityTypePK entityTypePK = new EntityTypePK();
+            entityTypePK.setDomainId(entityType.getDomainId());
+            entityTypePK.setEntityTypeId(entityType.getEntityTypeId());
+            EntityType oldEntityType = (new EntityTypeRepository()).get(entityTypePK);
+            entityType.setCreatedTime(oldEntityType.getCreatedTime());
+            entityType = getUpdatedObject(oldEntityType, entityType);
+            (new EntityTypeRepository()).update(entityType);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * <p>API method to check EntityType Exists</p>
+     *
+     * @param entityTypeId
+     */
+    @Override
+    public boolean isEntityTypeExists(String domainId, String entityTypeId) throws SharingRegistryException, TException {
+        try{
+            EntityTypePK entityTypePK = new EntityTypePK();
+            entityTypePK.setDomainId(domainId);
+            entityTypePK.setEntityTypeId(entityTypeId);
+            return (new EntityTypeRepository()).isExists(entityTypePK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean deleteEntityType(String domainId, String entityTypeId) throws SharingRegistryException, TException {
+        try{
+            EntityTypePK entityTypePK = new EntityTypePK();
+            entityTypePK.setDomainId(domainId);
+            entityTypePK.setEntityTypeId(entityTypeId);
+            (new EntityTypeRepository()).delete(entityTypePK);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public EntityType getEntityType(String domainId, String entityTypeId) throws SharingRegistryException, TException {
+        try{
+            EntityTypePK entityTypePK = new EntityTypePK();
+            entityTypePK.setDomainId(domainId);
+            entityTypePK.setEntityTypeId(entityTypeId);
+            return (new EntityTypeRepository()).get(entityTypePK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<EntityType> getEntityTypes(String domain, int offset, int limit) throws TException {
+        try{
+            HashMap<String, String> filters = new HashMap<>();
+            filters.put(DBConstants.EntityTypeTable.DOMAIN_ID, domain);
+            return (new EntityTypeRepository()).select(filters, offset, limit);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * * Permission Operations
+     * *
+     */
+    @Override
+    public String createPermissionType(PermissionType permissionType) throws SharingRegistryException, DuplicateEntryException, TException {
+        try{
+            PermissionTypePK permissionTypePK =  new PermissionTypePK();
+            permissionTypePK.setDomainId(permissionType.getDomainId());
+            permissionTypePK.setPermissionTypeId(permissionType.getPermissionTypeId());
+            if((new PermissionTypeRepository()).get(permissionTypePK) != null)
+                throw new DuplicateEntryException("There exist PermissionType with given PermissionType id");
+            permissionType.setCreatedTime(System.currentTimeMillis());
+            permissionType.setUpdatedTime(System.currentTimeMillis());
+            (new PermissionTypeRepository()).create(permissionType);
+            return permissionType.getPermissionTypeId();
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean updatePermissionType(PermissionType permissionType) throws SharingRegistryException, TException {
+        try{
+            permissionType.setUpdatedTime(System.currentTimeMillis());
+            PermissionTypePK permissionTypePK =  new PermissionTypePK();
+            permissionTypePK.setDomainId(permissionType.getDomainId());
+            permissionTypePK.setPermissionTypeId(permissionType.getPermissionTypeId());
+            PermissionType oldPermissionType = (new PermissionTypeRepository()).get(permissionTypePK);
+            permissionType = getUpdatedObject(oldPermissionType, permissionType);
+            (new PermissionTypeRepository()).update(permissionType);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * <p>API method to check Permission Exists</p>
+     *
+     * @param permissionId
+     */
+    @Override
+    public boolean isPermissionExists(String domainId, String permissionId) throws SharingRegistryException, TException {
+        try{
+            PermissionTypePK permissionTypePK = new PermissionTypePK();
+            permissionTypePK.setDomainId(domainId);
+            permissionTypePK.setPermissionTypeId(permissionId);
+            return (new PermissionTypeRepository()).isExists(permissionTypePK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean deletePermissionType(String domainId, String permissionTypeId) throws SharingRegistryException, TException {
+        try{
+            PermissionTypePK permissionTypePK =  new PermissionTypePK();
+            permissionTypePK.setDomainId(domainId);
+            permissionTypePK.setPermissionTypeId(permissionTypeId);
+            (new PermissionTypeRepository()).delete(permissionTypePK);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public PermissionType getPermissionType(String domainId, String permissionTypeId) throws SharingRegistryException, TException {
+        try{
+            PermissionTypePK permissionTypePK =  new PermissionTypePK();
+            permissionTypePK.setDomainId(domainId);
+            permissionTypePK.setPermissionTypeId(permissionTypeId);
+            return (new PermissionTypeRepository()).get(permissionTypePK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws SharingRegistryException, TException {
+        try{
+            HashMap<String, String> filters = new HashMap<>();
+            filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domain);
+            return (new PermissionTypeRepository()).select(filters, offset, limit);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * * Entity Operations
+     * *
+     */
+    @Override
+    public String createEntity(Entity entity) throws SharingRegistryException, DuplicateEntryException, TException {
+        try{
+            EntityPK entityPK = new EntityPK();
+            entityPK.setDomainId(entity.getDomainId());
+            entityPK.setEntityId(entity.getEntityId());
+            if((new EntityRepository()).get(entityPK) != null)
+                throw new DuplicateEntryException("There exist Entity with given Entity id");
+
+            UserPK userPK = new UserPK();
+            userPK.setDomainId(entity.getDomainId());
+            userPK.setUserId(entity.getOwnerId());
+            if(!(new UserRepository()).isExists(userPK)){
+                //Todo this is for Airavata easy integration. Proper thing is to throw an exception here
+                User user = new User();
+                user.setUserId(entity.getOwnerId());
+                user.setDomainId(entity.getDomainId());
+                user.setUserName(user.getUserId().split("@")[0]);
+
+                createUser(user);
+            }
+            entity.setCreatedTime(System.currentTimeMillis());
+            entity.setUpdatedTime(System.currentTimeMillis());
+
+            if(entity.getOriginalEntityCreationTime()==0){
+                entity.setOriginalEntityCreationTime(entity.getCreatedTime());
+            }
+            (new EntityRepository()).create(entity);
+
+            //Assigning global permission for the owner
+            Sharing newSharing = new Sharing();
+            newSharing.setPermissionTypeId((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(entity.getDomainId()));
+            newSharing.setEntityId(entity.getEntityId());
+            newSharing.setGroupId(entity.getOwnerId());
+            newSharing.setSharingType(SharingType.DIRECT_CASCADING);
+            newSharing.setInheritedParentId(entity.getEntityId());
+            newSharing.setDomainId(entity.getDomainId());
+            newSharing.setCreatedTime(System.currentTimeMillis());
+            newSharing.setUpdatedTime(System.currentTimeMillis());
+
+            (new SharingRepository()).create(newSharing);
+
+            // creating records for inherited permissions
+            if (entity.getParentEntityId() != null && entity.getParentEntityId() != "") {
+                addCascadingPermissionsForEntity(entity);
+            }
+
+            return entity.getEntityId();
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            SharingRegistryException sharingRegistryException = new SharingRegistryException();
+            sharingRegistryException.setMessage(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+            throw sharingRegistryException;
+        }
+    }
+
+    private void addCascadingPermissionsForEntity(Entity entity) throws SharingRegistryException {
+        Sharing newSharing;
+        List<Sharing> sharings = (new SharingRepository()).getCascadingPermissionsForEntity(entity.getDomainId(),
+                entity.getParentEntityId());
+        for (Sharing sharing : sharings) {
+                    newSharing = new Sharing();
+                    newSharing.setPermissionTypeId(sharing.getPermissionTypeId());
+                    newSharing.setEntityId(entity.getEntityId());
+                    newSharing.setGroupId(sharing.getGroupId());
+                    newSharing.setInheritedParentId(sharing.getInheritedParentId());
+                    newSharing.setSharingType(SharingType.INDIRECT_CASCADING);
+                    newSharing.setDomainId(entity.getDomainId());
+                    newSharing.setCreatedTime(System.currentTimeMillis());
+                    newSharing.setUpdatedTime(System.currentTimeMillis());
+
+                    (new SharingRepository()).create(newSharing);
+                }
+            }
+
+    @Override
+    public boolean updateEntity(Entity entity) throws SharingRegistryException, TException {
+        try{
+            //TODO Check for permission changes
+            entity.setUpdatedTime(System.currentTimeMillis());
+            EntityPK entityPK = new EntityPK();
+            entityPK.setDomainId(entity.getDomainId());
+            entityPK.setEntityId(entity.getEntityId());
+            Entity oldEntity = (new EntityRepository()).get(entityPK);
+            entity.setCreatedTime(oldEntity.getCreatedTime());
+            // check if parent entity changed and re-add inherited permissions
+            if (!Objects.equals(oldEntity.getParentEntityId(), entity.getParentEntityId())) {
+                logger.debug("Parent entity changed for {}, updating inherited permissions", entity.getEntityId());
+                if (oldEntity.getParentEntityId() != null && oldEntity.getParentEntityId() != "") {
+                    logger.debug("Removing inherited permissions from {} that were inherited from parent {}", entity.getEntityId(), oldEntity.getParentEntityId());
+                    (new SharingRepository()).removeAllIndirectCascadingPermissionsForEntity(entity.getDomainId(), entity.getEntityId());
+                }
+                if (entity.getParentEntityId() != null && entity.getParentEntityId() != "") {
+                    // re-add INDIRECT_CASCADING permissions
+                    logger.debug("Adding inherited permissions to {} that are inherited from parent {}", entity.getEntityId(), entity.getParentEntityId());
+                    addCascadingPermissionsForEntity(entity);
+                }
+            }
+            entity = getUpdatedObject(oldEntity, entity);
+            entity.setSharedCount((new SharingRepository()).getSharedCount(entity.getDomainId(), entity.getEntityId()));
+            (new EntityRepository()).update(entity);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    /**
+     * <p>API method to check Entity Exists</p>
+     *
+     * @param entityId
+     */
+    @Override
+    public boolean isEntityExists(String domainId, String entityId) throws SharingRegistryException, TException {
+        try{
+            EntityPK entityPK = new EntityPK();
+            entityPK.setDomainId(domainId);
+            entityPK.setEntityId(entityId);
+            return (new EntityRepository()).isExists(entityPK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean deleteEntity(String domainId, String entityId) throws SharingRegistryException, TException {
+        try{
+            //TODO Check for permission changes
+            EntityPK entityPK = new EntityPK();
+            entityPK.setDomainId(domainId);
+            entityPK.setEntityId(entityId);
+            (new EntityRepository()).delete(entityPK);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public Entity getEntity(String domainId, String entityId) throws SharingRegistryException, TException {
+        try{
+            EntityPK entityPK = new EntityPK();
+            entityPK.setDomainId(domainId);
+            entityPK.setEntityId(entityId);
+            return (new EntityRepository()).get(entityPK);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<Entity> searchEntities(String domainId, String userId, List<SearchCriteria> filters,
+                                       int offset, int limit) throws SharingRegistryException, TException {
+        try{
+            List<String> groupIds = new ArrayList<>();
+            groupIds.add(userId);
+            (new GroupMembershipRepository()).getAllParentMembershipsForChild(domainId, userId).stream().forEach(gm -> groupIds.add(gm.getParentId()));
+            return (new EntityRepository()).searchEntities(domainId, groupIds, filters, offset, limit);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<User> getListOfSharedUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException, TException {
+        try{
+            return (new UserRepository()).getAccessibleUsers(domainId, entityId, permissionTypeId);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<User> getListOfDirectlySharedUsers(String domainId, String entityId, String permissionTypeId)
+            throws SharingRegistryException, TException {
+        try{
+            return (new UserRepository()).getDirectlyAccessibleUsers(domainId, entityId, permissionTypeId);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            SharingRegistryException sharingRegistryException = new SharingRegistryException();
+            sharingRegistryException.setMessage(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+            throw sharingRegistryException;
+        }
+    }
+
+    @Override
+    public List<UserGroup> getListOfSharedGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException, TException {
+        try{
+            return (new UserGroupRepository()).getAccessibleGroups(domainId, entityId, permissionTypeId);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public List<UserGroup> getListOfDirectlySharedGroups(String domainId, String entityId, String permissionTypeId)
+            throws SharingRegistryException, TException {
+        try{
+            return (new UserGroupRepository()).getDirectlyAccessibleGroups(domainId, entityId, permissionTypeId);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            SharingRegistryException sharingRegistryException = new SharingRegistryException();
+            sharingRegistryException.setMessage(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+            throw sharingRegistryException;
+        }
+    }
+
+    /**
+     * Sharing Entity with Users and Groups
+     * @param domainId
+     * @param entityId
+     * @param userList
+     * @param permissionTypeId
+     * @param cascadePermission
+     * @return
+     * @throws SharingRegistryException
+     * @throws TException
+     */
+    @Override
+    public boolean shareEntityWithUsers(String domainId, String entityId, List<String> userList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException {
+        try{
+            return shareEntity(domainId, entityId, userList, permissionTypeId, cascadePermission);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean shareEntityWithGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException {
+        try{
+            return shareEntity(domainId, entityId, groupList, permissionTypeId, cascadePermission);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    private boolean shareEntity(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId, boolean cascadePermission)  throws SharingRegistryException, TException {
+        try{
+            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
+                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
+            }
+
+            List<Sharing> sharings = new ArrayList<>();
+
+            //Adding permission for the specified users/groups for the specified entity
+            LinkedList<Entity> temp = new LinkedList<>();
+            for(String userId : groupOrUserList){
+                Sharing sharing = new Sharing();
+                sharing.setPermissionTypeId(permissionTypeId);
+                sharing.setEntityId(entityId);
+                sharing.setGroupId(userId);
+                sharing.setInheritedParentId(entityId);
+                sharing.setDomainId(domainId);
+                if(cascadePermission) {
+                    sharing.setSharingType(SharingType.DIRECT_CASCADING);
+                }else {
+                    sharing.setSharingType(SharingType.DIRECT_NON_CASCADING);
+                }
+                sharing.setCreatedTime(System.currentTimeMillis());
+                sharing.setUpdatedTime(System.currentTimeMillis());
+
+                sharings.add(sharing);
+            }
+
+            if(cascadePermission){
+                //Adding permission for the specified users/groups for all child entities
+                (new EntityRepository()).getChildEntities(domainId, entityId).stream().forEach(e -> temp.addLast(e));
+                while(temp.size() > 0){
+                    Entity entity = temp.pop();
+                    String childEntityId = entity.getEntityId();
+                    for(String userId : groupOrUserList){
+                        Sharing sharing = new Sharing();
+                        sharing.setPermissionTypeId(permissionTypeId);
+                        sharing.setEntityId(childEntityId);
+                        sharing.setGroupId(userId);
+                        sharing.setInheritedParentId(entityId);
+                        sharing.setSharingType(SharingType.INDIRECT_CASCADING);
+                        sharing.setInheritedParentId(entityId);
+                        sharing.setDomainId(domainId);
+                        sharing.setCreatedTime(System.currentTimeMillis());
+                        sharing.setUpdatedTime(System.currentTimeMillis());
+                        sharings.add(sharing);
+                        (new EntityRepository()).getChildEntities(domainId, childEntityId).stream().forEach(e -> temp.addLast(e));
+                    }
+                }
+            }
+            (new SharingRepository()).create(sharings);
+
+            EntityPK entityPK = new EntityPK();
+            entityPK.setDomainId(domainId);
+            entityPK.setEntityId(entityId);
+            Entity entity = (new EntityRepository()).get(entityPK);
+            entity.setSharedCount((new SharingRepository()).getSharedCount(domainId, entityId));
+            (new EntityRepository()).update(entity);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean revokeEntitySharingFromUsers(String domainId, String entityId, List<String> userList, String permissionTypeId) throws SharingRegistryException, TException {
+        try{
+            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
+                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
+            }
+            return revokeEntitySharing(domainId, entityId, userList, permissionTypeId);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+
+    @Override
+    public boolean revokeEntitySharingFromGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId) throws SharingRegistryException, TException {
+        try{
+            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
+                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
+            }
+            return revokeEntitySharing(domainId, entityId, groupList, permissionTypeId);
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    @Override
+    public boolean userHasAccess(String domainId, String userId, String entityId, String permissionTypeId) throws SharingRegistryException, TException {
+        try{
+            //check whether the user has permission directly or indirectly
+            List<GroupMembership> parentMemberships = (new GroupMembershipRepository()).getAllParentMembershipsForChild(domainId, userId);
+            List<String> groupIds = new ArrayList<>();
+            parentMemberships.stream().forEach(pm->groupIds.add(pm.getParentId()));
+            groupIds.add(userId);
+            return (new SharingRepository()).hasAccess(domainId, entityId, groupIds, Arrays.asList(permissionTypeId,
+                    (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId)));
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+    }
+
+    public boolean revokeEntitySharing(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId) throws SharingRegistryException {
+        try{
+            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
+                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be removed");
+            }
+
+            //revoking permission for the entity
+            for(String groupId : groupOrUserList){
+                SharingPK sharingPK = new SharingPK();
+                sharingPK.setEntityId(entityId);
+                sharingPK.setGroupId(groupId);
+                sharingPK.setPermissionTypeId(permissionTypeId);
+                sharingPK.setInheritedParentId(entityId);
+                sharingPK.setDomainId(domainId);
+
+                (new SharingRepository()).delete(sharingPK);
+            }
+
+            //revoking permission from inheritance
+            List<Sharing> temp = new ArrayList<>();
+            (new SharingRepository()).getIndirectSharedChildren(domainId, entityId, permissionTypeId).stream().forEach(s -> temp.add(s));
+            for(Sharing sharing : temp){
+                String childEntityId = sharing.getEntityId();
+                for(String groupId : groupOrUserList){
+                    SharingPK sharingPK = new SharingPK();
+                    sharingPK.setEntityId(childEntityId);
+                    sharingPK.setGroupId(groupId);
+                    sharingPK.setPermissionTypeId(permissionTypeId);
+                    sharingPK.setInheritedParentId(entityId);
+                    sharingPK.setDomainId(domainId);
+
+                    (new SharingRepository()).delete(sharingPK);
+                }
+            }
+
+            EntityPK entityPK = new EntityPK();
+            entityPK.setDomainId(domainId);
+            entityPK.setEntityId(entityId);
+            Entity entity = (new EntityRepository()).get(entityPK);
+            entity.setSharedCount((new SharingRepository()).getSharedCount(domainId, entityId));
+            (new EntityRepository()).update(entity);
+            return true;
+        }catch (Throwable ex) {
+            logger.error(ex.getMessage(), ex);
+            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
+        }
+
+    }
+
+
+
+    private <T> T getUpdatedObject(T oldEntity, T newEntity) throws SharingRegistryException {
+        Field[] newEntityFields = newEntity.getClass().getDeclaredFields();
+        Hashtable newHT = fieldsToHT(newEntityFields, newEntity);
+
+        Class oldEntityClass = oldEntity.getClass();
+        Field[] oldEntityFields = oldEntityClass.getDeclaredFields();
+
+        for (Field field : oldEntityFields){
+            if (!Modifier.isFinal(field.getModifiers())) {
+                field.setAccessible(true);
+                Object o = newHT.get(field.getName());
+                if (o != null) {
+                    Field f = null;
+                    try {
+                        f = oldEntityClass.getDeclaredField(field.getName());
+                        f.setAccessible(true);
+                        logger.debug("setting " + f.getName());
+                        f.set(oldEntity, o);
+                    } catch (Exception e) {
+                        throw new SharingRegistryException(e.getMessage());
+                    }
+                }
+            }
+        }
+        return oldEntity;
+    }
+
+    private static Hashtable<String, Object> fieldsToHT(Field[] fields, Object obj){
+        Hashtable<String,Object> hashtable = new Hashtable<>();
+        for (Field field: fields){
+            field.setAccessible(true);
+            try {
+                Object retrievedObject = field.get(obj);
+                if (retrievedObject != null){
+                    logger.debug("scanning " + field.getName());
+                    hashtable.put(field.getName(), field.get(obj));
+                }
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        return hashtable;
+    }
+
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/META-INF/persistence.xml b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..936b84d
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+
+    <persistence-unit name="airavata-sharing-registry">
+        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+        <class>org.apache.airavata.sharing.registry.db.entities.DomainEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.EntityEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.EntityTypeEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.GroupMembershipEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.PermissionTypeEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.SharingEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.UserEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.GroupAdminEntity</class>
+        <class>org.apache.airavata.sharing.registry.db.entities.UserGroupEntity</class>
+    </persistence-unit>
+</persistence>
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/airavata.jks b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/airavata.jks
new file mode 100644
index 0000000..e0e46e2
Binary files /dev/null and b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/airavata.jks differ
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/client_truststore.jks b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/client_truststore.jks
new file mode 100644
index 0000000..4ff588f
Binary files /dev/null and b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/client_truststore.jks differ
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-derby.sql b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
new file mode 100644
index 0000000..a7038e2
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
@@ -0,0 +1,147 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+CREATE TABLE DOMAIN (
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (DOMAIN_ID)
+);
+
+CREATE TABLE SHARING_USER (
+  USER_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  USER_NAME VARCHAR(255) NOT NULL,
+  FIRST_NAME VARCHAR (255),
+  LAST_NAME VARCHAR (255),
+  EMAIL VARCHAR (255),
+  ICON BLOB,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (USER_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE GROUP_ADMIN (
+  ADMIN_ID VARCHAR(255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  PRIMARY KEY (ADMIN_ID, GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (ADMIN_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE USER_GROUP (
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  OWNER_ID VARCHAR(255) NOT NULL,
+  GROUP_TYPE VARCHAR(255) NOT NULL,
+  GROUP_CARDINALITY VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+
+CREATE TABLE GROUP_MEMBERSHIP (
+  PARENT_ID VARCHAR(255) NOT NULL,
+  CHILD_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  CHILD_TYPE VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PARENT_ID, CHILD_ID, DOMAIN_ID),
+  FOREIGN KEY (PARENT_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (CHILD_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE ENTITY_TYPE (
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE PERMISSION_TYPE (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE ENTITY (
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  OWNER_ID VARCHAR(255) NOT NULL,
+  PARENT_ENTITY_ID VARCHAR(255),
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  BINARY_DATA BLOB,
+  FULL_TEXT VARCHAR(255),
+  SHARED_COUNT BIGINT DEFAULT 0,
+  ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_ID, DOMAIN_ID),
+  FOREIGN KEY (ENTITY_TYPE_ID, DOMAIN_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (PARENT_ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+-- ALTER TABLE ENTITY ADD FULLTEXT FULL_TEXT_INDEX(FULL_TEXT);
+
+CREATE TABLE SHARING (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR (255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  SHARING_TYPE VARCHAR(255) NOT NULL,
+  INHERITED_PARENT_ID VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID, DOMAIN_ID, INHERITED_PARENT_ID),
+  FOREIGN KEY (PERMISSION_TYPE_ID, DOMAIN_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (INHERITED_PARENT_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (GROUP_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE CONFIGURATION
+(
+  CONFIG_KEY VARCHAR(255) NOT NULL,
+  CONFIG_VALUE VARCHAR(255) NOT NULL,
+  PRIMARY KEY(CONFIG_KEY, CONFIG_VALUE)
+);
+
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VALUE) VALUES('sharing_reg_version', '0.17');
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
new file mode 100644
index 0000000..145d926
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
@@ -0,0 +1,146 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+CREATE TABLE DOMAIN (
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (DOMAIN_ID)
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE SHARING_USER (
+  USER_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  USER_NAME VARCHAR(255) NOT NULL,
+  FIRST_NAME VARCHAR (255),
+  LAST_NAME VARCHAR (255),
+  EMAIL VARCHAR (255),
+  ICON BLOB,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (USER_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE USER_GROUP (
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  OWNER_ID VARCHAR(255) NOT NULL,
+  GROUP_TYPE VARCHAR(255) NOT NULL,
+  GROUP_CARDINALITY VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE GROUP_ADMIN (
+  ADMIN_ID VARCHAR(255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  PRIMARY KEY (ADMIN_ID, GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (ADMIN_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE GROUP_MEMBERSHIP (
+  PARENT_ID VARCHAR(255) NOT NULL,
+  CHILD_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  CHILD_TYPE VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PARENT_ID, CHILD_ID, DOMAIN_ID),
+  FOREIGN KEY (PARENT_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (CHILD_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE ENTITY_TYPE (
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE PERMISSION_TYPE (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE ENTITY (
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  OWNER_ID VARCHAR(255) NOT NULL,
+  PARENT_ENTITY_ID VARCHAR(255),
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  BINARY_DATA BLOB,
+  FULL_TEXT TEXT,
+  SHARED_COUNT BIGINT DEFAULT 0,
+  ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_ID, DOMAIN_ID),
+  FOREIGN KEY (ENTITY_TYPE_ID, DOMAIN_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (PARENT_ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+ALTER TABLE ENTITY ADD FULLTEXT FULL_TEXT_INDEX(FULL_TEXT);
+
+CREATE TABLE SHARING (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR (255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  SHARING_TYPE VARCHAR(255) NOT NULL,
+  INHERITED_PARENT_ID VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID, DOMAIN_ID, INHERITED_PARENT_ID),
+  CONSTRAINT `SHARING_PERMISSION_TYPE_ID_DOMAIN_ID_FK` FOREIGN KEY (PERMISSION_TYPE_ID, DOMAIN_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  CONSTRAINT `SHARING_ENTITY_ID_DOMAIN_ID_FK` FOREIGN KEY (ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  CONSTRAINT `SHARING_INHERITED_PARENT_ID_DOMAIN_ID_FK` FOREIGN KEY (INHERITED_PARENT_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  CONSTRAINT `SHARING_GROUP_ID_DOMAIN_ID_FK` FOREIGN KEY (GROUP_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE CONFIGURATION
+(
+  CONFIG_KEY VARCHAR(255) NOT NULL,
+  CONFIG_VALUE VARCHAR(255) NOT NULL,
+  PRIMARY KEY(CONFIG_KEY, CONFIG_VALUE)
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VALUE) VALUES('sharing_reg_version', '0.17');
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/CipresTest.java b/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/CipresTest.java
new file mode 100644
index 0000000..f3ccc52
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/CipresTest.java
@@ -0,0 +1,632 @@
+/**
+ *
+ * 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.custos.sharing.registry;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.sharing.registry.models.*;
+import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSSLTransportFactory;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class CipresTest {
+    public static void main(String[] args) throws InterruptedException, TException, ApplicationSettingsException {
+        System.out.println("Hello World!");
+        //should use the correct host name and port here
+        String serverHost = "wb-airavata.scigap.org";
+
+        int serverPort = 7878;
+        TTransport transport = null;
+        TProtocol protocol = null;
+        try {
+
+            SharingRegistryService.Client sharingServiceClient;
+
+            //Non Secure Client
+//            transport = new TSocket(serverHost, serverPort);
+//            transport.open();
+//            protocol = new TBinaryProtocol(transport);
+//            sharingServiceClient= new SharingRegistryService.Client(protocol);
+
+            //TLS enabled client
+            TSSLTransportFactory.TSSLTransportParameters params =
+                    new TSSLTransportFactory.TSSLTransportParameters();
+            params.setKeyStore(ServerSettings.getKeyStorePath(), ServerSettings.getKeyStorePassword());
+            params.setTrustStore(ServerSettings.getTrustStorePath(), ServerSettings.getTrustStorePassword());
+            transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, 10000, params);
+            protocol = new TBinaryProtocol(transport);
+            sharingServiceClient = new SharingRegistryService.Client(protocol);
+
+
+            try {
+                sharingServiceClient.deleteDomain("test-domain");
+            } catch (SharingRegistryException sre1) {
+                System.out.println("deleteDomain failed" + sre1.getMessage() + "\n");
+            }
+            Domain domain = new Domain();
+            //has to be one word
+            domain.setName("test-domain");
+            //optional
+            domain.setDescription("test domain description");
+            //domain id will be same as domain name
+            String domainId = sharingServiceClient.createDomain(domain);
+            System.out.println("After domain creation...\n");
+
+            User user1 = new User();
+            String userName1 = "test-user-1";
+            String userId1 = "test-user-1";
+            //required
+            user1.setUserId(userId1);
+            //required
+            user1.setUserName(userName1);
+            //required
+            user1.setDomainId(domainId);
+            //required
+            user1.setFirstName("John");
+            //required
+            user1.setLastName("Doe");
+            //required
+            user1.setEmail("john.doe@abc.com");
+            //optional - this should be bytes of the users image icon
+            //byte[] icon = new byte[10];
+            //user1.setIcon(icon);
+            sharingServiceClient.createUser(user1);
+            User user2 = new User();
+            String userName2 = "test-user-2";
+            String userId2 = "test-user-2";
+            //required
+            user2.setUserId(userId2);
+            //required
+            user2.setUserName(userName2);
+            //required
+            user2.setDomainId(domainId);
+            //required
+            user2.setFirstName("John");
+            //required
+            user2.setLastName("Doe");
+            //required
+            user2.setEmail("john.doe@abc.com");
+            //optional - this should be bytes of the users image icon
+            //byte[] icon = new byte[20];
+            //user2.setIcon(icon);
+            sharingServiceClient.createUser(user2);
+            User user3 = new User();
+            String userName3 = "test-user-3";
+            String userId3 = "test-user-3";
+            //required
+            user3.setUserId(userId3);
+            //required
+            user3.setUserName(userName3);
+            //required
+            user3.setDomainId(domainId);
+            //required
+            user3.setFirstName("John");
+            //required
+            user3.setLastName("Doe");
+            //required
+            user3.setEmail("john.doe@abc.com");
+            //optional - this should be bytes of the users image icon
+            //byte[] icon = new byte[30];
+            //user3.setIcon(icon);
+            sharingServiceClient.createUser(user3);
+            System.out.println("After user creation...\n");
+
+            UserGroup userGroup1 = new UserGroup();
+            //required
+            userGroup1.setGroupId("test-group-1");
+            //required
+            userGroup1.setDomainId(domainId);
+            //required
+            userGroup1.setName("test-group-1");
+            //optional
+            //userGroup1.setDescription("test group description");
+            //required
+            userGroup1.setOwnerId("test-user-1");
+            //required
+            userGroup1.setGroupType(GroupType.USER_LEVEL_GROUP);
+            sharingServiceClient.createGroup(userGroup1);
+            //Similarly create another group "userGroup2" with the owner being "test-user-2".
+            UserGroup userGroup2 = new UserGroup();
+            //required
+            userGroup2.setGroupId("test-group-2");
+            //required
+            userGroup2.setDomainId(domainId);
+            //required
+            userGroup2.setName("test-group-2");
+            //optional
+            //userGroup2.setDescription("test group description");
+            //required
+            userGroup2.setOwnerId("test-user-2");
+            //required
+            userGroup2.setGroupType(GroupType.USER_LEVEL_GROUP);
+            sharingServiceClient.createGroup(userGroup2);
+            System.out.println("After group creation...\n");
+
+            sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("test-user-3"), "test-group-2");
+            System.out.println("After adding user to group...\n");
+
+            sharingServiceClient.addChildGroupsToParentGroup(domainId, Arrays.asList("test-group-2"), "test-group-1");
+
+
+            PermissionType permissionType1 = new PermissionType();
+            //required
+            permissionType1.setPermissionTypeId("READ");
+            //required
+            permissionType1.setDomainId(domainId);
+            //required
+            permissionType1.setName("READ");
+            //optional
+            permissionType1.setDescription("READ description");
+            sharingServiceClient.createPermissionType(permissionType1);
+            PermissionType permissionType2 = new PermissionType();
+            permissionType2.setPermissionTypeId("WRITE");
+            permissionType2.setDomainId(domainId);
+            permissionType2.setName("WRITE");
+            permissionType2.setDescription("WRITE description");
+            sharingServiceClient.createPermissionType(permissionType2);
+            PermissionType permissionType3 = new PermissionType();
+            permissionType3.setPermissionTypeId("CLONE");
+            permissionType3.setDomainId(domainId);
+            permissionType3.setName("CLONE");
+            permissionType3.setDescription("CLONE description");
+            sharingServiceClient.createPermissionType(permissionType3);
+            System.out.println("After adding groups to parent group...\n");
+
+            EntityType entityType1 = new EntityType();
+            //required
+            entityType1.setEntityTypeId("PROJECT");
+            //required
+            entityType1.setDomainId(domainId);
+            //required
+            entityType1.setName("PROJECT");
+            //optional
+            entityType1.setDescription("PROJECT entity type description");
+            sharingServiceClient.createEntityType(entityType1);
+            EntityType entityType2 = new EntityType();
+            entityType2.setEntityTypeId("EXPERIMENT");
+            entityType2.setDomainId(domainId);
+            entityType2.setName("EXPERIMENT");
+            entityType2.setDescription("EXPERIMENT entity type");
+            sharingServiceClient.createEntityType(entityType2);
+            EntityType entityType3 = new EntityType();
+            entityType3.setEntityTypeId("FILE");
+            entityType3.setDomainId(domainId);
+            entityType3.setName("FILE");
+            entityType3.setDescription("FILE entity type");
+            sharingServiceClient.createEntityType(entityType3);
+            System.out.println("After project entity creation...\n");
+
+            Entity entity1 = new Entity();
+            //required
+            entity1.setEntityId("test-project-1");
+            //required
+            entity1.setDomainId(domainId);
+            //required
+            entity1.setEntityTypeId("PROJECT");
+            //required
+            entity1.setOwnerId("test-user-1");
+            //required
+            entity1.setName("test-project-1");
+            //optional
+            entity1.setDescription("test project 1 description");
+            //optional
+            entity1.setFullText("test project 1 stampede gaussian seagrid");
+            //optional - If not set this will be default to current system time
+            entity1.setOriginalEntityCreationTime(System.currentTimeMillis());
+            sharingServiceClient.createEntity(entity1);
+            System.out.println("After currentTimeMillis()...\n");
+            Entity entity2 = new Entity();
+            entity2.setEntityId("test-experiment-1");
+            entity2.setDomainId(domainId);
+            entity2.setEntityTypeId("EXPERIMENT");
+            entity2.setOwnerId("test-user-1");
+            entity2.setName("test-experiment-1");
+            entity2.setDescription("test experiment 1 description");
+            entity2.setParentEntityId("test-project-1");
+            entity2.setFullText("test experiment 1 benzene");
+            System.out.println("Before sharingServiceClient.createEntity entity2...\n");
+            sharingServiceClient.createEntity(entity2);
+            System.out.println("After sharingServiceClient.createEntity entity2...\n");
+            Entity entity3 = new Entity();
+            entity3.setEntityId("test-experiment-2");
+            entity3.setDomainId(domainId);
+            entity3.setEntityTypeId("EXPERIMENT");
+            entity3.setOwnerId("test-user-1");
+            entity3.setName("test-experiment-2");
+            entity3.setDescription("test experiment 2 description");
+            entity3.setParentEntityId("test-project-1");
+            entity3.setFullText("test experiment 1 3-methyl 1-butanol stampede");
+            sharingServiceClient.createEntity(entity3);
+            System.out.println("After sharingServiceClient.createEntity entity3...\n");
+            Entity entity4 = new Entity();
+            entity4.setEntityId("test-file-1");
+            entity4.setDomainId(domainId);
+            entity4.setEntityTypeId("FILE");
+            entity4.setOwnerId("test-user-1");
+            entity4.setName("test-file-1");
+            entity4.setDescription("test file 1 description");
+            entity4.setParentEntityId("test-experiment-2");
+            entity4.setFullText("test input file 1 for experiment 2");
+            sharingServiceClient.createEntity(entity4);
+            System.out.println("After sharingServiceClient.createEntity entity4...\n");
+            System.out.println("After test entity creation...\n");
+
+            //shared with cascading permissions
+            //System.out.println("Before shareEntityWithUsers WRITE...\n");
+            //sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true);
+            System.out.println("Before shareEntityWithGroups READ...\n");
+            long time = System.currentTimeMillis();
+            sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "READ", true);
+            System.out.println("Time for sharing " + (System.currentTimeMillis() - time));
+            //shared with non cascading permissions
+            System.out.println("Before shareEntityWithGroups CLONE...\n");
+            time = System.currentTimeMillis();
+            sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "CLONE", false);
+            System.out.println("Time for sharing " + (System.currentTimeMillis() - time));
+
+            //test-project-1 is explicitly shared with test-user-2 with WRITE permission
+            System.out.println("Before userHasAccess 1...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-project-1", "WRITE"));
+            //test-user-2 has WRITE permission to test-experiment-1 and test-experiment-2 indirectly
+            System.out.println("Before userHasAccess 2...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "WRITE"));
+            System.out.println("Before userHasAccess 3...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "WRITE"));
+            //test-user-2 does not have READ permission to test-experiment-1 and test-experiment-2
+            System.out.println("Before userHasAccess 4...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "READ"));
+            System.out.println(domainId + " test-user-2 " + " test-experiment-2 " + " READ ");
+            System.out.println("Before userHasAccess 5...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "READ"));
+            //test-user-3 does not have READ permission to test-project-1
+            System.out.println("Before userHasAccess 6...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-project-1", "READ"));
+            //test-experiment-2 is shared with test-group-2 with READ permission. Therefore test-user-3 has READ permission
+            System.out.println("Before userHasAccess 7...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "READ"));
+            //test-user-3 does not have WRITE permission to test-experiment-2
+            System.out.println("Before userHasAccess 8...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "WRITE"));
+            //test-user-3 has CLONE permission to test-experiment-2
+            System.out.println("Before userHasAccess 9...\n");
+            System.out.println((sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "CLONE")));
+            //test-user-3 does not have CLONE permission to test-file-1
+            System.out.println("Before userHasAccess 10...\n");
+            System.out.println((sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-file-1", "CLONE")));
+            System.out.println("After cascading permissions...\n");
+
+            ArrayList<SearchCriteria> filters = new ArrayList<>();
+            //ArrayList<SearchCriteria> filters = new List<>();
+            SearchCriteria searchCriteria = new SearchCriteria();
+            searchCriteria.setSearchCondition(SearchCondition.LIKE);
+            searchCriteria.setValue("experiment stampede methyl");
+            //searchCriteria.setValue("stampede");
+            //searchCriteria.setSearchField(EntitySearchField.NAME);
+            searchCriteria.setSearchField(EntitySearchField.FULL_TEXT);
+            filters.add(searchCriteria);
+            searchCriteria = new SearchCriteria();
+            searchCriteria.setSearchCondition(SearchCondition.EQUAL);
+            searchCriteria.setValue("READ");
+            searchCriteria.setSearchField(EntitySearchField.PERMISSION_TYPE_ID);
+            filters.add(searchCriteria);
+            System.out.println(sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1).size());
+            System.out.println(sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1));
+            System.out.println("After searchEntities...\n");
+
+
+            //System.out.println("After searchEntities...\n");
+            User userA = new User();
+            String userNameA = "UserA";
+            String userIdA = "UserA";
+            //required
+            userA.setUserId(userIdA);
+            //required
+            userA.setUserName(userNameA);
+            //required
+            userA.setDomainId(domainId);
+            //required
+            userA.setFirstName("User");
+            //required
+            userA.setLastName("A");
+            //required
+            userA.setEmail("user.a@example.com");
+            //optional - this should be bytes of the users image icon
+            //byte[] icon = new byte[10];
+            //userA.setIcon(icon);
+            sharingServiceClient.createUser(userA);
+            User userB = new User();
+            String userNameB = "UserB";
+            String userIdB = "UserB";
+            //required
+            userB.setUserId(userIdB);
+            //required
+            userB.setUserName(userNameB);
+            //required
+            userB.setDomainId(domainId);
+            //required
+            userB.setFirstName("User");
+            //required
+            userB.setLastName("B");
+            //required
+            userB.setEmail("user.b@example.com");
+            //optional - this should be bytes of the users image icon
+            //byte[] icon = new byte[10];
+            //userB.setIcon(icon);
+            sharingServiceClient.createUser(userB);
+            User userC = new User();
+            String userNameC = "UserC";
+            String userIdC = "UserC";
+            //required
+            userC.setUserId(userIdC);
+            //required
+            userC.setUserName(userNameC);
+            //required
+            userC.setDomainId(domainId);
+            //required
+            userC.setFirstName("User");
+            //required
+            userC.setLastName("C");
+            //required
+            userC.setEmail("user.c@example.com");
+            //optional - this should be bytes of the users image icon
+            //byte[] icon = new byte[10];
+            //userC.setIcon(icon);
+            sharingServiceClient.createUser(userC);
+            User userD = new User();
+            String userNameD = "UserD";
+            String userIdD = "UserD";
+            //required
+            userD.setUserId(userIdD);
+            //required
+            userD.setUserName(userNameD);
+            //required
+            userD.setDomainId(domainId);
+            //required
+            userD.setFirstName("User");
+            //required
+            userD.setLastName("D");
+            //required
+            userD.setEmail("user.d@example.com");
+            //optional - this should be bytes of the users image icon
+            //byte[] icon = new byte[10];
+            //userD.setIcon(icon);
+            sharingServiceClient.createUser(userD);
+            System.out.println("After user creation...\n");
+
+            UserGroup Group1 = new UserGroup();
+            //required
+            Group1.setGroupId("Group1");
+            //required
+            Group1.setDomainId(domainId);
+            //required
+            Group1.setName("Group1");
+            //optional
+            //userGroup1.setDescription("test group description");
+            //required
+            Group1.setOwnerId("UserA");
+            //required
+            Group1.setGroupType(GroupType.USER_LEVEL_GROUP);
+            sharingServiceClient.createGroup(Group1);
+            System.out.println("After Group1 creation...\n");
+
+            sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("UserB"), "Group1");
+            sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("UserC"), "Group1");
+            sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("UserD"), "Group1");
+
+            System.out.println("After adding users to Group1 creation...\n");
+
+            EntityType entityTypeFolder = new EntityType();
+            //required
+            entityTypeFolder.setEntityTypeId("FOLDER");
+            //required
+            entityTypeFolder.setDomainId(domainId);
+            //required
+            entityTypeFolder.setName("FOLDER");
+            //optional
+            //entityTypeFolder.setDescription("PROJECT entity type description");
+            sharingServiceClient.createEntityType(entityTypeFolder);
+            System.out.println("After creating FOLDER entity type...\n");
+
+            EntityType entityTypeInputData = new EntityType();
+            //required
+            entityTypeInputData.setEntityTypeId("INPUTDATA");
+            //required
+            entityTypeInputData.setDomainId(domainId);
+            //required
+            entityTypeInputData.setName("INPUTDATA");
+            //optional
+            //entityTypeFolder.setDescription("PROJECT entity type description");
+            sharingServiceClient.createEntityType(entityTypeInputData);
+            System.out.println("After creating INPUTDATA entity type...\n");
+
+            Entity entityB1 = new Entity();
+            //required
+            entityB1.setEntityId("UserBProject1");
+            //required
+            entityB1.setDomainId(domainId);
+            //required
+            entityB1.setEntityTypeId("PROJECT");
+            //required
+            entityB1.setOwnerId("UserB");
+            //required
+            entityB1.setName("UserBProject1");
+            //optional
+            entityB1.setDescription("User B's Project 1");
+            //optional
+            entityB1.setFullText("test project 1");
+            //optional - If not set this will be default to current system time
+            entityB1.setOriginalEntityCreationTime(System.currentTimeMillis());
+            sharingServiceClient.createEntity(entityB1);
+            System.out.println("After creating UserBProject1 ...\n");
+
+            Entity entityC1 = new Entity();
+            //required
+            entityC1.setEntityId("UserCProject2");
+            //required
+            entityC1.setDomainId(domainId);
+            //required
+            entityC1.setEntityTypeId("PROJECT");
+            //required
+            entityC1.setOwnerId("UserC");
+            //required
+            entityC1.setName("UserCProject2");
+            //optional
+            entityC1.setDescription("User C's Project 2");
+            //optional
+            entityC1.setFullText("test project 2");
+            //optional - If not set this will be default to current system time
+            entityC1.setOriginalEntityCreationTime(System.currentTimeMillis());
+            sharingServiceClient.createEntity(entityC1);
+            System.out.println("After creating UserCProject2 ...\n");
+
+            Entity entityF1 = new Entity();
+            entityF1.setEntityId("Folder1");
+            entityF1.setDomainId(domainId);
+            entityF1.setEntityTypeId("FOLDER");
+            entityF1.setOwnerId("UserB");
+            entityF1.setName("UserBFolder1");
+            entityF1.setDescription("UserB's Folder 1");
+            entityF1.setParentEntityId("UserBProject1");
+            entityF1.setFullText("test experiment 1 ethidium");
+            sharingServiceClient.createEntity(entityF1);
+            System.out.println("After creating Folder1 ...\n");
+
+            Entity entityD1 = new Entity();
+            entityD1.setEntityId("Data1");
+            entityD1.setDomainId(domainId);
+            entityD1.setEntityTypeId("INPUTDATA");
+            entityD1.setOwnerId("UserB");
+            entityD1.setName("UserBData1");
+            entityD1.setDescription("UserB's Data 1");
+            entityD1.setParentEntityId("Folder1");
+            entityD1.setFullText("Data 1 for User B Folder 1");
+            sharingServiceClient.createEntity(entityD1);
+            System.out.println("After creating Data1 ...\n");
+
+            Entity entityF2 = new Entity();
+            entityF2.setEntityId("Folder2");
+            entityF2.setDomainId(domainId);
+            entityF2.setEntityTypeId("FOLDER");
+            entityF2.setOwnerId("UserC");
+            entityF2.setName("UserCFolder2");
+            entityF2.setDescription("UserC's Folder 2");
+            entityF2.setParentEntityId("UserCProject2");
+            entityF2.setFullText("test experiment 2 ethidium");
+            sharingServiceClient.createEntity(entityF2);
+            System.out.println("After creating Folder2 ...\n");
+
+            Entity entityD2 = new Entity();
+            entityD2.setEntityId("Data2");
+            entityD2.setDomainId(domainId);
+            entityD2.setEntityTypeId("INPUTDATA");
+            entityD2.setOwnerId("UserC");
+            entityD2.setName("UserCData2");
+            entityD2.setDescription("UserC's Data 2");
+            entityD2.setParentEntityId("Folder2");
+            entityD2.setFullText("Data 2 for User C Folder 1");
+            sharingServiceClient.createEntity(entityD2);
+            System.out.println("After creating Data2 ...\n");
+
+            //sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "READ", true);
+            time = System.currentTimeMillis();
+            sharingServiceClient.shareEntityWithGroups(domainId, "Folder1", Arrays.asList("Group1"), "READ", true);
+            System.out.println("Time for sharing " + (System.currentTimeMillis() - time));
+            System.out.println("After READ sharing UserBFolder1 with Group1 ...\n");
+            //sharingServiceClient.shareEntityWithGroups(domainId, "Folder2", Arrays.asList("Group1"), "READ", true);
+            //System.out.println("After READ sharing UserCFolder2 with Group1 ...\n");
+
+            Entity entityD3 = new Entity();
+            entityD3.setEntityId("Data3");
+            entityD3.setDomainId(domainId);
+            entityD3.setEntityTypeId("INPUTDATA");
+            entityD3.setOwnerId("UserC");
+            entityD3.setName("UserCData3");
+            entityD3.setDescription("UserC's Data 3");
+            entityD3.setParentEntityId("Folder2");
+            entityD3.setFullText("Data 3 for User C Folder 2");
+            sharingServiceClient.createEntity(entityD3);
+            System.out.println("After creating Data3 ...\n");
+
+            System.out.println("Does UserC have READ access to Data1 ...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "UserC", "Data1", "READ"));
+            System.out.println("Does UserC have READ access to Data2 ...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "UserC", "Data2", "READ"));
+            System.out.println("Does UserC have READ access to Data3 ...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "UserC", "Data3", "READ"));
+            System.out.println("Does UserB have READ access to Data3 ...\n");
+            System.out.println(sharingServiceClient.userHasAccess(domainId, "UserB", "Data3", "READ"));
+
+            ArrayList<SearchCriteria> sharedfilters = new ArrayList<>();
+            searchCriteria = new SearchCriteria();
+            searchCriteria.setSearchCondition(SearchCondition.EQUAL);
+            searchCriteria.setValue("READ");
+            searchCriteria.setSearchField(EntitySearchField.PERMISSION_TYPE_ID);
+            sharedfilters.add(searchCriteria);
+            System.out.println("items READable by UserC ...\n");
+            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1).size());
+            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1));
+            searchCriteria = new SearchCriteria();
+            //searchCriteria.setSearchCondition(SearchCondition.EQUAL);
+            searchCriteria.setSearchCondition(SearchCondition.NOT);
+            searchCriteria.setValue("UserC");
+            searchCriteria.setSearchField(EntitySearchField.OWNER_ID);
+            sharedfilters.add(searchCriteria);
+            System.out.println("items READable, and not owned by UserC by UserC ...\n");
+            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1).size());
+            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1));
+            System.out.println("After searchEntities 2...\n");
+
+            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1).size());
+            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1));
+            System.out.println("After searchEntities 2...\n");
+
+
+            sharingServiceClient.removeUsersFromGroup(domainId, Arrays.asList("UserD"), "Group1");
+            System.out.println("After removing UserD from Group1 ...\n");
+
+            sharingServiceClient.deleteGroup(domainId, "Group1");
+            System.out.println("After deleting Group1 ...\n");
+
+            System.out.println("End of try clause...\n");
+        } catch (TTransportException ex1) {
+            System.out.println("TTransportException...\n");
+            System.out.println(ex1);
+            System.out.println(ex1.getCause());
+            ex1.printStackTrace();
+            System.out.println(ex1.getMessage());
+        } catch (SharingRegistryException ex2) {
+            System.out.println("SharingRegistryException...\n");
+            System.out.println(ex2.getMessage());
+        } catch (TException ex3) {
+            System.out.println("TException...\n");
+            System.out.println(ex3.getMessage());
+        } finally {
+            System.out.println("In finally...\n");
+            transport.close();
+        }
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServerHandlerTest.java b/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServerHandlerTest.java
new file mode 100644
index 0000000..2b88167
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServerHandlerTest.java
@@ -0,0 +1,386 @@
+/**
+ *
+ * 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.custos.sharing.registry;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.sharing.registry.db.utils.SharingRegistryDBInitConfig;
+import org.apache.custos.sharing.registry.models.*;
+import org.apache.custos.sharing.registry.server.SharingRegistryServerHandler;
+import org.junit.Assert;
+import org.apache.thrift.TException;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class SharingRegistryServerHandlerTest {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServerHandlerTest.class);
+
+    @Test
+    public void test() throws TException, ApplicationSettingsException {
+        SharingRegistryDBInitConfig sharingRegistryDBInitConfig = new SharingRegistryDBInitConfig();
+        sharingRegistryDBInitConfig.setDBInitScriptPrefix("sharing-registry");
+        SharingRegistryServerHandler sharingRegistryServerHandler = new SharingRegistryServerHandler(sharingRegistryDBInitConfig);
+
+        //Creating domain
+        Domain domain = new Domain();
+        String domainId = "test-domain."+System.currentTimeMillis();
+        domain.setDomainId(domainId);
+        domain.setName(domainId);
+        domain.setDescription("test domain description");
+        domain.setCreatedTime(System.currentTimeMillis());
+        domain.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createDomain(domain));
+        Assert.assertTrue(sharingRegistryServerHandler.getDomains(0, 10).size() > 0);
+
+        //Creating users
+        User user1 = new User();
+        String userName1 = "test-user-1." + System.currentTimeMillis();
+        String userId1 = domainId + ":" + userName1;
+        user1.setUserId(userId1);
+        user1.setUserName(userName1);
+        user1.setDomainId(domainId);
+        user1.setCreatedTime(System.currentTimeMillis());
+        user1.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user1));
+
+        User user2 = new User();
+        String userName2 = "test-user-2." + System.currentTimeMillis();
+        String userId2 = domainId + ":" + userName2;
+        user2.setUserId(userId2);
+        user2.setUserName(userName2);
+        user2.setDomainId(domainId);
+        user2.setCreatedTime(System.currentTimeMillis());
+        user2.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user2));
+
+        User user3 = new User();
+        String userName3 = "test-user-3." + System.currentTimeMillis();
+        String userId3 = domainId + ":" + userName3;
+        user3.setUserId(userId3);
+        user3.setUserName(userName3);
+        user3.setDomainId(domainId);
+        user3.setCreatedTime(System.currentTimeMillis());
+        user3.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user3));
+
+        User user7 = new User();
+        String userName7 = "test-user-7." + System.currentTimeMillis();
+        String userId7 = domainId + ":" + userName7;
+        user7.setUserId(userId7);
+        user7.setUserName(userName7);
+        user7.setDomainId(domainId);
+        user7.setCreatedTime(System.currentTimeMillis());
+        user7.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user7));
+
+        Assert.assertTrue(sharingRegistryServerHandler.getUsers(domainId, 0, 10).size() > 0);
+
+        // Creating user groups
+        UserGroup userGroup1 = new UserGroup();
+        String groupName1 = "test-group-1." + System.currentTimeMillis();
+        String groupId1 = domainId + ":" + groupName1;
+        userGroup1.setGroupId(groupId1);
+        userGroup1.setDomainId(domainId);
+        userGroup1.setName(groupName1);
+        userGroup1.setDescription("test group description");
+        userGroup1.setOwnerId(userId1);
+        userGroup1.setGroupType(GroupType.USER_LEVEL_GROUP);
+        userGroup1.setGroupCardinality(GroupCardinality.MULTI_USER);
+        userGroup1.setCreatedTime(System.currentTimeMillis());
+        userGroup1.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createGroup(userGroup1));
+        Assert.assertEquals(1, sharingRegistryServerHandler.getAllMemberGroupsForUser(domainId, userId1).size());
+
+        UserGroup userGroup2 = new UserGroup();
+        String groupName2 = "test-group-2." + System.currentTimeMillis();
+        String groupId2 = domainId + ":" + groupName2;
+        userGroup2.setGroupId(groupId2);
+        userGroup2.setDomainId(domainId);
+        userGroup2.setName(groupName2);
+        userGroup2.setDescription("test group description");
+        userGroup2.setOwnerId(userId2);
+        userGroup2.setGroupType(GroupType.USER_LEVEL_GROUP);
+        userGroup2.setGroupCardinality(GroupCardinality.MULTI_USER);
+        userGroup2.setCreatedTime(System.currentTimeMillis());
+        userGroup2.setUpdatedTime(System.currentTimeMillis());
+
+        Assert.assertNotNull(sharingRegistryServerHandler.createGroup(userGroup2));
+
+        sharingRegistryServerHandler.addUsersToGroup(domainId, Arrays.asList(userId1), groupId1);
+        sharingRegistryServerHandler.addUsersToGroup(domainId, Arrays.asList(userId7), groupId1);
+
+        sharingRegistryServerHandler.addUsersToGroup(domainId, Arrays.asList(userId2, userId3), groupId2);
+        Assert.assertEquals(1, sharingRegistryServerHandler.getAllMemberGroupsForUser(domainId, userId3).size());
+
+        sharingRegistryServerHandler.addChildGroupsToParentGroup(domainId, Arrays.asList(groupId2), groupId1);
+
+        Assert.assertTrue(sharingRegistryServerHandler.getGroupMembersOfTypeGroup(domainId, groupId1, 0, 10).size() == 1);
+        Assert.assertTrue(sharingRegistryServerHandler.getGroupMembersOfTypeUser(domainId, groupId2, 0, 10).size() == 2);
+
+        // Group roles tests
+
+        // user has owner access
+        Assert.assertTrue(sharingRegistryServerHandler.hasOwnerAccess(domainId, groupId1, userId1));
+
+        // user has admin access
+        Assert.assertTrue(sharingRegistryServerHandler.addGroupAdmins(domainId, groupId1, Arrays.asList(userId7)));
+        Assert.assertTrue(sharingRegistryServerHandler.hasAdminAccess(domainId, groupId1, userId7));
+        Assert.assertTrue(sharingRegistryServerHandler.removeGroupAdmins(domainId, groupId1, Arrays.asList(userId7)));
+        Assert.assertFalse(sharingRegistryServerHandler.hasAdminAccess(domainId, groupId1, userId7));
+
+        // transfer group ownership
+        sharingRegistryServerHandler.addUsersToGroup(domainId, Arrays.asList(userId2), groupId1);
+        Assert.assertTrue(sharingRegistryServerHandler.transferGroupOwnership(domainId, groupId1, userId2));
+        Assert.assertTrue(sharingRegistryServerHandler.hasOwnerAccess(domainId, groupId1, userId2));
+        Assert.assertTrue(sharingRegistryServerHandler.transferGroupOwnership(domainId, groupId1, userId1));
+        Assert.assertFalse(sharingRegistryServerHandler.hasOwnerAccess(domainId, groupId1, userId2));
+
+        //Creating permission types
+        PermissionType permissionType1 = new PermissionType();
+        String permissionName1 = "READ";
+        permissionType1.setPermissionTypeId(domainId+":"+permissionName1);
+        permissionType1.setDomainId(domainId);
+        permissionType1.setName(permissionName1);
+        permissionType1.setDescription("READ description");
+        permissionType1.setCreatedTime(System.currentTimeMillis());
+        permissionType1.setUpdatedTime(System.currentTimeMillis());
+        String permissionTypeId1 = sharingRegistryServerHandler.createPermissionType(permissionType1);
+        Assert.assertNotNull(permissionTypeId1);
+
+        PermissionType permissionType2 = new PermissionType();
+        String permissionName2 = "WRITE";
+        permissionType2.setPermissionTypeId(domainId+":"+permissionName2);
+        permissionType2.setDomainId(domainId);
+        permissionType2.setName(permissionName2);
+        permissionType2.setDescription("WRITE description");
+        permissionType2.setCreatedTime(System.currentTimeMillis());
+        permissionType2.setUpdatedTime(System.currentTimeMillis());
+        String permissionTypeId2 = sharingRegistryServerHandler.createPermissionType(permissionType2);
+        Assert.assertNotNull(permissionTypeId2);
+
+        //Creating entity types
+        EntityType entityType1 = new EntityType();
+        String entityType1Name = "Project";
+        entityType1.setEntityTypeId(domainId+":"+entityType1Name);
+        entityType1.setDomainId(domainId);
+        entityType1.setName(entityType1Name);
+        entityType1.setDescription("test entity type");
+        entityType1.setCreatedTime(System.currentTimeMillis());
+        entityType1.setUpdatedTime(System.currentTimeMillis());
+        String entityTypeId1 = sharingRegistryServerHandler.createEntityType(entityType1);
+        Assert.assertNotNull(entityTypeId1);
+
+        EntityType entityType2 = new EntityType();
+        String entityType2Name = "Experiment";
+        entityType2.setEntityTypeId(domainId+":"+entityType2Name);
+        entityType2.setDomainId(domainId);
+        entityType2.setName(entityType2Name);
+        entityType2.setDescription("test entity type");
+        entityType2.setCreatedTime(System.currentTimeMillis());
+        entityType2.setUpdatedTime(System.currentTimeMillis());
+        String entityTypeId2 = sharingRegistryServerHandler.createEntityType(entityType2);
+        Assert.assertNotNull(entityTypeId2);
+
+        EntityType entityType3 = new EntityType();
+        String entityType3Name = "FileInput";
+        entityType3.setEntityTypeId(domainId+":"+entityType3Name);
+        entityType3.setDomainId(domainId);
+        entityType3.setName(entityType3Name);
+        entityType3.setDescription("file input type");
+        entityType3.setCreatedTime(System.currentTimeMillis());
+        entityType3.setUpdatedTime(System.currentTimeMillis());
+        String entityTypeId3 = sharingRegistryServerHandler.createEntityType(entityType3);
+        Assert.assertNotNull(entityTypeId3);
+
+        EntityType entityType4 = new EntityType();
+        String entityType4Name = "Application-Deployment";
+        entityType4.setEntityTypeId(domainId+":"+entityType4Name);
+        entityType4.setDomainId(domainId);
+        entityType4.setName(entityType4Name);
+        entityType4.setDescription("test entity type");
+        entityType4.setCreatedTime(System.currentTimeMillis());
+        entityType4.setUpdatedTime(System.currentTimeMillis());
+        String entityTypeId4 = sharingRegistryServerHandler.createEntityType(entityType4);
+        Assert.assertNotNull(entityTypeId4);
+
+        //Creating Entities
+        Entity entity1 = new Entity();
+        entity1.setEntityId(domainId+":Entity1");
+        entity1.setDomainId(domainId);
+        entity1.setEntityTypeId(entityTypeId1);
+        entity1.setOwnerId(userId1);
+        entity1.setName("Project name 1");
+        entity1.setDescription("Project description");
+        entity1.setFullText("Project name project description");
+        entity1.setCreatedTime(System.currentTimeMillis());
+        entity1.setUpdatedTime(System.currentTimeMillis());
+
+        String entityId1 = sharingRegistryServerHandler.createEntity(entity1);
+        Assert.assertNotNull(entityId1);
+
+        Entity entity2 = new Entity();
+        entity2.setEntityId(domainId+":Entity2");
+        entity2.setDomainId(domainId);
+        entity2.setEntityTypeId(entityTypeId2);
+        entity2.setOwnerId(userId1);
+        entity2.setName("Experiment name");
+        entity2.setDescription("Experiment description");
+        entity2.setParentEntityId(entityId1);
+        entity2.setFullText("Project name project description");
+        entity2.setCreatedTime(System.currentTimeMillis());
+        entity2.setUpdatedTime(System.currentTimeMillis());
+
+        String entityId2 = sharingRegistryServerHandler.createEntity(entity2);
+        Assert.assertNotNull(entityId2);
+
+        Entity entity3 = new Entity();
+        entity3.setEntityId(domainId+":Entity3");
+        entity3.setDomainId(domainId);
+        entity3.setEntityTypeId(entityTypeId2);
+        entity3.setOwnerId(userId1);
+        entity3.setName("Experiment name");
+        entity3.setDescription("Experiment description");
+        entity3.setParentEntityId(entityId1);
+        entity3.setFullText("Project name project description");
+        entity3.setCreatedTime(System.currentTimeMillis());
+        entity3.setUpdatedTime(System.currentTimeMillis());
+
+        String entityId3 = sharingRegistryServerHandler.createEntity(entity3);
+        Assert.assertNotNull(entityId3);
+
+        sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId1, Arrays.asList(userId2), permissionTypeId1, true);
+        sharingRegistryServerHandler.shareEntityWithGroups(domainId, entityId3, Arrays.asList(groupId2), permissionTypeId1, true);
+
+        Entity entity4 = new Entity();
+        entity4.setEntityId(domainId+":Entity4");
+        entity4.setDomainId(domainId);
+        entity4.setEntityTypeId(entityTypeId3);
+        entity4.setOwnerId(userId3);
+        entity4.setName("Input name");
+        entity4.setDescription("Input file description");
+        entity4.setParentEntityId(entityId3);
+        entity4.setFullText("Input File");
+        entity4.setCreatedTime(System.currentTimeMillis());
+        entity4.setUpdatedTime(System.currentTimeMillis());
+
+        String entityId4 = sharingRegistryServerHandler.createEntity(entity4);
+        Assert.assertNotNull(entityId4);
+
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId4, permissionTypeId1));
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId4, permissionTypeId1));
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId1, entityId4, permissionTypeId1));
+        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId1, permissionTypeId1));
+
+        Entity entity5 = new Entity();
+        entity5.setEntityId(domainId+":Entity5");
+        entity5.setDomainId(domainId);
+        entity5.setEntityTypeId(entityTypeId4);
+        entity5.setOwnerId(userId1);
+        entity5.setName("App deployment name");
+        entity5.setDescription("App deployment description");
+        entity5.setFullText("App Deployment name app deployment description");
+        entity5.setCreatedTime(System.currentTimeMillis());
+        entity5.setUpdatedTime(System.currentTimeMillis());
+
+        String entityId5 = sharingRegistryServerHandler.createEntity(entity5);
+        Assert.assertNotNull(entityId5);
+
+        sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId5, Arrays.asList(userId2), permissionTypeId1, true);
+        sharingRegistryServerHandler.shareEntityWithGroups(domainId, entityId5, Arrays.asList(groupId2), permissionTypeId2, true);
+
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId5, permissionTypeId2));
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId5, permissionTypeId1));
+        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId5, permissionTypeId1));
+
+        ArrayList<SearchCriteria> filters = new ArrayList<>();
+        SearchCriteria searchCriteria = new SearchCriteria();
+        searchCriteria.setSearchCondition(SearchCondition.LIKE);
+        searchCriteria.setValue("Input");
+        searchCriteria.setSearchField(EntitySearchField.NAME);
+        filters.add(searchCriteria);
+
+        searchCriteria = new SearchCriteria();
+        searchCriteria.setSearchCondition(SearchCondition.EQUAL);
+        searchCriteria.setValue(entityTypeId3);
+        searchCriteria.setSearchField(EntitySearchField.ENTITY_TYPE_ID);
+        filters.add(searchCriteria);
+
+        Assert.assertTrue(sharingRegistryServerHandler.searchEntities(domainId, userId1, filters, 0, -1).size() > 0);
+
+        Assert.assertNotNull(sharingRegistryServerHandler.getListOfSharedUsers(domainId, entityId1, permissionTypeId1));
+        Assert.assertNotNull(sharingRegistryServerHandler.getListOfSharedGroups(domainId, entityId1, permissionTypeId1));
+
+        Assert.assertTrue(sharingRegistryServerHandler.getListOfSharedUsers(domainId, entityId1, domainId + ":OWNER").size()==1);
+
+        // test changing parent - old INDIRECT_CASCADING permissions removed, new is added
+        // entityId2's parent is entityId1. entityId1 is shared with userId2
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId1, permissionTypeId1));
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId2, permissionTypeId1));
+        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId2, permissionTypeId1));
+        // create a different parent entity
+        Entity entity6 = new Entity();
+        entity6.setEntityId(domainId+":Entity6");
+        entity6.setDomainId(domainId);
+        entity6.setEntityTypeId(entityTypeId1);
+        entity6.setOwnerId(userId1);
+        entity6.setName("Project name 2");
+        entity6.setDescription("Project description");
+        entity6.setFullText("Project name project description");
+        entity6.setCreatedTime(System.currentTimeMillis());
+        entity6.setUpdatedTime(System.currentTimeMillis());
+        String entityId6 = sharingRegistryServerHandler.createEntity(entity6);
+        Assert.assertNotNull(entityId6);
+
+        sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId6, Arrays.asList(userId3), permissionTypeId1, true);
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId6, permissionTypeId1));
+        // Make sure entityId2 isn't shared with userId7 and then share it directly
+        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId7, entityId2, permissionTypeId1));
+        sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId2, Arrays.asList(userId7), permissionTypeId1, true);
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId7, entityId2, permissionTypeId1));
+        entity2.setParentEntityId(entityId6);
+        logger.debug("Updating entity2");
+        Assert.assertTrue(sharingRegistryServerHandler.updateEntity(entity2));
+        Entity entity2Updated = sharingRegistryServerHandler.getEntity(domainId, entityId2);
+        Assert.assertEquals(entityId6, entity2Updated.getParentEntityId());
+        // parent changed so entityId2 should now be shared with entityId6's shared users (userId3)
+        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId2, permissionTypeId1));
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId2, permissionTypeId1));
+        // entityId2 should still be shared with userId7 since that was directly shared
+        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId7, entityId2, permissionTypeId1));
+
+        Assert.assertEquals(Arrays.asList(user3), sharingRegistryServerHandler.getListOfDirectlySharedUsers(domainId, entityId6, permissionTypeId1));
+        Assert.assertEquals(Arrays.asList(user7), sharingRegistryServerHandler.getListOfDirectlySharedUsers(domainId, entityId2, permissionTypeId1));
+        List<User> entityId2SharedUsers = sharingRegistryServerHandler.getListOfSharedUsers(domainId, entityId2, permissionTypeId1);
+        Assert.assertEquals(2, entityId2SharedUsers.size());
+        Assert.assertTrue("user3 and user7 in shared users", entityId2SharedUsers.contains(user3) && entityId2SharedUsers.contains(user7));
+        Assert.assertEquals(1, sharingRegistryServerHandler.getListOfDirectlySharedGroups(domainId, entityId3, permissionTypeId1).size());
+        Assert.assertEquals(groupId2, sharingRegistryServerHandler.getListOfDirectlySharedGroups(domainId, entityId3, permissionTypeId1).get(0).getGroupId());
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServiceTest.java b/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServiceTest.java
new file mode 100644
index 0000000..c6777ff
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServiceTest.java
@@ -0,0 +1,419 @@
+/**
+ *
+ * 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.custos.sharing.registry;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.sharing.registry.models.*;
+import org.apache.custos.sharing.registry.server.SharingRegistryServer;
+import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSSLTransportFactory;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class SharingRegistryServiceTest {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServiceTest.class);
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        SharingRegistryServer server = new SharingRegistryServer();
+        server.setTestMode(true);
+        server.start();
+        Thread.sleep(1000 * 2);
+    }
+
+
+    @Test
+    public void test() throws TException, InterruptedException, ApplicationSettingsException {
+        String serverHost = "localhost";
+        int serverPort = 7878;
+
+        SharingRegistryService.Client sharingServiceClient;
+        if (!ServerSettings.isSharingTLSEnabled()) {
+            TTransport transport = new TSocket(serverHost, serverPort);
+            transport.open();
+            TProtocol protocol = new TBinaryProtocol(transport);
+            sharingServiceClient = new SharingRegistryService.Client(protocol);
+        }else{
+            TSSLTransportFactory.TSSLTransportParameters params =
+                    new TSSLTransportFactory.TSSLTransportParameters();
+            params.setKeyStore(ServerSettings.getKeyStorePath(), ServerSettings.getKeyStorePassword());
+            params.setTrustStore(ServerSettings.getTrustStorePath(), ServerSettings.getTrustStorePassword());
+
+            TTransport transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, 10000, params);
+            TProtocol protocol = new TBinaryProtocol(transport);
+            sharingServiceClient = new SharingRegistryService.Client(protocol);
+        }
+
+        Domain domain = new Domain();
+        //has to be one word
+        domain.setName("test-domain" + Math.random());
+        //optional
+        domain.setDescription("test domain description");
+
+        String domainId = sharingServiceClient.createDomain(domain);
+        Assert.assertTrue(sharingServiceClient.isDomainExists(domainId));
+
+        User user1 = new User();
+        //required
+        user1.setUserId("test-user-1");
+        //required
+        user1.setUserName("test-user-1");
+        //required
+        user1.setDomainId(domainId);
+        //required
+        user1.setFirstName("John");
+        //required
+        user1.setLastName("Doe");
+        //required
+        user1.setEmail("john.doe@abc.com");
+        //optional - this should be bytes of the users image icon
+        //byte[] icon1 = new byte[10];
+        //user1.setIcon(icon1);
+
+        sharingServiceClient.createUser(user1);
+        Assert.assertTrue(sharingServiceClient.isUserExists(domainId, "test-user-1"));
+
+        User user2 = new User();
+        //required
+        user2.setUserId("test-user-2");
+        //required
+        user2.setUserName("test-user-2");
+        //required
+        user2.setDomainId(domainId);
+        //required
+        user2.setFirstName("John");
+        //required
+        user2.setLastName("Doe");
+        //required
+        user2.setEmail("john.doe@abc.com");
+        //optional - this should be bytes of the users image icon
+        //byte[] icon2 = new byte[10];
+        //user2.setIcon(icon2);
+
+        sharingServiceClient.createUser(user2);
+
+        User user3 = new User();
+        //required
+        user3.setUserId("test-user-3");
+        //required
+        user3.setUserName("test-user-3");
+        //required
+        user3.setDomainId(domainId);
+        //required
+        user3.setFirstName("John");
+        //required
+        user3.setLastName("Doe");
+        //required
+        user3.setEmail("john.doe@abc.com");
+        //optional - this should be bytes of the users image icon
+        //byte[] icon3 = new byte[10];
+        //user3.setIcon(icon3);
+
+        sharingServiceClient.createUser(user3);
+
+        User user7 = new User();
+        //required
+        user7.setUserId("test-user-7");
+        //required
+        user7.setUserName("test-user-7");
+        //required
+        user7.setDomainId(domainId);
+        //required
+        user7.setFirstName("John");
+        //required
+        user7.setLastName("Doe");
+        //required
+        user7.setEmail("john.doe@abc.com");
+        //optional - this should be bytes of the users image icon
+        //byte[] icon3 = new byte[10];
+        //user3.setIcon(icon3);
+
+        sharingServiceClient.createUser(user7);
+
+        // Test updates to user and how it affects the user's SINGLE_USER group
+        UserGroup singleUserGroupUser7 = sharingServiceClient.getGroup(domainId, user7.getUserId());
+        Assert.assertEquals(GroupCardinality.SINGLE_USER, singleUserGroupUser7.getGroupCardinality());
+        user7.setFirstName("Johnny");
+        sharingServiceClient.updatedUser(user7);
+        User updatedUser7 = sharingServiceClient.getUser(domainId, user7.getUserId());
+        Assert.assertEquals("Johnny", updatedUser7.getFirstName());
+        singleUserGroupUser7 = sharingServiceClient.getGroup(domainId, user7.getUserId());
+        Assert.assertEquals(GroupCardinality.SINGLE_USER, singleUserGroupUser7.getGroupCardinality());
+
+        UserGroup userGroup1 = new UserGroup();
+        //required
+        userGroup1.setGroupId("test-group-1");
+        //required
+        userGroup1.setDomainId(domainId);
+        //required
+        userGroup1.setName("test-group-1");
+        //optional
+        userGroup1.setDescription("test group description");
+        //required
+        userGroup1.setOwnerId("test-user-1");
+        //required
+        userGroup1.setGroupType(GroupType.USER_LEVEL_GROUP);
+
+        sharingServiceClient.createGroup(userGroup1);
+        userGroup1.setDescription("updated description");
+        sharingServiceClient.updateGroup(userGroup1);
+        Assert.assertTrue(sharingServiceClient.getGroup(domainId, userGroup1.getGroupId()).getDescription().equals("updated description"));
+        Assert.assertTrue(sharingServiceClient.isGroupExists(domainId, "test-group-1"));
+
+        UserGroup userGroup2 = new UserGroup();
+        //required
+        userGroup2.setGroupId("test-group-2");
+        //required
+        userGroup2.setDomainId(domainId);
+        //required
+        userGroup2.setName("test-group-2");
+        //optional
+        userGroup2.setDescription("test group description");
+        //required
+        userGroup2.setOwnerId("test-user-2");
+        //required
+        userGroup2.setGroupType(GroupType.USER_LEVEL_GROUP);
+
+        sharingServiceClient.createGroup(userGroup2);
+
+        sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("test-user-3"), "test-group-2");
+
+        sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("test-user-7"), "test-group-1");
+
+        sharingServiceClient.addChildGroupsToParentGroup(domainId, Arrays.asList("test-group-2"), "test-group-1");
+
+        //Group roles
+        Assert.assertTrue(sharingServiceClient.hasOwnerAccess(domainId, "test-group-1", "test-user-1"));
+
+        // user has admin access
+        Assert.assertTrue(sharingServiceClient.addGroupAdmins(domainId, "test-group-1", Arrays.asList("test-user-7")));
+        Assert.assertTrue(sharingServiceClient.hasAdminAccess(domainId, "test-group-1", "test-user-7"));
+
+        UserGroup getGroup = sharingServiceClient.getGroup(domainId, "test-group-1");
+        Assert.assertTrue(getGroup.getGroupAdmins().size() == 1);
+
+        Assert.assertTrue(sharingServiceClient.removeGroupAdmins(domainId, "test-group-1", Arrays.asList("test-user-7")));
+        Assert.assertFalse(sharingServiceClient.hasAdminAccess(domainId, "test-group-1", "test-user-7"));
+
+        // transfer group ownership
+        sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("test-user-2"), "test-group-1");
+        Assert.assertTrue(sharingServiceClient.transferGroupOwnership(domainId, "test-group-1", "test-user-2"));
+        Assert.assertTrue(sharingServiceClient.hasOwnerAccess(domainId, "test-group-1", "test-user-2"));
+        Assert.assertTrue(sharingServiceClient.transferGroupOwnership(domainId, "test-group-1", "test-user-1"));
+        Assert.assertFalse(sharingServiceClient.hasOwnerAccess(domainId, "test-group-1", "test-user-2"));
+
+        PermissionType permissionType1 = new PermissionType();
+        //required
+        permissionType1.setPermissionTypeId("READ");
+        //required
+        permissionType1.setDomainId(domainId);
+        //required
+        permissionType1.setName("READ");
+        //optional
+        permissionType1.setDescription("READ description");
+        sharingServiceClient.createPermissionType(permissionType1);
+        Assert.assertTrue(sharingServiceClient.isPermissionExists(domainId, "READ"));
+
+        PermissionType permissionType2 = new PermissionType();
+        permissionType2.setPermissionTypeId("WRITE");
+        permissionType2.setDomainId(domainId);
+        permissionType2.setName("WRITE");
+        permissionType2.setDescription("WRITE description");
+        sharingServiceClient.createPermissionType(permissionType2);
+
+        PermissionType permissionType3 = new PermissionType();
+        permissionType3.setPermissionTypeId("CLONE");
+        permissionType3.setDomainId(domainId);
+        permissionType3.setName("CLONE");
+        permissionType3.setDescription("CLONE description");
+        sharingServiceClient.createPermissionType(permissionType3);
+
+        EntityType entityType1 = new EntityType();
+        //required
+        entityType1.setEntityTypeId("PROJECT");
+        //required
+        entityType1.setDomainId(domainId);
+        //required
+        entityType1.setName("PROJECT");
+        //optional
+        entityType1.setDescription("PROJECT entity type description");
+        sharingServiceClient.createEntityType(entityType1);
+        Assert.assertTrue(sharingServiceClient.isEntityTypeExists(domainId, "PROJECT"));
+
+        EntityType entityType2 = new EntityType();
+        entityType2.setEntityTypeId("EXPERIMENT");
+        entityType2.setDomainId(domainId);
+        entityType2.setName("EXPERIMENT");
+        entityType2.setDescription("EXPERIMENT entity type");
+        sharingServiceClient.createEntityType(entityType2);
+
+        EntityType entityType3 = new EntityType();
+        entityType3.setEntityTypeId("FILE");
+        entityType3.setDomainId(domainId);
+        entityType3.setName("FILE");
+        entityType3.setDescription("FILE entity type");
+        sharingServiceClient.createEntityType(entityType3);
+
+
+        //Creating entities
+        Entity entity1 = new Entity();
+        //required
+        entity1.setEntityId("test-project-1");
+        //required
+        entity1.setDomainId(domainId);
+        //required
+        entity1.setEntityTypeId("PROJECT");
+        //required
+        entity1.setOwnerId("test-user-1");
+        //required
+        entity1.setName("test-project-1");
+        //optional
+        entity1.setDescription("test project 1 description");
+        //optional
+        entity1.setFullText("test project 1 stampede gaussian seagrid");
+        //optional - If not set this will be default to current system time
+        entity1.setOriginalEntityCreationTime(System.currentTimeMillis());
+        sharingServiceClient.createEntity(entity1);
+        Assert.assertTrue(sharingServiceClient.isEntityExists(domainId, "test-project-1"));
+
+        Entity entity2 = new Entity();
+        entity2.setEntityId("test-experiment-1");
+        entity2.setDomainId(domainId);
+        entity2.setEntityTypeId("EXPERIMENT");
+        entity2.setOwnerId("test-user-1");
+        entity2.setName("test-experiment-1");
+        entity2.setDescription("test experiment 1 description");
+        entity2.setParentEntityId("test-project-1");
+        entity2.setFullText("test experiment 1 benzene");
+        sharingServiceClient.createEntity(entity2);
+
+
+        Entity entity3 = new Entity();
+        entity3.setEntityId("test-experiment-2");
+        entity3.setDomainId(domainId);
+        entity3.setEntityTypeId("EXPERIMENT");
+        entity3.setOwnerId("test-user-1");
+        entity3.setName("test-experiment-2");
+        entity3.setDescription("test experiment 2 description");
+        entity3.setParentEntityId("test-project-1");
+        entity3.setFullText("test experiment 1 3-methyl 1-butanol stampede");
+        sharingServiceClient.createEntity(entity3);
+
+
+        Entity entity4 = new Entity();
+        entity4.setEntityId("test-file-1");
+        entity4.setDomainId(domainId);
+        entity4.setEntityTypeId("FILE");
+        entity4.setOwnerId("test-user-1");
+        entity4.setName("test-file-1");
+        entity4.setDescription("test file 1 description");
+        entity4.setParentEntityId("test-experiment-2");
+        entity4.setFullText("test input file 1 for experiment 2");
+        sharingServiceClient.createEntity(entity4);
+
+        Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").getSharedCount() == 0);
+        sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true);
+        Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").getSharedCount() == 1);
+        ArrayList<SearchCriteria> filters = new ArrayList<>();
+        SearchCriteria searchCriteria = new SearchCriteria();
+        searchCriteria.setSearchField(EntitySearchField.SHARED_COUNT);
+        searchCriteria.setValue("1");
+        searchCriteria.setSearchCondition(SearchCondition.GTE);
+        filters.add(searchCriteria);
+        Assert.assertEquals(1, sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1).size());
+
+
+        sharingServiceClient.revokeEntitySharingFromUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE");
+        Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").getSharedCount() == 0);
+        sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true);
+
+        sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "READ", true);
+        sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "CLONE", false);
+
+        //true
+        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-project-1", "WRITE"));
+        //true
+        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "WRITE"));
+        //true
+        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "WRITE"));
+
+        //false
+        Assert.assertFalse(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "READ"));
+        //true
+        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "READ"));
+
+        //false
+        Assert.assertFalse(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-project-1", "READ"));
+        //true
+        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "READ"));
+        //false
+        Assert.assertFalse(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "WRITE"));
+
+        //true
+        Assert.assertTrue((sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "CLONE")));
+        //false
+        Assert.assertFalse((sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-file-1", "CLONE")));
+
+        filters = new ArrayList<>();
+        searchCriteria = new SearchCriteria();
+        searchCriteria.setSearchCondition(SearchCondition.FULL_TEXT);
+        searchCriteria.setValue("experiment");
+        searchCriteria.setSearchField(EntitySearchField.FULL_TEXT);
+        filters.add(searchCriteria);
+
+        searchCriteria = new SearchCriteria();
+        searchCriteria.setSearchCondition(SearchCondition.EQUAL);
+        searchCriteria.setValue("EXPERIMENT");
+        searchCriteria.setSearchField(EntitySearchField.ENTITY_TYPE_ID);
+        filters.add(searchCriteria);
+
+        searchCriteria = new SearchCriteria();
+        searchCriteria.setSearchCondition(SearchCondition.EQUAL);
+        searchCriteria.setValue("READ");
+        searchCriteria.setSearchField(EntitySearchField.PERMISSION_TYPE_ID);
+        filters.add(searchCriteria);
+
+        Assert.assertTrue(sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1).size() == 1);
+        Entity persistedEntity = sharingServiceClient.searchEntities(
+                domainId, "test-user-2", filters, 0, -1).get(0);
+        Assert.assertEquals(entity3.getName(), persistedEntity.getName());
+        Assert.assertEquals(entity3.getDescription(), persistedEntity.getDescription());
+        Assert.assertEquals(entity3.getFullText(), persistedEntity.getFullText());
+
+        searchCriteria = new SearchCriteria();
+        searchCriteria.setSearchCondition(SearchCondition.NOT);
+        searchCriteria.setValue("test-user-1");
+        searchCriteria.setSearchField(EntitySearchField.OWNER_ID);
+        filters.add(searchCriteria);
+        Assert.assertTrue(sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1).size() == 0);
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/resources/airavata.jks b/custos-sharing-registry-service/sharing-registry-server/src/test/resources/airavata.jks
new file mode 100644
index 0000000..e0e46e2
Binary files /dev/null and b/custos-sharing-registry-service/sharing-registry-server/src/test/resources/airavata.jks differ
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/resources/client_truststore.jks b/custos-sharing-registry-service/sharing-registry-server/src/test/resources/client_truststore.jks
new file mode 100644
index 0000000..4ff588f
Binary files /dev/null and b/custos-sharing-registry-service/sharing-registry-server/src/test/resources/client_truststore.jks differ
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/resources/logback.xml b/custos-sharing-registry-service/sharing-registry-server/src/test/resources/logback.xml
new file mode 100644
index 0000000..88937d3
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-server/src/test/resources/logback.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  ~
+  -->
+<configuration>
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>[%p] %m%n</pattern>
+        </encoder>
+    </appender>
+    <!-- <logger name="org.apache.airavata.sharing.registry" level="DEBUG"/> -->
+    <root level="INFO">
+        <appender-ref ref="CONSOLE"/>
+    </root>
+</configuration>
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/pom.xml b/custos-sharing-registry-service/sharing-registry-stubs/pom.xml
new file mode 100644
index 0000000..01364ad
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-stubs/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>custos-sharing-registry-service</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <relativePath>../pom.xml</relativePath>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-sharing-registry-stubs</artifactId>
+    <packaging>jar</packaging>
+    <name>Sharing Registry Stubs</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>${thrift.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.5.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <!--<plugin>-->
+                <!--<groupId>com.google.code.maven-replacer-plugin</groupId>-->
+                <!--<artifactId>replacer</artifactId>-->
+                <!--<version>${maven.replacer.plugin.version}</version>-->
+                <!--<executions>-->
+                    <!--<execution>-->
+                        <!--<phase>generate-sources</phase>-->
+                        <!--<goals>-->
+                            <!--<goal>replace</goal>-->
+                        <!--</goals>-->
+                    <!--</execution>-->
+                <!--</executions>-->
+                <!--<configuration>-->
+                    <!--<includes>-->
+                        <!--<include>${basedir}/src/main/java/org/apache/airavata/**/*.java</include>-->
+                    <!--</includes>-->
+                    <!--<token>, date = ".*"</token>-->
+                    <!--<value> </value>-->
+                <!--</configuration>-->
+            <!--</plugin>-->
+        </plugins>
+    </build>
+</project>
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/client/SharingRegistryServiceClientFactory.java b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/client/SharingRegistryServiceClientFactory.java
new file mode 100644
index 0000000..dbcb49a
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/client/SharingRegistryServiceClientFactory.java
@@ -0,0 +1,44 @@
+/**
+ *
+ * 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.custos.sharing.registry.client;
+
+import org.apache.custos.sharing.registry.models.SharingRegistryException;
+import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransportException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SharingRegistryServiceClientFactory {
+    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServiceClientFactory.class);
+
+    public static SharingRegistryService.Client createSharingRegistryClient(String serverHost, int serverPort) throws SharingRegistryException {
+        try {
+            TSocket e = new TSocket(serverHost, serverPort);
+            e.open();
+            TBinaryProtocol protocol = new TBinaryProtocol(e);
+            return new SharingRegistryService.Client(protocol);
+        } catch (TTransportException var4) {
+            logger.error("failed to create sharing registry client", var4);
+            throw new SharingRegistryException();
+        }
+    }
+}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Domain.java b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Domain.java
new file mode 100644
index 0000000..d61f613
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Domain.java
@@ -0,0 +1,805 @@
+/**
+ * Autogenerated by Thrift Compiler (0.12.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.sharing.registry.models;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+/**
+ * <p>Domain is the entity that enables multi-tenency in this componenet. Every tenant will be
+ * operating separately it's own silo which is identified by the domain id. In the current implementation domain id
+ * will be same as the domain name</p>
+ * <li>domainId : Will be generated by the server based on the domain name</li>
+ * <li><b>name</b> : A single word name that identifies the domain e.g seagrid, ultrascan</li>
+ * <li>description : A short description for the domain</li>
+ * <li>createdTime : Will be set by the system</li>
+ * <li>updatedTime : Will be set by the system</li>
+ * 
+ */
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-13")
+public class Domain implements org.apache.thrift.TBase<Domain, Domain._Fields>, java.io.Serializable, Cloneable, Comparable<Domain> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Domain");
+
+  private static final org.apache.thrift.protocol.TField DOMAIN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("domainId", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)2);
+  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)3);
+  private static final org.apache.thrift.protocol.TField CREATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createdTime", org.apache.thrift.protocol.TType.I64, (short)4);
+  private static final org.apache.thrift.protocol.TField UPDATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedTime", org.apache.thrift.protocol.TType.I64, (short)5);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new DomainStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new DomainTupleSchemeFactory();
+
+  public @org.apache.thrift.annotation.Nullable String domainId; // optional
+  public @org.apache.thrift.annotation.Nullable String name; // optional
+  public @org.apache.thrift.annotation.Nullable String description; // optional
+  public long createdTime; // optional
+  public long updatedTime; // optional
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    DOMAIN_ID((short)1, "domainId"),
+    NAME((short)2, "name"),
+    DESCRIPTION((short)3, "description"),
+    CREATED_TIME((short)4, "createdTime"),
+    UPDATED_TIME((short)5, "updatedTime");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    @org.apache.thrift.annotation.Nullable
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // DOMAIN_ID
+          return DOMAIN_ID;
+        case 2: // NAME
+          return NAME;
+        case 3: // DESCRIPTION
+          return DESCRIPTION;
+        case 4: // CREATED_TIME
+          return CREATED_TIME;
+        case 5: // UPDATED_TIME
+          return UPDATED_TIME;
+        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.
+     */
+    @org.apache.thrift.annotation.Nullable
+    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
+  private static final int __CREATEDTIME_ISSET_ID = 0;
+  private static final int __UPDATEDTIME_ISSET_ID = 1;
+  private byte __isset_bitfield = 0;
+  private static final _Fields optionals[] = {_Fields.DOMAIN_ID,_Fields.NAME,_Fields.DESCRIPTION,_Fields.CREATED_TIME,_Fields.UPDATED_TIME};
+  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.DOMAIN_ID, new org.apache.thrift.meta_data.FieldMetaData("domainId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        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.CREATED_TIME, new org.apache.thrift.meta_data.FieldMetaData("createdTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.UPDATED_TIME, new org.apache.thrift.meta_data.FieldMetaData("updatedTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Domain.class, metaDataMap);
+  }
+
+  public Domain() {
+    this.domainId = "DO_NOT_SET_AT_CLIENTS_ID";
+
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public Domain(Domain other) {
+    __isset_bitfield = other.__isset_bitfield;
+    if (other.isSetDomainId()) {
+      this.domainId = other.domainId;
+    }
+    if (other.isSetName()) {
+      this.name = other.name;
+    }
+    if (other.isSetDescription()) {
+      this.description = other.description;
+    }
+    this.createdTime = other.createdTime;
+    this.updatedTime = other.updatedTime;
+  }
+
+  public Domain deepCopy() {
+    return new Domain(this);
+  }
+
+  @Override
+  public void clear() {
+    this.domainId = "DO_NOT_SET_AT_CLIENTS_ID";
+
+    this.name = null;
+    this.description = null;
+    setCreatedTimeIsSet(false);
+    this.createdTime = 0;
+    setUpdatedTimeIsSet(false);
+    this.updatedTime = 0;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getDomainId() {
+    return this.domainId;
+  }
+
+  public Domain setDomainId(@org.apache.thrift.annotation.Nullable String domainId) {
+    this.domainId = domainId;
+    return this;
+  }
+
+  public void unsetDomainId() {
+    this.domainId = null;
+  }
+
+  /** Returns true if field domainId is set (has been assigned a value) and false otherwise */
+  public boolean isSetDomainId() {
+    return this.domainId != null;
+  }
+
+  public void setDomainIdIsSet(boolean value) {
+    if (!value) {
+      this.domainId = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getName() {
+    return this.name;
+  }
+
+  public Domain setName(@org.apache.thrift.annotation.Nullable String name) {
+    this.name = name;
+    return this;
+  }
+
+  public void unsetName() {
+    this.name = null;
+  }
+
+  /** Returns true if field name is set (has been assigned a value) and false otherwise */
+  public boolean isSetName() {
+    return this.name != null;
+  }
+
+  public void setNameIsSet(boolean value) {
+    if (!value) {
+      this.name = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getDescription() {
+    return this.description;
+  }
+
+  public Domain setDescription(@org.apache.thrift.annotation.Nullable 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 long getCreatedTime() {
+    return this.createdTime;
+  }
+
+  public Domain setCreatedTime(long createdTime) {
+    this.createdTime = createdTime;
+    setCreatedTimeIsSet(true);
+    return this;
+  }
+
+  public void unsetCreatedTime() {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CREATEDTIME_ISSET_ID);
+  }
+
+  /** Returns true if field createdTime is set (has been assigned a value) and false otherwise */
+  public boolean isSetCreatedTime() {
+    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CREATEDTIME_ISSET_ID);
+  }
+
+  public void setCreatedTimeIsSet(boolean value) {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CREATEDTIME_ISSET_ID, value);
+  }
+
+  public long getUpdatedTime() {
+    return this.updatedTime;
+  }
+
+  public Domain setUpdatedTime(long updatedTime) {
+    this.updatedTime = updatedTime;
+    setUpdatedTimeIsSet(true);
+    return this;
+  }
+
+  public void unsetUpdatedTime() {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID);
+  }
+
+  /** Returns true if field updatedTime is set (has been assigned a value) and false otherwise */
+  public boolean isSetUpdatedTime() {
+    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID);
+  }
+
+  public void setUpdatedTimeIsSet(boolean value) {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID, value);
+  }
+
+  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+    switch (field) {
+    case DOMAIN_ID:
+      if (value == null) {
+        unsetDomainId();
+      } else {
+        setDomainId((String)value);
+      }
+      break;
+
+    case NAME:
+      if (value == null) {
+        unsetName();
+      } else {
+        setName((String)value);
+      }
+      break;
+
+    case DESCRIPTION:
+      if (value == null) {
+        unsetDescription();
+      } else {
+        setDescription((String)value);
+      }
+      break;
+
+    case CREATED_TIME:
+      if (value == null) {
+        unsetCreatedTime();
+      } else {
+        setCreatedTime((Long)value);
+      }
+      break;
+
+    case UPDATED_TIME:
+      if (value == null) {
+        unsetUpdatedTime();
+      } else {
+        setUpdatedTime((Long)value);
+      }
+      break;
+
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case DOMAIN_ID:
+      return getDomainId();
+
+    case NAME:
+      return getName();
+
+    case DESCRIPTION:
+      return getDescription();
+
+    case CREATED_TIME:
+      return getCreatedTime();
+
+    case UPDATED_TIME:
+      return getUpdatedTime();
+
+    }
+    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 DOMAIN_ID:
+      return isSetDomainId();
+    case NAME:
+      return isSetName();
+    case DESCRIPTION:
+      return isSetDescription();
+    case CREATED_TIME:
+      return isSetCreatedTime();
+    case UPDATED_TIME:
+      return isSetUpdatedTime();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof Domain)
+      return this.equals((Domain)that);
+    return false;
+  }
+
+  public boolean equals(Domain that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    boolean this_present_domainId = true && this.isSetDomainId();
+    boolean that_present_domainId = true && that.isSetDomainId();
+    if (this_present_domainId || that_present_domainId) {
+      if (!(this_present_domainId && that_present_domainId))
+        return false;
+      if (!this.domainId.equals(that.domainId))
+        return false;
+    }
+
+    boolean this_present_name = true && this.isSetName();
+    boolean that_present_name = true && that.isSetName();
+    if (this_present_name || that_present_name) {
+      if (!(this_present_name && that_present_name))
+        return false;
+      if (!this.name.equals(that.name))
+        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_createdTime = true && this.isSetCreatedTime();
+    boolean that_present_createdTime = true && that.isSetCreatedTime();
+    if (this_present_createdTime || that_present_createdTime) {
+      if (!(this_present_createdTime && that_present_createdTime))
+        return false;
+      if (this.createdTime != that.createdTime)
+        return false;
+    }
+
+    boolean this_present_updatedTime = true && this.isSetUpdatedTime();
+    boolean that_present_updatedTime = true && that.isSetUpdatedTime();
+    if (this_present_updatedTime || that_present_updatedTime) {
+      if (!(this_present_updatedTime && that_present_updatedTime))
+        return false;
+      if (this.updatedTime != that.updatedTime)
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetDomainId()) ? 131071 : 524287);
+    if (isSetDomainId())
+      hashCode = hashCode * 8191 + domainId.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287);
+    if (isSetName())
+      hashCode = hashCode * 8191 + name.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetDescription()) ? 131071 : 524287);
+    if (isSetDescription())
+      hashCode = hashCode * 8191 + description.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetCreatedTime()) ? 131071 : 524287);
+    if (isSetCreatedTime())
+      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(createdTime);
+
+    hashCode = hashCode * 8191 + ((isSetUpdatedTime()) ? 131071 : 524287);
+    if (isSetUpdatedTime())
+      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(updatedTime);
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(Domain other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetDomainId()).compareTo(other.isSetDomainId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetDomainId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.domainId, other.domainId);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name);
+      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;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetCreatedTime()).compareTo(other.isSetCreatedTime());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetCreatedTime()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createdTime, other.createdTime);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetUpdatedTime()).compareTo(other.isSetUpdatedTime());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetUpdatedTime()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updatedTime, other.updatedTime);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("Domain(");
+    boolean first = true;
+
+    if (isSetDomainId()) {
+      sb.append("domainId:");
+      if (this.domainId == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.domainId);
+      }
+      first = false;
+    }
+    if (isSetName()) {
+      if (!first) sb.append(", ");
+      sb.append("name:");
+      if (this.name == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.name);
+      }
+      first = false;
+    }
+    if (isSetDescription()) {
+      if (!first) sb.append(", ");
+      sb.append("description:");
+      if (this.description == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.description);
+      }
+      first = false;
+    }
+    if (isSetCreatedTime()) {
+      if (!first) sb.append(", ");
+      sb.append("createdTime:");
+      sb.append(this.createdTime);
+      first = false;
+    }
+    if (isSetUpdatedTime()) {
+      if (!first) sb.append(", ");
+      sb.append("updatedTime:");
+      sb.append(this.updatedTime);
+      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 {
+      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+      __isset_bitfield = 0;
+      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 DomainStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public DomainStandardScheme getScheme() {
+      return new DomainStandardScheme();
+    }
+  }
+
+  private static class DomainStandardScheme extends org.apache.thrift.scheme.StandardScheme<Domain> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, Domain 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: // DOMAIN_ID
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.domainId = iprot.readString();
+              struct.setDomainIdIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.name = iprot.readString();
+              struct.setNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 3: // 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 4: // CREATED_TIME
+            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
+              struct.createdTime = iprot.readI64();
+              struct.setCreatedTimeIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 5: // UPDATED_TIME
+            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
+              struct.updatedTime = iprot.readI64();
+              struct.setUpdatedTimeIsSet(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, Domain struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.domainId != null) {
+        if (struct.isSetDomainId()) {
+          oprot.writeFieldBegin(DOMAIN_ID_FIELD_DESC);
+          oprot.writeString(struct.domainId);
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.name != null) {
+        if (struct.isSetName()) {
+          oprot.writeFieldBegin(NAME_FIELD_DESC);
+          oprot.writeString(struct.name);
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.description != null) {
+        if (struct.isSetDescription()) {
+          oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC);
+          oprot.writeString(struct.description);
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.isSetCreatedTime()) {
+        oprot.writeFieldBegin(CREATED_TIME_FIELD_DESC);
+        oprot.writeI64(struct.createdTime);
+        oprot.writeFieldEnd();
+      }
+      if (struct.isSetUpdatedTime()) {
+        oprot.writeFieldBegin(UPDATED_TIME_FIELD_DESC);
+        oprot.writeI64(struct.updatedTime);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class DomainTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public DomainTupleScheme getScheme() {
+      return new DomainTupleScheme();
+    }
+  }
+
+  private static class DomainTupleScheme extends org.apache.thrift.scheme.TupleScheme<Domain> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, Domain struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      java.util.BitSet optionals = new java.util.BitSet();
+      if (struct.isSetDomainId()) {
+        optionals.set(0);
+      }
+      if (struct.isSetName()) {
+        optionals.set(1);
+      }
+      if (struct.isSetDescription()) {
+        optionals.set(2);
+      }
+      if (struct.isSetCreatedTime()) {
+        optionals.set(3);
+      }
+      if (struct.isSetUpdatedTime()) {
+        optionals.set(4);
+      }
+      oprot.writeBitSet(optionals, 5);
+      if (struct.isSetDomainId()) {
+        oprot.writeString(struct.domainId);
+      }
+      if (struct.isSetName()) {
+        oprot.writeString(struct.name);
+      }
+      if (struct.isSetDescription()) {
+        oprot.writeString(struct.description);
+      }
+      if (struct.isSetCreatedTime()) {
+        oprot.writeI64(struct.createdTime);
+      }
+      if (struct.isSetUpdatedTime()) {
+        oprot.writeI64(struct.updatedTime);
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, Domain struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      java.util.BitSet incoming = iprot.readBitSet(5);
+      if (incoming.get(0)) {
+        struct.domainId = iprot.readString();
+        struct.setDomainIdIsSet(true);
+      }
+      if (incoming.get(1)) {
+        struct.name = iprot.readString();
+        struct.setNameIsSet(true);
+      }
+      if (incoming.get(2)) {
+        struct.description = iprot.readString();
+        struct.setDescriptionIsSet(true);
+      }
+      if (incoming.get(3)) {
+        struct.createdTime = iprot.readI64();
+        struct.setCreatedTimeIsSet(true);
+      }
+      if (incoming.get(4)) {
+        struct.updatedTime = iprot.readI64();
+        struct.setUpdatedTimeIsSet(true);
+      }
+    }
+  }
+
+  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+  }
+}
+
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/DuplicateEntryException.java b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/DuplicateEntryException.java
new file mode 100644
index 0000000..bcbf29a
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/DuplicateEntryException.java
@@ -0,0 +1,377 @@
+/**
+ * Autogenerated by Thrift Compiler (0.12.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.sharing.registry.models;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+/**
+ * This exception is thrown when you try to save a duplicate entity that already exists
+ *   in the database.
+ * 
+ *   message: contains the associated error message
+ * 
+ */
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-13")
+public class DuplicateEntryException extends org.apache.thrift.TException implements org.apache.thrift.TBase<DuplicateEntryException, DuplicateEntryException._Fields>, java.io.Serializable, Cloneable, Comparable<DuplicateEntryException> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("DuplicateEntryException");
+
+  private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new DuplicateEntryExceptionStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new DuplicateEntryExceptionTupleSchemeFactory();
+
+  public @org.apache.thrift.annotation.Nullable String message; // 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 {
+    MESSAGE((short)1, "message");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    @org.apache.thrift.annotation.Nullable
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // MESSAGE
+          return MESSAGE;
+        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.
+     */
+    @org.apache.thrift.annotation.Nullable
+    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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(DuplicateEntryException.class, metaDataMap);
+  }
+
+  public DuplicateEntryException() {
+  }
+
+  public DuplicateEntryException(
+    String message)
+  {
+    this();
+    this.message = message;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public DuplicateEntryException(DuplicateEntryException other) {
+    if (other.isSetMessage()) {
+      this.message = other.message;
+    }
+  }
+
+  public DuplicateEntryException deepCopy() {
+    return new DuplicateEntryException(this);
+  }
+
+  @Override
+  public void clear() {
+    this.message = null;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getMessage() {
+    return this.message;
+  }
+
+  public DuplicateEntryException setMessage(@org.apache.thrift.annotation.Nullable String message) {
+    this.message = message;
+    return this;
+  }
+
+  public void unsetMessage() {
+    this.message = null;
+  }
+
+  /** Returns true if field message is set (has been assigned a value) and false otherwise */
+  public boolean isSetMessage() {
+    return this.message != null;
+  }
+
+  public void setMessageIsSet(boolean value) {
+    if (!value) {
+      this.message = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+    switch (field) {
+    case MESSAGE:
+      if (value == null) {
+        unsetMessage();
+      } else {
+        setMessage((String)value);
+      }
+      break;
+
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case MESSAGE:
+      return getMessage();
+
+    }
+    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 MESSAGE:
+      return isSetMessage();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof DuplicateEntryException)
+      return this.equals((DuplicateEntryException)that);
+    return false;
+  }
+
+  public boolean equals(DuplicateEntryException that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    boolean this_present_message = true && this.isSetMessage();
+    boolean that_present_message = true && that.isSetMessage();
+    if (this_present_message || that_present_message) {
+      if (!(this_present_message && that_present_message))
+        return false;
+      if (!this.message.equals(that.message))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
+    if (isSetMessage())
+      hashCode = hashCode * 8191 + message.hashCode();
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(DuplicateEntryException other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetMessage()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("DuplicateEntryException(");
+    boolean first = true;
+
+    sb.append("message:");
+    if (this.message == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.message);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (message == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' was not present! Struct: " + toString());
+    }
+    // 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 DuplicateEntryExceptionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public DuplicateEntryExceptionStandardScheme getScheme() {
+      return new DuplicateEntryExceptionStandardScheme();
+    }
+  }
+
+  private static class DuplicateEntryExceptionStandardScheme extends org.apache.thrift.scheme.StandardScheme<DuplicateEntryException> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, DuplicateEntryException 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: // MESSAGE
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.message = iprot.readString();
+              struct.setMessageIsSet(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, DuplicateEntryException struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.message != null) {
+        oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
+        oprot.writeString(struct.message);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class DuplicateEntryExceptionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public DuplicateEntryExceptionTupleScheme getScheme() {
+      return new DuplicateEntryExceptionTupleScheme();
+    }
+  }
+
+  private static class DuplicateEntryExceptionTupleScheme extends org.apache.thrift.scheme.TupleScheme<DuplicateEntryException> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, DuplicateEntryException struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      oprot.writeString(struct.message);
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, DuplicateEntryException struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      struct.message = iprot.readString();
+      struct.setMessageIsSet(true);
+    }
+  }
+
+  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+  }
+}
+
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Entity.java b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Entity.java
new file mode 100644
index 0000000..613ea5d
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Entity.java
@@ -0,0 +1,1663 @@
+/**
+ * Autogenerated by Thrift Compiler (0.12.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.sharing.registry.models;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+/**
+ * <p>Entity object which is used to register an entity in the system.</p>
+ * <li><b>entityId</b> : Entity id provided by the client</li>
+ * <li><b>domainId</b> : Domain id</li>
+ * <li><b>entityTypeId</b> : Entity type id</li>
+ * <li><b>ownerId</b> : Owner id</li>
+ * <li>parentEntityId : Parent entity id</li>
+ * <li><b>name</b> : Name</li>
+ * <li>description : Short description for the entity</li>
+ * <li>binaryData : Any information stored in binary format</li>
+ * <li>fullText : A string which will be considered for full text search</li>
+ * <li><b>originalEntityCreationTime</b> : When registering old records what is the original entity creation time. If not
+ * set will be default to current time</li>
+ * <li>createdTime : Will be set by the system</li>
+ * <li>updatedTime : Will be set by the system</li>
+ * 
+ */
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-13")
+public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, java.io.Serializable, Cloneable, Comparable<Entity> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Entity");
+
+  private static final org.apache.thrift.protocol.TField ENTITY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("entityId", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField DOMAIN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("domainId", org.apache.thrift.protocol.TType.STRING, (short)2);
+  private static final org.apache.thrift.protocol.TField ENTITY_TYPE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("entityTypeId", org.apache.thrift.protocol.TType.STRING, (short)3);
+  private static final org.apache.thrift.protocol.TField OWNER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("ownerId", org.apache.thrift.protocol.TType.STRING, (short)4);
+  private static final org.apache.thrift.protocol.TField PARENT_ENTITY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("parentEntityId", org.apache.thrift.protocol.TType.STRING, (short)5);
+  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)6);
+  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)7);
+  private static final org.apache.thrift.protocol.TField BINARY_DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("binaryData", org.apache.thrift.protocol.TType.STRING, (short)8);
+  private static final org.apache.thrift.protocol.TField FULL_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("fullText", org.apache.thrift.protocol.TType.STRING, (short)9);
+  private static final org.apache.thrift.protocol.TField SHARED_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("sharedCount", org.apache.thrift.protocol.TType.I64, (short)10);
+  private static final org.apache.thrift.protocol.TField ORIGINAL_ENTITY_CREATION_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("originalEntityCreationTime", org.apache.thrift.protocol.TType.I64, (short)11);
+  private static final org.apache.thrift.protocol.TField CREATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createdTime", org.apache.thrift.protocol.TType.I64, (short)12);
+  private static final org.apache.thrift.protocol.TField UPDATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedTime", org.apache.thrift.protocol.TType.I64, (short)13);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new EntityStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new EntityTupleSchemeFactory();
+
+  public @org.apache.thrift.annotation.Nullable String entityId; // optional
+  public @org.apache.thrift.annotation.Nullable String domainId; // optional
+  public @org.apache.thrift.annotation.Nullable String entityTypeId; // optional
+  public @org.apache.thrift.annotation.Nullable String ownerId; // optional
+  public @org.apache.thrift.annotation.Nullable String parentEntityId; // optional
+  public @org.apache.thrift.annotation.Nullable String name; // optional
+  public @org.apache.thrift.annotation.Nullable String description; // optional
+  public @org.apache.thrift.annotation.Nullable java.nio.ByteBuffer binaryData; // optional
+  public @org.apache.thrift.annotation.Nullable String fullText; // optional
+  public long sharedCount; // optional
+  public long originalEntityCreationTime; // optional
+  public long createdTime; // optional
+  public long updatedTime; // optional
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    ENTITY_ID((short)1, "entityId"),
+    DOMAIN_ID((short)2, "domainId"),
+    ENTITY_TYPE_ID((short)3, "entityTypeId"),
+    OWNER_ID((short)4, "ownerId"),
+    PARENT_ENTITY_ID((short)5, "parentEntityId"),
+    NAME((short)6, "name"),
+    DESCRIPTION((short)7, "description"),
+    BINARY_DATA((short)8, "binaryData"),
+    FULL_TEXT((short)9, "fullText"),
+    SHARED_COUNT((short)10, "sharedCount"),
+    ORIGINAL_ENTITY_CREATION_TIME((short)11, "originalEntityCreationTime"),
+    CREATED_TIME((short)12, "createdTime"),
+    UPDATED_TIME((short)13, "updatedTime");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    @org.apache.thrift.annotation.Nullable
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // ENTITY_ID
+          return ENTITY_ID;
+        case 2: // DOMAIN_ID
+          return DOMAIN_ID;
+        case 3: // ENTITY_TYPE_ID
+          return ENTITY_TYPE_ID;
+        case 4: // OWNER_ID
+          return OWNER_ID;
+        case 5: // PARENT_ENTITY_ID
+          return PARENT_ENTITY_ID;
+        case 6: // NAME
+          return NAME;
+        case 7: // DESCRIPTION
+          return DESCRIPTION;
+        case 8: // BINARY_DATA
+          return BINARY_DATA;
+        case 9: // FULL_TEXT
+          return FULL_TEXT;
+        case 10: // SHARED_COUNT
+          return SHARED_COUNT;
+        case 11: // ORIGINAL_ENTITY_CREATION_TIME
+          return ORIGINAL_ENTITY_CREATION_TIME;
+        case 12: // CREATED_TIME
+          return CREATED_TIME;
+        case 13: // UPDATED_TIME
+          return UPDATED_TIME;
+        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.
+     */
+    @org.apache.thrift.annotation.Nullable
+    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
+  private static final int __SHAREDCOUNT_ISSET_ID = 0;
+  private static final int __ORIGINALENTITYCREATIONTIME_ISSET_ID = 1;
+  private static final int __CREATEDTIME_ISSET_ID = 2;
+  private static final int __UPDATEDTIME_ISSET_ID = 3;
+  private byte __isset_bitfield = 0;
+  private static final _Fields optionals[] = {_Fields.ENTITY_ID,_Fields.DOMAIN_ID,_Fields.ENTITY_TYPE_ID,_Fields.OWNER_ID,_Fields.PARENT_ENTITY_ID,_Fields.NAME,_Fields.DESCRIPTION,_Fields.BINARY_DATA,_Fields.FULL_TEXT,_Fields.SHARED_COUNT,_Fields.ORIGINAL_ENTITY_CREATION_TIME,_Fields.CREATED_TIME,_Fields.UPDATED_TIME};
+  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.ENTITY_ID, new org.apache.thrift.meta_data.FieldMetaData("entityId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.DOMAIN_ID, new org.apache.thrift.meta_data.FieldMetaData("domainId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.ENTITY_TYPE_ID, new org.apache.thrift.meta_data.FieldMetaData("entityTypeId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.OWNER_ID, new org.apache.thrift.meta_data.FieldMetaData("ownerId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.PARENT_ENTITY_ID, new org.apache.thrift.meta_data.FieldMetaData("parentEntityId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        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.BINARY_DATA, new org.apache.thrift.meta_data.FieldMetaData("binaryData", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
+    tmpMap.put(_Fields.FULL_TEXT, new org.apache.thrift.meta_data.FieldMetaData("fullText", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.SHARED_COUNT, new org.apache.thrift.meta_data.FieldMetaData("sharedCount", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.ORIGINAL_ENTITY_CREATION_TIME, new org.apache.thrift.meta_data.FieldMetaData("originalEntityCreationTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.CREATED_TIME, new org.apache.thrift.meta_data.FieldMetaData("createdTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.UPDATED_TIME, new org.apache.thrift.meta_data.FieldMetaData("updatedTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Entity.class, metaDataMap);
+  }
+
+  public Entity() {
+    this.sharedCount = 0L;
+
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public Entity(Entity other) {
+    __isset_bitfield = other.__isset_bitfield;
+    if (other.isSetEntityId()) {
+      this.entityId = other.entityId;
+    }
+    if (other.isSetDomainId()) {
+      this.domainId = other.domainId;
+    }
+    if (other.isSetEntityTypeId()) {
+      this.entityTypeId = other.entityTypeId;
+    }
+    if (other.isSetOwnerId()) {
+      this.ownerId = other.ownerId;
+    }
+    if (other.isSetParentEntityId()) {
+      this.parentEntityId = other.parentEntityId;
+    }
+    if (other.isSetName()) {
+      this.name = other.name;
+    }
+    if (other.isSetDescription()) {
+      this.description = other.description;
+    }
+    if (other.isSetBinaryData()) {
+      this.binaryData = org.apache.thrift.TBaseHelper.copyBinary(other.binaryData);
+    }
+    if (other.isSetFullText()) {
+      this.fullText = other.fullText;
+    }
+    this.sharedCount = other.sharedCount;
+    this.originalEntityCreationTime = other.originalEntityCreationTime;
+    this.createdTime = other.createdTime;
+    this.updatedTime = other.updatedTime;
+  }
+
+  public Entity deepCopy() {
+    return new Entity(this);
+  }
+
+  @Override
+  public void clear() {
+    this.entityId = null;
+    this.domainId = null;
+    this.entityTypeId = null;
+    this.ownerId = null;
+    this.parentEntityId = null;
+    this.name = null;
+    this.description = null;
+    this.binaryData = null;
+    this.fullText = null;
+    this.sharedCount = 0L;
+
+    setOriginalEntityCreationTimeIsSet(false);
+    this.originalEntityCreationTime = 0;
+    setCreatedTimeIsSet(false);
+    this.createdTime = 0;
+    setUpdatedTimeIsSet(false);
+    this.updatedTime = 0;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getEntityId() {
+    return this.entityId;
+  }
+
+  public Entity setEntityId(@org.apache.thrift.annotation.Nullable String entityId) {
+    this.entityId = entityId;
+    return this;
+  }
+
+  public void unsetEntityId() {
+    this.entityId = null;
+  }
+
+  /** Returns true if field entityId is set (has been assigned a value) and false otherwise */
+  public boolean isSetEntityId() {
+    return this.entityId != null;
+  }
+
+  public void setEntityIdIsSet(boolean value) {
+    if (!value) {
+      this.entityId = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getDomainId() {
+    return this.domainId;
+  }
+
+  public Entity setDomainId(@org.apache.thrift.annotation.Nullable String domainId) {
+    this.domainId = domainId;
+    return this;
+  }
+
+  public void unsetDomainId() {
+    this.domainId = null;
+  }
+
+  /** Returns true if field domainId is set (has been assigned a value) and false otherwise */
+  public boolean isSetDomainId() {
+    return this.domainId != null;
+  }
+
+  public void setDomainIdIsSet(boolean value) {
+    if (!value) {
+      this.domainId = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getEntityTypeId() {
+    return this.entityTypeId;
+  }
+
+  public Entity setEntityTypeId(@org.apache.thrift.annotation.Nullable String entityTypeId) {
+    this.entityTypeId = entityTypeId;
+    return this;
+  }
+
+  public void unsetEntityTypeId() {
+    this.entityTypeId = null;
+  }
+
+  /** Returns true if field entityTypeId is set (has been assigned a value) and false otherwise */
+  public boolean isSetEntityTypeId() {
+    return this.entityTypeId != null;
+  }
+
+  public void setEntityTypeIdIsSet(boolean value) {
+    if (!value) {
+      this.entityTypeId = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getOwnerId() {
+    return this.ownerId;
+  }
+
+  public Entity setOwnerId(@org.apache.thrift.annotation.Nullable String ownerId) {
+    this.ownerId = ownerId;
+    return this;
+  }
+
+  public void unsetOwnerId() {
+    this.ownerId = null;
+  }
+
+  /** Returns true if field ownerId is set (has been assigned a value) and false otherwise */
+  public boolean isSetOwnerId() {
+    return this.ownerId != null;
+  }
+
+  public void setOwnerIdIsSet(boolean value) {
+    if (!value) {
+      this.ownerId = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getParentEntityId() {
+    return this.parentEntityId;
+  }
+
+  public Entity setParentEntityId(@org.apache.thrift.annotation.Nullable String parentEntityId) {
+    this.parentEntityId = parentEntityId;
+    return this;
+  }
+
+  public void unsetParentEntityId() {
+    this.parentEntityId = null;
+  }
+
+  /** Returns true if field parentEntityId is set (has been assigned a value) and false otherwise */
+  public boolean isSetParentEntityId() {
+    return this.parentEntityId != null;
+  }
+
+  public void setParentEntityIdIsSet(boolean value) {
+    if (!value) {
+      this.parentEntityId = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getName() {
+    return this.name;
+  }
+
+  public Entity setName(@org.apache.thrift.annotation.Nullable String name) {
+    this.name = name;
+    return this;
+  }
+
+  public void unsetName() {
+    this.name = null;
+  }
+
+  /** Returns true if field name is set (has been assigned a value) and false otherwise */
+  public boolean isSetName() {
+    return this.name != null;
+  }
+
+  public void setNameIsSet(boolean value) {
+    if (!value) {
+      this.name = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getDescription() {
+    return this.description;
+  }
+
+  public Entity setDescription(@org.apache.thrift.annotation.Nullable 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 byte[] getBinaryData() {
+    setBinaryData(org.apache.thrift.TBaseHelper.rightSize(binaryData));
+    return binaryData == null ? null : binaryData.array();
+  }
+
+  public java.nio.ByteBuffer bufferForBinaryData() {
+    return org.apache.thrift.TBaseHelper.copyBinary(binaryData);
+  }
+
+  public Entity setBinaryData(byte[] binaryData) {
+    this.binaryData = binaryData == null ? (java.nio.ByteBuffer)null   : java.nio.ByteBuffer.wrap(binaryData.clone());
+    return this;
+  }
+
+  public Entity setBinaryData(@org.apache.thrift.annotation.Nullable java.nio.ByteBuffer binaryData) {
+    this.binaryData = org.apache.thrift.TBaseHelper.copyBinary(binaryData);
+    return this;
+  }
+
+  public void unsetBinaryData() {
+    this.binaryData = null;
+  }
+
+  /** Returns true if field binaryData is set (has been assigned a value) and false otherwise */
+  public boolean isSetBinaryData() {
+    return this.binaryData != null;
+  }
+
+  public void setBinaryDataIsSet(boolean value) {
+    if (!value) {
+      this.binaryData = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getFullText() {
+    return this.fullText;
+  }
+
+  public Entity setFullText(@org.apache.thrift.annotation.Nullable String fullText) {
+    this.fullText = fullText;
+    return this;
+  }
+
+  public void unsetFullText() {
+    this.fullText = null;
+  }
+
+  /** Returns true if field fullText is set (has been assigned a value) and false otherwise */
+  public boolean isSetFullText() {
+    return this.fullText != null;
+  }
+
+  public void setFullTextIsSet(boolean value) {
+    if (!value) {
+      this.fullText = null;
+    }
+  }
+
+  public long getSharedCount() {
+    return this.sharedCount;
+  }
+
+  public Entity setSharedCount(long sharedCount) {
+    this.sharedCount = sharedCount;
+    setSharedCountIsSet(true);
+    return this;
+  }
+
+  public void unsetSharedCount() {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SHAREDCOUNT_ISSET_ID);
+  }
+
+  /** Returns true if field sharedCount is set (has been assigned a value) and false otherwise */
+  public boolean isSetSharedCount() {
+    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SHAREDCOUNT_ISSET_ID);
+  }
+
+  public void setSharedCountIsSet(boolean value) {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SHAREDCOUNT_ISSET_ID, value);
+  }
+
+  public long getOriginalEntityCreationTime() {
+    return this.originalEntityCreationTime;
+  }
+
+  public Entity setOriginalEntityCreationTime(long originalEntityCreationTime) {
+    this.originalEntityCreationTime = originalEntityCreationTime;
+    setOriginalEntityCreationTimeIsSet(true);
+    return this;
+  }
+
+  public void unsetOriginalEntityCreationTime() {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ORIGINALENTITYCREATIONTIME_ISSET_ID);
+  }
+
+  /** Returns true if field originalEntityCreationTime is set (has been assigned a value) and false otherwise */
+  public boolean isSetOriginalEntityCreationTime() {
+    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ORIGINALENTITYCREATIONTIME_ISSET_ID);
+  }
+
+  public void setOriginalEntityCreationTimeIsSet(boolean value) {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ORIGINALENTITYCREATIONTIME_ISSET_ID, value);
+  }
+
+  public long getCreatedTime() {
+    return this.createdTime;
+  }
+
+  public Entity setCreatedTime(long createdTime) {
+    this.createdTime = createdTime;
+    setCreatedTimeIsSet(true);
+    return this;
+  }
+
+  public void unsetCreatedTime() {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CREATEDTIME_ISSET_ID);
+  }
+
+  /** Returns true if field createdTime is set (has been assigned a value) and false otherwise */
+  public boolean isSetCreatedTime() {
+    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CREATEDTIME_ISSET_ID);
+  }
+
+  public void setCreatedTimeIsSet(boolean value) {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CREATEDTIME_ISSET_ID, value);
+  }
+
+  public long getUpdatedTime() {
+    return this.updatedTime;
+  }
+
+  public Entity setUpdatedTime(long updatedTime) {
+    this.updatedTime = updatedTime;
+    setUpdatedTimeIsSet(true);
+    return this;
+  }
+
+  public void unsetUpdatedTime() {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID);
+  }
+
+  /** Returns true if field updatedTime is set (has been assigned a value) and false otherwise */
+  public boolean isSetUpdatedTime() {
+    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID);
+  }
+
+  public void setUpdatedTimeIsSet(boolean value) {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID, value);
+  }
+
+  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+    switch (field) {
+    case ENTITY_ID:
+      if (value == null) {
+        unsetEntityId();
+      } else {
+        setEntityId((String)value);
+      }
+      break;
+
+    case DOMAIN_ID:
+      if (value == null) {
+        unsetDomainId();
+      } else {
+        setDomainId((String)value);
+      }
+      break;
+
+    case ENTITY_TYPE_ID:
+      if (value == null) {
+        unsetEntityTypeId();
+      } else {
+        setEntityTypeId((String)value);
+      }
+      break;
+
+    case OWNER_ID:
+      if (value == null) {
+        unsetOwnerId();
+      } else {
+        setOwnerId((String)value);
+      }
+      break;
+
+    case PARENT_ENTITY_ID:
+      if (value == null) {
+        unsetParentEntityId();
+      } else {
+        setParentEntityId((String)value);
+      }
+      break;
+
+    case NAME:
+      if (value == null) {
+        unsetName();
+      } else {
+        setName((String)value);
+      }
+      break;
+
+    case DESCRIPTION:
+      if (value == null) {
+        unsetDescription();
+      } else {
+        setDescription((String)value);
+      }
+      break;
+
+    case BINARY_DATA:
+      if (value == null) {
+        unsetBinaryData();
+      } else {
+        if (value instanceof byte[]) {
+          setBinaryData((byte[])value);
+        } else {
+          setBinaryData((java.nio.ByteBuffer)value);
+        }
+      }
+      break;
+
+    case FULL_TEXT:
+      if (value == null) {
+        unsetFullText();
+      } else {
+        setFullText((String)value);
+      }
+      break;
+
+    case SHARED_COUNT:
+      if (value == null) {
+        unsetSharedCount();
+      } else {
+        setSharedCount((Long)value);
+      }
+      break;
+
+    case ORIGINAL_ENTITY_CREATION_TIME:
+      if (value == null) {
+        unsetOriginalEntityCreationTime();
+      } else {
+        setOriginalEntityCreationTime((Long)value);
+      }
+      break;
+
+    case CREATED_TIME:
+      if (value == null) {
+        unsetCreatedTime();
+      } else {
+        setCreatedTime((Long)value);
+      }
+      break;
+
+    case UPDATED_TIME:
+      if (value == null) {
+        unsetUpdatedTime();
+      } else {
+        setUpdatedTime((Long)value);
+      }
+      break;
+
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case ENTITY_ID:
+      return getEntityId();
+
+    case DOMAIN_ID:
+      return getDomainId();
+
+    case ENTITY_TYPE_ID:
+      return getEntityTypeId();
+
+    case OWNER_ID:
+      return getOwnerId();
+
+    case PARENT_ENTITY_ID:
+      return getParentEntityId();
+
+    case NAME:
+      return getName();
+
+    case DESCRIPTION:
+      return getDescription();
+
+    case BINARY_DATA:
+      return getBinaryData();
+
+    case FULL_TEXT:
+      return getFullText();
+
+    case SHARED_COUNT:
+      return getSharedCount();
+
+    case ORIGINAL_ENTITY_CREATION_TIME:
+      return getOriginalEntityCreationTime();
+
+    case CREATED_TIME:
+      return getCreatedTime();
+
+    case UPDATED_TIME:
+      return getUpdatedTime();
+
+    }
+    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 ENTITY_ID:
+      return isSetEntityId();
+    case DOMAIN_ID:
+      return isSetDomainId();
+    case ENTITY_TYPE_ID:
+      return isSetEntityTypeId();
+    case OWNER_ID:
+      return isSetOwnerId();
+    case PARENT_ENTITY_ID:
+      return isSetParentEntityId();
+    case NAME:
+      return isSetName();
+    case DESCRIPTION:
+      return isSetDescription();
+    case BINARY_DATA:
+      return isSetBinaryData();
+    case FULL_TEXT:
+      return isSetFullText();
+    case SHARED_COUNT:
+      return isSetSharedCount();
+    case ORIGINAL_ENTITY_CREATION_TIME:
+      return isSetOriginalEntityCreationTime();
+    case CREATED_TIME:
+      return isSetCreatedTime();
+    case UPDATED_TIME:
+      return isSetUpdatedTime();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof Entity)
+      return this.equals((Entity)that);
+    return false;
+  }
+
+  public boolean equals(Entity that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    boolean this_present_entityId = true && this.isSetEntityId();
+    boolean that_present_entityId = true && that.isSetEntityId();
+    if (this_present_entityId || that_present_entityId) {
+      if (!(this_present_entityId && that_present_entityId))
+        return false;
+      if (!this.entityId.equals(that.entityId))
+        return false;
+    }
+
+    boolean this_present_domainId = true && this.isSetDomainId();
+    boolean that_present_domainId = true && that.isSetDomainId();
+    if (this_present_domainId || that_present_domainId) {
+      if (!(this_present_domainId && that_present_domainId))
+        return false;
+      if (!this.domainId.equals(that.domainId))
+        return false;
+    }
+
+    boolean this_present_entityTypeId = true && this.isSetEntityTypeId();
+    boolean that_present_entityTypeId = true && that.isSetEntityTypeId();
+    if (this_present_entityTypeId || that_present_entityTypeId) {
+      if (!(this_present_entityTypeId && that_present_entityTypeId))
+        return false;
+      if (!this.entityTypeId.equals(that.entityTypeId))
+        return false;
+    }
+
+    boolean this_present_ownerId = true && this.isSetOwnerId();
+    boolean that_present_ownerId = true && that.isSetOwnerId();
+    if (this_present_ownerId || that_present_ownerId) {
+      if (!(this_present_ownerId && that_present_ownerId))
+        return false;
+      if (!this.ownerId.equals(that.ownerId))
+        return false;
+    }
+
+    boolean this_present_parentEntityId = true && this.isSetParentEntityId();
+    boolean that_present_parentEntityId = true && that.isSetParentEntityId();
+    if (this_present_parentEntityId || that_present_parentEntityId) {
+      if (!(this_present_parentEntityId && that_present_parentEntityId))
+        return false;
+      if (!this.parentEntityId.equals(that.parentEntityId))
+        return false;
+    }
+
+    boolean this_present_name = true && this.isSetName();
+    boolean that_present_name = true && that.isSetName();
+    if (this_present_name || that_present_name) {
+      if (!(this_present_name && that_present_name))
+        return false;
+      if (!this.name.equals(that.name))
+        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_binaryData = true && this.isSetBinaryData();
+    boolean that_present_binaryData = true && that.isSetBinaryData();
+    if (this_present_binaryData || that_present_binaryData) {
+      if (!(this_present_binaryData && that_present_binaryData))
+        return false;
+      if (!this.binaryData.equals(that.binaryData))
+        return false;
+    }
+
+    boolean this_present_fullText = true && this.isSetFullText();
+    boolean that_present_fullText = true && that.isSetFullText();
+    if (this_present_fullText || that_present_fullText) {
+      if (!(this_present_fullText && that_present_fullText))
+        return false;
+      if (!this.fullText.equals(that.fullText))
+        return false;
+    }
+
+    boolean this_present_sharedCount = true && this.isSetSharedCount();
+    boolean that_present_sharedCount = true && that.isSetSharedCount();
+    if (this_present_sharedCount || that_present_sharedCount) {
+      if (!(this_present_sharedCount && that_present_sharedCount))
+        return false;
+      if (this.sharedCount != that.sharedCount)
+        return false;
+    }
+
+    boolean this_present_originalEntityCreationTime = true && this.isSetOriginalEntityCreationTime();
+    boolean that_present_originalEntityCreationTime = true && that.isSetOriginalEntityCreationTime();
+    if (this_present_originalEntityCreationTime || that_present_originalEntityCreationTime) {
+      if (!(this_present_originalEntityCreationTime && that_present_originalEntityCreationTime))
+        return false;
+      if (this.originalEntityCreationTime != that.originalEntityCreationTime)
+        return false;
+    }
+
+    boolean this_present_createdTime = true && this.isSetCreatedTime();
+    boolean that_present_createdTime = true && that.isSetCreatedTime();
+    if (this_present_createdTime || that_present_createdTime) {
+      if (!(this_present_createdTime && that_present_createdTime))
+        return false;
+      if (this.createdTime != that.createdTime)
+        return false;
+    }
+
+    boolean this_present_updatedTime = true && this.isSetUpdatedTime();
+    boolean that_present_updatedTime = true && that.isSetUpdatedTime();
+    if (this_present_updatedTime || that_present_updatedTime) {
+      if (!(this_present_updatedTime && that_present_updatedTime))
+        return false;
+      if (this.updatedTime != that.updatedTime)
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetEntityId()) ? 131071 : 524287);
+    if (isSetEntityId())
+      hashCode = hashCode * 8191 + entityId.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetDomainId()) ? 131071 : 524287);
+    if (isSetDomainId())
+      hashCode = hashCode * 8191 + domainId.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetEntityTypeId()) ? 131071 : 524287);
+    if (isSetEntityTypeId())
+      hashCode = hashCode * 8191 + entityTypeId.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetOwnerId()) ? 131071 : 524287);
+    if (isSetOwnerId())
+      hashCode = hashCode * 8191 + ownerId.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetParentEntityId()) ? 131071 : 524287);
+    if (isSetParentEntityId())
+      hashCode = hashCode * 8191 + parentEntityId.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287);
+    if (isSetName())
+      hashCode = hashCode * 8191 + name.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetDescription()) ? 131071 : 524287);
+    if (isSetDescription())
+      hashCode = hashCode * 8191 + description.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetBinaryData()) ? 131071 : 524287);
+    if (isSetBinaryData())
+      hashCode = hashCode * 8191 + binaryData.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetFullText()) ? 131071 : 524287);
+    if (isSetFullText())
+      hashCode = hashCode * 8191 + fullText.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetSharedCount()) ? 131071 : 524287);
+    if (isSetSharedCount())
+      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(sharedCount);
+
+    hashCode = hashCode * 8191 + ((isSetOriginalEntityCreationTime()) ? 131071 : 524287);
+    if (isSetOriginalEntityCreationTime())
+      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(originalEntityCreationTime);
+
+    hashCode = hashCode * 8191 + ((isSetCreatedTime()) ? 131071 : 524287);
+    if (isSetCreatedTime())
+      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(createdTime);
+
+    hashCode = hashCode * 8191 + ((isSetUpdatedTime()) ? 131071 : 524287);
+    if (isSetUpdatedTime())
+      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(updatedTime);
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(Entity other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetEntityId()).compareTo(other.isSetEntityId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetEntityId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.entityId, other.entityId);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetDomainId()).compareTo(other.isSetDomainId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetDomainId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.domainId, other.domainId);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetEntityTypeId()).compareTo(other.isSetEntityTypeId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetEntityTypeId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.entityTypeId, other.entityTypeId);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetOwnerId()).compareTo(other.isSetOwnerId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetOwnerId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ownerId, other.ownerId);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetParentEntityId()).compareTo(other.isSetParentEntityId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetParentEntityId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.parentEntityId, other.parentEntityId);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name);
+      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;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetBinaryData()).compareTo(other.isSetBinaryData());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetBinaryData()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.binaryData, other.binaryData);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetFullText()).compareTo(other.isSetFullText());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetFullText()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fullText, other.fullText);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetSharedCount()).compareTo(other.isSetSharedCount());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetSharedCount()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sharedCount, other.sharedCount);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetOriginalEntityCreationTime()).compareTo(other.isSetOriginalEntityCreationTime());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetOriginalEntityCreationTime()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.originalEntityCreationTime, other.originalEntityCreationTime);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetCreatedTime()).compareTo(other.isSetCreatedTime());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetCreatedTime()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createdTime, other.createdTime);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetUpdatedTime()).compareTo(other.isSetUpdatedTime());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetUpdatedTime()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updatedTime, other.updatedTime);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("Entity(");
+    boolean first = true;
+
+    if (isSetEntityId()) {
+      sb.append("entityId:");
+      if (this.entityId == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.entityId);
+      }
+      first = false;
+    }
+    if (isSetDomainId()) {
+      if (!first) sb.append(", ");
+      sb.append("domainId:");
+      if (this.domainId == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.domainId);
+      }
+      first = false;
+    }
+    if (isSetEntityTypeId()) {
+      if (!first) sb.append(", ");
+      sb.append("entityTypeId:");
+      if (this.entityTypeId == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.entityTypeId);
+      }
+      first = false;
+    }
+    if (isSetOwnerId()) {
+      if (!first) sb.append(", ");
+      sb.append("ownerId:");
+      if (this.ownerId == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ownerId);
+      }
+      first = false;
+    }
+    if (isSetParentEntityId()) {
+      if (!first) sb.append(", ");
+      sb.append("parentEntityId:");
+      if (this.parentEntityId == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.parentEntityId);
+      }
+      first = false;
+    }
+    if (isSetName()) {
+      if (!first) sb.append(", ");
+      sb.append("name:");
+      if (this.name == null) {
+        sb.append("null");
+      } else {
... 79299 lines suppressed ...


[airavata-custos] 33/48: Merge pull request #6 from aarushiibisht/custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a0b64626d1688e6cc40969d712bac9903c4dd2b2
Merge: 7ba18f6 5595257
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Sat Aug 31 13:09:57 2019 -0400

    Merge pull request #6 from aarushiibisht/custos-dev-abisht
    
    Updating the master branch

 .../handler/CustosAuthenticationHandler.java       |   2 +-
 ...ava => AuthenticationServiceClientFactory.java} |   2 +-
 custos-commons/custos-server.properties            |   0
 .../src/main/resources/custos-server.properties    |  10 +-
 .../manager/KeyCloakSecurityManager.java           |   3 +-
 .../main/resources/keystores/client_truststore.jks | Bin 0 -> 963 bytes
 .../user/handler/UserProfileServiceHandler.java    |  10 +-
 .../test/java/TestUserProfileServiceHandler.java   |  36 +++--
 ide-integration/README.md                          |  64 +++++++++
 ide-integration/custos-services/pom.xml            |  15 ++
 .../server/start}/CustosAPIServerStarted.java      |   4 +-
 .../src/main/resources/custos-server.properties    |  10 +-
 .../database_scripts/init/01-databases.sql         |  43 +++---
 .../user-profile-catalog-derby.sql                 |  30 ----
 .../user-profile-catalog-mysql.sql                 |  30 ----
 .../src/main/resources/docker-compose.yml          |   2 +-
 .../main/resources/keycloak/Default-export.json    |   0
 .../main/resources/keycloak/Default-export.json.bk |   0
 .../src/main/resources/keycloak/standalone.xml     |   2 +-
 .../src/main/resources/keystores/custos.jks        | Bin 0 -> 2252 bytes
 .../src/main/resources}/log4j.properties           |   8 +-
 ide-integration/pom.xml                            |  17 +++
 ide-integration/samples/commons/pom.xml            |  15 ++
 .../org/apache/samples/common/SamplesCommon.java   |  60 ++++++++
 .../custos-authentication-service-samples/pom.xml  |  23 +++
 .../sample/CustosAuthenticationServiceSample.java  |  64 +++++++++
 .../src/main/resources/log4j.properties            |  10 +-
 .../samples/custos-profile-service-samples/pom.xml |  22 +++
 .../service/samples/TenantProfileSample.java       |  80 +++++++++++
 .../profile/service/samples/UserProfileSample.java | 160 +++++++++++++++++++++
 .../samples/utils/ProfileServiceClientUtil.java    |  63 ++++++++
 .../src/main/resources/log4j.properties            |  10 +-
 .../resources/profile-client-sample.properties     |  29 ++++
 ide-integration/samples/pom.xml                    |  20 +++
 .../src/main/resources/keystores/airavata.jks      | Bin 2679 -> 0 bytes
 .../src/main/resources/keystores/airavata_sym.jks  | Bin 501 -> 0 bytes
 .../main/resources/keystores/client_truststore.jks | Bin 1027 -> 0 bytes
 37 files changed, 715 insertions(+), 129 deletions(-)


[airavata-custos] 20/48: Merge branch 'custos-dev-abisht' of https://github.com/aarushiibisht/airavata-custos into custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit cf853a8d6feb2488e9e0cad9cae4f16b346a7e00
Merge: bd6952c 6fa92d1
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Aug 13 11:01:32 2019 -0400

    Merge branch 'custos-dev-abisht' of https://github.com/aarushiibisht/airavata-custos into custos-dev-abisht



[airavata-custos] 05/48: added logging

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8f67c2dd18d8a1b8585a6b7b005cbced319a733d
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Jun 25 09:03:05 2019 -0400

    added logging
---
 .../src/main/resources/log4j.properties            | 41 ++++++++++++++++++++++
 pom.xml                                            | 10 ++++++
 2 files changed, 51 insertions(+)

diff --git a/custos-profile-service/profile-service-server/src/main/resources/log4j.properties b/custos-profile-service/profile-service-server/src/main/resources/log4j.properties
new file mode 100644
index 0000000..a625c4f
--- /dev/null
+++ b/custos-profile-service/profile-service-server/src/main/resources/log4j.properties
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+# Set root category priority to INFO and its only appender to CONSOLE.
+log4j.rootCategory=INFO, CONSOLE,LOGFILE
+log4j.rootLogger=INFO, CONSOLE, LOGFILE
+
+# Set the enterprise logger priority to FATAL
+log4j.logger.org.apache.axis2.enterprise=FATAL
+log4j.logger.de.hunsicker.jalopy.io=FATAL
+log4j.logger.httpclient.wire.header=FATAL
+log4j.logger.org.apache.commons.httpclient=FATAL
+log4j.logger.org.apache.zookeeper=FATAL
+         
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n
+
+# LOGFILE is set to be a File appender using a PatternLayout.
+log4j.appender.LOGFILE=org.apache.log4j.FileAppender
+log4j.appender.LOGFILE.File=../../bin/airavata.log
+log4j.appender.LOGFILE.Append=true
+log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
diff --git a/pom.xml b/pom.xml
index d42d29e..7bcdf03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,5 +51,15 @@
             <artifactId>mariadb-java-client</artifactId>
             <version>2.0.2</version>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>${org.slf4j.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
     </dependencies>
 </project>
\ No newline at end of file


[airavata-custos] 17/48: code refactoring

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6fa92d10cbbd31ca34636bd609e120a9351757bd
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Aug 12 12:27:48 2019 -0400

    code refactoring
---
 .../authentication/service/AuthenticationServiceClient.java  |  2 +-
 .../org/apache/custos/commons/utils/ApplicationSettings.java | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
index 7ef7cf4..4fc0444 100644
--- a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
+++ b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
@@ -8,7 +8,7 @@ import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 
-    public class AuthenticationServiceClient {
+public class AuthenticationServiceClient {
 
     public static CustosAuthenticationService.Client createAuthenticationServiceClient(String serverHost, int serverPort)  throws CustosAuthenticationServiceException {
         try {
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
index e494120..fdcdf97 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
@@ -14,7 +14,7 @@ import java.util.*;
 import java.util.regex.Pattern;
 
 public class ApplicationSettings {
-    //private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
+    private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
     protected static ApplicationSettings INSTANCE;
     private Exception propertyLoadException;
     public static final String SERVER_PROPERTIES="custos-server.properties";
@@ -31,11 +31,11 @@ public class ApplicationSettings {
         URL url = getPropertyFileURL();
         try {
             properties.load(url.openStream());
-            //logger.info("Settings loaded from "+url.toString());
+            logger.info("Settings loaded from "+url.toString());
             URL[] externalSettingsFileURLs = getExternalSettingsFileURLs();
             for (URL externalSettings : externalSettingsFileURLs) {
                 mergeSettingsImpl(externalSettings.openStream());
-                //logger.info("External settings merged from "+url.toString());
+                logger.info("External settings merged from "+url.toString());
             }
         } catch (Exception e) {
             propertyLoadException=e;
@@ -54,7 +54,7 @@ public class ApplicationSettings {
             for (String externalSettingFile : externalSettingFiles) {
                 URL externalSettingFileURL = ApplicationSettings.loadFile(externalSettingFile);
                 if (externalSettingFileURL==null){
-                    //logger.warn("Could not file external settings file "+externalSettingFile);
+                    logger.warn("Could not file external settings file "+externalSettingFile);
                 }else{
                     externalSettingsFileURLs.add(externalSettingFileURL);
                 }
@@ -81,7 +81,7 @@ public class ApplicationSettings {
                     return asfile.toURI().toURL();
                 }
             } catch (MalformedURLException e) {
-                //logger.error("Error parsing the file from custos.config.dir", custosConfigDir);
+                logger.error("Error parsing the file from custos.config.dir", custosConfigDir);
             }
         }
 
@@ -114,7 +114,7 @@ public class ApplicationSettings {
                 throw new ApplicationSettingsException(url.getPath(), e);
             }
         }else{
-            //logger.warn("Properties cannot be updated to location "+url.toString());
+            logger.warn("Properties cannot be updated to location "+url.toString());
         }
     }
     private String getSettingImpl(String key, String defaultValue){


[airavata-custos] 27/48: Added user profile service unit test cases

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7ba18f6cd021652c4640e978c7b09715dc09f73d
Merge: c9ca887 20e5010
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Mon Aug 19 21:30:40 2019 -0400

    Added user profile service unit test cases
    
    Added test cases, refactored delete handler of user profile, added configuration files

 .../{cpi => }/CustosAuthenticationService.java     |  238 +---
 .../cpi/CustosAuthenticationService.java           |  236 +---
 .../CustosAuthenticationServiceException.java      |    2 +-
 .../handler/CustosAuthenticationHandler.java       |    4 +-
 .../src/main/resources/custos-server.properties    |    3 +-
 custos-connectors/pom.xml                          |    5 +
 .../manager/CustosSecurityManager.java             |    2 +-
 .../manager/KeyCloakSecurityManager.java           |   27 +-
 .../services/core/TenantManagementInterface.java   |   10 +
 .../core/TenantManagementKeycloakImpl.java         |   30 +
 .../iam/admin/services/cpi/IamAdminServices.java   | 1255 ++++++++++++++++++--
 .../services/handler/IamAdminServicesHandler.java  |   34 +-
 .../repositories}/TenantProfileRepository.java     |   19 +-
 .../repositories/UserProfileRepository.java        |    3 +-
 .../src/main/resources/META-INF/persistence.xml    |    1 -
 .../profile/tenant/client/TenantProfileClient.java |   26 +
 .../profile/tenant/cpi/TenantProfileService.java   | 1109 ++++++++++++++++-
 .../handler/TenantProfileServiceHandler.java       |   19 +-
 .../user-profile-service/pom.xml                   |   14 +
 .../profile/user/client/UserProfileClient.java     |    4 +
 .../profile/user/cpi/UserProfileService.java       |  470 +-------
 .../user/handler/UserProfileServiceHandler.java    |   32 +-
 .../test/java/TestUserProfileServiceHandler.java   |  110 ++
 .../src/main/resources/custos-server.properties    |    3 +-
 .../src/main/resources/docker-compose.yml          |    2 +-
 pom.xml                                            |    2 +
 .../authentication-service-cpi.thrift              |    2 +-
 .../iam-admin-services-cpi.thrift                  |    6 +-
 .../profile-tenant/profile-tenant-cpi.thrift       |    4 +
 .../profile-user/profile-user-cpi.thrift           |    8 +-
 30 files changed, 2663 insertions(+), 1017 deletions(-)


[airavata-custos] 21/48: Merge branch 'custos-dev-abisht' of https://github.com/aarushiibisht/airavata-custos into custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b5260d910489ee5d5d1361d4fdf3a34446b55a59
Merge: bd6952c 6fa92d1
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Aug 13 11:01:32 2019 -0400

    Merge branch 'custos-dev-abisht' of https://github.com/aarushiibisht/airavata-custos into custos-dev-abisht

 pom.xml | 1 -
 1 file changed, 1 deletion(-)


[airavata-custos] 38/48: Merge pull request #8 from aarushiibisht/custos_sharing_registry_changes

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0a94161b8162cd8f4e53cbf71fb54fe9b7d3f76d
Merge: b211e6d 7534acb
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Mon Sep 2 19:48:09 2019 -0400

    Merge pull request #8 from aarushiibisht/custos_sharing_registry_changes
    
    Custos sharing registry changes

 custos-commons/pom.xml                             |   6 +
 .../exceptions/ServiceConnectionException.java     |  11 +
 .../custos/commons/utils/ServiceRequest.java       |  36 -
 .../custos/commons/utils/ServiceRequestClient.java | 101 +++
 .../src/main/resources/custos-server.properties    |  10 +-
 .../group-profile-core/pom.xml                     |  23 +
 .../service/core/service/GroupProfileService.java  | 730 ++++++++++-----------
 custos-profile-service/pom.xml                     |   1 +
 custos-sharing-registry-service/pom.xml            |   5 +-
 .../sharing-service-api/pom.xml                    |   6 +
 .../custos/sharing/service/api/AppConfig.java      |  15 -
 .../custos/sharing/service/api/Application.java    |   2 +-
 .../api/constants/SharingRegistryEndpoints.java    |  88 ++-
 .../service/api/controllers/AccessController.java  |  31 +-
 .../service/api/controllers/DomainsController.java |  43 +-
 .../service/api/controllers/EntityController.java  |  49 +-
 .../api/controllers/EntityTypeController.java      |  37 +-
 .../service/api/controllers/GroupController.java   |  85 ++-
 .../api/controllers/PermissionTypeController.java  |  38 +-
 .../service/api/controllers/UsersController.java   |  36 +-
 .../src/main/resources/application.properties      |   2 +
 .../sharing-service-core/pom.xml                   |  39 +-
 .../service/core/db/entities/DomainEntity.java     |   1 -
 .../core/db/repositories/EntityRepository.java     |   2 +-
 .../sharing/service/core/db/utils/JPAUtils.java    |   2 +-
 .../custos/sharing/service/core/models/Domain.java |  21 +-
 .../custos/sharing/service/core/models/Entity.java |  39 +-
 .../sharing/service/core/models/EntityType.java    |  23 +-
 .../service/core/models/GroupMembership.java       |  12 +-
 .../service/core/models/PermissionType.java        |  21 +-
 .../sharing/service/core/models/Sharing.java       |  12 +-
 .../custos/sharing/service/core/models/User.java   |  33 +-
 .../sharing/service/core/models/UserGroup.java     |  30 +-
 .../core/service/SharingRegistryService.java       |  42 +-
 .../src/main/resources/META-INF/persistence.xml    |  16 +
 .../database_scripts/sharing-registry-derby.sql    | 147 +++++
 .../database_scripts/sharing-registry-mysql.sql    | 146 +++++
 .../database_scripts/init/01-databases.sql         | 187 +++---
 .../database_scripts/sharing-registry-mysql.sql    | 146 +++++
 ide-integration/pom.xml                            |   8 +-
 .../custos-authentication-service-samples/pom.xml  |   2 +-
 .../samples/custos-profile-service-samples/pom.xml |   2 +-
 pom.xml                                            |   5 +
 .../sharing-service/sharing-cpi/sharing_cpi.thrift | 274 --------
 .../sharing-models/sharing_models.thrift           | 303 ---------
 45 files changed, 1520 insertions(+), 1348 deletions(-)


[airavata-custos] 44/48: group profile service changes should go in a different commit

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 409ac825255c55bedb3bdf795e3ec39c968eb716
Merge: 5fe0bee 1b588e9
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Mon Sep 2 21:26:07 2019 -0400

    group profile service changes should go in a different commit
    
    group profile service changes should go in a different commit

 .../group-profile-api/pom.xml                      |  21 --
 .../group/profile/service/api/Application.java     |  28 --
 .../api/controllers/GroupServiceController.java    |  82 -----
 .../group-profile-core/pom.xml                     |  45 ---
 .../exceptions/GroupManagerServiceException.java   |  16 -
 .../profile/service/core/models/GroupModel.java    |  73 ----
 .../service/core/service/GroupProfileService.java  | 370 ---------------------
 .../group-profile-service/pom.xml                  |  20 --
 custos-profile-service/pom.xml                     |   1 -
 9 files changed, 656 deletions(-)


[airavata-custos] 15/48: Merge pull request #2 from aarushiibisht/custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 611cb4ad57f183425e626c02cf9ff71983f5730d
Merge: 1f8697e 21e80c7
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Sat Aug 10 12:24:05 2019 -0400

    Merge pull request #2 from aarushiibisht/custos-dev-abisht
    
    Added user, tenant, iamadmin profile service

 custos-client/pom.xml                              |    16 +-
 .../service/AuthenticationServiceClient.java       |     2 +-
 .../service/CustosProfileServiceClientFactory.java |    77 +
 .../custos/commons/utils/ApplicationSettings.java  |    21 +-
 .../apache/custos/commons/utils/DBInitConfig.java  |    33 +
 .../apache/custos/commons/utils/DBInitializer.java |    71 +
 .../org/apache/custos/commons/utils/DBUtil.java    |   306 +
 .../custos/commons/utils/DatabaseCreator.java      |   378 +
 .../apache/custos/commons/utils/JDBCConfig.java    |    29 +
 .../org/apache/custos/commons/utils/JPAUtils.java  |    67 +
 .../custos/commons/utils/ServerSettings.java       |    36 +-
 custos-connectors/pom.xml                          |    48 +-
 .../manager/KeyCloakSecurityManager.java           |     2 -
 .../iam-admin-services}/pom.xml                    |    13 +-
 .../client/CustosIamAdminServiceClient.java        |    48 +
 .../services/core/TenantManagementInterface.java   |   206 +
 .../core/TenantManagementKeycloakImpl.java         |   815 +
 .../iam/admin/services/cpi/IamAdminServices.java   | 17956 +++++++++++++++++++
 .../cpi/exception/IamAdminServicesException.java   |   381 +
 .../cpi/iam_admin_services_cpiConstants.java       |    16 +
 .../services/handler/IamAdminServicesHandler.java  |   296 +
 custos-profile-service/pom.xml                     |    26 +
 .../profile-service-commons/pom.xml                |   124 +
 .../commons/repositories/AbstractRepository.java   |   124 +
 .../commons/tenant/entities/GatewayEntity.java     |   285 +
 .../user/entities/CustomizedDashboardEntity.java   |   325 +
 .../user/entities/NSFDemographicsEntity.java       |   108 +
 .../commons/user/entities/UserProfileEntity.java   |   345 +
 .../custos/profile/commons/utils/Committer.java    |    27 +
 .../custos/profile/commons/utils/JPAConstants.java |    34 +
 .../custos/profile/commons/utils/JPAUtils.java     |    53 +
 .../commons/utils/ObjectMapperSingleton.java       |    39 +
 .../commons/utils/ProfileServiceJDBCConfig.java    |    51 +
 .../profile/commons/utils/QueryConstants.java      |    36 +
 .../apache/custos/profile/commons/utils/Utils.java |   122 +
 .../src/main/resources/META-INF/persistence.xml    |    36 +
 .../profile-service-model/pom.xml                  |    15 +
 .../profile/model/tenant/PasswordCredential.java   |   996 +
 .../apache/custos/profile/model/tenant/Tenant.java |  1543 ++
 .../profile/model/tenant/TenantApprovalStatus.java |    78 +
 .../custos/profile/model/tenant/TenantConfig.java  |   699 +
 .../profile/model/tenant/TenantPreferences.java    |   594 +
 .../custos/profile/model/user/CustomDashboard.java |  2912 +++
 .../custos/profile/model/user/NSFDemographics.java |  1085 ++
 .../apache/custos/profile/model/user/Status.java   |    96 +
 .../custos/profile/model/user/USCitizenship.java   |    67 +
 .../custos/profile/model/user/UserProfile.java     |  3221 ++++
 .../custos/profile/model/user/disability.java      |    66 +
 .../custos/profile/model/user/ethnicity.java       |    65 +
 .../org/apache/custos/profile/model/user/race.java |    84 +
 .../model/user/user_profile_modelConstants.java    |    31 +
 .../custos/profile/model/workspace/Gateway.java    |  2383 +++
 .../model/workspace/GatewayApprovalStatus.java     |    78 +
 .../profile-service-server}/pom.xml                |    20 +-
 .../profile/server/ProfileServiceServer.java       |   197 +
 .../src/main/resources/log4j.properties            |    34 +
 .../tenant-profile-service}/pom.xml                |    20 +-
 .../tenant/core/TenantProfileRepository.java       |   104 +
 .../profile/tenant/cpi/TenantProfileService.java   |  9934 ++++++++++
 .../exception/TenantProfileServiceException.java   |   370 +
 .../tenant/cpi/profile_tenant_cpiConstants.java    |    16 +
 .../handler/TenantProfileServiceHandler.java       |   193 +
 .../user-profile-service}/pom.xml                  |    30 +-
 .../exceptions/UserProfileRegistryException.java   |    28 +
 .../core/repositories/UserProfileRepository.java   |   129 +
 .../core/utils/UserProfileCatalogDBInitConfig.java |    42 +
 .../core/utils/UserProfileCatalogJDBCConfig.java   |    52 +
 .../profile/user/cpi/UserProfileService.java       |  9611 ++++++++++
 .../cpi/exception/UserProfileServiceException.java |   370 +
 .../user/cpi/profile_user_cpiConstants.java        |    16 +
 .../user/handler/UserProfileServiceHandler.java    |   239 +
 ide-integration/log4j.properties                   |    34 +
 ide-integration/pom.xml                            |    10 +
 .../src/main/java/CustosAPIServerStarted.java      |     6 +
 .../src/main/resources/custos-server.properties    |    18 +
 .../database_scripts/init/01-databases.sql         |   355 +
 .../user-profile-catalog-derby.sql                 |   163 +
 .../user-profile-catalog-mysql.sql                 |   163 +
 .../src/main/resources/docker-compose.yml          |    14 +-
 .../src/main/resources/keystores/airavata.jks      |   Bin 0 -> 2679 bytes
 .../src/main/resources/keystores/airavata_sym.jks  |   Bin 0 -> 501 bytes
 .../main/resources/keystores/client_truststore.jks |   Bin 0 -> 1027 bytes
 log4j.properties                                   |    34 +
 pom.xml                                            |    38 +-
 .../tenant_profile_model.thrift                    |    73 +
 .../user_profile_model.thrift                      |   229 +
 .../workspace_model.thrift                         |    57 +
 .../iam-admin-services-cpi.thrift                  |   118 +
 .../iam_admin_services_cpi_errors.thrift           |    33 +
 .../profile-service/profile-service-cpi.thrift     |    29 +
 .../profile-tenant/profile-tenant-cpi.thrift       |    75 +
 .../profile_tenant_cpi_errors.thrift               |    33 +
 .../profile-user/profile-user-cpi.thrift           |    83 +
 .../profile-user/profile_user_cpi_errors.thrift    |    33 +
 94 files changed, 59477 insertions(+), 91 deletions(-)


[airavata-custos] 13/48: Merge pull request #1 from aarushiibisht/custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1f8697ef5cf18efc1971dcb479789e5779a8e5b5
Merge: 3802acd 37a1821
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Tue Jul 9 11:09:19 2019 -0400

    Merge pull request #1 from aarushiibisht/custos-dev-abisht
    
    Added authentication server, client and other common utilities

 .gitignore                                         |   39 +
 custos-authentication/pom.xml                      |   29 +
 .../cpi/CustosAuthenticationService.java           | 3408 ++++++++++++++++++++
 .../CustosAuthenticationServiceException.java      |  370 +++
 .../handler/CustosAuthenticationHandler.java       |   54 +
 .../server/CustosAuthenticationServer.java         |  137 +
 custos-client/pom.xml                              |   33 +
 .../service/AuthenticationServiceClient.java       |   23 +
 custos-commons/custos-server.properties            |    0
 custos-commons/pom.xml                             |   37 +
 .../exceptions/ApplicationSettingsException.java   |   14 +
 .../custos/commons/exceptions/CustosException.java |   35 +
 .../exceptions/CustosSecurityException.java        |   39 +
 .../custos/commons/model/security/AuthzToken.java  |  541 ++++
 .../custos/commons/model/security/UserInfo.java    |  875 +++++
 .../custos/commons/utils/ApplicationSettings.java  |  171 +
 .../org/apache/custos/commons/utils/Constants.java |   39 +
 .../apache/custos/commons/utils/CustosUtils.java   |   45 +
 .../org/apache/custos/commons/utils/IServer.java   |   49 +
 .../commons/utils/KeyStorePasswordCallback.java    |   69 +
 .../apache/custos/commons/utils/SecurityUtil.java  |  192 ++
 .../custos/commons/utils/ServerSettings.java       |   64 +
 .../apache/custos/commons/utils/StringUtil.java    |   43 +
 .../apache/custos/commons/utils/ThriftUtils.java   |   34 +
 custos-connectors/pom.xml                          |   41 +
 .../authzcache/AuthzCache.java                     |   61 +
 .../authzcache/AuthzCacheEntry.java                |   63 +
 .../authzcache/AuthzCacheIndex.java                |   90 +
 .../authzcache/AuthzCacheManager.java              |   80 +
 .../authzcache/AuthzCacheManagerFactory.java       |   60 +
 .../authzcache/AuthzCachedStatus.java              |   34 +
 .../authzcache/DefaultAuthzCacheManager.java       |  106 +
 .../manager/CustosSecurityManager.java             |   60 +
 .../manager/IdentityContext.java                   |   45 +
 .../manager/KeyCloakSecurityManager.java           |  242 ++
 .../manager/SecurityManagerFactory.java            |   60 +
 .../utils/TrustStoreManager.java                   |  100 +
 ide-integration/pom.xml                            |   29 +
 .../src/main/java/CustosAPIServerStarted.java      |    8 +
 .../src/main/resources/custos-server.properties    |   46 +
 .../src/main/resources/docker-compose.yml          |   15 +
 .../main/resources/keycloak/Default-export.json    | 1508 +++++++++
 .../main/resources/keycloak/Default-export.json.bk | 1507 +++++++++
 .../src/main/resources/keycloak/standalone.xml     |  521 +++
 pom.xml                                            |   67 +
 .../authentication-service-cpi.thrift              |   14 +
 .../authentication_service_cpi_errors.thrift       |   27 +
 .../authentication-service/security_model.thrift   |   15 +
 .../authentication-service/userInfo_model.thrift   |   33 +
 49 files changed, 11172 insertions(+)


[airavata-custos] 10/48: added custos authentication server

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d71d2010a4a80129a9d7400550e3461e33328a62
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Jul 8 18:37:09 2019 -0400

    added custos authentication server
---
 .gitignore                                         |     2 +-
 .../CustosAuthenticationService.java               |  3198 ---
 .../cpi/CustosAuthenticationService.java           |   556 +-
 .../handler/CustosAuthenticationHandler.java       |    11 +-
 .../service/AuthenticationServiceClient.java       |     2 +-
 .../service/CustosProfileServiceClientFactory.java |    89 -
 .../model/error/AuthenticationException.java       |   385 -
 .../model/error/AuthorizationException.java        |   385 -
 .../custos/commons/utils/ApplicationSettings.java  |    22 -
 .../org/apache/custos/commons/utils/Constants.java |     4 -
 .../apache/custos/commons/utils/DBInitConfig.java  |    33 -
 .../apache/custos/commons/utils/DBInitializer.java |    71 -
 .../org/apache/custos/commons/utils/DBUtil.java    |   307 -
 .../custos/commons/utils/DatabaseCreator.java      |   378 -
 .../apache/custos/commons/utils/JDBCConfig.java    |    29 -
 .../org/apache/custos/commons/utils/JPAUtils.java  |    67 -
 .../custos/commons/utils/ServerSettings.java       |    24 +-
 .../interceptor/SecurityCheck.java                 |    36 -
 .../interceptor/SecurityInterceptor.java           |    82 -
 .../interceptor/SecurityModule.java                |    42 -
 .../manager/CustosSecurityManager.java             |     2 +-
 .../manager/KeyCloakSecurityManager.java           |   197 +-
 .../iam-admin-services-core/pom.xml                |    89 -
 .../core/impl/TenantManagementKeycloakImpl.java    |   821 -
 .../core/interfaces/TenantManagementInterface.java |   206 -
 .../admin/services/core/tests/SetupNewGateway.java |   141 -
 custos-profile-service/pom.xml                     |    24 -
 .../profile-service-commons/pom.xml                |   124 -
 .../commons/repositories/AbstractRepository.java   |   124 -
 .../commons/tenant/entities/GatewayEntity.java     |   285 -
 .../user/entities/CustomizedDashboardEntity.java   |   325 -
 .../user/entities/NSFDemographicsEntity.java       |   108 -
 .../commons/user/entities/UserProfileEntity.java   |   345 -
 .../custos/profile/commons/utils/Committer.java    |    27 -
 .../custos/profile/commons/utils/JPAConstants.java |    34 -
 .../custos/profile/commons/utils/JPAUtils.java     |    53 -
 .../commons/utils/ObjectMapperSingleton.java       |    39 -
 .../commons/utils/ProfileServiceJDBCConfig.java    |    51 -
 .../profile/commons/utils/QueryConstants.java      |    36 -
 .../apache/custos/profile/commons/utils/Utils.java |   122 -
 .../src/main/resources/META-INF/persistence.xml    |    36 -
 .../profile-service-model/pom.xml                  |    14 -
 .../profile/model/tenant/PasswordCredential.java   |   996 -
 .../apache/custos/profile/model/tenant/Tenant.java |  1543 --
 .../profile/model/tenant/TenantApprovalStatus.java |    78 -
 .../custos/profile/model/tenant/TenantConfig.java  |   699 -
 .../profile/model/tenant/TenantPreferences.java    |   594 -
 .../custos/profile/model/user/CustomDashboard.java |  2912 ---
 .../custos/profile/model/user/NSFDemographics.java |  1085 -
 .../apache/custos/profile/model/user/Status.java   |    96 -
 .../custos/profile/model/user/USCitizenship.java   |    67 -
 .../custos/profile/model/user/UserProfile.java     |  3221 ---
 .../custos/profile/model/user/disability.java      |    66 -
 .../custos/profile/model/user/ethnicity.java       |    65 -
 .../org/apache/custos/profile/model/user/race.java |    84 -
 .../model/user/user_profile_modelConstants.java    |    31 -
 .../custos/profile/model/workspace/Gateway.java    |  2383 ---
 .../model/workspace/GatewayApprovalStatus.java     |    78 -
 .../profile-service-server/pom.xml                 |    50 -
 .../profile/handlers/IamAdminServicesHandler.java  |   312 -
 .../handlers/TenantProfileServiceHandler.java      |   259 -
 .../handlers/UserProfileServiceHandler.java        |   239 -
 .../profile/server/ProfileServiceServer.java       |   198 -
 .../src/main/resources/log4j.properties            |    41 -
 .../client/ProfileServiceClientFactory.java        |    78 -
 .../iam.admin.services.cpi/IamAdminServices.java   | 19580 -------------------
 .../exception/IamAdminServicesException.java       |   381 -
 .../iam_admin_services_cpiConstants.java           |    16 -
 .../profile/tenant.cpi/TenantProfileService.java   | 10869 ----------
 .../exception/TenantProfileServiceException.java   |   370 -
 .../tenant.cpi/profile_tenant_cpiConstants.java    |    16 -
 .../profile/user.cpi/UserProfileService.java       | 10003 ----------
 .../exception/UserProfileServiceException.java     |   370 -
 .../user.cpi/profile_user_cpiConstants.java        |    16 -
 custos-profile-service/profile-tenant-core/pom.xml |    43 -
 .../core/repositories/TenantProfileRepository.java |   121 -
 custos-profile-service/profile-user-core/pom.xml   |    90 -
 .../exceptions/UserProfileRegistryException.java   |    28 -
 .../core/repositories/UserProfileRepository.java   |   129 -
 .../core/utils/UserProfileCatalogDBInitConfig.java |    42 -
 .../core/utils/UserProfileCatalogJDBCConfig.java   |    52 -
 .../user-profile-catalog-derby.sql                 |   163 -
 .../user-profile-catalog-mysql.sql                 |   163 -
 .../core/repositories/WorkspaceRepositoryTest.java |   176 -
 .../pom.xml                                        |    13 +-
 .../src/main/java/CustosAPIServerStarted.java      |     8 +
 .../src/main/resources/custos-server.properties    |    32 +
 .../src/main/resources/docker-compose.yml          |    15 +
 .../main/resources/keycloak/Default-export.json    |  1508 ++
 .../main/resources/keycloak/Default-export.json.bk |  1507 ++
 .../src/main/resources/keycloak/standalone.xml     |   521 +
 pom.xml                                            |     1 -
 .../authentication-service-cpi.thrift              |     6 +-
 .../security_model.thrift                          |     0
 .../userInfo_model.thrift                          |     0
 thrift-interfaces/custos-apis/custos_errors.thrift |    47 -
 .../tenant_profile_model.thrift                    |    73 -
 .../user_profile_model.thrift                      |   229 -
 .../workspace_model.thrift                         |    60 -
 .../iam-admin-services-cpi.thrift                  |   133 -
 .../iam_admin_services_cpi_errors.thrift           |    33 -
 .../profile-service/profile-service-cpi.thrift     |    29 -
 .../profile-tenant/profile-tenant-cpi.thrift       |    85 -
 .../profile_tenant_cpi_errors.thrift               |    33 -
 .../profile-user/profile-user-cpi.thrift           |    86 -
 .../profile-user/profile_user_cpi_errors.thrift    |    33 -
 106 files changed, 4001 insertions(+), 67180 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1864f17..c732a73 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,4 +36,4 @@ com_crashlytics_export_strings.xml
 .classpath
 .factorypath
 
-.database_data
+database_data
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/CustosAuthenticationService.java b/custos-authentication/src/main/java/org/apache/custos/authentication/CustosAuthenticationService.java
deleted file mode 100644
index 115c3e3..0000000
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/CustosAuthenticationService.java
+++ /dev/null
@@ -1,3198 +0,0 @@
-/**
- * Autogenerated by Thrift Compiler (0.12.0)
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- *  @generated
- */
-package org.apache.custos.authentication;
-
-@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-08")
-public class CustosAuthenticationService {
-
-  public interface Iface {
-
-    public boolean isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
-
-    public org.apache.custos.commons.model.security.UserInfo getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
-
-    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
-
-  }
-
-  public interface AsyncIface {
-
-    public void isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
-
-    public void getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException;
-
-    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException;
-
-  }
-
-  public static class Client extends org.apache.thrift.TServiceClient implements Iface {
-    public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {
-      public Factory() {}
-      public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
-        return new Client(prot);
-      }
-      public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
-        return new Client(iprot, oprot);
-      }
-    }
-
-    public Client(org.apache.thrift.protocol.TProtocol prot)
-    {
-      super(prot, prot);
-    }
-
-    public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
-      super(iprot, oprot);
-    }
-
-    public boolean isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
-    {
-      send_isUserAuthenticated(authzToken);
-      return recv_isUserAuthenticated();
-    }
-
-    public void send_isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.thrift.TException
-    {
-      isUserAuthenticated_args args = new isUserAuthenticated_args();
-      args.setAuthzToken(authzToken);
-      sendBase("isUserAuthenticated", args);
-    }
-
-    public boolean recv_isUserAuthenticated() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
-    {
-      isUserAuthenticated_result result = new isUserAuthenticated_result();
-      receiveBase(result, "isUserAuthenticated");
-      if (result.isSetSuccess()) {
-        return result.success;
-      }
-      if (result.ae != null) {
-        throw result.ae;
-      }
-      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isUserAuthenticated failed: unknown result");
-    }
-
-    public org.apache.custos.commons.model.security.UserInfo getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
-    {
-      send_getUserInfoFromAuthzToken(authzToken);
-      return recv_getUserInfoFromAuthzToken();
-    }
-
-    public void send_getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.thrift.TException
-    {
-      getUserInfoFromAuthzToken_args args = new getUserInfoFromAuthzToken_args();
-      args.setAuthzToken(authzToken);
-      sendBase("getUserInfoFromAuthzToken", args);
-    }
-
-    public org.apache.custos.commons.model.security.UserInfo recv_getUserInfoFromAuthzToken() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
-    {
-      getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
-      receiveBase(result, "getUserInfoFromAuthzToken");
-      if (result.isSetSuccess()) {
-        return result.success;
-      }
-      if (result.ae != null) {
-        throw result.ae;
-      }
-      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserInfoFromAuthzToken failed: unknown result");
-    }
-
-    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
-    {
-      send_getUserManagementServiceAccountAuthzToken(authzToken, gatewayId);
-      return recv_getUserManagementServiceAccountAuthzToken();
-    }
-
-    public void send_getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.thrift.TException
-    {
-      getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
-      args.setAuthzToken(authzToken);
-      args.setGatewayId(gatewayId);
-      sendBase("getUserManagementServiceAccountAuthzToken", args);
-    }
-
-    public org.apache.custos.commons.model.security.AuthzToken recv_getUserManagementServiceAccountAuthzToken() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
-    {
-      getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
-      receiveBase(result, "getUserManagementServiceAccountAuthzToken");
-      if (result.isSetSuccess()) {
-        return result.success;
-      }
-      if (result.ae != null) {
-        throw result.ae;
-      }
-      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserManagementServiceAccountAuthzToken failed: unknown result");
-    }
-
-  }
-  public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
-    public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
-      private org.apache.thrift.async.TAsyncClientManager clientManager;
-      private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
-      public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
-        this.clientManager = clientManager;
-        this.protocolFactory = protocolFactory;
-      }
-      public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
-        return new AsyncClient(protocolFactory, clientManager, transport);
-      }
-    }
-
-    public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
-      super(protocolFactory, clientManager, transport);
-    }
-
-    public void isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
-      checkReady();
-      isUserAuthenticated_call method_call = new isUserAuthenticated_call(authzToken, resultHandler, this, ___protocolFactory, ___transport);
-      this.___currentMethod = method_call;
-      ___manager.call(method_call);
-    }
-
-    public static class isUserAuthenticated_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
-      private org.apache.custos.commons.model.security.AuthzToken authzToken;
-      public isUserAuthenticated_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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;
-      }
-
-      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
-        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("isUserAuthenticated", org.apache.thrift.protocol.TMessageType.CALL, 0));
-        isUserAuthenticated_args args = new isUserAuthenticated_args();
-        args.setAuthzToken(authzToken);
-        args.write(prot);
-        prot.writeMessageEnd();
-      }
-
-      public Boolean getResult() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException {
-        if (getState() != 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_isUserAuthenticated();
-      }
-    }
-
-    public void getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException {
-      checkReady();
-      getUserInfoFromAuthzToken_call method_call = new getUserInfoFromAuthzToken_call(authzToken, resultHandler, this, ___protocolFactory, ___transport);
-      this.___currentMethod = method_call;
-      ___manager.call(method_call);
-    }
-
-    public static class getUserInfoFromAuthzToken_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.commons.model.security.UserInfo> {
-      private org.apache.custos.commons.model.security.AuthzToken authzToken;
-      public getUserInfoFromAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> 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;
-      }
-
-      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
-        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUserInfoFromAuthzToken", org.apache.thrift.protocol.TMessageType.CALL, 0));
-        getUserInfoFromAuthzToken_args args = new getUserInfoFromAuthzToken_args();
-        args.setAuthzToken(authzToken);
-        args.write(prot);
-        prot.writeMessageEnd();
-      }
-
-      public org.apache.custos.commons.model.security.UserInfo getResult() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException {
-        if (getState() != 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_getUserInfoFromAuthzToken();
-      }
-    }
-
-    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
-      checkReady();
-      getUserManagementServiceAccountAuthzToken_call method_call = new getUserManagementServiceAccountAuthzToken_call(authzToken, gatewayId, resultHandler, this, ___protocolFactory, ___transport);
-      this.___currentMethod = method_call;
-      ___manager.call(method_call);
-    }
-
-    public static class getUserManagementServiceAccountAuthzToken_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.commons.model.security.AuthzToken> {
-      private org.apache.custos.commons.model.security.AuthzToken authzToken;
-      private String gatewayId;
-      public getUserManagementServiceAccountAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> 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;
-      }
-
-      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
-        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUserManagementServiceAccountAuthzToken", org.apache.thrift.protocol.TMessageType.CALL, 0));
-        getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
-        args.setAuthzToken(authzToken);
-        args.setGatewayId(gatewayId);
-        args.write(prot);
-        prot.writeMessageEnd();
-      }
-
-      public org.apache.custos.commons.model.security.AuthzToken getResult() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException {
-        if (getState() != 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_getUserManagementServiceAccountAuthzToken();
-      }
-    }
-
-  }
-
-  public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
-    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName());
-    public Processor(I iface) {
-      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
-    }
-
-    protected Processor(I iface, java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
-      super(iface, getProcessMap(processMap));
-    }
-
-    private static <I extends Iface> java.util.Map<String,  org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {
-      processMap.put("isUserAuthenticated", new isUserAuthenticated());
-      processMap.put("getUserInfoFromAuthzToken", new getUserInfoFromAuthzToken());
-      processMap.put("getUserManagementServiceAccountAuthzToken", new getUserManagementServiceAccountAuthzToken());
-      return processMap;
-    }
-
-    public static class isUserAuthenticated<I extends Iface> extends org.apache.thrift.ProcessFunction<I, isUserAuthenticated_args> {
-      public isUserAuthenticated() {
-        super("isUserAuthenticated");
-      }
-
-      public isUserAuthenticated_args getEmptyArgsInstance() {
-        return new isUserAuthenticated_args();
-      }
-
-      protected boolean isOneway() {
-        return false;
-      }
-
-      @Override
-      protected boolean rethrowUnhandledExceptions() {
-        return false;
-      }
-
-      public isUserAuthenticated_result getResult(I iface, isUserAuthenticated_args args) throws org.apache.thrift.TException {
-        isUserAuthenticated_result result = new isUserAuthenticated_result();
-        try {
-          result.success = iface.isUserAuthenticated(args.authzToken);
-          result.setSuccessIsSet(true);
-        } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
-          result.ae = ae;
-        }
-        return result;
-      }
-    }
-
-    public static class getUserInfoFromAuthzToken<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUserInfoFromAuthzToken_args> {
-      public getUserInfoFromAuthzToken() {
-        super("getUserInfoFromAuthzToken");
-      }
-
-      public getUserInfoFromAuthzToken_args getEmptyArgsInstance() {
-        return new getUserInfoFromAuthzToken_args();
-      }
-
-      protected boolean isOneway() {
-        return false;
-      }
-
-      @Override
-      protected boolean rethrowUnhandledExceptions() {
-        return false;
-      }
-
-      public getUserInfoFromAuthzToken_result getResult(I iface, getUserInfoFromAuthzToken_args args) throws org.apache.thrift.TException {
-        getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
-        try {
-          result.success = iface.getUserInfoFromAuthzToken(args.authzToken);
-        } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
-          result.ae = ae;
-        }
-        return result;
-      }
-    }
-
-    public static class getUserManagementServiceAccountAuthzToken<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUserManagementServiceAccountAuthzToken_args> {
-      public getUserManagementServiceAccountAuthzToken() {
-        super("getUserManagementServiceAccountAuthzToken");
-      }
-
-      public getUserManagementServiceAccountAuthzToken_args getEmptyArgsInstance() {
-        return new getUserManagementServiceAccountAuthzToken_args();
-      }
-
-      protected boolean isOneway() {
-        return false;
-      }
-
-      @Override
-      protected boolean rethrowUnhandledExceptions() {
-        return false;
-      }
-
-      public getUserManagementServiceAccountAuthzToken_result getResult(I iface, getUserManagementServiceAccountAuthzToken_args args) throws org.apache.thrift.TException {
-        getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
-        try {
-          result.success = iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId);
-        } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
-          result.ae = ae;
-        }
-        return result;
-      }
-    }
-
-  }
-
-  public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
-    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName());
-    public AsyncProcessor(I iface) {
-      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
-    }
-
-    protected AsyncProcessor(I iface, java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
-      super(iface, getProcessMap(processMap));
-    }
-
-    private static <I extends AsyncIface> java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
-      processMap.put("isUserAuthenticated", new isUserAuthenticated());
-      processMap.put("getUserInfoFromAuthzToken", new getUserInfoFromAuthzToken());
-      processMap.put("getUserManagementServiceAccountAuthzToken", new getUserManagementServiceAccountAuthzToken());
-      return processMap;
-    }
-
-    public static class isUserAuthenticated<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUserAuthenticated_args, Boolean> {
-      public isUserAuthenticated() {
-        super("isUserAuthenticated");
-      }
-
-      public isUserAuthenticated_args getEmptyArgsInstance() {
-        return new isUserAuthenticated_args();
-      }
-
-      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
-        final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
-          public void onComplete(Boolean o) {
-            isUserAuthenticated_result result = new isUserAuthenticated_result();
-            result.success = o;
-            result.setSuccessIsSet(true);
-            try {
-              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
-            } catch (org.apache.thrift.transport.TTransportException e) {
-              _LOGGER.error("TTransportException writing to internal frame buffer", e);
-              fb.close();
-            } catch (Exception e) {
-              _LOGGER.error("Exception writing to internal frame buffer", e);
-              onError(e);
-            }
-          }
-          public void onError(Exception e) {
-            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
-            org.apache.thrift.TSerializable msg;
-            isUserAuthenticated_result result = new isUserAuthenticated_result();
-            if (e instanceof org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) {
-              result.ae = (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) e;
-              result.setAeIsSet(true);
-              msg = result;
-            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
-              _LOGGER.error("TTransportException inside handler", e);
-              fb.close();
-              return;
-            } else if (e instanceof org.apache.thrift.TApplicationException) {
-              _LOGGER.error("TApplicationException inside handler", e);
-              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
-              msg = (org.apache.thrift.TApplicationException)e;
-            } else {
-              _LOGGER.error("Exception inside handler", e);
-              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
-              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
-            }
-            try {
-              fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (Exception ex) {
-              _LOGGER.error("Exception writing to internal frame buffer", ex);
-              fb.close();
-            }
-          }
-        };
-      }
-
-      protected boolean isOneway() {
-        return false;
-      }
-
-      public void start(I iface, isUserAuthenticated_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
-        iface.isUserAuthenticated(args.authzToken,resultHandler);
-      }
-    }
-
-    public static class getUserInfoFromAuthzToken<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUserInfoFromAuthzToken_args, org.apache.custos.commons.model.security.UserInfo> {
-      public getUserInfoFromAuthzToken() {
-        super("getUserInfoFromAuthzToken");
-      }
-
-      public getUserInfoFromAuthzToken_args getEmptyArgsInstance() {
-        return new getUserInfoFromAuthzToken_args();
-      }
-
-      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
-        final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo>() { 
-          public void onComplete(org.apache.custos.commons.model.security.UserInfo o) {
-            getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
-            result.success = o;
-            try {
-              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
-            } catch (org.apache.thrift.transport.TTransportException e) {
-              _LOGGER.error("TTransportException writing to internal frame buffer", e);
-              fb.close();
-            } catch (Exception e) {
-              _LOGGER.error("Exception writing to internal frame buffer", e);
-              onError(e);
-            }
-          }
-          public void onError(Exception e) {
-            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
-            org.apache.thrift.TSerializable msg;
-            getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
-            if (e instanceof org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) {
-              result.ae = (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) e;
-              result.setAeIsSet(true);
-              msg = result;
-            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
-              _LOGGER.error("TTransportException inside handler", e);
-              fb.close();
-              return;
-            } else if (e instanceof org.apache.thrift.TApplicationException) {
-              _LOGGER.error("TApplicationException inside handler", e);
-              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
-              msg = (org.apache.thrift.TApplicationException)e;
-            } else {
-              _LOGGER.error("Exception inside handler", e);
-              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
-              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
-            }
-            try {
-              fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (Exception ex) {
-              _LOGGER.error("Exception writing to internal frame buffer", ex);
-              fb.close();
-            }
-          }
-        };
-      }
-
-      protected boolean isOneway() {
-        return false;
-      }
-
-      public void start(I iface, getUserInfoFromAuthzToken_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException {
-        iface.getUserInfoFromAuthzToken(args.authzToken,resultHandler);
-      }
-    }
-
-    public static class getUserManagementServiceAccountAuthzToken<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUserManagementServiceAccountAuthzToken_args, org.apache.custos.commons.model.security.AuthzToken> {
-      public getUserManagementServiceAccountAuthzToken() {
-        super("getUserManagementServiceAccountAuthzToken");
-      }
-
-      public getUserManagementServiceAccountAuthzToken_args getEmptyArgsInstance() {
-        return new getUserManagementServiceAccountAuthzToken_args();
-      }
-
-      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
-        final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken>() { 
-          public void onComplete(org.apache.custos.commons.model.security.AuthzToken o) {
-            getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
-            result.success = o;
-            try {
-              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
-            } catch (org.apache.thrift.transport.TTransportException e) {
-              _LOGGER.error("TTransportException writing to internal frame buffer", e);
-              fb.close();
-            } catch (Exception e) {
-              _LOGGER.error("Exception writing to internal frame buffer", e);
-              onError(e);
-            }
-          }
-          public void onError(Exception e) {
-            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
-            org.apache.thrift.TSerializable msg;
-            getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
-            if (e instanceof org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) {
-              result.ae = (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) e;
-              result.setAeIsSet(true);
-              msg = result;
-            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
-              _LOGGER.error("TTransportException inside handler", e);
-              fb.close();
-              return;
-            } else if (e instanceof org.apache.thrift.TApplicationException) {
-              _LOGGER.error("TApplicationException inside handler", e);
-              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
-              msg = (org.apache.thrift.TApplicationException)e;
-            } else {
-              _LOGGER.error("Exception inside handler", e);
-              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
-              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
-            }
-            try {
-              fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (Exception ex) {
-              _LOGGER.error("Exception writing to internal frame buffer", ex);
-              fb.close();
-            }
-          }
-        };
-      }
-
-      protected boolean isOneway() {
-        return false;
-      }
-
-      public void start(I iface, getUserManagementServiceAccountAuthzToken_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
-        iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId,resultHandler);
-      }
-    }
-
-  }
-
-  public static class isUserAuthenticated_args implements org.apache.thrift.TBase<isUserAuthenticated_args, isUserAuthenticated_args._Fields>, java.io.Serializable, Cloneable, Comparable<isUserAuthenticated_args>   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isUserAuthenticated_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUserAuthenticated_argsStandardSchemeFactory();
-    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUserAuthenticated_argsTupleSchemeFactory();
-
-    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // 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");
-
-      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-      static {
-        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
-          byName.put(field.getFieldName(), field);
-        }
-      }
-
-      /**
-       * Find the _Fields constant that matches fieldId, or null if its not found.
-       */
-      @org.apache.thrift.annotation.Nullable
-      public static _Fields findByThriftId(int fieldId) {
-        switch(fieldId) {
-          case 1: // AUTHZ_TOKEN
-            return AUTHZ_TOKEN;
-          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.
-       */
-      @org.apache.thrift.annotation.Nullable
-      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-    static {
-      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
-      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_args.class, metaDataMap);
-    }
-
-    public isUserAuthenticated_args() {
-    }
-
-    public isUserAuthenticated_args(
-      org.apache.custos.commons.model.security.AuthzToken authzToken)
-    {
-      this();
-      this.authzToken = authzToken;
-    }
-
-    /**
-     * Performs a deep copy on <i>other</i>.
-     */
-    public isUserAuthenticated_args(isUserAuthenticated_args other) {
-      if (other.isSetAuthzToken()) {
-        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
-      }
-    }
-
-    public isUserAuthenticated_args deepCopy() {
-      return new isUserAuthenticated_args(this);
-    }
-
-    @Override
-    public void clear() {
-      this.authzToken = null;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
-      return this.authzToken;
-    }
-
-    public isUserAuthenticated_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
-      switch (field) {
-      case AUTHZ_TOKEN:
-        if (value == null) {
-          unsetAuthzToken();
-        } else {
-          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
-        }
-        break;
-
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public Object getFieldValue(_Fields field) {
-      switch (field) {
-      case AUTHZ_TOKEN:
-        return getAuthzToken();
-
-      }
-      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();
-      }
-      throw new IllegalStateException();
-    }
-
-    @Override
-    public boolean equals(Object that) {
-      if (that == null)
-        return false;
-      if (that instanceof isUserAuthenticated_args)
-        return this.equals((isUserAuthenticated_args)that);
-      return false;
-    }
-
-    public boolean equals(isUserAuthenticated_args that) {
-      if (that == null)
-        return false;
-      if (this == that)
-        return true;
-
-      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;
-      }
-
-      return true;
-    }
-
-    @Override
-    public int hashCode() {
-      int hashCode = 1;
-
-      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
-      if (isSetAuthzToken())
-        hashCode = hashCode * 8191 + authzToken.hashCode();
-
-      return hashCode;
-    }
-
-    @Override
-    public int compareTo(isUserAuthenticated_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;
-        }
-      }
-      return 0;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public _Fields fieldForId(int fieldId) {
-      return _Fields.findByThriftId(fieldId);
-    }
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
-      scheme(iprot).read(iprot, this);
-    }
-
-    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-      scheme(oprot).write(oprot, this);
-    }
-
-    @Override
-    public String toString() {
-      StringBuilder sb = new StringBuilder("isUserAuthenticated_args(");
-      boolean first = true;
-
-      sb.append("authzToken:");
-      if (this.authzToken == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.authzToken);
-      }
-      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());
-      }
-      // 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 isUserAuthenticated_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public isUserAuthenticated_argsStandardScheme getScheme() {
-        return new isUserAuthenticated_argsStandardScheme();
-      }
-    }
-
-    private static class isUserAuthenticated_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<isUserAuthenticated_args> {
-
-      public void read(org.apache.thrift.protocol.TProtocol iprot, isUserAuthenticated_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.custos.commons.model.security.AuthzToken();
-                struct.authzToken.read(iprot);
-                struct.setAuthzTokenIsSet(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, isUserAuthenticated_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();
-        }
-        oprot.writeFieldStop();
-        oprot.writeStructEnd();
-      }
-
-    }
-
-    private static class isUserAuthenticated_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public isUserAuthenticated_argsTupleScheme getScheme() {
-        return new isUserAuthenticated_argsTupleScheme();
-      }
-    }
-
-    private static class isUserAuthenticated_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<isUserAuthenticated_args> {
-
-      @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_args struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken.write(oprot);
-      }
-
-      @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_args struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
-        struct.authzToken.read(iprot);
-        struct.setAuthzTokenIsSet(true);
-      }
-    }
-
-    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-    }
-  }
-
-  public static class isUserAuthenticated_result implements org.apache.thrift.TBase<isUserAuthenticated_result, isUserAuthenticated_result._Fields>, java.io.Serializable, Cloneable, Comparable<isUserAuthenticated_result>   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isUserAuthenticated_result");
-
-    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0);
-    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)1);
-
-    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUserAuthenticated_resultStandardSchemeFactory();
-    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUserAuthenticated_resultTupleSchemeFactory();
-
-    public boolean success; // required
-    public @org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae; // 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"),
-      AE((short)1, "ae");
-
-      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-      static {
-        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
-          byName.put(field.getFieldName(), field);
-        }
-      }
-
-      /**
-       * Find the _Fields constant that matches fieldId, or null if its not found.
-       */
-      @org.apache.thrift.annotation.Nullable
-      public static _Fields findByThriftId(int fieldId) {
-        switch(fieldId) {
-          case 0: // SUCCESS
-            return SUCCESS;
-          case 1: // AE
-            return AE;
-          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.
-       */
-      @org.apache.thrift.annotation.Nullable
-      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
-    private static final int __SUCCESS_ISSET_ID = 0;
-    private byte __isset_bitfield = 0;
-    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-    static {
-      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.BOOL)));
-      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
-      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_result.class, metaDataMap);
-    }
-
-    public isUserAuthenticated_result() {
-    }
-
-    public isUserAuthenticated_result(
-      boolean success,
-      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
-    {
-      this();
-      this.success = success;
-      setSuccessIsSet(true);
-      this.ae = ae;
-    }
-
-    /**
-     * Performs a deep copy on <i>other</i>.
-     */
-    public isUserAuthenticated_result(isUserAuthenticated_result other) {
-      __isset_bitfield = other.__isset_bitfield;
-      this.success = other.success;
-      if (other.isSetAe()) {
-        this.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException(other.ae);
-      }
-    }
-
-    public isUserAuthenticated_result deepCopy() {
-      return new isUserAuthenticated_result(this);
-    }
-
-    @Override
-    public void clear() {
-      setSuccessIsSet(false);
-      this.success = false;
-      this.ae = null;
-    }
-
-    public boolean isSuccess() {
-      return this.success;
-    }
-
-    public isUserAuthenticated_result setSuccess(boolean success) {
-      this.success = success;
-      setSuccessIsSet(true);
-      return this;
-    }
-
-    public void unsetSuccess() {
-      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID);
-    }
-
-    /** Returns true if field success is set (has been assigned a value) and false otherwise */
-    public boolean isSetSuccess() {
-      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID);
-    }
-
-    public void setSuccessIsSet(boolean value) {
-      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException getAe() {
-      return this.ae;
-    }
-
-    public isUserAuthenticated_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
-      this.ae = ae;
-      return this;
-    }
-
-    public void unsetAe() {
-      this.ae = null;
-    }
-
-    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
-    public boolean isSetAe() {
-      return this.ae != null;
-    }
-
-    public void setAeIsSet(boolean value) {
-      if (!value) {
-        this.ae = null;
-      }
-    }
-
-    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
-      switch (field) {
-      case SUCCESS:
-        if (value == null) {
-          unsetSuccess();
-        } else {
-          setSuccess((Boolean)value);
-        }
-        break;
-
-      case AE:
-        if (value == null) {
-          unsetAe();
-        } else {
-          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
-        }
-        break;
-
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public Object getFieldValue(_Fields field) {
-      switch (field) {
-      case SUCCESS:
-        return isSuccess();
-
-      case AE:
-        return getAe();
-
-      }
-      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 AE:
-        return isSetAe();
-      }
-      throw new IllegalStateException();
-    }
-
-    @Override
-    public boolean equals(Object that) {
-      if (that == null)
-        return false;
-      if (that instanceof isUserAuthenticated_result)
-        return this.equals((isUserAuthenticated_result)that);
-      return false;
-    }
-
-    public boolean equals(isUserAuthenticated_result that) {
-      if (that == null)
-        return false;
-      if (this == that)
-        return true;
-
-      boolean this_present_success = true;
-      boolean that_present_success = true;
-      if (this_present_success || that_present_success) {
-        if (!(this_present_success && that_present_success))
-          return false;
-        if (this.success != that.success)
-          return false;
-      }
-
-      boolean this_present_ae = true && this.isSetAe();
-      boolean that_present_ae = true && that.isSetAe();
-      if (this_present_ae || that_present_ae) {
-        if (!(this_present_ae && that_present_ae))
-          return false;
-        if (!this.ae.equals(that.ae))
-          return false;
-      }
-
-      return true;
-    }
-
-    @Override
-    public int hashCode() {
-      int hashCode = 1;
-
-      hashCode = hashCode * 8191 + ((success) ? 131071 : 524287);
-
-      hashCode = hashCode * 8191 + ((isSetAe()) ? 131071 : 524287);
-      if (isSetAe())
-        hashCode = hashCode * 8191 + ae.hashCode();
-
-      return hashCode;
-    }
-
-    @Override
-    public int compareTo(isUserAuthenticated_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(isSetAe()).compareTo(other.isSetAe());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetAe()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
-      return 0;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public _Fields fieldForId(int fieldId) {
-      return _Fields.findByThriftId(fieldId);
-    }
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
-      scheme(iprot).read(iprot, this);
-    }
-
-    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-      scheme(oprot).write(oprot, this);
-      }
-
-    @Override
-    public String toString() {
-      StringBuilder sb = new StringBuilder("isUserAuthenticated_result(");
-      boolean first = true;
-
-      sb.append("success:");
-      sb.append(this.success);
-      first = false;
-      if (!first) sb.append(", ");
-      sb.append("ae:");
-      if (this.ae == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.ae);
-      }
-      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 {
-        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
-        __isset_bitfield = 0;
-        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 isUserAuthenticated_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public isUserAuthenticated_resultStandardScheme getScheme() {
-        return new isUserAuthenticated_resultStandardScheme();
-      }
-    }
-
-    private static class isUserAuthenticated_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<isUserAuthenticated_result> {
-
-      public void read(org.apache.thrift.protocol.TProtocol iprot, isUserAuthenticated_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.BOOL) {
-                struct.success = iprot.readBool();
-                struct.setSuccessIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
-            case 1: // AE
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
-                struct.ae.read(iprot);
-                struct.setAeIsSet(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, isUserAuthenticated_result struct) throws org.apache.thrift.TException {
-        struct.validate();
-
-        oprot.writeStructBegin(STRUCT_DESC);
-        if (struct.isSetSuccess()) {
-          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
-          oprot.writeBool(struct.success);
-          oprot.writeFieldEnd();
-        }
-        if (struct.ae != null) {
-          oprot.writeFieldBegin(AE_FIELD_DESC);
-          struct.ae.write(oprot);
-          oprot.writeFieldEnd();
-        }
-        oprot.writeFieldStop();
-        oprot.writeStructEnd();
-      }
-
-    }
-
-    private static class isUserAuthenticated_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public isUserAuthenticated_resultTupleScheme getScheme() {
-        return new isUserAuthenticated_resultTupleScheme();
-      }
-    }
-
-    private static class isUserAuthenticated_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<isUserAuthenticated_result> {
-
-      @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_result struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        java.util.BitSet optionals = new java.util.BitSet();
-        if (struct.isSetSuccess()) {
-          optionals.set(0);
-        }
-        if (struct.isSetAe()) {
-          optionals.set(1);
-        }
-        oprot.writeBitSet(optionals, 2);
-        if (struct.isSetSuccess()) {
-          oprot.writeBool(struct.success);
-        }
-        if (struct.isSetAe()) {
-          struct.ae.write(oprot);
-        }
-      }
-
-      @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_result struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        java.util.BitSet incoming = iprot.readBitSet(2);
-        if (incoming.get(0)) {
-          struct.success = iprot.readBool();
-          struct.setSuccessIsSet(true);
-        }
-        if (incoming.get(1)) {
-          struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
-          struct.ae.read(iprot);
-          struct.setAeIsSet(true);
-        }
-      }
-    }
-
-    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-    }
-  }
-
-  public static class getUserInfoFromAuthzToken_args implements org.apache.thrift.TBase<getUserInfoFromAuthzToken_args, getUserInfoFromAuthzToken_args._Fields>, java.io.Serializable, Cloneable, Comparable<getUserInfoFromAuthzToken_args>   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserInfoFromAuthzToken_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserInfoFromAuthzToken_argsStandardSchemeFactory();
-    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserInfoFromAuthzToken_argsTupleSchemeFactory();
-
-    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // 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");
-
-      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-      static {
-        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
-          byName.put(field.getFieldName(), field);
-        }
-      }
-
-      /**
-       * Find the _Fields constant that matches fieldId, or null if its not found.
-       */
-      @org.apache.thrift.annotation.Nullable
-      public static _Fields findByThriftId(int fieldId) {
-        switch(fieldId) {
-          case 1: // AUTHZ_TOKEN
-            return AUTHZ_TOKEN;
-          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.
-       */
-      @org.apache.thrift.annotation.Nullable
-      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-    static {
-      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
-      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_args.class, metaDataMap);
-    }
-
-    public getUserInfoFromAuthzToken_args() {
-    }
-
-    public getUserInfoFromAuthzToken_args(
-      org.apache.custos.commons.model.security.AuthzToken authzToken)
-    {
-      this();
-      this.authzToken = authzToken;
-    }
-
-    /**
-     * Performs a deep copy on <i>other</i>.
-     */
-    public getUserInfoFromAuthzToken_args(getUserInfoFromAuthzToken_args other) {
-      if (other.isSetAuthzToken()) {
-        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
-      }
-    }
-
-    public getUserInfoFromAuthzToken_args deepCopy() {
-      return new getUserInfoFromAuthzToken_args(this);
-    }
-
-    @Override
-    public void clear() {
-      this.authzToken = null;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
-      return this.authzToken;
-    }
-
-    public getUserInfoFromAuthzToken_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
-      switch (field) {
-      case AUTHZ_TOKEN:
-        if (value == null) {
-          unsetAuthzToken();
-        } else {
-          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
-        }
-        break;
-
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public Object getFieldValue(_Fields field) {
-      switch (field) {
-      case AUTHZ_TOKEN:
-        return getAuthzToken();
-
-      }
-      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();
-      }
-      throw new IllegalStateException();
-    }
-
-    @Override
-    public boolean equals(Object that) {
-      if (that == null)
-        return false;
-      if (that instanceof getUserInfoFromAuthzToken_args)
-        return this.equals((getUserInfoFromAuthzToken_args)that);
-      return false;
-    }
-
-    public boolean equals(getUserInfoFromAuthzToken_args that) {
-      if (that == null)
-        return false;
-      if (this == that)
-        return true;
-
-      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;
-      }
-
-      return true;
-    }
-
-    @Override
-    public int hashCode() {
-      int hashCode = 1;
-
-      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
-      if (isSetAuthzToken())
-        hashCode = hashCode * 8191 + authzToken.hashCode();
-
-      return hashCode;
-    }
-
-    @Override
-    public int compareTo(getUserInfoFromAuthzToken_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;
-        }
-      }
-      return 0;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public _Fields fieldForId(int fieldId) {
-      return _Fields.findByThriftId(fieldId);
-    }
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
-      scheme(iprot).read(iprot, this);
-    }
-
-    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-      scheme(oprot).write(oprot, this);
-    }
-
-    @Override
-    public String toString() {
-      StringBuilder sb = new StringBuilder("getUserInfoFromAuthzToken_args(");
-      boolean first = true;
-
-      sb.append("authzToken:");
-      if (this.authzToken == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.authzToken);
-      }
-      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());
-      }
-      // 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 getUserInfoFromAuthzToken_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public getUserInfoFromAuthzToken_argsStandardScheme getScheme() {
-        return new getUserInfoFromAuthzToken_argsStandardScheme();
-      }
-    }
-
-    private static class getUserInfoFromAuthzToken_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserInfoFromAuthzToken_args> {
-
-      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserInfoFromAuthzToken_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.custos.commons.model.security.AuthzToken();
-                struct.authzToken.read(iprot);
-                struct.setAuthzTokenIsSet(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, getUserInfoFromAuthzToken_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();
-        }
-        oprot.writeFieldStop();
-        oprot.writeStructEnd();
-      }
-
-    }
-
-    private static class getUserInfoFromAuthzToken_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public getUserInfoFromAuthzToken_argsTupleScheme getScheme() {
-        return new getUserInfoFromAuthzToken_argsTupleScheme();
-      }
-    }
-
-    private static class getUserInfoFromAuthzToken_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserInfoFromAuthzToken_args> {
-
-      @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_args struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken.write(oprot);
-      }
-
-      @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_args struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
-        struct.authzToken.read(iprot);
-        struct.setAuthzTokenIsSet(true);
-      }
-    }
-
-    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-    }
-  }
-
-  public static class getUserInfoFromAuthzToken_result implements org.apache.thrift.TBase<getUserInfoFromAuthzToken_result, getUserInfoFromAuthzToken_result._Fields>, java.io.Serializable, Cloneable, Comparable<getUserInfoFromAuthzToken_result>   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserInfoFromAuthzToken_result");
-
-    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
-    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)1);
-
-    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserInfoFromAuthzToken_resultStandardSchemeFactory();
-    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserInfoFromAuthzToken_resultTupleSchemeFactory();
-
-    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.UserInfo success; // required
-    public @org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae; // 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"),
-      AE((short)1, "ae");
-
-      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-      static {
-        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
-          byName.put(field.getFieldName(), field);
-        }
-      }
-
-      /**
-       * Find the _Fields constant that matches fieldId, or null if its not found.
-       */
-      @org.apache.thrift.annotation.Nullable
-      public static _Fields findByThriftId(int fieldId) {
-        switch(fieldId) {
-          case 0: // SUCCESS
-            return SUCCESS;
-          case 1: // AE
-            return AE;
-          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.
-       */
-      @org.apache.thrift.annotation.Nullable
-      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-    static {
-      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.UserInfo.class)));
-      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
-      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_result.class, metaDataMap);
-    }
-
-    public getUserInfoFromAuthzToken_result() {
-    }
-
-    public getUserInfoFromAuthzToken_result(
-      org.apache.custos.commons.model.security.UserInfo success,
-      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
-    {
-      this();
-      this.success = success;
-      this.ae = ae;
-    }
-
-    /**
-     * Performs a deep copy on <i>other</i>.
-     */
-    public getUserInfoFromAuthzToken_result(getUserInfoFromAuthzToken_result other) {
-      if (other.isSetSuccess()) {
-        this.success = new org.apache.custos.commons.model.security.UserInfo(other.success);
-      }
-      if (other.isSetAe()) {
-        this.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException(other.ae);
-      }
-    }
-
-    public getUserInfoFromAuthzToken_result deepCopy() {
-      return new getUserInfoFromAuthzToken_result(this);
-    }
-
-    @Override
-    public void clear() {
-      this.success = null;
-      this.ae = null;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public org.apache.custos.commons.model.security.UserInfo getSuccess() {
-      return this.success;
-    }
-
-    public getUserInfoFromAuthzToken_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.UserInfo 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;
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException getAe() {
-      return this.ae;
-    }
-
-    public getUserInfoFromAuthzToken_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
-      this.ae = ae;
-      return this;
-    }
-
-    public void unsetAe() {
-      this.ae = null;
-    }
-
-    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
-    public boolean isSetAe() {
-      return this.ae != null;
-    }
-
-    public void setAeIsSet(boolean value) {
-      if (!value) {
-        this.ae = null;
-      }
-    }
-
-    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
-      switch (field) {
-      case SUCCESS:
-        if (value == null) {
-          unsetSuccess();
-        } else {
-          setSuccess((org.apache.custos.commons.model.security.UserInfo)value);
-        }
-        break;
-
-      case AE:
-        if (value == null) {
-          unsetAe();
-        } else {
-          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
-        }
-        break;
-
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public Object getFieldValue(_Fields field) {
-      switch (field) {
-      case SUCCESS:
-        return getSuccess();
-
-      case AE:
-        return getAe();
-
-      }
-      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 AE:
-        return isSetAe();
-      }
-      throw new IllegalStateException();
-    }
-
-    @Override
-    public boolean equals(Object that) {
-      if (that == null)
-        return false;
-      if (that instanceof getUserInfoFromAuthzToken_result)
-        return this.equals((getUserInfoFromAuthzToken_result)that);
-      return false;
-    }
-
-    public boolean equals(getUserInfoFromAuthzToken_result that) {
-      if (that == null)
-        return false;
-      if (this == that)
-        return true;
-
-      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_ae = true && this.isSetAe();
-      boolean that_present_ae = true && that.isSetAe();
-      if (this_present_ae || that_present_ae) {
-        if (!(this_present_ae && that_present_ae))
-          return false;
-        if (!this.ae.equals(that.ae))
-          return false;
-      }
-
-      return true;
-    }
-
-    @Override
-    public int hashCode() {
-      int hashCode = 1;
-
-      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
-      if (isSetSuccess())
-        hashCode = hashCode * 8191 + success.hashCode();
-
-      hashCode = hashCode * 8191 + ((isSetAe()) ? 131071 : 524287);
-      if (isSetAe())
-        hashCode = hashCode * 8191 + ae.hashCode();
-
-      return hashCode;
-    }
-
-    @Override
-    public int compareTo(getUserInfoFromAuthzToken_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(isSetAe()).compareTo(other.isSetAe());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetAe()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
-      return 0;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public _Fields fieldForId(int fieldId) {
-      return _Fields.findByThriftId(fieldId);
-    }
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
-      scheme(iprot).read(iprot, this);
-    }
-
-    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-      scheme(oprot).write(oprot, this);
-      }
-
-    @Override
-    public String toString() {
-      StringBuilder sb = new StringBuilder("getUserInfoFromAuthzToken_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("ae:");
-      if (this.ae == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.ae);
-      }
-      first = false;
-      sb.append(")");
-      return sb.toString();
-    }
-
-    public void validate() throws org.apache.thrift.TException {
-      // check for required fields
-      // check for sub-struct validity
-      if (success != null) {
-        success.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 getUserInfoFromAuthzToken_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public getUserInfoFromAuthzToken_resultStandardScheme getScheme() {
-        return new getUserInfoFromAuthzToken_resultStandardScheme();
-      }
-    }
-
-    private static class getUserInfoFromAuthzToken_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserInfoFromAuthzToken_result> {
-
-      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserInfoFromAuthzToken_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.STRUCT) {
-                struct.success = new org.apache.custos.commons.model.security.UserInfo();
-                struct.success.read(iprot);
-                struct.setSuccessIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
-            case 1: // AE
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
-                struct.ae.read(iprot);
-                struct.setAeIsSet(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, getUserInfoFromAuthzToken_result struct) throws org.apache.thrift.TException {
-        struct.validate();
-
-        oprot.writeStructBegin(STRUCT_DESC);
-        if (struct.success != null) {
-          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
-          struct.success.write(oprot);
-          oprot.writeFieldEnd();
-        }
-        if (struct.ae != null) {
-          oprot.writeFieldBegin(AE_FIELD_DESC);
-          struct.ae.write(oprot);
-          oprot.writeFieldEnd();
-        }
-        oprot.writeFieldStop();
-        oprot.writeStructEnd();
-      }
-
-    }
-
-    private static class getUserInfoFromAuthzToken_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public getUserInfoFromAuthzToken_resultTupleScheme getScheme() {
-        return new getUserInfoFromAuthzToken_resultTupleScheme();
-      }
-    }
-
-    private static class getUserInfoFromAuthzToken_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserInfoFromAuthzToken_result> {
-
-      @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_result struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        java.util.BitSet optionals = new java.util.BitSet();
-        if (struct.isSetSuccess()) {
-          optionals.set(0);
-        }
-        if (struct.isSetAe()) {
-          optionals.set(1);
-        }
-        oprot.writeBitSet(optionals, 2);
-        if (struct.isSetSuccess()) {
-          struct.success.write(oprot);
-        }
-        if (struct.isSetAe()) {
-          struct.ae.write(oprot);
-        }
-      }
-
-      @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_result struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        java.util.BitSet incoming = iprot.readBitSet(2);
-        if (incoming.get(0)) {
-          struct.success = new org.apache.custos.commons.model.security.UserInfo();
-          struct.success.read(iprot);
-          struct.setSuccessIsSet(true);
-        }
-        if (incoming.get(1)) {
-          struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
-          struct.ae.read(iprot);
-          struct.setAeIsSet(true);
-        }
-      }
-    }
-
-    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-    }
-  }
-
-  public static class getUserManagementServiceAccountAuthzToken_args implements org.apache.thrift.TBase<getUserManagementServiceAccountAuthzToken_args, getUserManagementServiceAccountAuthzToken_args._Fields>, java.io.Serializable, Cloneable, Comparable<getUserManagementServiceAccountAuthzToken_args>   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserManagementServiceAccountAuthzToken_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsStandardSchemeFactory();
-    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsTupleSchemeFactory();
-
-    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
-    public @org.apache.thrift.annotation.Nullable String gatewayId; // 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");
-
-      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-      static {
-        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
-          byName.put(field.getFieldName(), field);
-        }
-      }
-
-      /**
-       * Find the _Fields constant that matches fieldId, or null if its not found.
-       */
-      @org.apache.thrift.annotation.Nullable
-      public static _Fields findByThriftId(int fieldId) {
-        switch(fieldId) {
-          case 1: // AUTHZ_TOKEN
-            return AUTHZ_TOKEN;
-          case 2: // GATEWAY_ID
-            return GATEWAY_ID;
-          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.
-       */
-      @org.apache.thrift.annotation.Nullable
-      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-    static {
-      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.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)));
-      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_args.class, metaDataMap);
-    }
-
-    public getUserManagementServiceAccountAuthzToken_args() {
-    }
-
-    public getUserManagementServiceAccountAuthzToken_args(
-      org.apache.custos.commons.model.security.AuthzToken authzToken,
-      String gatewayId)
-    {
-      this();
-      this.authzToken = authzToken;
-      this.gatewayId = gatewayId;
-    }
-
-    /**
-     * Performs a deep copy on <i>other</i>.
-     */
-    public getUserManagementServiceAccountAuthzToken_args(getUserManagementServiceAccountAuthzToken_args other) {
-      if (other.isSetAuthzToken()) {
-        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
-      }
-      if (other.isSetGatewayId()) {
-        this.gatewayId = other.gatewayId;
-      }
-    }
-
-    public getUserManagementServiceAccountAuthzToken_args deepCopy() {
-      return new getUserManagementServiceAccountAuthzToken_args(this);
-    }
-
-    @Override
-    public void clear() {
-      this.authzToken = null;
-      this.gatewayId = null;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
-      return this.authzToken;
-    }
-
-    public getUserManagementServiceAccountAuthzToken_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public String getGatewayId() {
-      return this.gatewayId;
-    }
-
-    public getUserManagementServiceAccountAuthzToken_args setGatewayId(@org.apache.thrift.annotation.Nullable 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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
-      switch (field) {
-      case AUTHZ_TOKEN:
-        if (value == null) {
-          unsetAuthzToken();
-        } else {
-          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
-        }
-        break;
-
-      case GATEWAY_ID:
-        if (value == null) {
-          unsetGatewayId();
-        } else {
-          setGatewayId((String)value);
-        }
-        break;
-
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public Object getFieldValue(_Fields field) {
-      switch (field) {
-      case AUTHZ_TOKEN:
-        return getAuthzToken();
-
-      case GATEWAY_ID:
-        return getGatewayId();
-
-      }
-      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();
-      }
-      throw new IllegalStateException();
-    }
-
-    @Override
-    public boolean equals(Object that) {
-      if (that == null)
-        return false;
-      if (that instanceof getUserManagementServiceAccountAuthzToken_args)
-        return this.equals((getUserManagementServiceAccountAuthzToken_args)that);
-      return false;
-    }
-
-    public boolean equals(getUserManagementServiceAccountAuthzToken_args that) {
-      if (that == null)
-        return false;
-      if (this == that)
-        return true;
-
-      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;
-      }
-
-      return true;
-    }
-
-    @Override
-    public int hashCode() {
-      int hashCode = 1;
-
-      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
-      if (isSetAuthzToken())
-        hashCode = hashCode * 8191 + authzToken.hashCode();
-
-      hashCode = hashCode * 8191 + ((isSetGatewayId()) ? 131071 : 524287);
-      if (isSetGatewayId())
-        hashCode = hashCode * 8191 + gatewayId.hashCode();
-
-      return hashCode;
-    }
-
-    @Override
-    public int compareTo(getUserManagementServiceAccountAuthzToken_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;
-        }
-      }
-      return 0;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public _Fields fieldForId(int fieldId) {
-      return _Fields.findByThriftId(fieldId);
-    }
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
-      scheme(iprot).read(iprot, this);
-    }
-
-    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-      scheme(oprot).write(oprot, this);
-    }
-
-    @Override
-    public String toString() {
-      StringBuilder sb = new StringBuilder("getUserManagementServiceAccountAuthzToken_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;
-      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());
-      }
-      // 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 getUserManagementServiceAccountAuthzToken_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public getUserManagementServiceAccountAuthzToken_argsStandardScheme getScheme() {
-        return new getUserManagementServiceAccountAuthzToken_argsStandardScheme();
-      }
-    }
-
-    private static class getUserManagementServiceAccountAuthzToken_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserManagementServiceAccountAuthzToken_args> {
-
-      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserManagementServiceAccountAuthzToken_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.custos.commons.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;
-            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, getUserManagementServiceAccountAuthzToken_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();
-        }
-        oprot.writeFieldStop();
-        oprot.writeStructEnd();
-      }
-
-    }
-
-    private static class getUserManagementServiceAccountAuthzToken_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public getUserManagementServiceAccountAuthzToken_argsTupleScheme getScheme() {
-        return new getUserManagementServiceAccountAuthzToken_argsTupleScheme();
-      }
-    }
-
-    private static class getUserManagementServiceAccountAuthzToken_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserManagementServiceAccountAuthzToken_args> {
-
-      @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_args struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken.write(oprot);
-        oprot.writeString(struct.gatewayId);
-      }
-
-      @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_args struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
-        struct.authzToken.read(iprot);
-        struct.setAuthzTokenIsSet(true);
-        struct.gatewayId = iprot.readString();
-        struct.setGatewayIdIsSet(true);
-      }
-    }
-
-    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-    }
-  }
-
-  public static class getUserManagementServiceAccountAuthzToken_result implements org.apache.thrift.TBase<getUserManagementServiceAccountAuthzToken_result, getUserManagementServiceAccountAuthzToken_result._Fields>, java.io.Serializable, Cloneable, Comparable<getUserManagementServiceAccountAuthzToken_result>   {
-    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserManagementServiceAccountAuthzToken_result");
-
-    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
-    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)1);
-
-    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_resultStandardSchemeFactory();
-    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_resultTupleSchemeFactory();
-
-    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken success; // required
-    public @org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae; // 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"),
-      AE((short)1, "ae");
-
-      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-      static {
-        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
-          byName.put(field.getFieldName(), field);
-        }
-      }
-
-      /**
-       * Find the _Fields constant that matches fieldId, or null if its not found.
-       */
-      @org.apache.thrift.annotation.Nullable
-      public static _Fields findByThriftId(int fieldId) {
-        switch(fieldId) {
-          case 0: // SUCCESS
-            return SUCCESS;
-          case 1: // AE
-            return AE;
-          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.
-       */
-      @org.apache.thrift.annotation.Nullable
-      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-    static {
-      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
-      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
-      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_result.class, metaDataMap);
-    }
-
-    public getUserManagementServiceAccountAuthzToken_result() {
-    }
-
-    public getUserManagementServiceAccountAuthzToken_result(
-      org.apache.custos.commons.model.security.AuthzToken success,
-      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
-    {
-      this();
-      this.success = success;
-      this.ae = ae;
-    }
-
-    /**
-     * Performs a deep copy on <i>other</i>.
-     */
-    public getUserManagementServiceAccountAuthzToken_result(getUserManagementServiceAccountAuthzToken_result other) {
-      if (other.isSetSuccess()) {
-        this.success = new org.apache.custos.commons.model.security.AuthzToken(other.success);
-      }
-      if (other.isSetAe()) {
-        this.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException(other.ae);
-      }
-    }
-
-    public getUserManagementServiceAccountAuthzToken_result deepCopy() {
-      return new getUserManagementServiceAccountAuthzToken_result(this);
-    }
-
-    @Override
-    public void clear() {
-      this.success = null;
-      this.ae = null;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public org.apache.custos.commons.model.security.AuthzToken getSuccess() {
-      return this.success;
-    }
-
-    public getUserManagementServiceAccountAuthzToken_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken 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;
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException getAe() {
-      return this.ae;
-    }
-
-    public getUserManagementServiceAccountAuthzToken_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
-      this.ae = ae;
-      return this;
-    }
-
-    public void unsetAe() {
-      this.ae = null;
-    }
-
-    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
-    public boolean isSetAe() {
-      return this.ae != null;
-    }
-
-    public void setAeIsSet(boolean value) {
-      if (!value) {
-        this.ae = null;
-      }
-    }
-
-    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
-      switch (field) {
-      case SUCCESS:
-        if (value == null) {
-          unsetSuccess();
-        } else {
-          setSuccess((org.apache.custos.commons.model.security.AuthzToken)value);
-        }
-        break;
-
-      case AE:
-        if (value == null) {
-          unsetAe();
-        } else {
-          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
-        }
-        break;
-
-      }
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public Object getFieldValue(_Fields field) {
-      switch (field) {
-      case SUCCESS:
-        return getSuccess();
-
-      case AE:
-        return getAe();
-
-      }
-      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 AE:
-        return isSetAe();
-      }
-      throw new IllegalStateException();
-    }
-
-    @Override
-    public boolean equals(Object that) {
-      if (that == null)
-        return false;
-      if (that instanceof getUserManagementServiceAccountAuthzToken_result)
-        return this.equals((getUserManagementServiceAccountAuthzToken_result)that);
-      return false;
-    }
-
-    public boolean equals(getUserManagementServiceAccountAuthzToken_result that) {
-      if (that == null)
-        return false;
-      if (this == that)
-        return true;
-
-      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_ae = true && this.isSetAe();
-      boolean that_present_ae = true && that.isSetAe();
-      if (this_present_ae || that_present_ae) {
-        if (!(this_present_ae && that_present_ae))
-          return false;
-        if (!this.ae.equals(that.ae))
-          return false;
-      }
-
-      return true;
-    }
-
-    @Override
-    public int hashCode() {
-      int hashCode = 1;
-
-      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
-      if (isSetSuccess())
-        hashCode = hashCode * 8191 + success.hashCode();
-
-      hashCode = hashCode * 8191 + ((isSetAe()) ? 131071 : 524287);
-      if (isSetAe())
-        hashCode = hashCode * 8191 + ae.hashCode();
-
-      return hashCode;
-    }
-
-    @Override
-    public int compareTo(getUserManagementServiceAccountAuthzToken_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(isSetAe()).compareTo(other.isSetAe());
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-      if (isSetAe()) {
-        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
-        if (lastComparison != 0) {
-          return lastComparison;
-        }
-      }
-      return 0;
-    }
-
-    @org.apache.thrift.annotation.Nullable
-    public _Fields fieldForId(int fieldId) {
-      return _Fields.findByThriftId(fieldId);
-    }
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
-      scheme(iprot).read(iprot, this);
-    }
-
-    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-      scheme(oprot).write(oprot, this);
-      }
-
-    @Override
-    public String toString() {
-      StringBuilder sb = new StringBuilder("getUserManagementServiceAccountAuthzToken_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("ae:");
-      if (this.ae == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.ae);
-      }
-      first = false;
-      sb.append(")");
-      return sb.toString();
-    }
-
-    public void validate() throws org.apache.thrift.TException {
-      // check for required fields
-      // check for sub-struct validity
-      if (success != null) {
-        success.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 getUserManagementServiceAccountAuthzToken_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public getUserManagementServiceAccountAuthzToken_resultStandardScheme getScheme() {
-        return new getUserManagementServiceAccountAuthzToken_resultStandardScheme();
-      }
-    }
-
-    private static class getUserManagementServiceAccountAuthzToken_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserManagementServiceAccountAuthzToken_result> {
-
-      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserManagementServiceAccountAuthzToken_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.STRUCT) {
-                struct.success = new org.apache.custos.commons.model.security.AuthzToken();
-                struct.success.read(iprot);
-                struct.setSuccessIsSet(true);
-              } else { 
-                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-              }
-              break;
-            case 1: // AE
-              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
-                struct.ae.read(iprot);
-                struct.setAeIsSet(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, getUserManagementServiceAccountAuthzToken_result struct) throws org.apache.thrift.TException {
-        struct.validate();
-
-        oprot.writeStructBegin(STRUCT_DESC);
-        if (struct.success != null) {
-          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
-          struct.success.write(oprot);
-          oprot.writeFieldEnd();
-        }
-        if (struct.ae != null) {
-          oprot.writeFieldBegin(AE_FIELD_DESC);
-          struct.ae.write(oprot);
-          oprot.writeFieldEnd();
-        }
-        oprot.writeFieldStop();
-        oprot.writeStructEnd();
-      }
-
-    }
-
-    private static class getUserManagementServiceAccountAuthzToken_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-      public getUserManagementServiceAccountAuthzToken_resultTupleScheme getScheme() {
-        return new getUserManagementServiceAccountAuthzToken_resultTupleScheme();
-      }
-    }
-
-    private static class getUserManagementServiceAccountAuthzToken_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserManagementServiceAccountAuthzToken_result> {
-
-      @Override
-      public void write(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_result struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        java.util.BitSet optionals = new java.util.BitSet();
-        if (struct.isSetSuccess()) {
-          optionals.set(0);
-        }
-        if (struct.isSetAe()) {
-          optionals.set(1);
-        }
-        oprot.writeBitSet(optionals, 2);
-        if (struct.isSetSuccess()) {
-          struct.success.write(oprot);
-        }
-        if (struct.isSetAe()) {
-          struct.ae.write(oprot);
-        }
-      }
-
-      @Override
-      public void read(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_result struct) throws org.apache.thrift.TException {
-        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        java.util.BitSet incoming = iprot.readBitSet(2);
-        if (incoming.get(0)) {
-          struct.success = new org.apache.custos.commons.model.security.AuthzToken();
-          struct.success.read(iprot);
-          struct.setSuccessIsSet(true);
-        }
-        if (incoming.get(1)) {
-          struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
-          struct.ae.read(iprot);
-          struct.setAeIsSet(true);
-        }
-      }
-    }
-
-    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-    }
-  }
-
-}
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
index 9c4b981..551cead 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
@@ -16,7 +16,7 @@ public class CustosAuthenticationService {
 
     public org.apache.custos.commons.model.security.UserInfo getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
 
-    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
 
   }
 
@@ -26,7 +26,7 @@ public class CustosAuthenticationService {
 
     public void getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException;
 
-    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException;
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException;
 
   }
 
@@ -102,17 +102,19 @@ public class CustosAuthenticationService {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserInfoFromAuthzToken failed: unknown result");
     }
 
-    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
     {
-      send_getUserManagementServiceAccountAuthzToken(authzToken, gatewayId);
+      send_getUserManagementServiceAccountAuthzToken(authzToken, gatewayId, clientId, clientSecret);
       return recv_getUserManagementServiceAccountAuthzToken();
     }
 
-    public void send_getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.thrift.TException
+    public void send_getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws org.apache.thrift.TException
     {
       getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
       args.setAuthzToken(authzToken);
       args.setGatewayId(gatewayId);
+      args.setClientId(clientId);
+      args.setClientSecret(clientSecret);
       sendBase("getUserManagementServiceAccountAuthzToken", args);
     }
 
@@ -211,9 +213,9 @@ public class CustosAuthenticationService {
       }
     }
 
-    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      getUserManagementServiceAccountAuthzToken_call method_call = new getUserManagementServiceAccountAuthzToken_call(authzToken, gatewayId, resultHandler, this, ___protocolFactory, ___transport);
+      getUserManagementServiceAccountAuthzToken_call method_call = new getUserManagementServiceAccountAuthzToken_call(authzToken, gatewayId, clientId, clientSecret, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
@@ -221,10 +223,14 @@ public class CustosAuthenticationService {
     public static class getUserManagementServiceAccountAuthzToken_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.commons.model.security.AuthzToken> {
       private org.apache.custos.commons.model.security.AuthzToken authzToken;
       private String gatewayId;
-      public getUserManagementServiceAccountAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> 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 String clientId;
+      private String clientSecret;
+      public getUserManagementServiceAccountAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, String clientId, String clientSecret, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> 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.clientId = clientId;
+        this.clientSecret = clientSecret;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -232,6 +238,8 @@ public class CustosAuthenticationService {
         getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
         args.setAuthzToken(authzToken);
         args.setGatewayId(gatewayId);
+        args.setClientId(clientId);
+        args.setClientSecret(clientSecret);
         args.write(prot);
         prot.writeMessageEnd();
       }
@@ -345,7 +353,7 @@ public class CustosAuthenticationService {
       public getUserManagementServiceAccountAuthzToken_result getResult(I iface, getUserManagementServiceAccountAuthzToken_args args) throws org.apache.thrift.TException {
         getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
         try {
-          result.success = iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId);
+          result.success = iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId, args.clientId, args.clientSecret);
         } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
           result.ae = ae;
         }
@@ -449,7 +457,7 @@ public class CustosAuthenticationService {
 
       public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo>() { 
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo>() {
           public void onComplete(org.apache.custos.commons.model.security.UserInfo o) {
             getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
             result.success = o;
@@ -514,7 +522,7 @@ public class CustosAuthenticationService {
 
       public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken>() { 
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken>() {
           public void onComplete(org.apache.custos.commons.model.security.AuthzToken o) {
             getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
             result.success = o;
@@ -564,7 +572,7 @@ public class CustosAuthenticationService {
       }
 
       public void start(I iface, getUserManagementServiceAccountAuthzToken_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
-        iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId,resultHandler);
+        iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId, args.clientId, args.clientSecret,resultHandler);
       }
     }
 
@@ -644,8 +652,8 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.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.custos.commons.model.security.AuthzToken.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_args.class, metaDataMap);
     }
@@ -654,7 +662,7 @@ public class CustosAuthenticationService {
     }
 
     public isUserAuthenticated_args(
-      org.apache.custos.commons.model.security.AuthzToken authzToken)
+            org.apache.custos.commons.model.security.AuthzToken authzToken)
     {
       this();
       this.authzToken = authzToken;
@@ -705,13 +713,13 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-      case AUTHZ_TOKEN:
-        if (value == null) {
-          unsetAuthzToken();
-        } else {
-          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
-        }
-        break;
+        case AUTHZ_TOKEN:
+          if (value == null) {
+            unsetAuthzToken();
+          } else {
+            setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+          }
+          break;
 
       }
     }
@@ -719,8 +727,8 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-      case AUTHZ_TOKEN:
-        return getAuthzToken();
+        case AUTHZ_TOKEN:
+          return getAuthzToken();
 
       }
       throw new IllegalStateException();
@@ -733,8 +741,8 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-      case AUTHZ_TOKEN:
-        return isSetAuthzToken();
+        case AUTHZ_TOKEN:
+          return isSetAuthzToken();
       }
       throw new IllegalStateException();
     }
@@ -868,7 +876,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
             break;
           }
           switch (schemeField.id) {
@@ -877,7 +885,7 @@ public class CustosAuthenticationService {
                 struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
-              } else { 
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -1016,10 +1024,10 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.BOOL)));
-      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.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.BOOL)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT,
+              new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_result.class, metaDataMap);
     }
@@ -1028,8 +1036,8 @@ public class CustosAuthenticationService {
     }
 
     public isUserAuthenticated_result(
-      boolean success,
-      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+            boolean success,
+            org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
     {
       this();
       this.success = success;
@@ -1109,21 +1117,21 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-      case SUCCESS:
-        if (value == null) {
-          unsetSuccess();
-        } else {
-          setSuccess((Boolean)value);
-        }
-        break;
+        case SUCCESS:
+          if (value == null) {
+            unsetSuccess();
+          } else {
+            setSuccess((Boolean)value);
+          }
+          break;
 
-      case AE:
-        if (value == null) {
-          unsetAe();
-        } else {
-          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
-        }
-        break;
+        case AE:
+          if (value == null) {
+            unsetAe();
+          } else {
+            setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+          }
+          break;
 
       }
     }
@@ -1131,11 +1139,11 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-      case SUCCESS:
-        return isSuccess();
+        case SUCCESS:
+          return isSuccess();
 
-      case AE:
-        return getAe();
+        case AE:
+          return getAe();
 
       }
       throw new IllegalStateException();
@@ -1148,10 +1156,10 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-      case SUCCESS:
-        return isSetSuccess();
-      case AE:
-        return isSetAe();
+        case SUCCESS:
+          return isSetSuccess();
+        case AE:
+          return isSetAe();
       }
       throw new IllegalStateException();
     }
@@ -1247,7 +1255,7 @@ public class CustosAuthenticationService {
 
     public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
       scheme(oprot).write(oprot, this);
-      }
+    }
 
     @Override
     public String toString() {
@@ -1306,7 +1314,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
             break;
           }
           switch (schemeField.id) {
@@ -1314,7 +1322,7 @@ public class CustosAuthenticationService {
               if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                 struct.success = iprot.readBool();
                 struct.setSuccessIsSet(true);
-              } else { 
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -1323,7 +1331,7 @@ public class CustosAuthenticationService {
                 struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
-              } else { 
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -1480,8 +1488,8 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.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.custos.commons.model.security.AuthzToken.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_args.class, metaDataMap);
     }
@@ -1490,7 +1498,7 @@ public class CustosAuthenticationService {
     }
 
     public getUserInfoFromAuthzToken_args(
-      org.apache.custos.commons.model.security.AuthzToken authzToken)
+            org.apache.custos.commons.model.security.AuthzToken authzToken)
     {
       this();
       this.authzToken = authzToken;
@@ -1541,13 +1549,13 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-      case AUTHZ_TOKEN:
-        if (value == null) {
-          unsetAuthzToken();
-        } else {
-          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
-        }
-        break;
+        case AUTHZ_TOKEN:
+          if (value == null) {
+            unsetAuthzToken();
+          } else {
+            setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+          }
+          break;
 
       }
     }
@@ -1555,8 +1563,8 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-      case AUTHZ_TOKEN:
-        return getAuthzToken();
+        case AUTHZ_TOKEN:
+          return getAuthzToken();
 
       }
       throw new IllegalStateException();
@@ -1569,8 +1577,8 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-      case AUTHZ_TOKEN:
-        return isSetAuthzToken();
+        case AUTHZ_TOKEN:
+          return isSetAuthzToken();
       }
       throw new IllegalStateException();
     }
@@ -1704,7 +1712,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
             break;
           }
           switch (schemeField.id) {
@@ -1713,7 +1721,7 @@ public class CustosAuthenticationService {
                 struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
-              } else { 
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -1850,10 +1858,10 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.UserInfo.class)));
-      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
+              new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.UserInfo.class)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT,
+              new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_result.class, metaDataMap);
     }
@@ -1862,8 +1870,8 @@ public class CustosAuthenticationService {
     }
 
     public getUserInfoFromAuthzToken_result(
-      org.apache.custos.commons.model.security.UserInfo success,
-      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+            org.apache.custos.commons.model.security.UserInfo success,
+            org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
     {
       this();
       this.success = success;
@@ -1944,21 +1952,21 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-      case SUCCESS:
-        if (value == null) {
-          unsetSuccess();
-        } else {
-          setSuccess((org.apache.custos.commons.model.security.UserInfo)value);
-        }
-        break;
+        case SUCCESS:
+          if (value == null) {
+            unsetSuccess();
+          } else {
+            setSuccess((org.apache.custos.commons.model.security.UserInfo)value);
+          }
+          break;
 
-      case AE:
-        if (value == null) {
-          unsetAe();
-        } else {
-          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
-        }
-        break;
+        case AE:
+          if (value == null) {
+            unsetAe();
+          } else {
+            setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+          }
+          break;
 
       }
     }
@@ -1966,11 +1974,11 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-      case SUCCESS:
-        return getSuccess();
+        case SUCCESS:
+          return getSuccess();
 
-      case AE:
-        return getAe();
+        case AE:
+          return getAe();
 
       }
       throw new IllegalStateException();
@@ -1983,10 +1991,10 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-      case SUCCESS:
-        return isSetSuccess();
-      case AE:
-        return isSetAe();
+        case SUCCESS:
+          return isSetSuccess();
+        case AE:
+          return isSetAe();
       }
       throw new IllegalStateException();
     }
@@ -2084,7 +2092,7 @@ public class CustosAuthenticationService {
 
     public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
       scheme(oprot).write(oprot, this);
-      }
+    }
 
     @Override
     public String toString() {
@@ -2148,7 +2156,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
             break;
           }
           switch (schemeField.id) {
@@ -2157,7 +2165,7 @@ public class CustosAuthenticationService {
                 struct.success = new org.apache.custos.commons.model.security.UserInfo();
                 struct.success.read(iprot);
                 struct.setSuccessIsSet(true);
-              } else { 
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -2166,7 +2174,7 @@ public class CustosAuthenticationService {
                 struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
-              } else { 
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -2255,17 +2263,23 @@ public class CustosAuthenticationService {
 
     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 CLIENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("clientId", org.apache.thrift.protocol.TType.STRING, (short)3);
+    private static final org.apache.thrift.protocol.TField CLIENT_SECRET_FIELD_DESC = new org.apache.thrift.protocol.TField("clientSecret", org.apache.thrift.protocol.TType.STRING, (short)4);
 
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsTupleSchemeFactory();
 
     public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
     public @org.apache.thrift.annotation.Nullable String gatewayId; // required
+    public @org.apache.thrift.annotation.Nullable String clientId; // required
+    public @org.apache.thrift.annotation.Nullable String clientSecret; // 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");
+      GATEWAY_ID((short)2, "gatewayId"),
+      CLIENT_ID((short)3, "clientId"),
+      CLIENT_SECRET((short)4, "clientSecret");
 
       private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
@@ -2285,6 +2299,10 @@ public class CustosAuthenticationService {
             return AUTHZ_TOKEN;
           case 2: // GATEWAY_ID
             return GATEWAY_ID;
+          case 3: // CLIENT_ID
+            return CLIENT_ID;
+          case 4: // CLIENT_SECRET
+            return CLIENT_SECRET;
           default:
             return null;
         }
@@ -2329,10 +2347,14 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.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.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.custos.commons.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.CLIENT_ID, new org.apache.thrift.meta_data.FieldMetaData("clientId", org.apache.thrift.TFieldRequirementType.REQUIRED,
+              new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+      tmpMap.put(_Fields.CLIENT_SECRET, new org.apache.thrift.meta_data.FieldMetaData("clientSecret", org.apache.thrift.TFieldRequirementType.REQUIRED,
+              new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_args.class, metaDataMap);
     }
@@ -2341,12 +2363,16 @@ public class CustosAuthenticationService {
     }
 
     public getUserManagementServiceAccountAuthzToken_args(
-      org.apache.custos.commons.model.security.AuthzToken authzToken,
-      String gatewayId)
+            org.apache.custos.commons.model.security.AuthzToken authzToken,
+            String gatewayId,
+            String clientId,
+            String clientSecret)
     {
       this();
       this.authzToken = authzToken;
       this.gatewayId = gatewayId;
+      this.clientId = clientId;
+      this.clientSecret = clientSecret;
     }
 
     /**
@@ -2359,6 +2385,12 @@ public class CustosAuthenticationService {
       if (other.isSetGatewayId()) {
         this.gatewayId = other.gatewayId;
       }
+      if (other.isSetClientId()) {
+        this.clientId = other.clientId;
+      }
+      if (other.isSetClientSecret()) {
+        this.clientSecret = other.clientSecret;
+      }
     }
 
     public getUserManagementServiceAccountAuthzToken_args deepCopy() {
@@ -2369,6 +2401,8 @@ public class CustosAuthenticationService {
     public void clear() {
       this.authzToken = null;
       this.gatewayId = null;
+      this.clientId = null;
+      this.clientSecret = null;
     }
 
     @org.apache.thrift.annotation.Nullable
@@ -2421,23 +2455,89 @@ public class CustosAuthenticationService {
       }
     }
 
+    @org.apache.thrift.annotation.Nullable
+    public String getClientId() {
+      return this.clientId;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args setClientId(@org.apache.thrift.annotation.Nullable String clientId) {
+      this.clientId = clientId;
+      return this;
+    }
+
+    public void unsetClientId() {
+      this.clientId = null;
+    }
+
+    /** Returns true if field clientId is set (has been assigned a value) and false otherwise */
+    public boolean isSetClientId() {
+      return this.clientId != null;
+    }
+
+    public void setClientIdIsSet(boolean value) {
+      if (!value) {
+        this.clientId = null;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getClientSecret() {
+      return this.clientSecret;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args setClientSecret(@org.apache.thrift.annotation.Nullable String clientSecret) {
+      this.clientSecret = clientSecret;
+      return this;
+    }
+
+    public void unsetClientSecret() {
+      this.clientSecret = null;
+    }
+
+    /** Returns true if field clientSecret is set (has been assigned a value) and false otherwise */
+    public boolean isSetClientSecret() {
+      return this.clientSecret != null;
+    }
+
+    public void setClientSecretIsSet(boolean value) {
+      if (!value) {
+        this.clientSecret = null;
+      }
+    }
+
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-      case AUTHZ_TOKEN:
-        if (value == null) {
-          unsetAuthzToken();
-        } else {
-          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
-        }
-        break;
+        case AUTHZ_TOKEN:
+          if (value == null) {
+            unsetAuthzToken();
+          } else {
+            setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+          }
+          break;
 
-      case GATEWAY_ID:
-        if (value == null) {
-          unsetGatewayId();
-        } else {
-          setGatewayId((String)value);
-        }
-        break;
+        case GATEWAY_ID:
+          if (value == null) {
+            unsetGatewayId();
+          } else {
+            setGatewayId((String)value);
+          }
+          break;
+
+        case CLIENT_ID:
+          if (value == null) {
+            unsetClientId();
+          } else {
+            setClientId((String)value);
+          }
+          break;
+
+        case CLIENT_SECRET:
+          if (value == null) {
+            unsetClientSecret();
+          } else {
+            setClientSecret((String)value);
+          }
+          break;
 
       }
     }
@@ -2445,11 +2545,17 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-      case AUTHZ_TOKEN:
-        return getAuthzToken();
+        case AUTHZ_TOKEN:
+          return getAuthzToken();
+
+        case GATEWAY_ID:
+          return getGatewayId();
 
-      case GATEWAY_ID:
-        return getGatewayId();
+        case CLIENT_ID:
+          return getClientId();
+
+        case CLIENT_SECRET:
+          return getClientSecret();
 
       }
       throw new IllegalStateException();
@@ -2462,10 +2568,14 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-      case AUTHZ_TOKEN:
-        return isSetAuthzToken();
-      case GATEWAY_ID:
-        return isSetGatewayId();
+        case AUTHZ_TOKEN:
+          return isSetAuthzToken();
+        case GATEWAY_ID:
+          return isSetGatewayId();
+        case CLIENT_ID:
+          return isSetClientId();
+        case CLIENT_SECRET:
+          return isSetClientSecret();
       }
       throw new IllegalStateException();
     }
@@ -2503,6 +2613,24 @@ public class CustosAuthenticationService {
           return false;
       }
 
+      boolean this_present_clientId = true && this.isSetClientId();
+      boolean that_present_clientId = true && that.isSetClientId();
+      if (this_present_clientId || that_present_clientId) {
+        if (!(this_present_clientId && that_present_clientId))
+          return false;
+        if (!this.clientId.equals(that.clientId))
+          return false;
+      }
+
+      boolean this_present_clientSecret = true && this.isSetClientSecret();
+      boolean that_present_clientSecret = true && that.isSetClientSecret();
+      if (this_present_clientSecret || that_present_clientSecret) {
+        if (!(this_present_clientSecret && that_present_clientSecret))
+          return false;
+        if (!this.clientSecret.equals(that.clientSecret))
+          return false;
+      }
+
       return true;
     }
 
@@ -2518,6 +2646,14 @@ public class CustosAuthenticationService {
       if (isSetGatewayId())
         hashCode = hashCode * 8191 + gatewayId.hashCode();
 
+      hashCode = hashCode * 8191 + ((isSetClientId()) ? 131071 : 524287);
+      if (isSetClientId())
+        hashCode = hashCode * 8191 + clientId.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetClientSecret()) ? 131071 : 524287);
+      if (isSetClientSecret())
+        hashCode = hashCode * 8191 + clientSecret.hashCode();
+
       return hashCode;
     }
 
@@ -2549,6 +2685,26 @@ public class CustosAuthenticationService {
           return lastComparison;
         }
       }
+      lastComparison = Boolean.valueOf(isSetClientId()).compareTo(other.isSetClientId());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetClientId()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientId, other.clientId);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      lastComparison = Boolean.valueOf(isSetClientSecret()).compareTo(other.isSetClientSecret());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetClientSecret()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.clientSecret, other.clientSecret);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
       return 0;
     }
 
@@ -2585,6 +2741,22 @@ public class CustosAuthenticationService {
         sb.append(this.gatewayId);
       }
       first = false;
+      if (!first) sb.append(", ");
+      sb.append("clientId:");
+      if (this.clientId == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.clientId);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("clientSecret:");
+      if (this.clientSecret == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.clientSecret);
+      }
+      first = false;
       sb.append(")");
       return sb.toString();
     }
@@ -2597,6 +2769,12 @@ public class CustosAuthenticationService {
       if (gatewayId == null) {
         throw new org.apache.thrift.protocol.TProtocolException("Required field 'gatewayId' was not present! Struct: " + toString());
       }
+      if (clientId == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientId' was not present! Struct: " + toString());
+      }
+      if (clientSecret == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'clientSecret' was not present! Struct: " + toString());
+      }
       // check for sub-struct validity
       if (authzToken != null) {
         authzToken.validate();
@@ -2633,7 +2811,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
             break;
           }
           switch (schemeField.id) {
@@ -2642,7 +2820,7 @@ public class CustosAuthenticationService {
                 struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
-              } else { 
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -2650,7 +2828,23 @@ public class CustosAuthenticationService {
               if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                 struct.gatewayId = iprot.readString();
                 struct.setGatewayIdIsSet(true);
-              } else { 
+              } else {
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 3: // CLIENT_ID
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+                struct.clientId = iprot.readString();
+                struct.setClientIdIsSet(true);
+              } else {
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 4: // CLIENT_SECRET
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+                struct.clientSecret = iprot.readString();
+                struct.setClientSecretIsSet(true);
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -2679,6 +2873,16 @@ public class CustosAuthenticationService {
           oprot.writeString(struct.gatewayId);
           oprot.writeFieldEnd();
         }
+        if (struct.clientId != null) {
+          oprot.writeFieldBegin(CLIENT_ID_FIELD_DESC);
+          oprot.writeString(struct.clientId);
+          oprot.writeFieldEnd();
+        }
+        if (struct.clientSecret != null) {
+          oprot.writeFieldBegin(CLIENT_SECRET_FIELD_DESC);
+          oprot.writeString(struct.clientSecret);
+          oprot.writeFieldEnd();
+        }
         oprot.writeFieldStop();
         oprot.writeStructEnd();
       }
@@ -2698,6 +2902,8 @@ public class CustosAuthenticationService {
         org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         struct.authzToken.write(oprot);
         oprot.writeString(struct.gatewayId);
+        oprot.writeString(struct.clientId);
+        oprot.writeString(struct.clientSecret);
       }
 
       @Override
@@ -2708,6 +2914,10 @@ public class CustosAuthenticationService {
         struct.setAuthzTokenIsSet(true);
         struct.gatewayId = iprot.readString();
         struct.setGatewayIdIsSet(true);
+        struct.clientId = iprot.readString();
+        struct.setClientIdIsSet(true);
+        struct.clientSecret = iprot.readString();
+        struct.setClientSecretIsSet(true);
       }
     }
 
@@ -2795,10 +3005,10 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
-      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
+              new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT,
+              new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_result.class, metaDataMap);
     }
@@ -2807,8 +3017,8 @@ public class CustosAuthenticationService {
     }
 
     public getUserManagementServiceAccountAuthzToken_result(
-      org.apache.custos.commons.model.security.AuthzToken success,
-      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+            org.apache.custos.commons.model.security.AuthzToken success,
+            org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
     {
       this();
       this.success = success;
@@ -2889,21 +3099,21 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-      case SUCCESS:
-        if (value == null) {
-          unsetSuccess();
-        } else {
-          setSuccess((org.apache.custos.commons.model.security.AuthzToken)value);
-        }
-        break;
+        case SUCCESS:
+          if (value == null) {
+            unsetSuccess();
+          } else {
+            setSuccess((org.apache.custos.commons.model.security.AuthzToken)value);
+          }
+          break;
 
-      case AE:
-        if (value == null) {
-          unsetAe();
-        } else {
-          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
-        }
-        break;
+        case AE:
+          if (value == null) {
+            unsetAe();
+          } else {
+            setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+          }
+          break;
 
       }
     }
@@ -2911,11 +3121,11 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-      case SUCCESS:
-        return getSuccess();
+        case SUCCESS:
+          return getSuccess();
 
-      case AE:
-        return getAe();
+        case AE:
+          return getAe();
 
       }
       throw new IllegalStateException();
@@ -2928,10 +3138,10 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-      case SUCCESS:
-        return isSetSuccess();
-      case AE:
-        return isSetAe();
+        case SUCCESS:
+          return isSetSuccess();
+        case AE:
+          return isSetAe();
       }
       throw new IllegalStateException();
     }
@@ -3029,7 +3239,7 @@ public class CustosAuthenticationService {
 
     public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
       scheme(oprot).write(oprot, this);
-      }
+    }
 
     @Override
     public String toString() {
@@ -3093,7 +3303,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
             break;
           }
           switch (schemeField.id) {
@@ -3102,7 +3312,7 @@ public class CustosAuthenticationService {
                 struct.success = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.success.read(iprot);
                 struct.setSuccessIsSet(true);
-              } else { 
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -3111,7 +3321,7 @@ public class CustosAuthenticationService {
                 struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
-              } else { 
+              } else {
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -3195,4 +3405,4 @@ public class CustosAuthenticationService {
     }
   }
 
-}
+}
\ No newline at end of file
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
index abb073a..1c078e0 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
@@ -4,7 +4,6 @@ import org.apache.custos.authentication.cpi.CustosAuthenticationService;
 import org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException;
 import org.apache.custos.commons.model.security.UserInfo;
 import org.apache.custos.commons.exceptions.CustosSecurityException;
-import org.apache.custos.commons.model.error.AuthenticationException;
 import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.security.manager.CustosSecurityManager;
@@ -16,7 +15,7 @@ public class CustosAuthenticationHandler implements CustosAuthenticationService.
     private final static Logger logger = LoggerFactory.getLogger(CustosAuthenticationHandler.class);
 
     @Override
-    public boolean isUserAuthenticated(AuthzToken authzToken) throws AuthenticationException {
+    public boolean isUserAuthenticated(AuthzToken authzToken) throws CustosAuthenticationServiceException {
         try {
             CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
             boolean isAuth = securityManager.isUserAuthenticated(authzToken);
@@ -25,11 +24,11 @@ public class CustosAuthenticationHandler implements CustosAuthenticationService.
                     return isAuth;
                 }
                 else{
-                    throw new AuthenticationException("User is not authenticated.");
+                    throw new CustosAuthenticationServiceException("User is not authenticated.");
                 }
         } catch (CustosSecurityException e) {
             logger.error(e.getMessage(), e);
-            throw new AuthenticationException("Error in authenticating.");
+            throw new CustosAuthenticationServiceException("Error in authenticating.");
         }
     }
     @Override
@@ -44,10 +43,10 @@ public class CustosAuthenticationHandler implements CustosAuthenticationService.
         }
     }
     @Override
-    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosAuthenticationServiceException {
+    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws CustosAuthenticationServiceException {
         try{
             CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
-            AuthzToken managementServiceAccountAuthzToken = securityManager.getUserManagementServiceAccountAuthzToken(authzToken, gatewayId);
+            AuthzToken managementServiceAccountAuthzToken = securityManager.getUserManagementServiceAccountAuthzToken(authzToken, gatewayId, clientId, clientSecret);
             return managementServiceAccountAuthzToken;
         }catch (CustosSecurityException e){
             logger.error(e.getMessage(), e);
diff --git a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
index 34aa7f9..054a5c1 100644
--- a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
+++ b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
@@ -2,7 +2,6 @@ package org.apache.custos.client.authentication.service;
 
 import org.apache.custos.authentication.cpi.CustosAuthenticationService;
 import org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException;
-import org.apache.custos.commons.model.error.AuthenticationException;
 import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.protocol.TMultiplexedProtocol;
 import org.apache.thrift.protocol.TProtocol;
@@ -11,6 +10,7 @@ import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 
 public class AuthenticationServiceClient {
+
     public static CustosAuthenticationService.Client createAuthenticationServiceClient(String serverHost, int serverPort)  throws CustosAuthenticationServiceException {
         try {
             TTransport transport = new TSocket(serverHost, serverPort);
diff --git a/custos-client/src/main/java/org/apache/custos/client/profile/service/CustosProfileServiceClientFactory.java b/custos-client/src/main/java/org/apache/custos/client/profile/service/CustosProfileServiceClientFactory.java
deleted file mode 100644
index 593be32..0000000
--- a/custos-client/src/main/java/org/apache/custos/client/profile/service/CustosProfileServiceClientFactory.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- *
- * 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.custos.client.profile.service;
-
-import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
-import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
-import org.apache.custos.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants;
-import org.apache.custos.profile.tenant.cpi.TenantProfileService;
-import org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException;
-import org.apache.custos.profile.tenant.cpi.profile_tenant_cpiConstants;
-import org.apache.custos.profile.user.cpi.UserProfileService;
-import org.apache.custos.profile.user.cpi.exception.UserProfileServiceException;
-import org.apache.custos.profile.user.cpi.profile_user_cpiConstants;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TMultiplexedProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
-
-/**
- * Created by goshenoy on 03/08/2017.
- */
-public class CustosProfileServiceClientFactory {
-    public static UserProfileService.Client createCustosUserProfileServiceClient(String serverHost, int serverPort)  throws UserProfileServiceException {
-        try {
-            TTransport transport = new TSocket(serverHost, serverPort);
-            transport.open();
-            TProtocol protocol = new TBinaryProtocol(transport);
-            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, profile_user_cpiConstants.USER_PROFILE_CPI_NAME);
-            return new UserProfileService.Client(multiplexedProtocol);
-        } catch (TTransportException e) {
-            throw new UserProfileServiceException(e.getMessage());
-        }
-    }
-
-    public static TenantProfileService.Client createCustosTenantProfileServiceClient(String serverHost, int serverPort) throws TenantProfileServiceException {
-        try {
-            TTransport transport = new TSocket(serverHost, serverPort);
-            transport.open();
-            TProtocol protocol = new TBinaryProtocol(transport);
-            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME);
-            return new TenantProfileService.Client(multiplexedProtocol);
-        } catch (TTransportException e) {
-            throw new TenantProfileServiceException(e.getMessage());
-        }
-    }
-
-    public static IamAdminServices.Client createCustosIamAdminServiceClient(String serverHost, int serverPort) throws IamAdminServicesException {
-        try {
-            TTransport transport = new TSocket(serverHost, serverPort);
-            transport.open();
-            TProtocol protocol = new TBinaryProtocol(transport);
-            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, iam_admin_services_cpiConstants.IAM_ADMIN_SERVICES_CPI_NAME);
-            return new IamAdminServices.Client(multiplexedProtocol);
-        } catch (TTransportException e) {
-            throw new IamAdminServicesException(e.getMessage());
-        }
-    }
-
-//    public static GroupManagerService.Client createGroupManagerServiceClient(String serverHost, int serverPort)  throws GroupManagerServiceException {
-//        try {
-//            TTransport transport = new TSocket(serverHost, serverPort);
-//            transport.open();
-//            TProtocol protocol = new TBinaryProtocol(transport);
-//            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, group_manager_cpiConstants.GROUP_MANAGER_CPI_NAME);
-//            return new GroupManagerService.Client(multiplexedProtocol);
-//        } catch (TTransportException e) {
-//            throw new GroupManagerServiceException(e.getMessage());
-//        }
-//    }
-}
\ No newline at end of file
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthenticationException.java b/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthenticationException.java
deleted file mode 100644
index 07ca704..0000000
--- a/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthenticationException.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/**
- * 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.10.0)
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- *  @generated
- */
-package org.apache.custos.commons.model.error;
-
-@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-/**
- * This exception is thrown for invalid sshKeyAuthentication requests.
- * 
- *  message: contains the cause of the authorization failure.
- */
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
-public class AuthenticationException extends org.apache.thrift.TException implements org.apache.thrift.TBase<AuthenticationException, AuthenticationException._Fields>, java.io.Serializable, Cloneable, Comparable<AuthenticationException> {
-  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthenticationException");
-
-  private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
-
-  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new AuthenticationExceptionStandardSchemeFactory();
-  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new AuthenticationExceptionTupleSchemeFactory();
-
-  private String message; // 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 {
-    MESSAGE((short)1, "message");
-
-    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-    static {
-      for (_Fields field : java.util.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: // MESSAGE
-          return MESSAGE;
-        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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-  static {
-    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthenticationException.class, metaDataMap);
-  }
-
-  public AuthenticationException() {
-  }
-
-  public AuthenticationException(
-    String message)
-  {
-    this();
-    this.message = message;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public AuthenticationException(AuthenticationException other) {
-    if (other.isSetMessage()) {
-      this.message = other.message;
-    }
-  }
-
-  public AuthenticationException deepCopy() {
-    return new AuthenticationException(this);
-  }
-
-  @Override
-  public void clear() {
-    this.message = null;
-  }
-
-  public String getMessage() {
-    return this.message;
-  }
-
-  public void setMessage(String message) {
-    this.message = message;
-  }
-
-  public void unsetMessage() {
-    this.message = null;
-  }
-
-  /** Returns true if field message is set (has been assigned a value) and false otherwise */
-  public boolean isSetMessage() {
-    return this.message != null;
-  }
-
-  public void setMessageIsSet(boolean value) {
-    if (!value) {
-      this.message = null;
-    }
-  }
-
-  public void setFieldValue(_Fields field, Object value) {
-    switch (field) {
-    case MESSAGE:
-      if (value == null) {
-        unsetMessage();
-      } else {
-        setMessage((String)value);
-      }
-      break;
-
-    }
-  }
-
-  public Object getFieldValue(_Fields field) {
-    switch (field) {
-    case MESSAGE:
-      return getMessage();
-
-    }
-    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 MESSAGE:
-      return isSetMessage();
-    }
-    throw new IllegalStateException();
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof AuthenticationException)
-      return this.equals((AuthenticationException)that);
-    return false;
-  }
-
-  public boolean equals(AuthenticationException that) {
-    if (that == null)
-      return false;
-    if (this == that)
-      return true;
-
-    boolean this_present_message = true && this.isSetMessage();
-    boolean that_present_message = true && that.isSetMessage();
-    if (this_present_message || that_present_message) {
-      if (!(this_present_message && that_present_message))
-        return false;
-      if (!this.message.equals(that.message))
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int hashCode = 1;
-
-    hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
-    if (isSetMessage())
-      hashCode = hashCode * 8191 + message.hashCode();
-
-    return hashCode;
-  }
-
-  @Override
-  public int compareTo(AuthenticationException other) {
-    if (!getClass().equals(other.getClass())) {
-      return getClass().getName().compareTo(other.getClass().getName());
-    }
-
-    int lastComparison = 0;
-
-    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetMessage()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
-      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 {
-    scheme(iprot).read(iprot, this);
-  }
-
-  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-    scheme(oprot).write(oprot, this);
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("AuthenticationException(");
-    boolean first = true;
-
-    sb.append("message:");
-    if (this.message == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.message);
-    }
-    first = false;
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public void validate() throws org.apache.thrift.TException {
-    // check for required fields
-    if (!isSetMessage()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' is unset! Struct:" + toString());
-    }
-
-    // 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 AuthenticationExceptionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public AuthenticationExceptionStandardScheme getScheme() {
-      return new AuthenticationExceptionStandardScheme();
-    }
-  }
-
-  private static class AuthenticationExceptionStandardScheme extends org.apache.thrift.scheme.StandardScheme<AuthenticationException> {
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot, AuthenticationException 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: // MESSAGE
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.message = iprot.readString();
-              struct.setMessageIsSet(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();
-      struct.validate();
-    }
-
-    public void write(org.apache.thrift.protocol.TProtocol oprot, AuthenticationException struct) throws org.apache.thrift.TException {
-      struct.validate();
-
-      oprot.writeStructBegin(STRUCT_DESC);
-      if (struct.message != null) {
-        oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
-        oprot.writeString(struct.message);
-        oprot.writeFieldEnd();
-      }
-      oprot.writeFieldStop();
-      oprot.writeStructEnd();
-    }
-
-  }
-
-  private static class AuthenticationExceptionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public AuthenticationExceptionTupleScheme getScheme() {
-      return new AuthenticationExceptionTupleScheme();
-    }
-  }
-
-  private static class AuthenticationExceptionTupleScheme extends org.apache.thrift.scheme.TupleScheme<AuthenticationException> {
-
-    @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, AuthenticationException struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      oprot.writeString(struct.message);
-    }
-
-    @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, AuthenticationException struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      struct.message = iprot.readString();
-      struct.setMessageIsSet(true);
-    }
-  }
-
-  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-  }
-}
-
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthorizationException.java b/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthorizationException.java
deleted file mode 100644
index dc84307..0000000
--- a/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthorizationException.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/**
- * 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.10.0)
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- *  @generated
- */
-package org.apache.custos.commons.model.error;
-
-@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-/**
- * This exception is thrown for invalid authorization requests such user does not have acces to an aplication or resource.
- * 
- *  message: contains the authorization failure message
- */
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
-public class AuthorizationException extends org.apache.thrift.TException implements org.apache.thrift.TBase<AuthorizationException, AuthorizationException._Fields>, java.io.Serializable, Cloneable, Comparable<AuthorizationException> {
-  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthorizationException");
-
-  private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
-
-  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new AuthorizationExceptionStandardSchemeFactory();
-  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new AuthorizationExceptionTupleSchemeFactory();
-
-  private String message; // 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 {
-    MESSAGE((short)1, "message");
-
-    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-    static {
-      for (_Fields field : java.util.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: // MESSAGE
-          return MESSAGE;
-        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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-  static {
-    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthorizationException.class, metaDataMap);
-  }
-
-  public AuthorizationException() {
-  }
-
-  public AuthorizationException(
-    String message)
-  {
-    this();
-    this.message = message;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public AuthorizationException(AuthorizationException other) {
-    if (other.isSetMessage()) {
-      this.message = other.message;
-    }
-  }
-
-  public AuthorizationException deepCopy() {
-    return new AuthorizationException(this);
-  }
-
-  @Override
-  public void clear() {
-    this.message = null;
-  }
-
-  public String getMessage() {
-    return this.message;
-  }
-
-  public void setMessage(String message) {
-    this.message = message;
-  }
-
-  public void unsetMessage() {
-    this.message = null;
-  }
-
-  /** Returns true if field message is set (has been assigned a value) and false otherwise */
-  public boolean isSetMessage() {
-    return this.message != null;
-  }
-
-  public void setMessageIsSet(boolean value) {
-    if (!value) {
-      this.message = null;
-    }
-  }
-
-  public void setFieldValue(_Fields field, Object value) {
-    switch (field) {
-    case MESSAGE:
-      if (value == null) {
-        unsetMessage();
-      } else {
-        setMessage((String)value);
-      }
-      break;
-
-    }
-  }
-
-  public Object getFieldValue(_Fields field) {
-    switch (field) {
-    case MESSAGE:
-      return getMessage();
-
-    }
-    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 MESSAGE:
-      return isSetMessage();
-    }
-    throw new IllegalStateException();
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof AuthorizationException)
-      return this.equals((AuthorizationException)that);
-    return false;
-  }
-
-  public boolean equals(AuthorizationException that) {
-    if (that == null)
-      return false;
-    if (this == that)
-      return true;
-
-    boolean this_present_message = true && this.isSetMessage();
-    boolean that_present_message = true && that.isSetMessage();
-    if (this_present_message || that_present_message) {
-      if (!(this_present_message && that_present_message))
-        return false;
-      if (!this.message.equals(that.message))
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int hashCode = 1;
-
-    hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
-    if (isSetMessage())
-      hashCode = hashCode * 8191 + message.hashCode();
-
-    return hashCode;
-  }
-
-  @Override
-  public int compareTo(AuthorizationException other) {
-    if (!getClass().equals(other.getClass())) {
-      return getClass().getName().compareTo(other.getClass().getName());
-    }
-
-    int lastComparison = 0;
-
-    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetMessage()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
-      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 {
-    scheme(iprot).read(iprot, this);
-  }
-
-  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-    scheme(oprot).write(oprot, this);
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("AuthorizationException(");
-    boolean first = true;
-
-    sb.append("message:");
-    if (this.message == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.message);
-    }
-    first = false;
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public void validate() throws org.apache.thrift.TException {
-    // check for required fields
-    if (!isSetMessage()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' is unset! Struct:" + toString());
-    }
-
-    // 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 AuthorizationExceptionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public AuthorizationExceptionStandardScheme getScheme() {
-      return new AuthorizationExceptionStandardScheme();
-    }
-  }
-
-  private static class AuthorizationExceptionStandardScheme extends org.apache.thrift.scheme.StandardScheme<AuthorizationException> {
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot, AuthorizationException 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: // MESSAGE
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.message = iprot.readString();
-              struct.setMessageIsSet(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();
-      struct.validate();
-    }
-
-    public void write(org.apache.thrift.protocol.TProtocol oprot, AuthorizationException struct) throws org.apache.thrift.TException {
-      struct.validate();
-
-      oprot.writeStructBegin(STRUCT_DESC);
-      if (struct.message != null) {
-        oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
-        oprot.writeString(struct.message);
-        oprot.writeFieldEnd();
-      }
-      oprot.writeFieldStop();
-      oprot.writeStructEnd();
-    }
-
-  }
-
-  private static class AuthorizationExceptionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public AuthorizationExceptionTupleScheme getScheme() {
-      return new AuthorizationExceptionTupleScheme();
-    }
-  }
-
-  private static class AuthorizationExceptionTupleScheme extends org.apache.thrift.scheme.TupleScheme<AuthorizationException> {
-
-    @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, AuthorizationException struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      oprot.writeString(struct.message);
-    }
-
-    @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, AuthorizationException struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      struct.message = iprot.readString();
-      struct.setMessageIsSet(true);
-    }
-  }
-
-  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-  }
-}
-
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
index 9c28e25..2233478 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
@@ -23,18 +23,6 @@ public class ApplicationSettings {
     protected static final String TRUST_STORE_PASSWORD="trust.store.password";
     private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
     protected Properties properties = new Properties();
-    // Profile Service Constants
-    public static final String PROFILE_SERVICE_SERVER_HOST = "profile.service.server.host";
-    public static final String PROFILE_SERVICE_SERVER_PORT = "profile.service.server.port";
-
-    // Iam Server Constants
-    public static final String IAM_SERVER_URL = "iam.server.url";
-    public static final String IAM_SERVER_SUPER_ADMIN_USERNAME = "iam.server.super.admin.username";
-    public static final String IAM_SERVER_SUPER_ADMIN_PASSWORD = "iam.server.super.admin.password";
-
-    //User Profile constant
-    public static final String USER_PROFILE_SERVER_HOST = "user.profile.server.host";
-    public static final String USER_PROFILE_SERVER_PORT = "user.profile.server.port";
 
     // Authentication service constants
     public static final String AUTHENTICATION_SERVICE_SERVER_PORT = "custos.authentication.server.port";
@@ -180,14 +168,4 @@ public class ApplicationSettings {
     public static String getTrustStorePassword() throws ApplicationSettingsException {
         return getSetting(TRUST_STORE_PASSWORD);
     }
-    public static String getIamServerUrl() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.IAM_SERVER_URL);
-    }
-    public static String getProfileServiceServerHost() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_HOST);
-    }
-
-    public static String getProfileServiceServerPort() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_PORT);
-    }
 }
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
index 1325f46..306c6be 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
@@ -25,16 +25,12 @@ package org.apache.custos.commons.utils;
 public final class Constants {
     public static final String IN_MEMORY_CACHE_SIZE = "in.memory.cache.size";
     public static final String AUTHZ_CACHE_MANAGER_CLASS = "authz.cache.manager.class";
-    public static final String API_METHOD_NAME = "api.method.name";
-    public static final String IS_API_SECURED = "api.secured";
-    public static final String AUTHORIZATION_POLICY_NAME = "authorization.policy";
     public static final String SECURITY_MANAGER_CLASS = "security.manager.class";
     public static final String AUTHZ_CACHE_ENABLED = "authz.cache.enabled";
 
     //Names of the attributes that could be passed in the AuthzToken's claims map.
     public static final String USER_NAME = "userName";
     public static final String GATEWAY_ID = "gatewayID";
-    public static final String IDENTITY_SERVER_TENANT = "identityServerTenant";
 
     //constants in XACML authorization response.
     public static final String PERMIT = "Permit";
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitConfig.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitConfig.java
deleted file mode 100644
index 123541a..0000000
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitConfig.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.custos.commons.utils;
-
-public interface DBInitConfig {
-    JDBCConfig getJDBCConfig();
-
-    String getDBInitScriptPrefix();
-
-    String getCheckTableName();
-
-    default void postInit() {
-
-    }
-}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitializer.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitializer.java
deleted file mode 100644
index 6e2038c..0000000
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitializer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.custos.commons.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Connection;
-
-public class DBInitializer {
-    private static final Logger logger = LoggerFactory.getLogger(DBInitializer.class);
-
-    private JDBCConfig jdbcConfig;
-    private String initScriptPrefix;
-    private String checkTableName;
-
-    public DBInitializer(JDBCConfig jdbcConfig, String initScriptPrefix, String checkTableName) {
-        this.jdbcConfig = jdbcConfig;
-        this.initScriptPrefix = initScriptPrefix;
-        this.checkTableName = checkTableName;
-    }
-
-    public static void initializeDB(DBInitConfig dbInitConfig) {
-
-        JDBCConfig jdbcConfig = dbInitConfig.getJDBCConfig();
-        DBInitializer dbInitializer = new DBInitializer(jdbcConfig, dbInitConfig.getDBInitScriptPrefix(), dbInitConfig.getCheckTableName());
-        dbInitializer.initializeDB();
-        dbInitConfig.postInit();
-    }
-
-    public void initializeDB() {
-        // Create connection
-        Connection conn = null;
-        try {
-            DBUtil dbUtil = new DBUtil(jdbcConfig);
-            conn = dbUtil.getConnection();
-            if (!DatabaseCreator.isDatabaseStructureCreated(checkTableName, conn)) {
-                DatabaseCreator.createRegistryDatabase(initScriptPrefix, conn);
-                logger.info("New Database created from " + initScriptPrefix + " !!!");
-            } else {
-                logger.info("Table " + checkTableName + " already exists. Skipping database init script " + initScriptPrefix);
-            }
-
-        } catch (Exception e) {
-            throw new RuntimeException("Failed to initialize database for " + initScriptPrefix, e);
-        } finally {
-            if (conn != null) {
-                DBUtil.cleanup(conn);
-            }
-        }
-
-    }
-}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBUtil.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBUtil.java
deleted file mode 100644
index bfac5d7..0000000
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBUtil.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/**
- *
- * 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.custos.commons.utils;
-
-import org.apache.commons.dbcp.BasicDataSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.sql.DataSource;
-import java.sql.*;
-import java.util.Properties;
-
-/**
- * Database lookup. Abstracts out JDBC operations.
- */
-public class DBUtil {
-
-    private String jdbcUrl;
-    private String databaseUserName;
-    private String databasePassword;
-    private String driverName;
-
-    protected static Logger log = LoggerFactory.getLogger(DBUtil.class);
-
-    private Properties properties;
-
-    public DBUtil(String jdbcUrl, String userName, String password, String driver) throws InstantiationException,
-            IllegalAccessException, ClassNotFoundException {
-
-        this.jdbcUrl = jdbcUrl;
-        this.databaseUserName = userName;
-        this.databasePassword = password;
-        this.driverName = driver;
-
-        init();
-    }
-
-    public DBUtil(JDBCConfig jdbcConfig) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
-        this(jdbcConfig.getURL(), jdbcConfig.getUser(), jdbcConfig.getPassword(), jdbcConfig.getDriver());
-    }
-
-    /**
-     * Initializes and load driver. Must be called this before calling anyother method.
-     * 
-     * @throws ClassNotFoundException
-     *             If DB driver is not found.
-     * @throws InstantiationException
-     *             If unable to create driver class.
-     * @throws IllegalAccessException
-     *             If security does not allow users to instantiate driver object.
-     */
-    private void init() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
-        properties = new Properties();
-
-        properties.put("user", databaseUserName);
-        properties.put("password", databasePassword);
-        properties.put("characterEncoding", "ISO-8859-1");
-        properties.put("useUnicode", "true");
-
-        loadDriver();
-    }
-
-    /**
-     * Generic method to query values in the database.
-     * 
-     * @param tableName
-     *            Table name to query
-     * @param selectColumn
-     *            The column selecting
-     * @param whereValue
-     *            The condition query
-     * @return The value appropriate to the query.
-     * @throws SQLException
-     *             If an error occurred while querying
-     */
-    public String getMatchingColumnValue(String tableName, String selectColumn, String whereValue) throws SQLException {
-        return getMatchingColumnValue(tableName, selectColumn, selectColumn, whereValue);
-    }
-
-    /**
-     * Generic method to query values in the database.
-     * 
-     * @param tableName
-     *            Table name to query
-     * @param selectColumn
-     *            The column selecting
-     * @param whereColumn
-     *            The column which condition should apply
-     * @param whereValue
-     *            The condition query
-     * @return The value appropriate to the query.
-     * @throws SQLException
-     *             If an error occurred while querying
-     */
-    public String getMatchingColumnValue(String tableName, String selectColumn, String whereColumn, String whereValue)
-            throws SQLException {
-
-        StringBuilder stringBuilder = new StringBuilder();
-
-        stringBuilder.append("SELECT ").append(selectColumn).append(" FROM ").append(tableName).append(" WHERE ")
-                .append(whereColumn).append(" = ?");
-
-        String sql = stringBuilder.toString();
-
-        Connection connection = getConnection();
-
-        PreparedStatement ps = connection.prepareStatement(sql);
-        ResultSet rs = null;
-
-        try {
-            ps.setString(1, whereValue);
-            rs = ps.executeQuery();
-
-            if (rs.next()) {
-                return rs.getString(1);
-            }
-
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-
-                ps.close();
-                connection.close();
-
-            } catch (Exception ignore) {
-                log.error("An error occurred while closing database connections ", ignore);
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Create table utility method.
-     * 
-     * @param sql
-     *            SQL to be executed.
-     * @throws SQLException
-     *             If an error occurred while creating the table.
-     */
-    public void executeSQL(String sql) throws SQLException {
-
-        Connection connection = getConnection();
-
-        PreparedStatement ps = connection.prepareStatement(sql);
-
-        try {
-            ps.executeUpdate();
-            connection.commit();
-        } finally {
-            try {
-                if (ps != null) {
-                    ps.close();
-                }
-
-                connection.close();
-
-            } catch (Exception ignore) {
-                log.error("An error occurred while closing database connections ", ignore);
-            }
-        }
-
-    }
-
-    private void loadDriver() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
-        Class.forName(driverName).newInstance();
-    }
-
-    /**
-     * Gets a new DBCP data source.
-     * 
-     * @return A new data source.
-     */
-    public DataSource getDataSource() {
-        BasicDataSource ds = new BasicDataSource();
-        ds.setDriverClassName(this.driverName);
-        ds.setUsername(this.databaseUserName);
-        ds.setPassword(this.databasePassword);
-        ds.setUrl(this.jdbcUrl);
-
-        return ds;
-    }
-
-    /**
-     * Creates a new JDBC connections based on provided DBCP properties.
-     * 
-     * @return A new DB connection.
-     * @throws SQLException
-     *             If an error occurred while creating the connection.
-     */
-    public Connection getConnection() throws SQLException {
-        Connection connection = DriverManager.getConnection(jdbcUrl, properties);
-        connection.setAutoCommit(false);
-        return connection;
-    }
-
-    /**
-     * Utility method to close statements and connections.
-     * 
-     * @param preparedStatement
-     *            The prepared statement to close.
-     * @param connection
-     *            The connection to close.
-     */
-    public static void cleanup(PreparedStatement preparedStatement, Connection connection) {
-        if (preparedStatement != null) {
-            try {
-                preparedStatement.close();
-            } catch (SQLException e) {
-                log.error("Error closing prepared statement.", e);
-            }
-        }
-        cleanup(connection);
-    }
-
-    /**
-     * Utility method to close statements and connections.
-     *
-     * @param preparedStatement
-     *            The prepared statement to close.
-     */
-    public static void cleanup(PreparedStatement preparedStatement) {
-        if (preparedStatement != null) {
-            try {
-                preparedStatement.close();
-            } catch (SQLException e) {
-                log.error("Error closing prepared statement.", e);
-            }
-        }
-    }
-
-    /**
-     * Utility method to close statements and connections.
-     *
-     * @param preparedStatement
-     *            The prepared statement to close.
-     */
-    public static void cleanup(PreparedStatement preparedStatement, ResultSet resultSet) {
-        if (resultSet != null) {
-            try {
-                resultSet.close();
-            } catch (SQLException e) {
-                log.error("Error closing prepared statement.", e);
-            }
-        }
-
-        cleanup(preparedStatement);
-    }
-
-    /**
-     * Cleanup the connection.
-     * @param connection The connection to close.
-     */
-    public static void cleanup(Connection connection) {
-        if (connection != null) {
-            try {
-                if (connection.isClosed()) {
-                    return;
-                }
-                if (!connection.getAutoCommit()) {
-                    connection.rollback();
-                }
-                connection.close();
-            } catch (SQLException e) {
-                throw new RuntimeException("Error closing connection", e);
-            }
-        }
-    }
-
-    /**
-     * Mainly useful for tests.
-     * 
-     * @param tableName
-     *            The table name.
-     * @param connection
-     *            The connection to be used.
-     */
-    public static void truncate(String tableName, Connection connection) throws SQLException {
-
-        String sql = "delete from " + tableName;
-
-        PreparedStatement preparedStatement = connection.prepareStatement(sql);
-        preparedStatement.executeUpdate();
-
-        connection.commit();
-
-    }
-}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DatabaseCreator.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DatabaseCreator.java
deleted file mode 100644
index 539ccf4..0000000
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/DatabaseCreator.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * 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.custos.commons.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.sql.*;
-import java.util.StringTokenizer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * This class creates the database tables required for custos with default configuration this
- * class creates derby database in server mode. User can specify required database in appropriate
- * properties files.
- */
-public class DatabaseCreator {
-    private final static Logger logger = LoggerFactory.getLogger(DatabaseCreator.class);
-
-    public enum DatabaseType {
-        derby("(?i).*derby.*"), mysql("(?i).*(mysql|mariadb).*"), other("");
-
-        private String pattern;
-
-        private DatabaseType(String matchingPattern) {
-            this.pattern = matchingPattern;
-        }
-
-        public String getMatchingPattern() {
-            return this.pattern;
-        }
-    }
-
-    private static DatabaseType[] supportedDatabase = new DatabaseType[] { DatabaseType.derby, DatabaseType.mysql };
-
-    private static Logger log = LoggerFactory.getLogger(DatabaseCreator.class);
-    private static final String delimiter = ";";
-
-    /**
-     * Creates database
-     *
-     * @throws Exception
-     */
-    public static void createRegistryDatabase(String prefix, Connection conn) throws Exception {
-        createDatabase(prefix, conn);
-    }
-
-
-
-    /**
-     * Checks whether database tables are created by using select * on given table name
-     *
-     * @param tableName
-     *            Table which should be existed
-     * @return <code>true</core> if checkSQL is success, else <code>false</code> .
-     */
-    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
-        try {
-
-            log.debug("Running a query to test the database tables existence.");
-
-            // check whether the tables are already created with a query
-            Statement statement = null;
-            try {
-                statement = conn.createStatement();
-                ResultSet rs = statement.executeQuery("select * from " + tableName);
-                if (rs != null) {
-                    rs.close();
-                }
-            } finally {
-                try {
-                    if (statement != null) {
-                        statement.close();
-                    }
-                } catch (SQLException e) {
-                    return false;
-                }
-            }
-        } catch (SQLException e) {
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * executes given sql
-     *
-     * @param sql
-     * @throws Exception
-     */
-    private static void executeSQL(String sql, Connection conn) throws Exception {
-        // Check and ignore empty statements
-        if ("".equals(sql.trim())) {
-            return;
-        }
-
-        Statement statement = null;
-        try {
-            log.debug("SQL : " + sql);
-
-            boolean ret;
-            int updateCount = 0, updateCountTotal = 0;
-            statement = conn.createStatement();
-            ret = statement.execute(sql);
-            updateCount = statement.getUpdateCount();
-            do {
-                if (!ret) {
-                    if (updateCount != -1) {
-                        updateCountTotal += updateCount;
-                    }
-                }
-                ret = statement.getMoreResults();
-                if (ret) {
-                    updateCount = statement.getUpdateCount();
-                }
-            } while (ret);
-
-            log.debug(sql + " : " + updateCountTotal + " rows affected");
-
-            SQLWarning warning = conn.getWarnings();
-            while (warning != null) {
-                log.info(warning + " sql warning");
-                warning = warning.getNextWarning();
-            }
-            conn.clearWarnings();
-        } catch (SQLException e) {
-            if (e.getSQLState().equals("X0Y32")) {
-                // eliminating the table already exception for the derby
-                // database
-                log.info("Table Already Exists", e);
-            } else {
-                throw new Exception("Error occurred while executing : " + sql, e);
-            }
-        } finally {
-            if (statement != null) {
-                try {
-                    statement.close();
-                } catch (SQLException e) {
-                    log.error("Error occurred while closing result set.", e);
-                }
-            }
-        }
-    }
-
-    /**
-     * computes relatational database type using database name
-     *
-     * @return DatabaseType
-     * @throws Exception
-     *
-     */
-    public static DatabaseType getDatabaseType(Connection conn) throws Exception {
-        try {
-            if (conn != null && (!conn.isClosed())) {
-                DatabaseMetaData metaData = conn.getMetaData();
-                String databaseProductName = metaData.getDatabaseProductName();
-                return checkType(databaseProductName);
-            }
-        } catch (SQLException e) {
-            String msg = "Failed to create Airavata database." + e.getMessage();
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-        return DatabaseType.other;
-    }
-
-    /**
-     * Overloaded method with String input
-     *
-     * @return DatabaseType
-     * @throws Exception
-     *
-     */
-    public static DatabaseType getDatabaseType(String dbUrl) throws Exception {
-        return checkType(dbUrl);
-    }
-
-    private static DatabaseType checkType(String text) throws Exception {
-        try {
-            if (text != null) {
-                for (DatabaseType type : supportedDatabase) {
-                    if (text.matches(type.getMatchingPattern()))
-                        return type;
-                }
-            }
-            String msg = "Unsupported database: " + text
-                    + ". Database will not be created automatically by the custos. "
-                    + "Please create the database using appropriate database scripts for " + "the database.";
-            throw new Exception(msg);
-
-        } catch (SQLException e) {
-            String msg = "Failed to create custosdatabase." + e.getMessage();
-            log.error(msg, e);
-            throw new Exception(msg, e);
-        }
-    }
-
-    /**
-     * Get scripts location which is prefix + "-" + databaseType + ".sql"
-     *
-     * @param prefix
-     * @param databaseType
-     * @return script location
-     */
-    private static String getScriptLocation(String prefix, DatabaseType databaseType) {
-        String scriptName = prefix + "-" + databaseType + ".sql";
-        log.debug("Loading database script from :" + scriptName);
-        return  scriptName;
-    }
-
-    private static void createDatabase(String prefix, Connection conn) throws Exception {
-        Statement statement = null;
-        try {
-            conn.setAutoCommit(false);
-            statement = conn.createStatement();
-            executeSQLScript(getScriptLocation(prefix, DatabaseCreator.getDatabaseType(conn)), conn);
-            conn.commit();
-            log.debug("Tables are created successfully.");
-        } catch (SQLException e) {
-            String msg = "Failed to create database tables for custos resource store. " + e.getMessage();
-            log.error(msg, e);
-            conn.rollback();
-            throw new Exception(msg, e);
-        } finally {
-            conn.setAutoCommit(true);
-            try {
-                if (statement != null) {
-                    statement.close();
-                }
-            } catch (SQLException e) {
-                log.error("Failed to close statement.", e);
-            }
-        }
-    }
-
-    private static void executeSQLScript(String dbscriptName, Connection conn) throws Exception {
-        StringBuffer sql = new StringBuffer();
-        BufferedReader reader = null;
-
-        try {
-            InputStream is = DatabaseCreator.class.getClassLoader().getResourceAsStream(dbscriptName);
-            if(is == null) {
-                logger.info("Script file not found at " + dbscriptName + ". Uses default database script file");
-                DatabaseType databaseType = DatabaseCreator.getDatabaseType(conn);
-                is = DatabaseCreator.class.getClassLoader().getResourceAsStream(
-                        getDBScriptFileName(databaseType, dbscriptName)
-                );
-            }
-            reader = new BufferedReader(new InputStreamReader(is));
-            String line;
-            while ((line = reader.readLine()) != null) {
-                line = line.trim();
-                if (line.startsWith("//")) {
-                    continue;
-                }
-                if (line.startsWith("--")) {
-                    continue;
-                }
-                StringTokenizer st = new StringTokenizer(line);
-                if (st.hasMoreTokens()) {
-                    String token = st.nextToken();
-                    if ("REM".equalsIgnoreCase(token)) {
-                        continue;
-                    }
-                }
-                sql.append(" ").append(line);
-
-                // SQL defines "--" as a comment to EOL
-                // and in Oracle it may contain a hint
-                // so we cannot just remove it, instead we must end it
-                if (line.indexOf("--") >= 0) {
-                    sql.append("\n");
-                }
-                if ((checkStringBufferEndsWith(sql, delimiter))) {
-                    executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
-                    sql.replace(0, sql.length(), "");
-                }
-            }
-            // Catch any statements not followed by ;
-            if (sql.length() > 0) {
-                executeSQL(sql.toString(), conn);
-            }
-        } catch (IOException e) {
-            log.error("Error occurred while executing SQL script for creating custos database", e);
-            throw new Exception("Error occurred while executing SQL script for creating custos database", e);
-
-        } finally {
-            if (reader != null) {
-                reader.close();
-            }
-        }
-    }
-
-    /**
-     * Checks that a string buffer ends up with a given string. It may sound trivial with the existing JDK API but the
-     * various implementation among JDKs can make those methods extremely resource intensive and perform poorly due to
-     * massive memory allocation and copying. See
-     *
-     * @param buffer
-     *            the buffer to perform the check on
-     * @param suffix
-     *            the suffix
-     * @return <code>true</code> if the character sequence represented by the argument is a suffix of the character
-     *         sequence represented by the StringBuffer object; <code>false</code> otherwise. Note that the result will
-     *         be <code>true</code> if the argument is the empty string.
-     */
-    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
-        if (suffix.length() > buffer.length()) {
-            return false;
-        }
-        // this loop is done on purpose to avoid memory allocation performance
-        // problems on various JDKs
-        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
-        // implementation is ok though does allocation/copying
-        // StringBuffer.toString().endsWith() does massive memory
-        // allocation/copying on JDK 1.5
-        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
-        int endIndex = suffix.length() - 1;
-        int bufferIndex = buffer.length() - 1;
-        while (endIndex >= 0) {
-            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
-                return false;
-            }
-            bufferIndex--;
-            endIndex--;
-        }
-        return true;
-    }
-
-    /**
-     * Method will accept a filepath containing a database script (eg: /user/database_scripts/expcatalog.sql)
-     *  and return only the filename of the database script (eg: expcatalog.sql).
-     * @param databaseType
-     * @param scriptFilePath
-     * @return
-     */
-    private static String getDBScriptFileName(DatabaseType databaseType, String scriptFilePath) {
-        // pattern: {dir_name}/{scriptfile_name}-{dbtype}.sql".
-        // Eg: database_scripts/expcatalog-derby.sql
-        final String scriptFilePattern = "(\\w*)(-" + databaseType.toString() + ".sql)";
-        final Pattern pattern = Pattern.compile(scriptFilePattern);
-        final Matcher matcher = pattern.matcher(scriptFilePath);
-        String dbScriptFileName = null;
-        // find a match
-        if (matcher.find()) {
-            dbScriptFileName = matcher.group();
-        }
-        return dbScriptFileName;
-    }
-
-//    public static void main(String[] args) throws Exception {
-//        System.out.println(DatabaseCreator.getDBScriptFileName(DatabaseType.derby, "db/db/expcatalog-derby.sql"));
-//        System.out.println(DatabaseCreator.getDBScriptFileName(DatabaseType.mysql, "/expcatalog-mysql.sql"));
-//    }
-}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/JDBCConfig.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/JDBCConfig.java
deleted file mode 100644
index 5cdb0ec..0000000
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/JDBCConfig.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.custos.commons.utils;
-
-public interface JDBCConfig {
-    String getURL();
-    String getDriver();
-    String getUser();
-    String getPassword();
-    String getValidationQuery();
-}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/JPAUtils.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/JPAUtils.java
deleted file mode 100644
index 9e02ce7..0000000
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/JPAUtils.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.apache.custos.commons.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * JPAUtils
- */
-public class JPAUtils {
-
-    private final static Logger logger = LoggerFactory.getLogger(JPAUtils.class);
-    private final static Map<String, String> DEFAULT_ENTITY_MANAGER_FACTORY_PROPERTIES;
-    static {
-        Map<String, String> properties = new HashMap<String, String>();
-        properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource");
-        properties.put("openjpa.DynamicEnhancementAgent", "true");
-        properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported");
-        properties.put("openjpa.RemoteCommitProvider", "sjvm");
-        properties.put("openjpa.Log", "DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO");
-        properties.put("openjpa.jdbc.SynchronizeMappings", "validate");
-        properties.put("openjpa.jdbc.QuerySQLCache", "false");
-        properties.put("openjpa.DetachState", "all");
-        properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72,"
-                + " PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000,  autoReconnect=true");
-        DEFAULT_ENTITY_MANAGER_FACTORY_PROPERTIES = properties;
-    }
-
-    /**
-     * Create an {@link EntityManagerFactory} with the default settings.
-     * @param persistenceUnitName
-     * @param jdbcConfig
-     * @return {@link EntityManagerFactory}
-     */
-    public static EntityManagerFactory getEntityManagerFactory(String persistenceUnitName, JDBCConfig jdbcConfig){
-
-        return getEntityManagerFactory(persistenceUnitName, jdbcConfig, Collections.emptyMap());
-    }
-
-    /**
-     * Create an {@link EntityManagerFactory}. The given properties will override the default properties.
-     * @param persistenceUnitName
-     * @param jdbcConfig
-     * @param properties
-     * @return {@link EntityManagerFactory}
-     */
-    public static EntityManagerFactory getEntityManagerFactory(String persistenceUnitName, JDBCConfig jdbcConfig, Map<String, String> properties) {
-
-        Map<String, String> finalProperties = new HashMap<>(DEFAULT_ENTITY_MANAGER_FACTORY_PROPERTIES);
-        finalProperties.putAll(createConnectionProperties(jdbcConfig));
-        finalProperties.putAll(properties);
-        return Persistence.createEntityManagerFactory(persistenceUnitName, finalProperties);
-    }
-
-    private static Map<String, String> createConnectionProperties(JDBCConfig jdbcConfig) {
-        String connectionProperties = "DriverClassName=" + jdbcConfig.getDriver() + "," + "Url=" + jdbcConfig.getURL()
-                + "?autoReconnect=true," + "Username=" + jdbcConfig.getUser() + "," + "Password="
-                + jdbcConfig.getPassword() + ",validationQuery=" + jdbcConfig.getValidationQuery();
-        logger.debug("Connection properties={}", connectionProperties);
-        return Collections.singletonMap("openjpa.ConnectionProperties", connectionProperties);
-    }
-}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
index 1b4015c..78570f7 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
@@ -26,7 +26,10 @@ import org.slf4j.LoggerFactory;
 public class ServerSettings extends ApplicationSettings {
 
     private static final Logger log = LoggerFactory.getLogger(ServerSettings.class);
-
+    // Iam Server Constants
+    public static final String IAM_SERVER_URL = "iam.server.url";
+    public static final String IAM_SERVER_SUPER_ADMIN_USERNAME = "iam.server.super.admin.username";
+    public static final String IAM_SERVER_SUPER_ADMIN_PASSWORD = "iam.server.super.admin.password";
 
     public static int getCacheSize() throws ApplicationSettingsException {
         return Integer.valueOf(getSetting(Constants.IN_MEMORY_CACHE_SIZE));
@@ -34,12 +37,7 @@ public class ServerSettings extends ApplicationSettings {
     public static String getAuthzCacheManagerClassName() throws ApplicationSettingsException {
         return getSetting(Constants.AUTHZ_CACHE_MANAGER_CLASS);
     }
-    public static boolean isAPISecured() throws ApplicationSettingsException {
-        return Boolean.valueOf(getSetting(Constants.IS_API_SECURED));
-    }
-    public static String getAuthorizationPoliyName() throws ApplicationSettingsException {
-        return getSetting(Constants.AUTHORIZATION_POLICY_NAME);
-    }
+
     public static String getSecurityManagerClassName() throws ApplicationSettingsException {
         return getSetting(Constants.SECURITY_MANAGER_CLASS);
     }
@@ -49,18 +47,6 @@ public class ServerSettings extends ApplicationSettings {
     public static boolean isAuthzCacheEnabled() throws ApplicationSettingsException {
         return Boolean.valueOf(getSetting(Constants.AUTHZ_CACHE_ENABLED));
     }
-    public static String getIamServerSuperAdminUsername() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.IAM_SERVER_SUPER_ADMIN_USERNAME);
-    }
-    public static String getIamServerSuperAdminPassword() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.IAM_SERVER_SUPER_ADMIN_PASSWORD);
-    }
-    public static String  getProfileServiceServerHost() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_HOST);
-    }
-    public static String getProfileServiceServerPort() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_PORT);
-    }
     public static  String getAuthenticationServerPort() throws ApplicationSettingsException {
         return getSetting(ServerSettings.AUTHENTICATION_SERVICE_SERVER_PORT);
     }
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityCheck.java b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityCheck.java
deleted file mode 100644
index 362fb1f..0000000
--- a/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityCheck.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- *
- * 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.custos.security.interceptor;
-
-import com.google.inject.BindingAnnotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This is just the definition of the annotation used to mark the API methods to be intercepted.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-@BindingAnnotation
-public @interface SecurityCheck {
-}
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java
deleted file mode 100644
index a67cf8e..0000000
--- a/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *
- * 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.custos.security.interceptor;
-
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.commons.exceptions.CustosSecurityException;
-import org.apache.custos.commons.model.error.AuthorizationException;
-import org.apache.custos.commons.model.security.AuthzToken;
-import org.apache.custos.commons.utils.Constants;
-import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.security.manager.CustosSecurityManager;
-import org.apache.custos.security.manager.IdentityContext;
-import org.apache.custos.security.manager.SecurityManagerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Interceptor of Custos API calls for the purpose of applying security.
- */
-public class SecurityInterceptor implements MethodInterceptor {
-    private final static Logger logger = LoggerFactory.getLogger(SecurityInterceptor.class);
-
-    @Override
-    public Object invoke(MethodInvocation invocation) throws Throwable {
-        //obtain the authz token from the input parameters
-        AuthzToken authzToken = (AuthzToken) invocation.getArguments()[0];
-        //authorize the API call
-        HashMap<String, String> metaDataMap = new HashMap();
-        metaDataMap.put(Constants.API_METHOD_NAME, invocation.getMethod().getName());
-        authorize(authzToken, metaDataMap);
-        //set the user identity info in a thread local to be used in downstream execution.
-        IdentityContext.set(authzToken);
-        //let the method call procees upon successful authorization
-        Object returnObj = invocation.proceed();
-        //clean the identity context before the method call returns
-        IdentityContext.unset();
-        return returnObj;
-    }
-
-    private void authorize(AuthzToken authzToken, Map<String, String> metaData) throws AuthorizationException {
-        try {
-            boolean isAPISecured = ServerSettings.isAPISecured();
-            if (isAPISecured) {
-                CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
-                boolean isAuthz = securityManager.isUserAuthenticated(authzToken);
-                if (!isAuthz) {
-                    throw new AuthorizationException("User is not authenticated or authorized.");
-                }
-            }
-        } catch (CustosSecurityException e) {
-            logger.error(e.getMessage(), e);
-            throw new AuthorizationException("Error in authenticating or authorizing user.");
-        } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            throw new AuthorizationException("Internal error in authenticating or authorizing user.");
-        }
-    }
-}
-
-
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityModule.java b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityModule.java
deleted file mode 100644
index c9475cc..0000000
--- a/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityModule.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *
- * 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.custos.security.interceptor;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.matcher.Matchers;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This does the plumbing work of integrating the interceptor with Guice framework for the methods to be
- * intercepted upon their invocation.
- */
-public class SecurityModule extends AbstractModule {
-    private final static Logger logger = LoggerFactory.getLogger(SecurityModule.class);
-
-    public void configure(){
-        logger.info("Security module reached...");
-        SecurityInterceptor interceptor = new SecurityInterceptor();
-        //requestInjection(interceptor);
-
-        bindInterceptor(Matchers.any(), Matchers.annotatedWith(SecurityCheck.class), interceptor);
-    }
-
-}
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
index 4fbcc5d..c18b8bc 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
@@ -48,7 +48,7 @@ public interface CustosSecurityManager {
      * @return
      * @throws CustosSecurityException
      */
-    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosSecurityException;
+    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws CustosSecurityException;
 
     /**
      * Get OpenID Connect user profile information from the given AuthzToken.
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
index 88cd26f..0b4d16e 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
@@ -96,11 +96,6 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
         String accessToken = authzToken.getAccessToken();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
         try {
-            if (!ServerSettings.isAPISecured()) {
-                return true;
-            }
-            initServiceClients();
-
             if (ServerSettings.isAuthzCacheEnabled()) {
                 //obtain an instance of AuthzCacheManager implementation.
                 AuthzCacheManager authzCacheManager = AuthzCacheManagerFactory.getAuthzCacheManager();
@@ -118,22 +113,17 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
                 } else if (AuthzCachedStatus.NOT_CACHED.equals(authzCachedStatus)) {
                     logger.debug("Authz decision for: (" + subject + ", " + accessToken + ") is not in the cache. " +
                             "Generating decision based on group membership.");
-//                    GatewayGroupMembership gatewayGroupMembership = getGatewayGroupMembership(subject, accessToken, gatewayId);
-//                    boolean authorizationDecision = hasPermission(gatewayGroupMembership, action);
-                    boolean authorizationDecision = validateToken(subject, accessToken, gatewayId);
+                    boolean authenticationDecision = validateToken(subject, accessToken, gatewayId);
                     //cache the authorization decision
                     long currentTime = System.currentTimeMillis();
-                    //TODO get the actual token expiration time
                     authzCacheManager.addToAuthzCache(new AuthzCacheIndex(subject, gatewayId, accessToken),
-                            new AuthzCacheEntry(authorizationDecision, currentTime + 1000 * 60 * 60, currentTime));
-                    return authorizationDecision;
+                            new AuthzCacheEntry(authenticationDecision, currentTime + 1000 * 60 * 60, currentTime));
+                    return authenticationDecision;
                 } else {
                     //undefined status returned from the authz cache manager
                     throw new CustosSecurityException("Error in reading from the authorization cache.");
                 }
             } else {
-//                GatewayGroupMembership gatewayGroupMembership = getGatewayGroupMembership(subject, accessToken, gatewayId);
-//                return hasPermission(gatewayGroupMembership, action);
                 return validateToken(subject, accessToken, gatewayId);
             }
 
@@ -144,48 +134,35 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
             logger.error("Error occurred while checking if user: " + subject + " is authorized in gateway: " + gatewayId, e);
             throw new CustosSecurityException(e.getMessage(), e);
         }
-//        } finally {
-//            closeServiceClients();
-//        }
     }
-
+    //TODO: no way to get gateway as tenant profile service has not been migrated. Check if clientId and clientSecret could be removed
     @Override
-    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosSecurityException {
+    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws CustosSecurityException {
         try {
-            initServiceClients();
-            Gateway gateway = tenantProfileClient.getGatewayUsingGatewayId(authzToken,gatewayId);
             String tokenURL = getTokenEndpoint(gatewayId);
-            JSONObject clientCredentials = getClientCredentials(tokenURL, gateway.getOauthClientId(), gateway.getOauthClientSecret());
+            JSONObject clientCredentials = getClientCredentials(tokenURL, clientId, clientSecret);
             String accessToken = clientCredentials.getString("access_token");
             AuthzToken userManagementServiceAccountAuthzToken = new AuthzToken(accessToken);
             userManagementServiceAccountAuthzToken.putToClaimsMap(Constants.GATEWAY_ID, gatewayId);
-            userManagementServiceAccountAuthzToken.putToClaimsMap(Constants.USER_NAME, gateway.getOauthClientId());
+            userManagementServiceAccountAuthzToken.putToClaimsMap(Constants.USER_NAME, clientId);
             return userManagementServiceAccountAuthzToken;
         } catch (Exception e) {
             throw new CustosSecurityException(e);
-        } finally {
-            closeServiceClients();
         }
     }
 
     @Override
     public UserInfo getUserInfoFromAuthzToken(AuthzToken authzToken) throws CustosSecurityException {
         try {
-//            initServiceClients();
             final String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
             final String token = authzToken.getAccessToken();
             return getUserInfo(gatewayId, token);
         } catch (Exception e) {
             throw new CustosSecurityException(e);
         }
-//        } finally {
-//            closeServiceClients();
-//        }
     }
 
     private UserInfo getUserInfo(String gatewayId, String token) throws Exception {
-//        GatewayResourceProfile gwrp = registryServiceClient.getGatewayResourceProfile(gatewayId);
-//        String identityServerRealm = gwrp.getIdentityServerTenant();
         //TODO: Confirm the difference between gatewayId and IdentityServerTenant, using gatewayId as of now
         String openIdConnectUrl = getOpenIDConfigurationUrl(gatewayId);
         JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, null));
@@ -200,25 +177,6 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
                 .setUsername(userInfo.getString("preferred_username"));
     }
 
-//    private GatewayGroupMembership getGatewayGroupMembership(String username, String token, String gatewayId) throws Exception {
-//        validateToken(username, token, gatewayId);
-//        GatewayGroups gatewayGroups = getGatewayGroups(gatewayId);
-//        List<UserGroup> userGroups = sharingRegistryServiceClient.getAllMemberGroupsForUser(gatewayId, username + "@" + gatewayId);
-//        List<String> userGroupIds = userGroups.stream().map(g -> g.getGroupId()).collect(Collectors.toList());
-//        GatewayGroupMembership gatewayGroupMembership = new GatewayGroupMembership();
-//        gatewayGroupMembership.setInAdminsGroup(userGroupIds.contains(gatewayGroups.getAdminsGroupId()));
-//        gatewayGroupMembership.setInReadOnlyAdminsGroup(userGroupIds.contains(gatewayGroups.getReadOnlyAdminsGroupId()));
-//        return gatewayGroupMembership;
-//    }
-
-//    private GatewayGroups getGatewayGroups(String gatewayId) throws Exception {
-//        if (registryServiceClient.isGatewayGroupsExists(gatewayId)) {
-//            return registryServiceClient.getGatewayGroups(gatewayId);
-//        } else {
-//            return GatewayGroupsInitializer.initializeGatewayGroups(gatewayId);
-//        }
-//    }
-
     private boolean validateToken(String username, String token, String gatewayId) throws Exception {
         UserInfo userInfo = getUserInfo(gatewayId, token);
         if (!username.equals(userInfo.getUsername())) {
@@ -227,30 +185,6 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
         return true;
     }
 
-//    private String[] getUserRolesFromOAuthToken(String username, String token, String gatewayId) throws Exception {
-//        GatewayResourceProfile gwrp = getRegistryServiceClient().getGatewayResourceProfile(gatewayId);
-//        String identityServerRealm = gwrp.getIdentityServerTenant();
-//        String openIdConnectUrl = getOpenIDConfigurationUrl(identityServerRealm);
-//        JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, token));
-//        String userInfoEndPoint = openIdConnectConfig.getString("userinfo_endpoint");
-//        JSONObject userInfo = new JSONObject(getFromUrl(userInfoEndPoint, token));
-//        if (!username.equals(userInfo.get("preferred_username"))) {
-//            throw new CustosSecurityException("Subject name and username for the token doesn't match");
-//        }
-//        String userId = userInfo.getString("sub");
-//
-//        String userRoleMappingUrl = ServerSettings.getRemoteIDPServiceUrl() + "/admin/realms/"
-//                + identityServerRealm + "/users/"
-//                + userId + "/role-mappings/realm";
-//        JSONArray roleMappings = new JSONArray(getFromUrl(userRoleMappingUrl, getAdminAccessToken(gatewayId)));
-//        String[] roles = new String[roleMappings.length()];
-//        for (int i = 0; i < roleMappings.length(); i++) {
-//            roles[i] = (new JSONObject(roleMappings.get(i).toString())).get("name").toString();
-//        }
-//
-//        return roles;
-//    }
-
     private String getOpenIDConfigurationUrl(String realm) throws ApplicationSettingsException {
         return ServerSettings.getRemoteIDPServiceUrl() + "/realms/" + realm + "/.well-known/openid-configuration";
     }
@@ -274,33 +208,6 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
         return result.toString();
     }
 
-//    private String getAdminAccessToken(String gatewayId) throws Exception {
-//        CredentialStoreService.Client csClient = getCredentialStoreServiceClient();
-//        GatewayResourceProfile gwrp = getRegistryServiceClient().getGatewayResourceProfile(gatewayId);
-//        String identityServerRealm = gwrp.getIdentityServerTenant();
-//        String openIdConnectUrl = getOpenIDConfigurationUrl(identityServerRealm);
-//        JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, null));
-//        PasswordCredential credential = csClient.getPasswordCredential(gwrp.getIdentityServerPwdCredToken(), gwrp.getGatewayID());
-//        String username = credential.getLoginUserName();
-//        String password = credential.getPassword();
-//        String urlString = openIdConnectConfig.getString("token_endpoint");
-//        StringBuilder result = new StringBuilder();
-//        URL url = new URL(urlString);
-//        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-//        conn.setRequestMethod("POST");
-//        conn.setDoOutput(true);
-//        String postFields = "client_id=admin-cli&username=" + username + "&password=" + password + "&grant_type=password";
-//        conn.getOutputStream().write(postFields.getBytes());
-//        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
-//        String line;
-//        while ((line = rd.readLine()) != null) {
-//            result.append(line);
-//        }
-//        rd.close();
-//        JSONObject tokenInfo = new JSONObject(result.toString());
-//        return tokenInfo.get("access_token").toString();
-//    }
-
     private String getTokenEndpoint(String gatewayId) throws Exception {
         String openIdConnectUrl = getOpenIDConfigurationUrl(gatewayId);
         JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, null));
@@ -337,94 +244,4 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
             }
         }
     }
-
-//    private boolean hasPermission(GatewayGroupMembership gatewayGroupMembership, String apiMethod) {
-//
-//        // Note: as a stopgap solution, until all resources are secured with group-based authorization, map the Admins
-//        // and Read Only Admins groups to the corresponding roles
-//        final String role;
-//        if (gatewayGroupMembership.isInAdminsGroup()) {
-//            return true;
-//        } else if (gatewayGroupMembership.isInReadOnlyAdminsGroup()) {
-//            role = "admin-read-only";
-//        } else {
-//            // If not in Admins or Read Only Admins groups, treat as a gateway-user
-//            role = "gateway-user";
-//        }
-//        Pattern pattern = Pattern.compile(this.rolePermissionConfig.get(role));
-//        Matcher matcher = pattern.matcher(apiMethod);
-//        return matcher.matches();
-//    }
-//
-//    private boolean hasPermission(String[] roles, String apiMethod) {
-//        for (int i = 0; i < roles.length; i++) {
-//            String role = roles[i];
-//            if (this.rolePermissionConfig.keySet().contains(role)) {
-//                Pattern pattern = Pattern.compile(this.rolePermissionConfig.get(role));
-//                Matcher matcher = pattern.matcher(apiMethod);
-//                if (matcher.matches())
-//                    return true;
-//            }
-//        }
-//        return false;
-//    }
-//
-    private void initServiceClients() throws TException, ApplicationSettingsException {
-        tenantProfileClient = getTenantProfileServiceClient();
-    }
-
-    private void closeServiceClients() {
-        if (tenantProfileClient != null) {
-            ThriftUtils.close(tenantProfileClient);
-        }
-    }
-
-//    private RegistryService.Client getRegistryServiceClient() throws TException, ApplicationSettingsException {
-//        final int serverPort = Integer.parseInt(ServerSettings.getRegistryServerPort());
-//        final String serverHost = ServerSettings.getRegistryServerHost();
-//        try {
-//            return RegistryServiceClientFactory.createRegistryClient(serverHost, serverPort);
-//        } catch (RegistryServiceException e) {
-//            throw new TException("Unable to create registry client...", e);
-//        }
-//    }
-//
-//    private CredentialStoreService.Client getCredentialStoreServiceClient() throws TException, ApplicationSettingsException {
-//        final int serverPort = Integer.parseInt(ServerSettings.getCredentialStoreServerPort());
-//        final String serverHost = ServerSettings.getCredentialStoreServerHost();
-//        try {
-//            return CredentialStoreClientFactory.createAiravataCSClient(serverHost, serverPort);
-//        } catch (CredentialStoreException e) {
-//            throw new TException("Unable to create credential store client...", e);
-//        }
-//    }
-//
-//    private SharingRegistryService.Client getSharingRegistryServiceClient() throws TException, ApplicationSettingsException {
-//        final int serverPort = Integer.parseInt(ServerSettings.getSharingRegistryPort());
-//        final String serverHost = ServerSettings.getSharingRegistryHost();
-//        try {
-//            return SharingRegistryServiceClientFactory.createSharingRegistryClient(serverHost, serverPort);
-//        } catch (SharingRegistryException e) {
-//            throw new TException("Unable to create sharing registry client...", e);
-//        }
-//    }
-
-//    public static void main(String[] args) throws CustosSecurityException, ApplicationSettingsException {
-//        ServerSettings.setSetting("trust.store", "./modules/configuration/server/src/main/resources/client_truststore.jks");
-//        ServerSettings.setSetting("trust.store.password", "airavata");
-//        KeyCloakSecurityManager keyCloakSecurityManager = new KeyCloakSecurityManager();
-//        final String tokenURL = "...";
-//        final String clientId = "...";
-//        final String clientSecret = "...";
-//        JSONObject jsonObject = keyCloakSecurityManager.getClientCredentials(tokenURL, clientId, clientSecret);
-//        System.out.println("access_token=" + jsonObject.getString("access_token"));
-//    }
-    private TenantProfileService.Client getTenantProfileServiceClient() throws ApplicationSettingsException , TenantProfileServiceException, TException {
-        try {
-            TenantProfileService.Client tenantProfileClient = ProfileServiceClientFactory.createTenantProfileServiceClient(ServerSettings.getProfileServiceServerHost(), Integer.parseInt(ServerSettings.getProfileServiceServerPort()));
-            return tenantProfileClient;
-        } catch (TenantProfileServiceException e) {
-            throw new TenantProfileServiceException("Unable to create tenant profile client...");
-        }
-    }
 }
diff --git a/custos-profile-service/iam-admin-services-core/pom.xml b/custos-profile-service/iam-admin-services-core/pom.xml
deleted file mode 100644
index 7b2e09d..0000000
--- a/custos-profile-service/iam-admin-services-core/pom.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>8</source>
-                    <target>8</target>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-    <parent>
-        <groupId>org.apache.custos</groupId>
-        <artifactId>profile-service</artifactId>
-        <version>1.0-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
-    </parent>
-
-    
-    <artifactId>iam-admin-services-core</artifactId>
-    <name>Iam Admin Services</name>
-
-    <dependencies>
-        <dependency>
-            <groupId>commons-httpclient</groupId>
-            <artifactId>commons-httpclient</artifactId>
-            <version>3.1</version>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
-        <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>4.5.2</version>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
-        <dependency>
-            <groupId>javax.ws.rs</groupId>
-            <artifactId>javax.ws.rs-api</artifactId>
-            <version>2.0.1</version>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-client -->
-        <dependency>
-            <groupId>org.jboss.resteasy</groupId>
-            <artifactId>resteasy-client</artifactId>
-            <version>3.0.14.Final</version>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jackson2-provider -->
-        <dependency>
-            <groupId>org.jboss.resteasy</groupId>
-            <artifactId>resteasy-jackson2-provider</artifactId>
-            <version>3.0.14.Final</version>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-databind</artifactId>
-            <version>2.5.4</version>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/org.keycloak/keycloak-admin-client -->
-        <dependency>
-            <groupId>org.keycloak</groupId>
-            <artifactId>keycloak-admin-client</artifactId>
-            <version>2.5.5.Final</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>profile-service-stubs</artifactId>
-            <version>1.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>custos-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>profile-service-models</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
-        </dependency>
-    </dependencies>
-    
-</project>
\ No newline at end of file
diff --git a/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java b/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
deleted file mode 100644
index f3309bd..0000000
--- a/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
+++ /dev/null
@@ -1,821 +0,0 @@
-/*
- *
- * 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.custos.profile.iam.admin.services.core.impl;
-
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.commons.utils.SecurityUtil;
-import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
-import org.apache.custos.profile.model.tenant.PasswordCredential;
-import org.apache.custos.profile.model.user.Status;
-import org.apache.custos.profile.model.user.UserProfile;
-import org.apache.custos.profile.model.workspace.Gateway;
-import org.apache.custos.profile.iam.admin.services.core.interfaces.TenantManagementInterface;
-import org.jboss.resteasy.client.jaxrs.ResteasyClient;
-import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
-import org.keycloak.admin.client.Keycloak;
-import org.keycloak.admin.client.KeycloakBuilder;
-import org.keycloak.admin.client.resource.RoleResource;
-import org.keycloak.admin.client.resource.UserResource;
-import org.keycloak.representations.idm.ClientRepresentation;
-import org.keycloak.representations.idm.CredentialRepresentation;
-import org.keycloak.representations.idm.RealmRepresentation;
-import org.keycloak.representations.idm.RoleRepresentation;
-import org.keycloak.representations.idm.RolesRepresentation;
-import org.keycloak.representations.idm.UserRepresentation;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.KeyStore;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class TenantManagementKeycloakImpl implements TenantManagementInterface {
-
-    private final static Logger logger = LoggerFactory.getLogger(TenantManagementKeycloakImpl.class);
-
-    private String superAdminRealmId = "master";
-
-    private static Keycloak getClient(String adminUrl, String realm, PasswordCredential AdminPasswordCreds) {
-
-        ResteasyClient resteasyClient = new ResteasyClientBuilder()
-                .connectionPoolSize(10)
-                .trustStore(loadKeyStore())
-                .build();
-        return KeycloakBuilder.builder()
-                .serverUrl(adminUrl)
-                .realm(realm)
-                .username(AdminPasswordCreds.getLoginUserName())
-                .password(AdminPasswordCreds.getPassword())
-                .clientId("admin-cli")
-                .resteasyClient(resteasyClient)
-                .build();
-    }
-
-    private static Keycloak getClient(String adminUrl, String realm, String accessToken) {
-
-        ResteasyClient resteasyClient = new ResteasyClientBuilder()
-                .connectionPoolSize(10)
-                .trustStore(loadKeyStore())
-                .build();
-        return KeycloakBuilder.builder()
-                .serverUrl(adminUrl)
-                .realm(realm)
-                .authorization(accessToken)
-                .resteasyClient(resteasyClient)
-                .build();
-    }
-
-    private static KeyStore loadKeyStore() {
-
-        InputStream is = null;
-        try {
-
-            String trustStorePath =  ServerSettings.getTrustStorePath();
-            File trustStoreFile = new File(trustStorePath);
-
-            if (trustStoreFile.exists()) {
-                logger.debug("Loading trust store file from path " + trustStorePath);
-                is = new FileInputStream(trustStorePath);
-            } else {
-                logger.debug("Trying to load trust store file form class path " + trustStorePath);
-                is = SecurityUtil.class.getClassLoader().getResourceAsStream(trustStorePath);
-                if (is != null) {
-                    logger.debug("Trust store file was loaded form class path " + trustStorePath);
-                }
-            }
-
-            if (is == null) {
-                throw new RuntimeException("Could not find a trust store file in path " + trustStorePath);
-            }
-
-            KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
-            ks.load(is, ServerSettings.getTrustStorePassword().toCharArray());
-            return ks;
-        } catch (Exception e) {
-            throw new RuntimeException("Failed to load trust store KeyStore instance", e);
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException e) {
-                    logger.error("Failed to close trust store FileInputStream", e);
-                }
-            }
-        }
-    }
-
-    @Override
-    public Gateway addTenant(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException {
-        Keycloak client = null;
-        try {
-            // get client
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), this.superAdminRealmId, isSuperAdminPasswordCreds);
-            // create realm
-            RealmRepresentation newRealmDetails = new RealmRepresentation();
-            newRealmDetails.setEnabled(true);
-            newRealmDetails.setId(gatewayDetails.getGatewayId());
-            newRealmDetails.setDisplayName(gatewayDetails.getGatewayName());
-            newRealmDetails.setRealm(gatewayDetails.getGatewayId());
-            // Following two settings allow duplicate email addresses
-            newRealmDetails.setLoginWithEmailAllowed(false);
-            newRealmDetails.setDuplicateEmailsAllowed(true);
-            // Default access token lifespan to 30 minutes, SSO session idle to 60 minutes
-            newRealmDetails.setAccessTokenLifespan(1800);
-            newRealmDetails.setSsoSessionIdleTimeout(3600);
-            RealmRepresentation realmWithRoles = TenantManagementKeycloakImpl.createDefaultRoles(newRealmDetails);
-            client.realms().create(realmWithRoles);
-            return gatewayDetails;
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting Iam server Url from property file, reason: " + ex.getMessage());
-            throw exception;
-        } catch (Exception ex){
-            logger.error("Error creating Realm in Keycloak Server, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error creating Realm in Keycloak Server, reason: " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    public static RealmRepresentation createDefaultRoles(RealmRepresentation realmDetails){
-        List<RoleRepresentation> defaultRoles = new ArrayList<RoleRepresentation>();
-        RoleRepresentation adminRole = new RoleRepresentation();
-        adminRole.setName("admin");
-        adminRole.setDescription("Admin role for PGA users");
-        defaultRoles.add(adminRole);
-        RoleRepresentation adminReadOnlyRole = new RoleRepresentation();
-        adminReadOnlyRole.setName("admin-read-only");
-        adminReadOnlyRole.setDescription("Read only role for PGA Admin users");
-        defaultRoles.add(adminReadOnlyRole);
-        RoleRepresentation gatewayUserRole = new RoleRepresentation();
-        gatewayUserRole.setName("gateway-user");
-        gatewayUserRole.setDescription("default role for PGA users");
-        defaultRoles.add(gatewayUserRole);
-        RoleRepresentation pendingUserRole = new RoleRepresentation();
-        pendingUserRole.setName("user-pending");
-        pendingUserRole.setDescription("role for newly registered PGA users");
-        defaultRoles.add(pendingUserRole);
-        RoleRepresentation gatewayProviderRole = new RoleRepresentation();
-        gatewayProviderRole.setName("gateway-provider");
-        gatewayProviderRole.setDescription("role for gateway providers in the super-admin PGA");
-        defaultRoles.add(gatewayProviderRole);
-        RolesRepresentation rolesRepresentation = new RolesRepresentation();
-        rolesRepresentation.setRealm(defaultRoles);
-        realmDetails.setRoles(rolesRepresentation);
-        return realmDetails;
-    }
-
-    @Override
-    public boolean createTenantAdminAccount(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails, String tenantAdminPassword) throws IamAdminServicesException{
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), this.superAdminRealmId, isSuperAdminPasswordCreds);
-            UserRepresentation user = new UserRepresentation();
-            user.setUsername(gatewayDetails.getIdentityServerUserName());
-            user.setFirstName(gatewayDetails.getGatewayAdminFirstName());
-            user.setLastName(gatewayDetails.getGatewayAdminLastName());
-            user.setEmail(gatewayDetails.getGatewayAdminEmail());
-            user.setEmailVerified(true);
-            user.setEnabled(true);
-            Response httpResponse = client.realm(gatewayDetails.getGatewayId()).users().create(user);
-            logger.info("Tenant Admin account creation exited with code : " + httpResponse.getStatus()+" : " +httpResponse.getStatusInfo());
-            if (httpResponse.getStatus() == 201) { //HTTP code for record creation: HTTP 201
-                List<UserRepresentation> retrieveCreatedUserList = client.realm(gatewayDetails.getGatewayId()).users().search(user.getUsername(),
-                        user.getFirstName(),
-                        user.getLastName(),
-                        user.getEmail(),
-                        0, 1);
-                UserResource retrievedUser = client.realm(gatewayDetails.getGatewayId()).users().get(retrieveCreatedUserList.get(0).getId());
-
-                // Add user to the "admin" role
-                RoleResource adminRoleResource = client.realm(gatewayDetails.getGatewayId()).roles().get("admin");
-                retrievedUser.roles().realmLevel().add(Arrays.asList(adminRoleResource.toRepresentation()));
-
-                CredentialRepresentation credential = new CredentialRepresentation();
-                credential.setType(CredentialRepresentation.PASSWORD);
-                credential.setValue(tenantAdminPassword);
-                credential.setTemporary(false);
-                retrievedUser.resetPassword(credential);
-                List<ClientRepresentation> realmClients = client.realm(gatewayDetails.getGatewayId()).clients().findAll();
-                String realmManagementClientId=getRealmManagementClientId(client, gatewayDetails.getGatewayId());
-                for(ClientRepresentation realmClient : realmClients){
-                    if(realmClient.getClientId().equals("realm-management")){
-                        realmManagementClientId = realmClient.getId();
-                    }
-                }
-                retrievedUser.roles().clientLevel(realmManagementClientId).add(retrievedUser.roles().clientLevel(realmManagementClientId).listAvailable());
-                return true;
-            } else {
-                logger.error("Request for Tenant Admin Account Creation failed with HTTP code : " + httpResponse.getStatus());
-                logger.error("Reason for Tenant Admin account creation failure : " + httpResponse.getStatusInfo());
-                return false;
-            }
-        }catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        }catch (Exception ex){
-            logger.error("Error creating Realm Admin Account in keycloak server, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error creating Realm Admin Account in keycloak server, reason: " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public Gateway configureClient(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException{
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), this.superAdminRealmId, isSuperAdminPasswordCreds);
-            ClientRepresentation pgaClient = new ClientRepresentation();
-            pgaClient.setName("pga");
-            pgaClient.setClientId("pga");
-            pgaClient.setProtocol("openid-connect");
-            pgaClient.setStandardFlowEnabled(true);
-            pgaClient.setEnabled(true);
-            pgaClient.setAuthorizationServicesEnabled(true);
-            pgaClient.setDirectAccessGrantsEnabled(true);
-            pgaClient.setServiceAccountsEnabled(true);
-            pgaClient.setFullScopeAllowed(true);
-            pgaClient.setClientAuthenticatorType("client-secret");
-            List<String> redirectUris = new ArrayList<>();
-            if(gatewayDetails.getGatewayURL()!=null){
-                String gatewayURL = gatewayDetails.getGatewayURL();
-                // Remove trailing slash from gatewayURL
-                if(gatewayURL.endsWith("/")) {
-                    gatewayURL = gatewayURL.substring(0, gatewayURL.length() - 1);
-                }
-                // Add redirect URL after login
-                redirectUris.add(gatewayURL + "/callback-url"); // PGA
-                redirectUris.add(gatewayURL + "/auth/callback*"); // Django
-                // Add redirect URL after logout
-                redirectUris.add(gatewayURL);
-            } else {
-                logger.error("Request for Realm Client Creation failed, callback URL not present");
-                IamAdminServicesException ex = new IamAdminServicesException();
-                ex.setMessage("Gateway Url field in GatewayProfile cannot be empty, Realm Client creation failed");
-                throw ex;
-            }
-            pgaClient.setRedirectUris(redirectUris);
-            pgaClient.setPublicClient(false);
-            Response httpResponse = client.realms().realm(gatewayDetails.getGatewayId()).clients().create(pgaClient);
-            logger.info("Tenant Client configuration exited with code : " + httpResponse.getStatus()+" : " +httpResponse.getStatusInfo());
-
-            // Add the manage-users role to the web client
-            UserRepresentation serviceAccountUserRepresentation = getUserByUsername(client, gatewayDetails.getGatewayId(), "service-account-" + pgaClient.getClientId());
-            UserResource serviceAccountUser = client.realms().realm(gatewayDetails.getGatewayId()).users().get(serviceAccountUserRepresentation.getId());
-            String realmManagementClientId = getRealmManagementClientId(client, gatewayDetails.getGatewayId());
-            List<RoleRepresentation> manageUsersRole = serviceAccountUser.roles().clientLevel(realmManagementClientId).listAvailable()
-                    .stream()
-                    .filter(r -> r.getName().equals("manage-users"))
-                    .collect(Collectors.toList());
-            serviceAccountUser.roles().clientLevel(realmManagementClientId).add(manageUsersRole);
-
-            if(httpResponse.getStatus() == 201){
-                String ClientUUID = client.realms().realm(gatewayDetails.getGatewayId()).clients().findByClientId(pgaClient.getClientId()).get(0).getId();
-                CredentialRepresentation clientSecret = client.realms().realm(gatewayDetails.getGatewayId()).clients().get(ClientUUID).getSecret();
-                gatewayDetails.setOauthClientId(pgaClient.getClientId());
-                gatewayDetails.setOauthClientSecret(clientSecret.getValue());
-                return gatewayDetails;
-            } else {
-                logger.error("Request for Realm Client Creation failed with HTTP code : " + httpResponse.getStatus());
-                logger.error("Reason for Realm Client Creation failure : " + httpResponse.getStatusInfo());
-                return null;
-            }
-        }catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    private static String getRealmManagementClientId(Keycloak client, String realmId) {
-        List<ClientRepresentation> realmClients = client.realm(realmId).clients().findAll();
-        String realmManagementClientId=null;
-        for(ClientRepresentation realmClient : realmClients){
-            if(realmClient.getClientId().equals("realm-management")){
-                realmManagementClientId = realmClient.getId();
-            }
-        }
-        return realmManagementClientId;
-    }
-
-    @Override
-    public boolean isUsernameAvailable(String accessToken, String tenantId, String username) throws IamAdminServicesException {
-        Keycloak client = null;
-        try {
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
-            return userRepresentation == null;
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public boolean createUser(String accessToken, String tenantId, String username, String emailAddress, String firstName, String lastName, String newPassword) throws IamAdminServicesException{
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            UserRepresentation user = new UserRepresentation();
-            user.setUsername(username);
-            user.setFirstName(firstName);
-            user.setLastName(lastName);
-            user.setEmail(emailAddress);
-            user.setEnabled(false);
-            Response httpResponse = client.realm(tenantId).users().create(user);
-            if (httpResponse.getStatus() == 201) { //HTTP code for record creation: HTTP 201
-                List<UserRepresentation> retrieveCreatedUserList = client.realm(tenantId).users().search(user.getUsername(),
-                        user.getFirstName(),
-                        user.getLastName(),
-                        user.getEmail(),
-                        0, 1);
-                UserResource retrievedUser = client.realm(tenantId).users().get(retrieveCreatedUserList.get(0).getId());
-                CredentialRepresentation credential = new CredentialRepresentation();
-                credential.setType(CredentialRepresentation.PASSWORD);
-                credential.setValue(newPassword);
-                credential.setTemporary(false);
-                retrievedUser.resetPassword(credential);
-                return true;
-            } else {
-                logger.error("Request for user Account Creation failed with HTTP code : " + httpResponse.getStatus());
-                logger.error("Reason for user account creation failure : " + httpResponse.getStatusInfo());
-                return false;
-            }
-        }catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public boolean enableUserAccount(String accessToken, String tenantId, String username) throws IamAdminServicesException{
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
-            UserResource userResource = client.realm(tenantId).users().get(userRepresentation.getId());
-            UserRepresentation profile = userResource.toRepresentation();
-            profile.setEnabled(true);
-            // We require that a user verify their email before enabling the account
-            profile.setEmailVerified(true);
-            userResource.update(profile);
-            return true;
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public boolean isUserAccountEnabled(String accessToken, String tenantId, String username) throws IamAdminServicesException{
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
-            return userRepresentation != null && userRepresentation.isEnabled();
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public boolean isUserExist(String accessToken, String tenantId, String username) throws IamAdminServicesException {
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
-            return userRepresentation != null;
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public UserProfile getUser(String accessToken, String tenantId, String username) throws IamAdminServicesException {
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
-            return userRepresentation != null ? convertUserRepresentationToUserProfile(userRepresentation, tenantId) : null;
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public List<UserProfile> getUsers(String accessToken, String tenantId, int offset, int limit, String search)
-            throws IamAdminServicesException {
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            List<UserRepresentation> userRepresentationList = client.realm(tenantId).users().search(search, offset, limit);
-            return userRepresentationList.stream().map(ur -> convertUserRepresentationToUserProfile(ur, tenantId))
-                    .collect(Collectors.toList());
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public boolean resetUserPassword(String accessToken, String tenantId, String username, String newPassword) throws IamAdminServicesException{
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
-            if(userRepresentation != null)
-            {
-                UserResource retrievedUser = client.realm(tenantId).users().get(userRepresentation.getId());
-                CredentialRepresentation credential = new CredentialRepresentation();
-                credential.setType(CredentialRepresentation.PASSWORD);
-                credential.setValue(newPassword);
-                credential.setTemporary(false);
-                retrievedUser.resetPassword(credential);
-                // Remove the UPDATE_PASSWORD required action
-                userRepresentation = retrievedUser.toRepresentation();
-                userRepresentation.getRequiredActions().remove("UPDATE_PASSWORD");
-                retrievedUser.update(userRepresentation);
-                return true;
-            }else{
-                logger.error("requested User not found");
-                return false;
-            }
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } catch (Exception ex){
-            logger.error("Error resetting user password in keycloak server, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error resetting user password in keycloak server, reason: " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public List<UserProfile> findUser(String accessToken, String tenantId, String email, String userName) throws IamAdminServicesException{
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            List<UserRepresentation> retrieveUserList = client.realm(tenantId).users().search(userName,
-                    null,
-                    null,
-                    email,
-                    0, 1);
-            if(!retrieveUserList.isEmpty())
-            {
-                List<UserProfile> userList = new ArrayList<>();
-                for(UserRepresentation user : retrieveUserList){
-                    UserProfile profile = new UserProfile();
-                    profile.setUserId(user.getUsername());
-                    profile.setFirstName(user.getFirstName());
-                    profile.setLastName(user.getLastName());
-                    profile.setEmails(Arrays.asList(new String[]{user.getEmail()}));
-                    userList.add(profile);
-                }
-                return userList;
-            }else{
-                logger.error("requested User not found");
-                return null;
-            }
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } catch (Exception ex){
-            logger.error("Error finding user in keycloak server, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error finding user in keycloak server, reason: " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public void updateUserProfile(String accessToken, String tenantId, String username, UserProfile userDetails) throws IamAdminServicesException {
-
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
-            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
-            if(userRepresentation != null)
-            {
-                userRepresentation.setFirstName(userDetails.getFirstName());
-                userRepresentation.setLastName(userDetails.getLastName());
-                userRepresentation.setEmail(userDetails.getEmails().get(0));
-                UserResource userResource = client.realm(tenantId).users().get(userRepresentation.getId());
-                userResource.update(userRepresentation);
-            }else{
-                throw new IamAdminServicesException("User [" + username + "] wasn't found in Keycloak!");
-            }
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } catch (Exception ex){
-            logger.error("Error updating user profile in keycloak server, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error updating user profile in keycloak server, reason: " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public boolean addRoleToUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException {
-
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
-            List<UserRepresentation> retrieveCreatedUserList = client.realm(tenantId).users().search(username,
-                    null,
-                    null,
-                    null,
-                    0, 1);
-            UserResource retrievedUser = client.realm(tenantId).users().get(retrieveCreatedUserList.get(0).getId());
-
-            // Add user to the role
-            RoleResource roleResource = client.realm(tenantId).roles().get(roleName);
-            retrievedUser.roles().realmLevel().add(Arrays.asList(roleResource.toRepresentation()));
-            return true;
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    @Override
-    public boolean removeRoleFromUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException {
-
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
-            List<UserRepresentation> retrieveCreatedUserList = client.realm(tenantId).users().search(username,
-                    null,
-                    null,
-                    null,
-                    0, 1);
-            UserResource retrievedUser = client.realm(tenantId).users().get(retrieveCreatedUserList.get(0).getId());
-
-            // Remove role from user
-            RoleResource roleResource = client.realm(tenantId).roles().get(roleName);
-            retrievedUser.roles().realmLevel().remove(Arrays.asList(roleResource.toRepresentation()));
-            return true;
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                client.close();
-            }
-        }
-    }
-
-    // TODO: this is needed for migrating from roles to group-based auth but after migration we can remove this
-    @Override
-    public List<UserProfile> getUsersWithRole(PasswordCredential realmAdminCreds, String tenantId, String roleName) throws IamAdminServicesException {
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
-            // FIXME: this only searches through the most recent 100 users for the given role (assuming there are no more than 10,000 users in the gateway)
-            int totalUserCount = client.realm(tenantId).users().count();
-            logger.debug("getUsersWithRole: totalUserCount=" + totalUserCount);
-            // Load all users in batches
-            List<UserRepresentation> allUsers = new ArrayList<>();
-            int userBatchSize = 100;
-            for (int start = 0; start < totalUserCount; start=start+userBatchSize) {
-
-                logger.debug("getUsersWithRole: fetching " + userBatchSize + " users...");
-                allUsers.addAll(client.realm(tenantId).users().search(null,
-                        null,
-                        null,
-                        null,
-                        start, userBatchSize));
-            }
-            logger.debug("getUsersWithRole: all users count=" + allUsers.size());
-            allUsers.sort((a, b) -> a.getCreatedTimestamp() - b.getCreatedTimestamp() > 0 ? -1 : 1);
-            // The 100 most recently created users
-            List<UserRepresentation> mostRecentUsers = allUsers.subList(0, Math.min(allUsers.size(), 100));
-            logger.debug("getUsersWithRole: most recent users count=" + mostRecentUsers.size());
-
-            List<UserProfile> usersWithRole = new ArrayList<>();
-            for (UserRepresentation user: mostRecentUsers) {
-                UserResource userResource = client.realm(tenantId).users().get(user.getId());
-
-                List<RoleRepresentation> roleRepresentations = userResource.roles().realmLevel().listAll();
-                for (RoleRepresentation roleRepresentation : roleRepresentations){
-                    if (roleRepresentation.getName().equals(roleName)) {
-                        usersWithRole.add(convertUserRepresentationToUserProfile(user, tenantId));
-                        break;
-                    }
-                }
-            }
-            logger.debug("getUsersWithRole: most recent users with role count=" + usersWithRole.size());
-            return usersWithRole;
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                logger.debug("getUsersWithRole: closing client...");
-                client.close();
-                logger.debug("getUsersWithRole: client closed");
-            }
-        }
-    }
-
-    public List<String> getUserRoles(PasswordCredential realmAdminCreds, String tenantId, String username) throws IamAdminServicesException {
-        Keycloak client = null;
-        try{
-            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
-            List<UserRepresentation> userRepresentationList = client.realm(tenantId).users().search(username,
-                    null,
-                    null,
-                    null,
-                    0, 1);
-            if (userRepresentationList.isEmpty()) {
-                logger.warn("No Keycloak user found for username [" + username + "] in tenant [" + tenantId + "].");
-                return null;
-            }
-            UserResource retrievedUser = client.realm(tenantId).users().get(userRepresentationList.get(0).getId());
-            return retrievedUser.roles().realmLevel().listAll()
-                    .stream()
-                    .map(roleRepresentation -> roleRepresentation.getName())
-                    .collect(Collectors.toList());
-        } catch (ApplicationSettingsException ex) {
-            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
-            IamAdminServicesException exception = new IamAdminServicesException();
-            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
-            throw exception;
-        } finally {
-            if (client != null) {
-                logger.debug("getUserRoles: closing client...");
-                client.close();
-                logger.debug("getUserRoles: client closed");
-            }
-        }
-    }
-
-    private UserProfile convertUserRepresentationToUserProfile(UserRepresentation userRepresentation, String tenantId) {
-
-        UserProfile profile = new UserProfile();
-        profile.setCustosInternalUserId(userRepresentation.getUsername() + "@" + tenantId);
-        profile.setGatewayId(tenantId);
-        profile.setUserId(userRepresentation.getUsername());
-        profile.setFirstName(userRepresentation.getFirstName());
-        profile.setLastName(userRepresentation.getLastName());
-        profile.setEmails(Arrays.asList(new String[]{userRepresentation.getEmail()}));
-        profile.setCreationTime(userRepresentation.getCreatedTimestamp());
-
-        // Just default these. UserProfile isn't a great data model for this data since it isn't actually the Airavata UserProfile
-        profile.setLastAccessTime(0);
-        profile.setValidUntil(0);
-        // Use state field to indicate whether user has been enabled or email verified in Keycloak
-        if (userRepresentation.isEnabled()) {
-            profile.setState(Status.ACTIVE);
-        } else if (userRepresentation.isEmailVerified()) {
-            profile.setState(Status.CONFIRMED);
-        } else {
-            profile.setState(Status.PENDING_CONFIRMATION);
-        }
-
-        return profile;
-    }
-
-    private static UserRepresentation getUserByUsername(Keycloak client, String tenantId, String username) {
-
-        // Searching for users by username returns also partial matches, so need to filter down to an exact match if it exists
-        List<UserRepresentation> userResourceList = client.realm(tenantId).users().search(
-                username, null, null, null, null, null);
-        for (UserRepresentation userRepresentation : userResourceList) {
-            if (userRepresentation.getUsername().equals(username)) {
-                return userRepresentation;
-            }
-        }
-        return null;
-    }
-
-//    public static void main(String[] args) throws IamAdminServicesException, ApplicationSettingsException {
-//        TenantManagementKeycloakImpl tenantManagementKeycloak = new TenantManagementKeycloakImpl();
-//        ServerSettings.setSetting("trust.store", "./modules/configuration/server/src/main/resources/client_truststore.jks");
-//        ServerSettings.setSetting("trust.store.password", "airavata");
-//        ServerSettings.setSetting("iam.server.url", "");
-//        String accessToken = "";
-//        String tenantId = "";
-//        String username = "";
-//        boolean isUsernameAvailable = tenantManagementKeycloak.isUsernameAvailable(accessToken, tenantId, username);
-//        System.out.println("Username " + username + " is " + (isUsernameAvailable ? "": "NOT ") + "available");
-//    }
-}
diff --git a/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java b/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java
deleted file mode 100644
index 1d4a141..0000000
--- a/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- *
- * 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.custos.profile.iam.admin.services.core.interfaces;
-
-import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
-import org.apache.custos.profile.model.tenant.PasswordCredential;
-import org.apache.custos.profile.model.user.UserProfile;
-import org.apache.custos.profile.model.workspace.Gateway;
-
-import java.util.List;
-
-public interface TenantManagementInterface {
-
-    /**
-     * Method to add Identity server tenant for Custos gateway creation.
-     *
-     * @param isSuperAdminPasswordCreds identity server super admin credentials
-     * @param gatewayDetails gateway details from workspace catalog
-     * @return Gateway object.
-     */
-    Gateway addTenant(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException;
-
-    /**
-     * Method to add tenant Admin account in Identity Server.
-     *
-     * @param isSuperAdminPasswordCreds identity server super admin credentials
-     * @param gatewayDetails gateway details from workspace catalog
-     * @param gatewayAdminPassword password to use when creating tenant admin account
-     * @return Gateway object.
-     */
-    boolean createTenantAdminAccount(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails, String gatewayAdminPassword) throws IamAdminServicesException;
-
-    /**
-     * Method to configure application client in Identity Server
-     *
-     * @param isSuperAdminPasswordCreds identity server super admin credentials
-     * @param gatewayDetails gateway details from workspace catalog
-     * @return Gateway object.
-     */
-    Gateway configureClient(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException;
-
-    /**
-     * Check if username is available to be used for creating a new user account.
-     * @param accessToken needs to have access to searching across users by username
-     * @param tenantId
-     * @param username
-     * @return
-     */
-    boolean isUsernameAvailable(String accessToken, String tenantId, String username) throws IamAdminServicesException;
-
-    /**
-     * Method to create user in Identity Server
-     *
-     * @param accessToken
-     * @param tenantId
-     * @param username
-     * @param emailAddress
-     * @param firstName
-     * @param lastName
-     * @param newPassword
-     * @return true if user created
-     * @throws IamAdminServicesException
-     */
-    boolean createUser(String accessToken, String tenantId, String username, String emailAddress, String firstName, String lastName, String newPassword) throws IamAdminServicesException;
-
-    /**
-     * Method to enable user in Identity Server
-     *
-     * @param accessToken
-     * @param tenantId
-     * @param username
-     * @return boolean.
-     */
-    boolean enableUserAccount(String accessToken, String tenantId, String username) throws IamAdminServicesException;
-
-    /**
-     * Method to check if user is enabled in Identity Server
-     *
-     * @param accessToken
-     * @param tenantId
-     * @param username
-     * @return boolean.
-     */
-    boolean isUserAccountEnabled(String accessToken, String tenantId, String username) throws IamAdminServicesException;
-
-    /**
-     * Return whether user exists with username.
-     *
-     * @param accessToken
-     * @param tenantId
-     * @param username
-     * @return
-     */
-    boolean isUserExist(String accessToken, String tenantId, String username) throws IamAdminServicesException;
-
-    /**
-     * Get user profile information from Identity Server
-     *
-     * @param accessToken
-     * @param tenantId
-     * @param username
-     * @return
-     */
-    UserProfile getUser(String accessToken, String tenantId, String username) throws IamAdminServicesException;
-
-    /**
-     * Get a paginated list of user profiles from Identity Server
-     * 
-     * @param accessToken
-     * @param tenantId
-     * @param offset
-     * @param limit
-     * @param search String - optional, if specified used to search user profiles
-     * @return
-     * @throws IamAdminServicesException
-     */
-    List<UserProfile> getUsers(String accessToken, String tenantId, int offset, int limit, String search) throws IamAdminServicesException;
-
-    /**
-     * Method to reset user password in Identity Server
-     *
-     * @param accessToken
-     * @param tenantId
-     * @param username
-     * @param newPassword
-     * @return boolean
-     */
-    boolean resetUserPassword(String accessToken, String tenantId, String username, String newPassword) throws IamAdminServicesException;
-
-    /**
-     * Method to find user in Identity Server
-     *
-     * @param accessToken
-     * @param tenantId required
-     * @param email required
-     * @param username can be null
-     * @return Gateway object.
-     */
-    List<UserProfile> findUser(String accessToken, String tenantId, String email, String username) throws IamAdminServicesException;
-
-    /**
-     * Update the user's profile in the Identity Server
-     * @param accessToken
-     * @param tenantId
-     * @param username
-     * @param userDetails
-     */
-    void updateUserProfile(String accessToken, String tenantId, String username, UserProfile userDetails) throws IamAdminServicesException;
-
-    /**
-     * Add the given role to the user.
-     *
-     * @param realmAdminCreds
-     * @param tenantId
-     * @param username
-     * @param roleName
-     * @return
-     * @throws IamAdminServicesException
-     */
-    @Deprecated
-    boolean addRoleToUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException;
-
-    /**
-     * Remove the given role from the user.
-     *
-     * @param realmAdminCreds
-     * @param tenantId
-     * @param username
-     * @param roleName
-     * @return
-     * @throws IamAdminServicesException
-     */
-    @Deprecated
-    boolean removeRoleFromUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException;
-
-    /**
-     * Get all users having the given role.
-     *
-     * @param realmAdminCreds
-     * @param tenantId
-     * @param roleName
-     * @return
-     * @throws IamAdminServicesException
-     */
-    @Deprecated
-    List<UserProfile> getUsersWithRole(PasswordCredential realmAdminCreds, String tenantId, String roleName) throws IamAdminServicesException;
-}
diff --git a/custos-profile-service/iam-admin-services-core/src/test/java/org/apache/custos/profile/iam/admin/services/core/tests/SetupNewGateway.java b/custos-profile-service/iam-admin-services-core/src/test/java/org/apache/custos/profile/iam/admin/services/core/tests/SetupNewGateway.java
deleted file mode 100644
index c96d0f0..0000000
--- a/custos-profile-service/iam-admin-services-core/src/test/java/org/apache/custos/profile/iam/admin/services/core/tests/SetupNewGateway.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package org.apache.custos.profile.iam.admin.services.core.tests;
-
-import org.apache.custos.profile.model.tenant.PasswordCredential;
-import org.apache.custos.profile.model.user.UserProfile;
-import org.apache.custos.profile.model.workspace.Gateway;
-import org.apache.custos.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl;
-import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SetupNewGateway {
-
-    private final static Logger logger = LoggerFactory.getLogger(SetupNewGateway.class);
-
-    public static void main(String[] args) {
-        findUser();
-//        final PasswordCredential tenantAdminCreds = createTenantAdminCreds("tenant", "admin", "admin-password");
-//        getUserRoles(tenantAdminCreds, "username");
-    }
-
-    public static void setUpGateway(){
-        Gateway testGateway = new Gateway();
-        testGateway.setGatewayId("maven.test.gateway");
-        testGateway.setGatewayName("maven test gateway");
-        testGateway.setIdentityServerUserName("mavenTest");
-        testGateway.setGatewayAdminFirstName("Maven");
-        testGateway.setGatewayAdminLastName("Test");
-        testGateway.setGatewayAdminEmail("some.man@gmail.com");
-        PasswordCredential superAdminCreds = new PasswordCredential();
-        superAdminCreds.setGatewayId(testGateway.getGatewayId());
-        superAdminCreds.setDescription("test credentials for IS admin creation");
-        superAdminCreds.setLoginUserName("airavataAdmin");
-        superAdminCreds.setPassword("Airavata@123");
-        superAdminCreds.setPortalUserName("superAdmin");
-        TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
-        try {
-            client.addTenant(superAdminCreds, testGateway);
-            if (!client.createTenantAdminAccount(superAdminCreds, testGateway, "Test@123")) {
-                logger.error("Admin account creation failed !!, please refer error logs for reason");
-            }
-            Gateway gatewayWithIdAndSecret = client.configureClient(superAdminCreds, testGateway);
-            System.out.println(gatewayWithIdAndSecret.getOauthClientId());
-            System.out.println(gatewayWithIdAndSecret.getOauthClientSecret());
-        } catch (IamAdminServicesException ex) {
-            logger.error("Gateway Setup Failed, reason: " + ex.getCause(), ex);
-        }
-    }
-     public static void UserRegistration(){
-         UserProfile user = new UserProfile();
-         user.setUserId("testuser");
-         user.setFirstName("test-firstname");
-         user.setLastName("test-lastname");
-         List<String> emails = new ArrayList<>();
-         emails.add("some.man@outlook.com");
-         user.setGatewayId("maven.test.gateway");
-         user.setEmails(emails);
-        PasswordCredential tenantAdminCreds = new PasswordCredential();
-         tenantAdminCreds.setGatewayId(user.getGatewayId());
-         tenantAdminCreds.setDescription("test credentials for tenant admin creation");
-         tenantAdminCreds.setLoginUserName("mavenTest");
-         tenantAdminCreds.setPassword("Test@1234");
-         tenantAdminCreds.setPortalUserName("TenantAdmin");
-
-         TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
-         try {
-             // FIXME: get an access token from tenant admin creds
-             String accessToken = "";
-             client.createUser(accessToken, user.getGatewayId(), user.getUserId(), user.getEmails().get(0), user.getFirstName(), user.getLastName(),"test@123");
-             client.enableUserAccount(accessToken, user.getGatewayId(), user.getUserId());
-         } catch (IamAdminServicesException e) {
-             e.printStackTrace();
-         }
-     }
-
-//     public static void resetPassword(){
-//         UserProfile user = new UserProfile();
-//         user.setUserId("testuser");
-//         List<String> emails = new ArrayList<>();
-//         emails.add("some.man@outlook.com");
-//         user.setGatewayId("maven.test.gateway");
-//         user.setEmails(emails);
-//         TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
-//         try {
-//             PasswordCredential tenantAdminCreds = new PasswordCredential();
-//             tenantAdminCreds.setGatewayId(user.getGatewayId());
-//             tenantAdminCreds.setDescription("test credentials for tenant admin creation");
-//             tenantAdminCreds.setLoginUserName("mavenTest");
-//             tenantAdminCreds.setPassword("Test@1234");
-//             tenantAdminCreds.setPortalUserName("TenantAdmin");
-//             client.resetUserPassword(tenantAdminCreds,user,"test@123");
-//         } catch (IamAdminServicesException e) {
-//             e.printStackTrace();
-//         }
-//     }
-
-     public static void findUser(){
-         UserProfile user = new UserProfile();
-
-         List<String> emails = new ArrayList<>();
-         emails.add("some.man@outlook.com");
-         user.setGatewayId("maven.test.gateway");
-         user.setEmails(emails);
-         TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
-         try {
-             PasswordCredential tenantAdminCreds = new PasswordCredential();
-             tenantAdminCreds.setGatewayId(user.getGatewayId());
-             tenantAdminCreds.setDescription("test credentials for tenant admin creation");
-             tenantAdminCreds.setLoginUserName("mavenTest");
-             tenantAdminCreds.setPassword("Test@1234");
-             tenantAdminCreds.setPortalUserName("TenantAdmin");
-             // FIXME: get an access token from tenant admin creds
-             String accessToken = "";
-             List<UserProfile> list = client.findUser(accessToken,"maven.test.gateway","some.man@outlook.com",null);
-             System.out.println(list.get(0).getUserId());
-         } catch (IamAdminServicesException e) {
-             e.printStackTrace();
-         }
-     }
-
-     public static void getUserRoles(PasswordCredential tenantAdminCreds, String username) {
-         TenantManagementKeycloakImpl keycloakClient = new TenantManagementKeycloakImpl();
-
-         try {
-             List<String> roleNames = keycloakClient.getUserRoles(tenantAdminCreds, tenantAdminCreds.getGatewayId(), username);
-             System.out.println("Roles=" + roleNames);
-         } catch (IamAdminServicesException e) {
-             e.printStackTrace();
-         }
-     }
-
-    private static PasswordCredential createTenantAdminCreds(String tenantId, String username, String password) {
-        PasswordCredential tenantAdminCreds = new PasswordCredential();
-        tenantAdminCreds.setGatewayId(tenantId);
-        tenantAdminCreds.setLoginUserName(username);
-        tenantAdminCreds.setPassword(password);
-        return tenantAdminCreds;
-    }
-}
diff --git a/custos-profile-service/pom.xml b/custos-profile-service/pom.xml
deleted file mode 100644
index 1857392..0000000
--- a/custos-profile-service/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>custos</artifactId>
-        <groupId>org.apache.custos</groupId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>profile-service</artifactId>
-    <packaging>pom</packaging>
-    <name>profile-service</name>
-    <modules>
-        <module>iam-admin-services-core</module>
-        <module>profile-tenant-core</module>
-        <module>profile-user-core</module>
-        <module>profile-service-server</module>
-        <module>profile-service-commons</module>
-        <module>profile-service-model</module>
-        <module>profile-service-stubs</module>
-    </modules>
-</project>
\ No newline at end of file
diff --git a/custos-profile-service/profile-service-commons/pom.xml b/custos-profile-service/profile-service-commons/pom.xml
deleted file mode 100644
index 184a4cf..0000000
--- a/custos-profile-service/profile-service-commons/pom.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--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. -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>profile-service</artifactId>
-        <groupId>org.apache.custos</groupId>
-        <version>1.0-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>profile-service-commons</artifactId>
-    <name>Custos Profile Service Commons</name>
-    <description>Module to expose a profile-service-commons as a thrift service</description>
-
-    <properties>
-        <derby.version>10.11.1.1</derby.version>
-        <surefire.version>2.18.1</surefire.version>
-        <skipTests>true</skipTests>
-        <mysql.connector.version>5.1.34</mysql.connector.version>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>net.sf.dozer</groupId>
-            <artifactId>dozer</artifactId>
-            <version>5.4.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa</artifactId>
-            <version>${openjpa.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-            <version>${mysql.connector.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.derby</groupId>
-            <artifactId>derby</artifactId>
-            <version>${derby.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.derby</groupId>
-            <artifactId>derbyclient</artifactId>
-            <version>${derby.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.derby</groupId>
-            <artifactId>derbynet</artifactId>
-            <version>${derby.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.derby</groupId>
-            <artifactId>derbytools</artifactId>
-            <version>${derby.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>custos-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>profile-service-models</artifactId>
-            <version>1.0-SNAPSHOT</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.1</version>
-                <configuration>
-                    <source>1.8</source>
-                    <target>1.8</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.openjpa</groupId>
-                <artifactId>openjpa-maven-plugin</artifactId>
-                <version>2.4.3</version>
-                <configuration>
-                    <includes>**/entities/*.class</includes>
-                    <excludes>**/entities/XML*.class</excludes>
-                    <addDefaultConstructor>true</addDefaultConstructor>
-                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>enhancer</id>
-                        <phase>process-classes</phase>
-                        <goals>
-                            <goal>enhance</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>${surefire.version}</version>
-                <inherited>true</inherited>
-                <configuration>
-                    <failIfNoTests>false</failIfNoTests>
-                    <skipTests>${skipTests}</skipTests>
-                    <workingDirectory>${project.build.testOutputDirectory}</workingDirectory>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
\ No newline at end of file
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/AbstractRepository.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/AbstractRepository.java
deleted file mode 100644
index 376b4fb..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/AbstractRepository.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.repositories;
-
-import org.apache.custos.profile.commons.utils.JPAUtils;
-import org.apache.custos.profile.commons.utils.ObjectMapperSingleton;
-import org.dozer.Mapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public abstract class AbstractRepository<T, E, Id> {
-    private final static Logger logger = LoggerFactory.getLogger(AbstractRepository.class);
-
-    private Class<T> thriftGenericClass;
-    private Class<E> dbEntityGenericClass;
-
-    public AbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass) {
-        this.thriftGenericClass = thriftGenericClass;
-        this.dbEntityGenericClass = dbEntityGenericClass;
-    }
-
-    public T create(T t) {
-        return update(t);
-    }
-
-    public T update(T t) {
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        E entity = mapper.map(t, dbEntityGenericClass);
-        E persistedCopy = JPAUtils.execute(entityManager -> entityManager.merge(entity));
-        return mapper.map(persistedCopy, thriftGenericClass);
-    }
-
-    public boolean delete(Id id) {
-        JPAUtils.execute(entityManager -> {
-            E entity = entityManager.find(dbEntityGenericClass, id);
-            entityManager.remove(entity);
-            return entity;
-        });
-        return true;
-    }
-
-    public T get(Id id) {
-        E entity = JPAUtils.execute(entityManager -> entityManager
-                .find(dbEntityGenericClass, id));
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        return mapper.map(entity, thriftGenericClass);
-    }
-
-    public List<T> select(String query) {
-        List resultSet = (List) JPAUtils.execute(entityManager -> entityManager.createQuery(query).getResultList());
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        List<T> resultList = new ArrayList<>();
-        resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, thriftGenericClass)));
-        return resultList;
-    }
-
-    public List<T> select(String query, int limit, int offset) {
-        List resultSet = (List) JPAUtils.execute(entityManager -> entityManager.createQuery(query).setFirstResult(offset)
-                .setMaxResults(limit).getResultList());
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        List<T> resultList = new ArrayList<>();
-        resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, thriftGenericClass)));
-        return resultList;
-    }
-
-    public List<T> select(String query, int limit, int offset, Map<String, Object> queryParams) {
-        List resultSet = (List) JPAUtils.execute(entityManager -> {
-            Query jpaQuery = entityManager.createQuery(query);
-
-            for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
-
-                jpaQuery.setParameter(entry.getKey(), entry.getValue());
-            }
-
-            return jpaQuery.setFirstResult(offset).setMaxResults(limit).getResultList();
-
-        });
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        List<T> resultList = new ArrayList<>();
-        resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, thriftGenericClass)));
-        return resultList;
-    }
-
-    public List<T> select(String query, Map<String, Object> queryParams) {
-        List resultSet = (List) JPAUtils.execute(entityManager -> {
-            Query jpaQuery = entityManager.createQuery(query);
-
-            for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
-
-                jpaQuery.setParameter(entry.getKey(), entry.getValue());
-            }
-
-            return jpaQuery.getResultList();
-
-        });
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        List<T> resultList = new ArrayList<>();
-        resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, thriftGenericClass)));
-        return resultList;
-    }
-}
\ No newline at end of file
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/tenant/entities/GatewayEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/tenant/entities/GatewayEntity.java
deleted file mode 100644
index 8f68815..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/tenant/entities/GatewayEntity.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/**
- *
- * 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.custos.profile.commons.tenant.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-import java.util.UUID;
-
-@Entity
-@Table(name = "GATEWAY")
-public class GatewayEntity {
-    private final static Logger logger = LoggerFactory.getLogger(GatewayEntity.class);
-    private String custosInternalGatewayId;
-    private String gatewayId;
-    private String gatewayName;
-    private String domain;
-    private String emailAddress;
-    private String gatewayApprovalStatus;
-    private String gatewayAcronym;
-    private String gatewayUrl;
-    private String gatewayPublicAbstract;
-    private String reviewProposalDescription;
-    private String gatewayAdminFirstName;
-    private String gatewayAdminLastName;
-    private String gatewayAdminEmail;
-    private String identityServerUserName;
-    private String identityServerPasswordToken;
-    private String declinedReason;
-    private String oauthClientId;
-    private String oauthClientSecret;
-    private long requestCreationTime;
-    private String requesterUsername;
-
-    // set random value for internalGatewayId
-    public GatewayEntity() {
-        this.custosInternalGatewayId = UUID.randomUUID().toString();
-    }
-
-    @Id
-    @Column(name = "CUSTOS_INTERNAL_GATEWAY_ID")
-    public String getCustosInternalGatewayId() {
-        return custosInternalGatewayId;
-    }
-
-    public void setCustosInternalGatewayId(String custosInternalGatewayId) {
-        this.custosInternalGatewayId = custosInternalGatewayId;
-    }
-
-    @Column(name = "GATEWAY_ID")
-    public String getGatewayId() {
-        return gatewayId;
-    }
-
-    public void setGatewayId(String gatewayId) {
-        this.gatewayId = gatewayId;
-    }
-
-    @Column(name = "GATEWAY_NAME")
-    public String getGatewayName() {
-        return gatewayName;
-    }
-
-    public void setGatewayName(String gatewayName) {
-        this.gatewayName = gatewayName;
-    }
-
-    @Column(name = "GATEWAY_DOMAIN")
-    public String getDomain() {
-        return domain;
-    }
-
-    public void setDomain(String domain) {
-        this.domain = domain;
-    }
-
-    @Column(name = "EMAIL_ADDRESS")
-    public String getEmailAddress() {
-        return emailAddress;
-    }
-
-    public void setEmailAddress(String emailAddress) {
-        this.emailAddress = emailAddress;
-    }
-
-    @Column(name = "GATEWAY_APPROVAL_STATUS")
-    public String getGatewayApprovalStatus() {
-        return gatewayApprovalStatus;
-    }
-
-    public void setGatewayApprovalStatus(String gatewayApprovalStatus) {
-        this.gatewayApprovalStatus = gatewayApprovalStatus;
-    }
-
-    @Column(name = "GATEWAY_ACRONYM")
-    public String getGatewayAcronym() {
-        return gatewayAcronym;
-    }
-
-    public void setGatewayAcronym(String gatewayAcronym) {
-        this.gatewayAcronym = gatewayAcronym;
-    }
-
-    @Column(name = "GATEWAY_URL")
-    public String getGatewayUrl() {
-        return gatewayUrl;
-    }
-
-    public void setGatewayUrl(String gatewayUrl) {
-        this.gatewayUrl = gatewayUrl;
-    }
-
-    @Column(name = "GATEWAY_PUBLIC_ABSTRACT")
-    public String getGatewayPublicAbstract() {
-        return gatewayPublicAbstract;
-    }
-
-    public void setGatewayPublicAbstract(String gatewayPublicAbstract) {
-        this.gatewayPublicAbstract = gatewayPublicAbstract;
-    }
-
-    @Column(name = "GATEWAY_REVIEW_PROPOSAL_DESCRIPTION")
-    public String getReviewProposalDescription() {
-        return reviewProposalDescription;
-    }
-
-    public void setReviewProposalDescription(String reviewProposalDescription) {
-        this.reviewProposalDescription = reviewProposalDescription;
-    }
-
-    @Column(name = "GATEWAY_ADMIN_FIRST_NAME")
-    public String getGatewayAdminFirstName() {
-        return gatewayAdminFirstName;
-    }
-
-    public void setGatewayAdminFirstName(String gatewayAdminFirstName) {
-        this.gatewayAdminFirstName = gatewayAdminFirstName;
-    }
-
-    @Column(name = "GATEWAY_ADMIN_LAST_NAME")
-    public String getGatewayAdminLastName() {
-        return gatewayAdminLastName;
-    }
-
-    public void setGatewayAdminLastName(String gatewayAdminLastName) {
-        this.gatewayAdminLastName = gatewayAdminLastName;
-    }
-
-    @Column(name = "GATEWAY_ADMIN_EMAIL")
-    public String getGatewayAdminEmail() {
-        return gatewayAdminEmail;
-    }
-
-    public void setGatewayAdminEmail(String gatewayAdminEmail) {
-        this.gatewayAdminEmail = gatewayAdminEmail;
-    }
-
-    @Column(name = "IDENTITY_SERVER_USERNAME")
-    public String getIdentityServerUserName() {
-        return identityServerUserName;
-    }
-
-    public void setIdentityServerUserName(String identityServerUserName) {
-        this.identityServerUserName = identityServerUserName;
-    }
-
-    @Column(name = "IDENTITY_SERVER_PASSWORD_TOKEN")
-    public String getIdentityServerPasswordToken() {
-        return identityServerPasswordToken;
-    }
-
-    public void setIdentityServerPasswordToken(String identityServerPasswordToken) {
-        this.identityServerPasswordToken = identityServerPasswordToken;
-    }
-
-    @Column(name = "REQUESTER_USERNAME")
-    public String getRequesterUsername() {
-        return requesterUsername;
-    }
-
-    public void setRequesterUsername(String requesterUsername) {
-        this.requesterUsername = requesterUsername;
-    }
-
-    @Column(name = "DECLINED_REASON")
-    public String getDeclinedReason() {
-        return declinedReason;
-    }
-
-    public void setDeclinedReason(String declinedReason) {
-        this.declinedReason = declinedReason;
-    }
-
-    @Column(name = "OAUTH_CLIENT_ID")
-    public String getOauthClientId() {
-        return oauthClientId;
-    }
-
-    public void setOauthClientId(String oauthClientId) {
-        this.oauthClientId = oauthClientId;
-    }
-
-    @Column(name = "REQUEST_CREATION_TIME")
-    public long getRequestCreationTime() {
-        return requestCreationTime;
-    }
-
-    public void setRequestCreationTime(long requestCreationTime) {
-        this.requestCreationTime = requestCreationTime;
-    }
-
-    @Column(name = "OAUTH_CLIENT_SECRET")
-    public String getOauthClientSecret() {
-        return oauthClientSecret;
-    }
-
-    public void setOauthClientSecret(String oauthClientSecret) {
-        this.oauthClientSecret = oauthClientSecret;
-    }
-
-    @PrePersist
-    void createdAt() {
-        this.requestCreationTime = System.currentTimeMillis();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (!(obj instanceof GatewayEntity)) {
-            return false;
-        }
-        GatewayEntity gwy = (GatewayEntity) obj;
-        return getCustosInternalGatewayId().equals(gwy.getCustosInternalGatewayId());
-    }
-
-    @Override
-    public String toString() {
-        return "GatewayEntity{" +
-                "custosInternalGatewayId='" + custosInternalGatewayId + '\'' +
-                ", gatewayId='" + gatewayId + '\'' +
-                ", gatewayName='" + gatewayName + '\'' +
-                ", domain='" + domain + '\'' +
-                ", emailAddress='" + emailAddress + '\'' +
-                ", gatewayApprovalStatus='" + gatewayApprovalStatus + '\'' +
-                ", gatewayAcronym='" + gatewayAcronym + '\'' +
-                ", gatewayUrl='" + gatewayUrl + '\'' +
-                ", gatewayPublicAbstract='" + gatewayPublicAbstract + '\'' +
-                ", reviewProposalDescription='" + reviewProposalDescription + '\'' +
-                ", gatewayAdminFirstName='" + gatewayAdminFirstName + '\'' +
-                ", gatewayAdminLastName='" + gatewayAdminLastName + '\'' +
-                ", gatewayAdminEmail='" + gatewayAdminEmail + '\'' +
-                ", identityServerUserName='" + identityServerUserName + '\'' +
-                ", identityServerPasswordToken='" + identityServerPasswordToken + '\'' +
-                ", declinedReason='" + declinedReason + '\'' +
-                ", oauthClientId='" + oauthClientId + '\'' +
-                ", oauthClientSecret='" + oauthClientSecret + '\'' +
-                ", requestCreationTime=" + requestCreationTime +
-                ", requesterUsername='" + requesterUsername + '\'' +
-                '}';
-    }
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/CustomizedDashboardEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/CustomizedDashboardEntity.java
deleted file mode 100644
index d92cc25..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/CustomizedDashboardEntity.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.user.entities;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "CUSTOMIZED_DASHBOARD")
-public class CustomizedDashboardEntity {
-
-    private String custosInternalUserId;
-    private String experimentId;
-    private String name;
-    private String description;
-    private String project;
-    private String owner;
-    private String application;
-    private String computeResource;
-    private String jobName;
-    private String jobId;
-    private String jobStatus;
-    private String jobCreationTime;
-    private String notificationsTo;
-    private String workingDir;
-    private String jobDescription;
-    private String creationTime;
-    private String lastModifiedTime;
-    private String wallTime;
-    private String cpuCount;
-    private String nodeCount;
-    private String queue;
-    private String inputs;
-    private String outputs;
-    private String storageDir;
-    private String errors;
-
-    private UserProfileEntity userProfileEntity;
-
-    @Id
-    @Column(name = "CUSTOS_INTERNAL_USER_ID")
-    public String getCustosInternalUserId() {
-        return custosInternalUserId;
-    }
-
-    public void setCustosInternalUserId(String custosInternalUserId) {
-        this.custosInternalUserId = custosInternalUserId;
-    }
-
-    @Column(name = "ENABLED_EXPERIMENT_ID")
-    public String getExperimentId() {
-        return experimentId;
-    }
-
-    public void setExperimentId(String experimentId) {
-        this.experimentId = experimentId;
-    }
-
-    @Column(name = "ENABLED_NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Column(name = "ENABLED_DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Column(name = "ENABLED_PROJECT")
-    public String getProject() {
-        return project;
-    }
-
-    public void setProject(String project) {
-        this.project = project;
-    }
-
-    @Column(name = "ENABLED_OWNER")
-    public String getOwner() {
-        return owner;
-    }
-
-    public void setOwner(String owner) {
-        this.owner = owner;
-    }
-
-    @Column(name = "ENABLED_APPLICATION")
-    public String getApplication() {
-        return application;
-    }
-
-    public void setApplication(String application) {
-        this.application = application;
-    }
-
-    @Column(name = "ENABLED_COMPUTE_RESOURCE")
-    public String getComputeResource() {
-        return computeResource;
-    }
-
-    public void setComputeResource(String computeResource) {
-        this.computeResource = computeResource;
-    }
-
-    @Column(name = "ENABLED_JOB_NAME")
-    public String getJobName() {
-        return jobName;
-    }
-
-    public void setJobName(String jobName) {
-        this.jobName = jobName;
-    }
-
-    @Column(name = "ENABLED_JOB_ID")
-    public String getJobId() {
-        return jobId;
-    }
-
-    public void setJobId(String jobId) {
-        this.jobId = jobId;
-    }
-
-    @Column(name = "ENABLED_JOB_STATUS")
-    public String getJobStatus() {
-        return jobStatus;
-    }
-
-    public void setJobStatus(String jobStatus) {
-        this.jobStatus = jobStatus;
-    }
-
-    @Column(name = "ENABLED_JOB_CREATION_TIME")
-    public String getJobCreationTime() {
-        return jobCreationTime;
-    }
-
-    public void setJobCreationTime(String jobCreationTime) {
-        this.jobCreationTime = jobCreationTime;
-    }
-
-    @Column(name = "ENABLED_NOTIFICATIONS_TO")
-    public String getNotificationsTo() {
-        return notificationsTo;
-    }
-
-    public void setNotificationsTo(String notificationsTo) {
-        this.notificationsTo = notificationsTo;
-    }
-
-    @Column(name = "ENABLED_WORKING_DIR")
-    public String getWorkingDir() {
-        return workingDir;
-    }
-
-    public void setWorkingDir(String workingDir) {
-        this.workingDir = workingDir;
-    }
-
-    @Column(name = "ENABLED_JOB_DESCRIPTION")
-    public String getJobDescription() {
-        return jobDescription;
-    }
-
-    public void setJobDescription(String jobDescription) {
-        this.jobDescription = jobDescription;
-    }
-
-    @Column(name = "ENABLED_CREATION_TIME")
-    public String getCreationTime() {
-        return creationTime;
-    }
-
-    public void setCreationTime(String creationTime) {
-        this.creationTime = creationTime;
-    }
-
-    @Column(name = "ENABLED_LAST_MODIFIED_TIME")
-    public String getLastModifiedTime() {
-        return lastModifiedTime;
-    }
-
-    public void setLastModifiedTime(String lastModifiedTime) {
-        this.lastModifiedTime = lastModifiedTime;
-    }
-
-    @Column(name = "ENABLED_WALL_TIME")
-    public String getWallTime() {
-        return wallTime;
-    }
-
-    public void setWallTime(String wallTime) {
-        this.wallTime = wallTime;
-    }
-
-    @Column(name = "ENABLED_CPU_COUNT")
-    public String getCpuCount() {
-        return cpuCount;
-    }
-
-    public void setCpuCount(String cpuCount) {
-        this.cpuCount = cpuCount;
-    }
-
-    @Column(name = "ENABLED_NODE_COUNT")
-    public String getNodeCount() {
-        return nodeCount;
-    }
-
-    public void setNodeCount(String nodeCount) {
-        this.nodeCount = nodeCount;
-    }
-
-    @Column(name = "ENABLED_QUEUE")
-    public String getQueue() {
-        return queue;
-    }
-
-    public void setQueue(String queue) {
-        this.queue = queue;
-    }
-
-    @Column(name = "ENABLED_INPUTS")
-    public String getInputs() {
-        return inputs;
-    }
-
-    public void setInputs(String inputs) {
-        this.inputs = inputs;
-    }
-
-    @Column(name = "ENABLED_OUTPUTS")
-    public String getOutputs() {
-        return outputs;
-    }
-
-    public void setOutputs(String outputs) {
-        this.outputs = outputs;
-    }
-
-    @Column(name = "ENABLED_STORAGE_DIR")
-    public String getStorageDir() {
-        return storageDir;
-    }
-
-    public void setStorageDir(String storageDir) {
-        this.storageDir = storageDir;
-    }
-
-    @Column(name = "ENABLED_ERRORS")
-    public String getErrors() {
-        return errors;
-    }
-
-    public void setErrors(String errors) {
-        this.errors = errors;
-    }
-
-    @OneToOne(targetEntity = UserProfileEntity.class, cascade = CascadeType.ALL)
-    @PrimaryKeyJoinColumn(name = "CUSTOS_INTERNAL_USER_ID", referencedColumnName = "CUSTOS_INTERNAL_USER_ID")
-    public UserProfileEntity getUserProfileEntity() {
-        return userProfileEntity;
-    }
-
-    public void setUserProfileEntity(UserProfileEntity userProfileEntity) {
-        this.userProfileEntity = userProfileEntity;
-    }
-
-    @Override
-    public String toString() {
-        return "CustomizedDashboardEntity{" +
-                "custosInternalUserId='" + custosInternalUserId + '\'' +
-                ", experimentId='" + experimentId + '\'' +
-                ", name='" + name + '\'' +
-                ", description='" + description + '\'' +
-                ", project='" + project + '\'' +
-                ", owner='" + owner + '\'' +
-                ", application='" + application + '\'' +
-                ", computeResource='" + computeResource + '\'' +
-                ", jobName='" + jobName + '\'' +
-                ", jobId='" + jobId + '\'' +
-                ", jobStatus='" + jobStatus + '\'' +
-                ", jobCreationTime='" + jobCreationTime + '\'' +
-                ", notificationsTo='" + notificationsTo + '\'' +
-                ", workingDir='" + workingDir + '\'' +
-                ", jobDescription='" + jobDescription + '\'' +
-                ", creationTime='" + creationTime + '\'' +
-                ", lastModifiedTime='" + lastModifiedTime + '\'' +
-                ", wallTime='" + wallTime + '\'' +
-                ", cpuCount='" + cpuCount + '\'' +
-                ", nodeCount='" + nodeCount + '\'' +
-                ", queue='" + queue + '\'' +
-                ", inputs='" + inputs + '\'' +
-                ", outputs='" + outputs + '\'' +
-                ", storageDir='" + storageDir + '\'' +
-                ", errors='" + errors + '\'' +
-                '}';
-    }
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/NSFDemographicsEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/NSFDemographicsEntity.java
deleted file mode 100644
index fdf2b90..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/NSFDemographicsEntity.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.user.entities;
-
-import javax.persistence.*;
-import java.util.List;
-
-@Entity
-@Table(name = "NSF_DEMOGRAPHIC")
-public class NSFDemographicsEntity {
-    private String custosInternalUserId;
-    private String gender;
-    private List<String> ethnicities;
-    private List<String> races;
-    private List<String> disabilities;
-    private UserProfileEntity userProfile;
-
-    @Id
-    @Column(name = "CUSTOS_INTERNAL_USER_ID")
-    public String getCustosInternalUserId() {
-        return custosInternalUserId;
-    }
-
-    public void setCustosInternalUserId(String userId) {
-        this.custosInternalUserId = userId;
-    }
-
-    @Column(name = "GENDER")
-    public String getGender() {
-        return gender;
-    }
-
-    public void setGender(String gender) {
-        this.gender = gender;
-    }
-
-    @ElementCollection
-    @CollectionTable(name="NSF_DEMOGRAPHIC_ETHNICITY", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
-    @Column(name = "ETHNICITY")
-    public List<String> getEthnicities() {
-        return ethnicities;
-    }
-
-    public void setEthnicities(List<String> ethnicities) {
-        this.ethnicities = ethnicities;
-    }
-
-    @ElementCollection
-    @CollectionTable(name="NSF_DEMOGRAPHIC_RACE", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
-    @Column(name = "RACE")
-    public List<String> getRaces() {
-        return races;
-    }
-
-    public void setRaces(List<String> races) {
-        this.races = races;
-    }
-
-    @ElementCollection
-    @CollectionTable(name="NSF_DEMOGRAPHIC_DISABILITY", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
-    @Column(name = "DISABILITY")
-    public List<String> getDisabilities() {
-        return disabilities;
-    }
-
-    public void setDisabilities(List<String> disabilities) {
-        this.disabilities = disabilities;
-    }
-
-    @OneToOne(targetEntity = UserProfileEntity.class, cascade = CascadeType.ALL)
-    @PrimaryKeyJoinColumn(name = "CUSTOS_INTERNAL_USER_ID", referencedColumnName = "CUSTOS_INTERNAL_USER_ID")
-    public UserProfileEntity getUserProfile() {
-        return userProfile;
-    }
-
-    public void setUserProfile(UserProfileEntity userProfile) {
-        this.userProfile = userProfile;
-    }
-
-    @Override
-    public String toString() {
-        return "NSFDemographicsEntity{" +
-                "custosInternalUserId='" + custosInternalUserId + '\'' +
-                ", gender='" + gender + '\'' +
-                ", ethnicities=" + ethnicities +
-                ", races=" + races +
-                ", disabilities=" + disabilities +
-                '}';
-    }
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java
deleted file mode 100644
index 04f3265..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.user.entities;
-
-import javax.persistence.*;
-import java.util.Date;
-import java.util.List;
-
-@Entity
-@Table(name="USER_PROFILE")
-public class UserProfileEntity {
-    private String custosInternalUserId;
-    private String userId;
-    private String gatewayId;
-    private String userModelVersion;
-    private String firstName;
-    private String lastName;
-    private String middleName;
-    private String namePrefix;
-    private String nameSuffix;
-    private String orcidId;
-    private String country;
-    private String homeOrganization;
-    private String orginationAffiliation;
-    private Date creationTime;
-    private Date lastAccessTime;
-    private Date validUntil;
-    private String state;
-    private String comments;
-    private List<String> labeledURI;
-    private String gpgKey;
-    private String timeZone;
-
-    private List<String> nationality;
-    private List<String> emails;
-    private List<String> phones;
-    private NSFDemographicsEntity nsfDemographics;
-    private CustomizedDashboardEntity customizedDashboardEntity;
-
-    @Id
-    @Column(name = "CUSTOS_INTERNAL_USER_ID")
-    public String getCustosInternalUserId() {
-        return custosInternalUserId;
-    }
-
-    public void setCustosInternalUserId(String id) {
-        this.custosInternalUserId = id;
-    }
-
-    @Column(name = "USER_ID")
-    public String getUserId() {
-        return userId;
-    }
-
-    public void setUserId(String userId) {
-        this.userId = userId;
-    }
-
-    @Column(name = "GATEWAY_ID")
-    public String getGatewayId() {
-        return gatewayId;
-    }
-
-    public void setGatewayId(String gatewayId) {
-        this.gatewayId = gatewayId;
-    }
-
-    @Column(name = "USER_MODEL_VERSION")
-    public String getUserModelVersion() {
-        return userModelVersion;
-    }
-
-    public void setUserModelVersion(String userModelVersion) {
-        this.userModelVersion = userModelVersion;
-    }
-
-    @ElementCollection(fetch = FetchType.EAGER)
-    @CollectionTable(name="USER_PROFILE_EMAIL", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
-    @Column(name = "EMAIL")
-    public List<String> getEmails() {
-        return emails;
-    }
-
-    public void setEmails(List<String> emails) {
-        this.emails = emails;
-    }
-
-    @Column(name = "FIRST_NAME")
-    public String getFirstName() {
-        return firstName;
-    }
-
-    public void setFirstName(String firstName) {
-        this.firstName = firstName;
-    }
-
-    @Column(name = "LAST_NAME")
-    public String getLastName() {
-        return lastName;
-    }
-
-    public void setLastName(String lastName) {
-        this.lastName = lastName;
-    }
-
-    @Column(name = "MIDDLE_NAME")
-    public String getMiddleName() {
-        return middleName;
-    }
-
-    public void setMiddleName(String middleName) {
-        this.middleName = middleName;
-    }
-
-    @Column(name = "NAME_PREFIX")
-    public String getNamePrefix() {
-        return namePrefix;
-    }
-
-    public void setNamePrefix(String namePrefix) {
-        this.namePrefix = namePrefix;
-    }
-
-    @Column(name = "NAME_SUFFIX")
-    public String getNameSuffix() {
-        return nameSuffix;
-    }
-
-    public void setNameSuffix(String nameSuffix) {
-        this.nameSuffix = nameSuffix;
-    }
-
-    @Column(name = "ORCID_ID")
-    public String getOrcidId() {
-        return orcidId;
-    }
-
-    public void setOrcidId(String orcidId) {
-        this.orcidId = orcidId;
-    }
-
-    @ElementCollection(fetch = FetchType.EAGER)
-    @CollectionTable(name="USER_PROFILE_PHONE", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
-    @Column(name = "PHONE")
-    public List<String> getPhones() {
-        return phones;
-    }
-
-    public void setPhones(List<String> phones) {
-        this.phones = phones;
-    }
-
-    @Column(name = "COUNTRY")
-    public String getCountry() {
-        return country;
-    }
-
-    public void setCountry(String country) {
-        this.country = country;
-    }
-
-    @ElementCollection(fetch = FetchType.EAGER)
-    @CollectionTable(name="USER_PROFILE_NATIONALITY", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
-    @Column(name = "NATIONALITY")
-    public List<String> getNationality() {
-        return nationality;
-    }
-
-    public void setNationality(List<String> nationality) {
-        this.nationality = nationality;
-    }
-
-    @Column(name = "HOME_ORGANIZATION")
-    public String getHomeOrganization() {
-        return homeOrganization;
-    }
-
-    public void setHomeOrganization(String homeOrganization) {
-        this.homeOrganization = homeOrganization;
-    }
-
-    @Column(name = "ORIGINATION_AFFILIATION")
-    public String getOrginationAffiliation() {
-        return orginationAffiliation;
-    }
-
-    public void setOrginationAffiliation(String orginationAffiliation) {
-        this.orginationAffiliation = orginationAffiliation;
-    }
-
-    @Column(name="CREATION_TIME")
-    public Date getCreationTime() {
-        return creationTime;
-    }
-
-    private void setCreationTime(Date creationTime) {
-        this.creationTime = creationTime;
-    }
-
-    @Column(name = "LAST_ACCESS_TIME")
-    public Date getLastAccessTime() {
-        return lastAccessTime;
-    }
-
-    private void setLastAccessTime(Date lastAccessTime) {
-        this.lastAccessTime = lastAccessTime;
-    }
-
-    @Column(name = "VALID_UNTIL")
-    public Date getValidUntil() {
-        return validUntil;
-    }
-
-    public void setValidUntil(Date validUntil) {
-        this.validUntil = validUntil;
-    }
-
-    @Column(name = "STATE")
-    public String getState() {
-        return state;
-    }
-
-    public void setState(String state) {
-        this.state = state;
-    }
-
-    @Lob
-    @Column(name = "COMMENTS")
-    public String getComments() {
-        return comments;
-    }
-
-    public void setComments(String comments) {
-        this.comments = comments;
-    }
-
-    @ElementCollection(fetch = FetchType.EAGER)
-    @CollectionTable(name="USER_PROFILE_LABELED_URI", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
-    @Column(name = "LABELED_URI")
-    public List<String> getLabeledURI() {
-        return labeledURI;
-    }
-
-    public void setLabeledURI(List<String> labeledURI) {
-        this.labeledURI = labeledURI;
-    }
-
-    @Lob
-    @Column(name = "GPG_KEY")
-    public String getGpgKey() {
-        return gpgKey;
-    }
-
-    public void setGpgKey(String gpgKey) {
-        this.gpgKey = gpgKey;
-    }
-
-    @Column(name = "TIME_ZONE")
-    public String getTimeZone() {
-        return timeZone;
-    }
-
-    public void setTimeZone(String timeZone) {
-        this.timeZone = timeZone;
-    }
-
-    @OneToOne(targetEntity = NSFDemographicsEntity.class, cascade = CascadeType.ALL,
-            mappedBy = "userProfile", fetch = FetchType.EAGER)
-    public NSFDemographicsEntity getNsfDemographics() {
-        return nsfDemographics;
-    }
-
-    public void setNsfDemographics(NSFDemographicsEntity nsfDemographics) {
-        this.nsfDemographics = nsfDemographics;
-    }
-
-    @OneToOne(targetEntity = CustomizedDashboardEntity.class, cascade = CascadeType.ALL,
-            mappedBy = "userProfileEntity", fetch = FetchType.EAGER)
-    public CustomizedDashboardEntity getCustomizedDashboardEntity() {
-        return customizedDashboardEntity;
-    }
-
-    public void setCustomizedDashboardEntity(CustomizedDashboardEntity customizedDashboardEntity) {
-        this.customizedDashboardEntity = customizedDashboardEntity;
-    }
-
-    @PrePersist
-    void createdAt() {
-        this.creationTime = this.lastAccessTime = new Date();
-    }
-
-    @PreUpdate
-    void updatedAt() {
-        this.lastAccessTime = new Date();
-    }
-
-    @Override
-    public String toString() {
-        return "UserProfileEntity{" +
-                "custosInternalUserId='" + custosInternalUserId + '\'' +
-                ", userId='" + userId + '\'' +
-                ", gatewayId='" + gatewayId + '\'' +
-                ", userModelVersion='" + userModelVersion + '\'' +
-                ", firstName='" + firstName + '\'' +
-                ", lastName='" + lastName + '\'' +
-                ", middleName='" + middleName + '\'' +
-                ", namePrefix='" + namePrefix + '\'' +
-                ", nameSuffix='" + nameSuffix + '\'' +
-                ", orcidId='" + orcidId + '\'' +
-                ", country='" + country + '\'' +
-                ", homeOrganization='" + homeOrganization + '\'' +
-                ", orginationAffiliation='" + orginationAffiliation + '\'' +
-                ", creationTime=" + creationTime +
-                ", lastAccessTime=" + lastAccessTime +
-                ", validUntil=" + validUntil +
-                ", state='" + state + '\'' +
-                ", comments='" + comments + '\'' +
-                ", labeledURI=" + labeledURI +
-                ", gpgKey='" + gpgKey + '\'' +
-                ", timeZone='" + timeZone + '\'' +
-                ", nationality=" + nationality +
-                ", emails=" + emails +
-                ", phones=" + phones +
-                ", nsfDemographics=" + nsfDemographics +
-                '}';
-    }
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Committer.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Committer.java
deleted file mode 100644
index 5cf4ea3..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Committer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.utils;
-
-@FunctionalInterface
-public interface Committer<T, R>  {
-
-    R commit(T t);
-}
\ No newline at end of file
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAConstants.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAConstants.java
deleted file mode 100644
index 7d35b13..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAConstants.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.utils;
-
-public class JPAConstants {
-	public static final String KEY_JDBC_URL = "profile.service.jdbc.url";
-	public static final String KEY_JDBC_USER = "profile.service.jdbc.user";
-	public static final String KEY_JDBC_PASSWORD = "profile.service.jdbc.password";
-	public static final String KEY_JDBC_DRIVER = "profile.service.jdbc.driver";
-
-	// TODO: is this needed?
-	public static final String KEY_DERBY_START_ENABLE = "profile.service.start.derby.server.mode";
-	public static final String VALIDATION_QUERY = "profile.service.validationQuery";
-	public static final String JPA_CACHE_SIZE = "profile.service.jpa.cache.size";
-	public static final String ENABLE_CACHING = "profile.service.cache.enable";
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAUtils.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAUtils.java
deleted file mode 100644
index 2b881eb..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAUtils.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.utils;
-
-import org.apache.custos.commons.utils.JDBCConfig;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-public class JPAUtils {
-    private static final String PERSISTENCE_UNIT_NAME = "profile_service";
-    private static final JDBCConfig JDBC_CONFIG = new ProfileServiceJDBCConfig();
-    private static final EntityManagerFactory factory = org.apache.custos.commons.utils.JPAUtils.getEntityManagerFactory(PERSISTENCE_UNIT_NAME, JDBC_CONFIG);
-
-    public static EntityManager getEntityManager() {
-        return factory.createEntityManager();
-    }
-
-    public static <R> R execute(Committer<EntityManager, R> committer){
-        EntityManager entityManager = JPAUtils.getEntityManager();
-        try {
-            entityManager.getTransaction().begin();
-            R r = committer.commit(entityManager);
-            entityManager.getTransaction().commit();
-            return  r;
-        }finally {
-            if (entityManager != null && entityManager.isOpen()) {
-                if (entityManager.getTransaction().isActive()) {
-                    entityManager.getTransaction().rollback();
-                }
-                entityManager.close();
-            }
-        }
-    }
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ObjectMapperSingleton.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ObjectMapperSingleton.java
deleted file mode 100644
index b012b17..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ObjectMapperSingleton.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *
- * 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.custos.profile.commons.utils;
-
-import org.dozer.DozerBeanMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ObjectMapperSingleton extends DozerBeanMapper{
-    private final static Logger logger = LoggerFactory.getLogger(ObjectMapperSingleton.class);
-
-    private static ObjectMapperSingleton instance;
-
-    private ObjectMapperSingleton(){}
-
-    public static ObjectMapperSingleton getInstance(){
-        if(instance == null)
-            instance = new ObjectMapperSingleton();
-        return instance;
-    }
-}
\ No newline at end of file
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ProfileServiceJDBCConfig.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ProfileServiceJDBCConfig.java
deleted file mode 100644
index 84a1f66..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ProfileServiceJDBCConfig.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.utils;
-
-import org.apache.custos.commons.utils.JDBCConfig;
-
-public class ProfileServiceJDBCConfig implements JDBCConfig {
-
-    @Override
-    public String getURL() {
-        return Utils.getJDBCURL();
-    }
-
-    @Override
-    public String getDriver() {
-        return Utils.getJDBCDriver();
-    }
-
-    @Override
-    public String getUser() {
-        return Utils.getJDBCUser();
-    }
-
-    @Override
-    public String getPassword() {
-        return Utils.getJDBCPassword();
-    }
-
-    @Override
-    public String getValidationQuery() {
-        return Utils.getValidationQuery();
-    }
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/QueryConstants.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/QueryConstants.java
deleted file mode 100644
index 15cc267..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/QueryConstants.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.apache.custos.profile.commons.utils;
-
-import org.apache.custos.profile.model.user.UserProfile;
-import org.apache.custos.profile.model.workspace.Gateway;
-
-/**
- * Created by goshenoy on 03/08/2017.
- */
-public class QueryConstants {
-
-
-    public static final String FIND_USER_PROFILE_BY_USER_ID = "SELECT u FROM UserProfileEntity u " +
-            "where u.userId LIKE :" + UserProfile._Fields.USER_ID.getFieldName() + " " +
-            "AND u.gatewayId LIKE :" + UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
-
-    public static final String FIND_ALL_USER_PROFILES_BY_GATEWAY_ID = "SELECT u FROM UserProfileEntity u " +
-            "where u.gatewayId LIKE :" + UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
-
-    public static final String FIND_GATEWAY_BY_INTERNAL_ID = "SELECT g FROM GatewayEntity g " +
-            "where g.custosInternalGatewayId LIKE :" + Gateway._Fields.CUSTOS_INTERNAL_GATEWAY_ID.getFieldName();
-
-    public static final String FIND_GATEWAY_BY_GATEWAY_ID = "SELECT g FROM GatewayEntity g " +
-            "where g.gatewayId LIKE :" + Gateway._Fields.GATEWAY_ID.getFieldName();
-
-    public static final String FIND_DUPLICATE_GATEWAY = "SELECT g FROM GatewayEntity g " +
-            "where g.gatewayApprovalStatus IN :" + Gateway._Fields.GATEWAY_APPROVAL_STATUS.getFieldName() + " " +
-            "and (g.gatewayId LIKE :" + Gateway._Fields.GATEWAY_ID.getFieldName() + " " +
-            "     or g.gatewayName LIKE :" + Gateway._Fields.GATEWAY_NAME.getFieldName() + " " +
-            "     or g.gatewayUrl LIKE :" + Gateway._Fields.GATEWAY_URL.getFieldName() + " " +
-            "    )";
-
-    public static final String GET_ALL_GATEWAYS = "SELECT g FROM GatewayEntity g";
-
-    public static final String GET_USER_GATEWAYS = "SELECT g from GatewayEntity g " +
-            "where g.requesterUsername LIKE :" + Gateway._Fields.REQUESTER_USERNAME.getFieldName() + "";
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Utils.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Utils.java
deleted file mode 100644
index b3ddd31..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Utils.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.utils;
-
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.commons.utils.ServerSettings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.URI;
-
-
-public class Utils {
-    private final static Logger logger = LoggerFactory.getLogger(Utils.class);
-
-    public static String getJDBCURL(){
-    	try {
-            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_URL);
-		} catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static String getHost(){
-        try{
-            String jdbcURL = getJDBCURL();
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getHost();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static int getPort(){
-        try{
-            String jdbcURL = getJDBCURL();
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-
-    public static int getJPACacheSize (){
-        try {
-            String cache = ServerSettings.getSetting(JPAConstants.JPA_CACHE_SIZE, "5000");
-            return Integer.parseInt(cache);
-        }catch (Exception e){
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-
-    public static String isCachingEnabled (){
-        try {
-            return ServerSettings.getSetting(JPAConstants.ENABLE_CACHING, "true");
-        }catch (Exception e){
-            logger.error(e.getMessage(), e);
-            return "true";
-        }
-    }
-
-    public static String getJDBCUser(){
-    	try {
-		    return ServerSettings.getSetting(JPAConstants.KEY_JDBC_USER);
-		} catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-		}
-    }
-
-    public static String getValidationQuery(){
-    	try {
-            return ServerSettings.getSetting(JPAConstants.VALIDATION_QUERY);
-		} catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-		}
-    }
-
-    public static String getJDBCPassword(){
-    	try {
-            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_PASSWORD);
-		} catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-		}
-
-    }
-
-    public static String getJDBCDriver(){
-    	try {
-            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_DRIVER);
-		} catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-		}
-    }
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml b/custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index f0a162e..0000000
--- a/custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0"?>
-<!--*
- *
- * 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.
- *
-* -->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
-    <persistence-unit name="profile_service">
-        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
-        <class>org.apache.custos.profile.commons.user.entities.UserProfileEntity</class>
-        <class>org.apache.custos.profile.commons.user.entities.NSFDemographicsEntity</class>
-        <class>org.apache.custos.profile.commons.user.entities.CustomizedDashboardEntity</class>
-        <class>org.apache.custos.profile.commons.tenant.entities.GatewayEntity</class>
-        <exclude-unlisted-classes>true</exclude-unlisted-classes>
-
-        <properties>
-            <property name="openjpa.jdbc.MappingDefaults"
-                      value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade" />
-        </properties>
-    </persistence-unit>
-</persistence>
diff --git a/custos-profile-service/profile-service-model/pom.xml b/custos-profile-service/profile-service-model/pom.xml
deleted file mode 100644
index dcae7be..0000000
--- a/custos-profile-service/profile-service-model/pom.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>profile-service</artifactId>
-        <groupId>org.apache.custos</groupId>
-        <version>1.0-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
... 62691 lines suppressed ...


[airavata-custos] 04/48: corrected the sql files

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1f86fea200266ac9fc3592109fc84f3928a3c3c8
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Jun 25 08:51:38 2019 -0400

    corrected the sql files
---
 .../user-profile-catalog-derby.sql                 | 62 +++++++++++-----------
 .../user-profile-catalog-mysql.sql                 | 62 +++++++++++-----------
 pom.xml                                            |  6 +++
 3 files changed, 68 insertions(+), 62 deletions(-)

diff --git a/custos-profile-service/profile-user-core/src/main/resources/database_scripts/user-profile-catalog-derby.sql b/custos-profile-service/profile-user-core/src/main/resources/database_scripts/user-profile-catalog-derby.sql
index 9ac9155..7600772 100644
--- a/custos-profile-service/profile-user-core/src/main/resources/database_scripts/user-profile-catalog-derby.sql
+++ b/custos-profile-service/profile-user-core/src/main/resources/database_scripts/user-profile-catalog-derby.sql
@@ -20,7 +20,7 @@
  */
 
 CREATE TABLE IF NOT EXISTS GATEWAY (
-  AIRAVATA_INTERNAL_GATEWAY_ID varchar(255) NOT NULL,
+  CUSTOS_INTERNAL_GATEWAY_ID varchar(255) NOT NULL,
   DECLINED_REASON varchar(255) DEFAULT NULL,
   GATEWAY_DOMAIN varchar(255) DEFAULT NULL,
   EMAIL_ADDRESS varchar(255) DEFAULT NULL,
@@ -40,11 +40,11 @@ CREATE TABLE IF NOT EXISTS GATEWAY (
   REQUEST_CREATION_TIME bigint(20) DEFAULT NULL,
   REQUESTER_USERNAME varchar(255) DEFAULT NULL,
   GATEWAY_REVIEW_PROPOSAL_DESCRIPTION varchar(255) DEFAULT NULL,
-  PRIMARY KEY (AIRAVATA_INTERNAL_GATEWAY_ID)
+  PRIMARY KEY (CUSTOS_INTERNAL_GATEWAY_ID)
 );
 
 CREATE TABLE USER_PROFILE (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     USER_ID VARCHAR (255) NOT NULL,
     GATEWAY_ID VARCHAR (255) NOT NULL,
     USER_MODEL_VERSION VARCHAR (255),
@@ -64,67 +64,67 @@ CREATE TABLE USER_PROFILE (
     COMMENTS CLOB,
     GPG_KEY CLOB,
     TIME_ZONE VARCHAR (255),
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID)
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID)
 );
 
 CREATE TABLE USER_PROFILE_EMAIL (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     EMAIL VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, EMAIL),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, EMAIL),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE USER_PROFILE_PHONE (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     PHONE VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, PHONE ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, PHONE ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE USER_PROFILE_NATIONALITY (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     NATIONALITY VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, NATIONALITY ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, NATIONALITY ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE USER_PROFILE_LABELED_URI (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     LABELED_URI VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, LABELED_URI ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, LABELED_URI ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE NSF_DEMOGRAPHIC (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     GENDER VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE NSF_DEMOGRAPHIC_ETHNICITY (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     ETHNICITY VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, ETHNICITY ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, ETHNICITY ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE NSF_DEMOGRAPHIC_RACE (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     RACE VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, RACE ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, RACE ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE NSF_DEMOGRAPHIC_DISABILITY (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     DISABILITY VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, DISABILITY ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, DISABILITY ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE CUSTOMIZED_DASHBOARD (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     ENABLED_EXPERIMENT_ID VARCHAR (255),
     ENABLED_NAME VARCHAR (255),
     ENABLED_DESCRIPTION VARCHAR (255),
@@ -149,8 +149,8 @@ CREATE TABLE CUSTOMIZED_DASHBOARD (
     ENABLED_OUTPUTS VARCHAR (255),
     ENABLED_STORAGE_DIR VARCHAR (255),
     ENABLED_ERRORS VARCHAR (255),
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
 CREATE TABLE CONFIGURATION
diff --git a/custos-profile-service/profile-user-core/src/main/resources/database_scripts/user-profile-catalog-mysql.sql b/custos-profile-service/profile-user-core/src/main/resources/database_scripts/user-profile-catalog-mysql.sql
index bcc37af..6da1c93 100644
--- a/custos-profile-service/profile-user-core/src/main/resources/database_scripts/user-profile-catalog-mysql.sql
+++ b/custos-profile-service/profile-user-core/src/main/resources/database_scripts/user-profile-catalog-mysql.sql
@@ -20,7 +20,7 @@
  */
 
 CREATE TABLE IF NOT EXISTS GATEWAY (
-  AIRAVATA_INTERNAL_GATEWAY_ID varchar(255) NOT NULL,
+  CUSTOS_INTERNAL_GATEWAY_ID varchar(255) NOT NULL,
   DECLINED_REASON varchar(255) DEFAULT NULL,
   GATEWAY_DOMAIN varchar(255) DEFAULT NULL,
   EMAIL_ADDRESS varchar(255) DEFAULT NULL,
@@ -40,11 +40,11 @@ CREATE TABLE IF NOT EXISTS GATEWAY (
   REQUEST_CREATION_TIME bigint(20) DEFAULT NULL,
   REQUESTER_USERNAME varchar(255) DEFAULT NULL,
   GATEWAY_REVIEW_PROPOSAL_DESCRIPTION varchar(255) DEFAULT NULL,
-  PRIMARY KEY (AIRAVATA_INTERNAL_GATEWAY_ID)
+  PRIMARY KEY (CUSTOS_INTERNAL_GATEWAY_ID)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS USER_PROFILE (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     USER_ID VARCHAR (255) NOT NULL,
     GATEWAY_ID VARCHAR (255) NOT NULL,
     USER_MODEL_VERSION VARCHAR (255),
@@ -64,67 +64,67 @@ CREATE TABLE IF NOT EXISTS USER_PROFILE (
     COMMENTS TEXT,
     GPG_KEY TEXT,
     TIME_ZONE VARCHAR (255),
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID)
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS USER_PROFILE_EMAIL (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     EMAIL VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, EMAIL),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, EMAIL),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS USER_PROFILE_PHONE (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     PHONE VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, PHONE ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, PHONE ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS USER_PROFILE_NATIONALITY (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     NATIONALITY VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, NATIONALITY ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, NATIONALITY ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS USER_PROFILE_LABELED_URI (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     LABELED_URI VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, LABELED_URI ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, LABELED_URI ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS NSF_DEMOGRAPHIC (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     GENDER VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS NSF_DEMOGRAPHIC_ETHNICITY (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     ETHNICITY VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, ETHNICITY ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, ETHNICITY ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS NSF_DEMOGRAPHIC_RACE (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     RACE VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, RACE ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, RACE ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS NSF_DEMOGRAPHIC_DISABILITY (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     DISABILITY VARCHAR (255) NOT NULL,
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID, DISABILITY ),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID, DISABILITY ),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE IF NOT EXISTS CUSTOMIZED_DASHBOARD (
-    AIRAVATA_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
+    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
     ENABLED_EXPERIMENT_ID VARCHAR (255),
     ENABLED_NAME VARCHAR (255),
     ENABLED_DESCRIPTION VARCHAR (255),
@@ -149,8 +149,8 @@ CREATE TABLE IF NOT EXISTS CUSTOMIZED_DASHBOARD (
     ENABLED_OUTPUTS VARCHAR (255),
     ENABLED_STORAGE_DIR VARCHAR (255),
     ENABLED_ERRORS VARCHAR (255),
-    PRIMARY KEY (AIRAVATA_INTERNAL_USER_ID),
-    FOREIGN KEY (AIRAVATA_INTERNAL_USER_ID) REFERENCES USER_PROFILE(AIRAVATA_INTERNAL_USER_ID) ON DELETE CASCADE
+    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID),
+    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 CREATE TABLE CONFIGURATION
diff --git a/pom.xml b/pom.xml
index aa895c8..d42d29e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,6 +20,7 @@
         <module>custos-connectors</module>
         <module>custos-profile-service</module>
         <module>custos-client</module>
+        <module>ide-integration</module>
     </modules>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -45,5 +46,10 @@
             <artifactId>libthrift</artifactId>
             <version>${thrift.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.mariadb.jdbc</groupId>
+            <artifactId>mariadb-java-client</artifactId>
+            <version>2.0.2</version>
+        </dependency>
     </dependencies>
 </project>
\ No newline at end of file


[airavata-custos] 03/48: 1. modified the project structure 2. corrected the thrift files 3. modified the UserProfileHandler, IamAdminServerHandler and TenantProfileHandler

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7d1e71242cb62304bebdadd274a68cc238382068
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Jun 25 08:23:07 2019 -0400

    1. modified the project structure 2. corrected the thrift files 3. modified the UserProfileHandler, IamAdminServerHandler and TenantProfileHandler
---
 {custos-commons => custos-client}/pom.xml          |    25 +-
 .../service}/ProfileServiceClientFactory.java      |    48 +-
 custos-commons/custos-server.properties            |     0
 custos-commons/pom.xml                             |    10 +-
 .../custos/commons/model/security}/AuthzToken.java |     2 +-
 .../apache/custos/commons/utils/DBInitializer.java |    71 +
 .../org/apache/custos/commons/utils/DBUtil.java    |   307 +
 .../custos/commons/utils/DatabaseCreator.java      |   378 +
 .../org/apache/custos/commons/utils/IServer.java   |    51 +-
 .../custos/commons/utils/ServerSettings.java       |    13 +
 .../apache/custos/commons/utils/ThriftUtils.java   |    22 +-
 custos-connectors/pom.xml                          |    47 +
 .../authzcache/AuthzCache.java                     |     0
 .../authzcache/AuthzCacheEntry.java                |     0
 .../authzcache/AuthzCacheIndex.java                |     0
 .../authzcache/AuthzCacheManager.java              |     0
 .../authzcache/AuthzCacheManagerFactory.java       |     0
 .../authzcache/AuthzCachedStatus.java              |     0
 .../authzcache/DefaultAuthzCacheManager.java       |     0
 .../interceptor/SecurityCheck.java                 |    24 +-
 .../interceptor/SecurityInterceptor.java           |    82 +
 .../interceptor/SecurityModule.java                |    31 +-
 .../manager/CustosSecurityManager.java             |     6 +-
 .../manager/IdentityContext.java                   |     3 +-
 .../manager/KeyCloakSecurityManager.java           |   192 +-
 .../manager/SecurityManagerFactory.java            |     0
 .../manager/UserInfo.java                          |     0
 .../utils/TrustStoreManager.java                   |     0
 .../iam-admin-services-core/pom.xml                |     2 +-
 .../core/impl/TenantManagementKeycloakImpl.java    |    38 +-
 .../core/interfaces/TenantManagementInterface.java |    12 +-
 .../admin/services/core/tests/SetupNewGateway.java |    12 +-
 .../pom.xml                                        |     5 +-
 .../profile-service-commons/pom.xml                |     0
 .../commons/repositories/AbstractRepository.java   |     6 +-
 .../commons/tenant/entities/GatewayEntity.java     |     2 +-
 .../user/entities/CustomizedDashboardEntity.java   |     6 +-
 .../user/entities/NSFDemographicsEntity.java       |    10 +-
 .../commons/user/entities/UserProfileEntity.java   |    12 +-
 .../custos}/profile/commons/utils/Committer.java   |     2 +-
 .../profile/commons/utils/JPAConstants.java        |     2 +-
 .../custos}/profile/commons/utils/JPAUtils.java    |     2 +-
 .../commons/utils/ObjectMapperSingleton.java       |     2 +-
 .../commons/utils/ProfileServiceJDBCConfig.java    |     2 +-
 .../profile/commons/utils/QueryConstants.java      |    11 +-
 .../custos}/profile/commons/utils/Utils.java       |     2 +-
 .../src/main/resources/META-INF/persistence.xml    |     8 +-
 .../profile-service-model}/pom.xml                 |     0
 .../profile/model}/tenant/PasswordCredential.java  |     2 +-
 .../custos/profile/model}/tenant/Tenant.java       |     6 +-
 .../model}/tenant/TenantApprovalStatus.java        |     2 +-
 .../custos/profile/model}/tenant/TenantConfig.java |     2 +-
 .../profile/model}/tenant/TenantPreferences.java   |     2 +-
 .../profile/model}/user/CustomDashboard.java       |     2 +-
 .../profile/model}/user/NSFDemographics.java       |   128 +-
 .../apache/custos/profile/model}/user/Status.java  |     2 +-
 .../custos/profile/model}/user/USCitizenship.java  |     2 +-
 .../custos/profile/model}/user/UserProfile.java    |   118 +-
 .../custos/profile/model}/user/disability.java     |     2 +-
 .../custos/profile/model}/user/ethnicity.java      |     2 +-
 .../apache/custos/profile/model}/user/race.java    |     2 +-
 .../model}/user/user_profile_modelConstants.java   |     2 +-
 .../custos/profile/model}/workspace/Gateway.java   |   116 +-
 .../model}/workspace/GatewayApprovalStatus.java    |     2 +-
 .../profile-service-server/pom.xml                 |    13 +-
 .../profile/handlers/IamAdminServicesHandler.java  |    51 +-
 .../handlers/TenantProfileServiceHandler.java      |    56 +-
 .../handlers/UserProfileServiceHandler.java        |    52 +-
 .../profile/server/ProfileServiceServer.java       |    39 +-
 .../profile-service-stubs}/pom.xml                 |    27 +-
 .../iam.admin.services.cpi}/IamAdminServices.java  |  3847 ++--
 .../exception/IamAdminServicesException.java       |    46 +-
 .../iam_admin_services_cpiConstants.java           |    16 +
 .../profile/tenant.cpi}/TenantProfileService.java  |  3312 ++--
 .../exception/TenantProfileServiceException.java   |    69 +-
 .../tenant.cpi/profile_tenant_cpiConstants.java    |    16 +
 .../profile/user.cpi}/UserProfileService.java      |  1951 +-
 .../exception/UserProfileServiceException.java     |    69 +-
 .../user.cpi/profile_user_cpiConstants.java        |    16 +
 .../profile-tenant-core/pom.xml                    |     0
 .../core/repositories/TenantProfileRepository.java |    32 +-
 .../profile-user-core/pom.xml                      |     0
 .../exceptions/UserProfileRegistryException.java   |     2 +-
 .../core/repositories/UserProfileRepository.java   |    16 +-
 .../core/utils/UserProfileCatalogDBInitConfig.java |     2 +-
 .../core/utils/UserProfileCatalogJDBCConfig.java   |     4 +-
 .../user-profile-catalog-derby.sql                 |     0
 .../user-profile-catalog-mysql.sql                 |     0
 .../core/repositories/WorkspaceRepositoryTest.java |     0
 custos-services/custos-security-service/pom.xml    |    71 -
 .../custos/security/oauth/DefaultOAuthClient.java  |    91 -
 .../security/service/SecurityServiceHandler.java   |    30 -
 .../custos/security/xacml/DefaultPAPClient.java    |   124 -
 .../custos/security/xacml/DefaultXACMLPEP.java     |   133 -
 custos-services/pom.xml                            |    34 -
 .../java-client-samples/pom.xml                    |    35 -
 .../profile/client/samples/GroupManagerSample.java |    41 -
 .../client/samples/TenantProfileSample.java        |    61 -
 .../profile/client/samples/UserProfileSample.java  |   121 -
 .../client/util/ProfileServiceClientUtil.java      |    47 -
 .../resources/profile-client-sample.properties     |    29 -
 .../profile-service-client-sdks/pom.xml            |    31 -
 .../handlers/GroupManagerServiceHandler.java       |   385 -
 .../profile-service/profile-service-stubs/pom.xml  |    35 -
 .../groupmanager/cpi/GroupManagerService.java      | 17625 -------------------
 .../exception/GroupManagerServiceException.java    |   381 -
 .../cpi/group_manager_cpiConstants.java            |    32 -
 .../cpi/iam_admin_services_cpiConstants.java       |    32 -
 .../tenant/cpi/profile_tenant_cpiConstants.java    |    32 -
 .../user/cpi/profile_user_cpiConstants.java        |    32 -
 .../profile-service/profile-services.iml           |    20 -
 pom.xml                                            |     6 +-
 ...airavata_errors.thrift => custos_errors.thrift} |     0
 .../custos-apis/security_model.thrift              |     8 +-
 .../group_manager_model.thrift                     |    55 -
 .../tenant_profile_model.thrift                    |     2 -
 .../user_profile_model.thrift                      |    15 +-
 .../workspace_model.thrift                         |     4 +-
 thrift-interfaces/generate-thrift-stubs.sh         |   347 -
 .../group-manager/group-manager-cpi.thrift         |    98 -
 .../group-manager/group_manager_cpi_errors.thrift  |    33 -
 .../iam-admin-services-cpi.thrift                  |    66 +-
 .../iam_admin_services_cpi_errors.thrift           |     8 +-
 .../profile-service/profile-service-cpi.thrift     |    14 +-
 .../profile-tenant/profile-tenant-cpi.thrift       |    39 +-
 .../profile_tenant_cpi_errors.thrift               |     6 +-
 .../profile-user/profile-user-cpi.thrift           |    36 +-
 .../profile-user/profile_user_cpi_errors.thrift    |     6 +-
 128 files changed, 7336 insertions(+), 24305 deletions(-)

diff --git a/custos-commons/pom.xml b/custos-client/pom.xml
similarity index 50%
copy from custos-commons/pom.xml
copy to custos-client/pom.xml
index a1a9e93..cc6d67b 100644
--- a/custos-commons/pom.xml
+++ b/custos-client/pom.xml
@@ -2,28 +2,25 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
     <parent>
         <artifactId>custos</artifactId>
         <groupId>org.apache.custos</groupId>
         <version>1.0-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
     </parent>
-    
-    <groupId>org.apache.custos</groupId>
-    <artifactId>custos-commons</artifactId>
-    <version>${parent.version}</version>
+    <modelVersion>4.0.0</modelVersion>
     <dependencies>
         <dependency>
-            <groupId>org.apache.thrift</groupId>
-            <artifactId>libthrift</artifactId>
-            <version>${thrift.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa</artifactId>
-            <version>${openjpa.version}</version>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>profile-service-stubs</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
         </dependency>
     </dependencies>
+    <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+    </properties>
+    <artifactId>custos-client</artifactId>
+
 
 </project>
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-stubs/src/main/java/org/apache/custos/service/profile/client/ProfileServiceClientFactory.java b/custos-client/src/main/java/org/apache/custos/client/profile/service/ProfileServiceClientFactory.java
similarity index 64%
rename from custos-services/profile-service/profile-service-stubs/src/main/java/org/apache/custos/service/profile/client/ProfileServiceClientFactory.java
rename to custos-client/src/main/java/org/apache/custos/client/profile/service/ProfileServiceClientFactory.java
index 7a9b37a..aa8f476 100644
--- a/custos-services/profile-service/profile-service-stubs/src/main/java/org/apache/custos/service/profile/client/ProfileServiceClientFactory.java
+++ b/custos-client/src/main/java/org/apache/custos/client/profile/service/ProfileServiceClientFactory.java
@@ -1,4 +1,4 @@
-/*
+/**
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -16,22 +16,18 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
-package org.apache.custos.service.profile.client;
+package org.apache.custos.client.profile.service;
 
-import org.apache.custos.service.profile.iam.admin.services.cpi.IamAdminServices;
-import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
-import org.apache.custos.service.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants;
-import org.apache.custos.service.profile.groupmanager.cpi.GroupManagerService;
-import org.apache.custos.service.profile.groupmanager.cpi.exception.GroupManagerServiceException;
-import org.apache.custos.service.profile.groupmanager.cpi.group_manager_cpiConstants;
-import org.apache.custos.service.profile.tenant.cpi.TenantProfileService;
-import org.apache.custos.service.profile.tenant.cpi.exception.TenantProfileServiceException;
-import org.apache.custos.service.profile.tenant.cpi.profile_tenant_cpiConstants;
-import org.apache.custos.service.profile.user.cpi.UserProfileService;
-import org.apache.custos.service.profile.user.cpi.exception.UserProfileServiceException;
-import org.apache.custos.service.profile.user.cpi.profile_user_cpiConstants;
+import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants;
+import org.apache.custos.profile.tenant.cpi.TenantProfileService;
+import org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException;
+import org.apache.custos.profile.tenant.cpi.profile_tenant_cpiConstants;
+import org.apache.custos.profile.user.cpi.UserProfileService;
+import org.apache.custos.profile.user.cpi.exception.UserProfileServiceException;
+import org.apache.custos.profile.user.cpi.profile_user_cpiConstants;
 import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.protocol.TMultiplexedProtocol;
 import org.apache.thrift.protocol.TProtocol;
@@ -79,15 +75,15 @@ public class ProfileServiceClientFactory {
         }
     }
 
-    public static GroupManagerService.Client createGroupManagerServiceClient(String serverHost, int serverPort)  throws GroupManagerServiceException {
-        try {
-            TTransport transport = new TSocket(serverHost, serverPort);
-            transport.open();
-            TProtocol protocol = new TBinaryProtocol(transport);
-            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, group_manager_cpiConstants.GROUP_MANAGER_CPI_NAME);
-            return new GroupManagerService.Client(multiplexedProtocol);
-        } catch (TTransportException e) {
-            throw new GroupManagerServiceException(e.getMessage());
-        }
-    }
+//    public static GroupManagerService.Client createGroupManagerServiceClient(String serverHost, int serverPort)  throws GroupManagerServiceException {
+//        try {
+//            TTransport transport = new TSocket(serverHost, serverPort);
+//            transport.open();
+//            TProtocol protocol = new TBinaryProtocol(transport);
+//            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, group_manager_cpiConstants.GROUP_MANAGER_CPI_NAME);
+//            return new GroupManagerService.Client(multiplexedProtocol);
+//        } catch (TTransportException e) {
+//            throw new GroupManagerServiceException(e.getMessage());
+//        }
+//    }
 }
\ No newline at end of file
diff --git a/custos-commons/custos-server.properties b/custos-commons/custos-server.properties
new file mode 100644
index 0000000..e69de29
diff --git a/custos-commons/pom.xml b/custos-commons/pom.xml
index a1a9e93..85b8584 100644
--- a/custos-commons/pom.xml
+++ b/custos-commons/pom.xml
@@ -9,7 +9,10 @@
         <version>1.0-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
-    
+    <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+    </properties>
     <groupId>org.apache.custos</groupId>
     <artifactId>custos-commons</artifactId>
     <version>${parent.version}</version>
@@ -24,6 +27,11 @@
             <artifactId>openjpa</artifactId>
             <version>${openjpa.version}</version>
         </dependency>
+        <dependency>
+            <groupId>commons-dbcp</groupId>
+            <artifactId>commons-dbcp</artifactId>
+            <version>1.4</version>
+        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/model/AuthzToken.java b/custos-commons/src/main/java/org/apache/custos/commons/model/security/AuthzToken.java
similarity index 99%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/model/AuthzToken.java
rename to custos-commons/src/main/java/org/apache/custos/commons/model/security/AuthzToken.java
index 448df68..f4d7178 100644
--- a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/model/AuthzToken.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/model/security/AuthzToken.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.security.model;
+package org.apache.custos.commons.model.security;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitializer.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitializer.java
new file mode 100644
index 0000000..6e2038c
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitializer.java
@@ -0,0 +1,71 @@
+/*
+ * 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.custos.commons.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Connection;
+
+public class DBInitializer {
+    private static final Logger logger = LoggerFactory.getLogger(DBInitializer.class);
+
+    private JDBCConfig jdbcConfig;
+    private String initScriptPrefix;
+    private String checkTableName;
+
+    public DBInitializer(JDBCConfig jdbcConfig, String initScriptPrefix, String checkTableName) {
+        this.jdbcConfig = jdbcConfig;
+        this.initScriptPrefix = initScriptPrefix;
+        this.checkTableName = checkTableName;
+    }
+
+    public static void initializeDB(DBInitConfig dbInitConfig) {
+
+        JDBCConfig jdbcConfig = dbInitConfig.getJDBCConfig();
+        DBInitializer dbInitializer = new DBInitializer(jdbcConfig, dbInitConfig.getDBInitScriptPrefix(), dbInitConfig.getCheckTableName());
+        dbInitializer.initializeDB();
+        dbInitConfig.postInit();
+    }
+
+    public void initializeDB() {
+        // Create connection
+        Connection conn = null;
+        try {
+            DBUtil dbUtil = new DBUtil(jdbcConfig);
+            conn = dbUtil.getConnection();
+            if (!DatabaseCreator.isDatabaseStructureCreated(checkTableName, conn)) {
+                DatabaseCreator.createRegistryDatabase(initScriptPrefix, conn);
+                logger.info("New Database created from " + initScriptPrefix + " !!!");
+            } else {
+                logger.info("Table " + checkTableName + " already exists. Skipping database init script " + initScriptPrefix);
+            }
+
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to initialize database for " + initScriptPrefix, e);
+        } finally {
+            if (conn != null) {
+                DBUtil.cleanup(conn);
+            }
+        }
+
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBUtil.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBUtil.java
new file mode 100644
index 0000000..bfac5d7
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBUtil.java
@@ -0,0 +1,307 @@
+/**
+ *
+ * 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.custos.commons.utils;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sql.DataSource;
+import java.sql.*;
+import java.util.Properties;
+
+/**
+ * Database lookup. Abstracts out JDBC operations.
+ */
+public class DBUtil {
+
+    private String jdbcUrl;
+    private String databaseUserName;
+    private String databasePassword;
+    private String driverName;
+
+    protected static Logger log = LoggerFactory.getLogger(DBUtil.class);
+
+    private Properties properties;
+
+    public DBUtil(String jdbcUrl, String userName, String password, String driver) throws InstantiationException,
+            IllegalAccessException, ClassNotFoundException {
+
+        this.jdbcUrl = jdbcUrl;
+        this.databaseUserName = userName;
+        this.databasePassword = password;
+        this.driverName = driver;
+
+        init();
+    }
+
+    public DBUtil(JDBCConfig jdbcConfig) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+        this(jdbcConfig.getURL(), jdbcConfig.getUser(), jdbcConfig.getPassword(), jdbcConfig.getDriver());
+    }
+
+    /**
+     * Initializes and load driver. Must be called this before calling anyother method.
+     * 
+     * @throws ClassNotFoundException
+     *             If DB driver is not found.
+     * @throws InstantiationException
+     *             If unable to create driver class.
+     * @throws IllegalAccessException
+     *             If security does not allow users to instantiate driver object.
+     */
+    private void init() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+        properties = new Properties();
+
+        properties.put("user", databaseUserName);
+        properties.put("password", databasePassword);
+        properties.put("characterEncoding", "ISO-8859-1");
+        properties.put("useUnicode", "true");
+
+        loadDriver();
+    }
+
+    /**
+     * Generic method to query values in the database.
+     * 
+     * @param tableName
+     *            Table name to query
+     * @param selectColumn
+     *            The column selecting
+     * @param whereValue
+     *            The condition query
+     * @return The value appropriate to the query.
+     * @throws SQLException
+     *             If an error occurred while querying
+     */
+    public String getMatchingColumnValue(String tableName, String selectColumn, String whereValue) throws SQLException {
+        return getMatchingColumnValue(tableName, selectColumn, selectColumn, whereValue);
+    }
+
+    /**
+     * Generic method to query values in the database.
+     * 
+     * @param tableName
+     *            Table name to query
+     * @param selectColumn
+     *            The column selecting
+     * @param whereColumn
+     *            The column which condition should apply
+     * @param whereValue
+     *            The condition query
+     * @return The value appropriate to the query.
+     * @throws SQLException
+     *             If an error occurred while querying
+     */
+    public String getMatchingColumnValue(String tableName, String selectColumn, String whereColumn, String whereValue)
+            throws SQLException {
+
+        StringBuilder stringBuilder = new StringBuilder();
+
+        stringBuilder.append("SELECT ").append(selectColumn).append(" FROM ").append(tableName).append(" WHERE ")
+                .append(whereColumn).append(" = ?");
+
+        String sql = stringBuilder.toString();
+
+        Connection connection = getConnection();
+
+        PreparedStatement ps = connection.prepareStatement(sql);
+        ResultSet rs = null;
+
+        try {
+            ps.setString(1, whereValue);
+            rs = ps.executeQuery();
+
+            if (rs.next()) {
+                return rs.getString(1);
+            }
+
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+
+                ps.close();
+                connection.close();
+
+            } catch (Exception ignore) {
+                log.error("An error occurred while closing database connections ", ignore);
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Create table utility method.
+     * 
+     * @param sql
+     *            SQL to be executed.
+     * @throws SQLException
+     *             If an error occurred while creating the table.
+     */
+    public void executeSQL(String sql) throws SQLException {
+
+        Connection connection = getConnection();
+
+        PreparedStatement ps = connection.prepareStatement(sql);
+
+        try {
+            ps.executeUpdate();
+            connection.commit();
+        } finally {
+            try {
+                if (ps != null) {
+                    ps.close();
+                }
+
+                connection.close();
+
+            } catch (Exception ignore) {
+                log.error("An error occurred while closing database connections ", ignore);
+            }
+        }
+
+    }
+
+    private void loadDriver() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+        Class.forName(driverName).newInstance();
+    }
+
+    /**
+     * Gets a new DBCP data source.
+     * 
+     * @return A new data source.
+     */
+    public DataSource getDataSource() {
+        BasicDataSource ds = new BasicDataSource();
+        ds.setDriverClassName(this.driverName);
+        ds.setUsername(this.databaseUserName);
+        ds.setPassword(this.databasePassword);
+        ds.setUrl(this.jdbcUrl);
+
+        return ds;
+    }
+
+    /**
+     * Creates a new JDBC connections based on provided DBCP properties.
+     * 
+     * @return A new DB connection.
+     * @throws SQLException
+     *             If an error occurred while creating the connection.
+     */
+    public Connection getConnection() throws SQLException {
+        Connection connection = DriverManager.getConnection(jdbcUrl, properties);
+        connection.setAutoCommit(false);
+        return connection;
+    }
+
+    /**
+     * Utility method to close statements and connections.
+     * 
+     * @param preparedStatement
+     *            The prepared statement to close.
+     * @param connection
+     *            The connection to close.
+     */
+    public static void cleanup(PreparedStatement preparedStatement, Connection connection) {
+        if (preparedStatement != null) {
+            try {
+                preparedStatement.close();
+            } catch (SQLException e) {
+                log.error("Error closing prepared statement.", e);
+            }
+        }
+        cleanup(connection);
+    }
+
+    /**
+     * Utility method to close statements and connections.
+     *
+     * @param preparedStatement
+     *            The prepared statement to close.
+     */
+    public static void cleanup(PreparedStatement preparedStatement) {
+        if (preparedStatement != null) {
+            try {
+                preparedStatement.close();
+            } catch (SQLException e) {
+                log.error("Error closing prepared statement.", e);
+            }
+        }
+    }
+
+    /**
+     * Utility method to close statements and connections.
+     *
+     * @param preparedStatement
+     *            The prepared statement to close.
+     */
+    public static void cleanup(PreparedStatement preparedStatement, ResultSet resultSet) {
+        if (resultSet != null) {
+            try {
+                resultSet.close();
+            } catch (SQLException e) {
+                log.error("Error closing prepared statement.", e);
+            }
+        }
+
+        cleanup(preparedStatement);
+    }
+
+    /**
+     * Cleanup the connection.
+     * @param connection The connection to close.
+     */
+    public static void cleanup(Connection connection) {
+        if (connection != null) {
+            try {
+                if (connection.isClosed()) {
+                    return;
+                }
+                if (!connection.getAutoCommit()) {
+                    connection.rollback();
+                }
+                connection.close();
+            } catch (SQLException e) {
+                throw new RuntimeException("Error closing connection", e);
+            }
+        }
+    }
+
+    /**
+     * Mainly useful for tests.
+     * 
+     * @param tableName
+     *            The table name.
+     * @param connection
+     *            The connection to be used.
+     */
+    public static void truncate(String tableName, Connection connection) throws SQLException {
+
+        String sql = "delete from " + tableName;
+
+        PreparedStatement preparedStatement = connection.prepareStatement(sql);
+        preparedStatement.executeUpdate();
+
+        connection.commit();
+
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DatabaseCreator.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DatabaseCreator.java
new file mode 100644
index 0000000..539ccf4
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/DatabaseCreator.java
@@ -0,0 +1,378 @@
+/*
+ * 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.custos.commons.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.*;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * This class creates the database tables required for custos with default configuration this
+ * class creates derby database in server mode. User can specify required database in appropriate
+ * properties files.
+ */
+public class DatabaseCreator {
+    private final static Logger logger = LoggerFactory.getLogger(DatabaseCreator.class);
+
+    public enum DatabaseType {
+        derby("(?i).*derby.*"), mysql("(?i).*(mysql|mariadb).*"), other("");
+
+        private String pattern;
+
+        private DatabaseType(String matchingPattern) {
+            this.pattern = matchingPattern;
+        }
+
+        public String getMatchingPattern() {
+            return this.pattern;
+        }
+    }
+
+    private static DatabaseType[] supportedDatabase = new DatabaseType[] { DatabaseType.derby, DatabaseType.mysql };
+
+    private static Logger log = LoggerFactory.getLogger(DatabaseCreator.class);
+    private static final String delimiter = ";";
+
+    /**
+     * Creates database
+     *
+     * @throws Exception
+     */
+    public static void createRegistryDatabase(String prefix, Connection conn) throws Exception {
+        createDatabase(prefix, conn);
+    }
+
+
+
+    /**
+     * Checks whether database tables are created by using select * on given table name
+     *
+     * @param tableName
+     *            Table which should be existed
+     * @return <code>true</core> if checkSQL is success, else <code>false</code> .
+     */
+    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
+        try {
+
+            log.debug("Running a query to test the database tables existence.");
+
+            // check whether the tables are already created with a query
+            Statement statement = null;
+            try {
+                statement = conn.createStatement();
+                ResultSet rs = statement.executeQuery("select * from " + tableName);
+                if (rs != null) {
+                    rs.close();
+                }
+            } finally {
+                try {
+                    if (statement != null) {
+                        statement.close();
+                    }
+                } catch (SQLException e) {
+                    return false;
+                }
+            }
+        } catch (SQLException e) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * executes given sql
+     *
+     * @param sql
+     * @throws Exception
+     */
+    private static void executeSQL(String sql, Connection conn) throws Exception {
+        // Check and ignore empty statements
+        if ("".equals(sql.trim())) {
+            return;
+        }
+
+        Statement statement = null;
+        try {
+            log.debug("SQL : " + sql);
+
+            boolean ret;
+            int updateCount = 0, updateCountTotal = 0;
+            statement = conn.createStatement();
+            ret = statement.execute(sql);
+            updateCount = statement.getUpdateCount();
+            do {
+                if (!ret) {
+                    if (updateCount != -1) {
+                        updateCountTotal += updateCount;
+                    }
+                }
+                ret = statement.getMoreResults();
+                if (ret) {
+                    updateCount = statement.getUpdateCount();
+                }
+            } while (ret);
+
+            log.debug(sql + " : " + updateCountTotal + " rows affected");
+
+            SQLWarning warning = conn.getWarnings();
+            while (warning != null) {
+                log.info(warning + " sql warning");
+                warning = warning.getNextWarning();
+            }
+            conn.clearWarnings();
+        } catch (SQLException e) {
+            if (e.getSQLState().equals("X0Y32")) {
+                // eliminating the table already exception for the derby
+                // database
+                log.info("Table Already Exists", e);
+            } else {
+                throw new Exception("Error occurred while executing : " + sql, e);
+            }
+        } finally {
+            if (statement != null) {
+                try {
+                    statement.close();
+                } catch (SQLException e) {
+                    log.error("Error occurred while closing result set.", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * computes relatational database type using database name
+     *
+     * @return DatabaseType
+     * @throws Exception
+     *
+     */
+    public static DatabaseType getDatabaseType(Connection conn) throws Exception {
+        try {
+            if (conn != null && (!conn.isClosed())) {
+                DatabaseMetaData metaData = conn.getMetaData();
+                String databaseProductName = metaData.getDatabaseProductName();
+                return checkType(databaseProductName);
+            }
+        } catch (SQLException e) {
+            String msg = "Failed to create Airavata database." + e.getMessage();
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        return DatabaseType.other;
+    }
+
+    /**
+     * Overloaded method with String input
+     *
+     * @return DatabaseType
+     * @throws Exception
+     *
+     */
+    public static DatabaseType getDatabaseType(String dbUrl) throws Exception {
+        return checkType(dbUrl);
+    }
+
+    private static DatabaseType checkType(String text) throws Exception {
+        try {
+            if (text != null) {
+                for (DatabaseType type : supportedDatabase) {
+                    if (text.matches(type.getMatchingPattern()))
+                        return type;
+                }
+            }
+            String msg = "Unsupported database: " + text
+                    + ". Database will not be created automatically by the custos. "
+                    + "Please create the database using appropriate database scripts for " + "the database.";
+            throw new Exception(msg);
+
+        } catch (SQLException e) {
+            String msg = "Failed to create custosdatabase." + e.getMessage();
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+    }
+
+    /**
+     * Get scripts location which is prefix + "-" + databaseType + ".sql"
+     *
+     * @param prefix
+     * @param databaseType
+     * @return script location
+     */
+    private static String getScriptLocation(String prefix, DatabaseType databaseType) {
+        String scriptName = prefix + "-" + databaseType + ".sql";
+        log.debug("Loading database script from :" + scriptName);
+        return  scriptName;
+    }
+
+    private static void createDatabase(String prefix, Connection conn) throws Exception {
+        Statement statement = null;
+        try {
+            conn.setAutoCommit(false);
+            statement = conn.createStatement();
+            executeSQLScript(getScriptLocation(prefix, DatabaseCreator.getDatabaseType(conn)), conn);
+            conn.commit();
+            log.debug("Tables are created successfully.");
+        } catch (SQLException e) {
+            String msg = "Failed to create database tables for custos resource store. " + e.getMessage();
+            log.error(msg, e);
+            conn.rollback();
+            throw new Exception(msg, e);
+        } finally {
+            conn.setAutoCommit(true);
+            try {
+                if (statement != null) {
+                    statement.close();
+                }
+            } catch (SQLException e) {
+                log.error("Failed to close statement.", e);
+            }
+        }
+    }
+
+    private static void executeSQLScript(String dbscriptName, Connection conn) throws Exception {
+        StringBuffer sql = new StringBuffer();
+        BufferedReader reader = null;
+
+        try {
+            InputStream is = DatabaseCreator.class.getClassLoader().getResourceAsStream(dbscriptName);
+            if(is == null) {
+                logger.info("Script file not found at " + dbscriptName + ". Uses default database script file");
+                DatabaseType databaseType = DatabaseCreator.getDatabaseType(conn);
+                is = DatabaseCreator.class.getClassLoader().getResourceAsStream(
+                        getDBScriptFileName(databaseType, dbscriptName)
+                );
+            }
+            reader = new BufferedReader(new InputStreamReader(is));
+            String line;
+            while ((line = reader.readLine()) != null) {
+                line = line.trim();
+                if (line.startsWith("//")) {
+                    continue;
+                }
+                if (line.startsWith("--")) {
+                    continue;
+                }
+                StringTokenizer st = new StringTokenizer(line);
+                if (st.hasMoreTokens()) {
+                    String token = st.nextToken();
+                    if ("REM".equalsIgnoreCase(token)) {
+                        continue;
+                    }
+                }
+                sql.append(" ").append(line);
+
+                // SQL defines "--" as a comment to EOL
+                // and in Oracle it may contain a hint
+                // so we cannot just remove it, instead we must end it
+                if (line.indexOf("--") >= 0) {
+                    sql.append("\n");
+                }
+                if ((checkStringBufferEndsWith(sql, delimiter))) {
+                    executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
+                    sql.replace(0, sql.length(), "");
+                }
+            }
+            // Catch any statements not followed by ;
+            if (sql.length() > 0) {
+                executeSQL(sql.toString(), conn);
+            }
+        } catch (IOException e) {
+            log.error("Error occurred while executing SQL script for creating custos database", e);
+            throw new Exception("Error occurred while executing SQL script for creating custos database", e);
+
+        } finally {
+            if (reader != null) {
+                reader.close();
+            }
+        }
+    }
+
+    /**
+     * Checks that a string buffer ends up with a given string. It may sound trivial with the existing JDK API but the
+     * various implementation among JDKs can make those methods extremely resource intensive and perform poorly due to
+     * massive memory allocation and copying. See
+     *
+     * @param buffer
+     *            the buffer to perform the check on
+     * @param suffix
+     *            the suffix
+     * @return <code>true</code> if the character sequence represented by the argument is a suffix of the character
+     *         sequence represented by the StringBuffer object; <code>false</code> otherwise. Note that the result will
+     *         be <code>true</code> if the argument is the empty string.
+     */
+    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
+        if (suffix.length() > buffer.length()) {
+            return false;
+        }
+        // this loop is done on purpose to avoid memory allocation performance
+        // problems on various JDKs
+        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
+        // implementation is ok though does allocation/copying
+        // StringBuffer.toString().endsWith() does massive memory
+        // allocation/copying on JDK 1.5
+        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
+        int endIndex = suffix.length() - 1;
+        int bufferIndex = buffer.length() - 1;
+        while (endIndex >= 0) {
+            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
+                return false;
+            }
+            bufferIndex--;
+            endIndex--;
+        }
+        return true;
+    }
+
+    /**
+     * Method will accept a filepath containing a database script (eg: /user/database_scripts/expcatalog.sql)
+     *  and return only the filename of the database script (eg: expcatalog.sql).
+     * @param databaseType
+     * @param scriptFilePath
+     * @return
+     */
+    private static String getDBScriptFileName(DatabaseType databaseType, String scriptFilePath) {
+        // pattern: {dir_name}/{scriptfile_name}-{dbtype}.sql".
+        // Eg: database_scripts/expcatalog-derby.sql
+        final String scriptFilePattern = "(\\w*)(-" + databaseType.toString() + ".sql)";
+        final Pattern pattern = Pattern.compile(scriptFilePattern);
+        final Matcher matcher = pattern.matcher(scriptFilePath);
+        String dbScriptFileName = null;
+        // find a match
+        if (matcher.find()) {
+            dbScriptFileName = matcher.group();
+        }
+        return dbScriptFileName;
+    }
+
+//    public static void main(String[] args) throws Exception {
+//        System.out.println(DatabaseCreator.getDBScriptFileName(DatabaseType.derby, "db/db/expcatalog-derby.sql"));
+//        System.out.println(DatabaseCreator.getDBScriptFileName(DatabaseType.mysql, "/expcatalog-mysql.sql"));
+//    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/IdentityContext.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/IServer.java
similarity index 53%
copy from custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/IdentityContext.java
copy to custos-commons/src/main/java/org/apache/custos/commons/utils/IServer.java
index f5648ba..c5c2ed9 100644
--- a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/IdentityContext.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/IServer.java
@@ -1,4 +1,4 @@
-/*
+/**
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -16,29 +16,34 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
  */
+package org.apache.custos.commons.utils;
 
-package org.apache.custos.security.manager;
-
-import org.apache.custos.security.model.AuthzToken;
-
-/**
- * This provides a thread local container for AuthzToken through out the execution of a particular thread.
- */
-public class IdentityContext {
-    private static ThreadLocal authzTokenContainer = new ThreadLocal();
-
-    public static void set(AuthzToken authzToken){
-        authzTokenContainer.set(authzToken);
-    }
-
-    public static void unset(){
-        authzTokenContainer.remove();
-    }
-
-    public static AuthzToken get(){
-        return (AuthzToken) authzTokenContainer.get();
-    }
+import java.util.Calendar;
+import java.util.Date;
 
+public interface IServer {
+	public enum ServerStatus{
+		STOPING,
+		STOPPED,
+		STARTING,
+		STARTED,
+		FAILED;
+		public void updateTime(){
+			now=Calendar.getInstance().getTime();
+		}
+		private Date now;
+		public Date getTime(){
+			return now;
+		}
+	}
+	public String getName();
+	public String getVersion();
+	public void start() throws Exception;
+	public void stop() throws Exception;
+	public void restart() throws Exception;
+	public void configure() throws Exception;
+	public ServerStatus getStatus() throws Exception;
+//	public void waitForServerToStart() throws Exception;
+//	public void waitForServerToStop() throws Exception;
 }
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
index 2ead9e3..9417313 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
@@ -26,6 +26,11 @@ import org.slf4j.LoggerFactory;
 public class ServerSettings extends ApplicationSettings {
 
     private static final Logger log = LoggerFactory.getLogger(ServerSettings.class);
+    //User Profile constant
+
+    public static final String USER_PROFILE_SERVER_HOST = "user.profile.server.host";
+    public static final String USER_PROFILE_SERVER_PORT = "user.profile.server.port";
+
     public static int getCacheSize() throws ApplicationSettingsException {
         return Integer.valueOf(getSetting(Constants.IN_MEMORY_CACHE_SIZE));
     }
@@ -53,4 +58,12 @@ public class ServerSettings extends ApplicationSettings {
     public static String getIamServerSuperAdminPassword() throws ApplicationSettingsException {
         return getSetting(ServerSettings.IAM_SERVER_SUPER_ADMIN_PASSWORD);
     }
+    public static String  getProfileServiceServerHost() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_HOST);
+    }
+
+    public static String getProfileServiceServerPort() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_PORT);
+    }
+
 }
diff --git a/custos-services/profile-service/profile-user-core/src/main/java/org/apache/custos/service/profile/user/core/exceptions/UserProfileRegistryException.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ThriftUtils.java
similarity index 67%
copy from custos-services/profile-service/profile-user-core/src/main/java/org/apache/custos/service/profile/user/core/exceptions/UserProfileRegistryException.java
copy to custos-commons/src/main/java/org/apache/custos/commons/utils/ThriftUtils.java
index fb0a5e6..ea0e895 100644
--- a/custos-services/profile-service/profile-user-core/src/main/java/org/apache/custos/service/profile/user/core/exceptions/UserProfileRegistryException.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ThriftUtils.java
@@ -16,13 +16,19 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
-*/
-package org.apache.custos.service.profile.user.core.exceptions;
+ */
+package org.apache.custos.commons.utils;
+
+import org.apache.thrift.*;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+public class ThriftUtils {
 
-public class UserProfileRegistryException extends Exception {
-    private final static Logger logger = LoggerFactory.getLogger(UserProfileRegistryException.class);
-}
\ No newline at end of file
+	public static void close(TServiceClient client) {
+		if (client.getOutputProtocol().getTransport().isOpen()) {
+			client.getOutputProtocol().getTransport().close();
+		}
+		if (client.getInputProtocol().getTransport().isOpen()) {
+			client.getInputProtocol().getTransport().close();
+		}
+	}
+}
diff --git a/custos-connectors/pom.xml b/custos-connectors/pom.xml
new file mode 100644
index 0000000..309e806
--- /dev/null
+++ b/custos-connectors/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>custos</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-connectors</artifactId>
+    <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-commons</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.inject</groupId>
+            <artifactId>guice</artifactId>
+            <version>4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20131018</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>profile-service-stubs</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-client</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCache.java b/custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCache.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCache.java
rename to custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCache.java
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheEntry.java b/custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCacheEntry.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheEntry.java
rename to custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCacheEntry.java
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheIndex.java b/custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCacheIndex.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheIndex.java
rename to custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCacheIndex.java
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManager.java b/custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCacheManager.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManager.java
rename to custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCacheManager.java
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManagerFactory.java b/custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCacheManagerFactory.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManagerFactory.java
rename to custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCacheManagerFactory.java
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCachedStatus.java b/custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCachedStatus.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCachedStatus.java
rename to custos-connectors/src/main/java/org.apache.custos.security/authzcache/AuthzCachedStatus.java
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/DefaultAuthzCacheManager.java b/custos-connectors/src/main/java/org.apache.custos.security/authzcache/DefaultAuthzCacheManager.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/DefaultAuthzCacheManager.java
rename to custos-connectors/src/main/java/org.apache.custos.security/authzcache/DefaultAuthzCacheManager.java
diff --git a/custos-services/profile-service/profile-user-core/src/main/java/org/apache/custos/service/profile/user/core/exceptions/UserProfileRegistryException.java b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityCheck.java
similarity index 62%
copy from custos-services/profile-service/profile-user-core/src/main/java/org/apache/custos/service/profile/user/core/exceptions/UserProfileRegistryException.java
copy to custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityCheck.java
index fb0a5e6..362fb1f 100644
--- a/custos-services/profile-service/profile-user-core/src/main/java/org/apache/custos/service/profile/user/core/exceptions/UserProfileRegistryException.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityCheck.java
@@ -16,13 +16,21 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
-*/
-package org.apache.custos.service.profile.user.core.exceptions;
+ */
+package org.apache.custos.security.interceptor;
+
+import com.google.inject.BindingAnnotation;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
-public class UserProfileRegistryException extends Exception {
-    private final static Logger logger = LoggerFactory.getLogger(UserProfileRegistryException.class);
-}
\ No newline at end of file
+/**
+ * This is just the definition of the annotation used to mark the API methods to be intercepted.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD})
+@BindingAnnotation
+public @interface SecurityCheck {
+}
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java
new file mode 100644
index 0000000..f075dd9
--- /dev/null
+++ b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java
@@ -0,0 +1,82 @@
+/**
+ *
+ * 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.custos.security.interceptor;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.model.error.AuthorizationException;
+import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.commons.utils.Constants;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.security.manager.CustosSecurityManager;
+import org.apache.custos.security.manager.IdentityContext;
+import org.apache.custos.security.manager.SecurityManagerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Interceptor of Custos API calls for the purpose of applying security.
+ */
+public class SecurityInterceptor implements MethodInterceptor {
+    private final static Logger logger = LoggerFactory.getLogger(SecurityInterceptor.class);
+
+    @Override
+    public Object invoke(MethodInvocation invocation) throws Throwable {
+        //obtain the authz token from the input parameters
+        AuthzToken authzToken = (AuthzToken) invocation.getArguments()[0];
+        //authorize the API call
+        HashMap<String, String> metaDataMap = new HashMap();
+        metaDataMap.put(Constants.API_METHOD_NAME, invocation.getMethod().getName());
+        authorize(authzToken, metaDataMap);
+        //set the user identity info in a thread local to be used in downstream execution.
+        IdentityContext.set(authzToken);
+        //let the method call procees upon successful authorization
+        Object returnObj = invocation.proceed();
+        //clean the identity context before the method call returns
+        IdentityContext.unset();
+        return returnObj;
+    }
+
+    private void authorize(AuthzToken authzToken, Map<String, String> metaData) throws AuthorizationException {
+        try {
+            boolean isAPISecured = ServerSettings.isAPISecured();
+            if (isAPISecured) {
+                CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
+                boolean isAuthz = securityManager.isUserAuthorized(authzToken, metaData);
+                if (!isAuthz) {
+                    throw new AuthorizationException("User is not authenticated or authorized.");
+                }
+            }
+        } catch (CustosSecurityException e) {
+            logger.error(e.getMessage(), e);
+            throw new AuthorizationException("Error in authenticating or authorizing user.");
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AuthorizationException("Internal error in authenticating or authorizing user.");
+        }
+    }
+}
+
+
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ObjectMapperSingleton.java b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityModule.java
similarity index 58%
copy from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ObjectMapperSingleton.java
copy to custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityModule.java
index e5cd0f1..c9475cc 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ObjectMapperSingleton.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityModule.java
@@ -16,24 +16,27 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- *
-*/
-package org.apache.custos.service.profile.commons.utils;
+ */
+package org.apache.custos.security.interceptor;
 
-import org.dozer.DozerBeanMapper;
+import com.google.inject.AbstractModule;
+import com.google.inject.matcher.Matchers;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ObjectMapperSingleton extends DozerBeanMapper{
-    private final static Logger logger = LoggerFactory.getLogger(ObjectMapperSingleton.class);
-
-    private static ObjectMapperSingleton instance;
+/**
+ * This does the plumbing work of integrating the interceptor with Guice framework for the methods to be
+ * intercepted upon their invocation.
+ */
+public class SecurityModule extends AbstractModule {
+    private final static Logger logger = LoggerFactory.getLogger(SecurityModule.class);
 
-    private ObjectMapperSingleton(){}
+    public void configure(){
+        logger.info("Security module reached...");
+        SecurityInterceptor interceptor = new SecurityInterceptor();
+        //requestInjection(interceptor);
 
-    public static ObjectMapperSingleton getInstance(){
-        if(instance == null)
-            instance = new ObjectMapperSingleton();
-        return instance;
+        bindInterceptor(Matchers.any(), Matchers.annotatedWith(SecurityCheck.class), interceptor);
     }
-}
\ No newline at end of file
+
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/CustosSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
similarity index 91%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/CustosSecurityManager.java
rename to custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
index afeb1d2..8051e77 100644
--- a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/CustosSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
@@ -21,7 +21,7 @@
 package org.apache.custos.security.manager;
 
 import org.apache.custos.commons.exceptions.CustosSecurityException;
-import org.apache.custos.security.model.AuthzToken;
+import org.apache.custos.commons.model.security.AuthzToken;
 
 import java.util.Map;
 
@@ -48,7 +48,7 @@ public interface CustosSecurityManager {
      * @return
      * @throws CustosSecurityException
      */
-    public AuthzToken getUserManagementServiceAccountAuthzToken(String gatewayId, String clientId, String clientSecret) throws CustosSecurityException;
+    public AuthzToken getUserManagementServiceAccountAuthzToken(String gatewayId) throws CustosSecurityException;
 
     /**
      * Get OpenID Connect user profile information from the given AuthzToken.
@@ -56,5 +56,5 @@ public interface CustosSecurityManager {
      * @return
      * @throws CustosSecurityException
      */
-    public UserInfo getUserInfoFromAuthzToken(AuthzToken authzToken, String identityServerRealm) throws CustosSecurityException;
+    public UserInfo getUserInfoFromAuthzToken(AuthzToken authzToken) throws CustosSecurityException;
 }
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/IdentityContext.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/IdentityContext.java
similarity index 95%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/IdentityContext.java
rename to custos-connectors/src/main/java/org.apache.custos.security/manager/IdentityContext.java
index f5648ba..04c689b 100644
--- a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/IdentityContext.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/IdentityContext.java
@@ -21,7 +21,8 @@
 
 package org.apache.custos.security.manager;
 
-import org.apache.custos.security.model.AuthzToken;
+
+import org.apache.custos.commons.model.security.AuthzToken;
 
 /**
  * This provides a thread local container for AuthzToken through out the execution of a particular thread.
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/KeyCloakSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
similarity index 61%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/KeyCloakSecurityManager.java
rename to custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
index ea1cbb2..b85ec1e 100644
--- a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/KeyCloakSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
@@ -21,12 +21,17 @@
 package org.apache.custos.security.manager;
 
 
+import org.apache.custos.client.profile.service.ProfileServiceClientFactory;
 import org.apache.custos.commons.exceptions.ApplicationSettingsException;
 import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.commons.utils.ThriftUtils;
+import org.apache.custos.profile.model.workspace.Gateway;
+import org.apache.custos.profile.tenant.cpi.TenantProfileService;
+import org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException;
 import org.apache.custos.security.authzcache.*;
-import org.apache.custos.security.model.AuthzToken;
 import org.apache.custos.security.utils.TrustStoreManager;
 import org.apache.http.Consts;
 import org.apache.http.HttpHeaders;
@@ -38,6 +43,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.util.EntityUtils;
+import org.apache.thrift.TException;
 import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -55,120 +61,8 @@ import java.util.Map;
 
 public class KeyCloakSecurityManager implements CustosSecurityManager {
     private final static Logger logger = LoggerFactory.getLogger(KeyCloakSecurityManager.class);
-
-//    private HashMap<String, String> rolePermissionConfig = new HashMap<>();
-//
-//    // Methods that users user to manage their user resource profile
-//    private final static String USER_RESOURCE_PROFILE_USER_METHODS = "/airavata/registerUserResourceProfile|/airavata/getUserResourceProfile" +
-//            "|/airavata/updateUserResourceProfile|/airavata/deleteUserResourceProfile|/airavata/addUserComputeResourcePreference" +
-//            "|/airavata/addUserStoragePreference|/airavata/getUserComputeResourcePreference|/airavata/getUserStoragePreference" +
-//            "|/airavata/getAllUserComputeResourcePreferences|/airavata/getAllUserStoragePreferences" +
-//            "|/airavata/updateUserComputeResourcePreference|/airavata/updateUserStoragePreference" +
-//            "|/airavata/deleteUserComputeResourcePreference|/airavata/deleteUserStoragePreference" +
-//            "|/airavata/generateAndRegisterSSHKeys|/airavata/getAllCredentialSummaryForUsersInGateway" +
-//            "|/airavata/deleteSSHPubKey|/airavata/isUserResourceProfileExists";
-//    private final static String SHARING_RESOURCE_METHODS = "/airavata/shareResourceWithUsers|/airavata/revokeSharingOfResourceFromUsers" +
-//            "|/airavata/shareResourceWithGroups|/airavata/revokeSharingOfResourceFromGroups|/airavata/getAllAccessibleUsers" +
-//            "|/airavata/getAllAccessibleGroups|/airavata/userHasAccess|/airavata/getAllDirectlyAccessibleUsers" +
-//            "|/airavata/getAllDirectlyAccessibleGroups";
-//    private final static String SSH_ACCOUNT_PROVISIONER_METHODS =
-//            "/airavata/getSSHAccountProvisioners|/airavata/doesUserHaveSSHAccount|/airavata" +
-//                    "/setupUserComputeResourcePreferencesForSSH|" +
-//                    // getGatewayResourceProfile is needed to look up whether ssh account provisioning is
-//                    // configured for a gateway's compute resource preference
-//                    "/airavata/getGatewayResourceProfile";
-//    // These methods are protected by sharing registry authorization
-//    private final static String GROUP_RESOURCE_PROFILE_METHODS =
-//            "/airavata/createGroupResourceProfile|/airavata/updateGroupResourceProfile|/airavata/getGroupResourceProfile" +
-//                    "|/airavata/removeGroupResourceProfile|/airavata/getGroupResourceList|/airavata/removeGroupComputePrefs" +
-//                    "|/airavata/removeGroupComputeResourcePolicy|/airavata/removeGroupBatchQueueResourcePolicy" +
-//                    "|/airavata/getGroupComputeResourcePreference|/airavata/getGroupComputeResourcePolicy" +
-//                    "|/airavata/getBatchQueueResourcePolicy|/airavata/getGroupComputeResourcePrefList" +
-//                    "|/airavata/getGroupBatchQueueResourcePolicyList|/airavata/getGroupComputeResourcePolicyList";
-//    // These methods are protected by sharing registry authorization
-//    private final static String APPLICATION_DEPLOYMENT_METHODS =
-//            "/airavata/registerApplicationDeployment|/airavata/getApplicationDeployment|/airavata/updateApplicationDeployment" +
-//                    "|/airavata/deleteApplicationDeployment|/airavata/getAllApplicationDeployments|/airavata/getAccessibleApplicationDeployments" +
-//                    "|/airavata/getApplicationDeploymentsForAppModuleAndGroupResourceProfile";
-//    private final static String APPLICATION_MODULE_METHODS = "/airavata/getAccessibleAppModules";
-//    private final static String CREDENTIAL_TOKEN_METHODS = "/airavata/getCredentialSummary|/airavata/getAllCredentialSummaries|/airavata/generateAndRegisterSSHKeys|/airavata/registerPwdCredential|/airavata/deleteSSHPubKey|/airavata/deletePWDCredential";
-//    // Misc. other methods needed for group based authorization
-//    private final static String GROUP_BASED_AUTH_METHODS = "/airavata/getGatewayGroups";
-//
-//    private RegistryService.Client registryServiceClient = null;
-//    private SharingRegistryService.Client sharingRegistryServiceClient = null;
-//
-//    private static class GatewayGroupMembership {
-//        private boolean inAdminsGroup = false;
-//        private boolean inReadOnlyAdminsGroup = false;
-//
-//        public boolean isInAdminsGroup() {
-//            return inAdminsGroup;
-//        }
-//
-//        public void setInAdminsGroup(boolean inAdminsGroup) {
-//            this.inAdminsGroup = inAdminsGroup;
-//        }
-//
-//        public boolean isInReadOnlyAdminsGroup() {
-//            return inReadOnlyAdminsGroup;
-//        }
-//
-//        public void setInReadOnlyAdminsGroup(boolean inReadOnlyAdminsGroup) {
-//            this.inReadOnlyAdminsGroup = inReadOnlyAdminsGroup;
-//        }
-//    }
-
+    private TenantProfileService.Client tenantProfileClient = null;
     public KeyCloakSecurityManager() throws CustosSecurityException {
-//        rolePermissionConfig.put("admin", "/airavata/.*");
-//        rolePermissionConfig.put("gateway-provider", "/airavata/.*");
-//        rolePermissionConfig.put("admin-read-only", "/airavata/getSSHPubKey|/airavata/getAllGatewaySSHPubKeys" +
-//                "|/airavata/getAllGatewayPWDCredentials|/airavata/getApplicationModule|/airavata/getAllAppModules" +
-//                "|/airavata/getApplicationDeployment|/airavata/getAllApplicationDeployments|/airavata/getAppModuleDeployedResources" +
-//                "|/airavata/getStorageResource|/airavata/getAllStorageResourceNames|/airavata/getSCPDataMovement" +
-//                "|/airavata/getUnicoreDataMovement|/airavata/getGridFTPDataMovement|/airavata/getResourceJobManager" +
-//                "|/airavata/deleteResourceJobManager|/airavata/getGatewayResourceProfile|/airavata/getGatewayComputeResourcePreference" +
-//                "|/airavata/getGatewayStoragePreference|/airavata/getAllGatewayComputeResourcePreferences" +
-//                "|/airavata/getAllGatewayStoragePreferences|/airavata/getAllGatewayResourceProfiles|/airavata/getAPIVersion" +
-//                "|/airavata/getNotification|/airavata/getAllNotifications|/airavata/createProject|/airavata/updateProject" +
-//                "|/airavata/getProject|/airavata/deleteProject|/airavata/getUserProjects|/airavata/searchProjectsByProjectName" +
-//                "|/airavata/searchProjectsByProjectDesc|/airavata/searchExperimentsByName|/airavata/searchExperimentsByDesc" +
-//                "|/airavata/searchExperimentsByApplication|/airavata/searchExperimentsByStatus|/airavata/searchExperimentsByCreationTime" +
-//                "|/airavata/searchExperiments|/airavata/getExperimentStatistics|/airavata/getExperimentsInProject" +
-//                "|/airavata/getUserExperiments|/airavata/createExperiment|/airavata/deleteExperiment|/airavata/getExperiment" +
-//                "|/airavata/getDetailedExperimentTree|/airavata/updateExperiment|/airavata/updateExperimentConfiguration" +
-//                "|/airavata/updateResourceScheduleing|/airavata/validateExperiment|/airavata/launchExperiment" +
-//                "|/airavata/getExperimentStatus|/airavata/getExperimentOutputs|/airavata/getIntermediateOutputs" +
-//                "|/airavata/getJobStatuses|/airavata/getJobDetails|/airavata/cloneExperiment|/airavata/terminateExperiment" +
-//                "|/airavata/getApplicationInterface|/airavata/getAllApplicationInterfaceNames|/airavata/getAllApplicationInterfaces" +
-//                "|/airavata/getApplicationInputs|/airavata/getApplicationOutputs|/airavata/getAvailableAppInterfaceComputeResources" +
-//                "|/airavata/getComputeResource|/airavata/getAllComputeResourceNames|/airavata/getWorkflow|/airavata/getWorkflowTemplateId" +
-//                "|/airavata/isWorkflowExistWithName|/airavata/registerDataProduct|/airavata/getDataProduct|/airavata/registerReplicaLocation" +
-//                "|/airavata/getParentDataProduct|/airavata/getChildDataProducts|/airavata/getAllAccessibleUsers" +
-//                "|/airavata/getExperimentByAdmin|/airavata/cloneExperimentByAdmin|/airavata/getAllCredentialSummaryForGateway" +
-//                "|" + USER_RESOURCE_PROFILE_USER_METHODS + "|/airavata/getAllUserResourceProfiles" +
-//                "|" + SHARING_RESOURCE_METHODS + "|/airavata/getGateway|" + SSH_ACCOUNT_PROVISIONER_METHODS + "|" + GROUP_RESOURCE_PROFILE_METHODS +
-//                "|" + APPLICATION_DEPLOYMENT_METHODS + "|" + GROUP_BASED_AUTH_METHODS + "|" + APPLICATION_MODULE_METHODS +
-//                "|" + CREDENTIAL_TOKEN_METHODS);
-//        rolePermissionConfig.put("gateway-user", "/airavata/getAPIVersion|/airavata/getNotification|/airavata/getAllNotifications|" +
-//                "/airavata/createProject|/airavata/updateProject|/airavata/getProject|/airavata/deleteProject|/airavata/getUserProjects|" +
-//                "/airavata/searchProjectsByProjectName|/airavata/searchProjectsByProjectDesc|/airavata/searchExperimentsByName|" +
-//                "/airavata/searchExperimentsByDesc|/airavata/searchExperimentsByApplication|/airavata/searchExperimentsByStatus|" +
-//                "/airavata/searchExperimentsByCreationTime|/airavata/searchExperiments|/airavata/getExperimentStatistics|" +
-//                "/airavata/getExperimentsInProject|/airavata/getUserExperiments|/airavata/createExperiment|/airavata/deleteExperiment|" +
-//                "/airavata/getExperiment|/airavata/getDetailedExperimentTree|/airavata/updateExperiment|/airavata/updateExperimentConfiguration|" +
-//                "/airavata/updateResourceScheduleing|/airavata/validateExperiment|/airavata/launchExperiment|/airavata/getExperimentStatus|" +
-//                "/airavata/getExperimentOutputs|/airavata/getIntermediateOutputs|/airavata/getJobStatuses|/airavata/getJobDetails|" +
-//                "/airavata/cloneExperiment|/airavata/terminateExperiment|/airavata/getApplicationInterface|/airavata/getAllApplicationInterfaceNames|" +
-//                "/airavata/getAllApplicationInterfaces|/airavata/getApplicationInputs|/airavata/getApplicationOutputs|" +
-//                "/airavata/getAvailableAppInterfaceComputeResources|/airavata/getComputeResource|/airavata/getAllComputeResourceNames|" +
-//                "/airavata/getWorkflow|/airavata/getWorkflowTemplateId|/airavata/isWorkflowExistWithName|/airavata/registerDataProduct|" +
-//                "/airavata/getDataProduct|/airavata/registerReplicaLocation|/airavata/getParentDataProduct|/airavata/getChildDataProducts|" +
-//                "/airavata/getAllAccessibleUsers|/airavata/getAllApplicationDeployments|/airavata/getAllAppModules|/airavata/getApplicationModule|" + USER_RESOURCE_PROFILE_USER_METHODS + "|" +
-//                SHARING_RESOURCE_METHODS + "|" + SSH_ACCOUNT_PROVISIONER_METHODS + "|" + GROUP_RESOURCE_PROFILE_METHODS +
-//                "|" + APPLICATION_DEPLOYMENT_METHODS + "|" + GROUP_BASED_AUTH_METHODS + "|" + APPLICATION_MODULE_METHODS +
-//                "|" + CREDENTIAL_TOKEN_METHODS);
-
         initializeSecurityInfra();
     }
 
@@ -203,13 +97,12 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
         String subject = authzToken.getClaimsMap().get(Constants.USER_NAME);
         String accessToken = authzToken.getAccessToken();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
-        String identityServerRealm = metaData.get(Constants.IDENTITY_SERVER_TENANT);
         //String action = "/airavata/" + metaData.get(Constants.API_METHOD_NAME);
         try {
-//            if (!ServerSettings.isAPISecured()) {
-//                return true;
-//            }
-//            initServiceClients();
+            if (!ServerSettings.isAPISecured()) {
+                return true;
+            }
+            initServiceClients();
 
             if (ServerSettings.isAuthzCacheEnabled()) {
                 //obtain an instance of AuthzCacheManager implementation.
@@ -230,7 +123,7 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
                             "Generating decision based on group membership.");
 //                    GatewayGroupMembership gatewayGroupMembership = getGatewayGroupMembership(subject, accessToken, gatewayId);
 //                    boolean authorizationDecision = hasPermission(gatewayGroupMembership, action);
-                    boolean authorizationDecision = validateToken(subject, accessToken, gatewayId, identityServerRealm);
+                    boolean authorizationDecision = validateToken(subject, accessToken, gatewayId);
                     //cache the authorization decision
                     long currentTime = System.currentTimeMillis();
                     //TODO get the actual token expiration time
@@ -244,7 +137,7 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
             } else {
 //                GatewayGroupMembership gatewayGroupMembership = getGatewayGroupMembership(subject, accessToken, gatewayId);
 //                return hasPermission(gatewayGroupMembership, action);
-                return validateToken(subject, accessToken, gatewayId, identityServerRealm);
+                return validateToken(subject, accessToken, gatewayId);
             }
 
         } catch (ApplicationSettingsException e) {
@@ -260,33 +153,31 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
     }
 
     @Override
-    public AuthzToken getUserManagementServiceAccountAuthzToken(String gatewayId, String clientId, String clientSecret) throws CustosSecurityException {
+    public AuthzToken getUserManagementServiceAccountAuthzToken(String gatewayId) throws CustosSecurityException {
         try {
-//            initServiceClients();
-//            Gateway gateway = registryServiceClient.getGateway(gatewayId);
+            initServiceClients();
+            Gateway gateway = tenantProfileClient.getGatewayUsingGatewayId(gatewayId);
             String tokenURL = getTokenEndpoint(gatewayId);
-//            JSONObject clientCredentials = getClientCredentials(tokenURL, gateway.getOauthClientId(), gateway.getOauthClientSecret());
-            JSONObject clientCredentials = getClientCredentials(tokenURL, clientId, clientSecret);
+            JSONObject clientCredentials = getClientCredentials(tokenURL, gateway.getOauthClientId(), gateway.getOauthClientSecret());
             String accessToken = clientCredentials.getString("access_token");
             AuthzToken authzToken = new AuthzToken(accessToken);
             authzToken.putToClaimsMap(Constants.GATEWAY_ID, gatewayId);
-            authzToken.putToClaimsMap(Constants.USER_NAME, clientId);
+            authzToken.putToClaimsMap(Constants.USER_NAME, gateway.getOauthClientId());
             return authzToken;
         } catch (Exception e) {
             throw new CustosSecurityException(e);
+        } finally {
+            closeServiceClients();
         }
-//        } finally {
-//            closeServiceClients();
-//        }
     }
 
     @Override
-    public UserInfo getUserInfoFromAuthzToken(AuthzToken authzToken, String identityServerRealm) throws CustosSecurityException {
+    public UserInfo getUserInfoFromAuthzToken(AuthzToken authzToken) throws CustosSecurityException {
         try {
 //            initServiceClients();
             final String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
             final String token = authzToken.getAccessToken();
-            return getUserInfo(gatewayId, token, identityServerRealm);
+            return getUserInfo(gatewayId, token);
         } catch (Exception e) {
             throw new CustosSecurityException(e);
         }
@@ -295,10 +186,11 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
 //        }
     }
 
-    private UserInfo getUserInfo(String gatewayId, String token, String identityServerRealm) throws Exception {
+    private UserInfo getUserInfo(String gatewayId, String token) throws Exception {
 //        GatewayResourceProfile gwrp = registryServiceClient.getGatewayResourceProfile(gatewayId);
 //        String identityServerRealm = gwrp.getIdentityServerTenant();
-        String openIdConnectUrl = getOpenIDConfigurationUrl(identityServerRealm);
+        //TODO: Confirm the difference between gatewayId and IdentityServerTenant, using gatewayId as of now
+        String openIdConnectUrl = getOpenIDConfigurationUrl(gatewayId);
         JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, null));
         String userInfoEndPoint = openIdConnectConfig.getString("userinfo_endpoint");
         JSONObject userInfo = new JSONObject(getFromUrl(userInfoEndPoint, token));
@@ -330,8 +222,8 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
 //        }
 //    }
 
-    private boolean validateToken(String username, String token, String gatewayId, String identityServerRealm) throws Exception {
-        UserInfo userInfo = getUserInfo(gatewayId, token, identityServerRealm);
+    private boolean validateToken(String username, String token, String gatewayId) throws Exception {
+        UserInfo userInfo = getUserInfo(gatewayId, token);
         if (!username.equals(userInfo.getUsername())) {
             throw new CustosSecurityException("Subject name and username for the token doesn't match");
         }
@@ -480,19 +372,15 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
 //        return false;
 //    }
 //
-//    private void initServiceClients() throws TException, ApplicationSettingsException {
-//        registryServiceClient = getRegistryServiceClient();
-//        sharingRegistryServiceClient = getSharingRegistryServiceClient();
-//    }
+    private void initServiceClients() throws TException, ApplicationSettingsException {
+        tenantProfileClient = getTenantProfileServiceClient();
+    }
 
-//    private void closeServiceClients() {
-//        if (registryServiceClient != null) {
-//            ThriftUtils.close(registryServiceClient);
-//        }
-//        if (sharingRegistryServiceClient != null) {
-//            ThriftUtils.close(sharingRegistryServiceClient);
-//        }
-//    }
+    private void closeServiceClients() {
+        if (tenantProfileClient != null) {
+            ThriftUtils.close(tenantProfileClient);
+        }
+    }
 
 //    private RegistryService.Client getRegistryServiceClient() throws TException, ApplicationSettingsException {
 //        final int serverPort = Integer.parseInt(ServerSettings.getRegistryServerPort());
@@ -534,4 +422,12 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
 //        JSONObject jsonObject = keyCloakSecurityManager.getClientCredentials(tokenURL, clientId, clientSecret);
 //        System.out.println("access_token=" + jsonObject.getString("access_token"));
 //    }
+    private TenantProfileService.Client getTenantProfileServiceClient() throws ApplicationSettingsException , TenantProfileServiceException, TException {
+        try {
+            TenantProfileService.Client tenantProfileClient = ProfileServiceClientFactory.createTenantProfileServiceClient(ServerSettings.getProfileServiceServerHost(), Integer.parseInt(ServerSettings.getProfileServiceServerPort()));
+            return tenantProfileClient;
+        } catch (TenantProfileServiceException e) {
+            throw new TenantProfileServiceException("Unable to create tenant profile client...");
+        }
+    }
 }
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/SecurityManagerFactory.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/SecurityManagerFactory.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/SecurityManagerFactory.java
rename to custos-connectors/src/main/java/org.apache.custos.security/manager/SecurityManagerFactory.java
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/UserInfo.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/UserInfo.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/UserInfo.java
rename to custos-connectors/src/main/java/org.apache.custos.security/manager/UserInfo.java
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/utils/TrustStoreManager.java b/custos-connectors/src/main/java/org.apache.custos.security/utils/TrustStoreManager.java
similarity index 100%
rename from custos-services/custos-security-service/src/main/java/org/apache/custos/security/utils/TrustStoreManager.java
rename to custos-connectors/src/main/java/org.apache.custos.security/utils/TrustStoreManager.java
diff --git a/custos-services/profile-service/iam-admin-services-core/pom.xml b/custos-profile-service/iam-admin-services-core/pom.xml
similarity index 98%
rename from custos-services/profile-service/iam-admin-services-core/pom.xml
rename to custos-profile-service/iam-admin-services-core/pom.xml
index bc2a6d0..7b2e09d 100644
--- a/custos-services/profile-service/iam-admin-services-core/pom.xml
+++ b/custos-profile-service/iam-admin-services-core/pom.xml
@@ -70,7 +70,7 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>profile-service-stubs</artifactId>
-            <version>${project.version}</version>
+            <version>1.0-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
diff --git a/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java b/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
similarity index 96%
rename from custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
rename to custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
index bab92a2..f3309bd 100644
--- a/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
+++ b/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
@@ -19,17 +19,17 @@
  *
  */
 
-package org.apache.custos.service.profile.iam.admin.services.core.impl;
+package org.apache.custos.profile.iam.admin.services.core.impl;
 
 import org.apache.custos.commons.exceptions.ApplicationSettingsException;
 import org.apache.custos.commons.utils.SecurityUtil;
 import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.profile.models.tenant.PasswordCredential;
-import org.apache.custos.profile.models.user.Status;
-import org.apache.custos.profile.models.user.UserProfile;
-import org.apache.custos.profile.models.workspace.Gateway;
-import org.apache.custos.service.profile.iam.admin.services.core.interfaces.TenantManagementInterface;
-import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.model.tenant.PasswordCredential;
+import org.apache.custos.profile.model.user.Status;
+import org.apache.custos.profile.model.user.UserProfile;
+import org.apache.custos.profile.model.workspace.Gateway;
+import org.apache.custos.profile.iam.admin.services.core.interfaces.TenantManagementInterface;
 import org.jboss.resteasy.client.jaxrs.ResteasyClient;
 import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
 import org.keycloak.admin.client.Keycloak;
@@ -771,7 +771,7 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface {
     private UserProfile convertUserRepresentationToUserProfile(UserRepresentation userRepresentation, String tenantId) {
 
         UserProfile profile = new UserProfile();
-        profile.setAiravataInternalUserId(userRepresentation.getUsername() + "@" + tenantId);
+        profile.setCustosInternalUserId(userRepresentation.getUsername() + "@" + tenantId);
         profile.setGatewayId(tenantId);
         profile.setUserId(userRepresentation.getUsername());
         profile.setFirstName(userRepresentation.getFirstName());
@@ -807,15 +807,15 @@ public class TenantManagementKeycloakImpl implements TenantManagementInterface {
         return null;
     }
 
-    public static void main(String[] args) throws IamAdminServicesException, ApplicationSettingsException {
-        TenantManagementKeycloakImpl tenantManagementKeycloak = new TenantManagementKeycloakImpl();
-        ServerSettings.setSetting("trust.store", "./modules/configuration/server/src/main/resources/client_truststore.jks");
-        ServerSettings.setSetting("trust.store.password", "airavata");
-        ServerSettings.setSetting("iam.server.url", "");
-        String accessToken = "";
-        String tenantId = "";
-        String username = "";
-        boolean isUsernameAvailable = tenantManagementKeycloak.isUsernameAvailable(accessToken, tenantId, username);
-        System.out.println("Username " + username + " is " + (isUsernameAvailable ? "": "NOT ") + "available");
-    }
+//    public static void main(String[] args) throws IamAdminServicesException, ApplicationSettingsException {
+//        TenantManagementKeycloakImpl tenantManagementKeycloak = new TenantManagementKeycloakImpl();
+//        ServerSettings.setSetting("trust.store", "./modules/configuration/server/src/main/resources/client_truststore.jks");
+//        ServerSettings.setSetting("trust.store.password", "airavata");
+//        ServerSettings.setSetting("iam.server.url", "");
+//        String accessToken = "";
+//        String tenantId = "";
+//        String username = "";
+//        boolean isUsernameAvailable = tenantManagementKeycloak.isUsernameAvailable(accessToken, tenantId, username);
+//        System.out.println("Username " + username + " is " + (isUsernameAvailable ? "": "NOT ") + "available");
+//    }
 }
diff --git a/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java b/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java
similarity index 93%
rename from custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java
rename to custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java
index d809ad2..1d4a141 100644
--- a/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java
+++ b/custos-profile-service/iam-admin-services-core/src/main/java/org/apache/custos/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java
@@ -19,19 +19,19 @@
  *
  */
 
-package org.apache.custos.service.profile.iam.admin.services.core.interfaces;
+package org.apache.custos.profile.iam.admin.services.core.interfaces;
 
-import org.apache.custos.profile.models.tenant.PasswordCredential;
-import org.apache.custos.profile.models.user.UserProfile;
-import org.apache.custos.profile.models.workspace.Gateway;
-import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.model.tenant.PasswordCredential;
+import org.apache.custos.profile.model.user.UserProfile;
+import org.apache.custos.profile.model.workspace.Gateway;
 
 import java.util.List;
 
 public interface TenantManagementInterface {
 
     /**
-     * Method to add Identity server tenant for Airavata gateway creation.
+     * Method to add Identity server tenant for Custos gateway creation.
      *
      * @param isSuperAdminPasswordCreds identity server super admin credentials
      * @param gatewayDetails gateway details from workspace catalog
diff --git a/custos-services/profile-service/iam-admin-services-core/src/test/java/org/apache/custos/service/profile/iam/admin/services/core/tests/SetupNewGateway.java b/custos-profile-service/iam-admin-services-core/src/test/java/org/apache/custos/profile/iam/admin/services/core/tests/SetupNewGateway.java
similarity index 93%
rename from custos-services/profile-service/iam-admin-services-core/src/test/java/org/apache/custos/service/profile/iam/admin/services/core/tests/SetupNewGateway.java
rename to custos-profile-service/iam-admin-services-core/src/test/java/org/apache/custos/profile/iam/admin/services/core/tests/SetupNewGateway.java
index 387ed1c..c96d0f0 100644
--- a/custos-services/profile-service/iam-admin-services-core/src/test/java/org/apache/custos/service/profile/iam/admin/services/core/tests/SetupNewGateway.java
+++ b/custos-profile-service/iam-admin-services-core/src/test/java/org/apache/custos/profile/iam/admin/services/core/tests/SetupNewGateway.java
@@ -1,10 +1,10 @@
-package org.apache.custos.service.profile.iam.admin.services.core.tests;
+package org.apache.custos.profile.iam.admin.services.core.tests;
 
-import org.apache.custos.profile.models.tenant.PasswordCredential;
-import org.apache.custos.profile.models.user.UserProfile;
-import org.apache.custos.profile.models.workspace.Gateway;
-import org.apache.custos.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl;
-import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.model.tenant.PasswordCredential;
+import org.apache.custos.profile.model.user.UserProfile;
+import org.apache.custos.profile.model.workspace.Gateway;
+import org.apache.custos.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl;
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
diff --git a/custos-services/profile-service/pom.xml b/custos-profile-service/pom.xml
similarity index 83%
rename from custos-services/profile-service/pom.xml
rename to custos-profile-service/pom.xml
index 64056a6..1857392 100644
--- a/custos-services/profile-service/pom.xml
+++ b/custos-profile-service/pom.xml
@@ -3,7 +3,7 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>custos-services</artifactId>
+        <artifactId>custos</artifactId>
         <groupId>org.apache.custos</groupId>
         <version>1.0-SNAPSHOT</version>
     </parent>
@@ -18,8 +18,7 @@
         <module>profile-user-core</module>
         <module>profile-service-server</module>
         <module>profile-service-commons</module>
-        <module>profile-service-client-sdks</module>
+        <module>profile-service-model</module>
         <module>profile-service-stubs</module>
-        <module>profile-service-models</module>
     </modules>
 </project>
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-commons/pom.xml b/custos-profile-service/profile-service-commons/pom.xml
similarity index 100%
rename from custos-services/profile-service/profile-service-commons/pom.xml
rename to custos-profile-service/profile-service-commons/pom.xml
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/repositories/AbstractRepository.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/AbstractRepository.java
similarity index 95%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/repositories/AbstractRepository.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/AbstractRepository.java
index 1a778a3..376b4fb 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/repositories/AbstractRepository.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/repositories/AbstractRepository.java
@@ -18,10 +18,10 @@
  * under the License.
  *
 */
-package org.apache.custos.service.profile.commons.repositories;
+package org.apache.custos.profile.commons.repositories;
 
-import org.apache.custos.service.profile.commons.utils.JPAUtils;
-import org.apache.custos.service.profile.commons.utils.ObjectMapperSingleton;
+import org.apache.custos.profile.commons.utils.JPAUtils;
+import org.apache.custos.profile.commons.utils.ObjectMapperSingleton;
 import org.dozer.Mapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/tenant/entities/GatewayEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/tenant/entities/GatewayEntity.java
similarity index 99%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/tenant/entities/GatewayEntity.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/tenant/entities/GatewayEntity.java
index c3506e3..8f68815 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/tenant/entities/GatewayEntity.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/tenant/entities/GatewayEntity.java
@@ -18,7 +18,7 @@
  * under the License.
  *
 */
-package org.apache.custos.service.profile.commons.tenant.entities;
+package org.apache.custos.profile.commons.tenant.entities;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/CustomizedDashboardEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/CustomizedDashboardEntity.java
similarity index 97%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/CustomizedDashboardEntity.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/CustomizedDashboardEntity.java
index 1ee3845..d92cc25 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/CustomizedDashboardEntity.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/CustomizedDashboardEntity.java
@@ -20,7 +20,7 @@
 */
 
 
-package org.apache.custos.service.profile.commons.user.entities;
+package org.apache.custos.profile.commons.user.entities;
 
 import javax.persistence.*;
 
@@ -57,7 +57,7 @@ public class CustomizedDashboardEntity {
     private UserProfileEntity userProfileEntity;
 
     @Id
-    @Column(name = "AIRAVATA_INTERNAL_USER_ID")
+    @Column(name = "CUSTOS_INTERNAL_USER_ID")
     public String getCustosInternalUserId() {
         return custosInternalUserId;
     }
@@ -283,7 +283,7 @@ public class CustomizedDashboardEntity {
     }
 
     @OneToOne(targetEntity = UserProfileEntity.class, cascade = CascadeType.ALL)
-    @PrimaryKeyJoinColumn(name = "AIRAVATA_INTERNAL_USER_ID", referencedColumnName = "AIRAVATA_INTERNAL_USER_ID")
+    @PrimaryKeyJoinColumn(name = "CUSTOS_INTERNAL_USER_ID", referencedColumnName = "CUSTOS_INTERNAL_USER_ID")
     public UserProfileEntity getUserProfileEntity() {
         return userProfileEntity;
     }
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/NSFDemographicsEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/NSFDemographicsEntity.java
similarity index 90%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/NSFDemographicsEntity.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/NSFDemographicsEntity.java
index f336444..fdf2b90 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/NSFDemographicsEntity.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/NSFDemographicsEntity.java
@@ -18,7 +18,7 @@
  * under the License.
  *
 */
-package org.apache.custos.service.profile.commons.user.entities;
+package org.apache.custos.profile.commons.user.entities;
 
 import javax.persistence.*;
 import java.util.List;
@@ -53,7 +53,7 @@ public class NSFDemographicsEntity {
     }
 
     @ElementCollection
-    @CollectionTable(name="NSF_DEMOGRAPHIC_ETHNICITY", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @CollectionTable(name="NSF_DEMOGRAPHIC_ETHNICITY", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
     @Column(name = "ETHNICITY")
     public List<String> getEthnicities() {
         return ethnicities;
@@ -64,7 +64,7 @@ public class NSFDemographicsEntity {
     }
 
     @ElementCollection
-    @CollectionTable(name="NSF_DEMOGRAPHIC_RACE", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @CollectionTable(name="NSF_DEMOGRAPHIC_RACE", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
     @Column(name = "RACE")
     public List<String> getRaces() {
         return races;
@@ -75,7 +75,7 @@ public class NSFDemographicsEntity {
     }
 
     @ElementCollection
-    @CollectionTable(name="NSF_DEMOGRAPHIC_DISABILITY", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @CollectionTable(name="NSF_DEMOGRAPHIC_DISABILITY", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
     @Column(name = "DISABILITY")
     public List<String> getDisabilities() {
         return disabilities;
@@ -86,7 +86,7 @@ public class NSFDemographicsEntity {
     }
 
     @OneToOne(targetEntity = UserProfileEntity.class, cascade = CascadeType.ALL)
-    @PrimaryKeyJoinColumn(name = "AIRAVATA_INTERNAL_USER_ID", referencedColumnName = "AIRAVATA_INTERNAL_USER_ID")
+    @PrimaryKeyJoinColumn(name = "CUSTOS_INTERNAL_USER_ID", referencedColumnName = "CUSTOS_INTERNAL_USER_ID")
     public UserProfileEntity getUserProfile() {
         return userProfile;
     }
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/UserProfileEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java
similarity index 96%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/UserProfileEntity.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java
index c95f2c0..04f3265 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/UserProfileEntity.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java
@@ -18,7 +18,7 @@
  * under the License.
  *
 */
-package org.apache.custos.service.profile.commons.user.entities;
+package org.apache.custos.profile.commons.user.entities;
 
 import javax.persistence.*;
 import java.util.Date;
@@ -56,7 +56,7 @@ public class UserProfileEntity {
     private CustomizedDashboardEntity customizedDashboardEntity;
 
     @Id
-    @Column(name = "AIRAVATA_INTERNAL_USER_ID")
+    @Column(name = "CUSTOS_INTERNAL_USER_ID")
     public String getCustosInternalUserId() {
         return custosInternalUserId;
     }
@@ -93,7 +93,7 @@ public class UserProfileEntity {
     }
 
     @ElementCollection(fetch = FetchType.EAGER)
-    @CollectionTable(name="USER_PROFILE_EMAIL", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @CollectionTable(name="USER_PROFILE_EMAIL", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
     @Column(name = "EMAIL")
     public List<String> getEmails() {
         return emails;
@@ -158,7 +158,7 @@ public class UserProfileEntity {
     }
 
     @ElementCollection(fetch = FetchType.EAGER)
-    @CollectionTable(name="USER_PROFILE_PHONE", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @CollectionTable(name="USER_PROFILE_PHONE", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
     @Column(name = "PHONE")
     public List<String> getPhones() {
         return phones;
@@ -178,7 +178,7 @@ public class UserProfileEntity {
     }
 
     @ElementCollection(fetch = FetchType.EAGER)
-    @CollectionTable(name="USER_PROFILE_NATIONALITY", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @CollectionTable(name="USER_PROFILE_NATIONALITY", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
     @Column(name = "NATIONALITY")
     public List<String> getNationality() {
         return nationality;
@@ -253,7 +253,7 @@ public class UserProfileEntity {
     }
 
     @ElementCollection(fetch = FetchType.EAGER)
-    @CollectionTable(name="USER_PROFILE_LABELED_URI", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @CollectionTable(name="USER_PROFILE_LABELED_URI", joinColumns = @JoinColumn(name="CUSTOS_INTERNAL_USER_ID"))
     @Column(name = "LABELED_URI")
     public List<String> getLabeledURI() {
         return labeledURI;
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Committer.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Committer.java
similarity index 93%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Committer.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Committer.java
index aa2dc58..5cf4ea3 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Committer.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Committer.java
@@ -18,7 +18,7 @@
  * under the License.
  *
 */
-package org.apache.custos.service.profile.commons.utils;
+package org.apache.custos.profile.commons.utils;
 
 @FunctionalInterface
 public interface Committer<T, R>  {
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAConstants.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAConstants.java
similarity index 96%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAConstants.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAConstants.java
index f029df0..7d35b13 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAConstants.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAConstants.java
@@ -18,7 +18,7 @@
  * under the License.
  *
  */
-package org.apache.custos.service.profile.commons.utils;
+package org.apache.custos.profile.commons.utils;
 
 public class JPAConstants {
 	public static final String KEY_JDBC_URL = "profile.service.jdbc.url";
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAUtils.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAUtils.java
similarity index 97%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAUtils.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAUtils.java
index 2cae126..2b881eb 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAUtils.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/JPAUtils.java
@@ -18,7 +18,7 @@
  * under the License.
  *
 */
-package org.apache.custos.service.profile.commons.utils;
+package org.apache.custos.profile.commons.utils;
 
 import org.apache.custos.commons.utils.JDBCConfig;
 
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ObjectMapperSingleton.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ObjectMapperSingleton.java
similarity index 95%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ObjectMapperSingleton.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ObjectMapperSingleton.java
index e5cd0f1..b012b17 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ObjectMapperSingleton.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ObjectMapperSingleton.java
@@ -18,7 +18,7 @@
  * under the License.
  *
 */
-package org.apache.custos.service.profile.commons.utils;
+package org.apache.custos.profile.commons.utils;
 
 import org.dozer.DozerBeanMapper;
 import org.slf4j.Logger;
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ProfileServiceJDBCConfig.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ProfileServiceJDBCConfig.java
similarity index 96%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ProfileServiceJDBCConfig.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ProfileServiceJDBCConfig.java
index fe2db70..84a1f66 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ProfileServiceJDBCConfig.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/ProfileServiceJDBCConfig.java
@@ -18,7 +18,7 @@
  * under the License.
  *
  */
-package org.apache.custos.service.profile.commons.utils;
+package org.apache.custos.profile.commons.utils;
 
 import org.apache.custos.commons.utils.JDBCConfig;
 
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/QueryConstants.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/QueryConstants.java
similarity index 75%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/QueryConstants.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/QueryConstants.java
index 6b3da31..15cc267 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/QueryConstants.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/QueryConstants.java
@@ -1,7 +1,7 @@
-package org.apache.custos.service.profile.commons.utils;
+package org.apache.custos.profile.commons.utils;
 
-import org.apache.custos.profile.models.user.UserProfile;
-import org.apache.custos.profile.models.workspace.Gateway;
+import org.apache.custos.profile.model.user.UserProfile;
+import org.apache.custos.profile.model.workspace.Gateway;
 
 /**
  * Created by goshenoy on 03/08/2017.
@@ -17,7 +17,10 @@ public class QueryConstants {
             "where u.gatewayId LIKE :" + UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
 
     public static final String FIND_GATEWAY_BY_INTERNAL_ID = "SELECT g FROM GatewayEntity g " +
-            "where g.airavataInternalGatewayId LIKE :" + Gateway._Fields.AIRAVATA_INTERNAL_GATEWAY_ID.getFieldName();
+            "where g.custosInternalGatewayId LIKE :" + Gateway._Fields.CUSTOS_INTERNAL_GATEWAY_ID.getFieldName();
+
+    public static final String FIND_GATEWAY_BY_GATEWAY_ID = "SELECT g FROM GatewayEntity g " +
+            "where g.gatewayId LIKE :" + Gateway._Fields.GATEWAY_ID.getFieldName();
 
     public static final String FIND_DUPLICATE_GATEWAY = "SELECT g FROM GatewayEntity g " +
             "where g.gatewayApprovalStatus IN :" + Gateway._Fields.GATEWAY_APPROVAL_STATUS.getFieldName() + " " +
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Utils.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Utils.java
similarity index 98%
rename from custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Utils.java
rename to custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Utils.java
index 78033cc..b3ddd31 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Utils.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/utils/Utils.java
@@ -18,7 +18,7 @@
  * under the License.
  *
  */
-package org.apache.custos.service.profile.commons.utils;
+package org.apache.custos.profile.commons.utils;
 
 import org.apache.custos.commons.exceptions.ApplicationSettingsException;
 import org.apache.custos.commons.utils.ServerSettings;
diff --git a/custos-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml b/custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
similarity index 77%
rename from custos-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
rename to custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
index 9f20353..f0a162e 100644
--- a/custos-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
+++ b/custos-profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
@@ -22,10 +22,10 @@
 <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
     <persistence-unit name="profile_service">
         <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
-        <class>org.apache.custos.service.profile.commons.user.entities.UserProfileEntity</class>
-        <class>org.apache.custos.service.profile.commons.user.entities.NSFDemographicsEntity</class>
-        <class>org.apache.custos.service.profile.commons.user.entities.CustomizedDashboardEntity</class>
-        <class>org.apache.custos.service.profile.commons.tenant.entities.GatewayEntity</class>
+        <class>org.apache.custos.profile.commons.user.entities.UserProfileEntity</class>
+        <class>org.apache.custos.profile.commons.user.entities.NSFDemographicsEntity</class>
+        <class>org.apache.custos.profile.commons.user.entities.CustomizedDashboardEntity</class>
+        <class>org.apache.custos.profile.commons.tenant.entities.GatewayEntity</class>
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
 
         <properties>
diff --git a/custos-services/profile-service/profile-service-models/pom.xml b/custos-profile-service/profile-service-model/pom.xml
similarity index 100%
rename from custos-services/profile-service/profile-service-models/pom.xml
rename to custos-profile-service/profile-service-model/pom.xml
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/PasswordCredential.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/PasswordCredential.java
similarity index 99%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/PasswordCredential.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/PasswordCredential.java
index 7a225c7..9bbe78e 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/PasswordCredential.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/PasswordCredential.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.tenant;
+package org.apache.custos.profile.model.tenant;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/Tenant.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/Tenant.java
similarity index 99%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/Tenant.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/Tenant.java
index 68b6bfd..014ec62 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/Tenant.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/Tenant.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.tenant;
+package org.apache.custos.profile.model.tenant;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
@@ -1225,7 +1225,7 @@ public class Tenant implements org.apache.thrift.TBase<Tenant, Tenant._Fields>,
             break;
           case 2: // TENANT_APPROVAL_STATUS
             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
-              struct.tenantApprovalStatus = org.apache.airavata.model.tenant.TenantApprovalStatus.findByValue(iprot.readI32());
+              struct.tenantApprovalStatus = org.apache.custos.profile.model.tenant.TenantApprovalStatus.findByValue(iprot.readI32());
               struct.setTenantApprovalStatusIsSet(true);
             } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
@@ -1490,7 +1490,7 @@ public class Tenant implements org.apache.thrift.TBase<Tenant, Tenant._Fields>,
       org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
       struct.tenantId = iprot.readString();
       struct.setTenantIdIsSet(true);
-      struct.tenantApprovalStatus = org.apache.airavata.model.tenant.TenantApprovalStatus.findByValue(iprot.readI32());
+      struct.tenantApprovalStatus = org.apache.custos.profile.model.tenant.TenantApprovalStatus.findByValue(iprot.readI32());
       struct.setTenantApprovalStatusIsSet(true);
       java.util.BitSet incoming = iprot.readBitSet(10);
       if (incoming.get(0)) {
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/TenantApprovalStatus.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/TenantApprovalStatus.java
similarity index 97%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/TenantApprovalStatus.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/TenantApprovalStatus.java
index ecd9ce1..6fa3587 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/TenantApprovalStatus.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/TenantApprovalStatus.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.tenant;
+package org.apache.custos.profile.model.tenant;
 
 
 import org.apache.thrift.TEnum;
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/TenantConfig.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/TenantConfig.java
similarity index 99%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/TenantConfig.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/TenantConfig.java
index 796e93d..056adce 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/TenantConfig.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/TenantConfig.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.tenant;
+package org.apache.custos.profile.model.tenant;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/TenantPreferences.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/TenantPreferences.java
similarity index 99%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/TenantPreferences.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/TenantPreferences.java
index d895150..945304a 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/TenantPreferences.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/tenant/TenantPreferences.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.tenant;
+package org.apache.custos.profile.model.tenant;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/CustomDashboard.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/CustomDashboard.java
similarity index 99%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/CustomDashboard.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/CustomDashboard.java
index 69cd1fe..0799843 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/CustomDashboard.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/CustomDashboard.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.user;
+package org.apache.custos.profile.model.user;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 /**
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/NSFDemographics.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/NSFDemographics.java
similarity index 88%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/NSFDemographics.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/NSFDemographics.java
index ef1e4f6..d2e54b7 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/NSFDemographics.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/NSFDemographics.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.user;
+package org.apache.custos.profile.model.user;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 /**
@@ -33,7 +33,7 @@ package org.apache.custos.profile.models.user;
 public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics, NSFDemographics._Fields>, java.io.Serializable, Cloneable, Comparable<NSFDemographics> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("NSFDemographics");
 
-  private static final org.apache.thrift.protocol.TField AIRAVATA_INTERNAL_USER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("airavataInternalUserId", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField CUSTOS_INTERNAL_USER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("custosInternalUserId", org.apache.thrift.protocol.TType.STRING, (short)1);
   private static final org.apache.thrift.protocol.TField GENDER_FIELD_DESC = new org.apache.thrift.protocol.TField("gender", org.apache.thrift.protocol.TType.STRING, (short)2);
   private static final org.apache.thrift.protocol.TField US_CITIZENSHIP_FIELD_DESC = new org.apache.thrift.protocol.TField("usCitizenship", org.apache.thrift.protocol.TType.I32, (short)3);
   private static final org.apache.thrift.protocol.TField ETHNICITIES_FIELD_DESC = new org.apache.thrift.protocol.TField("ethnicities", org.apache.thrift.protocol.TType.LIST, (short)4);
@@ -43,7 +43,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
   private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new NSFDemographicsStandardSchemeFactory();
   private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new NSFDemographicsTupleSchemeFactory();
 
-  private String airavataInternalUserId; // required
+  private String custosInternalUserId; // required
   private String gender; // optional
   private USCitizenship usCitizenship; // optional
   private java.util.List<ethnicity> ethnicities; // optional
@@ -52,7 +52,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
-    AIRAVATA_INTERNAL_USER_ID((short)1, "airavataInternalUserId"),
+    CUSTOS_INTERNAL_USER_ID((short)1, "custosInternalUserId"),
     GENDER((short)2, "gender"),
     /**
      *
@@ -76,8 +76,8 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
      */
     public static _Fields findByThriftId(int fieldId) {
       switch(fieldId) {
-        case 1: // AIRAVATA_INTERNAL_USER_ID
-          return AIRAVATA_INTERNAL_USER_ID;
+        case 1: // CUSTOS_INTERNAL_USER_ID
+          return CUSTOS_INTERNAL_USER_ID;
         case 2: // GENDER
           return GENDER;
         case 3: // US_CITIZENSHIP
@@ -132,7 +132,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
   public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
   static {
     java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.AIRAVATA_INTERNAL_USER_ID, new org.apache.thrift.meta_data.FieldMetaData("airavataInternalUserId", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.CUSTOS_INTERNAL_USER_ID, new org.apache.thrift.meta_data.FieldMetaData("custosInternalUserId", org.apache.thrift.TFieldRequirementType.REQUIRED,
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     tmpMap.put(_Fields.GENDER, new org.apache.thrift.meta_data.FieldMetaData("gender", org.apache.thrift.TFieldRequirementType.OPTIONAL,
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
@@ -152,23 +152,23 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
   }
 
   public NSFDemographics() {
-    this.airavataInternalUserId = "DO_NOT_SET_AT_CLIENTS";
+    this.custosInternalUserId = "DO_NOT_SET_AT_CLIENTS";
 
   }
 
   public NSFDemographics(
-    String airavataInternalUserId)
+    String custosInternalUserId)
   {
     this();
-    this.airavataInternalUserId = airavataInternalUserId;
+    this.custosInternalUserId = custosInternalUserId;
   }
 
   /**
    * Performs a deep copy on <i>other</i>.
    */
   public NSFDemographics(NSFDemographics other) {
-    if (other.isSetAiravataInternalUserId()) {
-      this.airavataInternalUserId = other.airavataInternalUserId;
+    if (other.isSetCustosInternalUserId()) {
+      this.custosInternalUserId = other.custosInternalUserId;
     }
     if (other.isSetGender()) {
       this.gender = other.gender;
@@ -205,7 +205,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
 
   @Override
   public void clear() {
-    this.airavataInternalUserId = "DO_NOT_SET_AT_CLIENTS";
+    this.custosInternalUserId = "DO_NOT_SET_AT_CLIENTS";
 
     this.gender = null;
     this.usCitizenship = null;
@@ -214,26 +214,26 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     this.disabilities = null;
   }
 
-  public String getAiravataInternalUserId() {
-    return this.airavataInternalUserId;
+  public String getCustosInternalUserId() {
+    return this.custosInternalUserId;
   }
 
-  public void setAiravataInternalUserId(String airavataInternalUserId) {
-    this.airavataInternalUserId = airavataInternalUserId;
+  public void setCustosInternalUserId(String CustosInternalUserId) {
+    this.custosInternalUserId = custosInternalUserId;
   }
 
-  public void unsetAiravataInternalUserId() {
-    this.airavataInternalUserId = null;
+  public void unsetCustosInternalUserId() {
+    this.custosInternalUserId = null;
   }
 
-  /** Returns true if field airavataInternalUserId is set (has been assigned a value) and false otherwise */
-  public boolean isSetAiravataInternalUserId() {
-    return this.airavataInternalUserId != null;
+  /** Returns true if field custosInternalUserId is set (has been assigned a value) and false otherwise */
+  public boolean isSetCustosInternalUserId() {
+    return this.custosInternalUserId != null;
   }
 
-  public void setAiravataInternalUserIdIsSet(boolean value) {
+  public void setCustosInternalUserIdIsSet(boolean value) {
     if (!value) {
-      this.airavataInternalUserId = null;
+      this.custosInternalUserId = null;
     }
   }
 
@@ -407,11 +407,11 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
 
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
-    case AIRAVATA_INTERNAL_USER_ID:
+    case CUSTOS_INTERNAL_USER_ID:
       if (value == null) {
-        unsetAiravataInternalUserId();
+        unsetCustosInternalUserId();
       } else {
-        setAiravataInternalUserId((String)value);
+        setCustosInternalUserId((String)value);
       }
       break;
 
@@ -460,8 +460,8 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
 
   public Object getFieldValue(_Fields field) {
     switch (field) {
-    case AIRAVATA_INTERNAL_USER_ID:
-      return getAiravataInternalUserId();
+    case CUSTOS_INTERNAL_USER_ID:
+      return getCustosInternalUserId();
 
     case GENDER:
       return getGender();
@@ -489,8 +489,8 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     }
 
     switch (field) {
-    case AIRAVATA_INTERNAL_USER_ID:
-      return isSetAiravataInternalUserId();
+    case CUSTOS_INTERNAL_USER_ID:
+      return isSetCustosInternalUserId();
     case GENDER:
       return isSetGender();
     case US_CITIZENSHIP:
@@ -520,12 +520,12 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     if (this == that)
       return true;
 
-    boolean this_present_airavataInternalUserId = true && this.isSetAiravataInternalUserId();
-    boolean that_present_airavataInternalUserId = true && that.isSetAiravataInternalUserId();
-    if (this_present_airavataInternalUserId || that_present_airavataInternalUserId) {
-      if (!(this_present_airavataInternalUserId && that_present_airavataInternalUserId))
+    boolean this_present_custosInternalUserId = true && this.isSetCustosInternalUserId();
+    boolean that_present_custosInternalUserId = true && that.isSetCustosInternalUserId();
+    if (this_present_custosInternalUserId || that_present_custosInternalUserId) {
+      if (!(this_present_custosInternalUserId && that_present_custosInternalUserId))
         return false;
-      if (!this.airavataInternalUserId.equals(that.airavataInternalUserId))
+      if (!this.custosInternalUserId.equals(that.custosInternalUserId))
         return false;
     }
 
@@ -581,9 +581,9 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
   public int hashCode() {
     int hashCode = 1;
 
-    hashCode = hashCode * 8191 + ((isSetAiravataInternalUserId()) ? 131071 : 524287);
-    if (isSetAiravataInternalUserId())
-      hashCode = hashCode * 8191 + airavataInternalUserId.hashCode();
+    hashCode = hashCode * 8191 + ((isSetCustosInternalUserId()) ? 131071 : 524287);
+    if (isSetCustosInternalUserId())
+      hashCode = hashCode * 8191 + custosInternalUserId.hashCode();
 
     hashCode = hashCode * 8191 + ((isSetGender()) ? 131071 : 524287);
     if (isSetGender())
@@ -616,12 +616,12 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
 
     int lastComparison = 0;
 
-    lastComparison = Boolean.valueOf(isSetAiravataInternalUserId()).compareTo(other.isSetAiravataInternalUserId());
+    lastComparison = Boolean.valueOf(isSetCustosInternalUserId()).compareTo(other.isSetCustosInternalUserId());
     if (lastComparison != 0) {
       return lastComparison;
     }
-    if (isSetAiravataInternalUserId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.airavataInternalUserId, other.airavataInternalUserId);
+    if (isSetCustosInternalUserId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.custosInternalUserId, other.custosInternalUserId);
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -696,11 +696,11 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     StringBuilder sb = new StringBuilder("NSFDemographics(");
     boolean first = true;
 
-    sb.append("airavataInternalUserId:");
-    if (this.airavataInternalUserId == null) {
+    sb.append("custosInternalUserId:");
+    if (this.custosInternalUserId == null) {
       sb.append("null");
     } else {
-      sb.append(this.airavataInternalUserId);
+      sb.append(this.custosInternalUserId);
     }
     first = false;
     if (isSetGender()) {
@@ -759,8 +759,8 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
 
   public void validate() throws org.apache.thrift.TException {
     // check for required fields
-    if (!isSetAiravataInternalUserId()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'airavataInternalUserId' is unset! Struct:" + toString());
+    if (!isSetCustosInternalUserId()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'custosInternalUserId' is unset! Struct:" + toString());
     }
 
     // check for sub-struct validity
@@ -800,10 +800,10 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
           break;
         }
         switch (schemeField.id) {
-          case 1: // AIRAVATA_INTERNAL_USER_ID
+          case 1: // CUSTOS_INTERNAL_USER_ID
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.airavataInternalUserId = iprot.readString();
-              struct.setAiravataInternalUserIdIsSet(true);
+              struct.custosInternalUserId = iprot.readString();
+              struct.setCustosInternalUserIdIsSet(true);
             } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
@@ -818,7 +818,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
             break;
           case 3: // US_CITIZENSHIP
             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
-              struct.usCitizenship = org.apache.airavata.model.user.USCitizenship.findByValue(iprot.readI32());
+              struct.usCitizenship = org.apache.custos.profile.model.user.USCitizenship.findByValue(iprot.readI32());
               struct.setUsCitizenshipIsSet(true);
             } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
@@ -832,7 +832,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
                 ethnicity _elem1;
                 for (int _i2 = 0; _i2 < _list0.size; ++_i2)
                 {
-                  _elem1 = org.apache.airavata.model.user.ethnicity.findByValue(iprot.readI32());
+                  _elem1 = org.apache.custos.profile.model.user.ethnicity.findByValue(iprot.readI32());
                   struct.ethnicities.add(_elem1);
                 }
                 iprot.readListEnd();
@@ -850,7 +850,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
                 race _elem4;
                 for (int _i5 = 0; _i5 < _list3.size; ++_i5)
                 {
-                  _elem4 = org.apache.airavata.model.user.race.findByValue(iprot.readI32());
+                  _elem4 = org.apache.custos.profile.model.user.race.findByValue(iprot.readI32());
                   struct.races.add(_elem4);
                 }
                 iprot.readListEnd();
@@ -868,7 +868,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
                 disability _elem7;
                 for (int _i8 = 0; _i8 < _list6.size; ++_i8)
                 {
-                  _elem7 = org.apache.airavata.model.user.disability.findByValue(iprot.readI32());
+                  _elem7 = org.apache.custos.profile.model.user.disability.findByValue(iprot.readI32());
                   struct.disabilities.add(_elem7);
                 }
                 iprot.readListEnd();
@@ -891,9 +891,9 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
       struct.validate();
 
       oprot.writeStructBegin(STRUCT_DESC);
-      if (struct.airavataInternalUserId != null) {
-        oprot.writeFieldBegin(AIRAVATA_INTERNAL_USER_ID_FIELD_DESC);
-        oprot.writeString(struct.airavataInternalUserId);
+      if (struct.custosInternalUserId != null) {
+        oprot.writeFieldBegin(CUSTOS_INTERNAL_USER_ID_FIELD_DESC);
+        oprot.writeString(struct.custosInternalUserId);
         oprot.writeFieldEnd();
       }
       if (struct.gender != null) {
@@ -969,7 +969,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     @Override
     public void write(org.apache.thrift.protocol.TProtocol prot, NSFDemographics struct) throws org.apache.thrift.TException {
       org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      oprot.writeString(struct.airavataInternalUserId);
+      oprot.writeString(struct.custosInternalUserId);
       java.util.BitSet optionals = new java.util.BitSet();
       if (struct.isSetGender()) {
         optionals.set(0);
@@ -1025,15 +1025,15 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     @Override
     public void read(org.apache.thrift.protocol.TProtocol prot, NSFDemographics struct) throws org.apache.thrift.TException {
       org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      struct.airavataInternalUserId = iprot.readString();
-      struct.setAiravataInternalUserIdIsSet(true);
+      struct.custosInternalUserId = iprot.readString();
+      struct.setCustosInternalUserIdIsSet(true);
       java.util.BitSet incoming = iprot.readBitSet(5);
       if (incoming.get(0)) {
         struct.gender = iprot.readString();
         struct.setGenderIsSet(true);
       }
       if (incoming.get(1)) {
-        struct.usCitizenship = org.apache.airavata.model.user.USCitizenship.findByValue(iprot.readI32());
+        struct.usCitizenship = org.apache.custos.profile.model.user.USCitizenship.findByValue(iprot.readI32());
         struct.setUsCitizenshipIsSet(true);
       }
       if (incoming.get(2)) {
@@ -1043,7 +1043,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
           ethnicity _elem16;
           for (int _i17 = 0; _i17 < _list15.size; ++_i17)
           {
-            _elem16 = org.apache.airavata.model.user.ethnicity.findByValue(iprot.readI32());
+            _elem16 = org.apache.custos.profile.model.user.ethnicity.findByValue(iprot.readI32());
             struct.ethnicities.add(_elem16);
           }
         }
@@ -1056,7 +1056,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
           race _elem19;
           for (int _i20 = 0; _i20 < _list18.size; ++_i20)
           {
-            _elem19 = org.apache.airavata.model.user.race.findByValue(iprot.readI32());
+            _elem19 = org.apache.custos.profile.model.user.race.findByValue(iprot.readI32());
             struct.races.add(_elem19);
           }
         }
@@ -1069,7 +1069,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
           disability _elem22;
           for (int _i23 = 0; _i23 < _list21.size; ++_i23)
           {
-            _elem22 = org.apache.airavata.model.user.disability.findByValue(iprot.readI32());
+            _elem22 = org.apache.custos.profile.model.user.disability.findByValue(iprot.readI32());
             struct.disabilities.add(_elem22);
           }
         }
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/Status.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/Status.java
similarity index 97%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/Status.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/Status.java
index e1af1c4..119a68b 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/Status.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/Status.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.user;
+package org.apache.custos.profile.model.user;
 
 
 import org.apache.thrift.TEnum;
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/USCitizenship.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/USCitizenship.java
similarity index 97%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/USCitizenship.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/USCitizenship.java
index ca79ab1..89cfcc0 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/USCitizenship.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/USCitizenship.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.user;
+package org.apache.custos.profile.model.user;
 
 
 import org.apache.thrift.TEnum;
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/UserProfile.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/UserProfile.java
similarity index 96%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/UserProfile.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/UserProfile.java
index 7e41d59..6b83946 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/UserProfile.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/UserProfile.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.user;
+package org.apache.custos.profile.model.user;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 /**
@@ -73,7 +73,7 @@ package org.apache.custos.profile.models.user;
  * * nationality Countries of citizenship
  * *
  * * comments:
- * *   Free-form information (treated as opaque by Airavata and simply passed to resource).
+ * *   Free-form information (treated as opaque by Custos and simply passed to resource).
  * *
  * * labeledURI:
  *   * Google Scholar, Web of Science, ACS, e.t.c
@@ -87,7 +87,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UserProfile");
 
   private static final org.apache.thrift.protocol.TField USER_MODEL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("userModelVersion", org.apache.thrift.protocol.TType.STRING, (short)1);
-  private static final org.apache.thrift.protocol.TField AIRAVATA_INTERNAL_USER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("airavataInternalUserId", org.apache.thrift.protocol.TType.STRING, (short)2);
+  private static final org.apache.thrift.protocol.TField CUSTOS_INTERNAL_USER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("custosInternalUserId", org.apache.thrift.protocol.TType.STRING, (short)2);
   private static final org.apache.thrift.protocol.TField USER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("userId", org.apache.thrift.protocol.TType.STRING, (short)3);
   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)4);
   private static final org.apache.thrift.protocol.TField EMAILS_FIELD_DESC = new org.apache.thrift.protocol.TField("emails", org.apache.thrift.protocol.TType.LIST, (short)5);
@@ -117,7 +117,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
   private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserProfileTupleSchemeFactory();
 
   private String userModelVersion; // required
-  private String airavataInternalUserId; // required
+  private String custosInternalUserId; // required
   private String userId; // required
   private String gatewayId; // required
   private java.util.List<String> emails; // required
@@ -146,7 +146,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
     USER_MODEL_VERSION((short)1, "userModelVersion"),
-    AIRAVATA_INTERNAL_USER_ID((short)2, "airavataInternalUserId"),
+    CUSTOS_INTERNAL_USER_ID((short)2, "custosInternalUserId"),
     USER_ID((short)3, "userId"),
     GATEWAY_ID((short)4, "gatewayId"),
     EMAILS((short)5, "emails"),
@@ -191,8 +191,8 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       switch(fieldId) {
         case 1: // USER_MODEL_VERSION
           return USER_MODEL_VERSION;
-        case 2: // AIRAVATA_INTERNAL_USER_ID
-          return AIRAVATA_INTERNAL_USER_ID;
+        case 2: // CUSTOS_INTERNAL_USER_ID
+          return CUSTOS_INTERNAL_USER_ID;
         case 3: // USER_ID
           return USER_ID;
         case 4: // GATEWAY_ID
@@ -291,7 +291,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
     tmpMap.put(_Fields.USER_MODEL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("userModelVersion", org.apache.thrift.TFieldRequirementType.REQUIRED,
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.AIRAVATA_INTERNAL_USER_ID, new org.apache.thrift.meta_data.FieldMetaData("airavataInternalUserId", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.CUSTOS_INTERNAL_USER_ID, new org.apache.thrift.meta_data.FieldMetaData("custosInternalUserId", org.apache.thrift.TFieldRequirementType.REQUIRED,
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     tmpMap.put(_Fields.USER_ID, new org.apache.thrift.meta_data.FieldMetaData("userId", org.apache.thrift.TFieldRequirementType.REQUIRED,
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
@@ -352,13 +352,13 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
   public UserProfile() {
     this.userModelVersion = "1.0";
 
-    this.airavataInternalUserId = "DO_NOT_SET_AT_CLIENTS";
+    this.custosInternalUserId = "DO_NOT_SET_AT_CLIENTS";
 
   }
 
   public UserProfile(
     String userModelVersion,
-    String airavataInternalUserId,
+    String custosInternalUserId,
     String userId,
     String gatewayId,
     java.util.List<String> emails,
@@ -371,7 +371,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
   {
     this();
     this.userModelVersion = userModelVersion;
-    this.airavataInternalUserId = airavataInternalUserId;
+    this.custosInternalUserId = custosInternalUserId;
     this.userId = userId;
     this.gatewayId = gatewayId;
     this.emails = emails;
@@ -394,8 +394,8 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     if (other.isSetUserModelVersion()) {
       this.userModelVersion = other.userModelVersion;
     }
-    if (other.isSetAiravataInternalUserId()) {
-      this.airavataInternalUserId = other.airavataInternalUserId;
+    if (other.isSetCustosInternalUserId()) {
+      this.custosInternalUserId = other.custosInternalUserId;
     }
     if (other.isSetUserId()) {
       this.userId = other.userId;
@@ -477,7 +477,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
   public void clear() {
     this.userModelVersion = "1.0";
 
-    this.airavataInternalUserId = "DO_NOT_SET_AT_CLIENTS";
+    this.custosInternalUserId = "DO_NOT_SET_AT_CLIENTS";
 
     this.userId = null;
     this.gatewayId = null;
@@ -531,26 +531,26 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
-  public String getAiravataInternalUserId() {
-    return this.airavataInternalUserId;
+  public String getCustosInternalUserId() {
+    return this.custosInternalUserId;
   }
 
-  public void setAiravataInternalUserId(String airavataInternalUserId) {
-    this.airavataInternalUserId = airavataInternalUserId;
+  public void setCustosInternalUserId(String custosInternalUserId) {
+    this.custosInternalUserId = custosInternalUserId;
   }
 
-  public void unsetAiravataInternalUserId() {
-    this.airavataInternalUserId = null;
+  public void unsetCustosInternalUserId() {
+    this.custosInternalUserId = null;
   }
 
-  /** Returns true if field airavataInternalUserId is set (has been assigned a value) and false otherwise */
-  public boolean isSetAiravataInternalUserId() {
-    return this.airavataInternalUserId != null;
+  /** Returns true if field custosInternalUserId is set (has been assigned a value) and false otherwise */
+  public boolean isSetCustosInternalUserId() {
+    return this.custosInternalUserId != null;
   }
 
-  public void setAiravataInternalUserIdIsSet(boolean value) {
+  public void setCustosInternalUserIdIsSet(boolean value) {
     if (!value) {
-      this.airavataInternalUserId = null;
+      this.custosInternalUserId = null;
     }
   }
 
@@ -1181,11 +1181,11 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       }
       break;
 
-    case AIRAVATA_INTERNAL_USER_ID:
+    case CUSTOS_INTERNAL_USER_ID:
       if (value == null) {
-        unsetAiravataInternalUserId();
+        unsetCustosInternalUserId();
       } else {
-        setAiravataInternalUserId((String)value);
+        setCustosInternalUserId((String)value);
       }
       break;
 
@@ -1389,8 +1389,8 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     case USER_MODEL_VERSION:
       return getUserModelVersion();
 
-    case AIRAVATA_INTERNAL_USER_ID:
-      return getAiravataInternalUserId();
+    case CUSTOS_INTERNAL_USER_ID:
+      return getCustosInternalUserId();
 
     case USER_ID:
       return getUserId();
@@ -1477,8 +1477,8 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     switch (field) {
     case USER_MODEL_VERSION:
       return isSetUserModelVersion();
-    case AIRAVATA_INTERNAL_USER_ID:
-      return isSetAiravataInternalUserId();
+    case CUSTOS_INTERNAL_USER_ID:
+      return isSetCustosInternalUserId();
     case USER_ID:
       return isSetUserId();
     case GATEWAY_ID:
@@ -1555,12 +1555,12 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         return false;
     }
 
-    boolean this_present_airavataInternalUserId = true && this.isSetAiravataInternalUserId();
-    boolean that_present_airavataInternalUserId = true && that.isSetAiravataInternalUserId();
-    if (this_present_airavataInternalUserId || that_present_airavataInternalUserId) {
-      if (!(this_present_airavataInternalUserId && that_present_airavataInternalUserId))
+    boolean this_present_custosInternalUserId = true && this.isSetCustosInternalUserId();
+    boolean that_present_custosInternalUserId = true && that.isSetCustosInternalUserId();
+    if (this_present_custosInternalUserId || that_present_custosInternalUserId) {
+      if (!(this_present_custosInternalUserId && that_present_custosInternalUserId))
         return false;
-      if (!this.airavataInternalUserId.equals(that.airavataInternalUserId))
+      if (!this.custosInternalUserId.equals(that.custosInternalUserId))
         return false;
     }
 
@@ -1791,9 +1791,9 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     if (isSetUserModelVersion())
       hashCode = hashCode * 8191 + userModelVersion.hashCode();
 
-    hashCode = hashCode * 8191 + ((isSetAiravataInternalUserId()) ? 131071 : 524287);
-    if (isSetAiravataInternalUserId())
-      hashCode = hashCode * 8191 + airavataInternalUserId.hashCode();
+    hashCode = hashCode * 8191 + ((isSetCustosInternalUserId()) ? 131071 : 524287);
+    if (isSetCustosInternalUserId())
+      hashCode = hashCode * 8191 + custosInternalUserId.hashCode();
 
     hashCode = hashCode * 8191 + ((isSetUserId()) ? 131071 : 524287);
     if (isSetUserId())
@@ -1906,12 +1906,12 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         return lastComparison;
       }
     }
-    lastComparison = Boolean.valueOf(isSetAiravataInternalUserId()).compareTo(other.isSetAiravataInternalUserId());
+    lastComparison = Boolean.valueOf(isSetCustosInternalUserId()).compareTo(other.isSetCustosInternalUserId());
     if (lastComparison != 0) {
       return lastComparison;
     }
-    if (isSetAiravataInternalUserId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.airavataInternalUserId, other.airavataInternalUserId);
+    if (isSetCustosInternalUserId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.custosInternalUserId, other.custosInternalUserId);
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -2184,11 +2184,11 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
     first = false;
     if (!first) sb.append(", ");
-    sb.append("airavataInternalUserId:");
-    if (this.airavataInternalUserId == null) {
+    sb.append("custosInternalUserId:");
+    if (this.custosInternalUserId == null) {
       sb.append("null");
     } else {
-      sb.append(this.airavataInternalUserId);
+      sb.append(this.custosInternalUserId);
     }
     first = false;
     if (!first) sb.append(", ");
@@ -2411,8 +2411,8 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       throw new org.apache.thrift.protocol.TProtocolException("Required field 'userModelVersion' is unset! Struct:" + toString());
     }
 
-    if (!isSetAiravataInternalUserId()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'airavataInternalUserId' is unset! Struct:" + toString());
+    if (!isSetCustosInternalUserId()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'custosInternalUserId' is unset! Struct:" + toString());
     }
 
     if (!isSetUserId()) {
@@ -2504,10 +2504,10 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
-          case 2: // AIRAVATA_INTERNAL_USER_ID
+          case 2: // CUSTOS_INTERNAL_USER_ID
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.airavataInternalUserId = iprot.readString();
-              struct.setAiravataInternalUserIdIsSet(true);
+              struct.custosInternalUserId = iprot.readString();
+              struct.setCustosInternalUserIdIsSet(true);
             } else {
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
@@ -2680,7 +2680,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             break;
           case 20: // STATE
             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
-              struct.State = org.apache.airavata.model.user.Status.findByValue(iprot.readI32());
+              struct.State = org.apache.custos.profile.model.user.Status.findByValue(iprot.readI32());
               struct.setStateIsSet(true);
             } else {
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
@@ -2764,9 +2764,9 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         oprot.writeString(struct.userModelVersion);
         oprot.writeFieldEnd();
       }
-      if (struct.airavataInternalUserId != null) {
-        oprot.writeFieldBegin(AIRAVATA_INTERNAL_USER_ID_FIELD_DESC);
-        oprot.writeString(struct.airavataInternalUserId);
+      if (struct.custosInternalUserId != null) {
+        oprot.writeFieldBegin(CUSTOS_INTERNAL_USER_ID_FIELD_DESC);
+        oprot.writeString(struct.custosInternalUserId);
         oprot.writeFieldEnd();
       }
       if (struct.userId != null) {
@@ -2959,7 +2959,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     public void write(org.apache.thrift.protocol.TProtocol prot, UserProfile struct) throws org.apache.thrift.TException {
       org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
       oprot.writeString(struct.userModelVersion);
-      oprot.writeString(struct.airavataInternalUserId);
+      oprot.writeString(struct.custosInternalUserId);
       oprot.writeString(struct.userId);
       oprot.writeString(struct.gatewayId);
       {
@@ -3092,8 +3092,8 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
       struct.userModelVersion = iprot.readString();
       struct.setUserModelVersionIsSet(true);
-      struct.airavataInternalUserId = iprot.readString();
-      struct.setAiravataInternalUserIdIsSet(true);
+      struct.custosInternalUserId = iprot.readString();
+      struct.setCustosInternalUserIdIsSet(true);
       struct.userId = iprot.readString();
       struct.setUserIdIsSet(true);
       struct.gatewayId = iprot.readString();
@@ -3119,7 +3119,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       struct.setLastAccessTimeIsSet(true);
       struct.validUntil = iprot.readI64();
       struct.setValidUntilIsSet(true);
-      struct.State = org.apache.airavata.model.user.Status.findByValue(iprot.readI32());
+      struct.State = org.apache.custos.profile.model.user.Status.findByValue(iprot.readI32());
       struct.setStateIsSet(true);
       java.util.BitSet incoming = iprot.readBitSet(15);
       if (incoming.get(0)) {
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/disability.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/disability.java
similarity index 97%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/disability.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/disability.java
index 7063c52..eb0058c 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/disability.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/disability.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.user;
+package org.apache.custos.profile.model.user;
 
 
 import org.apache.thrift.TEnum;
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/ethnicity.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/ethnicity.java
similarity index 97%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/ethnicity.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/ethnicity.java
index 4ee5411..955f16c 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/ethnicity.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/ethnicity.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.user;
+package org.apache.custos.profile.model.user;
 
 
 import org.apache.thrift.TEnum;
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/race.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/race.java
similarity index 98%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/race.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/race.java
index a56e572..3bc91aa 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/race.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/race.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.user;
+package org.apache.custos.profile.model.user;
 
 
 import org.apache.thrift.TEnum;
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/user_profile_modelConstants.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/user_profile_modelConstants.java
similarity index 95%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/user_profile_modelConstants.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/user_profile_modelConstants.java
index dc98ae6..03b89d8 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/user/user_profile_modelConstants.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/user_profile_modelConstants.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.user;
+package org.apache.custos.profile.model.user;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 public class user_profile_modelConstants {
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/workspace/Gateway.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/workspace/Gateway.java
similarity index 95%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/workspace/Gateway.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/workspace/Gateway.java
index 6e8609a..54f4c7e 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/workspace/Gateway.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/workspace/Gateway.java
@@ -21,14 +21,14 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.workspace;
+package org.apache.custos.profile.model.workspace;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
 @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
 public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields>, java.io.Serializable, Cloneable, Comparable<Gateway> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Gateway");
 
-  private static final org.apache.thrift.protocol.TField AIRAVATA_INTERNAL_GATEWAY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("airavataInternalGatewayId", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField CUSTOS_INTERNAL_GATEWAY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("custosInternalGatewayId", org.apache.thrift.protocol.TType.STRING, (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 GATEWAY_APPROVAL_STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("gatewayApprovalStatus", org.apache.thrift.protocol.TType.I32, (short)3);
   private static final org.apache.thrift.protocol.TField GATEWAY_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("gatewayName", org.apache.thrift.protocol.TType.STRING, (short)4);
@@ -52,7 +52,7 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
   private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new GatewayStandardSchemeFactory();
   private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new GatewayTupleSchemeFactory();
 
-  private String airavataInternalGatewayId; // optional
+  private String custosInternalGatewayId; // optional
   private String gatewayId; // required
   private GatewayApprovalStatus gatewayApprovalStatus; // required
   private String gatewayName; // optional
@@ -75,7 +75,7 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
-    AIRAVATA_INTERNAL_GATEWAY_ID((short)1, "airavataInternalGatewayId"),
+    CUSTOS_INTERNAL_GATEWAY_ID((short)1, "custosInternalGatewayId"),
     GATEWAY_ID((short)2, "gatewayId"),
     /**
      *
@@ -113,8 +113,8 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
      */
     public static _Fields findByThriftId(int fieldId) {
       switch(fieldId) {
-        case 1: // AIRAVATA_INTERNAL_GATEWAY_ID
-          return AIRAVATA_INTERNAL_GATEWAY_ID;
+        case 1: // CUSTOS_INTERNAL_GATEWAY_ID
+          return CUSTOS_INTERNAL_GATEWAY_ID;
         case 2: // GATEWAY_ID
           return GATEWAY_ID;
         case 3: // GATEWAY_APPROVAL_STATUS
@@ -195,11 +195,11 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
   // isset id assignments
   private static final int __REQUESTCREATIONTIME_ISSET_ID = 0;
   private byte __isset_bitfield = 0;
-  private static final _Fields optionals[] = {_Fields.AIRAVATA_INTERNAL_GATEWAY_ID, _Fields.GATEWAY_NAME, _Fields.DOMAIN, _Fields.EMAIL_ADDRESS, _Fields.GATEWAY_ACRONYM, _Fields.GATEWAY_URL, _Fields.GATEWAY_PUBLIC_ABSTRACT, _Fields.REVIEW_PROPOSAL_DESCRIPTION, _Fields.GATEWAY_ADMIN_FIRST_NAME, _Fields.GATEWAY_ADMIN_LAST_NAME, _Fields.GATEWAY_ADMIN_EMAIL, _Fields.IDENTITY_SERVER_USER_NAME, _Fields.IDENTITY_SERVER_PASSWORD_TOKEN, _Fields.DECLINED_REASON, _Fields.OAUTH_CLIENT_ID, _Fields.OA [...]
+  private static final _Fields optionals[] = {_Fields.CUSTOS_INTERNAL_GATEWAY_ID, _Fields.GATEWAY_NAME, _Fields.DOMAIN, _Fields.EMAIL_ADDRESS, _Fields.GATEWAY_ACRONYM, _Fields.GATEWAY_URL, _Fields.GATEWAY_PUBLIC_ABSTRACT, _Fields.REVIEW_PROPOSAL_DESCRIPTION, _Fields.GATEWAY_ADMIN_FIRST_NAME, _Fields.GATEWAY_ADMIN_LAST_NAME, _Fields.GATEWAY_ADMIN_EMAIL, _Fields.IDENTITY_SERVER_USER_NAME, _Fields.IDENTITY_SERVER_PASSWORD_TOKEN, _Fields.DECLINED_REASON, _Fields.OAUTH_CLIENT_ID, _Fields.OAUT [...]
   public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
   static {
     java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.AIRAVATA_INTERNAL_GATEWAY_ID, new org.apache.thrift.meta_data.FieldMetaData("airavataInternalGatewayId", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.CUSTOS_INTERNAL_GATEWAY_ID, new org.apache.thrift.meta_data.FieldMetaData("custosInternalGatewayId", org.apache.thrift.TFieldRequirementType.OPTIONAL,
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
     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)));
@@ -260,8 +260,8 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
    */
   public Gateway(Gateway other) {
     __isset_bitfield = other.__isset_bitfield;
-    if (other.isSetAiravataInternalGatewayId()) {
-      this.airavataInternalGatewayId = other.airavataInternalGatewayId;
+    if (other.isSetCustosInternalGatewayId()) {
+      this.custosInternalGatewayId = other.custosInternalGatewayId;
     }
     if (other.isSetGatewayId()) {
       this.gatewayId = other.gatewayId;
@@ -326,7 +326,7 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
 
   @Override
   public void clear() {
-    this.airavataInternalGatewayId = null;
+    this.custosInternalGatewayId = null;
     this.gatewayId = null;
     this.gatewayApprovalStatus = null;
     this.gatewayName = null;
@@ -349,26 +349,26 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
     this.requesterUsername = null;
   }
 
-  public String getAiravataInternalGatewayId() {
-    return this.airavataInternalGatewayId;
+  public String getCustosInternalGatewayId() {
+    return this.custosInternalGatewayId;
   }
 
-  public void setAiravataInternalGatewayId(String airavataInternalGatewayId) {
-    this.airavataInternalGatewayId = airavataInternalGatewayId;
+  public void setCustosInternalGatewayId(String custosInternalGatewayId) {
+    this.custosInternalGatewayId = custosInternalGatewayId;
   }
 
-  public void unsetAiravataInternalGatewayId() {
-    this.airavataInternalGatewayId = null;
+  public void unsetCustosInternalGatewayId() {
+    this.custosInternalGatewayId = null;
   }
 
-  /** Returns true if field airavataInternalGatewayId is set (has been assigned a value) and false otherwise */
-  public boolean isSetAiravataInternalGatewayId() {
-    return this.airavataInternalGatewayId != null;
+  /** Returns true if field custosInternalGatewayId is set (has been assigned a value) and false otherwise */
+  public boolean isSetCustosInternalGatewayId() {
+    return this.custosInternalGatewayId != null;
   }
 
-  public void setAiravataInternalGatewayIdIsSet(boolean value) {
+  public void setCustosInternalGatewayIdIsSet(boolean value) {
     if (!value) {
-      this.airavataInternalGatewayId = null;
+      this.custosInternalGatewayId = null;
     }
   }
 
@@ -818,11 +818,11 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
 
   public void setFieldValue(_Fields field, Object value) {
     switch (field) {
-    case AIRAVATA_INTERNAL_GATEWAY_ID:
+    case CUSTOS_INTERNAL_GATEWAY_ID:
       if (value == null) {
-        unsetAiravataInternalGatewayId();
+        unsetCustosInternalGatewayId();
       } else {
-        setAiravataInternalGatewayId((String)value);
+        setCustosInternalGatewayId((String)value);
       }
       break;
 
@@ -983,8 +983,8 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
 
   public Object getFieldValue(_Fields field) {
     switch (field) {
-    case AIRAVATA_INTERNAL_GATEWAY_ID:
-      return getAiravataInternalGatewayId();
+    case CUSTOS_INTERNAL_GATEWAY_ID:
+      return getCustosInternalGatewayId();
 
     case GATEWAY_ID:
       return getGatewayId();
@@ -1054,8 +1054,8 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
     }
 
     switch (field) {
-    case AIRAVATA_INTERNAL_GATEWAY_ID:
-      return isSetAiravataInternalGatewayId();
+    case CUSTOS_INTERNAL_GATEWAY_ID:
+      return isSetCustosInternalGatewayId();
     case GATEWAY_ID:
       return isSetGatewayId();
     case GATEWAY_APPROVAL_STATUS:
@@ -1113,12 +1113,12 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
     if (this == that)
       return true;
 
-    boolean this_present_airavataInternalGatewayId = true && this.isSetAiravataInternalGatewayId();
-    boolean that_present_airavataInternalGatewayId = true && that.isSetAiravataInternalGatewayId();
-    if (this_present_airavataInternalGatewayId || that_present_airavataInternalGatewayId) {
-      if (!(this_present_airavataInternalGatewayId && that_present_airavataInternalGatewayId))
+    boolean this_present_custosInternalGatewayId = true && this.isSetCustosInternalGatewayId();
+    boolean that_present_custosInternalGatewayId = true && that.isSetCustosInternalGatewayId();
+    if (this_present_custosInternalGatewayId || that_present_custosInternalGatewayId) {
+      if (!(this_present_custosInternalGatewayId && that_present_custosInternalGatewayId))
         return false;
-      if (!this.airavataInternalGatewayId.equals(that.airavataInternalGatewayId))
+      if (!this.custosInternalGatewayId.equals(that.custosInternalGatewayId))
         return false;
     }
 
@@ -1300,9 +1300,9 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
   public int hashCode() {
     int hashCode = 1;
 
-    hashCode = hashCode * 8191 + ((isSetAiravataInternalGatewayId()) ? 131071 : 524287);
-    if (isSetAiravataInternalGatewayId())
-      hashCode = hashCode * 8191 + airavataInternalGatewayId.hashCode();
+    hashCode = hashCode * 8191 + ((isSetCustosInternalGatewayId()) ? 131071 : 524287);
+    if (isSetCustosInternalGatewayId())
+      hashCode = hashCode * 8191 + custosInternalGatewayId.hashCode();
 
     hashCode = hashCode * 8191 + ((isSetGatewayId()) ? 131071 : 524287);
     if (isSetGatewayId())
@@ -1391,12 +1391,12 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
 
     int lastComparison = 0;
 
-    lastComparison = Boolean.valueOf(isSetAiravataInternalGatewayId()).compareTo(other.isSetAiravataInternalGatewayId());
+    lastComparison = Boolean.valueOf(isSetCustosInternalGatewayId()).compareTo(other.isSetCustosInternalGatewayId());
     if (lastComparison != 0) {
       return lastComparison;
     }
-    if (isSetAiravataInternalGatewayId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.airavataInternalGatewayId, other.airavataInternalGatewayId);
+    if (isSetCustosInternalGatewayId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.custosInternalGatewayId, other.custosInternalGatewayId);
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -1611,12 +1611,12 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
     StringBuilder sb = new StringBuilder("Gateway(");
     boolean first = true;
 
-    if (isSetAiravataInternalGatewayId()) {
-      sb.append("airavataInternalGatewayId:");
-      if (this.airavataInternalGatewayId == null) {
+    if (isSetCustosInternalGatewayId()) {
+      sb.append("custosInternalGatewayId:");
+      if (this.custosInternalGatewayId == null) {
         sb.append("null");
       } else {
-        sb.append(this.airavataInternalGatewayId);
+        sb.append(this.custosInternalGatewayId);
       }
       first = false;
     }
@@ -1855,10 +1855,10 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
           break;
         }
         switch (schemeField.id) {
-          case 1: // AIRAVATA_INTERNAL_GATEWAY_ID
+          case 1: // CUSTOS_INTERNAL_GATEWAY_ID
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.airavataInternalGatewayId = iprot.readString();
-              struct.setAiravataInternalGatewayIdIsSet(true);
+              struct.custosInternalGatewayId = iprot.readString();
+              struct.setCustosInternalGatewayIdIsSet(true);
             } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
@@ -1873,7 +1873,7 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
             break;
           case 3: // GATEWAY_APPROVAL_STATUS
             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
-              struct.gatewayApprovalStatus = org.apache.airavata.model.workspace.GatewayApprovalStatus.findByValue(iprot.readI32());
+              struct.gatewayApprovalStatus = org.apache.custos.profile.model.workspace.GatewayApprovalStatus.findByValue(iprot.readI32());
               struct.setGatewayApprovalStatusIsSet(true);
             } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
@@ -2028,10 +2028,10 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
       struct.validate();
 
       oprot.writeStructBegin(STRUCT_DESC);
-      if (struct.airavataInternalGatewayId != null) {
-        if (struct.isSetAiravataInternalGatewayId()) {
-          oprot.writeFieldBegin(AIRAVATA_INTERNAL_GATEWAY_ID_FIELD_DESC);
-          oprot.writeString(struct.airavataInternalGatewayId);
+      if (struct.custosInternalGatewayId != null) {
+        if (struct.isSetCustosInternalGatewayId()) {
+          oprot.writeFieldBegin(CUSTOS_INTERNAL_GATEWAY_ID_FIELD_DESC);
+          oprot.writeString(struct.custosInternalGatewayId);
           oprot.writeFieldEnd();
         }
       }
@@ -2182,7 +2182,7 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
       oprot.writeString(struct.gatewayId);
       oprot.writeI32(struct.gatewayApprovalStatus.getValue());
       java.util.BitSet optionals = new java.util.BitSet();
-      if (struct.isSetAiravataInternalGatewayId()) {
+      if (struct.isSetCustosInternalGatewayId()) {
         optionals.set(0);
       }
       if (struct.isSetGatewayName()) {
@@ -2237,8 +2237,8 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
         optionals.set(17);
       }
       oprot.writeBitSet(optionals, 18);
-      if (struct.isSetAiravataInternalGatewayId()) {
-        oprot.writeString(struct.airavataInternalGatewayId);
+      if (struct.isSetCustosInternalGatewayId()) {
+        oprot.writeString(struct.custosInternalGatewayId);
       }
       if (struct.isSetGatewayName()) {
         oprot.writeString(struct.gatewayName);
@@ -2298,12 +2298,12 @@ public class Gateway implements org.apache.thrift.TBase<Gateway, Gateway._Fields
       org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
       struct.gatewayId = iprot.readString();
       struct.setGatewayIdIsSet(true);
-      struct.gatewayApprovalStatus = org.apache.airavata.model.workspace.GatewayApprovalStatus.findByValue(iprot.readI32());
+      struct.gatewayApprovalStatus = org.apache.custos.profile.model.workspace.GatewayApprovalStatus.findByValue(iprot.readI32());
       struct.setGatewayApprovalStatusIsSet(true);
       java.util.BitSet incoming = iprot.readBitSet(18);
       if (incoming.get(0)) {
-        struct.airavataInternalGatewayId = iprot.readString();
-        struct.setAiravataInternalGatewayIdIsSet(true);
+        struct.custosInternalGatewayId = iprot.readString();
+        struct.setCustosInternalGatewayIdIsSet(true);
       }
       if (incoming.get(1)) {
         struct.gatewayName = iprot.readString();
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/workspace/GatewayApprovalStatus.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/workspace/GatewayApprovalStatus.java
similarity index 97%
rename from custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/workspace/GatewayApprovalStatus.java
rename to custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/workspace/GatewayApprovalStatus.java
index c0e01c3..655d921 100644
--- a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/workspace/GatewayApprovalStatus.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/workspace/GatewayApprovalStatus.java
@@ -21,7 +21,7 @@
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.profile.models.workspace;
+package org.apache.custos.profile.model.workspace;
 
 
 import org.apache.thrift.TEnum;
diff --git a/custos-services/profile-service/profile-service-server/pom.xml b/custos-profile-service/profile-service-server/pom.xml
similarity index 87%
rename from custos-services/profile-service/profile-service-server/pom.xml
rename to custos-profile-service/profile-service-server/pom.xml
index 885b851..0de9d74 100644
--- a/custos-services/profile-service/profile-service-server/pom.xml
+++ b/custos-profile-service/profile-service-server/pom.xml
@@ -20,15 +20,13 @@
     <artifactId>profile-service-server</artifactId>
     <name>Custos Profile Service Server</name>
     <description>Module to expose a profile service as a thrift service</description>
-
+    <properties>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+    </properties>
     <dependencies>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>profile-service-stubs</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
             <artifactId>profile-user-core</artifactId>
             <version>${project.version}</version>
         </dependency>
@@ -44,9 +42,8 @@
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>custos-security-service</artifactId>
+            <artifactId>custos-connectors</artifactId>
             <version>${project.version}</version>
-            <scope>compile</scope>
         </dependency>
     </dependencies>
     
diff --git a/custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/handlers/IamAdminServicesHandler.java b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/IamAdminServicesHandler.java
similarity index 92%
rename from custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/handlers/IamAdminServicesHandler.java
rename to custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/IamAdminServicesHandler.java
index a95fda2..0e10bd0 100644
--- a/custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/handlers/IamAdminServicesHandler.java
+++ b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/IamAdminServicesHandler.java
@@ -19,20 +19,21 @@
  *
  */
 
-package org.apache.custos.service.profile.handlers;
+package org.apache.custos.profile.handlers;
 
 import org.apache.custos.commons.exceptions.ApplicationSettingsException;
 import org.apache.custos.commons.model.error.AuthorizationException;
+import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.profile.models.tenant.PasswordCredential;
-import org.apache.custos.profile.models.user.UserProfile;
-import org.apache.custos.profile.models.workspace.Gateway;
-import org.apache.custos.security.model.AuthzToken;
-import org.apache.custos.service.profile.iam.admin.services.cpi.IamAdminServices;
-import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
-import org.apache.custos.service.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants;
-import org.apache.custos.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl;
+import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.model.tenant.PasswordCredential;
+import org.apache.custos.profile.model.user.UserProfile;
+import org.apache.custos.profile.model.workspace.Gateway;
+import org.apache.custos.security.interceptor.SecurityCheck;
+import org.apache.custos.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants;
+import org.apache.custos.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,7 +51,8 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
+    //TODO: check if tenantAdminPasswordCredential is required
     public Gateway setUpGateway(AuthzToken authzToken, Gateway gateway, PasswordCredential tenantAdminPasswordCredential) throws IamAdminServicesException, AuthorizationException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         PasswordCredential isSuperAdminCredentials = getSuperAdminPasswordCredential();
@@ -75,7 +77,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public boolean isUsernameAvailable(AuthzToken authzToken, String username) throws IamAdminServicesException, AuthorizationException, TException {
         TenantManagementKeycloakImpl keycloakClient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -84,7 +86,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
 
     //ToDo: Will only be secure when using SSL between PGA and Airavata
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public boolean registerUser(AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword) throws IamAdminServicesException, AuthorizationException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -101,7 +103,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public boolean enableUser(AuthzToken authzToken, String username) throws IamAdminServicesException, AuthorizationException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -118,7 +120,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public boolean isUserEnabled(AuthzToken authzToken, String username) throws IamAdminServicesException, AuthorizationException, TException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -132,7 +134,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public boolean isUserExist(AuthzToken authzToken, String username) throws IamAdminServicesException, AuthorizationException, TException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -146,7 +148,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public UserProfile getUser(AuthzToken authzToken, String username) throws IamAdminServicesException, AuthorizationException, TException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -161,7 +163,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
 
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public List<UserProfile> getUsers(AuthzToken authzToken, int offset, int limit, String search)
             throws IamAdminServicesException, AuthorizationException, TException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
@@ -176,7 +178,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public boolean resetUserPassword(AuthzToken authzToken, String username, String newPassword) throws IamAdminServicesException, AuthorizationException, TException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -193,7 +195,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public List<UserProfile> findUsers(AuthzToken authzToken, String email, String userId) throws IamAdminServicesException, AuthorizationException, TException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -207,7 +209,7 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public void updateUserProfile(AuthzToken authzToken, UserProfile userDetails) throws IamAdminServicesException, AuthorizationException, TException {
 
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
@@ -218,8 +220,9 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     @Deprecated
+    //TODO: check if isRealmAdminCredentials required or not
     public boolean addRoleToUser(AuthzToken authzToken, String username, String roleName, PasswordCredential isRealmAdminCredentials) throws IamAdminServicesException, AuthorizationException, TException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -234,8 +237,9 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     @Deprecated
+    //TODO:// check if isRealmAdminCredentials required or not
     public boolean removeRoleFromUser(AuthzToken authzToken, String username, String roleName, PasswordCredential isRealmAdminCredentials) throws IamAdminServicesException, AuthorizationException, TException {
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
@@ -250,8 +254,9 @@ public class IamAdminServicesHandler implements IamAdminServices.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     @Deprecated
+    //TODO: check if PasswordCredential required
     public List<UserProfile> getUsersWithRole(AuthzToken authzToken, String roleName, PasswordCredential isRealmAdminCredentials) throws IamAdminServicesException, AuthorizationException, TException {
 
         TenantManagementKeycloakImpl keycloakclient = new TenantManagementKeycloakImpl();
diff --git a/custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/handlers/TenantProfileServiceHandler.java b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/TenantProfileServiceHandler.java
similarity index 83%
rename from custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/handlers/TenantProfileServiceHandler.java
rename to custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/TenantProfileServiceHandler.java
index 35a6906..587095d 100644
--- a/custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/handlers/TenantProfileServiceHandler.java
+++ b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/TenantProfileServiceHandler.java
@@ -18,17 +18,18 @@
  * under the License.
  *
 */
-package org.apache.custos.service.profile.handlers;
+package org.apache.custos.profile.handlers;
 
 import org.apache.custos.commons.model.error.AuthorizationException;
-import org.apache.custos.profile.models.workspace.Gateway;
-import org.apache.custos.profile.models.workspace.GatewayApprovalStatus;
-import org.apache.custos.security.model.AuthzToken;
-import org.apache.custos.service.profile.commons.tenant.entities.GatewayEntity;
-import org.apache.custos.service.profile.tenant.core.repositories.TenantProfileRepository;
-import org.apache.custos.service.profile.tenant.cpi.TenantProfileService;
-import org.apache.custos.service.profile.tenant.cpi.exception.TenantProfileServiceException;
-import org.apache.custos.service.profile.tenant.cpi.profile_tenant_cpiConstants;
+import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.profile.model.workspace.Gateway;
+import org.apache.custos.profile.model.workspace.GatewayApprovalStatus;
+import org.apache.custos.profile.tenant.cpi.TenantProfileService;
+import org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException;
+import org.apache.custos.profile.tenant.cpi.profile_tenant_cpiConstants;
+import org.apache.custos.security.interceptor.SecurityCheck;
+import org.apache.custos.profile.commons.tenant.entities.GatewayEntity;
+import org.apache.custos.profile.tenant.core.repositories.TenantProfileRepository;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -61,7 +62,7 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
     public Gateway addGateway(AuthzToken authzToken, Gateway gateway) throws TenantProfileServiceException, AuthorizationException, TException {
         try {
             // Assign UUID to gateway
-            gateway.setAiravataInternalGatewayId(UUID.randomUUID().toString());
+            gateway.setCustosInternalGatewayId(UUID.randomUUID().toString());
             if (!checkDuplicateGateway(gateway)) {
                 // If admin password, copy it in the credential store under the requested gateway's gatewayId
 //                if (gateway.getIdentityServerPasswordToken() != null) {
@@ -69,13 +70,16 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
 //                }
                 gateway = tenantProfileRepository.create(gateway);
                 if (gateway != null) {
-                    logger.info("Added Airavata Gateway with Id: " + gateway.getGatewayId());
+                    logger.info("Added Custos Gateway with Id: " + gateway.getGatewayId());
                     // replicate tenant at end-places only if status is APPROVED
                     if (gateway.getGatewayApprovalStatus().equals(GatewayApprovalStatus.APPROVED)) {
                         logger.info("Gateway with ID: {}, is now APPROVED, replicating to subscribers.", gateway.getGatewayId());
                         return gateway;
                         //dbEventPublisherUtils.publish(EntityType.TENANT, CrudType.CREATE, gateway);
                     }
+                    else {
+                        throw new Exception("Gateway status is not approved");
+                    }
 //                    // return internal id
 //                    return gateway.getAiravataInternalGatewayId();
                 } else {
@@ -112,12 +116,13 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
 //                dbEventPublisherUtils.publish(EntityType.TENANT, CrudType.UPDATE, updatedGateway);
                 return updatedGateway;
             } else {
-                new TException("Could not update the gateway");
+                throw new TException("Could not update the gateway");
             }
         } catch (Exception ex) {
             logger.error("Error updating gateway-profile, reason: " + ex.getMessage(), ex);
             TenantProfileServiceException exception = new TenantProfileServiceException();
             exception.setMessage("Error updating gateway-profile, reason: " + ex.getMessage());
+            throw exception;
         }
     }
 
@@ -138,12 +143,30 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
         }
     }
 
+    //TODO: check why this was not included, add authToken
+    @Override
+    @SecurityCheck
+    public Gateway getGatewayUsingGatewayId(String gatewayId) throws TenantProfileServiceException, AuthorizationException, TException {
+        try {
+            Gateway gateway = tenantProfileRepository.getGatewayUsingId(gatewayId);
+            if (gateway == null) {
+                throw new Exception("Could not find Gateway with ID: " + gatewayId);
+            }
+            return gateway;
+        } catch (Exception ex) {
+            logger.error("Error getting gateway-profile, reason: " + ex.getMessage(), ex);
+            TenantProfileServiceException exception = new TenantProfileServiceException();
+            exception.setMessage("Error getting gateway-profile, reason: " + ex.getMessage());
+            throw exception;
+        }
+    }
+
     @Override
     @SecurityCheck
-    public Gateway deleteGateway(AuthzToken authzToken, String airavataInternalGatewayId, String gatewayId) throws TenantProfileServiceException, AuthorizationException, TException {
+    public Gateway deleteGateway(AuthzToken authzToken, String custosInternalGatewayId, String gatewayId) throws TenantProfileServiceException, AuthorizationException, TException {
         try {
-            logger.debug("Deleting Airavata gateway-profile with ID: " + gatewayId + "Internal ID: " + airavataInternalGatewayId);
-            boolean deleteSuccess = tenantProfileRepository.delete(airavataInternalGatewayId);
+            logger.debug("Deleting Custos gateway-profile with ID: " + gatewayId + "Internal ID: " + custosInternalGatewayId);
+            boolean deleteSuccess = tenantProfileRepository.delete(custosInternalGatewayId);
             if (deleteSuccess) {
                 // delete tenant at end-places
 //                dbEventPublisherUtils.publish(EntityType.TENANT, CrudType.DELETE,
@@ -152,6 +175,9 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
 //                        new Gateway(gatewayId, GatewayApprovalStatus.DEACTIVATED));
                 return new Gateway(gatewayId, GatewayApprovalStatus.DEACTIVATED);
             }
+            else {
+                throw new Exception("Deleting gateway failed");
+            }
         } catch (Exception ex) {
             logger.error("Error deleting gateway-profile, reason: " + ex.getMessage(), ex);
             TenantProfileServiceException exception = new TenantProfileServiceException();
diff --git a/custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/handlers/UserProfileServiceHandler.java b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/UserProfileServiceHandler.java
similarity index 87%
rename from custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/handlers/UserProfileServiceHandler.java
rename to custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/UserProfileServiceHandler.java
index 74ccf62..1068863 100644
--- a/custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/handlers/UserProfileServiceHandler.java
+++ b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/UserProfileServiceHandler.java
@@ -18,28 +18,29 @@
  * under the License.
  *
 */
-package org.apache.custos.service.profile.handlers;
+package org.apache.custos.profile.handlers;
 
 
+import org.apache.custos.client.profile.service.ProfileServiceClientFactory;
 import org.apache.custos.commons.exceptions.ApplicationSettingsException;
 import org.apache.custos.commons.exceptions.CustosSecurityException;
 import org.apache.custos.commons.model.error.AuthorizationException;
+import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.CustosUtils;
 import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.profile.models.user.Status;
-import org.apache.custos.profile.models.user.UserProfile;
-import org.apache.custos.profile.models.user.user_profile_modelConstants;
+import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.model.user.Status;
+import org.apache.custos.profile.model.user.UserProfile;
+import org.apache.custos.profile.model.user.user_profile_modelConstants;
+import org.apache.custos.profile.user.core.repositories.UserProfileRepository;
+import org.apache.custos.profile.user.cpi.UserProfileService;
+import org.apache.custos.profile.user.cpi.exception.UserProfileServiceException;
+import org.apache.custos.security.interceptor.SecurityCheck;
 import org.apache.custos.security.manager.CustosSecurityManager;
 import org.apache.custos.security.manager.SecurityManagerFactory;
 import org.apache.custos.security.manager.UserInfo;
-import org.apache.custos.security.model.AuthzToken;
-import org.apache.custos.service.profile.client.ProfileServiceClientFactory;
-import org.apache.custos.service.profile.iam.admin.services.cpi.IamAdminServices;
-import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
-import org.apache.custos.service.profile.user.core.repositories.UserProfileRepository;
-import org.apache.custos.service.profile.user.cpi.UserProfileService;
-import org.apache.custos.service.profile.user.cpi.exception.UserProfileServiceException;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -60,17 +61,17 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    public String getAPIVersion() throws UserProfileServiceException, TException {
+    public String getAPIVersion() {
         return user_profile_modelConstants.USER_PROFILE_VERSION;
     }
 
     @Override
-    //@SecurityCheck
-    public UserProfile initializeUserProfile(AuthzToken authzToken, String identityServerRealm) throws UserProfileServiceException, AuthorizationException, TException {
+    @SecurityCheck
+    public UserProfile initializeUserProfile(AuthzToken authzToken) throws UserProfileServiceException, AuthorizationException {
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
         try {
             // Load UserInfo for the access token and create an initial UserProfile from it
-            UserInfo userInfo = SecurityManagerFactory.getSecurityManager().getUserInfoFromAuthzToken(authzToken, identityServerRealm);
+            UserInfo userInfo = SecurityManagerFactory.getSecurityManager().getUserInfoFromAuthzToken(authzToken);
             final UserProfile existingProfile = userProfileRepository.getUserProfileByIdAndGateWay(userInfo.getUsername(), gatewayId);
             // If a user profile already exists, just return the userId
             if (existingProfile != null) {
@@ -79,7 +80,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
             UserProfile userProfile = new UserProfile();
             userProfile.setUserId(userInfo.getUsername().toLowerCase());
             userProfile.setGatewayId(gatewayId);
-            userProfile.setAiravataInternalUserId(userProfile.getUserId() + "@" + gatewayId);
+            userProfile.setCustosInternalUserId(userProfile.getUserId() + "@" + gatewayId);
             userProfile.addToEmails(userInfo.getEmailAddress());
             userProfile.setFirstName(userInfo.getFirstName());
             userProfile.setLastName(userInfo.getLastName());
@@ -103,12 +104,12 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    //@SecurityCheck
-    public UserProfile addUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException, AuthorizationException, TException {
+    @SecurityCheck
+    public UserProfile addUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException, AuthorizationException {
         try{
             // Lowercase user id and internal id
             userProfile.setUserId(userProfile.getUserId().toLowerCase());
-            userProfile.setAiravataInternalUserId(userProfile.getUserId() + "@" + userProfile.getGatewayId());
+            userProfile.setCustosInternalUserId(userProfile.getUserId() + "@" + userProfile.getGatewayId());
             userProfile = userProfileRepository.updateUserProfile(userProfile, getIAMUserProfileUpdater(authzToken, userProfile));
             if (null != userProfile) {
                 logger.info("Added UserProfile with userId: " + userProfile.getUserId());
@@ -125,8 +126,8 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    //@SecurityCheck
-    public UserProfile updateUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException, AuthorizationException, TException {
+    @SecurityCheck
+    public UserProfile updateUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException, AuthorizationException {
         try {
             // After updating the user profile in the database but before committing the transaction, the
             // following will update the user profile in the IAM service also. If the update in the IAM service
@@ -142,6 +143,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
             exception.setMessage("Error while Updating user profile. More info : " + e.getMessage());
             throw exception;
         }
+        throw new UserProfileServiceException("User update failed. Please try again.");
     }
 
     private Runnable getIAMUserProfileUpdater(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException {
@@ -176,7 +178,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    //@SecurityCheck
+    @SecurityCheck
     public UserProfile deleteUserProfile(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException, AuthorizationException, TException {
         UserProfile userProfile = null;
         try{
@@ -196,8 +198,8 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    //@SecurityCheck
-    public List<UserProfile> getAllUserProfilesInGateway(AuthzToken authzToken, String gatewayId, int offset, int limit) throws UserProfileServiceException, AuthorizationException, TException {
+    @SecurityCheck
+    public List<UserProfile> getAllUserProfilesInGateway(AuthzToken authzToken, String gatewayId, int offset, int limit) throws UserProfileServiceException, AuthorizationException {
         try{
             List<UserProfile> usersInGateway = userProfileRepository.getAllUserProfilesInGateway(gatewayId, offset, limit);
             if(usersInGateway != null)
@@ -213,7 +215,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    public boolean doesUserExist(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException, AuthorizationException, TException {
+    public boolean doesUserExist(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException, AuthorizationException {
         try{
             UserProfile userProfile = userProfileRepository.getUserProfileByIdAndGateWay(userId, gatewayId);
             return null != userProfile;
diff --git a/custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/server/ProfileServiceServer.java b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/server/ProfileServiceServer.java
similarity index 79%
rename from custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/server/ProfileServiceServer.java
rename to custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/server/ProfileServiceServer.java
index a70a527..cb1923e 100644
--- a/custos-services/profile-service/profile-service-server/src/main/java/org/apache/custos/service/profile/server/ProfileServiceServer.java
+++ b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/server/ProfileServiceServer.java
@@ -19,25 +19,22 @@
  *
 */
 
-package org.apache.custos.service.profile.server;
-
-import org.apache.airavata.common.utils.DBInitConfig;
-import org.apache.airavata.common.utils.DBInitializer;
-import org.apache.airavata.common.utils.IServer;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.custos.service.profile.groupmanager.cpi.GroupManagerService;
-import org.apache.custos.service.profile.groupmanager.cpi.group_manager_cpiConstants;
-import org.apache.custos.service.profile.handlers.IamAdminServicesHandler;
-import org.apache.custos.service.profile.iam.admin.services.cpi.IamAdminServices;
-import org.apache.custos.service.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants;
-import org.apache.custos.service.profile.tenant.cpi.TenantProfileService;
-import org.apache.custos.service.profile.tenant.cpi.profile_tenant_cpiConstants;
-import org.apache.custos.service.profile.user.core.utils.UserProfileCatalogDBInitConfig;
-import org.apache.custos.service.profile.user.cpi.UserProfileService;
-import org.apache.custos.service.profile.user.cpi.profile_user_cpiConstants;
-import org.apache.custos.service.profile.handlers.GroupManagerServiceHandler;
-import org.apache.custos.service.profile.handlers.TenantProfileServiceHandler;
-import org.apache.custos.service.profile.handlers.UserProfileServiceHandler;
+package org.apache.custos.profile.server;
+
+import org.apache.custos.commons.utils.DBInitConfig;
+import org.apache.custos.commons.utils.DBInitializer;
+import org.apache.custos.commons.utils.IServer;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.profile.handlers.IamAdminServicesHandler;
+import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
+import org.apache.custos.profile.tenant.cpi.TenantProfileService;
+import org.apache.custos.profile.tenant.cpi.profile_tenant_cpiConstants;
+import org.apache.custos.profile.user.core.utils.UserProfileCatalogDBInitConfig;
+import org.apache.custos.profile.user.cpi.UserProfileService;
+import org.apache.custos.profile.user.cpi.profile_user_cpiConstants;
+import org.apache.custos.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants;
+import org.apache.custos.profile.handlers.TenantProfileServiceHandler;
+import org.apache.custos.profile.handlers.UserProfileServiceHandler;
 import org.apache.thrift.TMultiplexedProcessor;
 import org.apache.thrift.server.TServer;
 import org.apache.thrift.server.TThreadPoolServer;
@@ -106,14 +103,14 @@ public class ProfileServiceServer implements IServer {
             UserProfileService.Processor userProfileProcessor = new UserProfileService.Processor(new UserProfileServiceHandler());
             TenantProfileService.Processor teneantProfileProcessor = new TenantProfileService.Processor(new TenantProfileServiceHandler());
             IamAdminServices.Processor iamAdminServicesProcessor = new IamAdminServices.Processor(new IamAdminServicesHandler());
-            GroupManagerService.Processor groupmanagerProcessor = new GroupManagerService.Processor(new GroupManagerServiceHandler());
+            //GroupManagerService.Processor groupmanagerProcessor = new GroupManagerService.Processor(new GroupManagerServiceHandler());
 
             // create a multiplexed processor
             TMultiplexedProcessor profileServiceProcessor = new TMultiplexedProcessor();
             profileServiceProcessor.registerProcessor(profile_user_cpiConstants.USER_PROFILE_CPI_NAME, userProfileProcessor);
             profileServiceProcessor.registerProcessor(profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME, teneantProfileProcessor);
             profileServiceProcessor.registerProcessor(iam_admin_services_cpiConstants.IAM_ADMIN_SERVICES_CPI_NAME, iamAdminServicesProcessor);
-            profileServiceProcessor.registerProcessor(group_manager_cpiConstants.GROUP_MANAGER_CPI_NAME, groupmanagerProcessor);
+            //profileServiceProcessor.registerProcessor(group_manager_cpiConstants.GROUP_MANAGER_CPI_NAME, groupmanagerProcessor);
 
             TServerTransport serverTransport;
 
diff --git a/custos-commons/pom.xml b/custos-profile-service/profile-service-stubs/pom.xml
similarity index 53%
copy from custos-commons/pom.xml
copy to custos-profile-service/profile-service-stubs/pom.xml
index a1a9e93..47aeafc 100644
--- a/custos-commons/pom.xml
+++ b/custos-profile-service/profile-service-stubs/pom.xml
@@ -2,28 +2,33 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
     <parent>
-        <artifactId>custos</artifactId>
+        <artifactId>profile-service</artifactId>
         <groupId>org.apache.custos</groupId>
         <version>1.0-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
     </parent>
-    
-    <groupId>org.apache.custos</groupId>
-    <artifactId>custos-commons</artifactId>
-    <version>${parent.version}</version>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>profile-service-stubs</artifactId>
     <dependencies>
         <dependency>
             <groupId>org.apache.thrift</groupId>
             <artifactId>libthrift</artifactId>
-            <version>${thrift.version}</version>
+            <version>0.12.0</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa</artifactId>
-            <version>${openjpa.version}</version>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>profile-service-models</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-commons</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
         </dependency>
     </dependencies>
 
+
 </project>
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-stubs/src/main/java/org/apache/custos/service/profile/iam/admin/services/cpi/IamAdminServices.java b/custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/iam.admin.services.cpi/IamAdminServices.java
similarity index 76%
rename from custos-services/profile-service/profile-service-stubs/src/main/java/org/apache/custos/service/profile/iam/admin/services/cpi/IamAdminServices.java
rename to custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/iam.admin.services.cpi/IamAdminServices.java
index 05c7ce5..c0327a7 100644
--- a/custos-services/profile-service/profile-service-stubs/src/main/java/org/apache/custos/service/profile/iam/admin/services/cpi/IamAdminServices.java
+++ b/custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/iam.admin.services.cpi/IamAdminServices.java
@@ -1,98 +1,80 @@
-    /*
-     * 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.10.0)
+ * Autogenerated by Thrift Compiler (0.12.0)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
  */
-package org.apache.custos.service.profile.iam.admin.services.cpi;
-
-    import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+package org.apache.custos.profile.iam.admin.services.cpi;
 
-    @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-06-24")
 public class IamAdminServices {
 
   public interface Iface {
 
-    public java.lang.String getAPIVersion() throws IamAdminServicesException, org.apache.thrift.TException;
+    public String getAPIVersion() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
 
-    public org.apache.airavata.model.workspace.Gateway setUpGateway(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.workspace.Gateway gateway) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public org.apache.custos.profile.model.workspace.Gateway setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public boolean isUsernameAvailable(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public boolean isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public boolean registerUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String emailAddress, java.lang.String firstName, java.lang.String lastName, java.lang.String newPassword) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public boolean registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public boolean enableUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public boolean enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public boolean isUserEnabled(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public boolean isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public boolean isUserExist(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public boolean isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public org.apache.airavata.model.user.UserProfile getUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public org.apache.custos.profile.model.user.UserProfile getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public java.util.List<org.apache.airavata.model.user.UserProfile> getUsers(org.apache.airavata.model.security.AuthzToken authzToken, int offset, int limit, java.lang.String search) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public boolean resetUserPassword(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String newPassword) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public boolean resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public java.util.List<org.apache.airavata.model.user.UserProfile> findUsers(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String email, java.lang.String userId) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public void updateUserProfile(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.user.UserProfile userDetails) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public boolean addRoleToUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public boolean addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public boolean removeRoleFromUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public boolean removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public java.util.List<org.apache.airavata.model.user.UserProfile> getUsersWithRole(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String roleName) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException;
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
   }
 
   public interface AsyncIface {
 
-    public void getAPIVersion(org.apache.thrift.async.AsyncMethodCallback<java.lang.String> resultHandler) throws org.apache.thrift.TException;
+    public void getAPIVersion(org.apache.thrift.async.AsyncMethodCallback<String> resultHandler) throws org.apache.thrift.TException;
 
-    public void setUpGateway(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.workspace.Gateway gateway, org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
+    public void setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
 
-    public void isUsernameAvailable(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException;
+    public void isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
-    public void registerUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String emailAddress, java.lang.String firstName, java.lang.String lastName, java.lang.String newPassword, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException;
+    public void registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
-    public void enableUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException;
+    public void enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
-    public void isUserEnabled(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException;
+    public void isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
-    public void isUserExist(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException;
+    public void isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
-    public void getUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
+    public void getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
 
-    public void getUsers(org.apache.airavata.model.security.AuthzToken authzToken, int offset, int limit, java.lang.String search, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException;
+    public void getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException;
 
-    public void resetUserPassword(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String newPassword, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException;
+    public void resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
-    public void findUsers(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String email, java.lang.String userId, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException;
+    public void findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException;
 
-    public void updateUserProfile(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.user.UserProfile userDetails, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException;
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException;
 
-    public void addRoleToUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException;
+    public void addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
-    public void removeRoleFromUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException;
+    public void removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
 
-    public void getUsersWithRole(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String roleName, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException;
+    public void getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException;
 
   }
 
@@ -116,7 +98,7 @@ public class IamAdminServices {
       super(iprot, oprot);
     }
 
-    public java.lang.String getAPIVersion() throws IamAdminServicesException, org.apache.thrift.TException
+    public String getAPIVersion() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
     {
       send_getAPIVersion();
       return recv_getAPIVersion();
@@ -128,7 +110,7 @@ public class IamAdminServices {
       sendBase("getAPIVersion", args);
     }
 
-    public java.lang.String recv_getAPIVersion() throws IamAdminServicesException, org.apache.thrift.TException
+    public String recv_getAPIVersion() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
     {
       getAPIVersion_result result = new getAPIVersion_result();
       receiveBase(result, "getAPIVersion");
@@ -141,21 +123,22 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getAPIVersion failed: unknown result");
     }
 
-    public org.apache.airavata.model.workspace.Gateway setUpGateway(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.workspace.Gateway gateway) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public org.apache.custos.profile.model.workspace.Gateway setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
-      send_setUpGateway(authzToken, gateway);
+      send_setUpGateway(authzToken, gateway, tenantAdminPasswordCredential);
       return recv_setUpGateway();
     }
 
-    public void send_setUpGateway(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.workspace.Gateway gateway) throws org.apache.thrift.TException
+    public void send_setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.thrift.TException
     {
       setUpGateway_args args = new setUpGateway_args();
       args.setAuthzToken(authzToken);
       args.setGateway(gateway);
+      args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
       sendBase("setUpGateway", args);
     }
 
-    public org.apache.airavata.model.workspace.Gateway recv_setUpGateway() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public org.apache.custos.profile.model.workspace.Gateway recv_setUpGateway() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       setUpGateway_result result = new setUpGateway_result();
       receiveBase(result, "setUpGateway");
@@ -171,13 +154,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "setUpGateway failed: unknown result");
     }
 
-    public boolean isUsernameAvailable(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_isUsernameAvailable(authzToken, username);
       return recv_isUsernameAvailable();
     }
 
-    public void send_isUsernameAvailable(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws org.apache.thrift.TException
+    public void send_isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
     {
       isUsernameAvailable_args args = new isUsernameAvailable_args();
       args.setAuthzToken(authzToken);
@@ -185,7 +168,7 @@ public class IamAdminServices {
       sendBase("isUsernameAvailable", args);
     }
 
-    public boolean recv_isUsernameAvailable() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean recv_isUsernameAvailable() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       isUsernameAvailable_result result = new isUsernameAvailable_result();
       receiveBase(result, "isUsernameAvailable");
@@ -201,13 +184,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isUsernameAvailable failed: unknown result");
     }
 
-    public boolean registerUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String emailAddress, java.lang.String firstName, java.lang.String lastName, java.lang.String newPassword) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_registerUser(authzToken, username, emailAddress, firstName, lastName, newPassword);
       return recv_registerUser();
     }
 
-    public void send_registerUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String emailAddress, java.lang.String firstName, java.lang.String lastName, java.lang.String newPassword) throws org.apache.thrift.TException
+    public void send_registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword) throws org.apache.thrift.TException
     {
       registerUser_args args = new registerUser_args();
       args.setAuthzToken(authzToken);
@@ -219,7 +202,7 @@ public class IamAdminServices {
       sendBase("registerUser", args);
     }
 
-    public boolean recv_registerUser() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean recv_registerUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       registerUser_result result = new registerUser_result();
       receiveBase(result, "registerUser");
@@ -235,13 +218,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "registerUser failed: unknown result");
     }
 
-    public boolean enableUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_enableUser(authzToken, username);
       return recv_enableUser();
     }
 
-    public void send_enableUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws org.apache.thrift.TException
+    public void send_enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
     {
       enableUser_args args = new enableUser_args();
       args.setAuthzToken(authzToken);
@@ -249,7 +232,7 @@ public class IamAdminServices {
       sendBase("enableUser", args);
     }
 
-    public boolean recv_enableUser() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean recv_enableUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       enableUser_result result = new enableUser_result();
       receiveBase(result, "enableUser");
@@ -265,13 +248,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "enableUser failed: unknown result");
     }
 
-    public boolean isUserEnabled(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_isUserEnabled(authzToken, username);
       return recv_isUserEnabled();
     }
 
-    public void send_isUserEnabled(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws org.apache.thrift.TException
+    public void send_isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
     {
       isUserEnabled_args args = new isUserEnabled_args();
       args.setAuthzToken(authzToken);
@@ -279,7 +262,7 @@ public class IamAdminServices {
       sendBase("isUserEnabled", args);
     }
 
-    public boolean recv_isUserEnabled() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean recv_isUserEnabled() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       isUserEnabled_result result = new isUserEnabled_result();
       receiveBase(result, "isUserEnabled");
@@ -295,13 +278,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isUserEnabled failed: unknown result");
     }
 
-    public boolean isUserExist(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_isUserExist(authzToken, username);
       return recv_isUserExist();
     }
 
-    public void send_isUserExist(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws org.apache.thrift.TException
+    public void send_isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
     {
       isUserExist_args args = new isUserExist_args();
       args.setAuthzToken(authzToken);
@@ -309,7 +292,7 @@ public class IamAdminServices {
       sendBase("isUserExist", args);
     }
 
-    public boolean recv_isUserExist() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean recv_isUserExist() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       isUserExist_result result = new isUserExist_result();
       receiveBase(result, "isUserExist");
@@ -325,13 +308,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isUserExist failed: unknown result");
     }
 
-    public org.apache.airavata.model.user.UserProfile getUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public org.apache.custos.profile.model.user.UserProfile getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_getUser(authzToken, username);
       return recv_getUser();
     }
 
-    public void send_getUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username) throws org.apache.thrift.TException
+    public void send_getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
     {
       getUser_args args = new getUser_args();
       args.setAuthzToken(authzToken);
@@ -339,7 +322,7 @@ public class IamAdminServices {
       sendBase("getUser", args);
     }
 
-    public org.apache.airavata.model.user.UserProfile recv_getUser() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public org.apache.custos.profile.model.user.UserProfile recv_getUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       getUser_result result = new getUser_result();
       receiveBase(result, "getUser");
@@ -355,13 +338,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUser failed: unknown result");
     }
 
-    public java.util.List<org.apache.airavata.model.user.UserProfile> getUsers(org.apache.airavata.model.security.AuthzToken authzToken, int offset, int limit, java.lang.String search) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_getUsers(authzToken, offset, limit, search);
       return recv_getUsers();
     }
 
-    public void send_getUsers(org.apache.airavata.model.security.AuthzToken authzToken, int offset, int limit, java.lang.String search) throws org.apache.thrift.TException
+    public void send_getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search) throws org.apache.thrift.TException
     {
       getUsers_args args = new getUsers_args();
       args.setAuthzToken(authzToken);
@@ -371,7 +354,7 @@ public class IamAdminServices {
       sendBase("getUsers", args);
     }
 
-    public java.util.List<org.apache.airavata.model.user.UserProfile> recv_getUsers() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> recv_getUsers() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       getUsers_result result = new getUsers_result();
       receiveBase(result, "getUsers");
@@ -387,13 +370,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUsers failed: unknown result");
     }
 
-    public boolean resetUserPassword(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String newPassword) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_resetUserPassword(authzToken, username, newPassword);
       return recv_resetUserPassword();
     }
 
-    public void send_resetUserPassword(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String newPassword) throws org.apache.thrift.TException
+    public void send_resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword) throws org.apache.thrift.TException
     {
       resetUserPassword_args args = new resetUserPassword_args();
       args.setAuthzToken(authzToken);
@@ -402,7 +385,7 @@ public class IamAdminServices {
       sendBase("resetUserPassword", args);
     }
 
-    public boolean recv_resetUserPassword() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean recv_resetUserPassword() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       resetUserPassword_result result = new resetUserPassword_result();
       receiveBase(result, "resetUserPassword");
@@ -418,13 +401,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "resetUserPassword failed: unknown result");
     }
 
-    public java.util.List<org.apache.airavata.model.user.UserProfile> findUsers(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String email, java.lang.String userId) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_findUsers(authzToken, email, userId);
       return recv_findUsers();
     }
 
-    public void send_findUsers(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String email, java.lang.String userId) throws org.apache.thrift.TException
+    public void send_findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId) throws org.apache.thrift.TException
     {
       findUsers_args args = new findUsers_args();
       args.setAuthzToken(authzToken);
@@ -433,7 +416,7 @@ public class IamAdminServices {
       sendBase("findUsers", args);
     }
 
-    public java.util.List<org.apache.airavata.model.user.UserProfile> recv_findUsers() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> recv_findUsers() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       findUsers_result result = new findUsers_result();
       receiveBase(result, "findUsers");
@@ -449,13 +432,13 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "findUsers failed: unknown result");
     }
 
-    public void updateUserProfile(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.user.UserProfile userDetails) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       send_updateUserProfile(authzToken, userDetails);
       recv_updateUserProfile();
     }
 
-    public void send_updateUserProfile(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.user.UserProfile userDetails) throws org.apache.thrift.TException
+    public void send_updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails) throws org.apache.thrift.TException
     {
       updateUserProfile_args args = new updateUserProfile_args();
       args.setAuthzToken(authzToken);
@@ -463,7 +446,7 @@ public class IamAdminServices {
       sendBase("updateUserProfile", args);
     }
 
-    public void recv_updateUserProfile() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public void recv_updateUserProfile() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       updateUserProfile_result result = new updateUserProfile_result();
       receiveBase(result, "updateUserProfile");
@@ -476,22 +459,23 @@ public class IamAdminServices {
       return;
     }
 
-    public boolean addRoleToUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
-      send_addRoleToUser(authzToken, username, roleName);
+      send_addRoleToUser(authzToken, username, roleName, tenantAdminPasswordCredential);
       return recv_addRoleToUser();
     }
 
-    public void send_addRoleToUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName) throws org.apache.thrift.TException
+    public void send_addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.thrift.TException
     {
       addRoleToUser_args args = new addRoleToUser_args();
       args.setAuthzToken(authzToken);
       args.setUsername(username);
       args.setRoleName(roleName);
+      args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
       sendBase("addRoleToUser", args);
     }
 
-    public boolean recv_addRoleToUser() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean recv_addRoleToUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       addRoleToUser_result result = new addRoleToUser_result();
       receiveBase(result, "addRoleToUser");
@@ -507,22 +491,23 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "addRoleToUser failed: unknown result");
     }
 
-    public boolean removeRoleFromUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
-      send_removeRoleFromUser(authzToken, username, roleName);
+      send_removeRoleFromUser(authzToken, username, roleName, tenantAdminPasswordCredential);
       return recv_removeRoleFromUser();
     }
 
-    public void send_removeRoleFromUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName) throws org.apache.thrift.TException
+    public void send_removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.thrift.TException
     {
       removeRoleFromUser_args args = new removeRoleFromUser_args();
       args.setAuthzToken(authzToken);
       args.setUsername(username);
       args.setRoleName(roleName);
+      args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
       sendBase("removeRoleFromUser", args);
     }
 
-    public boolean recv_removeRoleFromUser() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public boolean recv_removeRoleFromUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       removeRoleFromUser_result result = new removeRoleFromUser_result();
       receiveBase(result, "removeRoleFromUser");
@@ -538,21 +523,22 @@ public class IamAdminServices {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "removeRoleFromUser failed: unknown result");
     }
 
-    public java.util.List<org.apache.airavata.model.user.UserProfile> getUsersWithRole(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String roleName) throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
-      send_getUsersWithRole(authzToken, roleName);
+      send_getUsersWithRole(authzToken, roleName, tenantAdminPasswordCredential);
       return recv_getUsersWithRole();
     }
 
-    public void send_getUsersWithRole(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String roleName) throws org.apache.thrift.TException
+    public void send_getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.thrift.TException
     {
       getUsersWithRole_args args = new getUsersWithRole_args();
       args.setAuthzToken(authzToken);
       args.setRoleName(roleName);
+      args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
       sendBase("getUsersWithRole", args);
     }
 
-    public java.util.List<org.apache.airavata.model.user.UserProfile> recv_getUsersWithRole() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> recv_getUsersWithRole() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
       getUsersWithRole_result result = new getUsersWithRole_result();
       receiveBase(result, "getUsersWithRole");
@@ -586,15 +572,15 @@ public class IamAdminServices {
       super(protocolFactory, clientManager, transport);
     }
 
-    public void getAPIVersion(org.apache.thrift.async.AsyncMethodCallback<java.lang.String> resultHandler) throws org.apache.thrift.TException {
+    public void getAPIVersion(org.apache.thrift.async.AsyncMethodCallback<String> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       getAPIVersion_call method_call = new getAPIVersion_call(resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class getAPIVersion_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.String> {
-      public getAPIVersion_call(org.apache.thrift.async.AsyncMethodCallback<java.lang.String> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class getAPIVersion_call extends org.apache.thrift.async.TAsyncMethodCall<String> {
+      public getAPIVersion_call(org.apache.thrift.async.AsyncMethodCallback<String> 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);
       }
 
@@ -605,9 +591,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public java.lang.String getResult() throws IamAdminServicesException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public String getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -615,20 +601,22 @@ public class IamAdminServices {
       }
     }
 
-    public void setUpGateway(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.workspace.Gateway gateway, org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
+    public void setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      setUpGateway_call method_call = new setUpGateway_call(authzToken, gateway, resultHandler, this, ___protocolFactory, ___transport);
+      setUpGateway_call method_call = new setUpGateway_call(authzToken, gateway, tenantAdminPasswordCredential, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class setUpGateway_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.airavata.model.workspace.Gateway> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private org.apache.airavata.model.workspace.Gateway gateway;
-      public setUpGateway_call(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.workspace.Gateway gateway, org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.workspace.Gateway> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class setUpGateway_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.profile.model.workspace.Gateway> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private org.apache.custos.profile.model.workspace.Gateway gateway;
+      private org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential;
+      public setUpGateway_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonb [...]
         super(client, protocolFactory, transport, resultHandler, false);
         this.authzToken = authzToken;
         this.gateway = gateway;
+        this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -636,13 +624,14 @@ public class IamAdminServices {
         setUpGateway_args args = new setUpGateway_args();
         args.setAuthzToken(authzToken);
         args.setGateway(gateway);
+        args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
         args.write(prot);
         prot.writeMessageEnd();
       }
 
-      public org.apache.airavata.model.workspace.Gateway getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public org.apache.custos.profile.model.workspace.Gateway getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -650,17 +639,17 @@ public class IamAdminServices {
       }
     }
 
-    public void isUsernameAvailable(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+    public void isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       isUsernameAvailable_call method_call = new isUsernameAvailable_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class isUsernameAvailable_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Boolean> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String username;
-      public isUsernameAvailable_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class isUsernameAvailable_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public isUsernameAvailable_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
@@ -675,9 +664,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public java.lang.Boolean getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -685,21 +674,21 @@ public class IamAdminServices {
       }
     }
 
-    public void registerUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String emailAddress, java.lang.String firstName, java.lang.String lastName, java.lang.String newPassword, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+    public void registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       registerUser_call method_call = new registerUser_call(authzToken, username, emailAddress, firstName, lastName, newPassword, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class registerUser_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Boolean> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String username;
-      private java.lang.String emailAddress;
-      private java.lang.String firstName;
-      private java.lang.String lastName;
-      private java.lang.String newPassword;
-      public registerUser_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String emailAddress, java.lang.String firstName, java.lang.String lastName, java.lang.String newPassword, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apac [...]
+    public static class registerUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      private String emailAddress;
+      private String firstName;
+      private String lastName;
+      private String newPassword;
+      public registerUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
@@ -722,9 +711,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public java.lang.Boolean getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -732,17 +721,17 @@ public class IamAdminServices {
       }
     }
 
-    public void enableUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+    public void enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       enableUser_call method_call = new enableUser_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class enableUser_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Boolean> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String username;
-      public enableUser_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class enableUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public enableUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
@@ -757,9 +746,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public java.lang.Boolean getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -767,17 +756,17 @@ public class IamAdminServices {
       }
     }
 
-    public void isUserEnabled(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+    public void isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       isUserEnabled_call method_call = new isUserEnabled_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class isUserEnabled_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Boolean> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String username;
-      public isUserEnabled_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class isUserEnabled_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public isUserEnabled_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
@@ -792,9 +781,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public java.lang.Boolean getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -802,17 +791,17 @@ public class IamAdminServices {
       }
     }
 
-    public void isUserExist(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+    public void isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       isUserExist_call method_call = new isUserExist_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class isUserExist_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Boolean> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String username;
-      public isUserExist_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class isUserExist_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public isUserExist_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
@@ -827,9 +816,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public java.lang.Boolean getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -837,17 +826,17 @@ public class IamAdminServices {
       }
     }
 
-    public void getUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
+    public void getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       getUser_call method_call = new getUser_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class getUser_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.airavata.model.user.UserProfile> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String username;
-      public getUser_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.user.UserProfile> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class getUser_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.profile.model.user.UserProfile> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public getUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> 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.username = username;
@@ -862,9 +851,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public org.apache.airavata.model.user.UserProfile getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public org.apache.custos.profile.model.user.UserProfile getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -872,19 +861,19 @@ public class IamAdminServices {
       }
     }
 
-    public void getUsers(org.apache.airavata.model.security.AuthzToken authzToken, int offset, int limit, java.lang.String search, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+    public void getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       getUsers_call method_call = new getUsers_call(authzToken, offset, limit, search, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class getUsers_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<org.apache.airavata.model.user.UserProfile>> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
+    public static class getUsers_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
       private int offset;
       private int limit;
-      private java.lang.String search;
-      public getUsers_call(org.apache.airavata.model.security.AuthzToken authzToken, int offset, int limit, java.lang.String search, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> 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 String search;
+      public getUsers_call(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> 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.offset = offset;
@@ -903,9 +892,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public java.util.List<org.apache.airavata.model.user.UserProfile> getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public java.util.List<org.apache.custos.profile.model.user.UserProfile> getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -913,18 +902,18 @@ public class IamAdminServices {
       }
     }
 
-    public void resetUserPassword(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String newPassword, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+    public void resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       resetUserPassword_call method_call = new resetUserPassword_call(authzToken, username, newPassword, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class resetUserPassword_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Boolean> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String username;
-      private java.lang.String newPassword;
-      public resetUserPassword_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String newPassword, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class resetUserPassword_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      private String newPassword;
+      public resetUserPassword_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
@@ -941,9 +930,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public java.lang.Boolean getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -951,18 +940,18 @@ public class IamAdminServices {
       }
     }
 
-    public void findUsers(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String email, java.lang.String userId, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+    public void findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       findUsers_call method_call = new findUsers_call(authzToken, email, userId, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class findUsers_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<org.apache.airavata.model.user.UserProfile>> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String email;
-      private java.lang.String userId;
-      public findUsers_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String email, java.lang.String userId, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class findUsers_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String email;
+      private String userId;
+      public findUsers_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> 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.email = email;
@@ -979,9 +968,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public java.util.List<org.apache.airavata.model.user.UserProfile> getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public java.util.List<org.apache.custos.profile.model.user.UserProfile> getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -989,7 +978,7 @@ public class IamAdminServices {
       }
     }
 
-    public void updateUserProfile(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.user.UserProfile userDetails, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException {
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException {
       checkReady();
       updateUserProfile_call method_call = new updateUserProfile_call(authzToken, userDetails, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
@@ -997,9 +986,9 @@ public class IamAdminServices {
     }
 
     public static class updateUserProfile_call extends org.apache.thrift.async.TAsyncMethodCall<Void> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private org.apache.airavata.model.user.UserProfile userDetails;
-      public updateUserProfile_call(org.apache.airavata.model.security.AuthzToken authzToken, org.apache.airavata.model.user.UserProfile userDetails, org.apache.thrift.async.AsyncMethodCallback<Void> 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.custos.commons.model.security.AuthzToken authzToken;
+      private org.apache.custos.profile.model.user.UserProfile userDetails;
+      public updateUserProfile_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails, org.apache.thrift.async.AsyncMethodCallback<Void> 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.userDetails = userDetails;
@@ -1014,9 +1003,9 @@ public class IamAdminServices {
         prot.writeMessageEnd();
       }
 
-      public Void getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public Void getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -1024,22 +1013,24 @@ public class IamAdminServices {
       }
     }
 
-    public void addRoleToUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+    public void addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      addRoleToUser_call method_call = new addRoleToUser_call(authzToken, username, roleName, resultHandler, this, ___protocolFactory, ___transport);
+      addRoleToUser_call method_call = new addRoleToUser_call(authzToken, username, roleName, tenantAdminPasswordCredential, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class addRoleToUser_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Boolean> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String username;
-      private java.lang.String roleName;
-      public addRoleToUser_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class addRoleToUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      private String roleName;
+      private org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential;
+      public addRoleToUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
         this.roleName = roleName;
+        this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -1048,13 +1039,14 @@ public class IamAdminServices {
         args.setAuthzToken(authzToken);
         args.setUsername(username);
         args.setRoleName(roleName);
+        args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
         args.write(prot);
         prot.writeMessageEnd();
       }
 
-      public java.lang.Boolean getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -1062,22 +1054,24 @@ public class IamAdminServices {
       }
     }
 
-    public void removeRoleFromUser(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+    public void removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      removeRoleFromUser_call method_call = new removeRoleFromUser_call(authzToken, username, roleName, resultHandler, this, ___protocolFactory, ___transport);
+      removeRoleFromUser_call method_call = new removeRoleFromUser_call(authzToken, username, roleName, tenantAdminPasswordCredential, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class removeRoleFromUser_call extends org.apache.thrift.async.TAsyncMethodCall<java.lang.Boolean> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String username;
-      private java.lang.String roleName;
-      public removeRoleFromUser_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String username, java.lang.String roleName, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class removeRoleFromUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      private String roleName;
+      private org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential;
+      public removeRoleFromUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
         this.roleName = roleName;
+        this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -1086,13 +1080,14 @@ public class IamAdminServices {
         args.setAuthzToken(authzToken);
         args.setUsername(username);
         args.setRoleName(roleName);
+        args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
         args.write(prot);
         prot.writeMessageEnd();
       }
 
-      public java.lang.Boolean getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -1100,20 +1095,22 @@ public class IamAdminServices {
       }
     }
 
-    public void getUsersWithRole(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String roleName, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+    public void getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      getUsersWithRole_call method_call = new getUsersWithRole_call(authzToken, roleName, resultHandler, this, ___protocolFactory, ___transport);
+      getUsersWithRole_call method_call = new getUsersWithRole_call(authzToken, roleName, tenantAdminPasswordCredential, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
-    public static class getUsersWithRole_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<org.apache.airavata.model.user.UserProfile>> {
-      private org.apache.airavata.model.security.AuthzToken authzToken;
-      private java.lang.String roleName;
-      public getUsersWithRole_call(org.apache.airavata.model.security.AuthzToken authzToken, java.lang.String roleName, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+    public static class getUsersWithRole_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String roleName;
+      private org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential;
+      public getUsersWithRole_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transp [...]
         super(client, protocolFactory, transport, resultHandler, false);
         this.authzToken = authzToken;
         this.roleName = roleName;
+        this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
@@ -1121,13 +1118,14 @@ public class IamAdminServices {
         getUsersWithRole_args args = new getUsersWithRole_args();
         args.setAuthzToken(authzToken);
         args.setRoleName(roleName);
+        args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
         args.write(prot);
         prot.writeMessageEnd();
       }
 
-      public java.util.List<org.apache.airavata.model.user.UserProfile> getResult() throws IamAdminServicesException, org.apache.airavata.model.error.AuthorizationException, org.apache.thrift.TException {
-        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
-          throw new java.lang.IllegalStateException("Method call not finished!");
+      public java.util.List<org.apache.custos.profile.model.user.UserProfile> getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException {
+        if (getState() != 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);
@@ -1140,14 +1138,14 @@ public class IamAdminServices {
   public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
     private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName());
     public Processor(I iface) {
-      super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
+      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
     }
 
-    protected Processor(I iface, java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
+    protected Processor(I iface, java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
       super(iface, getProcessMap(processMap));
     }
 
-    private static <I extends Iface> java.util.Map<java.lang.String,  org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {
+    private static <I extends Iface> java.util.Map<String,  org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {
       processMap.put("getAPIVersion", new getAPIVersion());
       processMap.put("setUpGateway", new setUpGateway());
       processMap.put("isUsernameAvailable", new isUsernameAvailable());
@@ -1179,11 +1177,16 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public getAPIVersion_result getResult(I iface, getAPIVersion_args args) throws org.apache.thrift.TException {
         getAPIVersion_result result = new getAPIVersion_result();
         try {
           result.success = iface.getAPIVersion();
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
         }
         return result;
@@ -1203,13 +1206,18 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public setUpGateway_result getResult(I iface, setUpGateway_args args) throws org.apache.thrift.TException {
         setUpGateway_result result = new setUpGateway_result();
         try {
-          result.success = iface.setUpGateway(args.authzToken, args.gateway);
-        } catch (IamAdminServicesException Idse) {
+          result.success = iface.setUpGateway(args.authzToken, args.gateway, args.tenantAdminPasswordCredential);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1229,14 +1237,19 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public isUsernameAvailable_result getResult(I iface, isUsernameAvailable_args args) throws org.apache.thrift.TException {
         isUsernameAvailable_result result = new isUsernameAvailable_result();
         try {
           result.success = iface.isUsernameAvailable(args.authzToken, args.username);
           result.setSuccessIsSet(true);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1256,14 +1269,19 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public registerUser_result getResult(I iface, registerUser_args args) throws org.apache.thrift.TException {
         registerUser_result result = new registerUser_result();
         try {
           result.success = iface.registerUser(args.authzToken, args.username, args.emailAddress, args.firstName, args.lastName, args.newPassword);
           result.setSuccessIsSet(true);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1283,14 +1301,19 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public enableUser_result getResult(I iface, enableUser_args args) throws org.apache.thrift.TException {
         enableUser_result result = new enableUser_result();
         try {
           result.success = iface.enableUser(args.authzToken, args.username);
           result.setSuccessIsSet(true);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1310,14 +1333,19 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public isUserEnabled_result getResult(I iface, isUserEnabled_args args) throws org.apache.thrift.TException {
         isUserEnabled_result result = new isUserEnabled_result();
         try {
           result.success = iface.isUserEnabled(args.authzToken, args.username);
           result.setSuccessIsSet(true);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1337,14 +1365,19 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public isUserExist_result getResult(I iface, isUserExist_args args) throws org.apache.thrift.TException {
         isUserExist_result result = new isUserExist_result();
         try {
           result.success = iface.isUserExist(args.authzToken, args.username);
           result.setSuccessIsSet(true);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1364,13 +1397,18 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public getUser_result getResult(I iface, getUser_args args) throws org.apache.thrift.TException {
         getUser_result result = new getUser_result();
         try {
           result.success = iface.getUser(args.authzToken, args.username);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1390,13 +1428,18 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public getUsers_result getResult(I iface, getUsers_args args) throws org.apache.thrift.TException {
         getUsers_result result = new getUsers_result();
         try {
           result.success = iface.getUsers(args.authzToken, args.offset, args.limit, args.search);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1416,14 +1459,19 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public resetUserPassword_result getResult(I iface, resetUserPassword_args args) throws org.apache.thrift.TException {
         resetUserPassword_result result = new resetUserPassword_result();
         try {
           result.success = iface.resetUserPassword(args.authzToken, args.username, args.newPassword);
           result.setSuccessIsSet(true);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1443,13 +1491,18 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public findUsers_result getResult(I iface, findUsers_args args) throws org.apache.thrift.TException {
         findUsers_result result = new findUsers_result();
         try {
           result.success = iface.findUsers(args.authzToken, args.email, args.userId);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1469,13 +1522,18 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public updateUserProfile_result getResult(I iface, updateUserProfile_args args) throws org.apache.thrift.TException {
         updateUserProfile_result result = new updateUserProfile_result();
         try {
           iface.updateUserProfile(args.authzToken, args.userDetails);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1495,14 +1553,19 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public addRoleToUser_result getResult(I iface, addRoleToUser_args args) throws org.apache.thrift.TException {
         addRoleToUser_result result = new addRoleToUser_result();
         try {
-          result.success = iface.addRoleToUser(args.authzToken, args.username, args.roleName);
+          result.success = iface.addRoleToUser(args.authzToken, args.username, args.roleName, args.tenantAdminPasswordCredential);
           result.setSuccessIsSet(true);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1522,14 +1585,19 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public removeRoleFromUser_result getResult(I iface, removeRoleFromUser_args args) throws org.apache.thrift.TException {
         removeRoleFromUser_result result = new removeRoleFromUser_result();
         try {
-          result.success = iface.removeRoleFromUser(args.authzToken, args.username, args.roleName);
+          result.success = iface.removeRoleFromUser(args.authzToken, args.username, args.roleName, args.tenantAdminPasswordCredential);
           result.setSuccessIsSet(true);
-        } catch (IamAdminServicesException Idse) {
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1549,13 +1617,18 @@ public class IamAdminServices {
         return false;
       }
 
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
       public getUsersWithRole_result getResult(I iface, getUsersWithRole_args args) throws org.apache.thrift.TException {
         getUsersWithRole_result result = new getUsersWithRole_result();
         try {
-          result.success = iface.getUsersWithRole(args.authzToken, args.roleName);
-        } catch (IamAdminServicesException Idse) {
+          result.success = iface.getUsersWithRole(args.authzToken, args.roleName, args.tenantAdminPasswordCredential);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
           result.Idse = Idse;
-        } catch (org.apache.airavata.model.error.AuthorizationException ae) {
+        } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
           result.ae = ae;
         }
         return result;
@@ -1567,14 +1640,14 @@ public class IamAdminServices {
   public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
     private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName());
     public AsyncProcessor(I iface) {
-      super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
+      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
     }
 
-    protected AsyncProcessor(I iface, java.util.Map<java.lang.String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
+    protected AsyncProcessor(I iface, java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
       super(iface, getProcessMap(processMap));
     }
 
-    private static <I extends AsyncIface> java.util.Map<java.lang.String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<java.lang.String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
+    private static <I extends AsyncIface> java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
       processMap.put("getAPIVersion", new getAPIVersion());
       processMap.put("setUpGateway", new setUpGateway());
       processMap.put("isUsernameAvailable", new isUsernameAvailable());
@@ -1593,7 +1666,7 @@ public class IamAdminServices {
       return processMap;
     }
 
-    public static class getAPIVersion<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getAPIVersion_args, java.lang.String> {
+    public static class getAPIVersion<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getAPIVersion_args, String> {
       public getAPIVersion() {
         super("getAPIVersion");
       }
@@ -1602,10 +1675,10 @@ public class IamAdminServices {
         return new getAPIVersion_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.lang.String> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<String> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.String>() { 
-          public void onComplete(java.lang.String o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<String>() {
+          public void onComplete(String o) {
             getAPIVersion_result result = new getAPIVersion_result();
             result.success = o;
             try {
@@ -1613,17 +1686,17 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             getAPIVersion_result result = new getAPIVersion_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -1641,7 +1714,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -1653,12 +1726,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, getAPIVersion_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.String> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, getAPIVersion_args args, org.apache.thrift.async.AsyncMethodCallback<String> resultHandler) throws org.apache.thrift.TException {
         iface.getAPIVersion(resultHandler);
       }
     }
 
-    public static class setUpGateway<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, setUpGateway_args, org.apache.airavata.model.workspace.Gateway> {
+    public static class setUpGateway<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, setUpGateway_args, org.apache.custos.profile.model.workspace.Gateway> {
       public setUpGateway() {
         super("setUpGateway");
       }
@@ -1667,10 +1740,10 @@ public class IamAdminServices {
         return new setUpGateway_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.workspace.Gateway> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.workspace.Gateway>() { 
-          public void onComplete(org.apache.airavata.model.workspace.Gateway o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway>() { 
+          public void onComplete(org.apache.custos.profile.model.workspace.Gateway o) {
             setUpGateway_result result = new setUpGateway_result();
             result.success = o;
             try {
@@ -1678,21 +1751,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             setUpGateway_result result = new setUpGateway_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -1710,7 +1783,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -1722,12 +1795,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, setUpGateway_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
-        iface.setUpGateway(args.authzToken, args.gateway,resultHandler);
+      public void start(I iface, setUpGateway_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
+        iface.setUpGateway(args.authzToken, args.gateway, args.tenantAdminPasswordCredential,resultHandler);
       }
     }
 
-    public static class isUsernameAvailable<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUsernameAvailable_args, java.lang.Boolean> {
+    public static class isUsernameAvailable<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUsernameAvailable_args, Boolean> {
       public isUsernameAvailable() {
         super("isUsernameAvailable");
       }
@@ -1736,10 +1809,10 @@ public class IamAdminServices {
         return new isUsernameAvailable_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean>() { 
-          public void onComplete(java.lang.Boolean o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
             isUsernameAvailable_result result = new isUsernameAvailable_result();
             result.success = o;
             result.setSuccessIsSet(true);
@@ -1748,21 +1821,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             isUsernameAvailable_result result = new isUsernameAvailable_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -1780,7 +1853,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -1792,12 +1865,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, isUsernameAvailable_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, isUsernameAvailable_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
         iface.isUsernameAvailable(args.authzToken, args.username,resultHandler);
       }
     }
 
-    public static class registerUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, registerUser_args, java.lang.Boolean> {
+    public static class registerUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, registerUser_args, Boolean> {
       public registerUser() {
         super("registerUser");
       }
@@ -1806,10 +1879,10 @@ public class IamAdminServices {
         return new registerUser_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean>() { 
-          public void onComplete(java.lang.Boolean o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
             registerUser_result result = new registerUser_result();
             result.success = o;
             result.setSuccessIsSet(true);
@@ -1818,21 +1891,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             registerUser_result result = new registerUser_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -1850,7 +1923,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -1862,12 +1935,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, registerUser_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, registerUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
         iface.registerUser(args.authzToken, args.username, args.emailAddress, args.firstName, args.lastName, args.newPassword,resultHandler);
       }
     }
 
-    public static class enableUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, enableUser_args, java.lang.Boolean> {
+    public static class enableUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, enableUser_args, Boolean> {
       public enableUser() {
         super("enableUser");
       }
@@ -1876,10 +1949,10 @@ public class IamAdminServices {
         return new enableUser_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean>() { 
-          public void onComplete(java.lang.Boolean o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
             enableUser_result result = new enableUser_result();
             result.success = o;
             result.setSuccessIsSet(true);
@@ -1888,21 +1961,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             enableUser_result result = new enableUser_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -1920,7 +1993,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -1932,12 +2005,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, enableUser_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, enableUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
         iface.enableUser(args.authzToken, args.username,resultHandler);
       }
     }
 
-    public static class isUserEnabled<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUserEnabled_args, java.lang.Boolean> {
+    public static class isUserEnabled<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUserEnabled_args, Boolean> {
       public isUserEnabled() {
         super("isUserEnabled");
       }
@@ -1946,10 +2019,10 @@ public class IamAdminServices {
         return new isUserEnabled_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean>() { 
-          public void onComplete(java.lang.Boolean o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
             isUserEnabled_result result = new isUserEnabled_result();
             result.success = o;
             result.setSuccessIsSet(true);
@@ -1958,21 +2031,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             isUserEnabled_result result = new isUserEnabled_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -1990,7 +2063,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2002,12 +2075,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, isUserEnabled_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, isUserEnabled_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
         iface.isUserEnabled(args.authzToken, args.username,resultHandler);
       }
     }
 
-    public static class isUserExist<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUserExist_args, java.lang.Boolean> {
+    public static class isUserExist<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUserExist_args, Boolean> {
       public isUserExist() {
         super("isUserExist");
       }
@@ -2016,10 +2089,10 @@ public class IamAdminServices {
         return new isUserExist_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean>() { 
-          public void onComplete(java.lang.Boolean o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
             isUserExist_result result = new isUserExist_result();
             result.success = o;
             result.setSuccessIsSet(true);
@@ -2028,21 +2101,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             isUserExist_result result = new isUserExist_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -2060,7 +2133,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2072,12 +2145,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, isUserExist_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, isUserExist_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
         iface.isUserExist(args.authzToken, args.username,resultHandler);
       }
     }
 
-    public static class getUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUser_args, org.apache.airavata.model.user.UserProfile> {
+    public static class getUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUser_args, org.apache.custos.profile.model.user.UserProfile> {
       public getUser() {
         super("getUser");
       }
@@ -2086,10 +2159,10 @@ public class IamAdminServices {
         return new getUser_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.user.UserProfile> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.user.UserProfile>() { 
-          public void onComplete(org.apache.airavata.model.user.UserProfile o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile>() { 
+          public void onComplete(org.apache.custos.profile.model.user.UserProfile o) {
             getUser_result result = new getUser_result();
             result.success = o;
             try {
@@ -2097,21 +2170,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             getUser_result result = new getUser_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -2129,7 +2202,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2141,12 +2214,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, getUser_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.airavata.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, getUser_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
         iface.getUser(args.authzToken, args.username,resultHandler);
       }
     }
 
-    public static class getUsers<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUsers_args, java.util.List<org.apache.airavata.model.user.UserProfile>> {
+    public static class getUsers<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUsers_args, java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
       public getUsers() {
         super("getUsers");
       }
@@ -2155,10 +2228,10 @@ public class IamAdminServices {
         return new getUsers_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>>() { 
-          public void onComplete(java.util.List<org.apache.airavata.model.user.UserProfile> o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>>() { 
+          public void onComplete(java.util.List<org.apache.custos.profile.model.user.UserProfile> o) {
             getUsers_result result = new getUsers_result();
             result.success = o;
             try {
@@ -2166,21 +2239,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             getUsers_result result = new getUsers_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -2198,7 +2271,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2210,12 +2283,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, getUsers_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, getUsers_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
         iface.getUsers(args.authzToken, args.offset, args.limit, args.search,resultHandler);
       }
     }
 
-    public static class resetUserPassword<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, resetUserPassword_args, java.lang.Boolean> {
+    public static class resetUserPassword<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, resetUserPassword_args, Boolean> {
       public resetUserPassword() {
         super("resetUserPassword");
       }
@@ -2224,10 +2297,10 @@ public class IamAdminServices {
         return new resetUserPassword_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean>() { 
-          public void onComplete(java.lang.Boolean o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
             resetUserPassword_result result = new resetUserPassword_result();
             result.success = o;
             result.setSuccessIsSet(true);
@@ -2236,21 +2309,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             resetUserPassword_result result = new resetUserPassword_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -2268,7 +2341,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2280,12 +2353,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, resetUserPassword_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, resetUserPassword_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
         iface.resetUserPassword(args.authzToken, args.username, args.newPassword,resultHandler);
       }
     }
 
-    public static class findUsers<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, findUsers_args, java.util.List<org.apache.airavata.model.user.UserProfile>> {
+    public static class findUsers<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, findUsers_args, java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
       public findUsers() {
         super("findUsers");
       }
@@ -2294,10 +2367,10 @@ public class IamAdminServices {
         return new findUsers_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>>() { 
-          public void onComplete(java.util.List<org.apache.airavata.model.user.UserProfile> o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>>() { 
+          public void onComplete(java.util.List<org.apache.custos.profile.model.user.UserProfile> o) {
             findUsers_result result = new findUsers_result();
             result.success = o;
             try {
@@ -2305,21 +2378,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             findUsers_result result = new findUsers_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -2337,7 +2410,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2349,7 +2422,7 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, findUsers_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+      public void start(I iface, findUsers_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
         iface.findUsers(args.authzToken, args.email, args.userId,resultHandler);
       }
     }
@@ -2373,21 +2446,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             updateUserProfile_result result = new updateUserProfile_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -2405,7 +2478,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2422,7 +2495,7 @@ public class IamAdminServices {
       }
     }
 
-    public static class addRoleToUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, addRoleToUser_args, java.lang.Boolean> {
+    public static class addRoleToUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, addRoleToUser_args, Boolean> {
       public addRoleToUser() {
         super("addRoleToUser");
       }
@@ -2431,10 +2504,10 @@ public class IamAdminServices {
         return new addRoleToUser_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean>() { 
-          public void onComplete(java.lang.Boolean o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
             addRoleToUser_result result = new addRoleToUser_result();
             result.success = o;
             result.setSuccessIsSet(true);
@@ -2443,21 +2516,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             addRoleToUser_result result = new addRoleToUser_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -2475,7 +2548,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2487,12 +2560,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, addRoleToUser_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
-        iface.addRoleToUser(args.authzToken, args.username, args.roleName,resultHandler);
+      public void start(I iface, addRoleToUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.addRoleToUser(args.authzToken, args.username, args.roleName, args.tenantAdminPasswordCredential,resultHandler);
       }
     }
 
-    public static class removeRoleFromUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, removeRoleFromUser_args, java.lang.Boolean> {
+    public static class removeRoleFromUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, removeRoleFromUser_args, Boolean> {
       public removeRoleFromUser() {
         super("removeRoleFromUser");
       }
@@ -2501,10 +2574,10 @@ public class IamAdminServices {
         return new removeRoleFromUser_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean>() { 
-          public void onComplete(java.lang.Boolean o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
             removeRoleFromUser_result result = new removeRoleFromUser_result();
             result.success = o;
             result.setSuccessIsSet(true);
@@ -2513,21 +2586,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             removeRoleFromUser_result result = new removeRoleFromUser_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -2545,7 +2618,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2557,12 +2630,12 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, removeRoleFromUser_args args, org.apache.thrift.async.AsyncMethodCallback<java.lang.Boolean> resultHandler) throws org.apache.thrift.TException {
-        iface.removeRoleFromUser(args.authzToken, args.username, args.roleName,resultHandler);
+      public void start(I iface, removeRoleFromUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.removeRoleFromUser(args.authzToken, args.username, args.roleName, args.tenantAdminPasswordCredential,resultHandler);
       }
     }
 
-    public static class getUsersWithRole<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUsersWithRole_args, java.util.List<org.apache.airavata.model.user.UserProfile>> {
+    public static class getUsersWithRole<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUsersWithRole_args, java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
       public getUsersWithRole() {
         super("getUsersWithRole");
       }
@@ -2571,10 +2644,10 @@ public class IamAdminServices {
         return new getUsersWithRole_args();
       }
 
-      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>>() { 
-          public void onComplete(java.util.List<org.apache.airavata.model.user.UserProfile> o) {
+        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>>() { 
+          public void onComplete(java.util.List<org.apache.custos.profile.model.user.UserProfile> o) {
             getUsersWithRole_result result = new getUsersWithRole_result();
             result.success = o;
             try {
@@ -2582,21 +2655,21 @@ public class IamAdminServices {
             } catch (org.apache.thrift.transport.TTransportException e) {
               _LOGGER.error("TTransportException writing to internal frame buffer", e);
               fb.close();
-            } catch (java.lang.Exception e) {
+            } catch (Exception e) {
               _LOGGER.error("Exception writing to internal frame buffer", e);
               onError(e);
             }
           }
-          public void onError(java.lang.Exception e) {
+          public void onError(Exception e) {
             byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
             org.apache.thrift.TSerializable msg;
             getUsersWithRole_result result = new getUsersWithRole_result();
-            if (e instanceof IamAdminServicesException) {
-              result.Idse = (IamAdminServicesException) e;
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
               result.setIdseIsSet(true);
               msg = result;
-            } else if (e instanceof org.apache.airavata.model.error.AuthorizationException) {
-              result.ae = (org.apache.airavata.model.error.AuthorizationException) e;
+            } else if (e instanceof org.apache.custos.commons.model.error.AuthorizationException) {
+              result.ae = (org.apache.custos.commons.model.error.AuthorizationException) e;
               result.setAeIsSet(true);
               msg = result;
             } else if (e instanceof org.apache.thrift.transport.TTransportException) {
@@ -2614,7 +2687,7 @@ public class IamAdminServices {
             }
             try {
               fcall.sendResponse(fb,msg,msgType,seqid);
-            } catch (java.lang.Exception ex) {
+            } catch (Exception ex) {
               _LOGGER.error("Exception writing to internal frame buffer", ex);
               fb.close();
             }
@@ -2626,8 +2699,8 @@ public class IamAdminServices {
         return false;
       }
 
-      public void start(I iface, getUsersWithRole_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.airavata.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
-        iface.getUsersWithRole(args.authzToken, args.roleName,resultHandler);
+      public void start(I iface, getUsersWithRole_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+        iface.getUsersWithRole(args.authzToken, args.roleName, args.tenantAdminPasswordCredential,resultHandler);
       }
     }
 
@@ -2645,7 +2718,7 @@ public class IamAdminServices {
     public enum _Fields implements org.apache.thrift.TFieldIdEnum {
 ;
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -2656,6 +2729,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           default:
@@ -2669,21 +2743,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -2692,7 +2767,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -2720,30 +2795,31 @@ public class IamAdminServices {
     public void clear() {
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof getAPIVersion_args)
@@ -2778,6 +2854,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -2791,8 +2868,8 @@ public class IamAdminServices {
     }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("getAPIVersion_args(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getAPIVersion_args(");
       boolean first = true;
 
       sb.append(")");
@@ -2812,7 +2889,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    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) {
@@ -2892,15 +2969,15 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getAPIVersion_resultStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getAPIVersion_resultTupleSchemeFactory();
 
-    public java.lang.String success; // required
-    public IamAdminServicesException Idse; // required
+    public @org.apache.thrift.annotation.Nullable String success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // 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"),
       IDSE((short)1, "Idse");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -2911,6 +2988,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 0: // SUCCESS
@@ -2928,21 +3006,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -2951,7 +3030,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -2963,7 +3042,7 @@ public class IamAdminServices {
       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.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, IamAdminServicesException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getAPIVersion_result.class, metaDataMap);
     }
@@ -2972,8 +3051,8 @@ public class IamAdminServices {
     }
 
     public getAPIVersion_result(
-      java.lang.String success,
-      IamAdminServicesException Idse)
+      String success,
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse)
     {
       this();
       this.success = success;
@@ -2988,7 +3067,7 @@ public class IamAdminServices {
         this.success = other.success;
       }
       if (other.isSetIdse()) {
-        this.Idse = new IamAdminServicesException(other.Idse);
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
       }
     }
 
@@ -3002,11 +3081,12 @@ public class IamAdminServices {
       this.Idse = null;
     }
 
-    public java.lang.String getSuccess() {
+    @org.apache.thrift.annotation.Nullable
+    public String getSuccess() {
       return this.success;
     }
 
-    public getAPIVersion_result setSuccess(java.lang.String success) {
+    public getAPIVersion_result setSuccess(@org.apache.thrift.annotation.Nullable String success) {
       this.success = success;
       return this;
     }
@@ -3026,11 +3106,12 @@ public class IamAdminServices {
       }
     }
 
-    public IamAdminServicesException getIdse() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
       return this.Idse;
     }
 
-    public getAPIVersion_result setIdse(IamAdminServicesException Idse) {
+    public getAPIVersion_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
       this.Idse = Idse;
       return this;
     }
@@ -3050,13 +3131,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case SUCCESS:
         if (value == null) {
           unsetSuccess();
         } else {
-          setSuccess((java.lang.String)value);
+          setSuccess((String)value);
         }
         break;
 
@@ -3064,14 +3145,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetIdse();
         } else {
-          setIdse((IamAdminServicesException)value);
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case SUCCESS:
         return getSuccess();
@@ -3080,13 +3162,13 @@ public class IamAdminServices {
         return getIdse();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -3095,11 +3177,11 @@ public class IamAdminServices {
       case IDSE:
         return isSetIdse();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof getAPIVersion_result)
@@ -3157,7 +3239,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
+      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -3167,7 +3249,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
+      lastComparison = Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -3180,6 +3262,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -3193,8 +3276,8 @@ public class IamAdminServices {
       }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("getAPIVersion_result(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getAPIVersion_result(");
       boolean first = true;
 
       sb.append("success:");
@@ -3229,7 +3312,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    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) {
@@ -3265,7 +3348,7 @@ public class IamAdminServices {
               break;
             case 1: // IDSE
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.Idse = new IamAdminServicesException();
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
                 struct.Idse.read(iprot);
                 struct.setIdseIsSet(true);
               } else { 
@@ -3339,7 +3422,7 @@ public class IamAdminServices {
           struct.setSuccessIsSet(true);
         }
         if (incoming.get(1)) {
-          struct.Idse = new IamAdminServicesException();
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
           struct.Idse.read(iprot);
           struct.setIdseIsSet(true);
         }
@@ -3356,19 +3439,22 @@ public class IamAdminServices {
 
     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_FIELD_DESC = new org.apache.thrift.protocol.TField("gateway", org.apache.thrift.protocol.TType.STRUCT, (short)2);
+    private static final org.apache.thrift.protocol.TField TENANT_ADMIN_PASSWORD_CREDENTIAL_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantAdminPasswordCredential", org.apache.thrift.protocol.TType.STRUCT, (short)3);
 
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setUpGateway_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setUpGateway_argsTupleSchemeFactory();
 
-    public org.apache.airavata.model.security.AuthzToken authzToken; // required
-    public org.apache.airavata.model.workspace.Gateway gateway; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway gateway; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential; // 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((short)2, "gateway");
+      GATEWAY((short)2, "gateway"),
+      TENANT_ADMIN_PASSWORD_CREDENTIAL((short)3, "tenantAdminPasswordCredential");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -3379,12 +3465,15 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 1: // AUTHZ_TOKEN
             return AUTHZ_TOKEN;
           case 2: // GATEWAY
             return GATEWAY;
+          case 3: // TENANT_ADMIN_PASSWORD_CREDENTIAL
+            return TENANT_ADMIN_PASSWORD_CREDENTIAL;
           default:
             return null;
         }
@@ -3396,21 +3485,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -3419,7 +3509,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -3429,9 +3519,11 @@ public class IamAdminServices {
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
       tmpMap.put(_Fields.GATEWAY, new org.apache.thrift.meta_data.FieldMetaData("gateway", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.workspace.Gateway.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.workspace.Gateway.class)));
+      tmpMap.put(_Fields.TENANT_ADMIN_PASSWORD_CREDENTIAL, new org.apache.thrift.meta_data.FieldMetaData("tenantAdminPasswordCredential", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.tenant.PasswordCredential.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setUpGateway_args.class, metaDataMap);
     }
@@ -3440,12 +3532,14 @@ public class IamAdminServices {
     }
 
     public setUpGateway_args(
-      org.apache.airavata.model.security.AuthzToken authzToken,
-      org.apache.airavata.model.workspace.Gateway gateway)
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      org.apache.custos.profile.model.workspace.Gateway gateway,
+      org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential)
     {
       this();
       this.authzToken = authzToken;
       this.gateway = gateway;
+      this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
     }
 
     /**
@@ -3453,10 +3547,13 @@ public class IamAdminServices {
      */
     public setUpGateway_args(setUpGateway_args other) {
       if (other.isSetAuthzToken()) {
-        this.authzToken = new org.apache.airavata.model.security.AuthzToken(other.authzToken);
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
       }
       if (other.isSetGateway()) {
-        this.gateway = new org.apache.airavata.model.workspace.Gateway(other.gateway);
+        this.gateway = new org.apache.custos.profile.model.workspace.Gateway(other.gateway);
+      }
+      if (other.isSetTenantAdminPasswordCredential()) {
+        this.tenantAdminPasswordCredential = new org.apache.custos.profile.model.tenant.PasswordCredential(other.tenantAdminPasswordCredential);
       }
     }
 
@@ -3468,13 +3565,15 @@ public class IamAdminServices {
     public void clear() {
       this.authzToken = null;
       this.gateway = null;
+      this.tenantAdminPasswordCredential = null;
     }
 
-    public org.apache.airavata.model.security.AuthzToken getAuthzToken() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
       return this.authzToken;
     }
 
-    public setUpGateway_args setAuthzToken(org.apache.airavata.model.security.AuthzToken authzToken) {
+    public setUpGateway_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken) {
       this.authzToken = authzToken;
       return this;
     }
@@ -3494,11 +3593,12 @@ public class IamAdminServices {
       }
     }
 
-    public org.apache.airavata.model.workspace.Gateway getGateway() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.model.workspace.Gateway getGateway() {
       return this.gateway;
     }
 
-    public setUpGateway_args setGateway(org.apache.airavata.model.workspace.Gateway gateway) {
+    public setUpGateway_args setGateway(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway gateway) {
       this.gateway = gateway;
       return this;
     }
@@ -3518,13 +3618,38 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.model.tenant.PasswordCredential getTenantAdminPasswordCredential() {
+      return this.tenantAdminPasswordCredential;
+    }
+
+    public setUpGateway_args setTenantAdminPasswordCredential(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) {
+      this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
+      return this;
+    }
+
+    public void unsetTenantAdminPasswordCredential() {
+      this.tenantAdminPasswordCredential = null;
+    }
+
+    /** Returns true if field tenantAdminPasswordCredential is set (has been assigned a value) and false otherwise */
+    public boolean isSetTenantAdminPasswordCredential() {
+      return this.tenantAdminPasswordCredential != null;
+    }
+
+    public void setTenantAdminPasswordCredentialIsSet(boolean value) {
+      if (!value) {
+        this.tenantAdminPasswordCredential = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case AUTHZ_TOKEN:
         if (value == null) {
           unsetAuthzToken();
         } else {
-          setAuthzToken((org.apache.airavata.model.security.AuthzToken)value);
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
         }
         break;
 
@@ -3532,14 +3657,23 @@ public class IamAdminServices {
         if (value == null) {
           unsetGateway();
         } else {
-          setGateway((org.apache.airavata.model.workspace.Gateway)value);
+          setGateway((org.apache.custos.profile.model.workspace.Gateway)value);
+        }
+        break;
+
+      case TENANT_ADMIN_PASSWORD_CREDENTIAL:
+        if (value == null) {
+          unsetTenantAdminPasswordCredential();
+        } else {
+          setTenantAdminPasswordCredential((org.apache.custos.profile.model.tenant.PasswordCredential)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case AUTHZ_TOKEN:
         return getAuthzToken();
@@ -3547,14 +3681,17 @@ public class IamAdminServices {
       case GATEWAY:
         return getGateway();
 
+      case TENANT_ADMIN_PASSWORD_CREDENTIAL:
+        return getTenantAdminPasswordCredential();
+
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -3562,12 +3699,14 @@ public class IamAdminServices {
         return isSetAuthzToken();
       case GATEWAY:
         return isSetGateway();
+      case TENANT_ADMIN_PASSWORD_CREDENTIAL:
+        return isSetTenantAdminPasswordCredential();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof setUpGateway_args)
@@ -3599,6 +3738,15 @@ public class IamAdminServices {
           return false;
       }
 
+      boolean this_present_tenantAdminPasswordCredential = true && this.isSetTenantAdminPasswordCredential();
+      boolean that_present_tenantAdminPasswordCredential = true && that.isSetTenantAdminPasswordCredential();
+      if (this_present_tenantAdminPasswordCredential || that_present_tenantAdminPasswordCredential) {
+        if (!(this_present_tenantAdminPasswordCredential && that_present_tenantAdminPasswordCredential))
+          return false;
+        if (!this.tenantAdminPasswordCredential.equals(that.tenantAdminPasswordCredential))
+          return false;
+      }
+
       return true;
     }
 
@@ -3614,6 +3762,10 @@ public class IamAdminServices {
       if (isSetGateway())
         hashCode = hashCode * 8191 + gateway.hashCode();
 
+      hashCode = hashCode * 8191 + ((isSetTenantAdminPasswordCredential()) ? 131071 : 524287);
+      if (isSetTenantAdminPasswordCredential())
+        hashCode = hashCode * 8191 + tenantAdminPasswordCredential.hashCode();
+
       return hashCode;
     }
 
@@ -3625,7 +3777,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
+      lastComparison = Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -3635,7 +3787,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetGateway()).compareTo(other.isSetGateway());
+      lastComparison = Boolean.valueOf(isSetGateway()).compareTo(other.isSetGateway());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -3645,9 +3797,20 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
+      lastComparison = Boolean.valueOf(isSetTenantAdminPasswordCredential()).compareTo(other.isSetTenantAdminPasswordCredential());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetTenantAdminPasswordCredential()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantAdminPasswordCredential, other.tenantAdminPasswordCredential);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -3661,8 +3824,8 @@ public class IamAdminServices {
     }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("setUpGateway_args(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("setUpGateway_args(");
       boolean first = true;
 
       sb.append("authzToken:");
@@ -3680,6 +3843,14 @@ public class IamAdminServices {
         sb.append(this.gateway);
       }
       first = false;
+      if (!first) sb.append(", ");
+      sb.append("tenantAdminPasswordCredential:");
+      if (this.tenantAdminPasswordCredential == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.tenantAdminPasswordCredential);
+      }
+      first = false;
       sb.append(")");
       return sb.toString();
     }
@@ -3692,6 +3863,9 @@ public class IamAdminServices {
       if (gateway == null) {
         throw new org.apache.thrift.protocol.TProtocolException("Required field 'gateway' was not present! Struct: " + toString());
       }
+      if (tenantAdminPasswordCredential == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'tenantAdminPasswordCredential' was not present! Struct: " + toString());
+      }
       // check for sub-struct validity
       if (authzToken != null) {
         authzToken.validate();
@@ -3699,6 +3873,9 @@ public class IamAdminServices {
       if (gateway != null) {
         gateway.validate();
       }
+      if (tenantAdminPasswordCredential != null) {
+        tenantAdminPasswordCredential.validate();
+      }
     }
 
     private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -3709,7 +3886,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    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) {
@@ -3737,7 +3914,7 @@ public class IamAdminServices {
           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 = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
               } else { 
@@ -3746,13 +3923,22 @@ public class IamAdminServices {
               break;
             case 2: // GATEWAY
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.gateway = new org.apache.airavata.model.workspace.Gateway();
+                struct.gateway = new org.apache.custos.profile.model.workspace.Gateway();
                 struct.gateway.read(iprot);
                 struct.setGatewayIsSet(true);
               } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
+            case 3: // TENANT_ADMIN_PASSWORD_CREDENTIAL
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.tenantAdminPasswordCredential = new org.apache.custos.profile.model.tenant.PasswordCredential();
+                struct.tenantAdminPasswordCredential.read(iprot);
+                struct.setTenantAdminPasswordCredentialIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
             default:
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
           }
@@ -3778,6 +3964,11 @@ public class IamAdminServices {
           struct.gateway.write(oprot);
           oprot.writeFieldEnd();
         }
+        if (struct.tenantAdminPasswordCredential != null) {
+          oprot.writeFieldBegin(TENANT_ADMIN_PASSWORD_CREDENTIAL_FIELD_DESC);
+          struct.tenantAdminPasswordCredential.write(oprot);
+          oprot.writeFieldEnd();
+        }
         oprot.writeFieldStop();
         oprot.writeStructEnd();
       }
@@ -3797,17 +3988,21 @@ public class IamAdminServices {
         org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         struct.authzToken.write(oprot);
         struct.gateway.write(oprot);
+        struct.tenantAdminPasswordCredential.write(oprot);
       }
 
       @Override
       public void read(org.apache.thrift.protocol.TProtocol prot, setUpGateway_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken = new org.apache.airavata.model.security.AuthzToken();
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
         struct.authzToken.read(iprot);
         struct.setAuthzTokenIsSet(true);
-        struct.gateway = new org.apache.airavata.model.workspace.Gateway();
+        struct.gateway = new org.apache.custos.profile.model.workspace.Gateway();
         struct.gateway.read(iprot);
         struct.setGatewayIsSet(true);
+        struct.tenantAdminPasswordCredential = new org.apache.custos.profile.model.tenant.PasswordCredential();
+        struct.tenantAdminPasswordCredential.read(iprot);
+        struct.setTenantAdminPasswordCredentialIsSet(true);
       }
     }
 
@@ -3826,9 +4021,9 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setUpGateway_resultStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setUpGateway_resultTupleSchemeFactory();
 
-    public org.apache.airavata.model.workspace.Gateway success; // required
-    public IamAdminServicesException Idse; // required
-    public org.apache.airavata.model.error.AuthorizationException ae; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae; // 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 {
@@ -3836,7 +4031,7 @@ public class IamAdminServices {
       IDSE((short)1, "Idse"),
       AE((short)2, "ae");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -3847,6 +4042,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 0: // SUCCESS
@@ -3866,21 +4062,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -3889,7 +4086,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -3899,11 +4096,11 @@ public class IamAdminServices {
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.workspace.Gateway.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.workspace.Gateway.class)));
       tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, IamAdminServicesException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
       tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.error.AuthorizationException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.error.AuthorizationException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setUpGateway_result.class, metaDataMap);
     }
@@ -3912,9 +4109,9 @@ public class IamAdminServices {
     }
 
     public setUpGateway_result(
-      org.apache.airavata.model.workspace.Gateway success,
-      IamAdminServicesException Idse,
-      org.apache.airavata.model.error.AuthorizationException ae)
+      org.apache.custos.profile.model.workspace.Gateway success,
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse,
+      org.apache.custos.commons.model.error.AuthorizationException ae)
     {
       this();
       this.success = success;
@@ -3927,13 +4124,13 @@ public class IamAdminServices {
      */
     public setUpGateway_result(setUpGateway_result other) {
       if (other.isSetSuccess()) {
-        this.success = new org.apache.airavata.model.workspace.Gateway(other.success);
+        this.success = new org.apache.custos.profile.model.workspace.Gateway(other.success);
       }
       if (other.isSetIdse()) {
-        this.Idse = new IamAdminServicesException(other.Idse);
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
       }
       if (other.isSetAe()) {
-        this.ae = new org.apache.airavata.model.error.AuthorizationException(other.ae);
+        this.ae = new org.apache.custos.commons.model.error.AuthorizationException(other.ae);
       }
     }
 
@@ -3948,11 +4145,12 @@ public class IamAdminServices {
       this.ae = null;
     }
 
-    public org.apache.airavata.model.workspace.Gateway getSuccess() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.model.workspace.Gateway getSuccess() {
       return this.success;
     }
 
-    public setUpGateway_result setSuccess(org.apache.airavata.model.workspace.Gateway success) {
+    public setUpGateway_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway success) {
       this.success = success;
       return this;
     }
@@ -3972,11 +4170,12 @@ public class IamAdminServices {
       }
     }
 
-    public IamAdminServicesException getIdse() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
       return this.Idse;
     }
 
-    public setUpGateway_result setIdse(IamAdminServicesException Idse) {
+    public setUpGateway_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
       this.Idse = Idse;
       return this;
     }
@@ -3996,11 +4195,12 @@ public class IamAdminServices {
       }
     }
 
-    public org.apache.airavata.model.error.AuthorizationException getAe() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.error.AuthorizationException getAe() {
       return this.ae;
     }
 
-    public setUpGateway_result setAe(org.apache.airavata.model.error.AuthorizationException ae) {
+    public setUpGateway_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae) {
       this.ae = ae;
       return this;
     }
@@ -4020,13 +4220,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case SUCCESS:
         if (value == null) {
           unsetSuccess();
         } else {
-          setSuccess((org.apache.airavata.model.workspace.Gateway)value);
+          setSuccess((org.apache.custos.profile.model.workspace.Gateway)value);
         }
         break;
 
@@ -4034,7 +4234,7 @@ public class IamAdminServices {
         if (value == null) {
           unsetIdse();
         } else {
-          setIdse((IamAdminServicesException)value);
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
         }
         break;
 
@@ -4042,14 +4242,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetAe();
         } else {
-          setAe((org.apache.airavata.model.error.AuthorizationException)value);
+          setAe((org.apache.custos.commons.model.error.AuthorizationException)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case SUCCESS:
         return getSuccess();
@@ -4061,13 +4262,13 @@ public class IamAdminServices {
         return getAe();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -4078,11 +4279,11 @@ public class IamAdminServices {
       case AE:
         return isSetAe();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof setUpGateway_result)
@@ -4153,7 +4354,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
+      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -4163,7 +4364,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
+      lastComparison = Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -4173,7 +4374,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
+      lastComparison = Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -4186,6 +4387,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -4199,8 +4401,8 @@ public class IamAdminServices {
       }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("setUpGateway_result(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("setUpGateway_result(");
       boolean first = true;
 
       sb.append("success:");
@@ -4246,7 +4448,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    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) {
@@ -4274,7 +4476,7 @@ public class IamAdminServices {
           switch (schemeField.id) {
             case 0: // SUCCESS
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.success = new org.apache.airavata.model.workspace.Gateway();
+                struct.success = new org.apache.custos.profile.model.workspace.Gateway();
                 struct.success.read(iprot);
                 struct.setSuccessIsSet(true);
               } else { 
@@ -4283,7 +4485,7 @@ public class IamAdminServices {
               break;
             case 1: // IDSE
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.Idse = new IamAdminServicesException();
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
                 struct.Idse.read(iprot);
                 struct.setIdseIsSet(true);
               } else { 
@@ -4292,7 +4494,7 @@ public class IamAdminServices {
               break;
             case 2: // AE
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+                struct.ae = new org.apache.custos.commons.model.error.AuthorizationException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
               } else { 
@@ -4373,17 +4575,17 @@ public class IamAdminServices {
         org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
         java.util.BitSet incoming = iprot.readBitSet(3);
         if (incoming.get(0)) {
-          struct.success = new org.apache.airavata.model.workspace.Gateway();
+          struct.success = new org.apache.custos.profile.model.workspace.Gateway();
           struct.success.read(iprot);
           struct.setSuccessIsSet(true);
         }
         if (incoming.get(1)) {
-          struct.Idse = new IamAdminServicesException();
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
           struct.Idse.read(iprot);
           struct.setIdseIsSet(true);
         }
         if (incoming.get(2)) {
-          struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+          struct.ae = new org.apache.custos.commons.model.error.AuthorizationException();
           struct.ae.read(iprot);
           struct.setAeIsSet(true);
         }
@@ -4404,15 +4606,15 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUsernameAvailable_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUsernameAvailable_argsTupleSchemeFactory();
 
-    public org.apache.airavata.model.security.AuthzToken authzToken; // required
-    public java.lang.String username; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String username; // 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"),
       USERNAME((short)2, "username");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -4423,6 +4625,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 1: // AUTHZ_TOKEN
@@ -4440,21 +4643,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -4463,7 +4667,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -4473,7 +4677,7 @@ public class IamAdminServices {
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
       tmpMap.put(_Fields.USERNAME, 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)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
@@ -4484,8 +4688,8 @@ public class IamAdminServices {
     }
 
     public isUsernameAvailable_args(
-      org.apache.airavata.model.security.AuthzToken authzToken,
-      java.lang.String username)
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String username)
     {
       this();
       this.authzToken = authzToken;
@@ -4497,7 +4701,7 @@ public class IamAdminServices {
      */
     public isUsernameAvailable_args(isUsernameAvailable_args other) {
       if (other.isSetAuthzToken()) {
-        this.authzToken = new org.apache.airavata.model.security.AuthzToken(other.authzToken);
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
       }
       if (other.isSetUsername()) {
         this.username = other.username;
@@ -4514,11 +4718,12 @@ public class IamAdminServices {
       this.username = null;
     }
 
-    public org.apache.airavata.model.security.AuthzToken getAuthzToken() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
       return this.authzToken;
     }
 
-    public isUsernameAvailable_args setAuthzToken(org.apache.airavata.model.security.AuthzToken authzToken) {
+    public isUsernameAvailable_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken) {
       this.authzToken = authzToken;
       return this;
     }
@@ -4538,11 +4743,12 @@ public class IamAdminServices {
       }
     }
 
-    public java.lang.String getUsername() {
+    @org.apache.thrift.annotation.Nullable
+    public String getUsername() {
       return this.username;
     }
 
-    public isUsernameAvailable_args setUsername(java.lang.String username) {
+    public isUsernameAvailable_args setUsername(@org.apache.thrift.annotation.Nullable String username) {
       this.username = username;
       return this;
     }
@@ -4562,13 +4768,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case AUTHZ_TOKEN:
         if (value == null) {
           unsetAuthzToken();
         } else {
-          setAuthzToken((org.apache.airavata.model.security.AuthzToken)value);
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
         }
         break;
 
@@ -4576,14 +4782,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetUsername();
         } else {
-          setUsername((java.lang.String)value);
+          setUsername((String)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case AUTHZ_TOKEN:
         return getAuthzToken();
@@ -4592,13 +4799,13 @@ public class IamAdminServices {
         return getUsername();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -4607,11 +4814,11 @@ public class IamAdminServices {
       case USERNAME:
         return isSetUsername();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof isUsernameAvailable_args)
@@ -4669,7 +4876,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
+      lastComparison = Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -4679,7 +4886,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
+      lastComparison = Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -4692,6 +4899,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -4705,8 +4913,8 @@ public class IamAdminServices {
     }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("isUsernameAvailable_args(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("isUsernameAvailable_args(");
       boolean first = true;
 
       sb.append("authzToken:");
@@ -4750,7 +4958,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    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) {
@@ -4778,7 +4986,7 @@ public class IamAdminServices {
           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 = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
               } else { 
@@ -4842,7 +5050,7 @@ public class IamAdminServices {
       @Override
       public void read(org.apache.thrift.protocol.TProtocol prot, isUsernameAvailable_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken = new org.apache.airavata.model.security.AuthzToken();
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
         struct.authzToken.read(iprot);
         struct.setAuthzTokenIsSet(true);
         struct.username = iprot.readString();
@@ -4866,8 +5074,8 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUsernameAvailable_resultTupleSchemeFactory();
 
     public boolean success; // required
-    public IamAdminServicesException Idse; // required
-    public org.apache.airavata.model.error.AuthorizationException ae; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae; // 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 {
@@ -4875,7 +5083,7 @@ public class IamAdminServices {
       IDSE((short)1, "Idse"),
       AE((short)2, "ae");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -4886,6 +5094,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 0: // SUCCESS
@@ -4905,21 +5114,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -4928,7 +5138,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -4942,9 +5152,9 @@ public class IamAdminServices {
       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.BOOL)));
       tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, IamAdminServicesException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
       tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.error.AuthorizationException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.error.AuthorizationException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUsernameAvailable_result.class, metaDataMap);
     }
@@ -4954,8 +5164,8 @@ public class IamAdminServices {
 
     public isUsernameAvailable_result(
       boolean success,
-      IamAdminServicesException Idse,
-      org.apache.airavata.model.error.AuthorizationException ae)
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse,
+      org.apache.custos.commons.model.error.AuthorizationException ae)
     {
       this();
       this.success = success;
@@ -4971,10 +5181,10 @@ public class IamAdminServices {
       __isset_bitfield = other.__isset_bitfield;
       this.success = other.success;
       if (other.isSetIdse()) {
-        this.Idse = new IamAdminServicesException(other.Idse);
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
       }
       if (other.isSetAe()) {
-        this.ae = new org.apache.airavata.model.error.AuthorizationException(other.ae);
+        this.ae = new org.apache.custos.commons.model.error.AuthorizationException(other.ae);
       }
     }
 
@@ -5013,11 +5223,12 @@ public class IamAdminServices {
       __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
     }
 
-    public IamAdminServicesException getIdse() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
       return this.Idse;
     }
 
-    public isUsernameAvailable_result setIdse(IamAdminServicesException Idse) {
+    public isUsernameAvailable_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
       this.Idse = Idse;
       return this;
     }
@@ -5037,11 +5248,12 @@ public class IamAdminServices {
       }
     }
 
-    public org.apache.airavata.model.error.AuthorizationException getAe() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.error.AuthorizationException getAe() {
       return this.ae;
     }
 
-    public isUsernameAvailable_result setAe(org.apache.airavata.model.error.AuthorizationException ae) {
+    public isUsernameAvailable_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae) {
       this.ae = ae;
       return this;
     }
@@ -5061,13 +5273,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case SUCCESS:
         if (value == null) {
           unsetSuccess();
         } else {
-          setSuccess((java.lang.Boolean)value);
+          setSuccess((Boolean)value);
         }
         break;
 
@@ -5075,7 +5287,7 @@ public class IamAdminServices {
         if (value == null) {
           unsetIdse();
         } else {
-          setIdse((IamAdminServicesException)value);
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
         }
         break;
 
@@ -5083,14 +5295,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetAe();
         } else {
-          setAe((org.apache.airavata.model.error.AuthorizationException)value);
+          setAe((org.apache.custos.commons.model.error.AuthorizationException)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case SUCCESS:
         return isSuccess();
@@ -5102,13 +5315,13 @@ public class IamAdminServices {
         return getAe();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -5119,11 +5332,11 @@ public class IamAdminServices {
       case AE:
         return isSetAe();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof isUsernameAvailable_result)
@@ -5192,7 +5405,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
+      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -5202,7 +5415,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
+      lastComparison = Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -5212,7 +5425,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
+      lastComparison = Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -5225,6 +5438,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -5238,8 +5452,8 @@ public class IamAdminServices {
       }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("isUsernameAvailable_result(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("isUsernameAvailable_result(");
       boolean first = true;
 
       sb.append("success:");
@@ -5278,7 +5492,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
       try {
         // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
         __isset_bitfield = 0;
@@ -5316,7 +5530,7 @@ public class IamAdminServices {
               break;
             case 1: // IDSE
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.Idse = new IamAdminServicesException();
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
                 struct.Idse.read(iprot);
                 struct.setIdseIsSet(true);
               } else { 
@@ -5325,7 +5539,7 @@ public class IamAdminServices {
               break;
             case 2: // AE
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+                struct.ae = new org.apache.custos.commons.model.error.AuthorizationException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
               } else { 
@@ -5410,12 +5624,12 @@ public class IamAdminServices {
           struct.setSuccessIsSet(true);
         }
         if (incoming.get(1)) {
-          struct.Idse = new IamAdminServicesException();
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
           struct.Idse.read(iprot);
           struct.setIdseIsSet(true);
         }
         if (incoming.get(2)) {
-          struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+          struct.ae = new org.apache.custos.commons.model.error.AuthorizationException();
           struct.ae.read(iprot);
           struct.setAeIsSet(true);
         }
@@ -5440,12 +5654,12 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new registerUser_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new registerUser_argsTupleSchemeFactory();
 
-    public org.apache.airavata.model.security.AuthzToken authzToken; // required
-    public java.lang.String username; // required
-    public java.lang.String emailAddress; // required
-    public java.lang.String firstName; // required
-    public java.lang.String lastName; // required
-    public java.lang.String newPassword; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String username; // required
+    public @org.apache.thrift.annotation.Nullable String emailAddress; // required
+    public @org.apache.thrift.annotation.Nullable String firstName; // required
+    public @org.apache.thrift.annotation.Nullable String lastName; // required
+    public @org.apache.thrift.annotation.Nullable String newPassword; // 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 {
@@ -5456,7 +5670,7 @@ public class IamAdminServices {
       LAST_NAME((short)5, "lastName"),
       NEW_PASSWORD((short)6, "newPassword");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -5467,6 +5681,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 1: // AUTHZ_TOKEN
@@ -5492,21 +5707,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -5515,7 +5731,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -5525,7 +5741,7 @@ public class IamAdminServices {
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
       tmpMap.put(_Fields.USERNAME, 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.EMAIL_ADDRESS, new org.apache.thrift.meta_data.FieldMetaData("emailAddress", org.apache.thrift.TFieldRequirementType.REQUIRED, 
@@ -5544,12 +5760,12 @@ public class IamAdminServices {
     }
 
     public registerUser_args(
-      org.apache.airavata.model.security.AuthzToken authzToken,
-      java.lang.String username,
-      java.lang.String emailAddress,
-      java.lang.String firstName,
-      java.lang.String lastName,
-      java.lang.String newPassword)
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String username,
+      String emailAddress,
+      String firstName,
+      String lastName,
+      String newPassword)
     {
       this();
       this.authzToken = authzToken;
@@ -5565,7 +5781,7 @@ public class IamAdminServices {
      */
     public registerUser_args(registerUser_args other) {
       if (other.isSetAuthzToken()) {
-        this.authzToken = new org.apache.airavata.model.security.AuthzToken(other.authzToken);
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
       }
       if (other.isSetUsername()) {
         this.username = other.username;
@@ -5598,11 +5814,12 @@ public class IamAdminServices {
       this.newPassword = null;
     }
 
-    public org.apache.airavata.model.security.AuthzToken getAuthzToken() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
       return this.authzToken;
     }
 
-    public registerUser_args setAuthzToken(org.apache.airavata.model.security.AuthzToken authzToken) {
+    public registerUser_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken) {
       this.authzToken = authzToken;
       return this;
     }
@@ -5622,11 +5839,12 @@ public class IamAdminServices {
       }
     }
 
-    public java.lang.String getUsername() {
+    @org.apache.thrift.annotation.Nullable
+    public String getUsername() {
       return this.username;
     }
 
-    public registerUser_args setUsername(java.lang.String username) {
+    public registerUser_args setUsername(@org.apache.thrift.annotation.Nullable String username) {
       this.username = username;
       return this;
     }
@@ -5646,11 +5864,12 @@ public class IamAdminServices {
       }
     }
 
-    public java.lang.String getEmailAddress() {
+    @org.apache.thrift.annotation.Nullable
+    public String getEmailAddress() {
       return this.emailAddress;
     }
 
-    public registerUser_args setEmailAddress(java.lang.String emailAddress) {
+    public registerUser_args setEmailAddress(@org.apache.thrift.annotation.Nullable String emailAddress) {
       this.emailAddress = emailAddress;
       return this;
     }
@@ -5670,11 +5889,12 @@ public class IamAdminServices {
       }
     }
 
-    public java.lang.String getFirstName() {
+    @org.apache.thrift.annotation.Nullable
+    public String getFirstName() {
       return this.firstName;
     }
 
-    public registerUser_args setFirstName(java.lang.String firstName) {
+    public registerUser_args setFirstName(@org.apache.thrift.annotation.Nullable String firstName) {
       this.firstName = firstName;
       return this;
     }
@@ -5694,11 +5914,12 @@ public class IamAdminServices {
       }
     }
 
-    public java.lang.String getLastName() {
+    @org.apache.thrift.annotation.Nullable
+    public String getLastName() {
       return this.lastName;
     }
 
-    public registerUser_args setLastName(java.lang.String lastName) {
+    public registerUser_args setLastName(@org.apache.thrift.annotation.Nullable String lastName) {
       this.lastName = lastName;
       return this;
     }
@@ -5718,11 +5939,12 @@ public class IamAdminServices {
       }
     }
 
-    public java.lang.String getNewPassword() {
+    @org.apache.thrift.annotation.Nullable
+    public String getNewPassword() {
       return this.newPassword;
     }
 
-    public registerUser_args setNewPassword(java.lang.String newPassword) {
+    public registerUser_args setNewPassword(@org.apache.thrift.annotation.Nullable String newPassword) {
       this.newPassword = newPassword;
       return this;
     }
@@ -5742,13 +5964,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case AUTHZ_TOKEN:
         if (value == null) {
           unsetAuthzToken();
         } else {
-          setAuthzToken((org.apache.airavata.model.security.AuthzToken)value);
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
         }
         break;
 
@@ -5756,7 +5978,7 @@ public class IamAdminServices {
         if (value == null) {
           unsetUsername();
         } else {
-          setUsername((java.lang.String)value);
+          setUsername((String)value);
         }
         break;
 
@@ -5764,7 +5986,7 @@ public class IamAdminServices {
         if (value == null) {
           unsetEmailAddress();
         } else {
-          setEmailAddress((java.lang.String)value);
+          setEmailAddress((String)value);
         }
         break;
 
@@ -5772,7 +5994,7 @@ public class IamAdminServices {
         if (value == null) {
           unsetFirstName();
         } else {
-          setFirstName((java.lang.String)value);
+          setFirstName((String)value);
         }
         break;
 
@@ -5780,7 +6002,7 @@ public class IamAdminServices {
         if (value == null) {
           unsetLastName();
         } else {
-          setLastName((java.lang.String)value);
+          setLastName((String)value);
         }
         break;
 
@@ -5788,14 +6010,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetNewPassword();
         } else {
-          setNewPassword((java.lang.String)value);
+          setNewPassword((String)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case AUTHZ_TOKEN:
         return getAuthzToken();
@@ -5816,13 +6039,13 @@ public class IamAdminServices {
         return getNewPassword();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -5839,11 +6062,11 @@ public class IamAdminServices {
       case NEW_PASSWORD:
         return isSetNewPassword();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof registerUser_args)
@@ -5953,7 +6176,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
+      lastComparison = Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -5963,7 +6186,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
+      lastComparison = Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -5973,7 +6196,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetEmailAddress()).compareTo(other.isSetEmailAddress());
+      lastComparison = Boolean.valueOf(isSetEmailAddress()).compareTo(other.isSetEmailAddress());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -5983,7 +6206,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetFirstName()).compareTo(other.isSetFirstName());
+      lastComparison = Boolean.valueOf(isSetFirstName()).compareTo(other.isSetFirstName());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -5993,7 +6216,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetLastName()).compareTo(other.isSetLastName());
+      lastComparison = Boolean.valueOf(isSetLastName()).compareTo(other.isSetLastName());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -6003,7 +6226,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetNewPassword()).compareTo(other.isSetNewPassword());
+      lastComparison = Boolean.valueOf(isSetNewPassword()).compareTo(other.isSetNewPassword());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -6016,6 +6239,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -6029,8 +6253,8 @@ public class IamAdminServices {
     }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("registerUser_args(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("registerUser_args(");
       boolean first = true;
 
       sb.append("authzToken:");
@@ -6118,7 +6342,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    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) {
@@ -6146,7 +6370,7 @@ public class IamAdminServices {
           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 = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
               } else { 
@@ -6266,7 +6490,7 @@ public class IamAdminServices {
       @Override
       public void read(org.apache.thrift.protocol.TProtocol prot, registerUser_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken = new org.apache.airavata.model.security.AuthzToken();
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
         struct.authzToken.read(iprot);
         struct.setAuthzTokenIsSet(true);
         struct.username = iprot.readString();
@@ -6298,8 +6522,8 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new registerUser_resultTupleSchemeFactory();
 
     public boolean success; // required
-    public IamAdminServicesException Idse; // required
-    public org.apache.airavata.model.error.AuthorizationException ae; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae; // 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 {
@@ -6307,7 +6531,7 @@ public class IamAdminServices {
       IDSE((short)1, "Idse"),
       AE((short)2, "ae");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -6318,6 +6542,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 0: // SUCCESS
@@ -6337,21 +6562,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -6360,7 +6586,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -6374,9 +6600,9 @@ public class IamAdminServices {
       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.BOOL)));
       tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, IamAdminServicesException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
       tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.error.AuthorizationException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.error.AuthorizationException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(registerUser_result.class, metaDataMap);
     }
@@ -6386,8 +6612,8 @@ public class IamAdminServices {
 
     public registerUser_result(
       boolean success,
-      IamAdminServicesException Idse,
-      org.apache.airavata.model.error.AuthorizationException ae)
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse,
+      org.apache.custos.commons.model.error.AuthorizationException ae)
     {
       this();
       this.success = success;
@@ -6403,10 +6629,10 @@ public class IamAdminServices {
       __isset_bitfield = other.__isset_bitfield;
       this.success = other.success;
       if (other.isSetIdse()) {
-        this.Idse = new IamAdminServicesException(other.Idse);
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
       }
       if (other.isSetAe()) {
-        this.ae = new org.apache.airavata.model.error.AuthorizationException(other.ae);
+        this.ae = new org.apache.custos.commons.model.error.AuthorizationException(other.ae);
       }
     }
 
@@ -6445,11 +6671,12 @@ public class IamAdminServices {
       __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
     }
 
-    public IamAdminServicesException getIdse() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
       return this.Idse;
     }
 
-    public registerUser_result setIdse(IamAdminServicesException Idse) {
+    public registerUser_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
       this.Idse = Idse;
       return this;
     }
@@ -6469,11 +6696,12 @@ public class IamAdminServices {
       }
     }
 
-    public org.apache.airavata.model.error.AuthorizationException getAe() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.error.AuthorizationException getAe() {
       return this.ae;
     }
 
-    public registerUser_result setAe(org.apache.airavata.model.error.AuthorizationException ae) {
+    public registerUser_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae) {
       this.ae = ae;
       return this;
     }
@@ -6493,13 +6721,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case SUCCESS:
         if (value == null) {
           unsetSuccess();
         } else {
-          setSuccess((java.lang.Boolean)value);
+          setSuccess((Boolean)value);
         }
         break;
 
@@ -6507,7 +6735,7 @@ public class IamAdminServices {
         if (value == null) {
           unsetIdse();
         } else {
-          setIdse((IamAdminServicesException)value);
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
         }
         break;
 
@@ -6515,14 +6743,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetAe();
         } else {
-          setAe((org.apache.airavata.model.error.AuthorizationException)value);
+          setAe((org.apache.custos.commons.model.error.AuthorizationException)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case SUCCESS:
         return isSuccess();
@@ -6534,13 +6763,13 @@ public class IamAdminServices {
         return getAe();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -6551,11 +6780,11 @@ public class IamAdminServices {
       case AE:
         return isSetAe();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof registerUser_result)
@@ -6624,7 +6853,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
+      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -6634,7 +6863,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
+      lastComparison = Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -6644,7 +6873,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
+      lastComparison = Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -6657,6 +6886,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -6670,8 +6900,8 @@ public class IamAdminServices {
       }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("registerUser_result(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("registerUser_result(");
       boolean first = true;
 
       sb.append("success:");
@@ -6710,7 +6940,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
       try {
         // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
         __isset_bitfield = 0;
@@ -6748,7 +6978,7 @@ public class IamAdminServices {
               break;
             case 1: // IDSE
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.Idse = new IamAdminServicesException();
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
                 struct.Idse.read(iprot);
                 struct.setIdseIsSet(true);
               } else { 
@@ -6757,7 +6987,7 @@ public class IamAdminServices {
               break;
             case 2: // AE
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+                struct.ae = new org.apache.custos.commons.model.error.AuthorizationException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
               } else { 
@@ -6842,12 +7072,12 @@ public class IamAdminServices {
           struct.setSuccessIsSet(true);
         }
         if (incoming.get(1)) {
-          struct.Idse = new IamAdminServicesException();
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
           struct.Idse.read(iprot);
           struct.setIdseIsSet(true);
         }
         if (incoming.get(2)) {
-          struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+          struct.ae = new org.apache.custos.commons.model.error.AuthorizationException();
           struct.ae.read(iprot);
           struct.setAeIsSet(true);
         }
@@ -6868,15 +7098,15 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new enableUser_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new enableUser_argsTupleSchemeFactory();
 
-    public org.apache.airavata.model.security.AuthzToken authzToken; // required
-    public java.lang.String username; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String username; // 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"),
       USERNAME((short)2, "username");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -6887,6 +7117,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 1: // AUTHZ_TOKEN
@@ -6904,21 +7135,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -6927,7 +7159,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -6937,7 +7169,7 @@ public class IamAdminServices {
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
       tmpMap.put(_Fields.USERNAME, 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)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
@@ -6948,8 +7180,8 @@ public class IamAdminServices {
     }
 
     public enableUser_args(
-      org.apache.airavata.model.security.AuthzToken authzToken,
-      java.lang.String username)
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String username)
     {
       this();
       this.authzToken = authzToken;
@@ -6961,7 +7193,7 @@ public class IamAdminServices {
      */
     public enableUser_args(enableUser_args other) {
       if (other.isSetAuthzToken()) {
-        this.authzToken = new org.apache.airavata.model.security.AuthzToken(other.authzToken);
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
       }
       if (other.isSetUsername()) {
         this.username = other.username;
@@ -6978,11 +7210,12 @@ public class IamAdminServices {
       this.username = null;
     }
 
-    public org.apache.airavata.model.security.AuthzToken getAuthzToken() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
       return this.authzToken;
     }
 
-    public enableUser_args setAuthzToken(org.apache.airavata.model.security.AuthzToken authzToken) {
+    public enableUser_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken) {
       this.authzToken = authzToken;
       return this;
     }
@@ -7002,11 +7235,12 @@ public class IamAdminServices {
       }
     }
 
-    public java.lang.String getUsername() {
+    @org.apache.thrift.annotation.Nullable
+    public String getUsername() {
       return this.username;
     }
 
-    public enableUser_args setUsername(java.lang.String username) {
+    public enableUser_args setUsername(@org.apache.thrift.annotation.Nullable String username) {
       this.username = username;
       return this;
     }
@@ -7026,13 +7260,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case AUTHZ_TOKEN:
         if (value == null) {
           unsetAuthzToken();
         } else {
-          setAuthzToken((org.apache.airavata.model.security.AuthzToken)value);
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
         }
         break;
 
@@ -7040,14 +7274,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetUsername();
         } else {
-          setUsername((java.lang.String)value);
+          setUsername((String)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case AUTHZ_TOKEN:
         return getAuthzToken();
@@ -7056,13 +7291,13 @@ public class IamAdminServices {
         return getUsername();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -7071,11 +7306,11 @@ public class IamAdminServices {
       case USERNAME:
         return isSetUsername();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof enableUser_args)
@@ -7133,7 +7368,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
+      lastComparison = Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -7143,7 +7378,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
+      lastComparison = Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -7156,6 +7391,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -7169,8 +7405,8 @@ public class IamAdminServices {
     }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("enableUser_args(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("enableUser_args(");
       boolean first = true;
 
       sb.append("authzToken:");
@@ -7214,7 +7450,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    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) {
@@ -7242,7 +7478,7 @@ public class IamAdminServices {
           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 = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
               } else { 
@@ -7306,7 +7542,7 @@ public class IamAdminServices {
       @Override
       public void read(org.apache.thrift.protocol.TProtocol prot, enableUser_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken = new org.apache.airavata.model.security.AuthzToken();
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
         struct.authzToken.read(iprot);
         struct.setAuthzTokenIsSet(true);
         struct.username = iprot.readString();
@@ -7330,8 +7566,8 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new enableUser_resultTupleSchemeFactory();
 
     public boolean success; // required
-    public IamAdminServicesException Idse; // required
-    public org.apache.airavata.model.error.AuthorizationException ae; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae; // 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 {
@@ -7339,7 +7575,7 @@ public class IamAdminServices {
       IDSE((short)1, "Idse"),
       AE((short)2, "ae");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -7350,6 +7586,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 0: // SUCCESS
@@ -7369,21 +7606,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -7392,7 +7630,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -7406,9 +7644,9 @@ public class IamAdminServices {
       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.BOOL)));
       tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, IamAdminServicesException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
       tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.error.AuthorizationException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.error.AuthorizationException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(enableUser_result.class, metaDataMap);
     }
@@ -7418,8 +7656,8 @@ public class IamAdminServices {
 
     public enableUser_result(
       boolean success,
-      IamAdminServicesException Idse,
-      org.apache.airavata.model.error.AuthorizationException ae)
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse,
+      org.apache.custos.commons.model.error.AuthorizationException ae)
     {
       this();
       this.success = success;
@@ -7435,10 +7673,10 @@ public class IamAdminServices {
       __isset_bitfield = other.__isset_bitfield;
       this.success = other.success;
       if (other.isSetIdse()) {
-        this.Idse = new IamAdminServicesException(other.Idse);
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
       }
       if (other.isSetAe()) {
-        this.ae = new org.apache.airavata.model.error.AuthorizationException(other.ae);
+        this.ae = new org.apache.custos.commons.model.error.AuthorizationException(other.ae);
       }
     }
 
@@ -7477,11 +7715,12 @@ public class IamAdminServices {
       __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
     }
 
-    public IamAdminServicesException getIdse() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
       return this.Idse;
     }
 
-    public enableUser_result setIdse(IamAdminServicesException Idse) {
+    public enableUser_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
       this.Idse = Idse;
       return this;
     }
@@ -7501,11 +7740,12 @@ public class IamAdminServices {
       }
     }
 
-    public org.apache.airavata.model.error.AuthorizationException getAe() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.error.AuthorizationException getAe() {
       return this.ae;
     }
 
-    public enableUser_result setAe(org.apache.airavata.model.error.AuthorizationException ae) {
+    public enableUser_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae) {
       this.ae = ae;
       return this;
     }
@@ -7525,13 +7765,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case SUCCESS:
         if (value == null) {
           unsetSuccess();
         } else {
-          setSuccess((java.lang.Boolean)value);
+          setSuccess((Boolean)value);
         }
         break;
 
@@ -7539,7 +7779,7 @@ public class IamAdminServices {
         if (value == null) {
           unsetIdse();
         } else {
-          setIdse((IamAdminServicesException)value);
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
         }
         break;
 
@@ -7547,14 +7787,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetAe();
         } else {
-          setAe((org.apache.airavata.model.error.AuthorizationException)value);
+          setAe((org.apache.custos.commons.model.error.AuthorizationException)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case SUCCESS:
         return isSuccess();
@@ -7566,13 +7807,13 @@ public class IamAdminServices {
         return getAe();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -7583,11 +7824,11 @@ public class IamAdminServices {
       case AE:
         return isSetAe();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof enableUser_result)
@@ -7656,7 +7897,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
+      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -7666,7 +7907,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
+      lastComparison = Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -7676,7 +7917,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
+      lastComparison = Boolean.valueOf(isSetAe()).compareTo(other.isSetAe());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -7689,6 +7930,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -7702,8 +7944,8 @@ public class IamAdminServices {
       }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("enableUser_result(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("enableUser_result(");
       boolean first = true;
 
       sb.append("success:");
@@ -7742,7 +7984,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
       try {
         // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
         __isset_bitfield = 0;
@@ -7780,7 +8022,7 @@ public class IamAdminServices {
               break;
             case 1: // IDSE
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.Idse = new IamAdminServicesException();
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
                 struct.Idse.read(iprot);
                 struct.setIdseIsSet(true);
               } else { 
@@ -7789,7 +8031,7 @@ public class IamAdminServices {
               break;
             case 2: // AE
               if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-                struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+                struct.ae = new org.apache.custos.commons.model.error.AuthorizationException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
               } else { 
@@ -7874,12 +8116,12 @@ public class IamAdminServices {
           struct.setSuccessIsSet(true);
         }
         if (incoming.get(1)) {
-          struct.Idse = new IamAdminServicesException();
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
           struct.Idse.read(iprot);
           struct.setIdseIsSet(true);
         }
         if (incoming.get(2)) {
-          struct.ae = new org.apache.airavata.model.error.AuthorizationException();
+          struct.ae = new org.apache.custos.commons.model.error.AuthorizationException();
           struct.ae.read(iprot);
           struct.setAeIsSet(true);
         }
@@ -7900,15 +8142,15 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUserEnabled_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUserEnabled_argsTupleSchemeFactory();
 
-    public org.apache.airavata.model.security.AuthzToken authzToken; // required
-    public java.lang.String username; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String username; // 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"),
       USERNAME((short)2, "username");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -7919,6 +8161,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 1: // AUTHZ_TOKEN
@@ -7936,21 +8179,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -7959,7 +8203,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -7969,7 +8213,7 @@ public class IamAdminServices {
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
       tmpMap.put(_Fields.USERNAME, 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)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
@@ -7980,8 +8224,8 @@ public class IamAdminServices {
     }
 
     public isUserEnabled_args(
-      org.apache.airavata.model.security.AuthzToken authzToken,
-      java.lang.String username)
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String username)
     {
       this();
       this.authzToken = authzToken;
@@ -7993,7 +8237,7 @@ public class IamAdminServices {
      */
     public isUserEnabled_args(isUserEnabled_args other) {
       if (other.isSetAuthzToken()) {
-        this.authzToken = new org.apache.airavata.model.security.AuthzToken(other.authzToken);
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
       }
       if (other.isSetUsername()) {
         this.username = other.username;
@@ -8010,11 +8254,12 @@ public class IamAdminServices {
       this.username = null;
     }
 
-    public org.apache.airavata.model.security.AuthzToken getAuthzToken() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
       return this.authzToken;
     }
 
-    public isUserEnabled_args setAuthzToken(org.apache.airavata.model.security.AuthzToken authzToken) {
+    public isUserEnabled_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken) {
       this.authzToken = authzToken;
       return this;
     }
@@ -8034,11 +8279,12 @@ public class IamAdminServices {
       }
     }
 
-    public java.lang.String getUsername() {
+    @org.apache.thrift.annotation.Nullable
+    public String getUsername() {
       return this.username;
     }
 
-    public isUserEnabled_args setUsername(java.lang.String username) {
+    public isUserEnabled_args setUsername(@org.apache.thrift.annotation.Nullable String username) {
       this.username = username;
       return this;
     }
@@ -8058,13 +8304,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case AUTHZ_TOKEN:
         if (value == null) {
           unsetAuthzToken();
         } else {
-          setAuthzToken((org.apache.airavata.model.security.AuthzToken)value);
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
         }
         break;
 
@@ -8072,14 +8318,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetUsername();
         } else {
-          setUsername((java.lang.String)value);
+          setUsername((String)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case AUTHZ_TOKEN:
         return getAuthzToken();
@@ -8088,13 +8335,13 @@ public class IamAdminServices {
         return getUsername();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -8103,11 +8350,11 @@ public class IamAdminServices {
       case USERNAME:
         return isSetUsername();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof isUserEnabled_args)
@@ -8165,7 +8412,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
+      lastComparison = Boolean.valueOf(isSetAuthzToken()).compareTo(other.isSetAuthzToken());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -8175,7 +8422,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
+      lastComparison = Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -8188,6 +8435,7 @@ public class IamAdminServices {
       return 0;
     }
 
+    @org.apache.thrift.annotation.Nullable
     public _Fields fieldForId(int fieldId) {
       return _Fields.findByThriftId(fieldId);
     }
@@ -8201,8 +8449,8 @@ public class IamAdminServices {
     }
 
     @Override
-    public java.lang.String toString() {
-      java.lang.StringBuilder sb = new java.lang.StringBuilder("isUserEnabled_args(");
+    public String toString() {
+      StringBuilder sb = new StringBuilder("isUserEnabled_args(");
       boolean first = true;
 
       sb.append("authzToken:");
@@ -8246,7 +8494,7 @@ public class IamAdminServices {
       }
     }
 
-    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
+    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) {
@@ -8274,7 +8522,7 @@ public class IamAdminServices {
           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 = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
               } else { 
@@ -8338,7 +8586,7 @@ public class IamAdminServices {
       @Override
       public void read(org.apache.thrift.protocol.TProtocol prot, isUserEnabled_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-        struct.authzToken = new org.apache.airavata.model.security.AuthzToken();
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
         struct.authzToken.read(iprot);
         struct.setAuthzTokenIsSet(true);
         struct.username = iprot.readString();
@@ -8362,8 +8610,8 @@ public class IamAdminServices {
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUserEnabled_resultTupleSchemeFactory();
 
     public boolean success; // required
-    public IamAdminServicesException Idse; // required
-    public org.apache.airavata.model.error.AuthorizationException ae; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae; // 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 {
@@ -8371,7 +8619,7 @@ public class IamAdminServices {
       IDSE((short)1, "Idse"),
       AE((short)2, "ae");
 
-      private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
       static {
         for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
@@ -8382,6 +8630,7 @@ public class IamAdminServices {
       /**
        * Find the _Fields constant that matches fieldId, or null if its not found.
        */
+      @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
           case 0: // SUCCESS
@@ -8401,21 +8650,22 @@ public class IamAdminServices {
        */
       public static _Fields findByThriftIdOrThrow(int fieldId) {
         _Fields fields = findByThriftId(fieldId);
-        if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+        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(java.lang.String name) {
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByName(String name) {
         return byName.get(name);
       }
 
       private final short _thriftId;
-      private final java.lang.String _fieldName;
+      private final String _fieldName;
 
-      _Fields(short thriftId, java.lang.String fieldName) {
+      _Fields(short thriftId, String fieldName) {
         _thriftId = thriftId;
         _fieldName = fieldName;
       }
@@ -8424,7 +8674,7 @@ public class IamAdminServices {
         return _thriftId;
       }
 
-      public java.lang.String getFieldName() {
+      public String getFieldName() {
         return _fieldName;
       }
     }
@@ -8438,9 +8688,9 @@ public class IamAdminServices {
       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.BOOL)));
       tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, IamAdminServicesException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
       tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
-          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.airavata.model.error.AuthorizationException.class)));
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.error.AuthorizationException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserEnabled_result.class, metaDataMap);
     }
@@ -8450,8 +8700,8 @@ public class IamAdminServices {
 
     public isUserEnabled_result(
       boolean success,
-      IamAdminServicesException Idse,
-      org.apache.airavata.model.error.AuthorizationException ae)
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse,
+      org.apache.custos.commons.model.error.AuthorizationException ae)
     {
       this();
       this.success = success;
@@ -8467,10 +8717,10 @@ public class IamAdminServices {
       __isset_bitfield = other.__isset_bitfield;
       this.success = other.success;
       if (other.isSetIdse()) {
-        this.Idse = new IamAdminServicesException(other.Idse);
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
       }
       if (other.isSetAe()) {
-        this.ae = new org.apache.airavata.model.error.AuthorizationException(other.ae);
+        this.ae = new org.apache.custos.commons.model.error.AuthorizationException(other.ae);
       }
     }
 
@@ -8509,11 +8759,12 @@ public class IamAdminServices {
       __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
     }
 
-    public IamAdminServicesException getIdse() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
       return this.Idse;
     }
 
-    public isUserEnabled_result setIdse(IamAdminServicesException Idse) {
+    public isUserEnabled_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
       this.Idse = Idse;
       return this;
     }
@@ -8533,11 +8784,12 @@ public class IamAdminServices {
       }
     }
 
-    public org.apache.airavata.model.error.AuthorizationException getAe() {
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.error.AuthorizationException getAe() {
       return this.ae;
     }
 
-    public isUserEnabled_result setAe(org.apache.airavata.model.error.AuthorizationException ae) {
+    public isUserEnabled_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.error.AuthorizationException ae) {
       this.ae = ae;
       return this;
     }
@@ -8557,13 +8809,13 @@ public class IamAdminServices {
       }
     }
 
-    public void setFieldValue(_Fields field, java.lang.Object value) {
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
       case SUCCESS:
         if (value == null) {
           unsetSuccess();
         } else {
-          setSuccess((java.lang.Boolean)value);
+          setSuccess((Boolean)value);
         }
         break;
 
@@ -8571,7 +8823,7 @@ public class IamAdminServices {
         if (value == null) {
           unsetIdse();
         } else {
-          setIdse((IamAdminServicesException)value);
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
         }
         break;
 
@@ -8579,14 +8831,15 @@ public class IamAdminServices {
         if (value == null) {
           unsetAe();
         } else {
-          setAe((org.apache.airavata.model.error.AuthorizationException)value);
+          setAe((org.apache.custos.commons.model.error.AuthorizationException)value);
         }
         break;
 
       }
     }
 
-    public java.lang.Object getFieldValue(_Fields field) {
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
       switch (field) {
       case SUCCESS:
         return isSuccess();
@@ -8598,13 +8851,13 @@ public class IamAdminServices {
         return getAe();
 
       }
-      throw new java.lang.IllegalStateException();
+      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 java.lang.IllegalArgumentException();
+        throw new IllegalArgumentException();
       }
 
       switch (field) {
@@ -8615,11 +8868,11 @@ public class IamAdminServices {
       case AE:
         return isSetAe();
       }
-      throw new java.lang.IllegalStateException();
+      throw new IllegalStateException();
     }
 
     @Override
-    public boolean equals(java.lang.Object that) {
+    public boolean equals(Object that) {
       if (that == null)
         return false;
       if (that instanceof isUserEnabled_result)
@@ -8688,7 +8941,7 @@ public class IamAdminServices {
 
       int lastComparison = 0;
 
-      lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
+      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -8698,7 +8951,7 @@ public class IamAdminServices {
           return lastComparison;
         }
       }
-      lastComparison = java.lang.Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
+      lastComparison = Boolean.valueOf(isSetIdse()).compareTo(other.isSetIdse());
       if (lastComparison != 0) {
         return lastComparison;
       }
@@ -8708,7 +8961,7 @@ public class IamAdminServices {
           return lastComparison;
... 41441 lines suppressed ...


[airavata-custos] 12/48: configuration changes

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 37a182105ec55d485876472c2a94785fb936163c
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Jul 9 11:02:29 2019 -0400

    configuration changes
---
 .../org.apache.custos.security/manager/KeyCloakSecurityManager.java     | 2 +-
 ide-integration/src/main/resources/custos-server.properties             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
index ad058f3..6665c3f 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
@@ -57,7 +57,7 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
     private final static Logger logger = LoggerFactory.getLogger(KeyCloakSecurityManager.class);
     private TenantProfileService.Client tenantProfileClient = null;
     public KeyCloakSecurityManager() throws CustosSecurityException {
-        //initializeSecurityInfra();
+        initializeSecurityInfra();
     }
 
     /**
diff --git a/ide-integration/src/main/resources/custos-server.properties b/ide-integration/src/main/resources/custos-server.properties
index 3741eab..27c5f33 100644
--- a/ide-integration/src/main/resources/custos-server.properties
+++ b/ide-integration/src/main/resources/custos-server.properties
@@ -34,7 +34,7 @@ security.manager.class=org.apache.custos.security.manager.KeyCloakSecurityManage
 ###########################################################################
 # Iam Admin services Configuration
 ###########################################################################
-iam.server.url=https://localhost:8443/auth
+iam.server.url=https://airavata.host:8443/auth
 iam.server.super.admin.username=admin
 iam.server.super.admin.password=admin
 


[airavata-custos] 09/48: added gitignore file

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0a9efcb05b5ceddffce034d241afafcca305a13e
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Jul 8 17:38:50 2019 -0400

    added gitignore file
---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index f2d127f..1864f17 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,5 @@ com_crashlytics_export_strings.xml
 .settings
 .classpath
 .factorypath
+
+.database_data


[airavata-custos] 08/48: added authentication service

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6563e2c7537e2ad5f8f0983e5f2a307062bfe19a
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Jul 8 17:11:25 2019 -0400

    added authentication service
---
 .gitignore                                         |   37 +
 {custos-client => custos-authentication}/pom.xml   |   15 +-
 .../CustosAuthenticationService.java               | 3198 ++++++++++++++++++++
 .../cpi/CustosAuthenticationService.java           | 3198 ++++++++++++++++++++
 .../CustosAuthenticationServiceException.java      |  370 +++
 .../handler/CustosAuthenticationHandler.java       |   57 +
 .../server/CustosAuthenticationServer.java         |  137 +
 custos-client/pom.xml                              |    9 +-
 .../service/AuthenticationServiceClient.java       |   25 +
 ...java => CustosProfileServiceClientFactory.java} |    8 +-
 .../custos/commons/model/security/UserInfo.java    |  875 ++++++
 .../custos/commons/utils/ApplicationSettings.java  |    8 +
 .../custos/commons/utils/ServerSettings.java       |   11 +-
 custos-connectors/pom.xml                          |    6 -
 .../interceptor/SecurityInterceptor.java           |    2 +-
 .../manager/CustosSecurityManager.java             |    6 +-
 .../manager/KeyCloakSecurityManager.java           |   23 +-
 .../manager/UserInfo.java                          |   84 -
 .../handlers/TenantProfileServiceHandler.java      |   15 +-
 .../handlers/UserProfileServiceHandler.java        |   22 +-
 .../profile/server/ProfileServiceServer.java       |    4 +-
 .../client}/ProfileServiceClientFactory.java       |   17 +-
 .../profile/tenant.cpi/TenantProfileService.java   |  140 +-
 pom.xml                                            |    1 +
 .../authentication-service-cpi.thrift              |   14 +
 .../authentication_service_cpi_errors.thrift       |   27 +
 .../custos-apis/userInfo_model.thrift              |   33 +
 .../profile-tenant/profile-tenant-cpi.thrift       |    6 +-
 28 files changed, 8167 insertions(+), 181 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f2d127f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,37 @@
+# From https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
+
+## Directory-based project format
+.idea/
+# if you remove the above rule, at least ignore user-specific stuff:
+# .idea/workspace.xml
+# .idea/tasks.xml
+# and these sensitive or high-churn files:
+# .idea/dataSources.ids
+# .idea/dataSources.xml
+# .idea/sqlDataSources.xml
+# .idea/dynamic.xml
+
+## File-based project format
+*.ipr
+*.iws
+*.iml
+*target
+## Additional for IntelliJ
+out/
+
+# generated by mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# generated by JIRA plugin
+atlassian-ide-plugin.xml
+
+# generated by Crashlytics plugin (for Android Studio and Intellij)
+com_crashlytics_export_strings.xml
+
+.DS_Store
+.project
+.vscode
+.settings
+.classpath
+.factorypath
diff --git a/custos-client/pom.xml b/custos-authentication/pom.xml
similarity index 66%
copy from custos-client/pom.xml
copy to custos-authentication/pom.xml
index cc6d67b..c8f8cf3 100644
--- a/custos-client/pom.xml
+++ b/custos-authentication/pom.xml
@@ -8,19 +8,22 @@
         <version>1.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-authentication</artifactId>
     <dependencies>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>profile-service-stubs</artifactId>
+            <artifactId>custos-commons</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-connectors</artifactId>
             <version>1.0-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
     </dependencies>
-    <properties>
-        <maven.compiler.source>1.8</maven.compiler.source>
-        <maven.compiler.target>1.8</maven.compiler.target>
-    </properties>
-    <artifactId>custos-client</artifactId>
 
 
 </project>
\ No newline at end of file
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/CustosAuthenticationService.java b/custos-authentication/src/main/java/org/apache/custos/authentication/CustosAuthenticationService.java
new file mode 100644
index 0000000..115c3e3
--- /dev/null
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/CustosAuthenticationService.java
@@ -0,0 +1,3198 @@
+/**
+ * Autogenerated by Thrift Compiler (0.12.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.authentication;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-08")
+public class CustosAuthenticationService {
+
+  public interface Iface {
+
+    public boolean isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
+
+    public org.apache.custos.commons.model.security.UserInfo getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
+
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
+
+  }
+
+  public interface AsyncIface {
+
+    public void isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException;
+
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException;
+
+  }
+
+  public static class Client extends org.apache.thrift.TServiceClient implements Iface {
+    public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {
+      public Factory() {}
+      public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
+        return new Client(prot);
+      }
+      public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
+        return new Client(iprot, oprot);
+      }
+    }
+
+    public Client(org.apache.thrift.protocol.TProtocol prot)
+    {
+      super(prot, prot);
+    }
+
+    public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
+      super(iprot, oprot);
+    }
+
+    public boolean isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      send_isUserAuthenticated(authzToken);
+      return recv_isUserAuthenticated();
+    }
+
+    public void send_isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.thrift.TException
+    {
+      isUserAuthenticated_args args = new isUserAuthenticated_args();
+      args.setAuthzToken(authzToken);
+      sendBase("isUserAuthenticated", args);
+    }
+
+    public boolean recv_isUserAuthenticated() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      isUserAuthenticated_result result = new isUserAuthenticated_result();
+      receiveBase(result, "isUserAuthenticated");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.ae != null) {
+        throw result.ae;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isUserAuthenticated failed: unknown result");
+    }
+
+    public org.apache.custos.commons.model.security.UserInfo getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      send_getUserInfoFromAuthzToken(authzToken);
+      return recv_getUserInfoFromAuthzToken();
+    }
+
+    public void send_getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.thrift.TException
+    {
+      getUserInfoFromAuthzToken_args args = new getUserInfoFromAuthzToken_args();
+      args.setAuthzToken(authzToken);
+      sendBase("getUserInfoFromAuthzToken", args);
+    }
+
+    public org.apache.custos.commons.model.security.UserInfo recv_getUserInfoFromAuthzToken() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
+      receiveBase(result, "getUserInfoFromAuthzToken");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.ae != null) {
+        throw result.ae;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserInfoFromAuthzToken failed: unknown result");
+    }
+
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      send_getUserManagementServiceAccountAuthzToken(authzToken, gatewayId);
+      return recv_getUserManagementServiceAccountAuthzToken();
+    }
+
+    public void send_getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.thrift.TException
+    {
+      getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
+      args.setAuthzToken(authzToken);
+      args.setGatewayId(gatewayId);
+      sendBase("getUserManagementServiceAccountAuthzToken", args);
+    }
+
+    public org.apache.custos.commons.model.security.AuthzToken recv_getUserManagementServiceAccountAuthzToken() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
+      receiveBase(result, "getUserManagementServiceAccountAuthzToken");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.ae != null) {
+        throw result.ae;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserManagementServiceAccountAuthzToken failed: unknown result");
+    }
+
+  }
+  public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
+    public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
+      private org.apache.thrift.async.TAsyncClientManager clientManager;
+      private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
+      public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
+        this.clientManager = clientManager;
+        this.protocolFactory = protocolFactory;
+      }
+      public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
+        return new AsyncClient(protocolFactory, clientManager, transport);
+      }
+    }
+
+    public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
+      super(protocolFactory, clientManager, transport);
+    }
+
+    public void isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      isUserAuthenticated_call method_call = new isUserAuthenticated_call(authzToken, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class isUserAuthenticated_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      public isUserAuthenticated_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("isUserAuthenticated", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        isUserAuthenticated_args args = new isUserAuthenticated_args();
+        args.setAuthzToken(authzToken);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException {
+        if (getState() != 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_isUserAuthenticated();
+      }
+    }
+
+    public void getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      getUserInfoFromAuthzToken_call method_call = new getUserInfoFromAuthzToken_call(authzToken, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class getUserInfoFromAuthzToken_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.commons.model.security.UserInfo> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      public getUserInfoFromAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> 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;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUserInfoFromAuthzToken", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        getUserInfoFromAuthzToken_args args = new getUserInfoFromAuthzToken_args();
+        args.setAuthzToken(authzToken);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public org.apache.custos.commons.model.security.UserInfo getResult() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException {
+        if (getState() != 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_getUserInfoFromAuthzToken();
+      }
+    }
+
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      getUserManagementServiceAccountAuthzToken_call method_call = new getUserManagementServiceAccountAuthzToken_call(authzToken, gatewayId, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class getUserManagementServiceAccountAuthzToken_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.commons.model.security.AuthzToken> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String gatewayId;
+      public getUserManagementServiceAccountAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> 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;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUserManagementServiceAccountAuthzToken", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
+        args.setAuthzToken(authzToken);
+        args.setGatewayId(gatewayId);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public org.apache.custos.commons.model.security.AuthzToken getResult() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException {
+        if (getState() != 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_getUserManagementServiceAccountAuthzToken();
+      }
+    }
+
+  }
+
+  public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
+    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName());
+    public Processor(I iface) {
+      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
+    }
+
+    protected Processor(I iface, java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
+      super(iface, getProcessMap(processMap));
+    }
+
+    private static <I extends Iface> java.util.Map<String,  org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {
+      processMap.put("isUserAuthenticated", new isUserAuthenticated());
+      processMap.put("getUserInfoFromAuthzToken", new getUserInfoFromAuthzToken());
+      processMap.put("getUserManagementServiceAccountAuthzToken", new getUserManagementServiceAccountAuthzToken());
+      return processMap;
+    }
+
+    public static class isUserAuthenticated<I extends Iface> extends org.apache.thrift.ProcessFunction<I, isUserAuthenticated_args> {
+      public isUserAuthenticated() {
+        super("isUserAuthenticated");
+      }
+
+      public isUserAuthenticated_args getEmptyArgsInstance() {
+        return new isUserAuthenticated_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public isUserAuthenticated_result getResult(I iface, isUserAuthenticated_args args) throws org.apache.thrift.TException {
+        isUserAuthenticated_result result = new isUserAuthenticated_result();
+        try {
+          result.success = iface.isUserAuthenticated(args.authzToken);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+          result.ae = ae;
+        }
+        return result;
+      }
+    }
+
+    public static class getUserInfoFromAuthzToken<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUserInfoFromAuthzToken_args> {
+      public getUserInfoFromAuthzToken() {
+        super("getUserInfoFromAuthzToken");
+      }
+
+      public getUserInfoFromAuthzToken_args getEmptyArgsInstance() {
+        return new getUserInfoFromAuthzToken_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public getUserInfoFromAuthzToken_result getResult(I iface, getUserInfoFromAuthzToken_args args) throws org.apache.thrift.TException {
+        getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
+        try {
+          result.success = iface.getUserInfoFromAuthzToken(args.authzToken);
+        } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+          result.ae = ae;
+        }
+        return result;
+      }
+    }
+
+    public static class getUserManagementServiceAccountAuthzToken<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUserManagementServiceAccountAuthzToken_args> {
+      public getUserManagementServiceAccountAuthzToken() {
+        super("getUserManagementServiceAccountAuthzToken");
+      }
+
+      public getUserManagementServiceAccountAuthzToken_args getEmptyArgsInstance() {
+        return new getUserManagementServiceAccountAuthzToken_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public getUserManagementServiceAccountAuthzToken_result getResult(I iface, getUserManagementServiceAccountAuthzToken_args args) throws org.apache.thrift.TException {
+        getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
+        try {
+          result.success = iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId);
+        } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+          result.ae = ae;
+        }
+        return result;
+      }
+    }
+
+  }
+
+  public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
+    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName());
+    public AsyncProcessor(I iface) {
+      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
+    }
+
+    protected AsyncProcessor(I iface, java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
+      super(iface, getProcessMap(processMap));
+    }
+
+    private static <I extends AsyncIface> java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
+      processMap.put("isUserAuthenticated", new isUserAuthenticated());
+      processMap.put("getUserInfoFromAuthzToken", new getUserInfoFromAuthzToken());
+      processMap.put("getUserManagementServiceAccountAuthzToken", new getUserManagementServiceAccountAuthzToken());
+      return processMap;
+    }
+
+    public static class isUserAuthenticated<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUserAuthenticated_args, Boolean> {
+      public isUserAuthenticated() {
+        super("isUserAuthenticated");
+      }
+
+      public isUserAuthenticated_args getEmptyArgsInstance() {
+        return new isUserAuthenticated_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            isUserAuthenticated_result result = new isUserAuthenticated_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            isUserAuthenticated_result result = new isUserAuthenticated_result();
+            if (e instanceof org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) {
+              result.ae = (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) e;
+              result.setAeIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, isUserAuthenticated_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.isUserAuthenticated(args.authzToken,resultHandler);
+      }
+    }
+
+    public static class getUserInfoFromAuthzToken<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUserInfoFromAuthzToken_args, org.apache.custos.commons.model.security.UserInfo> {
+      public getUserInfoFromAuthzToken() {
+        super("getUserInfoFromAuthzToken");
+      }
+
+      public getUserInfoFromAuthzToken_args getEmptyArgsInstance() {
+        return new getUserInfoFromAuthzToken_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo>() { 
+          public void onComplete(org.apache.custos.commons.model.security.UserInfo o) {
+            getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
+            if (e instanceof org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) {
+              result.ae = (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) e;
+              result.setAeIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, getUserInfoFromAuthzToken_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException {
+        iface.getUserInfoFromAuthzToken(args.authzToken,resultHandler);
+      }
+    }
+
+    public static class getUserManagementServiceAccountAuthzToken<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUserManagementServiceAccountAuthzToken_args, org.apache.custos.commons.model.security.AuthzToken> {
+      public getUserManagementServiceAccountAuthzToken() {
+        super("getUserManagementServiceAccountAuthzToken");
+      }
+
+      public getUserManagementServiceAccountAuthzToken_args getEmptyArgsInstance() {
+        return new getUserManagementServiceAccountAuthzToken_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken>() { 
+          public void onComplete(org.apache.custos.commons.model.security.AuthzToken o) {
+            getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
+            if (e instanceof org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) {
+              result.ae = (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) e;
+              result.setAeIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, getUserManagementServiceAccountAuthzToken_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
+        iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId,resultHandler);
+      }
+    }
+
+  }
+
+  public static class isUserAuthenticated_args implements org.apache.thrift.TBase<isUserAuthenticated_args, isUserAuthenticated_args._Fields>, java.io.Serializable, Cloneable, Comparable<isUserAuthenticated_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isUserAuthenticated_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUserAuthenticated_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUserAuthenticated_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // 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");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_args.class, metaDataMap);
+    }
+
+    public isUserAuthenticated_args() {
+    }
+
+    public isUserAuthenticated_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken)
+    {
+      this();
+      this.authzToken = authzToken;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public isUserAuthenticated_args(isUserAuthenticated_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+    }
+
+    public isUserAuthenticated_args deepCopy() {
+      return new isUserAuthenticated_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public isUserAuthenticated_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      }
+      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();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof isUserAuthenticated_args)
+        return this.equals((isUserAuthenticated_args)that);
+      return false;
+    }
+
+    public boolean equals(isUserAuthenticated_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(isUserAuthenticated_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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("isUserAuthenticated_args(");
+      boolean first = true;
+
+      sb.append("authzToken:");
+      if (this.authzToken == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.authzToken);
+      }
+      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());
+      }
+      // 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 isUserAuthenticated_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUserAuthenticated_argsStandardScheme getScheme() {
+        return new isUserAuthenticated_argsStandardScheme();
+      }
+    }
+
+    private static class isUserAuthenticated_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<isUserAuthenticated_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, isUserAuthenticated_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.custos.commons.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(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, isUserAuthenticated_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();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class isUserAuthenticated_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUserAuthenticated_argsTupleScheme getScheme() {
+        return new isUserAuthenticated_argsTupleScheme();
+      }
+    }
+
+    private static class isUserAuthenticated_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<isUserAuthenticated_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class isUserAuthenticated_result implements org.apache.thrift.TBase<isUserAuthenticated_result, isUserAuthenticated_result._Fields>, java.io.Serializable, Cloneable, Comparable<isUserAuthenticated_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isUserAuthenticated_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0);
+    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUserAuthenticated_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUserAuthenticated_resultTupleSchemeFactory();
+
+    public boolean success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae; // 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"),
+      AE((short)1, "ae");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // AE
+            return AE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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
+    private static final int __SUCCESS_ISSET_ID = 0;
+    private byte __isset_bitfield = 0;
+    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.BOOL)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_result.class, metaDataMap);
+    }
+
+    public isUserAuthenticated_result() {
+    }
+
+    public isUserAuthenticated_result(
+      boolean success,
+      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+    {
+      this();
+      this.success = success;
+      setSuccessIsSet(true);
+      this.ae = ae;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public isUserAuthenticated_result(isUserAuthenticated_result other) {
+      __isset_bitfield = other.__isset_bitfield;
+      this.success = other.success;
+      if (other.isSetAe()) {
+        this.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException(other.ae);
+      }
+    }
+
+    public isUserAuthenticated_result deepCopy() {
+      return new isUserAuthenticated_result(this);
+    }
+
+    @Override
+    public void clear() {
+      setSuccessIsSet(false);
+      this.success = false;
+      this.ae = null;
+    }
+
+    public boolean isSuccess() {
+      return this.success;
+    }
+
+    public isUserAuthenticated_result setSuccess(boolean success) {
+      this.success = success;
+      setSuccessIsSet(true);
+      return this;
+    }
+
+    public void unsetSuccess() {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    /** Returns true if field success is set (has been assigned a value) and false otherwise */
+    public boolean isSetSuccess() {
+      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    public void setSuccessIsSet(boolean value) {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException getAe() {
+      return this.ae;
+    }
+
+    public isUserAuthenticated_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+      this.ae = ae;
+      return this;
+    }
+
+    public void unsetAe() {
+      this.ae = null;
+    }
+
+    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
+    public boolean isSetAe() {
+      return this.ae != null;
+    }
+
+    public void setAeIsSet(boolean value) {
+      if (!value) {
+        this.ae = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((Boolean)value);
+        }
+        break;
+
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return isSuccess();
+
+      case AE:
+        return getAe();
+
+      }
+      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 AE:
+        return isSetAe();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof isUserAuthenticated_result)
+        return this.equals((isUserAuthenticated_result)that);
+      return false;
+    }
+
+    public boolean equals(isUserAuthenticated_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      boolean this_present_success = true;
+      boolean that_present_success = true;
+      if (this_present_success || that_present_success) {
+        if (!(this_present_success && that_present_success))
+          return false;
+        if (this.success != that.success)
+          return false;
+      }
+
+      boolean this_present_ae = true && this.isSetAe();
+      boolean that_present_ae = true && that.isSetAe();
+      if (this_present_ae || that_present_ae) {
+        if (!(this_present_ae && that_present_ae))
+          return false;
+        if (!this.ae.equals(that.ae))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((success) ? 131071 : 524287);
+
+      hashCode = hashCode * 8191 + ((isSetAe()) ? 131071 : 524287);
+      if (isSetAe())
+        hashCode = hashCode * 8191 + ae.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(isUserAuthenticated_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(isSetAe()).compareTo(other.isSetAe());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetAe()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("isUserAuthenticated_result(");
+      boolean first = true;
+
+      sb.append("success:");
+      sb.append(this.success);
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("ae:");
+      if (this.ae == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ae);
+      }
+      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 {
+        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+        __isset_bitfield = 0;
+        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 isUserAuthenticated_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUserAuthenticated_resultStandardScheme getScheme() {
+        return new isUserAuthenticated_resultStandardScheme();
+      }
+    }
+
+    private static class isUserAuthenticated_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<isUserAuthenticated_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, isUserAuthenticated_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.BOOL) {
+                struct.success = iprot.readBool();
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // AE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+                struct.ae.read(iprot);
+                struct.setAeIsSet(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, isUserAuthenticated_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.isSetSuccess()) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          oprot.writeBool(struct.success);
+          oprot.writeFieldEnd();
+        }
+        if (struct.ae != null) {
+          oprot.writeFieldBegin(AE_FIELD_DESC);
+          struct.ae.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class isUserAuthenticated_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUserAuthenticated_resultTupleScheme getScheme() {
+        return new isUserAuthenticated_resultTupleScheme();
+      }
+    }
+
+    private static class isUserAuthenticated_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<isUserAuthenticated_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetAe()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          oprot.writeBool(struct.success);
+        }
+        if (struct.isSetAe()) {
+          struct.ae.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = iprot.readBool();
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+          struct.ae.read(iprot);
+          struct.setAeIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getUserInfoFromAuthzToken_args implements org.apache.thrift.TBase<getUserInfoFromAuthzToken_args, getUserInfoFromAuthzToken_args._Fields>, java.io.Serializable, Cloneable, Comparable<getUserInfoFromAuthzToken_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserInfoFromAuthzToken_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserInfoFromAuthzToken_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserInfoFromAuthzToken_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // 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");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_args.class, metaDataMap);
+    }
+
+    public getUserInfoFromAuthzToken_args() {
+    }
+
+    public getUserInfoFromAuthzToken_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken)
+    {
+      this();
+      this.authzToken = authzToken;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getUserInfoFromAuthzToken_args(getUserInfoFromAuthzToken_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+    }
+
+    public getUserInfoFromAuthzToken_args deepCopy() {
+      return new getUserInfoFromAuthzToken_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public getUserInfoFromAuthzToken_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      }
+      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();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getUserInfoFromAuthzToken_args)
+        return this.equals((getUserInfoFromAuthzToken_args)that);
+      return false;
+    }
+
+    public boolean equals(getUserInfoFromAuthzToken_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getUserInfoFromAuthzToken_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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getUserInfoFromAuthzToken_args(");
+      boolean first = true;
+
+      sb.append("authzToken:");
+      if (this.authzToken == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.authzToken);
+      }
+      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());
+      }
+      // 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 getUserInfoFromAuthzToken_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserInfoFromAuthzToken_argsStandardScheme getScheme() {
+        return new getUserInfoFromAuthzToken_argsStandardScheme();
+      }
+    }
+
+    private static class getUserInfoFromAuthzToken_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserInfoFromAuthzToken_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserInfoFromAuthzToken_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.custos.commons.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(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, getUserInfoFromAuthzToken_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();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getUserInfoFromAuthzToken_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserInfoFromAuthzToken_argsTupleScheme getScheme() {
+        return new getUserInfoFromAuthzToken_argsTupleScheme();
+      }
+    }
+
+    private static class getUserInfoFromAuthzToken_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserInfoFromAuthzToken_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getUserInfoFromAuthzToken_result implements org.apache.thrift.TBase<getUserInfoFromAuthzToken_result, getUserInfoFromAuthzToken_result._Fields>, java.io.Serializable, Cloneable, Comparable<getUserInfoFromAuthzToken_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserInfoFromAuthzToken_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserInfoFromAuthzToken_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserInfoFromAuthzToken_resultTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.UserInfo success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae; // 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"),
+      AE((short)1, "ae");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // AE
+            return AE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.UserInfo.class)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_result.class, metaDataMap);
+    }
+
+    public getUserInfoFromAuthzToken_result() {
+    }
+
+    public getUserInfoFromAuthzToken_result(
+      org.apache.custos.commons.model.security.UserInfo success,
+      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+    {
+      this();
+      this.success = success;
+      this.ae = ae;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getUserInfoFromAuthzToken_result(getUserInfoFromAuthzToken_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new org.apache.custos.commons.model.security.UserInfo(other.success);
+      }
+      if (other.isSetAe()) {
+        this.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException(other.ae);
+      }
+    }
+
+    public getUserInfoFromAuthzToken_result deepCopy() {
+      return new getUserInfoFromAuthzToken_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+      this.ae = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.UserInfo getSuccess() {
+      return this.success;
+    }
+
+    public getUserInfoFromAuthzToken_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.UserInfo 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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException getAe() {
+      return this.ae;
+    }
+
+    public getUserInfoFromAuthzToken_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+      this.ae = ae;
+      return this;
+    }
+
+    public void unsetAe() {
+      this.ae = null;
+    }
+
+    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
+    public boolean isSetAe() {
+      return this.ae != null;
+    }
+
+    public void setAeIsSet(boolean value) {
+      if (!value) {
+        this.ae = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.custos.commons.model.security.UserInfo)value);
+        }
+        break;
+
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      case AE:
+        return getAe();
+
+      }
+      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 AE:
+        return isSetAe();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getUserInfoFromAuthzToken_result)
+        return this.equals((getUserInfoFromAuthzToken_result)that);
+      return false;
+    }
+
+    public boolean equals(getUserInfoFromAuthzToken_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_ae = true && this.isSetAe();
+      boolean that_present_ae = true && that.isSetAe();
+      if (this_present_ae || that_present_ae) {
+        if (!(this_present_ae && that_present_ae))
+          return false;
+        if (!this.ae.equals(that.ae))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
+      if (isSetSuccess())
+        hashCode = hashCode * 8191 + success.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetAe()) ? 131071 : 524287);
+      if (isSetAe())
+        hashCode = hashCode * 8191 + ae.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getUserInfoFromAuthzToken_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(isSetAe()).compareTo(other.isSetAe());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetAe()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getUserInfoFromAuthzToken_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("ae:");
+      if (this.ae == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ae);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws org.apache.thrift.TException {
+      // check for required fields
+      // check for sub-struct validity
+      if (success != null) {
+        success.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 getUserInfoFromAuthzToken_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserInfoFromAuthzToken_resultStandardScheme getScheme() {
+        return new getUserInfoFromAuthzToken_resultStandardScheme();
+      }
+    }
+
+    private static class getUserInfoFromAuthzToken_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserInfoFromAuthzToken_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserInfoFromAuthzToken_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.STRUCT) {
+                struct.success = new org.apache.custos.commons.model.security.UserInfo();
+                struct.success.read(iprot);
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // AE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+                struct.ae.read(iprot);
+                struct.setAeIsSet(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, getUserInfoFromAuthzToken_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.success != null) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          struct.success.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        if (struct.ae != null) {
+          oprot.writeFieldBegin(AE_FIELD_DESC);
+          struct.ae.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getUserInfoFromAuthzToken_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserInfoFromAuthzToken_resultTupleScheme getScheme() {
+        return new getUserInfoFromAuthzToken_resultTupleScheme();
+      }
+    }
+
+    private static class getUserInfoFromAuthzToken_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserInfoFromAuthzToken_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetAe()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          struct.success.write(oprot);
+        }
+        if (struct.isSetAe()) {
+          struct.ae.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = new org.apache.custos.commons.model.security.UserInfo();
+          struct.success.read(iprot);
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+          struct.ae.read(iprot);
+          struct.setAeIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getUserManagementServiceAccountAuthzToken_args implements org.apache.thrift.TBase<getUserManagementServiceAccountAuthzToken_args, getUserManagementServiceAccountAuthzToken_args._Fields>, java.io.Serializable, Cloneable, Comparable<getUserManagementServiceAccountAuthzToken_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserManagementServiceAccountAuthzToken_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String gatewayId; // 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");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          case 2: // GATEWAY_ID
+            return GATEWAY_ID;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.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)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_args.class, metaDataMap);
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args() {
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String gatewayId)
+    {
+      this();
+      this.authzToken = authzToken;
+      this.gatewayId = gatewayId;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getUserManagementServiceAccountAuthzToken_args(getUserManagementServiceAccountAuthzToken_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+      if (other.isSetGatewayId()) {
+        this.gatewayId = other.gatewayId;
+      }
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args deepCopy() {
+      return new getUserManagementServiceAccountAuthzToken_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+      this.gatewayId = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getGatewayId() {
+      return this.gatewayId;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args setGatewayId(@org.apache.thrift.annotation.Nullable 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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case GATEWAY_ID:
+        if (value == null) {
+          unsetGatewayId();
+        } else {
+          setGatewayId((String)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      case GATEWAY_ID:
+        return getGatewayId();
+
+      }
+      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();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getUserManagementServiceAccountAuthzToken_args)
+        return this.equals((getUserManagementServiceAccountAuthzToken_args)that);
+      return false;
+    }
+
+    public boolean equals(getUserManagementServiceAccountAuthzToken_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetGatewayId()) ? 131071 : 524287);
+      if (isSetGatewayId())
+        hashCode = hashCode * 8191 + gatewayId.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getUserManagementServiceAccountAuthzToken_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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getUserManagementServiceAccountAuthzToken_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;
+      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());
+      }
+      // 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 getUserManagementServiceAccountAuthzToken_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserManagementServiceAccountAuthzToken_argsStandardScheme getScheme() {
+        return new getUserManagementServiceAccountAuthzToken_argsStandardScheme();
+      }
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserManagementServiceAccountAuthzToken_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserManagementServiceAccountAuthzToken_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.custos.commons.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;
+            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, getUserManagementServiceAccountAuthzToken_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();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserManagementServiceAccountAuthzToken_argsTupleScheme getScheme() {
+        return new getUserManagementServiceAccountAuthzToken_argsTupleScheme();
+      }
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserManagementServiceAccountAuthzToken_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+        oprot.writeString(struct.gatewayId);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+        struct.gatewayId = iprot.readString();
+        struct.setGatewayIdIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getUserManagementServiceAccountAuthzToken_result implements org.apache.thrift.TBase<getUserManagementServiceAccountAuthzToken_result, getUserManagementServiceAccountAuthzToken_result._Fields>, java.io.Serializable, Cloneable, Comparable<getUserManagementServiceAccountAuthzToken_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserManagementServiceAccountAuthzToken_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_resultTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae; // 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"),
+      AE((short)1, "ae");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // AE
+            return AE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_result.class, metaDataMap);
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result() {
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result(
+      org.apache.custos.commons.model.security.AuthzToken success,
+      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+    {
+      this();
+      this.success = success;
+      this.ae = ae;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getUserManagementServiceAccountAuthzToken_result(getUserManagementServiceAccountAuthzToken_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new org.apache.custos.commons.model.security.AuthzToken(other.success);
+      }
+      if (other.isSetAe()) {
+        this.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException(other.ae);
+      }
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result deepCopy() {
+      return new getUserManagementServiceAccountAuthzToken_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+      this.ae = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getSuccess() {
+      return this.success;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken 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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException getAe() {
+      return this.ae;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+      this.ae = ae;
+      return this;
+    }
+
+    public void unsetAe() {
+      this.ae = null;
+    }
+
+    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
+    public boolean isSetAe() {
+      return this.ae != null;
+    }
+
+    public void setAeIsSet(boolean value) {
+      if (!value) {
+        this.ae = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      case AE:
+        return getAe();
+
+      }
+      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 AE:
+        return isSetAe();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getUserManagementServiceAccountAuthzToken_result)
+        return this.equals((getUserManagementServiceAccountAuthzToken_result)that);
+      return false;
+    }
+
+    public boolean equals(getUserManagementServiceAccountAuthzToken_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_ae = true && this.isSetAe();
+      boolean that_present_ae = true && that.isSetAe();
+      if (this_present_ae || that_present_ae) {
+        if (!(this_present_ae && that_present_ae))
+          return false;
+        if (!this.ae.equals(that.ae))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
+      if (isSetSuccess())
+        hashCode = hashCode * 8191 + success.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetAe()) ? 131071 : 524287);
+      if (isSetAe())
+        hashCode = hashCode * 8191 + ae.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getUserManagementServiceAccountAuthzToken_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(isSetAe()).compareTo(other.isSetAe());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetAe()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getUserManagementServiceAccountAuthzToken_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("ae:");
+      if (this.ae == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ae);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws org.apache.thrift.TException {
+      // check for required fields
+      // check for sub-struct validity
+      if (success != null) {
+        success.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 getUserManagementServiceAccountAuthzToken_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserManagementServiceAccountAuthzToken_resultStandardScheme getScheme() {
+        return new getUserManagementServiceAccountAuthzToken_resultStandardScheme();
+      }
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserManagementServiceAccountAuthzToken_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserManagementServiceAccountAuthzToken_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.STRUCT) {
+                struct.success = new org.apache.custos.commons.model.security.AuthzToken();
+                struct.success.read(iprot);
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // AE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+                struct.ae.read(iprot);
+                struct.setAeIsSet(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, getUserManagementServiceAccountAuthzToken_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.success != null) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          struct.success.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        if (struct.ae != null) {
+          oprot.writeFieldBegin(AE_FIELD_DESC);
+          struct.ae.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserManagementServiceAccountAuthzToken_resultTupleScheme getScheme() {
+        return new getUserManagementServiceAccountAuthzToken_resultTupleScheme();
+      }
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserManagementServiceAccountAuthzToken_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetAe()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          struct.success.write(oprot);
+        }
+        if (struct.isSetAe()) {
+          struct.ae.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = new org.apache.custos.commons.model.security.AuthzToken();
+          struct.success.read(iprot);
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+          struct.ae.read(iprot);
+          struct.setAeIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+}
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
new file mode 100644
index 0000000..9c4b981
--- /dev/null
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
@@ -0,0 +1,3198 @@
+/**
+ * Autogenerated by Thrift Compiler (0.12.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.authentication.cpi;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-08")
+public class CustosAuthenticationService {
+
+  public interface Iface {
+
+    public boolean isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
+
+    public org.apache.custos.commons.model.security.UserInfo getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
+
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException;
+
+  }
+
+  public interface AsyncIface {
+
+    public void isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException;
+
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException;
+
+  }
+
+  public static class Client extends org.apache.thrift.TServiceClient implements Iface {
+    public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {
+      public Factory() {}
+      public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
+        return new Client(prot);
+      }
+      public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
+        return new Client(iprot, oprot);
+      }
+    }
+
+    public Client(org.apache.thrift.protocol.TProtocol prot)
+    {
+      super(prot, prot);
+    }
+
+    public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
+      super(iprot, oprot);
+    }
+
+    public boolean isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      send_isUserAuthenticated(authzToken);
+      return recv_isUserAuthenticated();
+    }
+
+    public void send_isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.thrift.TException
+    {
+      isUserAuthenticated_args args = new isUserAuthenticated_args();
+      args.setAuthzToken(authzToken);
+      sendBase("isUserAuthenticated", args);
+    }
+
+    public boolean recv_isUserAuthenticated() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      isUserAuthenticated_result result = new isUserAuthenticated_result();
+      receiveBase(result, "isUserAuthenticated");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.ae != null) {
+        throw result.ae;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isUserAuthenticated failed: unknown result");
+    }
+
+    public org.apache.custos.commons.model.security.UserInfo getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      send_getUserInfoFromAuthzToken(authzToken);
+      return recv_getUserInfoFromAuthzToken();
+    }
+
+    public void send_getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken) throws org.apache.thrift.TException
+    {
+      getUserInfoFromAuthzToken_args args = new getUserInfoFromAuthzToken_args();
+      args.setAuthzToken(authzToken);
+      sendBase("getUserInfoFromAuthzToken", args);
+    }
+
+    public org.apache.custos.commons.model.security.UserInfo recv_getUserInfoFromAuthzToken() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
+      receiveBase(result, "getUserInfoFromAuthzToken");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.ae != null) {
+        throw result.ae;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserInfoFromAuthzToken failed: unknown result");
+    }
+
+    public org.apache.custos.commons.model.security.AuthzToken getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      send_getUserManagementServiceAccountAuthzToken(authzToken, gatewayId);
+      return recv_getUserManagementServiceAccountAuthzToken();
+    }
+
+    public void send_getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.thrift.TException
+    {
+      getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
+      args.setAuthzToken(authzToken);
+      args.setGatewayId(gatewayId);
+      sendBase("getUserManagementServiceAccountAuthzToken", args);
+    }
+
+    public org.apache.custos.commons.model.security.AuthzToken recv_getUserManagementServiceAccountAuthzToken() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException
+    {
+      getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
+      receiveBase(result, "getUserManagementServiceAccountAuthzToken");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.ae != null) {
+        throw result.ae;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserManagementServiceAccountAuthzToken failed: unknown result");
+    }
+
+  }
+  public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
+    public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
+      private org.apache.thrift.async.TAsyncClientManager clientManager;
+      private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
+      public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
+        this.clientManager = clientManager;
+        this.protocolFactory = protocolFactory;
+      }
+      public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
+        return new AsyncClient(protocolFactory, clientManager, transport);
+      }
+    }
+
+    public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
+      super(protocolFactory, clientManager, transport);
+    }
+
+    public void isUserAuthenticated(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      isUserAuthenticated_call method_call = new isUserAuthenticated_call(authzToken, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class isUserAuthenticated_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      public isUserAuthenticated_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("isUserAuthenticated", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        isUserAuthenticated_args args = new isUserAuthenticated_args();
+        args.setAuthzToken(authzToken);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException {
+        if (getState() != 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_isUserAuthenticated();
+      }
+    }
+
+    public void getUserInfoFromAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      getUserInfoFromAuthzToken_call method_call = new getUserInfoFromAuthzToken_call(authzToken, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class getUserInfoFromAuthzToken_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.commons.model.security.UserInfo> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      public getUserInfoFromAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> 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;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUserInfoFromAuthzToken", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        getUserInfoFromAuthzToken_args args = new getUserInfoFromAuthzToken_args();
+        args.setAuthzToken(authzToken);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public org.apache.custos.commons.model.security.UserInfo getResult() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException {
+        if (getState() != 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_getUserInfoFromAuthzToken();
+      }
+    }
+
+    public void getUserManagementServiceAccountAuthzToken(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      getUserManagementServiceAccountAuthzToken_call method_call = new getUserManagementServiceAccountAuthzToken_call(authzToken, gatewayId, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class getUserManagementServiceAccountAuthzToken_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.commons.model.security.AuthzToken> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String gatewayId;
+      public getUserManagementServiceAccountAuthzToken_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> 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;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUserManagementServiceAccountAuthzToken", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        getUserManagementServiceAccountAuthzToken_args args = new getUserManagementServiceAccountAuthzToken_args();
+        args.setAuthzToken(authzToken);
+        args.setGatewayId(gatewayId);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public org.apache.custos.commons.model.security.AuthzToken getResult() throws org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException, org.apache.thrift.TException {
+        if (getState() != 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_getUserManagementServiceAccountAuthzToken();
+      }
+    }
+
+  }
+
+  public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
+    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName());
+    public Processor(I iface) {
+      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
+    }
+
+    protected Processor(I iface, java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
+      super(iface, getProcessMap(processMap));
+    }
+
+    private static <I extends Iface> java.util.Map<String,  org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {
+      processMap.put("isUserAuthenticated", new isUserAuthenticated());
+      processMap.put("getUserInfoFromAuthzToken", new getUserInfoFromAuthzToken());
+      processMap.put("getUserManagementServiceAccountAuthzToken", new getUserManagementServiceAccountAuthzToken());
+      return processMap;
+    }
+
+    public static class isUserAuthenticated<I extends Iface> extends org.apache.thrift.ProcessFunction<I, isUserAuthenticated_args> {
+      public isUserAuthenticated() {
+        super("isUserAuthenticated");
+      }
+
+      public isUserAuthenticated_args getEmptyArgsInstance() {
+        return new isUserAuthenticated_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public isUserAuthenticated_result getResult(I iface, isUserAuthenticated_args args) throws org.apache.thrift.TException {
+        isUserAuthenticated_result result = new isUserAuthenticated_result();
+        try {
+          result.success = iface.isUserAuthenticated(args.authzToken);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+          result.ae = ae;
+        }
+        return result;
+      }
+    }
+
+    public static class getUserInfoFromAuthzToken<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUserInfoFromAuthzToken_args> {
+      public getUserInfoFromAuthzToken() {
+        super("getUserInfoFromAuthzToken");
+      }
+
+      public getUserInfoFromAuthzToken_args getEmptyArgsInstance() {
+        return new getUserInfoFromAuthzToken_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public getUserInfoFromAuthzToken_result getResult(I iface, getUserInfoFromAuthzToken_args args) throws org.apache.thrift.TException {
+        getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
+        try {
+          result.success = iface.getUserInfoFromAuthzToken(args.authzToken);
+        } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+          result.ae = ae;
+        }
+        return result;
+      }
+    }
+
+    public static class getUserManagementServiceAccountAuthzToken<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUserManagementServiceAccountAuthzToken_args> {
+      public getUserManagementServiceAccountAuthzToken() {
+        super("getUserManagementServiceAccountAuthzToken");
+      }
+
+      public getUserManagementServiceAccountAuthzToken_args getEmptyArgsInstance() {
+        return new getUserManagementServiceAccountAuthzToken_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public getUserManagementServiceAccountAuthzToken_result getResult(I iface, getUserManagementServiceAccountAuthzToken_args args) throws org.apache.thrift.TException {
+        getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
+        try {
+          result.success = iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId);
+        } catch (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+          result.ae = ae;
+        }
+        return result;
+      }
+    }
+
+  }
+
+  public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
+    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName());
+    public AsyncProcessor(I iface) {
+      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
+    }
+
+    protected AsyncProcessor(I iface, java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
+      super(iface, getProcessMap(processMap));
+    }
+
+    private static <I extends AsyncIface> java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
+      processMap.put("isUserAuthenticated", new isUserAuthenticated());
+      processMap.put("getUserInfoFromAuthzToken", new getUserInfoFromAuthzToken());
+      processMap.put("getUserManagementServiceAccountAuthzToken", new getUserManagementServiceAccountAuthzToken());
+      return processMap;
+    }
+
+    public static class isUserAuthenticated<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUserAuthenticated_args, Boolean> {
+      public isUserAuthenticated() {
+        super("isUserAuthenticated");
+      }
+
+      public isUserAuthenticated_args getEmptyArgsInstance() {
+        return new isUserAuthenticated_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            isUserAuthenticated_result result = new isUserAuthenticated_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            isUserAuthenticated_result result = new isUserAuthenticated_result();
+            if (e instanceof org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) {
+              result.ae = (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) e;
+              result.setAeIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, isUserAuthenticated_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.isUserAuthenticated(args.authzToken,resultHandler);
+      }
+    }
+
+    public static class getUserInfoFromAuthzToken<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUserInfoFromAuthzToken_args, org.apache.custos.commons.model.security.UserInfo> {
+      public getUserInfoFromAuthzToken() {
+        super("getUserInfoFromAuthzToken");
+      }
+
+      public getUserInfoFromAuthzToken_args getEmptyArgsInstance() {
+        return new getUserInfoFromAuthzToken_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo>() { 
+          public void onComplete(org.apache.custos.commons.model.security.UserInfo o) {
+            getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
+            if (e instanceof org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) {
+              result.ae = (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) e;
+              result.setAeIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, getUserInfoFromAuthzToken_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> resultHandler) throws org.apache.thrift.TException {
+        iface.getUserInfoFromAuthzToken(args.authzToken,resultHandler);
+      }
+    }
+
+    public static class getUserManagementServiceAccountAuthzToken<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUserManagementServiceAccountAuthzToken_args, org.apache.custos.commons.model.security.AuthzToken> {
+      public getUserManagementServiceAccountAuthzToken() {
+        super("getUserManagementServiceAccountAuthzToken");
+      }
+
+      public getUserManagementServiceAccountAuthzToken_args getEmptyArgsInstance() {
+        return new getUserManagementServiceAccountAuthzToken_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken>() { 
+          public void onComplete(org.apache.custos.commons.model.security.AuthzToken o) {
+            getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
+            if (e instanceof org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) {
+              result.ae = (org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException) e;
+              result.setAeIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, getUserManagementServiceAccountAuthzToken_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> resultHandler) throws org.apache.thrift.TException {
+        iface.getUserManagementServiceAccountAuthzToken(args.authzToken, args.gatewayId,resultHandler);
+      }
+    }
+
+  }
+
+  public static class isUserAuthenticated_args implements org.apache.thrift.TBase<isUserAuthenticated_args, isUserAuthenticated_args._Fields>, java.io.Serializable, Cloneable, Comparable<isUserAuthenticated_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isUserAuthenticated_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUserAuthenticated_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUserAuthenticated_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // 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");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_args.class, metaDataMap);
+    }
+
+    public isUserAuthenticated_args() {
+    }
+
+    public isUserAuthenticated_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken)
+    {
+      this();
+      this.authzToken = authzToken;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public isUserAuthenticated_args(isUserAuthenticated_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+    }
+
+    public isUserAuthenticated_args deepCopy() {
+      return new isUserAuthenticated_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public isUserAuthenticated_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      }
+      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();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof isUserAuthenticated_args)
+        return this.equals((isUserAuthenticated_args)that);
+      return false;
+    }
+
+    public boolean equals(isUserAuthenticated_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(isUserAuthenticated_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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("isUserAuthenticated_args(");
+      boolean first = true;
+
+      sb.append("authzToken:");
+      if (this.authzToken == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.authzToken);
+      }
+      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());
+      }
+      // 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 isUserAuthenticated_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUserAuthenticated_argsStandardScheme getScheme() {
+        return new isUserAuthenticated_argsStandardScheme();
+      }
+    }
+
+    private static class isUserAuthenticated_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<isUserAuthenticated_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, isUserAuthenticated_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.custos.commons.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(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, isUserAuthenticated_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();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class isUserAuthenticated_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUserAuthenticated_argsTupleScheme getScheme() {
+        return new isUserAuthenticated_argsTupleScheme();
+      }
+    }
+
+    private static class isUserAuthenticated_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<isUserAuthenticated_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class isUserAuthenticated_result implements org.apache.thrift.TBase<isUserAuthenticated_result, isUserAuthenticated_result._Fields>, java.io.Serializable, Cloneable, Comparable<isUserAuthenticated_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isUserAuthenticated_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0);
+    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUserAuthenticated_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUserAuthenticated_resultTupleSchemeFactory();
+
+    public boolean success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae; // 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"),
+      AE((short)1, "ae");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // AE
+            return AE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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
+    private static final int __SUCCESS_ISSET_ID = 0;
+    private byte __isset_bitfield = 0;
+    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.BOOL)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_result.class, metaDataMap);
+    }
+
+    public isUserAuthenticated_result() {
+    }
+
+    public isUserAuthenticated_result(
+      boolean success,
+      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+    {
+      this();
+      this.success = success;
+      setSuccessIsSet(true);
+      this.ae = ae;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public isUserAuthenticated_result(isUserAuthenticated_result other) {
+      __isset_bitfield = other.__isset_bitfield;
+      this.success = other.success;
+      if (other.isSetAe()) {
+        this.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException(other.ae);
+      }
+    }
+
+    public isUserAuthenticated_result deepCopy() {
+      return new isUserAuthenticated_result(this);
+    }
+
+    @Override
+    public void clear() {
+      setSuccessIsSet(false);
+      this.success = false;
+      this.ae = null;
+    }
+
+    public boolean isSuccess() {
+      return this.success;
+    }
+
+    public isUserAuthenticated_result setSuccess(boolean success) {
+      this.success = success;
+      setSuccessIsSet(true);
+      return this;
+    }
+
+    public void unsetSuccess() {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    /** Returns true if field success is set (has been assigned a value) and false otherwise */
+    public boolean isSetSuccess() {
+      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    public void setSuccessIsSet(boolean value) {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException getAe() {
+      return this.ae;
+    }
+
+    public isUserAuthenticated_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+      this.ae = ae;
+      return this;
+    }
+
+    public void unsetAe() {
+      this.ae = null;
+    }
+
+    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
+    public boolean isSetAe() {
+      return this.ae != null;
+    }
+
+    public void setAeIsSet(boolean value) {
+      if (!value) {
+        this.ae = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((Boolean)value);
+        }
+        break;
+
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return isSuccess();
+
+      case AE:
+        return getAe();
+
+      }
+      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 AE:
+        return isSetAe();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof isUserAuthenticated_result)
+        return this.equals((isUserAuthenticated_result)that);
+      return false;
+    }
+
+    public boolean equals(isUserAuthenticated_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      boolean this_present_success = true;
+      boolean that_present_success = true;
+      if (this_present_success || that_present_success) {
+        if (!(this_present_success && that_present_success))
+          return false;
+        if (this.success != that.success)
+          return false;
+      }
+
+      boolean this_present_ae = true && this.isSetAe();
+      boolean that_present_ae = true && that.isSetAe();
+      if (this_present_ae || that_present_ae) {
+        if (!(this_present_ae && that_present_ae))
+          return false;
+        if (!this.ae.equals(that.ae))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((success) ? 131071 : 524287);
+
+      hashCode = hashCode * 8191 + ((isSetAe()) ? 131071 : 524287);
+      if (isSetAe())
+        hashCode = hashCode * 8191 + ae.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(isUserAuthenticated_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(isSetAe()).compareTo(other.isSetAe());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetAe()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("isUserAuthenticated_result(");
+      boolean first = true;
+
+      sb.append("success:");
+      sb.append(this.success);
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("ae:");
+      if (this.ae == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ae);
+      }
+      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 {
+        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+        __isset_bitfield = 0;
+        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 isUserAuthenticated_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUserAuthenticated_resultStandardScheme getScheme() {
+        return new isUserAuthenticated_resultStandardScheme();
+      }
+    }
+
+    private static class isUserAuthenticated_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<isUserAuthenticated_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, isUserAuthenticated_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.BOOL) {
+                struct.success = iprot.readBool();
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // AE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+                struct.ae.read(iprot);
+                struct.setAeIsSet(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, isUserAuthenticated_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.isSetSuccess()) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          oprot.writeBool(struct.success);
+          oprot.writeFieldEnd();
+        }
+        if (struct.ae != null) {
+          oprot.writeFieldBegin(AE_FIELD_DESC);
+          struct.ae.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class isUserAuthenticated_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUserAuthenticated_resultTupleScheme getScheme() {
+        return new isUserAuthenticated_resultTupleScheme();
+      }
+    }
+
+    private static class isUserAuthenticated_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<isUserAuthenticated_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetAe()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          oprot.writeBool(struct.success);
+        }
+        if (struct.isSetAe()) {
+          struct.ae.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, isUserAuthenticated_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = iprot.readBool();
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+          struct.ae.read(iprot);
+          struct.setAeIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getUserInfoFromAuthzToken_args implements org.apache.thrift.TBase<getUserInfoFromAuthzToken_args, getUserInfoFromAuthzToken_args._Fields>, java.io.Serializable, Cloneable, Comparable<getUserInfoFromAuthzToken_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserInfoFromAuthzToken_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserInfoFromAuthzToken_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserInfoFromAuthzToken_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // 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");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_args.class, metaDataMap);
+    }
+
+    public getUserInfoFromAuthzToken_args() {
+    }
+
+    public getUserInfoFromAuthzToken_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken)
+    {
+      this();
+      this.authzToken = authzToken;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getUserInfoFromAuthzToken_args(getUserInfoFromAuthzToken_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+    }
+
+    public getUserInfoFromAuthzToken_args deepCopy() {
+      return new getUserInfoFromAuthzToken_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public getUserInfoFromAuthzToken_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      }
+      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();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getUserInfoFromAuthzToken_args)
+        return this.equals((getUserInfoFromAuthzToken_args)that);
+      return false;
+    }
+
+    public boolean equals(getUserInfoFromAuthzToken_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getUserInfoFromAuthzToken_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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getUserInfoFromAuthzToken_args(");
+      boolean first = true;
+
+      sb.append("authzToken:");
+      if (this.authzToken == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.authzToken);
+      }
+      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());
+      }
+      // 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 getUserInfoFromAuthzToken_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserInfoFromAuthzToken_argsStandardScheme getScheme() {
+        return new getUserInfoFromAuthzToken_argsStandardScheme();
+      }
+    }
+
+    private static class getUserInfoFromAuthzToken_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserInfoFromAuthzToken_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserInfoFromAuthzToken_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.custos.commons.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(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, getUserInfoFromAuthzToken_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();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getUserInfoFromAuthzToken_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserInfoFromAuthzToken_argsTupleScheme getScheme() {
+        return new getUserInfoFromAuthzToken_argsTupleScheme();
+      }
+    }
+
+    private static class getUserInfoFromAuthzToken_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserInfoFromAuthzToken_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getUserInfoFromAuthzToken_result implements org.apache.thrift.TBase<getUserInfoFromAuthzToken_result, getUserInfoFromAuthzToken_result._Fields>, java.io.Serializable, Cloneable, Comparable<getUserInfoFromAuthzToken_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserInfoFromAuthzToken_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserInfoFromAuthzToken_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserInfoFromAuthzToken_resultTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.UserInfo success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae; // 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"),
+      AE((short)1, "ae");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // AE
+            return AE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.UserInfo.class)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_result.class, metaDataMap);
+    }
+
+    public getUserInfoFromAuthzToken_result() {
+    }
+
+    public getUserInfoFromAuthzToken_result(
+      org.apache.custos.commons.model.security.UserInfo success,
+      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+    {
+      this();
+      this.success = success;
+      this.ae = ae;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getUserInfoFromAuthzToken_result(getUserInfoFromAuthzToken_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new org.apache.custos.commons.model.security.UserInfo(other.success);
+      }
+      if (other.isSetAe()) {
+        this.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException(other.ae);
+      }
+    }
+
+    public getUserInfoFromAuthzToken_result deepCopy() {
+      return new getUserInfoFromAuthzToken_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+      this.ae = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.UserInfo getSuccess() {
+      return this.success;
+    }
+
+    public getUserInfoFromAuthzToken_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.UserInfo 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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException getAe() {
+      return this.ae;
+    }
+
+    public getUserInfoFromAuthzToken_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+      this.ae = ae;
+      return this;
+    }
+
+    public void unsetAe() {
+      this.ae = null;
+    }
+
+    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
+    public boolean isSetAe() {
+      return this.ae != null;
+    }
+
+    public void setAeIsSet(boolean value) {
+      if (!value) {
+        this.ae = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.custos.commons.model.security.UserInfo)value);
+        }
+        break;
+
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      case AE:
+        return getAe();
+
+      }
+      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 AE:
+        return isSetAe();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getUserInfoFromAuthzToken_result)
+        return this.equals((getUserInfoFromAuthzToken_result)that);
+      return false;
+    }
+
+    public boolean equals(getUserInfoFromAuthzToken_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_ae = true && this.isSetAe();
+      boolean that_present_ae = true && that.isSetAe();
+      if (this_present_ae || that_present_ae) {
+        if (!(this_present_ae && that_present_ae))
+          return false;
+        if (!this.ae.equals(that.ae))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
+      if (isSetSuccess())
+        hashCode = hashCode * 8191 + success.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetAe()) ? 131071 : 524287);
+      if (isSetAe())
+        hashCode = hashCode * 8191 + ae.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getUserInfoFromAuthzToken_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(isSetAe()).compareTo(other.isSetAe());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetAe()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getUserInfoFromAuthzToken_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("ae:");
+      if (this.ae == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ae);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws org.apache.thrift.TException {
+      // check for required fields
+      // check for sub-struct validity
+      if (success != null) {
+        success.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 getUserInfoFromAuthzToken_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserInfoFromAuthzToken_resultStandardScheme getScheme() {
+        return new getUserInfoFromAuthzToken_resultStandardScheme();
+      }
+    }
+
+    private static class getUserInfoFromAuthzToken_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserInfoFromAuthzToken_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserInfoFromAuthzToken_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.STRUCT) {
+                struct.success = new org.apache.custos.commons.model.security.UserInfo();
+                struct.success.read(iprot);
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // AE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+                struct.ae.read(iprot);
+                struct.setAeIsSet(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, getUserInfoFromAuthzToken_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.success != null) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          struct.success.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        if (struct.ae != null) {
+          oprot.writeFieldBegin(AE_FIELD_DESC);
+          struct.ae.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getUserInfoFromAuthzToken_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserInfoFromAuthzToken_resultTupleScheme getScheme() {
+        return new getUserInfoFromAuthzToken_resultTupleScheme();
+      }
+    }
+
+    private static class getUserInfoFromAuthzToken_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserInfoFromAuthzToken_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetAe()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          struct.success.write(oprot);
+        }
+        if (struct.isSetAe()) {
+          struct.ae.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getUserInfoFromAuthzToken_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = new org.apache.custos.commons.model.security.UserInfo();
+          struct.success.read(iprot);
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+          struct.ae.read(iprot);
+          struct.setAeIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getUserManagementServiceAccountAuthzToken_args implements org.apache.thrift.TBase<getUserManagementServiceAccountAuthzToken_args, getUserManagementServiceAccountAuthzToken_args._Fields>, java.io.Serializable, Cloneable, Comparable<getUserManagementServiceAccountAuthzToken_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserManagementServiceAccountAuthzToken_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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String gatewayId; // 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");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          case 2: // GATEWAY_ID
+            return GATEWAY_ID;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.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)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_args.class, metaDataMap);
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args() {
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String gatewayId)
+    {
+      this();
+      this.authzToken = authzToken;
+      this.gatewayId = gatewayId;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getUserManagementServiceAccountAuthzToken_args(getUserManagementServiceAccountAuthzToken_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+      if (other.isSetGatewayId()) {
+        this.gatewayId = other.gatewayId;
+      }
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args deepCopy() {
+      return new getUserManagementServiceAccountAuthzToken_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+      this.gatewayId = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getGatewayId() {
+      return this.gatewayId;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_args setGatewayId(@org.apache.thrift.annotation.Nullable 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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case GATEWAY_ID:
+        if (value == null) {
+          unsetGatewayId();
+        } else {
+          setGatewayId((String)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      case GATEWAY_ID:
+        return getGatewayId();
+
+      }
+      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();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getUserManagementServiceAccountAuthzToken_args)
+        return this.equals((getUserManagementServiceAccountAuthzToken_args)that);
+      return false;
+    }
+
+    public boolean equals(getUserManagementServiceAccountAuthzToken_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetGatewayId()) ? 131071 : 524287);
+      if (isSetGatewayId())
+        hashCode = hashCode * 8191 + gatewayId.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getUserManagementServiceAccountAuthzToken_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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getUserManagementServiceAccountAuthzToken_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;
+      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());
+      }
+      // 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 getUserManagementServiceAccountAuthzToken_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserManagementServiceAccountAuthzToken_argsStandardScheme getScheme() {
+        return new getUserManagementServiceAccountAuthzToken_argsStandardScheme();
+      }
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserManagementServiceAccountAuthzToken_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserManagementServiceAccountAuthzToken_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.custos.commons.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;
+            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, getUserManagementServiceAccountAuthzToken_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();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserManagementServiceAccountAuthzToken_argsTupleScheme getScheme() {
+        return new getUserManagementServiceAccountAuthzToken_argsTupleScheme();
+      }
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserManagementServiceAccountAuthzToken_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+        oprot.writeString(struct.gatewayId);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+        struct.gatewayId = iprot.readString();
+        struct.setGatewayIdIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getUserManagementServiceAccountAuthzToken_result implements org.apache.thrift.TBase<getUserManagementServiceAccountAuthzToken_result, getUserManagementServiceAccountAuthzToken_result._Fields>, java.io.Serializable, Cloneable, Comparable<getUserManagementServiceAccountAuthzToken_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserManagementServiceAccountAuthzToken_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+    private static final org.apache.thrift.protocol.TField AE_FIELD_DESC = new org.apache.thrift.protocol.TField("ae", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserManagementServiceAccountAuthzToken_resultTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae; // 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"),
+      AE((short)1, "ae");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // AE
+            return AE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_result.class, metaDataMap);
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result() {
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result(
+      org.apache.custos.commons.model.security.AuthzToken success,
+      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+    {
+      this();
+      this.success = success;
+      this.ae = ae;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getUserManagementServiceAccountAuthzToken_result(getUserManagementServiceAccountAuthzToken_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new org.apache.custos.commons.model.security.AuthzToken(other.success);
+      }
+      if (other.isSetAe()) {
+        this.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException(other.ae);
+      }
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result deepCopy() {
+      return new getUserManagementServiceAccountAuthzToken_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+      this.ae = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getSuccess() {
+      return this.success;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken 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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException getAe() {
+      return this.ae;
+    }
+
+    public getUserManagementServiceAccountAuthzToken_result setAe(@org.apache.thrift.annotation.Nullable org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae) {
+      this.ae = ae;
+      return this;
+    }
+
+    public void unsetAe() {
+      this.ae = null;
+    }
+
+    /** Returns true if field ae is set (has been assigned a value) and false otherwise */
+    public boolean isSetAe() {
+      return this.ae != null;
+    }
+
+    public void setAeIsSet(boolean value) {
+      if (!value) {
+        this.ae = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      case AE:
+        return getAe();
+
+      }
+      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 AE:
+        return isSetAe();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getUserManagementServiceAccountAuthzToken_result)
+        return this.equals((getUserManagementServiceAccountAuthzToken_result)that);
+      return false;
+    }
+
+    public boolean equals(getUserManagementServiceAccountAuthzToken_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_ae = true && this.isSetAe();
+      boolean that_present_ae = true && that.isSetAe();
+      if (this_present_ae || that_present_ae) {
+        if (!(this_present_ae && that_present_ae))
+          return false;
+        if (!this.ae.equals(that.ae))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
+      if (isSetSuccess())
+        hashCode = hashCode * 8191 + success.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetAe()) ? 131071 : 524287);
+      if (isSetAe())
+        hashCode = hashCode * 8191 + ae.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getUserManagementServiceAccountAuthzToken_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(isSetAe()).compareTo(other.isSetAe());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetAe()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ae, other.ae);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getUserManagementServiceAccountAuthzToken_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("ae:");
+      if (this.ae == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ae);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws org.apache.thrift.TException {
+      // check for required fields
+      // check for sub-struct validity
+      if (success != null) {
+        success.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 getUserManagementServiceAccountAuthzToken_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserManagementServiceAccountAuthzToken_resultStandardScheme getScheme() {
+        return new getUserManagementServiceAccountAuthzToken_resultStandardScheme();
+      }
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserManagementServiceAccountAuthzToken_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getUserManagementServiceAccountAuthzToken_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.STRUCT) {
+                struct.success = new org.apache.custos.commons.model.security.AuthzToken();
+                struct.success.read(iprot);
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // AE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+                struct.ae.read(iprot);
+                struct.setAeIsSet(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, getUserManagementServiceAccountAuthzToken_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.success != null) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          struct.success.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        if (struct.ae != null) {
+          oprot.writeFieldBegin(AE_FIELD_DESC);
+          struct.ae.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getUserManagementServiceAccountAuthzToken_resultTupleScheme getScheme() {
+        return new getUserManagementServiceAccountAuthzToken_resultTupleScheme();
+      }
+    }
+
+    private static class getUserManagementServiceAccountAuthzToken_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserManagementServiceAccountAuthzToken_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetAe()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          struct.success.write(oprot);
+        }
+        if (struct.isSetAe()) {
+          struct.ae.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getUserManagementServiceAccountAuthzToken_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = new org.apache.custos.commons.model.security.AuthzToken();
+          struct.success.read(iprot);
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
+          struct.ae.read(iprot);
+          struct.setAeIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+}
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/exception/CustosAuthenticationServiceException.java b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/exception/CustosAuthenticationServiceException.java
new file mode 100644
index 0000000..571f176
--- /dev/null
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/exception/CustosAuthenticationServiceException.java
@@ -0,0 +1,370 @@
+/**
+ * Autogenerated by Thrift Compiler (0.12.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.authentication.cpi.exception;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-07")
+public class CustosAuthenticationServiceException extends org.apache.thrift.TException implements org.apache.thrift.TBase<CustosAuthenticationServiceException, CustosAuthenticationServiceException._Fields>, java.io.Serializable, Cloneable, Comparable<CustosAuthenticationServiceException> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CustosAuthenticationServiceException");
+
+  private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new CustosAuthenticationServiceExceptionStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new CustosAuthenticationServiceExceptionTupleSchemeFactory();
+
+  public @org.apache.thrift.annotation.Nullable String message; // 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 {
+    MESSAGE((short)1, "message");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    @org.apache.thrift.annotation.Nullable
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // MESSAGE
+          return MESSAGE;
+        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.
+     */
+    @org.apache.thrift.annotation.Nullable
+    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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CustosAuthenticationServiceException.class, metaDataMap);
+  }
+
+  public CustosAuthenticationServiceException() {
+  }
+
+  public CustosAuthenticationServiceException(
+    String message)
+  {
+    this();
+    this.message = message;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public CustosAuthenticationServiceException(CustosAuthenticationServiceException other) {
+    if (other.isSetMessage()) {
+      this.message = other.message;
+    }
+  }
+
+  public CustosAuthenticationServiceException deepCopy() {
+    return new CustosAuthenticationServiceException(this);
+  }
+
+  @Override
+  public void clear() {
+    this.message = null;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getMessage() {
+    return this.message;
+  }
+
+  public CustosAuthenticationServiceException setMessage(@org.apache.thrift.annotation.Nullable String message) {
+    this.message = message;
+    return this;
+  }
+
+  public void unsetMessage() {
+    this.message = null;
+  }
+
+  /** Returns true if field message is set (has been assigned a value) and false otherwise */
+  public boolean isSetMessage() {
+    return this.message != null;
+  }
+
+  public void setMessageIsSet(boolean value) {
+    if (!value) {
+      this.message = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+    switch (field) {
+    case MESSAGE:
+      if (value == null) {
+        unsetMessage();
+      } else {
+        setMessage((String)value);
+      }
+      break;
+
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case MESSAGE:
+      return getMessage();
+
+    }
+    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 MESSAGE:
+      return isSetMessage();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof CustosAuthenticationServiceException)
+      return this.equals((CustosAuthenticationServiceException)that);
+    return false;
+  }
+
+  public boolean equals(CustosAuthenticationServiceException that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    boolean this_present_message = true && this.isSetMessage();
+    boolean that_present_message = true && that.isSetMessage();
+    if (this_present_message || that_present_message) {
+      if (!(this_present_message && that_present_message))
+        return false;
+      if (!this.message.equals(that.message))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
+    if (isSetMessage())
+      hashCode = hashCode * 8191 + message.hashCode();
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(CustosAuthenticationServiceException other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetMessage()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("CustosAuthenticationServiceException(");
+    boolean first = true;
+
+    sb.append("message:");
+    if (this.message == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.message);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (message == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' was not present! Struct: " + toString());
+    }
+    // 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 CustosAuthenticationServiceExceptionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public CustosAuthenticationServiceExceptionStandardScheme getScheme() {
+      return new CustosAuthenticationServiceExceptionStandardScheme();
+    }
+  }
+
+  private static class CustosAuthenticationServiceExceptionStandardScheme extends org.apache.thrift.scheme.StandardScheme<CustosAuthenticationServiceException> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, CustosAuthenticationServiceException 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: // MESSAGE
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.message = iprot.readString();
+              struct.setMessageIsSet(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, CustosAuthenticationServiceException struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.message != null) {
+        oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
+        oprot.writeString(struct.message);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class CustosAuthenticationServiceExceptionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public CustosAuthenticationServiceExceptionTupleScheme getScheme() {
+      return new CustosAuthenticationServiceExceptionTupleScheme();
+    }
+  }
+
+  private static class CustosAuthenticationServiceExceptionTupleScheme extends org.apache.thrift.scheme.TupleScheme<CustosAuthenticationServiceException> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, CustosAuthenticationServiceException struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      oprot.writeString(struct.message);
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, CustosAuthenticationServiceException struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      struct.message = iprot.readString();
+      struct.setMessageIsSet(true);
+    }
+  }
+
+  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+  }
+}
+
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
new file mode 100644
index 0000000..abb073a
--- /dev/null
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
@@ -0,0 +1,57 @@
+package org.apache.custos.authentication.handler;
+
+import org.apache.custos.authentication.cpi.CustosAuthenticationService;
+import org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException;
+import org.apache.custos.commons.model.security.UserInfo;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.model.error.AuthenticationException;
+import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.commons.utils.Constants;
+import org.apache.custos.security.manager.CustosSecurityManager;
+import org.apache.custos.security.manager.SecurityManagerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CustosAuthenticationHandler implements CustosAuthenticationService.Iface {
+    private final static Logger logger = LoggerFactory.getLogger(CustosAuthenticationHandler.class);
+
+    @Override
+    public boolean isUserAuthenticated(AuthzToken authzToken) throws AuthenticationException {
+        try {
+            CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
+            boolean isAuth = securityManager.isUserAuthenticated(authzToken);
+                if (isAuth) {
+                    logger.info("User" + authzToken.getClaimsMap().get(Constants.USER_NAME) + "in gateway" + authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + "is authenticated");
+                    return isAuth;
+                }
+                else{
+                    throw new AuthenticationException("User is not authenticated.");
+                }
+        } catch (CustosSecurityException e) {
+            logger.error(e.getMessage(), e);
+            throw new AuthenticationException("Error in authenticating.");
+        }
+    }
+    @Override
+    public UserInfo getUserInfoFromAuthzToken(AuthzToken authzToken) throws CustosAuthenticationServiceException {
+        try{
+            CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
+            UserInfo userInfo = securityManager.getUserInfoFromAuthzToken(authzToken);
+            return userInfo;
+        }catch (CustosSecurityException e){
+            logger.error(e.getMessage(), e);
+            throw new CustosAuthenticationServiceException("Could not retrieve user info");
+        }
+    }
+    @Override
+    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosAuthenticationServiceException {
+        try{
+            CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
+            AuthzToken managementServiceAccountAuthzToken = securityManager.getUserManagementServiceAccountAuthzToken(authzToken, gatewayId);
+            return managementServiceAccountAuthzToken;
+        }catch (CustosSecurityException e){
+            logger.error(e.getMessage(), e);
+            throw new CustosAuthenticationServiceException("Could get user management account authz token");
+        }
+    }
+}
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/server/CustosAuthenticationServer.java b/custos-authentication/src/main/java/org/apache/custos/authentication/server/CustosAuthenticationServer.java
new file mode 100644
index 0000000..76a4066
--- /dev/null
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/server/CustosAuthenticationServer.java
@@ -0,0 +1,137 @@
+package org.apache.custos.authentication.server;
+
+import org.apache.custos.authentication.cpi.CustosAuthenticationService;
+import org.apache.custos.authentication.handler.CustosAuthenticationHandler;
+import org.apache.custos.commons.utils.IServer;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.thrift.server.TServer;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TServerTransport;
+import org.apache.thrift.transport.TTransportException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetSocketAddress;
+import java.util.Date;;
+
+public class CustosAuthenticationServer implements  IServer{
+
+    private final static Logger logger = LoggerFactory.getLogger(CustosAuthenticationService.class);
+
+    private static final String SERVER_NAME = "Authentication Service Server";
+    private static final String SERVER_VERSION = "1.0";
+
+    private ServerStatus status;
+    private TServer server;
+
+    public CustosAuthenticationServer() {
+        setStatus(ServerStatus.STOPPED);
+    }
+
+    public void updateTime() {
+
+    }
+
+    public Date getTime() {
+        return null;
+    }
+
+    public String getName() {
+        return SERVER_NAME;
+    }
+
+    public String getVersion() {
+        return SERVER_VERSION;
+    }
+
+    public void start() throws Exception {
+        try {
+            final int serverPort = Integer.parseInt(ServerSettings.getAuthenticationServerPort());
+            final String serverHost = ServerSettings.getAuthenticationServerHost();
+            CustosAuthenticationService.Processor authenticationProcessor = new CustosAuthenticationService.Processor(new CustosAuthenticationHandler());
+            TServerTransport serverTransport;
+
+            if (serverHost == null) {
+                serverTransport = new TServerSocket(serverPort);
+            } else {
+                InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
+                serverTransport = new TServerSocket(inetSocketAddress);
+            }
+            TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
+            options.minWorkerThreads = 30;
+            server = new TThreadPoolServer(options.processor(authenticationProcessor));
+
+            new Thread() {
+                public void run() {
+                    server.serve();
+                    setStatus(ServerStatus.STOPPED);
+                    logger.info("Authentication Service Server Stopped.");
+                }
+            }.start();
+            new Thread() {
+                public void run() {
+                    while (!server.isServing()) {
+                        try {
+                            Thread.sleep(500);
+                        } catch (InterruptedException e) {
+                            break;
+                        }
+                    }
+                    if (server.isServing()) {
+                        setStatus(ServerStatus.STARTED);
+                        logger.info("Starting Authentication Service Server on Port " + serverPort);
+                        logger.info("Listening to Authentication Service Server clients ....");
+                    }
+                }
+            }.start();
+        }
+         catch (TTransportException e) {
+            setStatus(ServerStatus.FAILED);
+            throw new Exception("Error while starting the Authentication Service Server", e);
+        }
+    }
+
+    public void stop() throws Exception {
+
+        if (server != null && server.isServing()) {
+            setStatus(ServerStatus.STOPING);
+            server.stop();
+        }
+    }
+
+    public void restart() throws Exception {
+
+        stop();
+        start();
+    }
+
+    public void configure() throws Exception {
+
+    }
+
+    public ServerStatus getStatus() throws Exception {
+        return status;
+    }
+
+    private void setStatus(ServerStatus stat) {
+        status = stat;
+        status.updateTime();
+    }
+
+    public TServer getServer() {
+        return server;
+    }
+
+    public void setServer(TServer server) {
+        this.server = server;
+    }
+
+    public static void main(String[] args) {
+        try {
+            new CustosAuthenticationServer().start();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+        }
+    }
+}
diff --git a/custos-client/pom.xml b/custos-client/pom.xml
index cc6d67b..882305a 100644
--- a/custos-client/pom.xml
+++ b/custos-client/pom.xml
@@ -8,6 +8,7 @@
         <version>1.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
+    <artifactId>custos-client</artifactId>
     <dependencies>
         <dependency>
             <groupId>org.apache.custos</groupId>
@@ -15,12 +16,18 @@
             <version>1.0-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-authentication</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
     <properties>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
     </properties>
-    <artifactId>custos-client</artifactId>
+
 
 
 </project>
\ No newline at end of file
diff --git a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
new file mode 100644
index 0000000..34aa7f9
--- /dev/null
+++ b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
@@ -0,0 +1,25 @@
+package org.apache.custos.client.authentication.service;
+
+import org.apache.custos.authentication.cpi.CustosAuthenticationService;
+import org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException;
+import org.apache.custos.commons.model.error.AuthenticationException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TMultiplexedProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+public class AuthenticationServiceClient {
+    public static CustosAuthenticationService.Client createAuthenticationServiceClient(String serverHost, int serverPort)  throws CustosAuthenticationServiceException {
+        try {
+            TTransport transport = new TSocket(serverHost, serverPort);
+            transport.open();
+            TProtocol protocol = new TBinaryProtocol(transport);
+            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, "CustosAuthenticationService");
+            return new CustosAuthenticationService.Client(multiplexedProtocol);
+        } catch (TTransportException e) {
+            throw new CustosAuthenticationServiceException(e.getMessage());
+        }
+    }
+}
diff --git a/custos-client/src/main/java/org/apache/custos/client/profile/service/ProfileServiceClientFactory.java b/custos-client/src/main/java/org/apache/custos/client/profile/service/CustosProfileServiceClientFactory.java
similarity index 89%
copy from custos-client/src/main/java/org/apache/custos/client/profile/service/ProfileServiceClientFactory.java
copy to custos-client/src/main/java/org/apache/custos/client/profile/service/CustosProfileServiceClientFactory.java
index aa8f476..593be32 100644
--- a/custos-client/src/main/java/org/apache/custos/client/profile/service/ProfileServiceClientFactory.java
+++ b/custos-client/src/main/java/org/apache/custos/client/profile/service/CustosProfileServiceClientFactory.java
@@ -38,8 +38,8 @@ import org.apache.thrift.transport.TTransportException;
 /**
  * Created by goshenoy on 03/08/2017.
  */
-public class ProfileServiceClientFactory {
-    public static UserProfileService.Client createUserProfileServiceClient(String serverHost, int serverPort)  throws UserProfileServiceException {
+public class CustosProfileServiceClientFactory {
+    public static UserProfileService.Client createCustosUserProfileServiceClient(String serverHost, int serverPort)  throws UserProfileServiceException {
         try {
             TTransport transport = new TSocket(serverHost, serverPort);
             transport.open();
@@ -51,7 +51,7 @@ public class ProfileServiceClientFactory {
         }
     }
 
-    public static TenantProfileService.Client createTenantProfileServiceClient(String serverHost, int serverPort) throws TenantProfileServiceException {
+    public static TenantProfileService.Client createCustosTenantProfileServiceClient(String serverHost, int serverPort) throws TenantProfileServiceException {
         try {
             TTransport transport = new TSocket(serverHost, serverPort);
             transport.open();
@@ -63,7 +63,7 @@ public class ProfileServiceClientFactory {
         }
     }
 
-    public static IamAdminServices.Client createIamAdminServiceClient(String serverHost, int serverPort) throws IamAdminServicesException {
+    public static IamAdminServices.Client createCustosIamAdminServiceClient(String serverHost, int serverPort) throws IamAdminServicesException {
         try {
             TTransport transport = new TSocket(serverHost, serverPort);
             transport.open();
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/model/security/UserInfo.java b/custos-commons/src/main/java/org/apache/custos/commons/model/security/UserInfo.java
new file mode 100644
index 0000000..167458f
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/model/security/UserInfo.java
@@ -0,0 +1,875 @@
+/**
+ * Autogenerated by Thrift Compiler (0.12.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.commons.model.security;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-08")
+public class UserInfo implements org.apache.thrift.TBase<UserInfo, UserInfo._Fields>, java.io.Serializable, Cloneable, Comparable<UserInfo> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UserInfo");
+
+  private static final org.apache.thrift.protocol.TField SUB_FIELD_DESC = new org.apache.thrift.protocol.TField("sub", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField FIRST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("firstName", org.apache.thrift.protocol.TType.STRING, (short)2);
+  private static final org.apache.thrift.protocol.TField LAST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("lastName", org.apache.thrift.protocol.TType.STRING, (short)3);
+  private static final org.apache.thrift.protocol.TField FULL_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("fullName", org.apache.thrift.protocol.TType.STRING, (short)4);
+  private static final org.apache.thrift.protocol.TField EMAIL_ADDRESS_FIELD_DESC = new org.apache.thrift.protocol.TField("emailAddress", org.apache.thrift.protocol.TType.STRING, (short)5);
+  private static final org.apache.thrift.protocol.TField USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)6);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UserInfoStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserInfoTupleSchemeFactory();
+
+  public @org.apache.thrift.annotation.Nullable String sub; // required
+  public @org.apache.thrift.annotation.Nullable String firstName; // required
+  public @org.apache.thrift.annotation.Nullable String lastName; // required
+  public @org.apache.thrift.annotation.Nullable String fullName; // required
+  public @org.apache.thrift.annotation.Nullable String emailAddress; // required
+  public @org.apache.thrift.annotation.Nullable String username; // 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 {
+    SUB((short)1, "sub"),
+    FIRST_NAME((short)2, "firstName"),
+    LAST_NAME((short)3, "lastName"),
+    FULL_NAME((short)4, "fullName"),
+    EMAIL_ADDRESS((short)5, "emailAddress"),
+    USERNAME((short)6, "username");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    @org.apache.thrift.annotation.Nullable
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // SUB
+          return SUB;
+        case 2: // FIRST_NAME
+          return FIRST_NAME;
+        case 3: // LAST_NAME
+          return LAST_NAME;
+        case 4: // FULL_NAME
+          return FULL_NAME;
+        case 5: // EMAIL_ADDRESS
+          return EMAIL_ADDRESS;
+        case 6: // USERNAME
+          return USERNAME;
+        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.
+     */
+    @org.apache.thrift.annotation.Nullable
+    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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.SUB, new org.apache.thrift.meta_data.FieldMetaData("sub", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.FIRST_NAME, new org.apache.thrift.meta_data.FieldMetaData("firstName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.LAST_NAME, new org.apache.thrift.meta_data.FieldMetaData("lastName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.FULL_NAME, new org.apache.thrift.meta_data.FieldMetaData("fullName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.EMAIL_ADDRESS, new org.apache.thrift.meta_data.FieldMetaData("emailAddress", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.USERNAME, 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)));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(UserInfo.class, metaDataMap);
+  }
+
+  public UserInfo() {
+  }
+
+  public UserInfo(
+    String sub,
+    String firstName,
+    String lastName,
+    String fullName,
+    String emailAddress,
+    String username)
+  {
+    this();
+    this.sub = sub;
+    this.firstName = firstName;
+    this.lastName = lastName;
+    this.fullName = fullName;
+    this.emailAddress = emailAddress;
+    this.username = username;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public UserInfo(UserInfo other) {
+    if (other.isSetSub()) {
+      this.sub = other.sub;
+    }
+    if (other.isSetFirstName()) {
+      this.firstName = other.firstName;
+    }
+    if (other.isSetLastName()) {
+      this.lastName = other.lastName;
+    }
+    if (other.isSetFullName()) {
+      this.fullName = other.fullName;
+    }
+    if (other.isSetEmailAddress()) {
+      this.emailAddress = other.emailAddress;
+    }
+    if (other.isSetUsername()) {
+      this.username = other.username;
+    }
+  }
+
+  public UserInfo deepCopy() {
+    return new UserInfo(this);
+  }
+
+  @Override
+  public void clear() {
+    this.sub = null;
+    this.firstName = null;
+    this.lastName = null;
+    this.fullName = null;
+    this.emailAddress = null;
+    this.username = null;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getSub() {
+    return this.sub;
+  }
+
+  public UserInfo setSub(@org.apache.thrift.annotation.Nullable String sub) {
+    this.sub = sub;
+    return this;
+  }
+
+  public void unsetSub() {
+    this.sub = null;
+  }
+
+  /** Returns true if field sub is set (has been assigned a value) and false otherwise */
+  public boolean isSetSub() {
+    return this.sub != null;
+  }
+
+  public void setSubIsSet(boolean value) {
+    if (!value) {
+      this.sub = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getFirstName() {
+    return this.firstName;
+  }
+
+  public UserInfo setFirstName(@org.apache.thrift.annotation.Nullable String firstName) {
+    this.firstName = firstName;
+    return this;
+  }
+
+  public void unsetFirstName() {
+    this.firstName = null;
+  }
+
+  /** Returns true if field firstName is set (has been assigned a value) and false otherwise */
+  public boolean isSetFirstName() {
+    return this.firstName != null;
+  }
+
+  public void setFirstNameIsSet(boolean value) {
+    if (!value) {
+      this.firstName = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getLastName() {
+    return this.lastName;
+  }
+
+  public UserInfo setLastName(@org.apache.thrift.annotation.Nullable String lastName) {
+    this.lastName = lastName;
+    return this;
+  }
+
+  public void unsetLastName() {
+    this.lastName = null;
+  }
+
+  /** Returns true if field lastName is set (has been assigned a value) and false otherwise */
+  public boolean isSetLastName() {
+    return this.lastName != null;
+  }
+
+  public void setLastNameIsSet(boolean value) {
+    if (!value) {
+      this.lastName = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getFullName() {
+    return this.fullName;
+  }
+
+  public UserInfo setFullName(@org.apache.thrift.annotation.Nullable String fullName) {
+    this.fullName = fullName;
+    return this;
+  }
+
+  public void unsetFullName() {
+    this.fullName = null;
+  }
+
+  /** Returns true if field fullName is set (has been assigned a value) and false otherwise */
+  public boolean isSetFullName() {
+    return this.fullName != null;
+  }
+
+  public void setFullNameIsSet(boolean value) {
+    if (!value) {
+      this.fullName = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getEmailAddress() {
+    return this.emailAddress;
+  }
+
+  public UserInfo setEmailAddress(@org.apache.thrift.annotation.Nullable String emailAddress) {
+    this.emailAddress = emailAddress;
+    return this;
+  }
+
+  public void unsetEmailAddress() {
+    this.emailAddress = null;
+  }
+
+  /** Returns true if field emailAddress is set (has been assigned a value) and false otherwise */
+  public boolean isSetEmailAddress() {
+    return this.emailAddress != null;
+  }
+
+  public void setEmailAddressIsSet(boolean value) {
+    if (!value) {
+      this.emailAddress = null;
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public String getUsername() {
+    return this.username;
+  }
+
+  public UserInfo setUsername(@org.apache.thrift.annotation.Nullable 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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+    switch (field) {
+    case SUB:
+      if (value == null) {
+        unsetSub();
+      } else {
+        setSub((String)value);
+      }
+      break;
+
+    case FIRST_NAME:
+      if (value == null) {
+        unsetFirstName();
+      } else {
+        setFirstName((String)value);
+      }
+      break;
+
+    case LAST_NAME:
+      if (value == null) {
+        unsetLastName();
+      } else {
+        setLastName((String)value);
+      }
+      break;
+
+    case FULL_NAME:
+      if (value == null) {
+        unsetFullName();
+      } else {
+        setFullName((String)value);
+      }
+      break;
+
+    case EMAIL_ADDRESS:
+      if (value == null) {
+        unsetEmailAddress();
+      } else {
+        setEmailAddress((String)value);
+      }
+      break;
+
+    case USERNAME:
+      if (value == null) {
+        unsetUsername();
+      } else {
+        setUsername((String)value);
+      }
+      break;
+
+    }
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case SUB:
+      return getSub();
+
+    case FIRST_NAME:
+      return getFirstName();
+
+    case LAST_NAME:
+      return getLastName();
+
+    case FULL_NAME:
+      return getFullName();
+
+    case EMAIL_ADDRESS:
+      return getEmailAddress();
+
+    case USERNAME:
+      return getUsername();
+
+    }
+    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 SUB:
+      return isSetSub();
+    case FIRST_NAME:
+      return isSetFirstName();
+    case LAST_NAME:
+      return isSetLastName();
+    case FULL_NAME:
+      return isSetFullName();
+    case EMAIL_ADDRESS:
+      return isSetEmailAddress();
+    case USERNAME:
+      return isSetUsername();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof UserInfo)
+      return this.equals((UserInfo)that);
+    return false;
+  }
+
+  public boolean equals(UserInfo that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    boolean this_present_sub = true && this.isSetSub();
+    boolean that_present_sub = true && that.isSetSub();
+    if (this_present_sub || that_present_sub) {
+      if (!(this_present_sub && that_present_sub))
+        return false;
+      if (!this.sub.equals(that.sub))
+        return false;
+    }
+
+    boolean this_present_firstName = true && this.isSetFirstName();
+    boolean that_present_firstName = true && that.isSetFirstName();
+    if (this_present_firstName || that_present_firstName) {
+      if (!(this_present_firstName && that_present_firstName))
+        return false;
+      if (!this.firstName.equals(that.firstName))
+        return false;
+    }
+
+    boolean this_present_lastName = true && this.isSetLastName();
+    boolean that_present_lastName = true && that.isSetLastName();
+    if (this_present_lastName || that_present_lastName) {
+      if (!(this_present_lastName && that_present_lastName))
+        return false;
+      if (!this.lastName.equals(that.lastName))
+        return false;
+    }
+
+    boolean this_present_fullName = true && this.isSetFullName();
+    boolean that_present_fullName = true && that.isSetFullName();
+    if (this_present_fullName || that_present_fullName) {
+      if (!(this_present_fullName && that_present_fullName))
+        return false;
+      if (!this.fullName.equals(that.fullName))
+        return false;
+    }
+
+    boolean this_present_emailAddress = true && this.isSetEmailAddress();
+    boolean that_present_emailAddress = true && that.isSetEmailAddress();
+    if (this_present_emailAddress || that_present_emailAddress) {
+      if (!(this_present_emailAddress && that_present_emailAddress))
+        return false;
+      if (!this.emailAddress.equals(that.emailAddress))
+        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;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetSub()) ? 131071 : 524287);
+    if (isSetSub())
+      hashCode = hashCode * 8191 + sub.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetFirstName()) ? 131071 : 524287);
+    if (isSetFirstName())
+      hashCode = hashCode * 8191 + firstName.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetLastName()) ? 131071 : 524287);
+    if (isSetLastName())
+      hashCode = hashCode * 8191 + lastName.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetFullName()) ? 131071 : 524287);
+    if (isSetFullName())
+      hashCode = hashCode * 8191 + fullName.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetEmailAddress()) ? 131071 : 524287);
+    if (isSetEmailAddress())
+      hashCode = hashCode * 8191 + emailAddress.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetUsername()) ? 131071 : 524287);
+    if (isSetUsername())
+      hashCode = hashCode * 8191 + username.hashCode();
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(UserInfo other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetSub()).compareTo(other.isSetSub());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetSub()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sub, other.sub);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetFirstName()).compareTo(other.isSetFirstName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetFirstName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.firstName, other.firstName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetLastName()).compareTo(other.isSetLastName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetLastName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.lastName, other.lastName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetFullName()).compareTo(other.isSetFullName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetFullName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fullName, other.fullName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetEmailAddress()).compareTo(other.isSetEmailAddress());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetEmailAddress()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.emailAddress, other.emailAddress);
+      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;
+      }
+    }
+    return 0;
+  }
+
+  @org.apache.thrift.annotation.Nullable
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
+  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("UserInfo(");
+    boolean first = true;
+
+    sb.append("sub:");
+    if (this.sub == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.sub);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("firstName:");
+    if (this.firstName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.firstName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("lastName:");
+    if (this.lastName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.lastName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("fullName:");
+    if (this.fullName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.fullName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("emailAddress:");
+    if (this.emailAddress == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.emailAddress);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("username:");
+    if (this.username == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.username);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (sub == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'sub' was not present! Struct: " + toString());
+    }
+    if (firstName == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'firstName' was not present! Struct: " + toString());
+    }
+    if (lastName == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'lastName' was not present! Struct: " + toString());
+    }
+    if (fullName == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'fullName' was not present! Struct: " + toString());
+    }
+    if (emailAddress == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'emailAddress' was not present! Struct: " + toString());
+    }
+    if (username == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'username' was not present! Struct: " + toString());
+    }
+    // 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 UserInfoStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public UserInfoStandardScheme getScheme() {
+      return new UserInfoStandardScheme();
+    }
+  }
+
+  private static class UserInfoStandardScheme extends org.apache.thrift.scheme.StandardScheme<UserInfo> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, UserInfo 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: // SUB
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.sub = iprot.readString();
+              struct.setSubIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // FIRST_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.firstName = iprot.readString();
+              struct.setFirstNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 3: // LAST_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.lastName = iprot.readString();
+              struct.setLastNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 4: // FULL_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.fullName = iprot.readString();
+              struct.setFullNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 5: // EMAIL_ADDRESS
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.emailAddress = iprot.readString();
+              struct.setEmailAddressIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 6: // USERNAME
+            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;
+          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, UserInfo struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.sub != null) {
+        oprot.writeFieldBegin(SUB_FIELD_DESC);
+        oprot.writeString(struct.sub);
+        oprot.writeFieldEnd();
+      }
+      if (struct.firstName != null) {
+        oprot.writeFieldBegin(FIRST_NAME_FIELD_DESC);
+        oprot.writeString(struct.firstName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.lastName != null) {
+        oprot.writeFieldBegin(LAST_NAME_FIELD_DESC);
+        oprot.writeString(struct.lastName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.fullName != null) {
+        oprot.writeFieldBegin(FULL_NAME_FIELD_DESC);
+        oprot.writeString(struct.fullName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.emailAddress != null) {
+        oprot.writeFieldBegin(EMAIL_ADDRESS_FIELD_DESC);
+        oprot.writeString(struct.emailAddress);
+        oprot.writeFieldEnd();
+      }
+      if (struct.username != null) {
+        oprot.writeFieldBegin(USERNAME_FIELD_DESC);
+        oprot.writeString(struct.username);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class UserInfoTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public UserInfoTupleScheme getScheme() {
+      return new UserInfoTupleScheme();
+    }
+  }
+
+  private static class UserInfoTupleScheme extends org.apache.thrift.scheme.TupleScheme<UserInfo> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, UserInfo struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      oprot.writeString(struct.sub);
+      oprot.writeString(struct.firstName);
+      oprot.writeString(struct.lastName);
+      oprot.writeString(struct.fullName);
+      oprot.writeString(struct.emailAddress);
+      oprot.writeString(struct.username);
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, UserInfo struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      struct.sub = iprot.readString();
+      struct.setSubIsSet(true);
+      struct.firstName = iprot.readString();
+      struct.setFirstNameIsSet(true);
+      struct.lastName = iprot.readString();
+      struct.setLastNameIsSet(true);
+      struct.fullName = iprot.readString();
+      struct.setFullNameIsSet(true);
+      struct.emailAddress = iprot.readString();
+      struct.setEmailAddressIsSet(true);
+      struct.username = iprot.readString();
+      struct.setUsernameIsSet(true);
+    }
+  }
+
+  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+  }
+}
+
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
index 9f0ad54..9c28e25 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
@@ -31,6 +31,14 @@ public class ApplicationSettings {
     public static final String IAM_SERVER_URL = "iam.server.url";
     public static final String IAM_SERVER_SUPER_ADMIN_USERNAME = "iam.server.super.admin.username";
     public static final String IAM_SERVER_SUPER_ADMIN_PASSWORD = "iam.server.super.admin.password";
+
+    //User Profile constant
+    public static final String USER_PROFILE_SERVER_HOST = "user.profile.server.host";
+    public static final String USER_PROFILE_SERVER_PORT = "user.profile.server.port";
+
+    // Authentication service constants
+    public static final String AUTHENTICATION_SERVICE_SERVER_PORT = "custos.authentication.server.port";
+    public static final String AUTHENTICATION_SERVICE_SERVER_HOST = "custos.authentication.server.host";
     {
         loadProperties();
     }
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
index 9417313..1b4015c 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
@@ -26,10 +26,7 @@ import org.slf4j.LoggerFactory;
 public class ServerSettings extends ApplicationSettings {
 
     private static final Logger log = LoggerFactory.getLogger(ServerSettings.class);
-    //User Profile constant
 
-    public static final String USER_PROFILE_SERVER_HOST = "user.profile.server.host";
-    public static final String USER_PROFILE_SERVER_PORT = "user.profile.server.port";
 
     public static int getCacheSize() throws ApplicationSettingsException {
         return Integer.valueOf(getSetting(Constants.IN_MEMORY_CACHE_SIZE));
@@ -61,9 +58,15 @@ public class ServerSettings extends ApplicationSettings {
     public static String  getProfileServiceServerHost() throws ApplicationSettingsException {
         return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_HOST);
     }
-
     public static String getProfileServiceServerPort() throws ApplicationSettingsException {
         return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_PORT);
     }
+    public static  String getAuthenticationServerPort() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.AUTHENTICATION_SERVICE_SERVER_PORT);
+    }
+    public static  String getAuthenticationServerHost() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.AUTHENTICATION_SERVICE_SERVER_HOST);
+    }
+
 
 }
diff --git a/custos-connectors/pom.xml b/custos-connectors/pom.xml
index 309e806..7b6ae79 100644
--- a/custos-connectors/pom.xml
+++ b/custos-connectors/pom.xml
@@ -36,12 +36,6 @@
             <version>1.0-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>custos-client</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
-        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java
index f075dd9..a67cf8e 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/interceptor/SecurityInterceptor.java
@@ -64,7 +64,7 @@ public class SecurityInterceptor implements MethodInterceptor {
             boolean isAPISecured = ServerSettings.isAPISecured();
             if (isAPISecured) {
                 CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
-                boolean isAuthz = securityManager.isUserAuthorized(authzToken, metaData);
+                boolean isAuthz = securityManager.isUserAuthenticated(authzToken);
                 if (!isAuthz) {
                     throw new AuthorizationException("User is not authenticated or authorized.");
                 }
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
index 8051e77..4fbcc5d 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/CustosSecurityManager.java
@@ -22,6 +22,7 @@ package org.apache.custos.security.manager;
 
 import org.apache.custos.commons.exceptions.CustosSecurityException;
 import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.commons.model.security.UserInfo;
 
 import java.util.Map;
 
@@ -35,11 +36,10 @@ public interface CustosSecurityManager {
     /**
      * Implement this method with the user authentication/authorization logic in your SecurityManager.
      * @param authzToken : this includes OAuth token and user's claims
-     * @param metaData : this includes other meta data needed for security enforcements.
      * @return
      * @throws CustosSecurityException
      */
-    public boolean isUserAuthorized(AuthzToken authzToken, Map<String, String> metaData) throws CustosSecurityException;
+    public boolean isUserAuthenticated(AuthzToken authzToken) throws CustosSecurityException;
 
 
     /**
@@ -48,7 +48,7 @@ public interface CustosSecurityManager {
      * @return
      * @throws CustosSecurityException
      */
-    public AuthzToken getUserManagementServiceAccountAuthzToken(String gatewayId) throws CustosSecurityException;
+    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosSecurityException;
 
     /**
      * Get OpenID Connect user profile information from the given AuthzToken.
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
index b85ec1e..88cd26f 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
@@ -20,14 +20,14 @@
 */
 package org.apache.custos.security.manager;
 
-
-import org.apache.custos.client.profile.service.ProfileServiceClientFactory;
 import org.apache.custos.commons.exceptions.ApplicationSettingsException;
 import org.apache.custos.commons.exceptions.CustosSecurityException;
 import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.commons.model.security.UserInfo;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.ServerSettings;
 import org.apache.custos.commons.utils.ThriftUtils;
+import org.apache.custos.profile.client.ProfileServiceClientFactory;
 import org.apache.custos.profile.model.workspace.Gateway;
 import org.apache.custos.profile.tenant.cpi.TenantProfileService;
 import org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException;
@@ -57,7 +57,6 @@ import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Base64;
 import java.util.List;
-import java.util.Map;
 
 public class KeyCloakSecurityManager implements CustosSecurityManager {
     private final static Logger logger = LoggerFactory.getLogger(KeyCloakSecurityManager.class);
@@ -85,19 +84,17 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
     }
 
     /**
-     * Implement this method with the user authentication/authorization logic in your SecurityManager.
+     * Implement this method with the user authentication logic in your SecurityManager.
      *
      * @param authzToken : this includes OAuth token and user's claims
-     * @param metaData   : this includes other meta data needed for security enforcements.
      * @return
      * @throws CustosSecurityException
      */
     @Override
-    public boolean isUserAuthorized(AuthzToken authzToken, Map<String, String> metaData) throws CustosSecurityException {
+    public boolean isUserAuthenticated(AuthzToken authzToken) throws CustosSecurityException {
         String subject = authzToken.getClaimsMap().get(Constants.USER_NAME);
         String accessToken = authzToken.getAccessToken();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
-        //String action = "/airavata/" + metaData.get(Constants.API_METHOD_NAME);
         try {
             if (!ServerSettings.isAPISecured()) {
                 return true;
@@ -153,17 +150,17 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
     }
 
     @Override
-    public AuthzToken getUserManagementServiceAccountAuthzToken(String gatewayId) throws CustosSecurityException {
+    public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosSecurityException {
         try {
             initServiceClients();
-            Gateway gateway = tenantProfileClient.getGatewayUsingGatewayId(gatewayId);
+            Gateway gateway = tenantProfileClient.getGatewayUsingGatewayId(authzToken,gatewayId);
             String tokenURL = getTokenEndpoint(gatewayId);
             JSONObject clientCredentials = getClientCredentials(tokenURL, gateway.getOauthClientId(), gateway.getOauthClientSecret());
             String accessToken = clientCredentials.getString("access_token");
-            AuthzToken authzToken = new AuthzToken(accessToken);
-            authzToken.putToClaimsMap(Constants.GATEWAY_ID, gatewayId);
-            authzToken.putToClaimsMap(Constants.USER_NAME, gateway.getOauthClientId());
-            return authzToken;
+            AuthzToken userManagementServiceAccountAuthzToken = new AuthzToken(accessToken);
+            userManagementServiceAccountAuthzToken.putToClaimsMap(Constants.GATEWAY_ID, gatewayId);
+            userManagementServiceAccountAuthzToken.putToClaimsMap(Constants.USER_NAME, gateway.getOauthClientId());
+            return userManagementServiceAccountAuthzToken;
         } catch (Exception e) {
             throw new CustosSecurityException(e);
         } finally {
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/UserInfo.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/UserInfo.java
deleted file mode 100644
index 4687748..0000000
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/UserInfo.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.custos.security.manager;
-
-public class UserInfo {
-    private String sub;
-    private String firstName;
-    private String lastName;
-    private String fullName;
-    private String emailAddress;
-    private String username;
-
-    public String getSub() {
-        return sub;
-    }
-
-    public UserInfo setSub(String sub) {
-        this.sub = sub;
-        return this;
-    }
-
-    public String getFirstName() {
-        return firstName;
-    }
-
-    public UserInfo setFirstName(String firstName) {
-        this.firstName = firstName;
-        return this;
-    }
-
-    public String getLastName() {
-        return lastName;
-    }
-
-    public UserInfo setLastName(String lastName) {
-        this.lastName = lastName;
-        return this;
-    }
-
-    public String getFullName() {
-        return fullName;
-    }
-
-    public UserInfo setFullName(String fullName) {
-        this.fullName = fullName;
-        return this;
-    }
-
-    public String getEmailAddress() {
-        return emailAddress;
-    }
-
-    public UserInfo setEmailAddress(String emailAddress) {
-        this.emailAddress = emailAddress;
-        return this;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public UserInfo setUsername(String username) {
-        this.username = username;
-        return this;
-    }
-}
diff --git a/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/TenantProfileServiceHandler.java b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/TenantProfileServiceHandler.java
index 587095d..32960e9 100644
--- a/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/TenantProfileServiceHandler.java
+++ b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/TenantProfileServiceHandler.java
@@ -45,7 +45,6 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
     private final static Logger logger = LoggerFactory.getLogger(TenantProfileServiceHandler.class);
 
     private TenantProfileRepository tenantProfileRepository;
-    //private DBEventPublisherUtils dbEventPublisherUtils = new DBEventPublisherUtils(DBEventService.TENANT);
 
     public TenantProfileServiceHandler() {
         logger.debug("Initializing TenantProfileServiceHandler");
@@ -75,13 +74,10 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
                     if (gateway.getGatewayApprovalStatus().equals(GatewayApprovalStatus.APPROVED)) {
                         logger.info("Gateway with ID: {}, is now APPROVED, replicating to subscribers.", gateway.getGatewayId());
                         return gateway;
-                        //dbEventPublisherUtils.publish(EntityType.TENANT, CrudType.CREATE, gateway);
                     }
                     else {
                         throw new Exception("Gateway status is not approved");
                     }
-//                    // return internal id
-//                    return gateway.getAiravataInternalGatewayId();
                 } else {
                     throw new Exception("Gateway object is null.");
                 }
@@ -112,8 +108,6 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
 
             if (tenantProfileRepository.update(updatedGateway) != null) {
                 logger.debug("Updated gateway-profile with ID: " + updatedGateway.getGatewayId());
-                // replicate tenant at end-places
-//                dbEventPublisherUtils.publish(EntityType.TENANT, CrudType.UPDATE, updatedGateway);
                 return updatedGateway;
             } else {
                 throw new TException("Could not update the gateway");
@@ -143,10 +137,10 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
         }
     }
 
-    //TODO: check why this was not included, add authToken
+    //TODO: check why this was not included
     @Override
     @SecurityCheck
-    public Gateway getGatewayUsingGatewayId(String gatewayId) throws TenantProfileServiceException, AuthorizationException, TException {
+    public Gateway getGatewayUsingGatewayId(AuthzToken authzToken,String gatewayId) throws TenantProfileServiceException, AuthorizationException, TException {
         try {
             Gateway gateway = tenantProfileRepository.getGatewayUsingId(gatewayId);
             if (gateway == null) {
@@ -168,11 +162,6 @@ public class TenantProfileServiceHandler implements TenantProfileService.Iface {
             logger.debug("Deleting Custos gateway-profile with ID: " + gatewayId + "Internal ID: " + custosInternalGatewayId);
             boolean deleteSuccess = tenantProfileRepository.delete(custosInternalGatewayId);
             if (deleteSuccess) {
-                // delete tenant at end-places
-//                dbEventPublisherUtils.publish(EntityType.TENANT, CrudType.DELETE,
-//                        // pass along gateway datamodel, with correct gatewayId;
-//                        // approvalstatus is not used for delete, hence set dummy value
-//                        new Gateway(gatewayId, GatewayApprovalStatus.DEACTIVATED));
                 return new Gateway(gatewayId, GatewayApprovalStatus.DEACTIVATED);
             }
             else {
diff --git a/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/UserProfileServiceHandler.java b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/UserProfileServiceHandler.java
index 1068863..8cb9c61 100644
--- a/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/UserProfileServiceHandler.java
+++ b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/handlers/UserProfileServiceHandler.java
@@ -20,15 +20,15 @@
 */
 package org.apache.custos.profile.handlers;
 
-
-import org.apache.custos.client.profile.service.ProfileServiceClientFactory;
 import org.apache.custos.commons.exceptions.ApplicationSettingsException;
 import org.apache.custos.commons.exceptions.CustosSecurityException;
 import org.apache.custos.commons.model.error.AuthorizationException;
 import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.commons.model.security.UserInfo;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.CustosUtils;
 import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.profile.client.ProfileServiceClientFactory;
 import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
 import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
 import org.apache.custos.profile.model.user.Status;
@@ -40,7 +40,6 @@ import org.apache.custos.profile.user.cpi.exception.UserProfileServiceException;
 import org.apache.custos.security.interceptor.SecurityCheck;
 import org.apache.custos.security.manager.CustosSecurityManager;
 import org.apache.custos.security.manager.SecurityManagerFactory;
-import org.apache.custos.security.manager.UserInfo;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,7 +52,6 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     private final static Logger logger = LoggerFactory.getLogger(UserProfileServiceHandler.class);
 
     private UserProfileRepository userProfileRepository;
-    //private DBEventPublisherUtils dbEventPublisherUtils = new DBEventPublisherUtils(DBEventService.USER_PROFILE);
 
     public UserProfileServiceHandler() {
 
@@ -66,14 +64,14 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    @SecurityCheck
+    //@SecurityCheck
     public UserProfile initializeUserProfile(AuthzToken authzToken) throws UserProfileServiceException, AuthorizationException {
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
         try {
             // Load UserInfo for the access token and create an initial UserProfile from it
             UserInfo userInfo = SecurityManagerFactory.getSecurityManager().getUserInfoFromAuthzToken(authzToken);
             final UserProfile existingProfile = userProfileRepository.getUserProfileByIdAndGateWay(userInfo.getUsername(), gatewayId);
-            // If a user profile already exists, just return the userId
+            // If a user profile already exists, just return the existing profile
             if (existingProfile != null) {
                 return existingProfile;
             }
@@ -104,7 +102,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    @SecurityCheck
+    //@SecurityCheck
     public UserProfile addUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException, AuthorizationException {
         try{
             // Lowercase user id and internal id
@@ -126,7 +124,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    @SecurityCheck
+    //@SecurityCheck
     public UserProfile updateUserProfile(AuthzToken authzToken, UserProfile userProfile) throws UserProfileServiceException, AuthorizationException {
         try {
             // After updating the user profile in the database but before committing the transaction, the
@@ -151,7 +149,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
         return () -> {
             try {
                 CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
-                AuthzToken serviceAccountAuthzToken = securityManager.getUserManagementServiceAccountAuthzToken(gatewayId);
+                AuthzToken serviceAccountAuthzToken = securityManager.getUserManagementServiceAccountAuthzToken(authzToken,gatewayId);
                 IamAdminServices.Client iamAdminServicesClient = getIamAdminServicesClient();
                 iamAdminServicesClient.updateUserProfile(serviceAccountAuthzToken, userProfile);
             } catch (CustosSecurityException |TException e) {
@@ -161,7 +159,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    @SecurityCheck
+    //@SecurityCheck
     public UserProfile getUserProfileById(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException, AuthorizationException, TException {
         try{
             UserProfile userProfile = userProfileRepository.getUserProfileByIdAndGateWay(userId, gatewayId);
@@ -178,7 +176,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    @SecurityCheck
+    //@SecurityCheck
     public UserProfile deleteUserProfile(AuthzToken authzToken, String userId, String gatewayId) throws UserProfileServiceException, AuthorizationException, TException {
         UserProfile userProfile = null;
         try{
@@ -198,7 +196,7 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
     }
 
     @Override
-    @SecurityCheck
+    //@SecurityCheck
     public List<UserProfile> getAllUserProfilesInGateway(AuthzToken authzToken, String gatewayId, int offset, int limit) throws UserProfileServiceException, AuthorizationException {
         try{
             List<UserProfile> usersInGateway = userProfileRepository.getAllUserProfilesInGateway(gatewayId, offset, limit);
diff --git a/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/server/ProfileServiceServer.java b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/server/ProfileServiceServer.java
index cb1923e..55ce1ca 100644
--- a/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/server/ProfileServiceServer.java
+++ b/custos-profile-service/profile-service-server/src/main/java/org/apache/custos/profile/server/ProfileServiceServer.java
@@ -101,14 +101,14 @@ public class ProfileServiceServer implements IServer {
 
             // create multiple processors for each profile-service
             UserProfileService.Processor userProfileProcessor = new UserProfileService.Processor(new UserProfileServiceHandler());
-            TenantProfileService.Processor teneantProfileProcessor = new TenantProfileService.Processor(new TenantProfileServiceHandler());
+            //TenantProfileService.Processor teneantProfileProcessor = new TenantProfileService.Processor(new TenantProfileServiceHandler());
             IamAdminServices.Processor iamAdminServicesProcessor = new IamAdminServices.Processor(new IamAdminServicesHandler());
             //GroupManagerService.Processor groupmanagerProcessor = new GroupManagerService.Processor(new GroupManagerServiceHandler());
 
             // create a multiplexed processor
             TMultiplexedProcessor profileServiceProcessor = new TMultiplexedProcessor();
             profileServiceProcessor.registerProcessor(profile_user_cpiConstants.USER_PROFILE_CPI_NAME, userProfileProcessor);
-            profileServiceProcessor.registerProcessor(profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME, teneantProfileProcessor);
+            //profileServiceProcessor.registerProcessor(profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME, teneantProfileProcessor);
             profileServiceProcessor.registerProcessor(iam_admin_services_cpiConstants.IAM_ADMIN_SERVICES_CPI_NAME, iamAdminServicesProcessor);
             //profileServiceProcessor.registerProcessor(group_manager_cpiConstants.GROUP_MANAGER_CPI_NAME, groupmanagerProcessor);
 
diff --git a/custos-client/src/main/java/org/apache/custos/client/profile/service/ProfileServiceClientFactory.java b/custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/client/ProfileServiceClientFactory.java
similarity index 83%
rename from custos-client/src/main/java/org/apache/custos/client/profile/service/ProfileServiceClientFactory.java
rename to custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/client/ProfileServiceClientFactory.java
index aa8f476..c62f467 100644
--- a/custos-client/src/main/java/org/apache/custos/client/profile/service/ProfileServiceClientFactory.java
+++ b/custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/client/ProfileServiceClientFactory.java
@@ -1,4 +1,4 @@
-/**
+/*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -16,8 +16,9 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
+ *
  */
-package org.apache.custos.client.profile.service;
+package org.apache.custos.profile.client;
 
 import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
 import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
@@ -74,16 +75,4 @@ public class ProfileServiceClientFactory {
             throw new IamAdminServicesException(e.getMessage());
         }
     }
-
-//    public static GroupManagerService.Client createGroupManagerServiceClient(String serverHost, int serverPort)  throws GroupManagerServiceException {
-//        try {
-//            TTransport transport = new TSocket(serverHost, serverPort);
-//            transport.open();
-//            TProtocol protocol = new TBinaryProtocol(transport);
-//            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, group_manager_cpiConstants.GROUP_MANAGER_CPI_NAME);
-//            return new GroupManagerService.Client(multiplexedProtocol);
-//        } catch (TTransportException e) {
-//            throw new GroupManagerServiceException(e.getMessage());
-//        }
-//    }
 }
\ No newline at end of file
diff --git a/custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/tenant.cpi/TenantProfileService.java b/custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/tenant.cpi/TenantProfileService.java
index fd14208..3bb0507 100644
--- a/custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/tenant.cpi/TenantProfileService.java
+++ b/custos-profile-service/profile-service-stubs/src/main/java/org/apache/custos/profile/tenant.cpi/TenantProfileService.java
@@ -7,7 +7,7 @@
 package org.apache.custos.profile.tenant.cpi;
 
 @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-06-24")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-05")
 public class TenantProfileService {
 
   public interface Iface {
@@ -26,7 +26,7 @@ public class TenantProfileService {
 
     public org.apache.custos.profile.model.workspace.Gateway getGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
-    public org.apache.custos.profile.model.workspace.Gateway getGatewayUsingGatewayId(String gatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
+    public org.apache.custos.profile.model.workspace.Gateway getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
     public org.apache.custos.profile.model.workspace.Gateway deleteGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId, String gatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException;
 
@@ -48,7 +48,7 @@ public class TenantProfileService {
 
     public void getGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
 
-    public void getGatewayUsingGatewayId(String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
+    public void getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
 
     public void deleteGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, String custosInternalGatewayId, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
 
@@ -195,15 +195,16 @@ public class TenantProfileService {
       throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getGateway failed: unknown result");
     }
 
-    public org.apache.custos.profile.model.workspace.Gateway getGatewayUsingGatewayId(String gatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
+    public org.apache.custos.profile.model.workspace.Gateway getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException, org.apache.custos.commons.model.error.AuthorizationException, org.apache.thrift.TException
     {
-      send_getGatewayUsingGatewayId(gatewayId);
+      send_getGatewayUsingGatewayId(authzToken, gatewayId);
       return recv_getGatewayUsingGatewayId();
     }
 
-    public void send_getGatewayUsingGatewayId(String gatewayId) throws org.apache.thrift.TException
+    public void send_getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId) throws org.apache.thrift.TException
     {
       getGatewayUsingGatewayId_args args = new getGatewayUsingGatewayId_args();
+      args.setAuthzToken(authzToken);
       args.setGatewayId(gatewayId);
       sendBase("getGatewayUsingGatewayId", args);
     }
@@ -496,23 +497,26 @@ public class TenantProfileService {
       }
     }
 
-    public void getGatewayUsingGatewayId(String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
+    public void getGatewayUsingGatewayId(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
       checkReady();
-      getGatewayUsingGatewayId_call method_call = new getGatewayUsingGatewayId_call(gatewayId, resultHandler, this, ___protocolFactory, ___transport);
+      getGatewayUsingGatewayId_call method_call = new getGatewayUsingGatewayId_call(authzToken, gatewayId, resultHandler, this, ___protocolFactory, ___transport);
       this.___currentMethod = method_call;
       ___manager.call(method_call);
     }
 
     public static class getGatewayUsingGatewayId_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.profile.model.workspace.Gateway> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
       private String gatewayId;
-      public getGatewayUsingGatewayId_call(String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
+      public getGatewayUsingGatewayId_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String gatewayId, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> 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;
       }
 
       public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
         prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getGatewayUsingGatewayId", org.apache.thrift.protocol.TMessageType.CALL, 0));
         getGatewayUsingGatewayId_args args = new getGatewayUsingGatewayId_args();
+        args.setAuthzToken(authzToken);
         args.setGatewayId(gatewayId);
         args.write(prot);
         prot.writeMessageEnd();
@@ -836,7 +840,7 @@ public class TenantProfileService {
       public getGatewayUsingGatewayId_result getResult(I iface, getGatewayUsingGatewayId_args args) throws org.apache.thrift.TException {
         getGatewayUsingGatewayId_result result = new getGatewayUsingGatewayId_result();
         try {
-          result.success = iface.getGatewayUsingGatewayId(args.gatewayId);
+          result.success = iface.getGatewayUsingGatewayId(args.authzToken, args.gatewayId);
         } catch (org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException tpe) {
           result.tpe = tpe;
         } catch (org.apache.custos.commons.model.error.AuthorizationException ae) {
@@ -1333,7 +1337,7 @@ public class TenantProfileService {
       }
 
       public void start(I iface, getGatewayUsingGatewayId_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
-        iface.getGatewayUsingGatewayId(args.gatewayId,resultHandler);
+        iface.getGatewayUsingGatewayId(args.authzToken, args.gatewayId,resultHandler);
       }
     }
 
@@ -5513,16 +5517,19 @@ public class TenantProfileService {
   public static class getGatewayUsingGatewayId_args implements org.apache.thrift.TBase<getGatewayUsingGatewayId_args, getGatewayUsingGatewayId_args._Fields>, java.io.Serializable, Cloneable, Comparable<getGatewayUsingGatewayId_args>   {
     private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getGatewayUsingGatewayId_args");
 
-    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)1);
+    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.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getGatewayUsingGatewayId_argsStandardSchemeFactory();
     private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getGatewayUsingGatewayId_argsTupleSchemeFactory();
 
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
     public @org.apache.thrift.annotation.Nullable String gatewayId; // 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 {
-      GATEWAY_ID((short)1, "gatewayId");
+      AUTHZ_TOKEN((short)1, "authzToken"),
+      GATEWAY_ID((short)2, "gatewayId");
 
       private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
@@ -5538,7 +5545,9 @@ public class TenantProfileService {
       @org.apache.thrift.annotation.Nullable
       public static _Fields findByThriftId(int fieldId) {
         switch(fieldId) {
-          case 1: // GATEWAY_ID
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          case 2: // GATEWAY_ID
             return GATEWAY_ID;
           default:
             return null;
@@ -5584,6 +5593,8 @@ public class TenantProfileService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.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)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
@@ -5594,9 +5605,11 @@ public class TenantProfileService {
     }
 
     public getGatewayUsingGatewayId_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
       String gatewayId)
     {
       this();
+      this.authzToken = authzToken;
       this.gatewayId = gatewayId;
     }
 
@@ -5604,6 +5617,9 @@ public class TenantProfileService {
      * Performs a deep copy on <i>other</i>.
      */
     public getGatewayUsingGatewayId_args(getGatewayUsingGatewayId_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
       if (other.isSetGatewayId()) {
         this.gatewayId = other.gatewayId;
       }
@@ -5615,10 +5631,36 @@ public class TenantProfileService {
 
     @Override
     public void clear() {
+      this.authzToken = null;
       this.gatewayId = null;
     }
 
     @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public getGatewayUsingGatewayId_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
     public String getGatewayId() {
       return this.gatewayId;
     }
@@ -5645,6 +5687,14 @@ public class TenantProfileService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
       case GATEWAY_ID:
         if (value == null) {
           unsetGatewayId();
@@ -5659,6 +5709,9 @@ public class TenantProfileService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
       case GATEWAY_ID:
         return getGatewayId();
 
@@ -5673,6 +5726,8 @@ public class TenantProfileService {
       }
 
       switch (field) {
+      case AUTHZ_TOKEN:
+        return isSetAuthzToken();
       case GATEWAY_ID:
         return isSetGatewayId();
       }
@@ -5694,6 +5749,15 @@ public class TenantProfileService {
       if (this == that)
         return true;
 
+      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) {
@@ -5710,6 +5774,10 @@ public class TenantProfileService {
     public int hashCode() {
       int hashCode = 1;
 
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
       hashCode = hashCode * 8191 + ((isSetGatewayId()) ? 131071 : 524287);
       if (isSetGatewayId())
         hashCode = hashCode * 8191 + gatewayId.hashCode();
@@ -5725,6 +5793,16 @@ public class TenantProfileService {
 
       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;
@@ -5756,6 +5834,14 @@ public class TenantProfileService {
       StringBuilder sb = new StringBuilder("getGatewayUsingGatewayId_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");
@@ -5769,10 +5855,16 @@ public class TenantProfileService {
 
     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());
       }
       // check for sub-struct validity
+      if (authzToken != null) {
+        authzToken.validate();
+      }
     }
 
     private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -5809,7 +5901,16 @@ public class TenantProfileService {
             break;
           }
           switch (schemeField.id) {
-            case 1: // GATEWAY_ID
+            case 1: // AUTHZ_TOKEN
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.authzToken = new org.apache.custos.commons.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);
@@ -5832,6 +5933,11 @@ public class TenantProfileService {
         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);
@@ -5854,12 +5960,16 @@ public class TenantProfileService {
       @Override
       public void write(org.apache.thrift.protocol.TProtocol prot, getGatewayUsingGatewayId_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
         oprot.writeString(struct.gatewayId);
       }
 
       @Override
       public void read(org.apache.thrift.protocol.TProtocol prot, getGatewayUsingGatewayId_args struct) throws org.apache.thrift.TException {
         org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
         struct.gatewayId = iprot.readString();
         struct.setGatewayIdIsSet(true);
       }
diff --git a/pom.xml b/pom.xml
index 7bcdf03..59f9579 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,7 @@
         <module>custos-profile-service</module>
         <module>custos-client</module>
         <module>ide-integration</module>
+        <module>custos-authentication</module>
     </modules>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/thrift-interfaces/authentication-service/authentication-service-cpi.thrift b/thrift-interfaces/authentication-service/authentication-service-cpi.thrift
new file mode 100644
index 0000000..3e40dd3
--- /dev/null
+++ b/thrift-interfaces/authentication-service/authentication-service-cpi.thrift
@@ -0,0 +1,14 @@
+namespace java org.apache.custos.authentication.cpi
+namespace php Custos.Authentication.CPI
+namespace py custos.authentication.cpi
+
+include "../custos-apis/security_model.thrift"
+include "authentication_service_cpi_errors.thrift"
+include "../custos-apis/userInfo_model.thrift"
+
+service CustosAuthenticationService {
+    bool isUserAuthenticated(1: required security_model.AuthzToken authzToken)
+                            throws (1: authentication_service_cpi_errors.CustosAuthenticationServiceException ae)
+    userInfo_model.UserInfo getUserInfoFromAuthzToken(1: required security_model.AuthzToken authzToken) throws (1: authentication_service_cpi_errors.CustosAuthenticationServiceException ae)
+    security_model.AuthzToken getUserManagementServiceAccountAuthzToken(1: required security_model.AuthzToken authzToken, 2: required string gatewayId) throws (1: authentication_service_cpi_errors.CustosAuthenticationServiceException ae)
+}
diff --git a/thrift-interfaces/authentication-service/authentication_service_cpi_errors.thrift b/thrift-interfaces/authentication-service/authentication_service_cpi_errors.thrift
new file mode 100644
index 0000000..a2eae1b
--- /dev/null
+++ b/thrift-interfaces/authentication-service/authentication_service_cpi_errors.thrift
@@ -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.
+ *
+ */
+
+namespace java org.apache.custos.authentication.cpi.exception
+namespace php Custos.Authentication.CPI.Error
+namespace py custos.authentication.cpi.error
+
+exception CustosAuthenticationServiceException {
+  1: required string message
+}
diff --git a/thrift-interfaces/custos-apis/userInfo_model.thrift b/thrift-interfaces/custos-apis/userInfo_model.thrift
new file mode 100644
index 0000000..f2af21f
--- /dev/null
+++ b/thrift-interfaces/custos-apis/userInfo_model.thrift
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ *
+ */
+
+namespace java org.apache.custos.commons.model.security
+namespace php Custos.Commons.Model.Security
+namespace cpp apache.custos.commons.model.security
+namespace py custos.commons.model.security
+
+struct UserInfo {
+    1: required string sub;
+    2: required string firstName;
+    3: required string lastName;
+    4: required string fullName;
+    5: required string emailAddress;
+    6: required string username;
+}
\ No newline at end of file
diff --git a/thrift-interfaces/profile-service/profile-tenant/profile-tenant-cpi.thrift b/thrift-interfaces/profile-service/profile-tenant/profile-tenant-cpi.thrift
index 826fc57..ad5b2c3 100644
--- a/thrift-interfaces/profile-service/profile-tenant/profile-tenant-cpi.thrift
+++ b/thrift-interfaces/profile-service/profile-tenant/profile-tenant-cpi.thrift
@@ -57,9 +57,9 @@ service TenantProfileService {
                                         2: required string custosInternalGatewayId)
                                      throws (1: profile_tenant_cpi_errors.TenantProfileServiceException tpe,
                                              2: custos_errors.AuthorizationException ae)
-    //TODO: check why this method was not included here, add authztoken
-    workspace_model.Gateway getGatewayUsingGatewayId (
-                                             1: required string gatewayId)
+    //TODO: check why this method was not included here
+    workspace_model.Gateway getGatewayUsingGatewayId (1: required security_model.AuthzToken authzToken,
+                                             2: required string gatewayId)
                                           throws (1: profile_tenant_cpi_errors.TenantProfileServiceException tpe,
                                                   2: custos_errors.AuthorizationException ae)
 


[airavata-custos] 30/48: added readme, log4j properties files, samples for end to end testing of services and deleted unnecessary configuration files

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5595257d48fb1ba2e5528d74083d73831d2586e7
Author: Aarushi <aa...@gmail.com>
AuthorDate: Thu Aug 22 18:45:43 2019 -0400

    added readme, log4j properties files, samples for end to end testing of services and deleted unnecessary configuration files
---
 .../handler/CustosAuthenticationHandler.java       |   2 +-
 custos-commons/custos-server.properties            |   0
 .../src/main/resources/custos-server.properties    |  10 +-
 .../src/main/resources/keystores/airavata.jks      | Bin 2679 -> 0 bytes
 .../src/main/resources/keystores/airavata_sym.jks  | Bin 501 -> 0 bytes
 .../main/resources/keystores/client_truststore.jks | Bin 1027 -> 963 bytes
 ide-integration/README.md                          |  64 ++++++++++++
 .../sample/CustosAuthenticationServiceSample.java  | 108 ---------------------
 .../src/main/resources/custos-server.properties    |   8 +-
 .../src/main/resources/docker-compose.yml          |   2 +-
 .../src/main/resources/keycloak/standalone.xml     |   2 +-
 .../src/main/resources/keystores/airavata.jks      | Bin 2679 -> 0 bytes
 .../src/main/resources/keystores/airavata_sym.jks  | Bin 501 -> 0 bytes
 .../main/resources/keystores/client_truststore.jks | Bin 1027 -> 0 bytes
 .../src/main/resources/keystores/custos.jks        | Bin 0 -> 2252 bytes
 .../src/main/resources}/log4j.properties           |   8 +-
 ide-integration/pom.xml                            |   3 +-
 .../commons}/pom.xml                               |   4 +-
 .../org/apache/samples/common/SamplesCommon.java   |  60 ++++++++++++
 .../custos-authentication-service-samples/pom.xml  |   8 ++
 .../sample/CustosAuthenticationServiceSample.java  |  64 ++++++++++++
 .../src/main/resources/log4j.properties            |  10 +-
 .../custos-profile-service-samples/pom.xml         |   7 ++
 .../service/samples/TenantProfileSample.java       |   0
 .../profile/service/samples/UserProfileSample.java |  89 ++++-------------
 .../samples/utils/ProfileServiceClientUtil.java    |   0
 .../src/main/resources/log4j.properties            |  10 +-
 .../resources/profile-client-sample.properties     |   0
 .../pom.xml                                        |   9 +-
 29 files changed, 255 insertions(+), 213 deletions(-)

diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
index 8a7de8c..8706071 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
@@ -20,7 +20,7 @@ public class CustosAuthenticationHandler implements CustosAuthenticationService.
             CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
             boolean isAuth = securityManager.isUserAuthenticated(authzToken);
                 if (isAuth) {
-                    logger.info("User" + authzToken.getClaimsMap().get(Constants.USER_NAME) + "in gateway" + authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + "is authenticated");
+                    logger.info("User " + authzToken.getClaimsMap().get(Constants.USER_NAME) + " in gateway " + authzToken.getClaimsMap().get(Constants.GATEWAY_ID) + " is authenticated");
                     return isAuth;
                 }
                 else{
diff --git a/custos-commons/custos-server.properties b/custos-commons/custos-server.properties
deleted file mode 100644
index e69de29..0000000
diff --git a/custos-commons/src/main/resources/custos-server.properties b/custos-commons/src/main/resources/custos-server.properties
index d9d59c3..c5d0b2f 100644
--- a/custos-commons/src/main/resources/custos-server.properties
+++ b/custos-commons/src/main/resources/custos-server.properties
@@ -34,16 +34,16 @@ security.manager.class=org.apache.custos.security.manager.KeyCloakSecurityManage
 ###########################################################################
 # Iam Admin services Configuration
 ###########################################################################
-iam.server.url=https://airavata.host:8443/auth
+iam.server.url=https://localhost:8443/auth
 iam.server.super.admin.username=admin
 iam.server.super.admin.password=admin
 
 #### keystore configuration ####
-keystore.path=keystores/airavata.jks
-keystore.password=airavata
+keystore.path=keystores/custos.jks
+keystore.password=custos
 #### trust store configuration ####
 trust.store=keystores/client_truststore.jks
-trust.store.password=airavata
+trust.store.password=custos
 
 #### authorization cache related configuration ####
 authz.cache.enabled=true
@@ -54,7 +54,7 @@ in.memory.cache.size=1000
 # Profile Service Configuration
 ###########################################################################
 profile.service.server.host=0.0.0.0
-profile.service.server.port=9092
+profile.service.server.port=8081
 profile_service=org.apache.custos.profile.server.ProfileServiceServer
 
 # MariaDB properties
diff --git a/custos-connectors/src/main/resources/keystores/airavata.jks b/custos-connectors/src/main/resources/keystores/airavata.jks
deleted file mode 100644
index b732322..0000000
Binary files a/custos-connectors/src/main/resources/keystores/airavata.jks and /dev/null differ
diff --git a/custos-connectors/src/main/resources/keystores/airavata_sym.jks b/custos-connectors/src/main/resources/keystores/airavata_sym.jks
deleted file mode 100644
index 57434f0..0000000
Binary files a/custos-connectors/src/main/resources/keystores/airavata_sym.jks and /dev/null differ
diff --git a/custos-connectors/src/main/resources/keystores/client_truststore.jks b/custos-connectors/src/main/resources/keystores/client_truststore.jks
index a7a604c..6b16a4f 100644
Binary files a/custos-connectors/src/main/resources/keystores/client_truststore.jks and b/custos-connectors/src/main/resources/keystores/client_truststore.jks differ
diff --git a/ide-integration/README.md b/ide-integration/README.md
new file mode 100644
index 0000000..a54aacf
--- /dev/null
+++ b/ide-integration/README.md
@@ -0,0 +1,64 @@
+## Introduction 
+
+This module is to setup custos authentication, profile services inside Intelij IDEA for development purposes
+
+## Prerequisites
+
+* Docker installed with 'docker-compose' utility
+  https://docs.docker.com/compose/
+
+* InteliJ IDEA with Java 8 installed
+  https://www.jetbrains.com/idea/download/
+
+* Maven
+
+* Git
+
+## Steps
+
+### Setting up the development environment
+
+* Clone Custos repository to a local directory
+
+  ```
+  git clone https://github.com/apache/airavata-custos
+  ```
+
+* Checkout develop branch
+  ```
+  git checkout develop
+  ```
+* Open the project using InteliJ IDEA
+  
+* Browse to ide-integration -> custos-services -> src-> main -> resources
+
+* start the docker containers 
+
+    ```
+    docker-compose up -d
+    ```
+* check if docker containers are up
+    ```
+    docker-compose ps
+    ``` 
+
+* Build the develop branch using Maven
+
+
+### Starting the services
+
+* Go to org.apache.custos.server.start.CustosAPIServerStarter class and right click on the editor and click Run option. This will start profile and authentication server.
+* The port on which profile and authentication service run can be changed in the custos-server.properties file found in the resources folder.
+* Once the services are up and running. Go to org.apache.custos.profile.service.samples to run code samples for tenant and profile services and org.apache.custos.authentication.service.sample.CustosAuthenticationServiceSample
+
+### Stop all components
+
+* For each composer file, run following commands to cleanup docker spawned components
+
+  ```
+  docker-compose down
+  ```
+ 
+  ```
+  docker-compose rm
+  ```
diff --git a/ide-integration/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java b/ide-integration/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java
deleted file mode 100644
index ac2c122..0000000
--- a/ide-integration/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.apache.custos.authentication.service.sample;
-
-import org.apache.custos.authentication.cpi.CustosAuthenticationService;
-import org.apache.custos.client.authentication.service.AuthenticationServiceClientFactory;
-import org.apache.custos.commons.exceptions.CustosSecurityException;
-import org.apache.custos.commons.model.security.AuthzToken;
-import org.apache.custos.commons.utils.Constants;
-import org.apache.custos.security.manager.KeyCloakSecurityManager;
-import org.apache.http.Consts;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.EntityUtils;
-import org.apache.thrift.TException;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-public class CustosAuthenticationServiceSample {
-
-    private static final Logger log = LoggerFactory.getLogger(CustosAuthenticationServiceSample.class);
-    //present in keycloak json configuration
-    public static String USERNAME = "default-admin";
-    public static String GATEWAY_ID = "default";
-
-    public static void main(String[] args) throws Exception{
-
-        try {
-            //change this based on the port on which the server is started
-            String serverHost = "localhost";
-            int serverPort = 9091;
-            CustosAuthenticationService.Client client = AuthenticationServiceClientFactory.createAuthenticationServiceClient(serverHost, serverPort);
-            testUserAuthentication(client);
-        }catch (TException e) {
-            throw new Exception(e);
-        }catch (Exception e){
-            throw new Exception("Error setting up the authentication server", e);
-        }
-    }
-
-    public static void testUserAuthentication(CustosAuthenticationService.Client client) throws TException, CustosSecurityException {
-        boolean authenticated = false;
-        new KeyCloakSecurityManager().initializeSecurityInfra();
-        AuthzToken authzToken = new AuthzToken();
-        HashMap<String, String> map_ = new HashMap<>();
-        map_.put(Constants.GATEWAY_ID, GATEWAY_ID);
-        map_.put(Constants.USER_NAME, USERNAME);
-        authzToken.setClaimsMap(map_);
-        JSONObject json = getAccessToken();
-        if(json.has("access_token")){
-            String access_token = getAccessToken().get("access_token").toString();
-            authzToken.setAccessToken(access_token);
-            authenticated = client.isUserAuthenticated(authzToken);
-        }
-
-        assert (authenticated): "User authenticating failed";
-        if(authenticated){
-            log.info("User successfully authenticated");
-        }
-
-    }
-
-    private static JSONObject getAccessToken() {
-        String password = "123456";
-        String tokenEndPoint = "https://airavata.host:8443/auth/realms/default/protocol/openid-connect/token";
-        String grant_type = "password";
-        String client_id = "admin-cli";
-
-        CloseableHttpClient httpClient = HttpClients.createSystem();
-        HttpPost httpPost = new HttpPost(tokenEndPoint);
-        ;
-        List<NameValuePair> formParams = new ArrayList<>();
-        formParams.add(new BasicNameValuePair("grant_type", "password"));
-        formParams.add(new BasicNameValuePair("client_id", client_id));
-        formParams.add(new BasicNameValuePair("username", USERNAME));
-        formParams.add(new BasicNameValuePair("password", password));
-        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
-        httpPost.setEntity(entity);
-        try {
-            CloseableHttpResponse response = httpClient.execute(httpPost);
-            try {
-                String responseBody = EntityUtils.toString(response.getEntity());
-                JSONObject tokenInfo = new JSONObject(responseBody);
-                return tokenInfo;
-            } finally {
-                response.close();
-            }
-
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        } finally {
-            try {
-                httpClient.close();
-            } catch (IOException e) {
-                throw new RuntimeException(e);
-            }
-        }
-    }
-}
diff --git a/ide-integration/custos-services/src/main/resources/custos-server.properties b/ide-integration/custos-services/src/main/resources/custos-server.properties
index 2e07020..c5d0b2f 100644
--- a/ide-integration/custos-services/src/main/resources/custos-server.properties
+++ b/ide-integration/custos-services/src/main/resources/custos-server.properties
@@ -34,16 +34,16 @@ security.manager.class=org.apache.custos.security.manager.KeyCloakSecurityManage
 ###########################################################################
 # Iam Admin services Configuration
 ###########################################################################
-iam.server.url=https://airavata.host:8443/auth
+iam.server.url=https://localhost:8443/auth
 iam.server.super.admin.username=admin
 iam.server.super.admin.password=admin
 
 #### keystore configuration ####
-keystore.path=keystores/airavata.jks
-keystore.password=airavata
+keystore.path=keystores/custos.jks
+keystore.password=custos
 #### trust store configuration ####
 trust.store=keystores/client_truststore.jks
-trust.store.password=airavata
+trust.store.password=custos
 
 #### authorization cache related configuration ####
 authz.cache.enabled=true
diff --git a/ide-integration/custos-services/src/main/resources/docker-compose.yml b/ide-integration/custos-services/src/main/resources/docker-compose.yml
index 5ced9a8..e43b9ec 100644
--- a/ide-integration/custos-services/src/main/resources/docker-compose.yml
+++ b/ide-integration/custos-services/src/main/resources/docker-compose.yml
@@ -10,7 +10,7 @@ services:
       - "8443:8443"
     volumes:
       - ./keycloak/Default-export.json:/opt/keycloak/Default-export.json
-      - ./keystores/airavata.jks:/opt/jboss/keycloak/standalone/configuration/keystores/airavata.jks
+      - ./keystores/custos.jks:/opt/jboss/keycloak/standalone/configuration/keystores/custos.jks
       - ./keycloak/standalone.xml:/opt/jboss/keycloak/standalone/configuration/standalone.xml
     command: ["-b", "0.0.0.0", "-Dkeycloak.migration.action=import", "-Dkeycloak.migration.provider=singleFile", "-Dkeycloak.migration.file=/opt/keycloak/Default-export.json", "-Dkeycloak.migration.strategy=OVERWRITE_EXISTING"]
   db:
diff --git a/ide-integration/custos-services/src/main/resources/keycloak/standalone.xml b/ide-integration/custos-services/src/main/resources/keycloak/standalone.xml
index f3eaea9..83006ef 100644
--- a/ide-integration/custos-services/src/main/resources/keycloak/standalone.xml
+++ b/ide-integration/custos-services/src/main/resources/keycloak/standalone.xml
@@ -47,7 +47,7 @@
             <security-realm name="UndertowRealm">
                 <server-identities>
                     <ssl>
-                        <keystore path="keystores/airavata.jks" relative-to="jboss.server.config.dir" keystore-password="airavata" />
+                        <keystore path="keystores/custos.jks" relative-to="jboss.server.config.dir" keystore-password="custos" />
                     </ssl>
                 </server-identities>
             </security-realm>
diff --git a/ide-integration/custos-services/src/main/resources/keystores/airavata.jks b/ide-integration/custos-services/src/main/resources/keystores/airavata.jks
deleted file mode 100644
index b732322..0000000
Binary files a/ide-integration/custos-services/src/main/resources/keystores/airavata.jks and /dev/null differ
diff --git a/ide-integration/custos-services/src/main/resources/keystores/airavata_sym.jks b/ide-integration/custos-services/src/main/resources/keystores/airavata_sym.jks
deleted file mode 100644
index 57434f0..0000000
Binary files a/ide-integration/custos-services/src/main/resources/keystores/airavata_sym.jks and /dev/null differ
diff --git a/ide-integration/custos-services/src/main/resources/keystores/client_truststore.jks b/ide-integration/custos-services/src/main/resources/keystores/client_truststore.jks
deleted file mode 100644
index a7a604c..0000000
Binary files a/ide-integration/custos-services/src/main/resources/keystores/client_truststore.jks and /dev/null differ
diff --git a/ide-integration/custos-services/src/main/resources/keystores/custos.jks b/ide-integration/custos-services/src/main/resources/keystores/custos.jks
new file mode 100644
index 0000000..05a4a06
Binary files /dev/null and b/ide-integration/custos-services/src/main/resources/keystores/custos.jks differ
diff --git a/ide-integration/log4j.properties b/ide-integration/custos-services/src/main/resources/log4j.properties
similarity index 83%
rename from ide-integration/log4j.properties
rename to ide-integration/custos-services/src/main/resources/log4j.properties
index 0328252..4313d4a 100644
--- a/ide-integration/log4j.properties
+++ b/ide-integration/custos-services/src/main/resources/log4j.properties
@@ -17,16 +17,14 @@
 # under the License.
 #
 
-# Set root category priority to INFO and its only appender to CONSOLE.
-log4j.rootCategory=INFO, ERROR, CONSOLE,LOGFILE
-log4j.rootLogger=INFO, ERROR, CONSOLE, LOGFILE
 
-         
+log4j.rootCategory=INFO, CONSOLE, LOGFILE
+log4j.rootLogger=INFO, CONSOLE, LOGFILE
+
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
 log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n
 
-# LOGFILE is set to be a File appender using a PatternLayout.
 log4j.appender.LOGFILE=org.apache.log4j.FileAppender
 log4j.appender.LOGFILE.File=./target/custos-server.log
 log4j.appender.LOGFILE.Append=true
diff --git a/ide-integration/pom.xml b/ide-integration/pom.xml
index a91f3dc..969fd9f 100644
--- a/ide-integration/pom.xml
+++ b/ide-integration/pom.xml
@@ -12,9 +12,8 @@
     <artifactId>ide-integration</artifactId>
     <packaging>pom</packaging>
     <modules>
-        <module>custos-profile-service-samples</module>
-        <module>custos-authentication-service-samples</module>
         <module>custos-services</module>
+        <module>samples</module>
     </modules>
     <dependencies>
         <dependency>
diff --git a/ide-integration/custos-profile-service-samples/pom.xml b/ide-integration/samples/commons/pom.xml
similarity index 77%
copy from ide-integration/custos-profile-service-samples/pom.xml
copy to ide-integration/samples/commons/pom.xml
index 070cda2..e8aa003 100644
--- a/ide-integration/custos-profile-service-samples/pom.xml
+++ b/ide-integration/samples/commons/pom.xml
@@ -3,13 +3,13 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>ide-integration</artifactId>
+        <artifactId>samples</artifactId>
         <groupId>org.apache.custos</groupId>
         <version>1.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>custos-profile-service-samples</artifactId>
+    <artifactId>commons</artifactId>
 
 
 </project>
\ No newline at end of file
diff --git a/ide-integration/samples/commons/src/main/java/org/apache/samples/common/SamplesCommon.java b/ide-integration/samples/commons/src/main/java/org/apache/samples/common/SamplesCommon.java
new file mode 100644
index 0000000..9f508b4
--- /dev/null
+++ b/ide-integration/samples/commons/src/main/java/org/apache/samples/common/SamplesCommon.java
@@ -0,0 +1,60 @@
+package org.apache.samples.common;
+
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.security.manager.KeyCloakSecurityManager;
+import org.apache.http.Consts;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SamplesCommon {
+
+    public static JSONObject getAccessToken(String username, String password, String clientId, String grant_type) throws CustosSecurityException {
+        new KeyCloakSecurityManager().initializeSecurityInfra();
+        if(password == null) {
+            //keeping a default password for testing
+            password = "123456";
+        }
+        String tokenEndPoint = "https://localhost:8443/auth/realms/default/protocol/openid-connect/token";
+
+        CloseableHttpClient httpClient = HttpClients.createSystem();
+        HttpPost httpPost = new HttpPost(tokenEndPoint);
+        ;
+        List<NameValuePair> formParams = new ArrayList<>();
+        formParams.add(new BasicNameValuePair("grant_type", grant_type));
+        formParams.add(new BasicNameValuePair("client_id", clientId));
+        formParams.add(new BasicNameValuePair("username", username));
+        formParams.add(new BasicNameValuePair("password", password));
+        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
+        httpPost.setEntity(entity);
+        try {
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            try {
+                String responseBody = EntityUtils.toString(response.getEntity());
+                JSONObject tokenInfo = new JSONObject(responseBody);
+                return tokenInfo;
+            } finally {
+                response.close();
+            }
+
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } finally {
+            try {
+                httpClient.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+}
diff --git a/ide-integration/custos-authentication-service-samples/pom.xml b/ide-integration/samples/custos-authentication-service-samples/pom.xml
similarity index 66%
copy from ide-integration/custos-authentication-service-samples/pom.xml
copy to ide-integration/samples/custos-authentication-service-samples/pom.xml
index 5a035cd..37037fc 100644
--- a/ide-integration/custos-authentication-service-samples/pom.xml
+++ b/ide-integration/samples/custos-authentication-service-samples/pom.xml
@@ -10,6 +10,14 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>custos-authentication-service-samples</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>commons</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
 
 
 </project>
\ No newline at end of file
diff --git a/ide-integration/samples/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java b/ide-integration/samples/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java
new file mode 100644
index 0000000..4fb0be0
--- /dev/null
+++ b/ide-integration/samples/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java
@@ -0,0 +1,64 @@
+package org.apache.custos.authentication.service.sample;
+
+import org.apache.custos.authentication.cpi.CustosAuthenticationService;
+import org.apache.custos.client.authentication.service.AuthenticationServiceClientFactory;
+import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.commons.utils.Constants;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.samples.common.SamplesCommon;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.HashMap;
+
+public class CustosAuthenticationServiceSample {
+
+    private static final Logger log = LoggerFactory.getLogger(CustosAuthenticationServiceSample.class);
+    //present in keycloak json configuration
+    public static String USERNAME = "default-admin";
+    public static String GATEWAY_ID = "default";
+    public static AuthzToken authzToken;
+
+    public static void main(String[] args){
+
+        try {
+            String serverHost = ServerSettings.getAuthenticationServerHost();
+            int serverPort = Integer.parseInt(ServerSettings.getAuthenticationServerPort());
+            CustosAuthenticationService.Client client = AuthenticationServiceClientFactory.createAuthenticationServiceClient(serverHost, serverPort);
+            testUserAuthentication(client);
+        }catch (Exception e){
+           log.error("Error setting up the authentication server");
+        }
+    }
+
+    public static void testUserAuthentication(CustosAuthenticationService.Client client){
+        try{
+            initializeAuthzToken();
+            boolean authenticated = client.isUserAuthenticated(authzToken);
+            assert (authenticated): "User not authenticated failed. Authentication test failed";
+            if(authenticated){
+                log.info("User successfully authenticated");
+            }
+        }catch (Exception e){
+            log.error("Test userAuthentication Failed!!", e);
+        }
+    }
+    private static void initializeAuthzToken() throws Exception{
+        try{
+            authzToken = new AuthzToken();
+            HashMap<String, String> map = new HashMap<>();
+            map.put(Constants.USER_NAME, USERNAME);
+            map.put(Constants.GATEWAY_ID, GATEWAY_ID);
+            authzToken.setClaimsMap(map);
+            JSONObject json = SamplesCommon.getAccessToken(USERNAME, null, "admin-cli", "password");
+            if(json.has("access_token")){
+                authzToken.setAccessToken(json.get("access_token").toString());
+            }else{
+                throw new Exception("Check if the user exists in keycloak");
+            }
+        }catch (Exception e) {
+            throw new Exception("Could not get access token", e);
+        }
+
+    }
+}
diff --git a/custos-profile-service/profile-service-server/src/main/resources/log4j.properties b/ide-integration/samples/custos-authentication-service-samples/src/main/resources/log4j.properties
similarity index 80%
rename from custos-profile-service/profile-service-server/src/main/resources/log4j.properties
rename to ide-integration/samples/custos-authentication-service-samples/src/main/resources/log4j.properties
index 2827ca2..31d6017 100644
--- a/custos-profile-service/profile-service-server/src/main/resources/log4j.properties
+++ b/ide-integration/samples/custos-authentication-service-samples/src/main/resources/log4j.properties
@@ -17,18 +17,16 @@
 # under the License.
 #
 
-# Set root category priority to INFO and its only appender to CONSOLE.
-log4j.rootCategory=INFO, ERROR, CONSOLE,LOGFILE
-log4j.rootLogger=INFO, ERROR, CONSOLE, LOGFILE
 
-         
+log4j.rootCategory=INFO, CONSOLE, LOGFILE
+log4j.rootLogger=INFO, CONSOLE, LOGFILE
+
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
 log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n
 
-# LOGFILE is set to be a File appender using a PatternLayout.
 log4j.appender.LOGFILE=org.apache.log4j.FileAppender
-log4j.appender.LOGFILE.File=./target/custos.log
+log4j.appender.LOGFILE.File=./target/custos-server-test.log
 log4j.appender.LOGFILE.Append=true
 log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
 log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
diff --git a/ide-integration/custos-profile-service-samples/pom.xml b/ide-integration/samples/custos-profile-service-samples/pom.xml
similarity index 69%
rename from ide-integration/custos-profile-service-samples/pom.xml
rename to ide-integration/samples/custos-profile-service-samples/pom.xml
index 070cda2..cce4841 100644
--- a/ide-integration/custos-profile-service-samples/pom.xml
+++ b/ide-integration/samples/custos-profile-service-samples/pom.xml
@@ -10,6 +10,13 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>custos-profile-service-samples</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>commons</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
 
 
 </project>
\ No newline at end of file
diff --git a/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/TenantProfileSample.java b/ide-integration/samples/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/TenantProfileSample.java
similarity index 100%
rename from ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/TenantProfileSample.java
rename to ide-integration/samples/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/TenantProfileSample.java
diff --git a/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/UserProfileSample.java b/ide-integration/samples/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/UserProfileSample.java
similarity index 69%
rename from ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/UserProfileSample.java
rename to ide-integration/samples/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/UserProfileSample.java
index 41255fc..66c9055 100644
--- a/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/UserProfileSample.java
+++ b/ide-integration/samples/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/UserProfileSample.java
@@ -20,42 +20,30 @@
 package org.apache.custos.profile.service.samples;
 
 import org.apache.custos.client.profile.service.CustosProfileServiceClientFactory;
-import org.apache.custos.commons.exceptions.CustosSecurityException;
 import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.profile.model.user.*;
 import org.apache.custos.profile.service.samples.utils.ProfileServiceClientUtil;
 import org.apache.custos.profile.user.cpi.UserProfileService;
-import org.apache.custos.security.manager.KeyCloakSecurityManager;
-import org.apache.http.Consts;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.EntityUtils;
+import org.apache.samples.common.SamplesCommon;
 import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.ThreadLocalRandom;
 
-/**
- * Created by goshenoy on 3/23/17.
- */
+
 public class UserProfileSample {
 
     private static final Logger logger = LoggerFactory.getLogger(UserProfileSample.class);
     private static UserProfileService.Client userProfileClient;
     private static UserProfile testUser = null;
+    //before changing the test gateway and username, make sure realm and user exists in keycloak
     private static String testGatewayId = "default";
     private static String username = "default-admin";
+    private static String grant_type = "password";
+    private static String client_id = "admin-cli";
     private static AuthzToken authzToken;
 
 
@@ -75,7 +63,7 @@ public class UserProfileSample {
         try {
             String profileServiceServerHost = ProfileServiceClientUtil.getProfileServiceServerHost();
             int profileServiceServerPort = ProfileServiceClientUtil.getProfileServiceServerPort();
-            authzToken = initializeAuthzToken();
+            initializeAuthzToken();
             userProfileClient = CustosProfileServiceClientFactory.createCustosUserProfileServiceClient(profileServiceServerHost, profileServiceServerPort);
 
             // test add-user-profile
@@ -124,7 +112,7 @@ public class UserProfileSample {
     private static UserProfile getUserProfile(String userId) {
         // get random value for userId
         int userIdValue = ThreadLocalRandom.current().nextInt(1000);
-        
+
         // construct userProfile object
         UserProfile userProfile = new UserProfile();
         userProfile.setUserModelVersion("model-" + userIdValue);
@@ -154,58 +142,19 @@ public class UserProfileSample {
         return nsfDemographics;
     }
 
-    private static AuthzToken initializeAuthzToken() throws Exception{
-         authzToken = new AuthzToken();
-        {
-            HashMap<String, String> map_ = new HashMap<>();
-            map_.put(Constants.GATEWAY_ID, testGatewayId);
-            map_.put(Constants.USER_NAME, username);
-            JSONObject json = getAccessToken();
-            if(json.has("access_token")) {
-                authzToken.setAccessToken(json.get("access_token").toString());
-            }
-            else{
-                throw new Exception("Cannot find access token for the user. Check if the user exists in the IDP");
-            }
-            authzToken.setClaimsMap(map_);
-            return authzToken;
+    private static void initializeAuthzToken() throws Exception{
+        authzToken = new AuthzToken();
+        HashMap<String, String> map_ = new HashMap<>();
+        map_.put(Constants.GATEWAY_ID, testGatewayId);
+        map_.put(Constants.USER_NAME, username);
+        authzToken.setClaimsMap(map_);
+        JSONObject json = SamplesCommon.getAccessToken(username,null,client_id, grant_type);
+        if(json.has("access_token")) {
+            authzToken.setAccessToken(json.get("access_token").toString());
         }
-    }
-    private static JSONObject getAccessToken() throws CustosSecurityException {
-        new KeyCloakSecurityManager().initializeSecurityInfra();
-        String password = "123456";
-        String tokenEndPoint = "https://airavata.host:8443/auth/realms/default/protocol/openid-connect/token";
-        String grant_type = "password";
-        String client_id = "admin-cli";
-
-        CloseableHttpClient httpClient = HttpClients.createSystem();
-        HttpPost httpPost = new HttpPost(tokenEndPoint);
-        ;
-        List<NameValuePair> formParams = new ArrayList<>();
-        formParams.add(new BasicNameValuePair("grant_type", "password"));
-        formParams.add(new BasicNameValuePair("client_id", client_id));
-        formParams.add(new BasicNameValuePair("username", username));
-        formParams.add(new BasicNameValuePair("password", password));
-        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
-        httpPost.setEntity(entity);
-        try {
-            CloseableHttpResponse response = httpClient.execute(httpPost);
-            try {
-                String responseBody = EntityUtils.toString(response.getEntity());
-                JSONObject tokenInfo = new JSONObject(responseBody);
-                return tokenInfo;
-            } finally {
-                response.close();
-            }
-
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        } finally {
-            try {
-                httpClient.close();
-            } catch (IOException e) {
-                throw new RuntimeException(e);
-            }
+        else{
+            throw new Exception("Cannot find access token for the user. Check if the user exists in the IDP");
         }
     }
+
 }
diff --git a/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/utils/ProfileServiceClientUtil.java b/ide-integration/samples/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/utils/ProfileServiceClientUtil.java
similarity index 100%
rename from ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/utils/ProfileServiceClientUtil.java
rename to ide-integration/samples/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/utils/ProfileServiceClientUtil.java
diff --git a/log4j.properties b/ide-integration/samples/custos-profile-service-samples/src/main/resources/log4j.properties
similarity index 80%
rename from log4j.properties
rename to ide-integration/samples/custos-profile-service-samples/src/main/resources/log4j.properties
index 2827ca2..31d6017 100644
--- a/log4j.properties
+++ b/ide-integration/samples/custos-profile-service-samples/src/main/resources/log4j.properties
@@ -17,18 +17,16 @@
 # under the License.
 #
 
-# Set root category priority to INFO and its only appender to CONSOLE.
-log4j.rootCategory=INFO, ERROR, CONSOLE,LOGFILE
-log4j.rootLogger=INFO, ERROR, CONSOLE, LOGFILE
 
-         
+log4j.rootCategory=INFO, CONSOLE, LOGFILE
+log4j.rootLogger=INFO, CONSOLE, LOGFILE
+
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
 log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n
 
-# LOGFILE is set to be a File appender using a PatternLayout.
 log4j.appender.LOGFILE=org.apache.log4j.FileAppender
-log4j.appender.LOGFILE.File=./target/custos.log
+log4j.appender.LOGFILE.File=./target/custos-server-test.log
 log4j.appender.LOGFILE.Append=true
 log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
 log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
diff --git a/ide-integration/custos-profile-service-samples/src/main/resources/profile-client-sample.properties b/ide-integration/samples/custos-profile-service-samples/src/main/resources/profile-client-sample.properties
similarity index 100%
rename from ide-integration/custos-profile-service-samples/src/main/resources/profile-client-sample.properties
rename to ide-integration/samples/custos-profile-service-samples/src/main/resources/profile-client-sample.properties
diff --git a/ide-integration/custos-authentication-service-samples/pom.xml b/ide-integration/samples/pom.xml
similarity index 64%
rename from ide-integration/custos-authentication-service-samples/pom.xml
rename to ide-integration/samples/pom.xml
index 5a035cd..a110489 100644
--- a/ide-integration/custos-authentication-service-samples/pom.xml
+++ b/ide-integration/samples/pom.xml
@@ -9,7 +9,12 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>custos-authentication-service-samples</artifactId>
-
+    <artifactId>samples</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>custos-authentication-service-samples</module>
+        <module>custos-profile-service-samples</module>
+        <module>commons</module>
+    </modules>
 
 </project>
\ No newline at end of file


[airavata-custos] 43/48: group profile service changes should go in a different commit

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1b588e97e2acf1279ac5dc4882ca9decdcdaa672
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Sep 2 21:24:05 2019 -0400

    group profile service changes should go in a different commit
---
 .../group-profile-api/pom.xml                      |  21 --
 .../group/profile/service/api/Application.java     |  28 --
 .../api/controllers/GroupServiceController.java    |  82 -----
 .../group-profile-core/pom.xml                     |  45 ---
 .../exceptions/GroupManagerServiceException.java   |  16 -
 .../profile/service/core/models/GroupModel.java    |  73 ----
 .../service/core/service/GroupProfileService.java  | 370 ---------------------
 .../group-profile-service/pom.xml                  |  20 --
 custos-profile-service/pom.xml                     |   1 -
 9 files changed, 656 deletions(-)

diff --git a/custos-profile-service/group-profile-service/group-profile-api/pom.xml b/custos-profile-service/group-profile-service/group-profile-api/pom.xml
deleted file mode 100644
index 1c5e69f..0000000
--- a/custos-profile-service/group-profile-service/group-profile-api/pom.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>group-profile-service</artifactId>
-        <groupId>org.apache.custos</groupId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>group-profile-api</artifactId>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>group-profile-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/Application.java b/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/Application.java
deleted file mode 100644
index 75f11de..0000000
--- a/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/Application.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * 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.group.profile.service.api;
-
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.ComponentScan;
-
-@SpringBootApplication
-@ComponentScan(basePackages = {"org.apache.custos.group.profile.api.controllers"})
-public class Application {
-}
diff --git a/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/controllers/GroupServiceController.java b/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/controllers/GroupServiceController.java
deleted file mode 100644
index 04b8dba..0000000
--- a/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/controllers/GroupServiceController.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.group.profile.service.api.controllers;
-
-import org.apache.custos.profile.service.core.models.GroupModel;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-import java.util.Map;
-
-@RestController
-@RequestMapping("/group")
-public class GroupServiceController {
-
-    @RequestMapping(method = RequestMethod.POST)
-    public ResponseEntity<String> createGroup(@RequestBody GroupModel groupModel){
-        return null;
-    }
-
-    @RequestMapping(method = RequestMethod.PUT)
-    public ResponseEntity<String> updateGroup(@RequestBody GroupModel groupModel){
-        return null;
-    }
-
-    @RequestMapping(value = "/id/{groupId}/owner/{ownerId}", method = RequestMethod.DELETE)
-    public ResponseEntity<String> deleteGroup(@PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
-        return null;
-    }
-
-    @RequestMapping(value = "/id/{groupId}", method = RequestMethod.GET)
-    public ResponseEntity<String> getGroup(@PathVariable("groupId") String groupId){
-        return null;
-    }
-
-    @RequestMapping(value = "/all", method = RequestMethod.GET)
-    public @ResponseBody
-    List<GroupModel> getGroups(){
-        return null;
-    }
-
-    @RequestMapping(value = "/username/{username}", method = RequestMethod.GET)
-    public @ResponseBody
-    List<GroupModel> getAllGroupsUserBelongs(@PathVariable("username") String username){
-        return null;
-    }
-
-    @RequestMapping(value = "/id/{groupId}", method = RequestMethod.PUT)
-    public ResponseEntity<String> addUsersToGroup(@PathVariable("groupId") String groupId, @RequestBody List<String> userIds){
-        return null;
-    }
-
-    @RequestMapping(value = "/id/{groupId}", method = RequestMethod.PUT)
-    public ResponseEntity<String> removeUsersFromGroup(@PathVariable("groupId") String groupId, @RequestBody List<String> userIds){
-        return null;
-    }
-
-    @RequestMapping(value = "/id/{groupId}/owner/{ownerId}", method = RequestMethod.PUT)
-    public ResponseEntity<String> transferGroupOwnership(@PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
-        return null;
-    }
-
-    @RequestMapping(value = "addAdmins/id/{groupId}", method = RequestMethod.PUT)
-    public ResponseEntity<String> addGroupAdmins(@PathVariable("groupId") String groupId, @RequestBody List<String> adminIds){
-        return null;
-    }
-
-    @RequestMapping(value = "removeAdmins/id/{groupId}", method = RequestMethod.PUT)
-    public ResponseEntity<String> removeGroupAdmins(@PathVariable("groupId") String groupId, @RequestBody List<String> adminIds){
-        return null;
-    }
-
-    @RequestMapping(value = "/id/{groupId}/admin/{adminId}", method = RequestMethod.GET)
-    public @ResponseBody
-    Map<String, Boolean> hasAdminAccess(@PathVariable("groupId") String groupId, @PathVariable("adminId") String adminId){
-        return null;
-    }
-
-    @RequestMapping(value = "/id/{groupId}/owner/{ownerId}", method = RequestMethod.GET)
-    public @ResponseBody
-    Map<String, Boolean> hasOwnerAccess(@PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
-        return null;
-    }
-}
diff --git a/custos-profile-service/group-profile-service/group-profile-core/pom.xml b/custos-profile-service/group-profile-service/group-profile-core/pom.xml
deleted file mode 100644
index 7945596..0000000
--- a/custos-profile-service/group-profile-service/group-profile-core/pom.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>group-profile-service</artifactId>
-        <groupId>org.apache.custos</groupId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>group-profile-core</artifactId>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>user-profile-service</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>sharing-service-api</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>profile-service-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
-        </dependency>
-        <dependency>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-            <version>20160212</version>
-            <scope>compile</scope>
-        </dependency>
-        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-            <version>2.8.5</version>
-        </dependency>
-    </dependencies>
-
-
-</project>
\ No newline at end of file
diff --git a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/exceptions/GroupManagerServiceException.java b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/exceptions/GroupManagerServiceException.java
deleted file mode 100644
index 6de6312..0000000
--- a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/exceptions/GroupManagerServiceException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.apache.custos.profile.service.core.exceptions;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-@ResponseStatus(value= HttpStatus.INTERNAL_SERVER_ERROR, reason = "Request cannot be completed due to server error")
-public class GroupManagerServiceException extends RuntimeException {
-
-    public GroupManagerServiceException(String errorMessage) {
-        super(errorMessage);
-    }
-
-    public GroupManagerServiceException(String errorMessage, Throwable err) {
-        super(errorMessage, err);
-    }
-}
diff --git a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/models/GroupModel.java b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/models/GroupModel.java
deleted file mode 100644
index c36d520..0000000
--- a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/models/GroupModel.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.apache.custos.profile.service.core.models;
-
-import java.util.List;
-
-public class GroupModel {
-    private String id;
-    private String name;
-    private String ownerId;
-    private String description;
-    private String gatewayId;
-    private List<String> members;
-    /**
-     * Note: each admin must also be a member of the group.
-     */
-    private List<String> admins;
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getOwnerId() {
-        return ownerId;
-    }
-
-    public void setOwnerId(String ownerId) {
-        this.ownerId = ownerId;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public List<String> getMembers() {
-        return members;
-    }
-
-    public void setMembers(List<String> members) {
-        this.members = members;
-    }
-
-    public List<String> getAdmins() {
-        return admins;
-    }
-
-    public void setAdmins(List<String> admins) {
-        this.admins = admins;
-    }
-
-
-    public String getGatewayId() {
-        return gatewayId;
-    }
-
-    public void setGatewayId(String gatewayId) {
-        this.gatewayId = gatewayId;
-    }
-}
diff --git a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java
deleted file mode 100644
index b11b4df..0000000
--- a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java
+++ /dev/null
@@ -1,370 +0,0 @@
-package org.apache.custos.profile.service.core.service;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.google.gson.Gson;
-import org.apache.custos.commons.exceptions.ServiceConnectionException;
-import org.apache.custos.commons.utils.ServiceRequestClient;
-import org.apache.custos.profile.commons.repositories.UserProfileRepository;
-import org.apache.custos.sharing.service.api.constants.SharingRegistryEndpoints;
-import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
-import org.apache.custos.sharing.service.core.models.GroupCardinality;
-import org.apache.custos.sharing.service.core.models.GroupType;
-import org.apache.custos.sharing.service.core.models.UserGroup;
-import org.apache.custos.profile.service.core.models.*;
-import org.apache.custos.profile.service.core.exceptions.*;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.json.HTTP;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class GroupProfileService {
-
-    private static final Logger logger = LoggerFactory.getLogger(GroupProfileService.class);
-
-    @Autowired
-    ServiceRequestClient serviceRequestClient;
-
-    @Autowired
-    SharingRegistryEndpoints sharingRegistryEndpoints;
-
-    private static final String GROUP_MANAGER_CPI_VERSION = "1.0";
-    private UserProfileRepository userProfileRepository = new UserProfileRepository();
-    private String SHARING_SERVICE_BASE_URL = sharingRegistryEndpoints.getBaseUrl();
-
-    public String getAPIVersion() {
-        return GROUP_MANAGER_CPI_VERSION;
-    }
-
-    private JSONObject getResponseBody(HttpResponse response) throws Exception {
-
-        try {
-            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-                BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
-                StringBuffer result = new StringBuffer();
-                String line = "";
-                while ((line = rd.readLine()) != null) {
-                    result.append(line);
-                }
-                JSONObject jsonObject = new JSONObject(result.toString());
-                return jsonObject;
-            } else {
-                throw new Exception();
-            }
-        } catch (Exception ex) {
-            //TODO: sharing service did not return correct response
-            throw ex;
-        }
-    }
-
-    private boolean validateHeadHttpRequest(HttpResponse response) throws Exception{
-        if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-            return true;
-        }else if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
-            return false;
-        }
-        else {
-            //TODO: this will be sharing server error
-            throw new Exception();
-        }
-    }
-
-    private boolean validatePutHttpRequest(HttpResponse response) throws Exception{
-        if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-            return true;
-        } else {
-            //TODO: this will be sharing server error
-            throw new Exception();
-        }
-    }
-
-    public String createGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
-        try {
-
-            UserGroup sharingUserGroup = new UserGroup();
-            sharingUserGroup.setGroupId(groupModel.getId());
-            sharingUserGroup.setName(groupModel.getName());
-            sharingUserGroup.setDescription(groupModel.getDescription());
-            sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
-            sharingUserGroup.setGroupCardinality(GroupCardinality.MULTI_USER);
-            sharingUserGroup.setDomainId(groupModel.getGatewayId());
-            sharingUserGroup.setOwnerId(groupModel.getOwnerId());
-
-            HttpResponse response = serviceRequestClient.httpPost(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getCreateGroupApi(groupModel.getGatewayId()), sharingUserGroup);
-
-            //TODO: should happen in one rest call
-            //internalAddUsersToGroup(sharingClient, gatewayId, groupModel.getMembers(), groupId);
-            //addGroupAdmins(authzToken,groupId,groupModel.getAdmins());
-            JSONObject responseEntity = getResponseBody(response);
-            return responseEntity.get("groupId").toString();
-        }catch (ServiceConnectionException ex) {
-            //TODO: reason could not make connection request to sharing service
-            throw ex;
-        }
-        catch (Exception e) {
-            String msg = "Error Creating Group" ;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public boolean updateGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
-        try {
-            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(gatewayId, groupModel.getId(), userId)));
-            boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(gatewayId, groupModel.getId(), userId)));
-            if (!ownerAccess || ! adminAccess) {
-                throw new GroupManagerServiceException("User does not have permission to update group");
-            }
-
-            UserGroup sharingUserGroup = new UserGroup();
-            sharingUserGroup.setGroupId(groupModel.getId());
-            sharingUserGroup.setName(groupModel.getName());
-            sharingUserGroup.setDescription(groupModel.getDescription());
-            sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
-            sharingUserGroup.setDomainId(gatewayId);
-
-            //adding and removal of users should be handle separately??
-            HttpResponse response = serviceRequestClient.httpPut(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getUpdateGroupApi(groupModel.getGatewayId()), null);
-            return validatePutHttpRequest(response);
-        }
-        catch (Exception e) {
-            String msg = "Error Updating Group" ;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public boolean deleteGroup(String groupId, String groupGatewayId, String domainId, String ownerId) throws GroupManagerServiceException{
-        try {
-            boolean hasOwnerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, ownerId)));
-            if (!hasOwnerAccess) {
-                throw new GroupManagerServiceException("User does not have permission to delete group");
-            }
-
-
-            serviceRequestClient.httpDelete(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getDeleteGroupApi(groupGatewayId,groupId));
-            return true;
-        }
-        catch (Exception e) {
-            String msg = "Error Deleting Group. Group ID: " + groupId ;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public GroupModel getGroup(String groupId, String groupGatewayId) throws GroupManagerServiceException{
-        try {
-            JSONObject jsonObject = getResponseBody(serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGetGroupApi(groupGatewayId, groupId)));
-            UserGroup userGroup = new Gson().fromJson(jsonObject.toString(),UserGroup.class);
-            GroupModel groupModel = convertToGroupModel(userGroup);
-            return groupModel;
-        }
-        catch (Exception e) {
-            String msg = "Error Retreiving Group. Group ID: " + groupId ;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public List<GroupModel> getGroups(String groupGatewayId) throws GroupManagerServiceException{
-        try {
-            JSONObject jsonObject = getResponseBody(serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGetGroupsApi(groupGatewayId, 0, -1)));
-            //List<UserGroup> userGroups = new Gson().fromJson(jsonObject.toString(),UserGroup.class);
-            List<UserGroup> userGroups = new ArrayList<>();
-            return convertToGroupModels(userGroups);
-        }
-        catch (Exception e) {
-            String msg = "Error Retrieving Groups. Domain ID: " + groupGatewayId;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public List<GroupModel> getAllGroupsUserBelongs(String userId, String groupGatewayId) throws GroupManagerServiceException{
-        try {
-            List<GroupModel> groupModels = new ArrayList<GroupModel>();
-            JSONObject jsonObject= getResponseBody(serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGetGroupsForUserApi(groupGatewayId, userId)));
-            List<UserGroup> userGroups = new ArrayList<>();
-            return convertToGroupModels(userGroups);
-        }
-        catch (Exception e) {
-            String msg = "Error Retreiving All Groups for User. User ID: " + userId ;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public boolean addUsersToGroup(List<String> userIds, String groupId, String groupGatewayId, String userId, String domainId) throws GroupManagerServiceException{
-        try {
-            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
-            boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(domainId, groupId, userId)));
-            if (! ownerAccess || !adminAccess) {
-                throw new GroupManagerServiceException("User does not have access to add users to the group");
-            }
-            return internalAddUsersToGroup(domainId, userIds, groupId);
-
-        } catch (Exception e) {
-            String msg = "Error adding users to group. Group ID: " + groupId ;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public boolean removeUsersFromGroup(List<String> userIds, String groupId, String groupGatewayId, String userId, String domainId) throws GroupManagerServiceException {
-        try {
-            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
-            boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(domainId, groupId, userId)));
-            if (! ownerAccess || !adminAccess)  {
-                throw new GroupManagerServiceException("User does not have access to remove users to the group");
-            }
-            return validateHeadHttpRequest(serviceRequestClient.httpDelete(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getRemoveUsersFromGroupApi(groupGatewayId, groupId)));
-        } catch (Exception e) {
-            String msg = "Error remove users to group. Group ID: " + groupId ;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public boolean transferGroupOwnership(String groupId, String groupGatewayId, String newOwnerId, String userId, String domainId) throws GroupManagerServiceException {
-        try{
-            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
-            if (!ownerAccess) {
-                throw new GroupManagerServiceException("User does not have Owner permission to transfer group ownership");
-            }
-            return validatePutHttpRequest(serviceRequestClient.httpPut(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getTransferGroupOwnershipApi(groupGatewayId, groupId, newOwnerId), null));
-        }
-        catch (Exception e) {
-            String msg = "Error Transferring Group Ownership";
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-
-    }
-
-    public boolean addGroupAdmins(String groupId,String groupGatewayId, List<String> adminIds, String userId, String domainId) throws GroupManagerServiceException {
-        try {
-            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
-            if (!ownerAccess) {
-                throw new GroupManagerServiceException("User does not have Owner permission to add group admins");
-            }
-            return validatePutHttpRequest(serviceRequestClient.httpPost(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getAddGroupAdminsApi(groupGatewayId, groupId), adminIds));
-        }
-        catch (Exception e) {
-            String msg = "Error Adding Admins to Group. Group ID: " + groupId;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public boolean removeGroupAdmins(String groupId, String groupGatewayId,List<String> adminIds, String userId, String domainId) throws GroupManagerServiceException{
-        try {
-            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
-            if (!ownerAccess) {
-                throw new GroupManagerServiceException("User does not have Owner permission to remove group admins");
-            }
-            return validatePutHttpRequest(serviceRequestClient.httpDelete(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getRemoveGroupAdminsApi(groupGatewayId, groupId)));
-        }
-        catch (Exception e) {
-            String msg = "Error Removing Admins from the Group. Group ID: " + groupId;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public boolean hasAdminAccess(String groupId, String adminId, String groupGatewayId) throws GroupManagerServiceException{
-        try {
-            boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(groupGatewayId, groupId, adminId)));
-            return adminAccess;
-        }
-        catch (Exception e) {
-            String msg = "Error Checking Admin Access for the Group. Group ID: " + groupId + " Admin ID: " + adminId;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-    public boolean hasOwnerAccess(String groupId, String groupGatewayId, String ownerId) throws GroupManagerServiceException{
-        try {
-            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(groupGatewayId, groupId, ownerId)));
-            return ownerAccess;
-        }
-        catch (Exception e) {
-            String msg = "Error Checking Owner Access for the Group. Group ID: " + groupId + " Owner ID: " + ownerId;
-            logger.error(msg, e);
-            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-            throw exception;
-        }
-    }
-
-
-    private List<GroupModel> convertToGroupModels(List<UserGroup> userGroups){
-
-        List<GroupModel> groupModels = new ArrayList<>();
-
-        for (UserGroup userGroup: userGroups) {
-            GroupModel groupModel = convertToGroupModel(userGroup);
-
-            groupModels.add(groupModel);
-        }
-        return groupModels;
-    }
-
-    private GroupModel convertToGroupModel(UserGroup userGroup) {
-        GroupModel groupModel = new GroupModel();
-        groupModel.setId(userGroup.getGroupId());
-        groupModel.setName(userGroup.getName());
-        groupModel.setDescription(userGroup.getDescription());
-        groupModel.setOwnerId(userGroup.getOwnerId());
-        final List<String> admins = userGroup.getGroupAdmins().stream()
-                .map(groupAdmin -> groupAdmin.getAdminId())
-                .collect(Collectors.toList());
-        groupModel.setAdmins(admins);
-
-//        serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGroupMemebersOfTypeUserApi(userGroup.getDomainId(), userGroup.getGroupId(), 0, -1)).stream().forEach(user->
-//                groupModel.getMembers().add((user.getUserId())
-//        );
-        return groupModel;
-    }
-
-    private boolean internalAddUsersToGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException {
-
-        // FIXME: workaround for UserProfiles that failed to sync to the sharing
-        // registry: create any missing users in the sharing registry
-//        for (String userId : userIds) {
-//            if (!sharingClient.isUserExists(domainId, userId)) {
-//                User user = new User();
-//                user.setDomainId(domainId);
-//                user.setUserId(userId);
-//                UserProfile userProfile = userProfileRepository.get(userId);
-//                user.setUserName(userProfile.getUserId());
-//                user.setCreatedTime(userProfile.getCreationTime());
-//                user.setEmail(userProfile.getEmailsSize() > 0 ? userProfile.getEmails().get(0) : null);
-//                user.setFirstName(userProfile.getFirstName());
-//                user.setLastName(userProfile.getLastName());
-//                sharingClient.createUser(user);
-//            }
-//        }
-//        return serviceRequestClient.httpPost(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getAddUsersToGroupApi(domainId, groupId), userIds);
-        return true;
-    }
-}
diff --git a/custos-profile-service/group-profile-service/pom.xml b/custos-profile-service/group-profile-service/pom.xml
deleted file mode 100644
index 7d58503..0000000
--- a/custos-profile-service/group-profile-service/pom.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>custos-profile-service</artifactId>
-        <groupId>org.apache.custos</groupId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>group-profile-service</artifactId>
-    <packaging>pom</packaging>
-    <modules>
-        <module>group-profile-api</module>
-        <module>group-profile-core</module>
-    </modules>
-
-
-</project>
\ No newline at end of file
diff --git a/custos-profile-service/pom.xml b/custos-profile-service/pom.xml
index c1802cb..e0ca29a 100644
--- a/custos-profile-service/pom.xml
+++ b/custos-profile-service/pom.xml
@@ -18,7 +18,6 @@
         <module>profile-service-model</module>
         <module>profile-service-server</module>
         <module>tenant-profile-service</module>
-        <module>group-profile-service</module>
     </modules>
     <properties>
         <java.version>1.8</java.version>


[airavata-custos] 23/48: Merge pull request #4 from aarushiibisht/custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c9ca88774c743bb01882ada793a6cb1129c8019d
Merge: 44b6bb1 ca8a8bb
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Tue Aug 13 11:06:17 2019 -0400

    Merge pull request #4 from aarushiibisht/custos-dev-abisht
    
    Removed customDashboard table from custos profile_service database

 .../user/entities/CustomizedDashboardEntity.java   |  325 ---
 .../commons/user/entities/UserProfileEntity.java   |   11 -
 .../custos/profile/model/user/CustomDashboard.java | 2912 --------------------
 .../custos/profile/model/user/NSFDemographics.java |  145 +-
 .../apache/custos/profile/model/user/Status.java   |   25 +-
 .../custos/profile/model/user/USCitizenship.java   |   25 +-
 .../custos/profile/model/user/UserProfile.java     |  506 ++--
 .../custos/profile/model/user/disability.java      |   25 +-
 .../custos/profile/model/user/ethnicity.java       |   25 +-
 .../org/apache/custos/profile/model/user/race.java |   25 +-
 .../model/user/user_profile_modelConstants.java    |   21 +-
 .../database_scripts/init/01-databases.sql         |   48 -
 .../user_profile_model.thrift                      |   36 +-
 13 files changed, 325 insertions(+), 3804 deletions(-)


[airavata-custos] 36/48: refactored some apis, added database dump

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3c659497ab64d78b365b7ace14811e73e86539ca
Author: Aarushi <aa...@gmail.com>
AuthorDate: Sat Aug 31 19:14:38 2019 -0400

    refactored some apis, added database dump
---
 .../src/main/resources/application.properties      |   2 +
 .../src/main/resources/META-INF/persistence.xml    |  16 ++
 .../database_scripts/sharing-registry-derby.sql    | 147 ++++++++++
 .../database_scripts/sharing-registry-mysql.sql    | 146 ++++++++++
 .../database_scripts/sharing-registry-mysql.sql    | 146 ++++++++++
 .../sharing-service/sharing-cpi/sharing_cpi.thrift | 274 -------------------
 .../sharing-models/sharing_models.thrift           | 303 ---------------------
 7 files changed, 457 insertions(+), 577 deletions(-)

diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/resources/application.properties b/custos-sharing-registry-service/sharing-service-api/src/main/resources/application.properties
new file mode 100644
index 0000000..2d64be9
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/resources/application.properties
@@ -0,0 +1,2 @@
+server.address=0.0.0.0
+server.port= 7070
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/resources/META-INF/persistence.xml b/custos-sharing-registry-service/sharing-service-core/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..61ec4fc
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+
+    <persistence-unit name="custos-sharing-registry">
+        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+        <class>org.apache.custos.sharing.service.core.db.entities.DomainEntity</class>
+        <class>org.apache.custos.sharing.service.core.db.entities.EntityEntity</class>
+        <class>org.apache.custos.sharing.service.core.db.entities.EntityTypeEntity</class>
+        <class>org.apache.custos.sharing.service.core.db.entities.GroupMembershipEntity</class>
+        <class>org.apache.custos.sharing.service.core.db.entities.PermissionTypeEntity</class>
+        <class>org.apache.custos.sharing.service.core.db.entities.SharingEntity</class>
+        <class>org.apache.custos.sharing.service.core.db.entities.UserEntity</class>
+        <class>org.apache.custos.sharing.service.core.db.entities.GroupAdminEntity</class>
+        <class>org.apache.custos.sharing.service.core.db.entities.UserGroupEntity</class>
+    </persistence-unit>
+</persistence>
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/resources/database_scripts/sharing-registry-derby.sql b/custos-sharing-registry-service/sharing-service-core/src/main/resources/database_scripts/sharing-registry-derby.sql
new file mode 100644
index 0000000..a7038e2
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/resources/database_scripts/sharing-registry-derby.sql
@@ -0,0 +1,147 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+CREATE TABLE DOMAIN (
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (DOMAIN_ID)
+);
+
+CREATE TABLE SHARING_USER (
+  USER_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  USER_NAME VARCHAR(255) NOT NULL,
+  FIRST_NAME VARCHAR (255),
+  LAST_NAME VARCHAR (255),
+  EMAIL VARCHAR (255),
+  ICON BLOB,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (USER_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE GROUP_ADMIN (
+  ADMIN_ID VARCHAR(255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  PRIMARY KEY (ADMIN_ID, GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (ADMIN_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE USER_GROUP (
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  OWNER_ID VARCHAR(255) NOT NULL,
+  GROUP_TYPE VARCHAR(255) NOT NULL,
+  GROUP_CARDINALITY VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+
+CREATE TABLE GROUP_MEMBERSHIP (
+  PARENT_ID VARCHAR(255) NOT NULL,
+  CHILD_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  CHILD_TYPE VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PARENT_ID, CHILD_ID, DOMAIN_ID),
+  FOREIGN KEY (PARENT_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (CHILD_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE ENTITY_TYPE (
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE PERMISSION_TYPE (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE ENTITY (
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  OWNER_ID VARCHAR(255) NOT NULL,
+  PARENT_ENTITY_ID VARCHAR(255),
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  BINARY_DATA BLOB,
+  FULL_TEXT VARCHAR(255),
+  SHARED_COUNT BIGINT DEFAULT 0,
+  ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_ID, DOMAIN_ID),
+  FOREIGN KEY (ENTITY_TYPE_ID, DOMAIN_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (PARENT_ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+-- ALTER TABLE ENTITY ADD FULLTEXT FULL_TEXT_INDEX(FULL_TEXT);
+
+CREATE TABLE SHARING (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR (255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  SHARING_TYPE VARCHAR(255) NOT NULL,
+  INHERITED_PARENT_ID VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID, DOMAIN_ID, INHERITED_PARENT_ID),
+  FOREIGN KEY (PERMISSION_TYPE_ID, DOMAIN_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (INHERITED_PARENT_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (GROUP_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+);
+
+CREATE TABLE CONFIGURATION
+(
+  CONFIG_KEY VARCHAR(255) NOT NULL,
+  CONFIG_VALUE VARCHAR(255) NOT NULL,
+  PRIMARY KEY(CONFIG_KEY, CONFIG_VALUE)
+);
+
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VALUE) VALUES('sharing_reg_version', '0.17');
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/resources/database_scripts/sharing-registry-mysql.sql b/custos-sharing-registry-service/sharing-service-core/src/main/resources/database_scripts/sharing-registry-mysql.sql
new file mode 100644
index 0000000..145d926
--- /dev/null
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/resources/database_scripts/sharing-registry-mysql.sql
@@ -0,0 +1,146 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+CREATE TABLE DOMAIN (
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (DOMAIN_ID)
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE SHARING_USER (
+  USER_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  USER_NAME VARCHAR(255) NOT NULL,
+  FIRST_NAME VARCHAR (255),
+  LAST_NAME VARCHAR (255),
+  EMAIL VARCHAR (255),
+  ICON BLOB,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (USER_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE USER_GROUP (
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  OWNER_ID VARCHAR(255) NOT NULL,
+  GROUP_TYPE VARCHAR(255) NOT NULL,
+  GROUP_CARDINALITY VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE GROUP_ADMIN (
+  ADMIN_ID VARCHAR(255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  PRIMARY KEY (ADMIN_ID, GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (ADMIN_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE GROUP_MEMBERSHIP (
+  PARENT_ID VARCHAR(255) NOT NULL,
+  CHILD_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  CHILD_TYPE VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PARENT_ID, CHILD_ID, DOMAIN_ID),
+  FOREIGN KEY (PARENT_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (CHILD_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE ENTITY_TYPE (
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE PERMISSION_TYPE (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE ENTITY (
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  OWNER_ID VARCHAR(255) NOT NULL,
+  PARENT_ENTITY_ID VARCHAR(255),
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  BINARY_DATA BLOB,
+  FULL_TEXT TEXT,
+  SHARED_COUNT BIGINT DEFAULT 0,
+  ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_ID, DOMAIN_ID),
+  FOREIGN KEY (ENTITY_TYPE_ID, DOMAIN_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (PARENT_ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+ALTER TABLE ENTITY ADD FULLTEXT FULL_TEXT_INDEX(FULL_TEXT);
+
+CREATE TABLE SHARING (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR (255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  SHARING_TYPE VARCHAR(255) NOT NULL,
+  INHERITED_PARENT_ID VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID, DOMAIN_ID, INHERITED_PARENT_ID),
+  CONSTRAINT `SHARING_PERMISSION_TYPE_ID_DOMAIN_ID_FK` FOREIGN KEY (PERMISSION_TYPE_ID, DOMAIN_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  CONSTRAINT `SHARING_ENTITY_ID_DOMAIN_ID_FK` FOREIGN KEY (ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  CONSTRAINT `SHARING_INHERITED_PARENT_ID_DOMAIN_ID_FK` FOREIGN KEY (INHERITED_PARENT_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  CONSTRAINT `SHARING_GROUP_ID_DOMAIN_ID_FK` FOREIGN KEY (GROUP_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE CONFIGURATION
+(
+  CONFIG_KEY VARCHAR(255) NOT NULL,
+  CONFIG_VALUE VARCHAR(255) NOT NULL,
+  PRIMARY KEY(CONFIG_KEY, CONFIG_VALUE)
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VALUE) VALUES('sharing_reg_version', '0.17');
\ No newline at end of file
diff --git a/ide-integration/custos-services/src/main/resources/database_scripts/sharing-registry-mysql.sql b/ide-integration/custos-services/src/main/resources/database_scripts/sharing-registry-mysql.sql
new file mode 100644
index 0000000..145d926
--- /dev/null
+++ b/ide-integration/custos-services/src/main/resources/database_scripts/sharing-registry-mysql.sql
@@ -0,0 +1,146 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+CREATE TABLE DOMAIN (
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (DOMAIN_ID)
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE SHARING_USER (
+  USER_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  USER_NAME VARCHAR(255) NOT NULL,
+  FIRST_NAME VARCHAR (255),
+  LAST_NAME VARCHAR (255),
+  EMAIL VARCHAR (255),
+  ICON BLOB,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (USER_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE USER_GROUP (
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  OWNER_ID VARCHAR(255) NOT NULL,
+  GROUP_TYPE VARCHAR(255) NOT NULL,
+  GROUP_CARDINALITY VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE GROUP_ADMIN (
+  ADMIN_ID VARCHAR(255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  PRIMARY KEY (ADMIN_ID, GROUP_ID, DOMAIN_ID),
+  FOREIGN KEY (ADMIN_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE GROUP_MEMBERSHIP (
+  PARENT_ID VARCHAR(255) NOT NULL,
+  CHILD_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  CHILD_TYPE VARCHAR(255) NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PARENT_ID, CHILD_ID, DOMAIN_ID),
+  FOREIGN KEY (PARENT_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (CHILD_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE ENTITY_TYPE (
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE PERMISSION_TYPE (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, DOMAIN_ID),
+  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE ENTITY (
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR(255) NOT NULL,
+  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
+  OWNER_ID VARCHAR(255) NOT NULL,
+  PARENT_ENTITY_ID VARCHAR(255),
+  NAME VARCHAR(255) NOT NULL,
+  DESCRIPTION VARCHAR(255),
+  BINARY_DATA BLOB,
+  FULL_TEXT TEXT,
+  SHARED_COUNT BIGINT DEFAULT 0,
+  ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL,
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (ENTITY_ID, DOMAIN_ID),
+  FOREIGN KEY (ENTITY_TYPE_ID, DOMAIN_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  FOREIGN KEY (PARENT_ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+ALTER TABLE ENTITY ADD FULLTEXT FULL_TEXT_INDEX(FULL_TEXT);
+
+CREATE TABLE SHARING (
+  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
+  ENTITY_ID VARCHAR(255) NOT NULL,
+  DOMAIN_ID VARCHAR (255) NOT NULL,
+  GROUP_ID VARCHAR(255) NOT NULL,
+  SHARING_TYPE VARCHAR(255) NOT NULL,
+  INHERITED_PARENT_ID VARCHAR(255),
+  CREATED_TIME BIGINT NOT NULL,
+  UPDATED_TIME BIGINT NOT NULL,
+  PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID, DOMAIN_ID, INHERITED_PARENT_ID),
+  CONSTRAINT `SHARING_PERMISSION_TYPE_ID_DOMAIN_ID_FK` FOREIGN KEY (PERMISSION_TYPE_ID, DOMAIN_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  CONSTRAINT `SHARING_ENTITY_ID_DOMAIN_ID_FK` FOREIGN KEY (ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  CONSTRAINT `SHARING_INHERITED_PARENT_ID_DOMAIN_ID_FK` FOREIGN KEY (INHERITED_PARENT_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
+  CONSTRAINT `SHARING_GROUP_ID_DOMAIN_ID_FK` FOREIGN KEY (GROUP_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+CREATE TABLE CONFIGURATION
+(
+  CONFIG_KEY VARCHAR(255) NOT NULL,
+  CONFIG_VALUE VARCHAR(255) NOT NULL,
+  PRIMARY KEY(CONFIG_KEY, CONFIG_VALUE)
+)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
+
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VALUE) VALUES('sharing_reg_version', '0.17');
\ No newline at end of file
diff --git a/thrift-interfaces/sharing-service/sharing-cpi/sharing_cpi.thrift b/thrift-interfaces/sharing-service/sharing-cpi/sharing_cpi.thrift
deleted file mode 100644
index d253bd7..0000000
--- a/thrift-interfaces/sharing-service/sharing-cpi/sharing_cpi.thrift
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * 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.
- *
- */
-
-namespace java org.apache.custos.sharing.registry.service.cpi
-namespace php Custos.API.Sharing
-namespace py custos.api.sharing
-
-include "../sharing-models/sharing_models.thrift"
-
-const string SHARING_CPI_VERSION = "0.18.0"
-
-service SharingRegistryService{
-
-    /**
-      <p>API method to return the custos sharing registry service version</p>
-    */
-    string getAPIVersion () throws (1: sharing_models.SharingRegistryException sre)
-
-    /**
-      <p>API method to create a new domain</p>
-    */
-    string createDomain(1: required sharing_models.Domain domain) throws (1: sharing_models.SharingRegistryException sre, 2: sharing_models.DuplicateEntryException dee)
-    /**
-     <p>API method to update a domain</p>
-    */
-    bool updateDomain(1: required sharing_models.Domain domain) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to check Domain Exists</p>
-    */
-    bool isDomainExists(1: required string domainId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to delete domain</p>
-    */
-    bool deleteDomain(1: required string domainId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to retrieve a domain</p>
-    */
-    sharing_models.Domain getDomain(1: required string domainId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get all domain.</p>
-    */
-    list<sharing_models.Domain> getDomains(1: required i32 offset, 2: required i32 limit) throws (1: sharing_models.SharingRegistryException sre);
-
-    /**
-     <p>API method to register a user in the system</p>
-    */
-    string createUser(1: required sharing_models.User user) throws (1: sharing_models.SharingRegistryException sre, 2: sharing_models.DuplicateEntryException dee)
-    /**
-     <p>API method to update existing user</p>
-    */
-    bool updatedUser(1: required sharing_models.User user) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to check User Exists</p>
-    */
-    bool isUserExists(1: required string domainId, 2: required string userId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to delete user</p>
-    */
-    bool deleteUser(1: required string domainId, 2: required string userId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get a user</p>
-    */
-    sharing_models.User getUser(1: required string domainId, 2: required string userId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get a list of users in a specific domain.</p>
-     <li>domainId : Domain id</li>
-     <li>offset : Starting result number</li>
-     <li>limit : Number of max results to be sent</li>
-    */
-    list<sharing_models.User> getUsers(1: required string domainId, 2: required i32 offset, 3: required i32 limit) throws (1: sharing_models.SharingRegistryException sre);
-
-    /**
-     <p>API method to create a new group</p>
-    */
-    string createGroup(1: required sharing_models.UserGroup group) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to update a group</p>
-    */
-    bool updateGroup(1: required sharing_models.UserGroup group) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to check Group Exists</p>
-    */
-    bool isGroupExists(1: required string domainId, 2: required string groupId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to delete a group</p>
-    */
-    bool deleteGroup(1: required string domainId, 2: required string groupId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get a group</p>
-    */
-    sharing_models.UserGroup getGroup(1: required string domainId, 2: required string groupId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get groups in a domainId.</p>
-    */
-    list<sharing_models.UserGroup> getGroups(1: required string domainId, 2: required i32 offset, 3: required i32 limit)
-
-    /**
-     <p>API method to add list of users to a group</p>
-    */
-    bool addUsersToGroup(1: required string domainId, 2: required list<string> userIds, 3: required string groupId) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-     <p>API method to remove users from a group</p>
-    */
-    bool removeUsersFromGroup(1: required string domainId, 2: required list<string> userIds, 3: required string groupId) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-     <p>API method to transfer group ownership</p>
-    */
-    bool transferGroupOwnership(1: required string domainId, 2: required string groupId, 3: required string newOwnerId) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-    <p>API method to add Admin for a group</p>
-    */
-    bool addGroupAdmins(1: required string domainId, 2: required string groupId, 3: required list<string> adminIds) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-    <p>API method to remove Admin for a group</p>
-    */
-    bool removeGroupAdmins(1: required string domainId, 2: required string groupId, 3: required list<string> adminIds) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-    <p>API method to check whether the user has Admin access for the group</p>
-    */
-    bool hasAdminAccess(1: required string domainId, 2: required string groupId, 3: required string adminId) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-    <p>API method to check whether the user has Admin access for the group</p>
-    */
-    bool hasOwnerAccess(1: required string domainId, 2: required string groupId, 3: required string ownerId) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-     <p>API method to get list of child users in a group. Only the direct members will be returned.</p>
-    */
-    list<sharing_models.User> getGroupMembersOfTypeUser(1: string domainId, 2: required string groupId, 3: required i32 offset, 4: required i32 limit) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-     <p>API method to get list of child groups in a group. Only the direct members will be returned.</p>
-    */
-    list<sharing_models.UserGroup> getGroupMembersOfTypeGroup(1: required string domainId, 2: required string groupId, 3: required i32 offset, 4: required i32 limit) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-     <p>API method to add a child group to a parent group.</p>
-    */
-    bool addChildGroupsToParentGroup(1: required string domainId, 2: required list<string> childIds, 3: required string groupId) throws (1: sharing_models.SharingRegistryException sre);
-    /**
-     <p>API method to remove a child group from parent group.</p>
-    */
-    bool removeChildGroupFromParentGroup(1: required string domainId, 2: required string childId, 3: required string groupId) throws (1: sharing_models.SharingRegistryException sre);
-
-    list<sharing_models.UserGroup> getAllMemberGroupsForUser(1: required string domainId, 2: required string userId) throws (1: sharing_models.SharingRegistryException sre);
-
-    /**
-     <p>API method to create a new entity type</p>
-    */
-    string createEntityType(1: required sharing_models.EntityType entityType) throws (1: sharing_models.SharingRegistryException sre, 2: sharing_models.DuplicateEntryException dee)
-    /**
-     <p>API method to update entity type</p>
-    */
-    bool updateEntityType(1: required sharing_models.EntityType entityType) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to check EntityType Exists</p>
-    */
-    bool isEntityTypeExists(1: required string domainId, 2: required string entityTypeId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to delete entity type</p>
-    */
-    bool deleteEntityType(1: required string domainId, 2: required string entityTypeId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get an entity type</p>
-    */
-    sharing_models.EntityType getEntityType(1: required string domainId, 2: required string entityTypeId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get entity types in a domainId.</p>
-    */
-    list<sharing_models.EntityType> getEntityTypes(1: required string domainId, 2: required i32 offset, 3: required i32 limit) throws (1: sharing_models.SharingRegistryException sre);
-
-
-    /**
-     <p>API method to register new entity</p>
-    */
-    string createEntity(1: required sharing_models.Entity entity) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to update entity</p>
-    */
-    bool updateEntity(1: required sharing_models.Entity entity) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to check Entity Exists</p>
-    */
-    bool isEntityExists(1: required string domainId, 2: required string entityId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to delete entity</p>
-    */
-    bool deleteEntity(1: required string domainId, 2: required string entityId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get entity</p>
-    */
-    sharing_models.Entity getEntity(1: required string domainId, 2: required string entityId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to search entities</p>
-    */
-    list<sharing_models.Entity> searchEntities(1: required string domainId, 2: required string userId, 3: required list<sharing_models.SearchCriteria> filters, 4: required i32 offset, 5: required i32 limit) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get a list of shared users given the entity id</p>
-    */
-    list<sharing_models.User> getListOfSharedUsers(1: required string domainId, 2: required string entityId, 3: required string permissionTypeId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get a list of shared users given the entity id where the sharing type is directly applied</p>
-    */
-    list<sharing_models.User> getListOfDirectlySharedUsers(1: required string domainId, 2: required string entityId, 3: required string permissionTypeId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get a list of shared groups given the entity id</p>
-    */
-    list<sharing_models.UserGroup> getListOfSharedGroups(1: required string domainId, 2: required string entityId, 3: required string permissionTypeId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get a list of directly shared groups given the entity id where the sharing type is directly applied</p>
-    */
-    list<sharing_models.UserGroup> getListOfDirectlySharedGroups(1: required string domainId, 2: required string entityId, 3: required string permissionTypeId) throws (1: sharing_models.SharingRegistryException sre)
-
-    /**
-     <p>API method to create permission type</p>
-    */
-    string createPermissionType(1: required sharing_models.PermissionType permissionType) throws (1: sharing_models.SharingRegistryException sre, 2: sharing_models.DuplicateEntryException dee)
-    /**
-     <p>API method to update permission type</p>
-    */
-    bool updatePermissionType(1: required sharing_models.PermissionType permissionType) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to check Permission Exists</p>
-    */
-    bool isPermissionExists(1: required string dimainId, 2: required string permissionId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to delete permission type</p>
-    */
-    bool deletePermissionType(1: required string domainId, 2: required string permissionTypeId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get permission type</p>
-    */
-    sharing_models.PermissionType getPermissionType(1: required string domainId, 2: required string permissionTypeId) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to get list of permission types in a given domainId.</p>
-    */
-    list<sharing_models.PermissionType> getPermissionTypes(1: required string domainId, 2: required i32 offset, 3: required i32 limit) throws (1: sharing_models.SharingRegistryException sre)
-
-    /**
-     <p>API method to share an entity with users</p>
-    */
-    bool shareEntityWithUsers(1: required string domainId, 2: required string entityId, 3: required list<string> userList, 4: required string permissionTypeId, 5: required bool cascadePermission) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to revoke sharing from a list of users</p>
-    */
-    bool revokeEntitySharingFromUsers(1: required string domainId, 2: required string entityId, 3: required list<string> userList, 4: required string permissionTypeId ) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to share an entity with list of groups</p>
-    */
-    bool shareEntityWithGroups(1: required string domainId, 2: required string entityId, 3: required list<string> groupList, 4: required string permissionTypeId, 5: required bool cascadePermission) throws (1: sharing_models.SharingRegistryException sre)
-    /**
-     <p>API method to revoke sharing from list of users</p>
-    */
-    bool revokeEntitySharingFromGroups(1: required string domainId, 2: required string entityId, 3: required list<string> groupList, 4: required string permissionTypeId) throws (1: sharing_models.SharingRegistryException sre)
-
-    /**
-     <p>API method to check whether a user has access to a specific entity</p>
-    */
-    bool userHasAccess(1: required string domainId, 2: required string userId, 3: required string entityId, 4: required string permissionTypeId) throws (1: sharing_models.SharingRegistryException sre)
-}
diff --git a/thrift-interfaces/sharing-service/sharing-models/sharing_models.thrift b/thrift-interfaces/sharing-service/sharing-models/sharing_models.thrift
deleted file mode 100644
index dbaae11..0000000
--- a/thrift-interfaces/sharing-service/sharing-models/sharing_models.thrift
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * 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.
- *
- */
-
- namespace java org.apache.custos.sharing.registry.models
- namespace php Custos.Model.Sharing
- namespace py Custos.model.sharing
-
-const string DO_NOT_SET_AT_CLIENTS_ID = "DO_NOT_SET_AT_CLIENTS_ID"
-
-/**
-* <p>Domain is the entity that enables multi-tenency in this componenet. Every tenant will be
-* operating separately it's own silo which is identified by the domain id. In the current implementation domain id
-* will be same as the domain name</p>
-* <li>domainId : Will be generated by the server based on the domain name</li>
-* <li><b>name</b> : A single word name that identifies the domain e.g seagrid, ultrascan</li>
-* <li>description : A short description for the domain</li>
-* <li>createdTime : Will be set by the system</li>
-* <li>updatedTime : Will be set by the system</li>
-**/
-struct Domain {
-    1: optional string domainId = DO_NOT_SET_AT_CLIENTS_ID,
-    2: optional string name,
-    3: optional string description,
-    4: optional i64 createdTime,
-    5: optional i64 updatedTime
-}
-
-/**
-* <p>User is the model used to register a user in the system. Minimal user information will be required to provide
-* regarding the user.</p>
-* <li><b>userId</b> : User id provided by the client</li>
-* <li><b>domainId</b> : Domain id for that user</li>
-* <li><b>userName</b> : User name for the user</li>
-* <li><b>firstName</b> : First name of the user</li>
-* <li><b>lastName</b> : Last name of the user</li>
-* <li><b>email</b> : Email address of the user</li>
-* <li>icon : A binary field for storing the user icon</li>
-* <li>createdTime : If client provides this value then the system will use it if not the current time will be set</li>
-* <li>updatedTime : If client provides this value then the system will use it if not the current time will be set</li>
-**/
-struct User {
- 1: optional string userId,
- 2: optional string domainId,
- 3: optional string userName,
- 4: optional string firstName,
- 5: optional string lastName,
- 6: optional string email,
- 7: optional binary icon,
- 8: optional i64 createdTime,
- 9: optional i64 updatedTime
-}
-
-/*
-* Admin user for a group. Admin will have access to add more users or remove users from the group
-*
-**/
-struct GroupAdmin {
- 1: optional string groupId,
- 2: optional string domainId,
- 3: optional string adminId
-}
-
-/**
-* <p>This is an system internal enum used to define single user groups and multi users groups. Every user is also
-* considered as a group in it's own right for implementation ease</p>
-**/
-enum GroupCardinality {
-    SINGLE_USER,
-    MULTI_USER
-}
-
-/**
-* <p>Group types can be either user level or domain level groups.</p>
-**/
-enum GroupType {
-    DOMAIN_LEVEL_GROUP,
-    USER_LEVEL_GROUP
-}
-
-/**
-*<p>User group is a collection of users.</p>
-* <li><b>groupId</b> : Group id provided by the client</li>
-* <li><b>domainId</b> : Domain id for this user group</li>
-* <li><b>name</b> : Name for the user group. should be one word</li>
-* <li>description : Short description for the group.</li>
-* <li><b>ownerId</b> : Owner id of this group.</li>
-* <li><b>groupType</b> : Group type (DOMAIN_LEVEL_GROUP, USER_LEVEL_GROUP)</li>
-* <li><b>groupCardinality</b> : Group cardinality (SINGLE_USER, MULTI_USER)</li>
-* <li>createdTime : Will be set by the system</li>
-* <li>updatedTime : Will be set by the system</li>
-* <li>groupAdmins : Admins for the group</li>
-**/
-struct UserGroup {
- 1: optional string groupId,
- 2: optional string domainId,
- 3: optional string name,
- 4: optional string description,
- 5: optional string ownerId,
- 6: optional GroupType groupType,
- 7: optional GroupCardinality groupCardinality,
- 8: optional i64 createdTime,
- 9: optional i64 updatedTime,
- 10: optional list<GroupAdmin> groupAdmins
-}
-
-/**
-* <p>System internal data type to match group child types</p>
-**/
-enum GroupChildType {
-    USER,
-    GROUP
-}
-
-/**
-* <p>System internal data type to map group memberships</p>
-**/
-struct GroupMembership {
-    1: optional string parentId,
-    2: optional string childId,
-    3: optional string domainId,
-    4: optional GroupChildType childType
-    5: optional i64 createdTime,
-    6: optional i64 updatedTime
-}
-
-
-/**
-* <p>client defined entity types</p>
-* <li><b>entityTypeId</b> : Entity type id provided by the client</li>
-* <li><b>domainId</b> : Domain id of the domain.</li>
-* <li><b>name</b> : Name for the entity type. Should be a single word.</li>
-* <li>description : Short description for the entity type.</li>
-* <li>createdTime : Will be set by the system</li>
-* <li>updatedTime : Will be set by the system</li>
-**/
-struct EntityType {
-    1: optional string entityTypeId,
-    2: optional string domainId,
-    3: optional string name,
-    4: optional string description,
-    5: optional i64 createdTime,
-    6: optional i64 updatedTime
-}
-
-/**
-* <p>This list of fields that can be used to search entities</p>
-* <li>NAME : Name of the entity</li>
-* <li>DESCRIPTION : Description of the entity</li>
-* <li>FULL_TEXT : Full text field of the entity</li>
-* <li>PARENT_ENTITY_ID : Parent entity id of the entity</li>
-* <li>OWNER_ID : Owner of the entity</li>
-* <li>CREATED_TIME : Created time of the entity</li>
-* <li>UPDATED_TIME : Updated time of the entity</li>
-* <li>SHARED_COUNT : Number of directly shared users and groups</li>
-**/
-enum EntitySearchField {
-    NAME,
-    DESCRIPTION,
-    FULL_TEXT,
-    PARRENT_ENTITY_ID,
-    OWNER_ID,
-    PERMISSION_TYPE_ID,
-    CREATED_TIME,
-    UPDATED_TIME,
-    ENTITY_TYPE_ID,
-    SHARED_COUNT
-}
-
-/**
-* <p>Different search operators that can be used with the entity search fields</p>
-* <li>EQUAL : Simply matches for equality. Applicable for name, and parent entity id</li>
-* <li>LIKE : Check for the condition %$FIELD% condition. Applicable for name, and description</li>
-* <li>FULL_TEXT : Does a full text search. Only applicable for the FULL_TEXT field.</li>
-* <li>GTE : Greater than or equal. Only applicable for created time, updated time and shared count.</li>
-* <li>LTE : Less than or equal. Only applicable for created time, updated time and shared count.</li>
-**/
-enum SearchCondition {
-    EQUAL,
-    LIKE,
-    FULL_TEXT,
-    GTE,
-    LTE,
-    NOT
-}
-
-/**
-* <p>Container object for search criteria</p>
-* <li><b>searchField</b> : Entity search field</li>
-* <li><b>value</b> : Search value</li>
-* <li><b>searchCondition</b> : EQUAL, LIKE etc..</li>
-**/
-struct SearchCriteria {
-    1: optional EntitySearchField searchField,
-    2: optional string value,
-    3: optional SearchCondition searchCondition
-}
-
-/**
-* <p>Entity object which is used to register an entity in the system.</p>
-* <li><b>entityId</b> : Entity id provided by the client</li>
-* <li><b>domainId</b> : Domain id</li>
-* <li><b>entityTypeId</b> : Entity type id</li>
-* <li><b>ownerId</b> : Owner id</li>
-* <li>parentEntityId : Parent entity id</li>
-* <li><b>name</b> : Name</li>
-* <li>description : Short description for the entity</li>
-* <li>binaryData : Any information stored in binary format</li>
-* <li>fullText : A string which will be considered for full text search</li>
-* <li><b>originalEntityCreationTime</b> : When registering old records what is the original entity creation time. If not
-* set will be default to current time</li>
-* <li>createdTime : Will be set by the system</li>
-* <li>updatedTime : Will be set by the system</li>
-**/
-struct Entity {
-    1: optional string entityId,
-    2: optional string domainId,
-    3: optional string entityTypeId,
-    4: optional string ownerId,
-    5: optional string parentEntityId,
-    6: optional string name,
-    7: optional string description,
-    8: optional binary binaryData,
-    9: optional string fullText,
-    10: optional i64 sharedCount = 0,
-    11: optional i64 originalEntityCreationTime,
-    12: optional i64 createdTime,
-    13: optional i64 updatedTime
-}
-
-/**
-* <p>Object for creating client defined permission type</p>
-* <li><b>permissionTypeId</b> : Permission type id provided by the client</li>
-* <li><b>domainId</b> : Domain id</li>
-* <li><b>name</b> : Single word name for the permission</li>
-* <li>description : Short description for the permission type</li>
-* <li>createdTime : Will be set by the system</li>
-* <li>updatedTime : Will be set by the system</li>
-**/
-struct PermissionType {
-    1: optional string permissionTypeId,
-    2: optional string domainId,
-    3: optional string name,
-    4: optional string description,
-    5: optional i64 createdTime,
-    6: optional i64 updatedTime
-}
-
-/**
-* <p>This is an internal enum type for managing sharings</p>
-**/
-enum SharingType {
-    DIRECT_NON_CASCADING,
-    DIRECT_CASCADING,
-    INDIRECT_CASCADING
- }
-
-/**
-* <p>This is an internal enum type for managing sharings</p>
-**/
-struct Sharing {
-    1: optional string permissionTypeId,
-    2: optional string entityId,
-    3: optional string groupId,
-    4: optional SharingType sharingType,
-    5: optional string domainId,
-    6: optional string inheritedParentId,
-    7: optional i64 createdTime,
-    8: optional i64 updatedTime
-}
-
-/**
-* <p>Exception model used in the sharing registry service</p>
-**/
-exception SharingRegistryException {
-  1: required string message
-}
-
-/**
-* This exception is thrown when you try to save a duplicate entity that already exists
-*   in the database.
-*
-*   message: contains the associated error message
-**/
-exception DuplicateEntryException {
-    1: required string message
-}
\ No newline at end of file


[airavata-custos] 19/48: code refactoring

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bd6952cbb33947daf4583de8395b9de6ed4b57b7
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Aug 12 12:27:48 2019 -0400

    code refactoring
---
 .../service/AuthenticationServiceClient.java       |    2 +-
 .../custos/commons/utils/ApplicationSettings.java  |   12 +-
 .../user/entities/CustomizedDashboardEntity.java   |  325 ---
 .../commons/user/entities/UserProfileEntity.java   |   11 -
 .../custos/profile/model/user/CustomDashboard.java | 2912 --------------------
 .../custos/profile/model/user/NSFDemographics.java |  145 +-
 .../apache/custos/profile/model/user/Status.java   |   25 +-
 .../custos/profile/model/user/USCitizenship.java   |   25 +-
 .../custos/profile/model/user/UserProfile.java     |  506 ++--
 .../custos/profile/model/user/disability.java      |   25 +-
 .../custos/profile/model/user/ethnicity.java       |   25 +-
 .../org/apache/custos/profile/model/user/race.java |   25 +-
 .../model/user/user_profile_modelConstants.java    |   21 +-
 .../database_scripts/init/01-databases.sql         |   48 -
 pom.xml                                            |    1 +
 .../user_profile_model.thrift                      |   36 +-
 16 files changed, 333 insertions(+), 3811 deletions(-)

diff --git a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
index 7ef7cf4..4fc0444 100644
--- a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
+++ b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
@@ -8,7 +8,7 @@ import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 
-    public class AuthenticationServiceClient {
+public class AuthenticationServiceClient {
 
     public static CustosAuthenticationService.Client createAuthenticationServiceClient(String serverHost, int serverPort)  throws CustosAuthenticationServiceException {
         try {
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
index e494120..fdcdf97 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
@@ -14,7 +14,7 @@ import java.util.*;
 import java.util.regex.Pattern;
 
 public class ApplicationSettings {
-    //private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
+    private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
     protected static ApplicationSettings INSTANCE;
     private Exception propertyLoadException;
     public static final String SERVER_PROPERTIES="custos-server.properties";
@@ -31,11 +31,11 @@ public class ApplicationSettings {
         URL url = getPropertyFileURL();
         try {
             properties.load(url.openStream());
-            //logger.info("Settings loaded from "+url.toString());
+            logger.info("Settings loaded from "+url.toString());
             URL[] externalSettingsFileURLs = getExternalSettingsFileURLs();
             for (URL externalSettings : externalSettingsFileURLs) {
                 mergeSettingsImpl(externalSettings.openStream());
-                //logger.info("External settings merged from "+url.toString());
+                logger.info("External settings merged from "+url.toString());
             }
         } catch (Exception e) {
             propertyLoadException=e;
@@ -54,7 +54,7 @@ public class ApplicationSettings {
             for (String externalSettingFile : externalSettingFiles) {
                 URL externalSettingFileURL = ApplicationSettings.loadFile(externalSettingFile);
                 if (externalSettingFileURL==null){
-                    //logger.warn("Could not file external settings file "+externalSettingFile);
+                    logger.warn("Could not file external settings file "+externalSettingFile);
                 }else{
                     externalSettingsFileURLs.add(externalSettingFileURL);
                 }
@@ -81,7 +81,7 @@ public class ApplicationSettings {
                     return asfile.toURI().toURL();
                 }
             } catch (MalformedURLException e) {
-                //logger.error("Error parsing the file from custos.config.dir", custosConfigDir);
+                logger.error("Error parsing the file from custos.config.dir", custosConfigDir);
             }
         }
 
@@ -114,7 +114,7 @@ public class ApplicationSettings {
                 throw new ApplicationSettingsException(url.getPath(), e);
             }
         }else{
-            //logger.warn("Properties cannot be updated to location "+url.toString());
+            logger.warn("Properties cannot be updated to location "+url.toString());
         }
     }
     private String getSettingImpl(String key, String defaultValue){
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/CustomizedDashboardEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/CustomizedDashboardEntity.java
deleted file mode 100644
index d92cc25..0000000
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/CustomizedDashboardEntity.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- *
- * 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.custos.profile.commons.user.entities;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "CUSTOMIZED_DASHBOARD")
-public class CustomizedDashboardEntity {
-
-    private String custosInternalUserId;
-    private String experimentId;
-    private String name;
-    private String description;
-    private String project;
-    private String owner;
-    private String application;
-    private String computeResource;
-    private String jobName;
-    private String jobId;
-    private String jobStatus;
-    private String jobCreationTime;
-    private String notificationsTo;
-    private String workingDir;
-    private String jobDescription;
-    private String creationTime;
-    private String lastModifiedTime;
-    private String wallTime;
-    private String cpuCount;
-    private String nodeCount;
-    private String queue;
-    private String inputs;
-    private String outputs;
-    private String storageDir;
-    private String errors;
-
-    private UserProfileEntity userProfileEntity;
-
-    @Id
-    @Column(name = "CUSTOS_INTERNAL_USER_ID")
-    public String getCustosInternalUserId() {
-        return custosInternalUserId;
-    }
-
-    public void setCustosInternalUserId(String custosInternalUserId) {
-        this.custosInternalUserId = custosInternalUserId;
-    }
-
-    @Column(name = "ENABLED_EXPERIMENT_ID")
-    public String getExperimentId() {
-        return experimentId;
-    }
-
-    public void setExperimentId(String experimentId) {
-        this.experimentId = experimentId;
-    }
-
-    @Column(name = "ENABLED_NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Column(name = "ENABLED_DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Column(name = "ENABLED_PROJECT")
-    public String getProject() {
-        return project;
-    }
-
-    public void setProject(String project) {
-        this.project = project;
-    }
-
-    @Column(name = "ENABLED_OWNER")
-    public String getOwner() {
-        return owner;
-    }
-
-    public void setOwner(String owner) {
-        this.owner = owner;
-    }
-
-    @Column(name = "ENABLED_APPLICATION")
-    public String getApplication() {
-        return application;
-    }
-
-    public void setApplication(String application) {
-        this.application = application;
-    }
-
-    @Column(name = "ENABLED_COMPUTE_RESOURCE")
-    public String getComputeResource() {
-        return computeResource;
-    }
-
-    public void setComputeResource(String computeResource) {
-        this.computeResource = computeResource;
-    }
-
-    @Column(name = "ENABLED_JOB_NAME")
-    public String getJobName() {
-        return jobName;
-    }
-
-    public void setJobName(String jobName) {
-        this.jobName = jobName;
-    }
-
-    @Column(name = "ENABLED_JOB_ID")
-    public String getJobId() {
-        return jobId;
-    }
-
-    public void setJobId(String jobId) {
-        this.jobId = jobId;
-    }
-
-    @Column(name = "ENABLED_JOB_STATUS")
-    public String getJobStatus() {
-        return jobStatus;
-    }
-
-    public void setJobStatus(String jobStatus) {
-        this.jobStatus = jobStatus;
-    }
-
-    @Column(name = "ENABLED_JOB_CREATION_TIME")
-    public String getJobCreationTime() {
-        return jobCreationTime;
-    }
-
-    public void setJobCreationTime(String jobCreationTime) {
-        this.jobCreationTime = jobCreationTime;
-    }
-
-    @Column(name = "ENABLED_NOTIFICATIONS_TO")
-    public String getNotificationsTo() {
-        return notificationsTo;
-    }
-
-    public void setNotificationsTo(String notificationsTo) {
-        this.notificationsTo = notificationsTo;
-    }
-
-    @Column(name = "ENABLED_WORKING_DIR")
-    public String getWorkingDir() {
-        return workingDir;
-    }
-
-    public void setWorkingDir(String workingDir) {
-        this.workingDir = workingDir;
-    }
-
-    @Column(name = "ENABLED_JOB_DESCRIPTION")
-    public String getJobDescription() {
-        return jobDescription;
-    }
-
-    public void setJobDescription(String jobDescription) {
-        this.jobDescription = jobDescription;
-    }
-
-    @Column(name = "ENABLED_CREATION_TIME")
-    public String getCreationTime() {
-        return creationTime;
-    }
-
-    public void setCreationTime(String creationTime) {
-        this.creationTime = creationTime;
-    }
-
-    @Column(name = "ENABLED_LAST_MODIFIED_TIME")
-    public String getLastModifiedTime() {
-        return lastModifiedTime;
-    }
-
-    public void setLastModifiedTime(String lastModifiedTime) {
-        this.lastModifiedTime = lastModifiedTime;
-    }
-
-    @Column(name = "ENABLED_WALL_TIME")
-    public String getWallTime() {
-        return wallTime;
-    }
-
-    public void setWallTime(String wallTime) {
-        this.wallTime = wallTime;
-    }
-
-    @Column(name = "ENABLED_CPU_COUNT")
-    public String getCpuCount() {
-        return cpuCount;
-    }
-
-    public void setCpuCount(String cpuCount) {
-        this.cpuCount = cpuCount;
-    }
-
-    @Column(name = "ENABLED_NODE_COUNT")
-    public String getNodeCount() {
-        return nodeCount;
-    }
-
-    public void setNodeCount(String nodeCount) {
-        this.nodeCount = nodeCount;
-    }
-
-    @Column(name = "ENABLED_QUEUE")
-    public String getQueue() {
-        return queue;
-    }
-
-    public void setQueue(String queue) {
-        this.queue = queue;
-    }
-
-    @Column(name = "ENABLED_INPUTS")
-    public String getInputs() {
-        return inputs;
-    }
-
-    public void setInputs(String inputs) {
-        this.inputs = inputs;
-    }
-
-    @Column(name = "ENABLED_OUTPUTS")
-    public String getOutputs() {
-        return outputs;
-    }
-
-    public void setOutputs(String outputs) {
-        this.outputs = outputs;
-    }
-
-    @Column(name = "ENABLED_STORAGE_DIR")
-    public String getStorageDir() {
-        return storageDir;
-    }
-
-    public void setStorageDir(String storageDir) {
-        this.storageDir = storageDir;
-    }
-
-    @Column(name = "ENABLED_ERRORS")
-    public String getErrors() {
-        return errors;
-    }
-
-    public void setErrors(String errors) {
-        this.errors = errors;
-    }
-
-    @OneToOne(targetEntity = UserProfileEntity.class, cascade = CascadeType.ALL)
-    @PrimaryKeyJoinColumn(name = "CUSTOS_INTERNAL_USER_ID", referencedColumnName = "CUSTOS_INTERNAL_USER_ID")
-    public UserProfileEntity getUserProfileEntity() {
-        return userProfileEntity;
-    }
-
-    public void setUserProfileEntity(UserProfileEntity userProfileEntity) {
-        this.userProfileEntity = userProfileEntity;
-    }
-
-    @Override
-    public String toString() {
-        return "CustomizedDashboardEntity{" +
-                "custosInternalUserId='" + custosInternalUserId + '\'' +
-                ", experimentId='" + experimentId + '\'' +
-                ", name='" + name + '\'' +
-                ", description='" + description + '\'' +
-                ", project='" + project + '\'' +
-                ", owner='" + owner + '\'' +
-                ", application='" + application + '\'' +
-                ", computeResource='" + computeResource + '\'' +
-                ", jobName='" + jobName + '\'' +
-                ", jobId='" + jobId + '\'' +
-                ", jobStatus='" + jobStatus + '\'' +
-                ", jobCreationTime='" + jobCreationTime + '\'' +
-                ", notificationsTo='" + notificationsTo + '\'' +
-                ", workingDir='" + workingDir + '\'' +
-                ", jobDescription='" + jobDescription + '\'' +
-                ", creationTime='" + creationTime + '\'' +
-                ", lastModifiedTime='" + lastModifiedTime + '\'' +
-                ", wallTime='" + wallTime + '\'' +
-                ", cpuCount='" + cpuCount + '\'' +
-                ", nodeCount='" + nodeCount + '\'' +
-                ", queue='" + queue + '\'' +
-                ", inputs='" + inputs + '\'' +
-                ", outputs='" + outputs + '\'' +
-                ", storageDir='" + storageDir + '\'' +
-                ", errors='" + errors + '\'' +
-                '}';
-    }
-}
diff --git a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java
index 04f3265..6a69b7f 100644
--- a/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java
+++ b/custos-profile-service/profile-service-commons/src/main/java/org/apache/custos/profile/commons/user/entities/UserProfileEntity.java
@@ -53,7 +53,6 @@ public class UserProfileEntity {
     private List<String> emails;
     private List<String> phones;
     private NSFDemographicsEntity nsfDemographics;
-    private CustomizedDashboardEntity customizedDashboardEntity;
 
     @Id
     @Column(name = "CUSTOS_INTERNAL_USER_ID")
@@ -292,16 +291,6 @@ public class UserProfileEntity {
         this.nsfDemographics = nsfDemographics;
     }
 
-    @OneToOne(targetEntity = CustomizedDashboardEntity.class, cascade = CascadeType.ALL,
-            mappedBy = "userProfileEntity", fetch = FetchType.EAGER)
-    public CustomizedDashboardEntity getCustomizedDashboardEntity() {
-        return customizedDashboardEntity;
-    }
-
-    public void setCustomizedDashboardEntity(CustomizedDashboardEntity customizedDashboardEntity) {
-        this.customizedDashboardEntity = customizedDashboardEntity;
-    }
-
     @PrePersist
     void createdAt() {
         this.creationTime = this.lastAccessTime = new Date();
diff --git a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/CustomDashboard.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/CustomDashboard.java
deleted file mode 100644
index 0799843..0000000
--- a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/CustomDashboard.java
+++ /dev/null
@@ -1,2912 +0,0 @@
-/**
- * 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.10.0)
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- *  @generated
- */
-package org.apache.custos.profile.model.user;
-
-@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-/**
- * A structure holding the cutomized admin dashboard information.
- * 
- * 
- */
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
-public class CustomDashboard implements org.apache.thrift.TBase<CustomDashboard, CustomDashboard._Fields>, java.io.Serializable, Cloneable, Comparable<CustomDashboard> {
-  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CustomDashboard");
-
-  private static final org.apache.thrift.protocol.TField AIRAVATA_INTERNAL_USER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("airavataInternalUserId", org.apache.thrift.protocol.TType.STRING, (short)1);
-  private static final org.apache.thrift.protocol.TField EXPERIMENT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("experimentId", org.apache.thrift.protocol.TType.STRING, (short)2);
-  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", 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 PROJECT_FIELD_DESC = new org.apache.thrift.protocol.TField("project", org.apache.thrift.protocol.TType.STRING, (short)5);
-  private static final org.apache.thrift.protocol.TField OWNER_FIELD_DESC = new org.apache.thrift.protocol.TField("owner", org.apache.thrift.protocol.TType.STRING, (short)6);
-  private static final org.apache.thrift.protocol.TField APPLICATION_FIELD_DESC = new org.apache.thrift.protocol.TField("application", org.apache.thrift.protocol.TType.STRING, (short)7);
-  private static final org.apache.thrift.protocol.TField COMPUTE_RESOURCE_FIELD_DESC = new org.apache.thrift.protocol.TField("computeResource", org.apache.thrift.protocol.TType.STRING, (short)8);
-  private static final org.apache.thrift.protocol.TField JOB_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("jobName", org.apache.thrift.protocol.TType.STRING, (short)9);
-  private static final org.apache.thrift.protocol.TField JOB_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("jobId", org.apache.thrift.protocol.TType.STRING, (short)10);
-  private static final org.apache.thrift.protocol.TField JOB_STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("jobStatus", org.apache.thrift.protocol.TType.STRING, (short)11);
-  private static final org.apache.thrift.protocol.TField JOB_CREATION_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("jobCreationTime", org.apache.thrift.protocol.TType.STRING, (short)12);
-  private static final org.apache.thrift.protocol.TField NOTIFICATIONS_TO_FIELD_DESC = new org.apache.thrift.protocol.TField("notificationsTo", org.apache.thrift.protocol.TType.STRING, (short)13);
-  private static final org.apache.thrift.protocol.TField WORKING_DIR_FIELD_DESC = new org.apache.thrift.protocol.TField("workingDir", org.apache.thrift.protocol.TType.STRING, (short)14);
-  private static final org.apache.thrift.protocol.TField JOB_DESCRIPTION_FIELD_DESC = new org.apache.thrift.protocol.TField("jobDescription", org.apache.thrift.protocol.TType.STRING, (short)15);
-  private static final org.apache.thrift.protocol.TField CREATION_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("creationTime", org.apache.thrift.protocol.TType.STRING, (short)16);
-  private static final org.apache.thrift.protocol.TField LAST_MODIFIED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("lastModifiedTime", org.apache.thrift.protocol.TType.STRING, (short)17);
-  private static final org.apache.thrift.protocol.TField WALL_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("wallTime", org.apache.thrift.protocol.TType.STRING, (short)18);
-  private static final org.apache.thrift.protocol.TField CPU_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("cpuCount", org.apache.thrift.protocol.TType.STRING, (short)19);
-  private static final org.apache.thrift.protocol.TField NODE_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("nodeCount", org.apache.thrift.protocol.TType.STRING, (short)20);
-  private static final org.apache.thrift.protocol.TField QUEUE_FIELD_DESC = new org.apache.thrift.protocol.TField("queue", org.apache.thrift.protocol.TType.STRING, (short)21);
-  private static final org.apache.thrift.protocol.TField INPUTS_FIELD_DESC = new org.apache.thrift.protocol.TField("inputs", org.apache.thrift.protocol.TType.STRING, (short)22);
-  private static final org.apache.thrift.protocol.TField OUTPUTS_FIELD_DESC = new org.apache.thrift.protocol.TField("outputs", org.apache.thrift.protocol.TType.STRING, (short)23);
-  private static final org.apache.thrift.protocol.TField STORAGE_DIR_FIELD_DESC = new org.apache.thrift.protocol.TField("storageDir", org.apache.thrift.protocol.TType.STRING, (short)24);
-  private static final org.apache.thrift.protocol.TField ERRORS_FIELD_DESC = new org.apache.thrift.protocol.TField("errors", org.apache.thrift.protocol.TType.STRING, (short)25);
-
-  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new CustomDashboardStandardSchemeFactory();
-  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new CustomDashboardTupleSchemeFactory();
-
-  private String airavataInternalUserId; // required
-  private String experimentId; // optional
-  private String name; // optional
-  private String description; // optional
-  private String project; // optional
-  private String owner; // optional
-  private String application; // optional
-  private String computeResource; // optional
-  private String jobName; // optional
-  private String jobId; // optional
-  private String jobStatus; // optional
-  private String jobCreationTime; // optional
-  private String notificationsTo; // optional
-  private String workingDir; // optional
-  private String jobDescription; // optional
-  private String creationTime; // optional
-  private String lastModifiedTime; // optional
-  private String wallTime; // optional
-  private String cpuCount; // optional
-  private String nodeCount; // optional
-  private String queue; // optional
-  private String inputs; // optional
-  private String outputs; // optional
-  private String storageDir; // optional
-  private String errors; // optional
-
-  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
-  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
-    AIRAVATA_INTERNAL_USER_ID((short)1, "airavataInternalUserId"),
-    EXPERIMENT_ID((short)2, "experimentId"),
-    NAME((short)3, "name"),
-    DESCRIPTION((short)4, "description"),
-    PROJECT((short)5, "project"),
-    OWNER((short)6, "owner"),
-    APPLICATION((short)7, "application"),
-    COMPUTE_RESOURCE((short)8, "computeResource"),
-    JOB_NAME((short)9, "jobName"),
-    JOB_ID((short)10, "jobId"),
-    JOB_STATUS((short)11, "jobStatus"),
-    JOB_CREATION_TIME((short)12, "jobCreationTime"),
-    NOTIFICATIONS_TO((short)13, "notificationsTo"),
-    WORKING_DIR((short)14, "workingDir"),
-    JOB_DESCRIPTION((short)15, "jobDescription"),
-    CREATION_TIME((short)16, "creationTime"),
-    LAST_MODIFIED_TIME((short)17, "lastModifiedTime"),
-    WALL_TIME((short)18, "wallTime"),
-    CPU_COUNT((short)19, "cpuCount"),
-    NODE_COUNT((short)20, "nodeCount"),
-    QUEUE((short)21, "queue"),
-    INPUTS((short)22, "inputs"),
-    OUTPUTS((short)23, "outputs"),
-    STORAGE_DIR((short)24, "storageDir"),
-    ERRORS((short)25, "errors");
-
-    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-    static {
-      for (_Fields field : java.util.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: // AIRAVATA_INTERNAL_USER_ID
-          return AIRAVATA_INTERNAL_USER_ID;
-        case 2: // EXPERIMENT_ID
-          return EXPERIMENT_ID;
-        case 3: // NAME
-          return NAME;
-        case 4: // DESCRIPTION
-          return DESCRIPTION;
-        case 5: // PROJECT
-          return PROJECT;
-        case 6: // OWNER
-          return OWNER;
-        case 7: // APPLICATION
-          return APPLICATION;
-        case 8: // COMPUTE_RESOURCE
-          return COMPUTE_RESOURCE;
-        case 9: // JOB_NAME
-          return JOB_NAME;
-        case 10: // JOB_ID
-          return JOB_ID;
-        case 11: // JOB_STATUS
-          return JOB_STATUS;
-        case 12: // JOB_CREATION_TIME
-          return JOB_CREATION_TIME;
-        case 13: // NOTIFICATIONS_TO
-          return NOTIFICATIONS_TO;
-        case 14: // WORKING_DIR
-          return WORKING_DIR;
-        case 15: // JOB_DESCRIPTION
-          return JOB_DESCRIPTION;
-        case 16: // CREATION_TIME
-          return CREATION_TIME;
-        case 17: // LAST_MODIFIED_TIME
-          return LAST_MODIFIED_TIME;
-        case 18: // WALL_TIME
-          return WALL_TIME;
-        case 19: // CPU_COUNT
-          return CPU_COUNT;
-        case 20: // NODE_COUNT
-          return NODE_COUNT;
-        case 21: // QUEUE
-          return QUEUE;
-        case 22: // INPUTS
-          return INPUTS;
-        case 23: // OUTPUTS
-          return OUTPUTS;
-        case 24: // STORAGE_DIR
-          return STORAGE_DIR;
-        case 25: // ERRORS
-          return ERRORS;
-        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
-  private static final _Fields optionals[] = {_Fields.EXPERIMENT_ID, _Fields.NAME, _Fields.DESCRIPTION, _Fields.PROJECT, _Fields.OWNER, _Fields.APPLICATION, _Fields.COMPUTE_RESOURCE, _Fields.JOB_NAME, _Fields.JOB_ID, _Fields.JOB_STATUS, _Fields.JOB_CREATION_TIME, _Fields.NOTIFICATIONS_TO, _Fields.WORKING_DIR, _Fields.JOB_DESCRIPTION, _Fields.CREATION_TIME, _Fields.LAST_MODIFIED_TIME, _Fields.WALL_TIME, _Fields.CPU_COUNT, _Fields.NODE_COUNT, _Fields.QUEUE, _Fields.INPUTS, _Fields.OUTPUTS, [...]
-  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-  static {
-    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.AIRAVATA_INTERNAL_USER_ID, new org.apache.thrift.meta_data.FieldMetaData("airavataInternalUserId", org.apache.thrift.TFieldRequirementType.REQUIRED,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.EXPERIMENT_ID, new org.apache.thrift.meta_data.FieldMetaData("experimentId", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        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.PROJECT, new org.apache.thrift.meta_data.FieldMetaData("project", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.OWNER, new org.apache.thrift.meta_data.FieldMetaData("owner", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.APPLICATION, new org.apache.thrift.meta_data.FieldMetaData("application", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.COMPUTE_RESOURCE, new org.apache.thrift.meta_data.FieldMetaData("computeResource", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.JOB_NAME, new org.apache.thrift.meta_data.FieldMetaData("jobName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.JOB_ID, new org.apache.thrift.meta_data.FieldMetaData("jobId", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.JOB_STATUS, new org.apache.thrift.meta_data.FieldMetaData("jobStatus", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.JOB_CREATION_TIME, new org.apache.thrift.meta_data.FieldMetaData("jobCreationTime", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.NOTIFICATIONS_TO, new org.apache.thrift.meta_data.FieldMetaData("notificationsTo", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.WORKING_DIR, new org.apache.thrift.meta_data.FieldMetaData("workingDir", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.JOB_DESCRIPTION, new org.apache.thrift.meta_data.FieldMetaData("jobDescription", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.CREATION_TIME, new org.apache.thrift.meta_data.FieldMetaData("creationTime", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.LAST_MODIFIED_TIME, new org.apache.thrift.meta_data.FieldMetaData("lastModifiedTime", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.WALL_TIME, new org.apache.thrift.meta_data.FieldMetaData("wallTime", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.CPU_COUNT, new org.apache.thrift.meta_data.FieldMetaData("cpuCount", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.NODE_COUNT, new org.apache.thrift.meta_data.FieldMetaData("nodeCount", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.QUEUE, new org.apache.thrift.meta_data.FieldMetaData("queue", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.INPUTS, new org.apache.thrift.meta_data.FieldMetaData("inputs", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.OUTPUTS, new org.apache.thrift.meta_data.FieldMetaData("outputs", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.STORAGE_DIR, new org.apache.thrift.meta_data.FieldMetaData("storageDir", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.ERRORS, new org.apache.thrift.meta_data.FieldMetaData("errors", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(CustomDashboard.class, metaDataMap);
-  }
-
-  public CustomDashboard() {
-    this.airavataInternalUserId = "DO_NOT_SET_AT_CLIENTS";
-
-  }
-
-  public CustomDashboard(
-    String airavataInternalUserId)
-  {
-    this();
-    this.airavataInternalUserId = airavataInternalUserId;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public CustomDashboard(CustomDashboard other) {
-    if (other.isSetAiravataInternalUserId()) {
-      this.airavataInternalUserId = other.airavataInternalUserId;
-    }
-    if (other.isSetExperimentId()) {
-      this.experimentId = other.experimentId;
-    }
-    if (other.isSetName()) {
-      this.name = other.name;
-    }
-    if (other.isSetDescription()) {
-      this.description = other.description;
-    }
-    if (other.isSetProject()) {
-      this.project = other.project;
-    }
-    if (other.isSetOwner()) {
-      this.owner = other.owner;
-    }
-    if (other.isSetApplication()) {
-      this.application = other.application;
-    }
-    if (other.isSetComputeResource()) {
-      this.computeResource = other.computeResource;
-    }
-    if (other.isSetJobName()) {
-      this.jobName = other.jobName;
-    }
-    if (other.isSetJobId()) {
-      this.jobId = other.jobId;
-    }
-    if (other.isSetJobStatus()) {
-      this.jobStatus = other.jobStatus;
-    }
-    if (other.isSetJobCreationTime()) {
-      this.jobCreationTime = other.jobCreationTime;
-    }
-    if (other.isSetNotificationsTo()) {
-      this.notificationsTo = other.notificationsTo;
-    }
-    if (other.isSetWorkingDir()) {
-      this.workingDir = other.workingDir;
-    }
-    if (other.isSetJobDescription()) {
-      this.jobDescription = other.jobDescription;
-    }
-    if (other.isSetCreationTime()) {
-      this.creationTime = other.creationTime;
-    }
-    if (other.isSetLastModifiedTime()) {
-      this.lastModifiedTime = other.lastModifiedTime;
-    }
-    if (other.isSetWallTime()) {
-      this.wallTime = other.wallTime;
-    }
-    if (other.isSetCpuCount()) {
-      this.cpuCount = other.cpuCount;
-    }
-    if (other.isSetNodeCount()) {
-      this.nodeCount = other.nodeCount;
-    }
-    if (other.isSetQueue()) {
-      this.queue = other.queue;
-    }
-    if (other.isSetInputs()) {
-      this.inputs = other.inputs;
-    }
-    if (other.isSetOutputs()) {
-      this.outputs = other.outputs;
-    }
-    if (other.isSetStorageDir()) {
-      this.storageDir = other.storageDir;
-    }
-    if (other.isSetErrors()) {
-      this.errors = other.errors;
-    }
-  }
-
-  public CustomDashboard deepCopy() {
-    return new CustomDashboard(this);
-  }
-
-  @Override
-  public void clear() {
-    this.airavataInternalUserId = "DO_NOT_SET_AT_CLIENTS";
-
-    this.experimentId = null;
-    this.name = null;
-    this.description = null;
-    this.project = null;
-    this.owner = null;
-    this.application = null;
-    this.computeResource = null;
-    this.jobName = null;
-    this.jobId = null;
-    this.jobStatus = null;
-    this.jobCreationTime = null;
-    this.notificationsTo = null;
-    this.workingDir = null;
-    this.jobDescription = null;
-    this.creationTime = null;
-    this.lastModifiedTime = null;
-    this.wallTime = null;
-    this.cpuCount = null;
-    this.nodeCount = null;
-    this.queue = null;
-    this.inputs = null;
-    this.outputs = null;
-    this.storageDir = null;
-    this.errors = null;
-  }
-
-  public String getAiravataInternalUserId() {
-    return this.airavataInternalUserId;
-  }
-
-  public void setAiravataInternalUserId(String airavataInternalUserId) {
-    this.airavataInternalUserId = airavataInternalUserId;
-  }
-
-  public void unsetAiravataInternalUserId() {
-    this.airavataInternalUserId = null;
-  }
-
-  /** Returns true if field airavataInternalUserId is set (has been assigned a value) and false otherwise */
-  public boolean isSetAiravataInternalUserId() {
-    return this.airavataInternalUserId != null;
-  }
-
-  public void setAiravataInternalUserIdIsSet(boolean value) {
-    if (!value) {
-      this.airavataInternalUserId = null;
-    }
-  }
-
-  public String getExperimentId() {
-    return this.experimentId;
-  }
-
-  public void setExperimentId(String experimentId) {
-    this.experimentId = experimentId;
-  }
-
-  public void unsetExperimentId() {
-    this.experimentId = null;
-  }
-
-  /** Returns true if field experimentId is set (has been assigned a value) and false otherwise */
-  public boolean isSetExperimentId() {
-    return this.experimentId != null;
-  }
-
-  public void setExperimentIdIsSet(boolean value) {
-    if (!value) {
-      this.experimentId = null;
-    }
-  }
-
-  public String getName() {
-    return this.name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public void unsetName() {
-    this.name = null;
-  }
-
-  /** Returns true if field name is set (has been assigned a value) and false otherwise */
-  public boolean isSetName() {
-    return this.name != null;
-  }
-
-  public void setNameIsSet(boolean value) {
-    if (!value) {
-      this.name = null;
-    }
-  }
-
-  public String getDescription() {
-    return this.description;
-  }
-
-  public void setDescription(String description) {
-    this.description = description;
-  }
-
-  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 String getProject() {
-    return this.project;
-  }
-
-  public void setProject(String project) {
-    this.project = project;
-  }
-
-  public void unsetProject() {
-    this.project = null;
-  }
-
-  /** Returns true if field project is set (has been assigned a value) and false otherwise */
-  public boolean isSetProject() {
-    return this.project != null;
-  }
-
-  public void setProjectIsSet(boolean value) {
-    if (!value) {
-      this.project = null;
-    }
-  }
-
-  public String getOwner() {
-    return this.owner;
-  }
-
-  public void setOwner(String owner) {
-    this.owner = owner;
-  }
-
-  public void unsetOwner() {
-    this.owner = null;
-  }
-
-  /** Returns true if field owner is set (has been assigned a value) and false otherwise */
-  public boolean isSetOwner() {
-    return this.owner != null;
-  }
-
-  public void setOwnerIsSet(boolean value) {
-    if (!value) {
-      this.owner = null;
-    }
-  }
-
-  public String getApplication() {
-    return this.application;
-  }
-
-  public void setApplication(String application) {
-    this.application = application;
-  }
-
-  public void unsetApplication() {
-    this.application = null;
-  }
-
-  /** Returns true if field application is set (has been assigned a value) and false otherwise */
-  public boolean isSetApplication() {
-    return this.application != null;
-  }
-
-  public void setApplicationIsSet(boolean value) {
-    if (!value) {
-      this.application = null;
-    }
-  }
-
-  public String getComputeResource() {
-    return this.computeResource;
-  }
-
-  public void setComputeResource(String computeResource) {
-    this.computeResource = computeResource;
-  }
-
-  public void unsetComputeResource() {
-    this.computeResource = null;
-  }
-
-  /** Returns true if field computeResource is set (has been assigned a value) and false otherwise */
-  public boolean isSetComputeResource() {
-    return this.computeResource != null;
-  }
-
-  public void setComputeResourceIsSet(boolean value) {
-    if (!value) {
-      this.computeResource = null;
-    }
-  }
-
-  public String getJobName() {
-    return this.jobName;
-  }
-
-  public void setJobName(String jobName) {
-    this.jobName = jobName;
-  }
-
-  public void unsetJobName() {
-    this.jobName = null;
-  }
-
-  /** Returns true if field jobName is set (has been assigned a value) and false otherwise */
-  public boolean isSetJobName() {
-    return this.jobName != null;
-  }
-
-  public void setJobNameIsSet(boolean value) {
-    if (!value) {
-      this.jobName = null;
-    }
-  }
-
-  public String getJobId() {
-    return this.jobId;
-  }
-
-  public void setJobId(String jobId) {
-    this.jobId = jobId;
-  }
-
-  public void unsetJobId() {
-    this.jobId = null;
-  }
-
-  /** Returns true if field jobId is set (has been assigned a value) and false otherwise */
-  public boolean isSetJobId() {
-    return this.jobId != null;
-  }
-
-  public void setJobIdIsSet(boolean value) {
-    if (!value) {
-      this.jobId = null;
-    }
-  }
-
-  public String getJobStatus() {
-    return this.jobStatus;
-  }
-
-  public void setJobStatus(String jobStatus) {
-    this.jobStatus = jobStatus;
-  }
-
-  public void unsetJobStatus() {
-    this.jobStatus = null;
-  }
-
-  /** Returns true if field jobStatus is set (has been assigned a value) and false otherwise */
-  public boolean isSetJobStatus() {
-    return this.jobStatus != null;
-  }
-
-  public void setJobStatusIsSet(boolean value) {
-    if (!value) {
-      this.jobStatus = null;
-    }
-  }
-
-  public String getJobCreationTime() {
-    return this.jobCreationTime;
-  }
-
-  public void setJobCreationTime(String jobCreationTime) {
-    this.jobCreationTime = jobCreationTime;
-  }
-
-  public void unsetJobCreationTime() {
-    this.jobCreationTime = null;
-  }
-
-  /** Returns true if field jobCreationTime is set (has been assigned a value) and false otherwise */
-  public boolean isSetJobCreationTime() {
-    return this.jobCreationTime != null;
-  }
-
-  public void setJobCreationTimeIsSet(boolean value) {
-    if (!value) {
-      this.jobCreationTime = null;
-    }
-  }
-
-  public String getNotificationsTo() {
-    return this.notificationsTo;
-  }
-
-  public void setNotificationsTo(String notificationsTo) {
-    this.notificationsTo = notificationsTo;
-  }
-
-  public void unsetNotificationsTo() {
-    this.notificationsTo = null;
-  }
-
-  /** Returns true if field notificationsTo is set (has been assigned a value) and false otherwise */
-  public boolean isSetNotificationsTo() {
-    return this.notificationsTo != null;
-  }
-
-  public void setNotificationsToIsSet(boolean value) {
-    if (!value) {
-      this.notificationsTo = null;
-    }
-  }
-
-  public String getWorkingDir() {
-    return this.workingDir;
-  }
-
-  public void setWorkingDir(String workingDir) {
-    this.workingDir = workingDir;
-  }
-
-  public void unsetWorkingDir() {
-    this.workingDir = null;
-  }
-
-  /** Returns true if field workingDir is set (has been assigned a value) and false otherwise */
-  public boolean isSetWorkingDir() {
-    return this.workingDir != null;
-  }
-
-  public void setWorkingDirIsSet(boolean value) {
-    if (!value) {
-      this.workingDir = null;
-    }
-  }
-
-  public String getJobDescription() {
-    return this.jobDescription;
-  }
-
-  public void setJobDescription(String jobDescription) {
-    this.jobDescription = jobDescription;
-  }
-
-  public void unsetJobDescription() {
-    this.jobDescription = null;
-  }
-
-  /** Returns true if field jobDescription is set (has been assigned a value) and false otherwise */
-  public boolean isSetJobDescription() {
-    return this.jobDescription != null;
-  }
-
-  public void setJobDescriptionIsSet(boolean value) {
-    if (!value) {
-      this.jobDescription = null;
-    }
-  }
-
-  public String getCreationTime() {
-    return this.creationTime;
-  }
-
-  public void setCreationTime(String creationTime) {
-    this.creationTime = creationTime;
-  }
-
-  public void unsetCreationTime() {
-    this.creationTime = null;
-  }
-
-  /** Returns true if field creationTime is set (has been assigned a value) and false otherwise */
-  public boolean isSetCreationTime() {
-    return this.creationTime != null;
-  }
-
-  public void setCreationTimeIsSet(boolean value) {
-    if (!value) {
-      this.creationTime = null;
-    }
-  }
-
-  public String getLastModifiedTime() {
-    return this.lastModifiedTime;
-  }
-
-  public void setLastModifiedTime(String lastModifiedTime) {
-    this.lastModifiedTime = lastModifiedTime;
-  }
-
-  public void unsetLastModifiedTime() {
-    this.lastModifiedTime = null;
-  }
-
-  /** Returns true if field lastModifiedTime is set (has been assigned a value) and false otherwise */
-  public boolean isSetLastModifiedTime() {
-    return this.lastModifiedTime != null;
-  }
-
-  public void setLastModifiedTimeIsSet(boolean value) {
-    if (!value) {
-      this.lastModifiedTime = null;
-    }
-  }
-
-  public String getWallTime() {
-    return this.wallTime;
-  }
-
-  public void setWallTime(String wallTime) {
-    this.wallTime = wallTime;
-  }
-
-  public void unsetWallTime() {
-    this.wallTime = null;
-  }
-
-  /** Returns true if field wallTime is set (has been assigned a value) and false otherwise */
-  public boolean isSetWallTime() {
-    return this.wallTime != null;
-  }
-
-  public void setWallTimeIsSet(boolean value) {
-    if (!value) {
-      this.wallTime = null;
-    }
-  }
-
-  public String getCpuCount() {
-    return this.cpuCount;
-  }
-
-  public void setCpuCount(String cpuCount) {
-    this.cpuCount = cpuCount;
-  }
-
-  public void unsetCpuCount() {
-    this.cpuCount = null;
-  }
-
-  /** Returns true if field cpuCount is set (has been assigned a value) and false otherwise */
-  public boolean isSetCpuCount() {
-    return this.cpuCount != null;
-  }
-
-  public void setCpuCountIsSet(boolean value) {
-    if (!value) {
-      this.cpuCount = null;
-    }
-  }
-
-  public String getNodeCount() {
-    return this.nodeCount;
-  }
-
-  public void setNodeCount(String nodeCount) {
-    this.nodeCount = nodeCount;
-  }
-
-  public void unsetNodeCount() {
-    this.nodeCount = null;
-  }
-
-  /** Returns true if field nodeCount is set (has been assigned a value) and false otherwise */
-  public boolean isSetNodeCount() {
-    return this.nodeCount != null;
-  }
-
-  public void setNodeCountIsSet(boolean value) {
-    if (!value) {
-      this.nodeCount = null;
-    }
-  }
-
-  public String getQueue() {
-    return this.queue;
-  }
-
-  public void setQueue(String queue) {
-    this.queue = queue;
-  }
-
-  public void unsetQueue() {
-    this.queue = null;
-  }
-
-  /** Returns true if field queue is set (has been assigned a value) and false otherwise */
-  public boolean isSetQueue() {
-    return this.queue != null;
-  }
-
-  public void setQueueIsSet(boolean value) {
-    if (!value) {
-      this.queue = null;
-    }
-  }
-
-  public String getInputs() {
-    return this.inputs;
-  }
-
-  public void setInputs(String inputs) {
-    this.inputs = inputs;
-  }
-
-  public void unsetInputs() {
-    this.inputs = null;
-  }
-
-  /** Returns true if field inputs is set (has been assigned a value) and false otherwise */
-  public boolean isSetInputs() {
-    return this.inputs != null;
-  }
-
-  public void setInputsIsSet(boolean value) {
-    if (!value) {
-      this.inputs = null;
-    }
-  }
-
-  public String getOutputs() {
-    return this.outputs;
-  }
-
-  public void setOutputs(String outputs) {
-    this.outputs = outputs;
-  }
-
-  public void unsetOutputs() {
-    this.outputs = null;
-  }
-
-  /** Returns true if field outputs is set (has been assigned a value) and false otherwise */
-  public boolean isSetOutputs() {
-    return this.outputs != null;
-  }
-
-  public void setOutputsIsSet(boolean value) {
-    if (!value) {
-      this.outputs = null;
-    }
-  }
-
-  public String getStorageDir() {
-    return this.storageDir;
-  }
-
-  public void setStorageDir(String storageDir) {
-    this.storageDir = storageDir;
-  }
-
-  public void unsetStorageDir() {
-    this.storageDir = null;
-  }
-
-  /** Returns true if field storageDir is set (has been assigned a value) and false otherwise */
-  public boolean isSetStorageDir() {
-    return this.storageDir != null;
-  }
-
-  public void setStorageDirIsSet(boolean value) {
-    if (!value) {
-      this.storageDir = null;
-    }
-  }
-
-  public String getErrors() {
-    return this.errors;
-  }
-
-  public void setErrors(String errors) {
-    this.errors = errors;
-  }
-
-  public void unsetErrors() {
-    this.errors = null;
-  }
-
-  /** Returns true if field errors is set (has been assigned a value) and false otherwise */
-  public boolean isSetErrors() {
-    return this.errors != null;
-  }
-
-  public void setErrorsIsSet(boolean value) {
-    if (!value) {
-      this.errors = null;
-    }
-  }
-
-  public void setFieldValue(_Fields field, Object value) {
-    switch (field) {
-    case AIRAVATA_INTERNAL_USER_ID:
-      if (value == null) {
-        unsetAiravataInternalUserId();
-      } else {
-        setAiravataInternalUserId((String)value);
-      }
-      break;
-
-    case EXPERIMENT_ID:
-      if (value == null) {
-        unsetExperimentId();
-      } else {
-        setExperimentId((String)value);
-      }
-      break;
-
-    case NAME:
-      if (value == null) {
-        unsetName();
-      } else {
-        setName((String)value);
-      }
-      break;
-
-    case DESCRIPTION:
-      if (value == null) {
-        unsetDescription();
-      } else {
-        setDescription((String)value);
-      }
-      break;
-
-    case PROJECT:
-      if (value == null) {
-        unsetProject();
-      } else {
-        setProject((String)value);
-      }
-      break;
-
-    case OWNER:
-      if (value == null) {
-        unsetOwner();
-      } else {
-        setOwner((String)value);
-      }
-      break;
-
-    case APPLICATION:
-      if (value == null) {
-        unsetApplication();
-      } else {
-        setApplication((String)value);
-      }
-      break;
-
-    case COMPUTE_RESOURCE:
-      if (value == null) {
-        unsetComputeResource();
-      } else {
-        setComputeResource((String)value);
-      }
-      break;
-
-    case JOB_NAME:
-      if (value == null) {
-        unsetJobName();
-      } else {
-        setJobName((String)value);
-      }
-      break;
-
-    case JOB_ID:
-      if (value == null) {
-        unsetJobId();
-      } else {
-        setJobId((String)value);
-      }
-      break;
-
-    case JOB_STATUS:
-      if (value == null) {
-        unsetJobStatus();
-      } else {
-        setJobStatus((String)value);
-      }
-      break;
-
-    case JOB_CREATION_TIME:
-      if (value == null) {
-        unsetJobCreationTime();
-      } else {
-        setJobCreationTime((String)value);
-      }
-      break;
-
-    case NOTIFICATIONS_TO:
-      if (value == null) {
-        unsetNotificationsTo();
-      } else {
-        setNotificationsTo((String)value);
-      }
-      break;
-
-    case WORKING_DIR:
-      if (value == null) {
-        unsetWorkingDir();
-      } else {
-        setWorkingDir((String)value);
-      }
-      break;
-
-    case JOB_DESCRIPTION:
-      if (value == null) {
-        unsetJobDescription();
-      } else {
-        setJobDescription((String)value);
-      }
-      break;
-
-    case CREATION_TIME:
-      if (value == null) {
-        unsetCreationTime();
-      } else {
-        setCreationTime((String)value);
-      }
-      break;
-
-    case LAST_MODIFIED_TIME:
-      if (value == null) {
-        unsetLastModifiedTime();
-      } else {
-        setLastModifiedTime((String)value);
-      }
-      break;
-
-    case WALL_TIME:
-      if (value == null) {
-        unsetWallTime();
-      } else {
-        setWallTime((String)value);
-      }
-      break;
-
-    case CPU_COUNT:
-      if (value == null) {
-        unsetCpuCount();
-      } else {
-        setCpuCount((String)value);
-      }
-      break;
-
-    case NODE_COUNT:
-      if (value == null) {
-        unsetNodeCount();
-      } else {
-        setNodeCount((String)value);
-      }
-      break;
-
-    case QUEUE:
-      if (value == null) {
-        unsetQueue();
-      } else {
-        setQueue((String)value);
-      }
-      break;
-
-    case INPUTS:
-      if (value == null) {
-        unsetInputs();
-      } else {
-        setInputs((String)value);
-      }
-      break;
-
-    case OUTPUTS:
-      if (value == null) {
-        unsetOutputs();
-      } else {
-        setOutputs((String)value);
-      }
-      break;
-
-    case STORAGE_DIR:
-      if (value == null) {
-        unsetStorageDir();
-      } else {
-        setStorageDir((String)value);
-      }
-      break;
-
-    case ERRORS:
-      if (value == null) {
-        unsetErrors();
-      } else {
-        setErrors((String)value);
-      }
-      break;
-
-    }
-  }
-
-  public Object getFieldValue(_Fields field) {
-    switch (field) {
-    case AIRAVATA_INTERNAL_USER_ID:
-      return getAiravataInternalUserId();
-
-    case EXPERIMENT_ID:
-      return getExperimentId();
-
-    case NAME:
-      return getName();
-
-    case DESCRIPTION:
-      return getDescription();
-
-    case PROJECT:
-      return getProject();
-
-    case OWNER:
-      return getOwner();
-
-    case APPLICATION:
-      return getApplication();
-
-    case COMPUTE_RESOURCE:
-      return getComputeResource();
-
-    case JOB_NAME:
-      return getJobName();
-
-    case JOB_ID:
-      return getJobId();
-
-    case JOB_STATUS:
-      return getJobStatus();
-
-    case JOB_CREATION_TIME:
-      return getJobCreationTime();
-
-    case NOTIFICATIONS_TO:
-      return getNotificationsTo();
-
-    case WORKING_DIR:
-      return getWorkingDir();
-
-    case JOB_DESCRIPTION:
-      return getJobDescription();
-
-    case CREATION_TIME:
-      return getCreationTime();
-
-    case LAST_MODIFIED_TIME:
-      return getLastModifiedTime();
-
-    case WALL_TIME:
-      return getWallTime();
-
-    case CPU_COUNT:
-      return getCpuCount();
-
-    case NODE_COUNT:
-      return getNodeCount();
-
-    case QUEUE:
-      return getQueue();
-
-    case INPUTS:
-      return getInputs();
-
-    case OUTPUTS:
-      return getOutputs();
-
-    case STORAGE_DIR:
-      return getStorageDir();
-
-    case ERRORS:
-      return getErrors();
-
-    }
-    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 AIRAVATA_INTERNAL_USER_ID:
-      return isSetAiravataInternalUserId();
-    case EXPERIMENT_ID:
-      return isSetExperimentId();
-    case NAME:
-      return isSetName();
-    case DESCRIPTION:
-      return isSetDescription();
-    case PROJECT:
-      return isSetProject();
-    case OWNER:
-      return isSetOwner();
-    case APPLICATION:
-      return isSetApplication();
-    case COMPUTE_RESOURCE:
-      return isSetComputeResource();
-    case JOB_NAME:
-      return isSetJobName();
-    case JOB_ID:
-      return isSetJobId();
-    case JOB_STATUS:
-      return isSetJobStatus();
-    case JOB_CREATION_TIME:
-      return isSetJobCreationTime();
-    case NOTIFICATIONS_TO:
-      return isSetNotificationsTo();
-    case WORKING_DIR:
-      return isSetWorkingDir();
-    case JOB_DESCRIPTION:
-      return isSetJobDescription();
-    case CREATION_TIME:
-      return isSetCreationTime();
-    case LAST_MODIFIED_TIME:
-      return isSetLastModifiedTime();
-    case WALL_TIME:
-      return isSetWallTime();
-    case CPU_COUNT:
-      return isSetCpuCount();
-    case NODE_COUNT:
-      return isSetNodeCount();
-    case QUEUE:
-      return isSetQueue();
-    case INPUTS:
-      return isSetInputs();
-    case OUTPUTS:
-      return isSetOutputs();
-    case STORAGE_DIR:
-      return isSetStorageDir();
-    case ERRORS:
-      return isSetErrors();
-    }
-    throw new IllegalStateException();
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof CustomDashboard)
-      return this.equals((CustomDashboard)that);
-    return false;
-  }
-
-  public boolean equals(CustomDashboard that) {
-    if (that == null)
-      return false;
-    if (this == that)
-      return true;
-
-    boolean this_present_airavataInternalUserId = true && this.isSetAiravataInternalUserId();
-    boolean that_present_airavataInternalUserId = true && that.isSetAiravataInternalUserId();
-    if (this_present_airavataInternalUserId || that_present_airavataInternalUserId) {
-      if (!(this_present_airavataInternalUserId && that_present_airavataInternalUserId))
-        return false;
-      if (!this.airavataInternalUserId.equals(that.airavataInternalUserId))
-        return false;
-    }
-
-    boolean this_present_experimentId = true && this.isSetExperimentId();
-    boolean that_present_experimentId = true && that.isSetExperimentId();
-    if (this_present_experimentId || that_present_experimentId) {
-      if (!(this_present_experimentId && that_present_experimentId))
-        return false;
-      if (!this.experimentId.equals(that.experimentId))
-        return false;
-    }
-
-    boolean this_present_name = true && this.isSetName();
-    boolean that_present_name = true && that.isSetName();
-    if (this_present_name || that_present_name) {
-      if (!(this_present_name && that_present_name))
-        return false;
-      if (!this.name.equals(that.name))
-        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_project = true && this.isSetProject();
-    boolean that_present_project = true && that.isSetProject();
-    if (this_present_project || that_present_project) {
-      if (!(this_present_project && that_present_project))
-        return false;
-      if (!this.project.equals(that.project))
-        return false;
-    }
-
-    boolean this_present_owner = true && this.isSetOwner();
-    boolean that_present_owner = true && that.isSetOwner();
-    if (this_present_owner || that_present_owner) {
-      if (!(this_present_owner && that_present_owner))
-        return false;
-      if (!this.owner.equals(that.owner))
-        return false;
-    }
-
-    boolean this_present_application = true && this.isSetApplication();
-    boolean that_present_application = true && that.isSetApplication();
-    if (this_present_application || that_present_application) {
-      if (!(this_present_application && that_present_application))
-        return false;
-      if (!this.application.equals(that.application))
-        return false;
-    }
-
-    boolean this_present_computeResource = true && this.isSetComputeResource();
-    boolean that_present_computeResource = true && that.isSetComputeResource();
-    if (this_present_computeResource || that_present_computeResource) {
-      if (!(this_present_computeResource && that_present_computeResource))
-        return false;
-      if (!this.computeResource.equals(that.computeResource))
-        return false;
-    }
-
-    boolean this_present_jobName = true && this.isSetJobName();
-    boolean that_present_jobName = true && that.isSetJobName();
-    if (this_present_jobName || that_present_jobName) {
-      if (!(this_present_jobName && that_present_jobName))
-        return false;
-      if (!this.jobName.equals(that.jobName))
-        return false;
-    }
-
-    boolean this_present_jobId = true && this.isSetJobId();
-    boolean that_present_jobId = true && that.isSetJobId();
-    if (this_present_jobId || that_present_jobId) {
-      if (!(this_present_jobId && that_present_jobId))
-        return false;
-      if (!this.jobId.equals(that.jobId))
-        return false;
-    }
-
-    boolean this_present_jobStatus = true && this.isSetJobStatus();
-    boolean that_present_jobStatus = true && that.isSetJobStatus();
-    if (this_present_jobStatus || that_present_jobStatus) {
-      if (!(this_present_jobStatus && that_present_jobStatus))
-        return false;
-      if (!this.jobStatus.equals(that.jobStatus))
-        return false;
-    }
-
-    boolean this_present_jobCreationTime = true && this.isSetJobCreationTime();
-    boolean that_present_jobCreationTime = true && that.isSetJobCreationTime();
-    if (this_present_jobCreationTime || that_present_jobCreationTime) {
-      if (!(this_present_jobCreationTime && that_present_jobCreationTime))
-        return false;
-      if (!this.jobCreationTime.equals(that.jobCreationTime))
-        return false;
-    }
-
-    boolean this_present_notificationsTo = true && this.isSetNotificationsTo();
-    boolean that_present_notificationsTo = true && that.isSetNotificationsTo();
-    if (this_present_notificationsTo || that_present_notificationsTo) {
-      if (!(this_present_notificationsTo && that_present_notificationsTo))
-        return false;
-      if (!this.notificationsTo.equals(that.notificationsTo))
-        return false;
-    }
-
-    boolean this_present_workingDir = true && this.isSetWorkingDir();
-    boolean that_present_workingDir = true && that.isSetWorkingDir();
-    if (this_present_workingDir || that_present_workingDir) {
-      if (!(this_present_workingDir && that_present_workingDir))
-        return false;
-      if (!this.workingDir.equals(that.workingDir))
-        return false;
-    }
-
-    boolean this_present_jobDescription = true && this.isSetJobDescription();
-    boolean that_present_jobDescription = true && that.isSetJobDescription();
-    if (this_present_jobDescription || that_present_jobDescription) {
-      if (!(this_present_jobDescription && that_present_jobDescription))
-        return false;
-      if (!this.jobDescription.equals(that.jobDescription))
-        return false;
-    }
-
-    boolean this_present_creationTime = true && this.isSetCreationTime();
-    boolean that_present_creationTime = true && that.isSetCreationTime();
-    if (this_present_creationTime || that_present_creationTime) {
-      if (!(this_present_creationTime && that_present_creationTime))
-        return false;
-      if (!this.creationTime.equals(that.creationTime))
-        return false;
-    }
-
-    boolean this_present_lastModifiedTime = true && this.isSetLastModifiedTime();
-    boolean that_present_lastModifiedTime = true && that.isSetLastModifiedTime();
-    if (this_present_lastModifiedTime || that_present_lastModifiedTime) {
-      if (!(this_present_lastModifiedTime && that_present_lastModifiedTime))
-        return false;
-      if (!this.lastModifiedTime.equals(that.lastModifiedTime))
-        return false;
-    }
-
-    boolean this_present_wallTime = true && this.isSetWallTime();
-    boolean that_present_wallTime = true && that.isSetWallTime();
-    if (this_present_wallTime || that_present_wallTime) {
-      if (!(this_present_wallTime && that_present_wallTime))
-        return false;
-      if (!this.wallTime.equals(that.wallTime))
-        return false;
-    }
-
-    boolean this_present_cpuCount = true && this.isSetCpuCount();
-    boolean that_present_cpuCount = true && that.isSetCpuCount();
-    if (this_present_cpuCount || that_present_cpuCount) {
-      if (!(this_present_cpuCount && that_present_cpuCount))
-        return false;
-      if (!this.cpuCount.equals(that.cpuCount))
-        return false;
-    }
-
-    boolean this_present_nodeCount = true && this.isSetNodeCount();
-    boolean that_present_nodeCount = true && that.isSetNodeCount();
-    if (this_present_nodeCount || that_present_nodeCount) {
-      if (!(this_present_nodeCount && that_present_nodeCount))
-        return false;
-      if (!this.nodeCount.equals(that.nodeCount))
-        return false;
-    }
-
-    boolean this_present_queue = true && this.isSetQueue();
-    boolean that_present_queue = true && that.isSetQueue();
-    if (this_present_queue || that_present_queue) {
-      if (!(this_present_queue && that_present_queue))
-        return false;
-      if (!this.queue.equals(that.queue))
-        return false;
-    }
-
-    boolean this_present_inputs = true && this.isSetInputs();
-    boolean that_present_inputs = true && that.isSetInputs();
-    if (this_present_inputs || that_present_inputs) {
-      if (!(this_present_inputs && that_present_inputs))
-        return false;
-      if (!this.inputs.equals(that.inputs))
-        return false;
-    }
-
-    boolean this_present_outputs = true && this.isSetOutputs();
-    boolean that_present_outputs = true && that.isSetOutputs();
-    if (this_present_outputs || that_present_outputs) {
-      if (!(this_present_outputs && that_present_outputs))
-        return false;
-      if (!this.outputs.equals(that.outputs))
-        return false;
-    }
-
-    boolean this_present_storageDir = true && this.isSetStorageDir();
-    boolean that_present_storageDir = true && that.isSetStorageDir();
-    if (this_present_storageDir || that_present_storageDir) {
-      if (!(this_present_storageDir && that_present_storageDir))
-        return false;
-      if (!this.storageDir.equals(that.storageDir))
-        return false;
-    }
-
-    boolean this_present_errors = true && this.isSetErrors();
-    boolean that_present_errors = true && that.isSetErrors();
-    if (this_present_errors || that_present_errors) {
-      if (!(this_present_errors && that_present_errors))
-        return false;
-      if (!this.errors.equals(that.errors))
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int hashCode = 1;
-
-    hashCode = hashCode * 8191 + ((isSetAiravataInternalUserId()) ? 131071 : 524287);
-    if (isSetAiravataInternalUserId())
-      hashCode = hashCode * 8191 + airavataInternalUserId.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetExperimentId()) ? 131071 : 524287);
-    if (isSetExperimentId())
-      hashCode = hashCode * 8191 + experimentId.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287);
-    if (isSetName())
-      hashCode = hashCode * 8191 + name.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetDescription()) ? 131071 : 524287);
-    if (isSetDescription())
-      hashCode = hashCode * 8191 + description.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetProject()) ? 131071 : 524287);
-    if (isSetProject())
-      hashCode = hashCode * 8191 + project.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetOwner()) ? 131071 : 524287);
-    if (isSetOwner())
-      hashCode = hashCode * 8191 + owner.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetApplication()) ? 131071 : 524287);
-    if (isSetApplication())
-      hashCode = hashCode * 8191 + application.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetComputeResource()) ? 131071 : 524287);
-    if (isSetComputeResource())
-      hashCode = hashCode * 8191 + computeResource.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetJobName()) ? 131071 : 524287);
-    if (isSetJobName())
-      hashCode = hashCode * 8191 + jobName.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetJobId()) ? 131071 : 524287);
-    if (isSetJobId())
-      hashCode = hashCode * 8191 + jobId.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetJobStatus()) ? 131071 : 524287);
-    if (isSetJobStatus())
-      hashCode = hashCode * 8191 + jobStatus.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetJobCreationTime()) ? 131071 : 524287);
-    if (isSetJobCreationTime())
-      hashCode = hashCode * 8191 + jobCreationTime.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetNotificationsTo()) ? 131071 : 524287);
-    if (isSetNotificationsTo())
-      hashCode = hashCode * 8191 + notificationsTo.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetWorkingDir()) ? 131071 : 524287);
-    if (isSetWorkingDir())
-      hashCode = hashCode * 8191 + workingDir.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetJobDescription()) ? 131071 : 524287);
-    if (isSetJobDescription())
-      hashCode = hashCode * 8191 + jobDescription.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetCreationTime()) ? 131071 : 524287);
-    if (isSetCreationTime())
-      hashCode = hashCode * 8191 + creationTime.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetLastModifiedTime()) ? 131071 : 524287);
-    if (isSetLastModifiedTime())
-      hashCode = hashCode * 8191 + lastModifiedTime.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetWallTime()) ? 131071 : 524287);
-    if (isSetWallTime())
-      hashCode = hashCode * 8191 + wallTime.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetCpuCount()) ? 131071 : 524287);
-    if (isSetCpuCount())
-      hashCode = hashCode * 8191 + cpuCount.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetNodeCount()) ? 131071 : 524287);
-    if (isSetNodeCount())
-      hashCode = hashCode * 8191 + nodeCount.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetQueue()) ? 131071 : 524287);
-    if (isSetQueue())
-      hashCode = hashCode * 8191 + queue.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetInputs()) ? 131071 : 524287);
-    if (isSetInputs())
-      hashCode = hashCode * 8191 + inputs.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetOutputs()) ? 131071 : 524287);
-    if (isSetOutputs())
-      hashCode = hashCode * 8191 + outputs.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetStorageDir()) ? 131071 : 524287);
-    if (isSetStorageDir())
-      hashCode = hashCode * 8191 + storageDir.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetErrors()) ? 131071 : 524287);
-    if (isSetErrors())
-      hashCode = hashCode * 8191 + errors.hashCode();
-
-    return hashCode;
-  }
-
-  @Override
-  public int compareTo(CustomDashboard other) {
-    if (!getClass().equals(other.getClass())) {
-      return getClass().getName().compareTo(other.getClass().getName());
-    }
-
-    int lastComparison = 0;
-
-    lastComparison = Boolean.valueOf(isSetAiravataInternalUserId()).compareTo(other.isSetAiravataInternalUserId());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetAiravataInternalUserId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.airavataInternalUserId, other.airavataInternalUserId);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetExperimentId()).compareTo(other.isSetExperimentId());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetExperimentId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.experimentId, other.experimentId);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetName()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name);
-      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;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetProject()).compareTo(other.isSetProject());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetProject()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.project, other.project);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetOwner()).compareTo(other.isSetOwner());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetOwner()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.owner, other.owner);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetApplication()).compareTo(other.isSetApplication());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetApplication()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.application, other.application);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetComputeResource()).compareTo(other.isSetComputeResource());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetComputeResource()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.computeResource, other.computeResource);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetJobName()).compareTo(other.isSetJobName());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetJobName()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jobName, other.jobName);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetJobId()).compareTo(other.isSetJobId());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetJobId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jobId, other.jobId);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetJobStatus()).compareTo(other.isSetJobStatus());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetJobStatus()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jobStatus, other.jobStatus);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetJobCreationTime()).compareTo(other.isSetJobCreationTime());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetJobCreationTime()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jobCreationTime, other.jobCreationTime);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetNotificationsTo()).compareTo(other.isSetNotificationsTo());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetNotificationsTo()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.notificationsTo, other.notificationsTo);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetWorkingDir()).compareTo(other.isSetWorkingDir());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetWorkingDir()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.workingDir, other.workingDir);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetJobDescription()).compareTo(other.isSetJobDescription());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetJobDescription()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jobDescription, other.jobDescription);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetCreationTime()).compareTo(other.isSetCreationTime());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetCreationTime()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.creationTime, other.creationTime);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetLastModifiedTime()).compareTo(other.isSetLastModifiedTime());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetLastModifiedTime()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.lastModifiedTime, other.lastModifiedTime);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetWallTime()).compareTo(other.isSetWallTime());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetWallTime()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.wallTime, other.wallTime);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetCpuCount()).compareTo(other.isSetCpuCount());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetCpuCount()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cpuCount, other.cpuCount);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetNodeCount()).compareTo(other.isSetNodeCount());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetNodeCount()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nodeCount, other.nodeCount);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetQueue()).compareTo(other.isSetQueue());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetQueue()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queue, other.queue);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetInputs()).compareTo(other.isSetInputs());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetInputs()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.inputs, other.inputs);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetOutputs()).compareTo(other.isSetOutputs());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetOutputs()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.outputs, other.outputs);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetStorageDir()).compareTo(other.isSetStorageDir());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetStorageDir()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.storageDir, other.storageDir);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetErrors()).compareTo(other.isSetErrors());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetErrors()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.errors, other.errors);
-      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 {
-    scheme(iprot).read(iprot, this);
-  }
-
-  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-    scheme(oprot).write(oprot, this);
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("CustomDashboard(");
-    boolean first = true;
-
-    sb.append("airavataInternalUserId:");
-    if (this.airavataInternalUserId == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.airavataInternalUserId);
-    }
-    first = false;
-    if (isSetExperimentId()) {
-      if (!first) sb.append(", ");
-      sb.append("experimentId:");
-      if (this.experimentId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.experimentId);
-      }
-      first = false;
-    }
-    if (isSetName()) {
-      if (!first) sb.append(", ");
-      sb.append("name:");
-      if (this.name == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.name);
-      }
-      first = false;
-    }
-    if (isSetDescription()) {
-      if (!first) sb.append(", ");
-      sb.append("description:");
-      if (this.description == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.description);
-      }
-      first = false;
-    }
-    if (isSetProject()) {
-      if (!first) sb.append(", ");
-      sb.append("project:");
-      if (this.project == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.project);
-      }
-      first = false;
-    }
-    if (isSetOwner()) {
-      if (!first) sb.append(", ");
-      sb.append("owner:");
-      if (this.owner == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.owner);
-      }
-      first = false;
-    }
-    if (isSetApplication()) {
-      if (!first) sb.append(", ");
-      sb.append("application:");
-      if (this.application == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.application);
-      }
-      first = false;
-    }
-    if (isSetComputeResource()) {
-      if (!first) sb.append(", ");
-      sb.append("computeResource:");
-      if (this.computeResource == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.computeResource);
-      }
-      first = false;
-    }
-    if (isSetJobName()) {
-      if (!first) sb.append(", ");
-      sb.append("jobName:");
-      if (this.jobName == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.jobName);
-      }
-      first = false;
-    }
-    if (isSetJobId()) {
-      if (!first) sb.append(", ");
-      sb.append("jobId:");
-      if (this.jobId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.jobId);
-      }
-      first = false;
-    }
-    if (isSetJobStatus()) {
-      if (!first) sb.append(", ");
-      sb.append("jobStatus:");
-      if (this.jobStatus == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.jobStatus);
-      }
-      first = false;
-    }
-    if (isSetJobCreationTime()) {
-      if (!first) sb.append(", ");
-      sb.append("jobCreationTime:");
-      if (this.jobCreationTime == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.jobCreationTime);
-      }
-      first = false;
-    }
-    if (isSetNotificationsTo()) {
-      if (!first) sb.append(", ");
-      sb.append("notificationsTo:");
-      if (this.notificationsTo == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.notificationsTo);
-      }
-      first = false;
-    }
-    if (isSetWorkingDir()) {
-      if (!first) sb.append(", ");
-      sb.append("workingDir:");
-      if (this.workingDir == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.workingDir);
-      }
-      first = false;
-    }
-    if (isSetJobDescription()) {
-      if (!first) sb.append(", ");
-      sb.append("jobDescription:");
-      if (this.jobDescription == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.jobDescription);
-      }
-      first = false;
-    }
-    if (isSetCreationTime()) {
-      if (!first) sb.append(", ");
-      sb.append("creationTime:");
-      if (this.creationTime == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.creationTime);
-      }
-      first = false;
-    }
-    if (isSetLastModifiedTime()) {
-      if (!first) sb.append(", ");
-      sb.append("lastModifiedTime:");
-      if (this.lastModifiedTime == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.lastModifiedTime);
-      }
-      first = false;
-    }
-    if (isSetWallTime()) {
-      if (!first) sb.append(", ");
-      sb.append("wallTime:");
-      if (this.wallTime == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.wallTime);
-      }
-      first = false;
-    }
-    if (isSetCpuCount()) {
-      if (!first) sb.append(", ");
-      sb.append("cpuCount:");
-      if (this.cpuCount == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.cpuCount);
-      }
-      first = false;
-    }
-    if (isSetNodeCount()) {
-      if (!first) sb.append(", ");
-      sb.append("nodeCount:");
-      if (this.nodeCount == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.nodeCount);
-      }
-      first = false;
-    }
-    if (isSetQueue()) {
-      if (!first) sb.append(", ");
-      sb.append("queue:");
-      if (this.queue == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.queue);
-      }
-      first = false;
-    }
-    if (isSetInputs()) {
-      if (!first) sb.append(", ");
-      sb.append("inputs:");
-      if (this.inputs == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.inputs);
-      }
-      first = false;
-    }
-    if (isSetOutputs()) {
-      if (!first) sb.append(", ");
-      sb.append("outputs:");
-      if (this.outputs == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.outputs);
-      }
-      first = false;
-    }
-    if (isSetStorageDir()) {
-      if (!first) sb.append(", ");
-      sb.append("storageDir:");
-      if (this.storageDir == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.storageDir);
-      }
-      first = false;
-    }
-    if (isSetErrors()) {
-      if (!first) sb.append(", ");
-      sb.append("errors:");
-      if (this.errors == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.errors);
-      }
-      first = false;
-    }
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public void validate() throws org.apache.thrift.TException {
-    // check for required fields
-    if (!isSetAiravataInternalUserId()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'airavataInternalUserId' is unset! Struct:" + toString());
-    }
-
-    // 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 CustomDashboardStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public CustomDashboardStandardScheme getScheme() {
-      return new CustomDashboardStandardScheme();
-    }
-  }
-
-  private static class CustomDashboardStandardScheme extends org.apache.thrift.scheme.StandardScheme<CustomDashboard> {
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot, CustomDashboard 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: // AIRAVATA_INTERNAL_USER_ID
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.airavataInternalUserId = iprot.readString();
-              struct.setAiravataInternalUserIdIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 2: // EXPERIMENT_ID
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.experimentId = iprot.readString();
-              struct.setExperimentIdIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 3: // NAME
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.name = iprot.readString();
-              struct.setNameIsSet(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;
-          case 5: // PROJECT
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.project = iprot.readString();
-              struct.setProjectIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 6: // OWNER
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.owner = iprot.readString();
-              struct.setOwnerIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 7: // APPLICATION
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.application = iprot.readString();
-              struct.setApplicationIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 8: // COMPUTE_RESOURCE
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.computeResource = iprot.readString();
-              struct.setComputeResourceIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 9: // JOB_NAME
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.jobName = iprot.readString();
-              struct.setJobNameIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 10: // JOB_ID
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.jobId = iprot.readString();
-              struct.setJobIdIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 11: // JOB_STATUS
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.jobStatus = iprot.readString();
-              struct.setJobStatusIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 12: // JOB_CREATION_TIME
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.jobCreationTime = iprot.readString();
-              struct.setJobCreationTimeIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 13: // NOTIFICATIONS_TO
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.notificationsTo = iprot.readString();
-              struct.setNotificationsToIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 14: // WORKING_DIR
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.workingDir = iprot.readString();
-              struct.setWorkingDirIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 15: // JOB_DESCRIPTION
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.jobDescription = iprot.readString();
-              struct.setJobDescriptionIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 16: // CREATION_TIME
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.creationTime = iprot.readString();
-              struct.setCreationTimeIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 17: // LAST_MODIFIED_TIME
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.lastModifiedTime = iprot.readString();
-              struct.setLastModifiedTimeIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 18: // WALL_TIME
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.wallTime = iprot.readString();
-              struct.setWallTimeIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 19: // CPU_COUNT
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.cpuCount = iprot.readString();
-              struct.setCpuCountIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 20: // NODE_COUNT
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.nodeCount = iprot.readString();
-              struct.setNodeCountIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 21: // QUEUE
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.queue = iprot.readString();
-              struct.setQueueIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 22: // INPUTS
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.inputs = iprot.readString();
-              struct.setInputsIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 23: // OUTPUTS
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.outputs = iprot.readString();
-              struct.setOutputsIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 24: // STORAGE_DIR
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.storageDir = iprot.readString();
-              struct.setStorageDirIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 25: // ERRORS
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.errors = iprot.readString();
-              struct.setErrorsIsSet(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();
-      struct.validate();
-    }
-
-    public void write(org.apache.thrift.protocol.TProtocol oprot, CustomDashboard struct) throws org.apache.thrift.TException {
-      struct.validate();
-
-      oprot.writeStructBegin(STRUCT_DESC);
-      if (struct.airavataInternalUserId != null) {
-        oprot.writeFieldBegin(AIRAVATA_INTERNAL_USER_ID_FIELD_DESC);
-        oprot.writeString(struct.airavataInternalUserId);
-        oprot.writeFieldEnd();
-      }
-      if (struct.experimentId != null) {
-        if (struct.isSetExperimentId()) {
-          oprot.writeFieldBegin(EXPERIMENT_ID_FIELD_DESC);
-          oprot.writeString(struct.experimentId);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.name != null) {
-        if (struct.isSetName()) {
-          oprot.writeFieldBegin(NAME_FIELD_DESC);
-          oprot.writeString(struct.name);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.description != null) {
-        if (struct.isSetDescription()) {
-          oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC);
-          oprot.writeString(struct.description);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.project != null) {
-        if (struct.isSetProject()) {
-          oprot.writeFieldBegin(PROJECT_FIELD_DESC);
-          oprot.writeString(struct.project);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.owner != null) {
-        if (struct.isSetOwner()) {
-          oprot.writeFieldBegin(OWNER_FIELD_DESC);
-          oprot.writeString(struct.owner);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.application != null) {
-        if (struct.isSetApplication()) {
-          oprot.writeFieldBegin(APPLICATION_FIELD_DESC);
-          oprot.writeString(struct.application);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.computeResource != null) {
-        if (struct.isSetComputeResource()) {
-          oprot.writeFieldBegin(COMPUTE_RESOURCE_FIELD_DESC);
-          oprot.writeString(struct.computeResource);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.jobName != null) {
-        if (struct.isSetJobName()) {
-          oprot.writeFieldBegin(JOB_NAME_FIELD_DESC);
-          oprot.writeString(struct.jobName);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.jobId != null) {
-        if (struct.isSetJobId()) {
-          oprot.writeFieldBegin(JOB_ID_FIELD_DESC);
-          oprot.writeString(struct.jobId);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.jobStatus != null) {
-        if (struct.isSetJobStatus()) {
-          oprot.writeFieldBegin(JOB_STATUS_FIELD_DESC);
-          oprot.writeString(struct.jobStatus);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.jobCreationTime != null) {
-        if (struct.isSetJobCreationTime()) {
-          oprot.writeFieldBegin(JOB_CREATION_TIME_FIELD_DESC);
-          oprot.writeString(struct.jobCreationTime);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.notificationsTo != null) {
-        if (struct.isSetNotificationsTo()) {
-          oprot.writeFieldBegin(NOTIFICATIONS_TO_FIELD_DESC);
-          oprot.writeString(struct.notificationsTo);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.workingDir != null) {
-        if (struct.isSetWorkingDir()) {
-          oprot.writeFieldBegin(WORKING_DIR_FIELD_DESC);
-          oprot.writeString(struct.workingDir);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.jobDescription != null) {
-        if (struct.isSetJobDescription()) {
-          oprot.writeFieldBegin(JOB_DESCRIPTION_FIELD_DESC);
-          oprot.writeString(struct.jobDescription);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.creationTime != null) {
-        if (struct.isSetCreationTime()) {
-          oprot.writeFieldBegin(CREATION_TIME_FIELD_DESC);
-          oprot.writeString(struct.creationTime);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.lastModifiedTime != null) {
-        if (struct.isSetLastModifiedTime()) {
-          oprot.writeFieldBegin(LAST_MODIFIED_TIME_FIELD_DESC);
-          oprot.writeString(struct.lastModifiedTime);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.wallTime != null) {
-        if (struct.isSetWallTime()) {
-          oprot.writeFieldBegin(WALL_TIME_FIELD_DESC);
-          oprot.writeString(struct.wallTime);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.cpuCount != null) {
-        if (struct.isSetCpuCount()) {
-          oprot.writeFieldBegin(CPU_COUNT_FIELD_DESC);
-          oprot.writeString(struct.cpuCount);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.nodeCount != null) {
-        if (struct.isSetNodeCount()) {
-          oprot.writeFieldBegin(NODE_COUNT_FIELD_DESC);
-          oprot.writeString(struct.nodeCount);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.queue != null) {
-        if (struct.isSetQueue()) {
-          oprot.writeFieldBegin(QUEUE_FIELD_DESC);
-          oprot.writeString(struct.queue);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.inputs != null) {
-        if (struct.isSetInputs()) {
-          oprot.writeFieldBegin(INPUTS_FIELD_DESC);
-          oprot.writeString(struct.inputs);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.outputs != null) {
-        if (struct.isSetOutputs()) {
-          oprot.writeFieldBegin(OUTPUTS_FIELD_DESC);
-          oprot.writeString(struct.outputs);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.storageDir != null) {
-        if (struct.isSetStorageDir()) {
-          oprot.writeFieldBegin(STORAGE_DIR_FIELD_DESC);
-          oprot.writeString(struct.storageDir);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.errors != null) {
-        if (struct.isSetErrors()) {
-          oprot.writeFieldBegin(ERRORS_FIELD_DESC);
-          oprot.writeString(struct.errors);
-          oprot.writeFieldEnd();
-        }
-      }
-      oprot.writeFieldStop();
-      oprot.writeStructEnd();
-    }
-
-  }
-
-  private static class CustomDashboardTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public CustomDashboardTupleScheme getScheme() {
-      return new CustomDashboardTupleScheme();
-    }
-  }
-
-  private static class CustomDashboardTupleScheme extends org.apache.thrift.scheme.TupleScheme<CustomDashboard> {
-
-    @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, CustomDashboard struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      oprot.writeString(struct.airavataInternalUserId);
-      java.util.BitSet optionals = new java.util.BitSet();
-      if (struct.isSetExperimentId()) {
-        optionals.set(0);
-      }
-      if (struct.isSetName()) {
-        optionals.set(1);
-      }
-      if (struct.isSetDescription()) {
-        optionals.set(2);
-      }
-      if (struct.isSetProject()) {
-        optionals.set(3);
-      }
-      if (struct.isSetOwner()) {
-        optionals.set(4);
-      }
-      if (struct.isSetApplication()) {
-        optionals.set(5);
-      }
-      if (struct.isSetComputeResource()) {
-        optionals.set(6);
-      }
-      if (struct.isSetJobName()) {
-        optionals.set(7);
-      }
-      if (struct.isSetJobId()) {
-        optionals.set(8);
-      }
-      if (struct.isSetJobStatus()) {
-        optionals.set(9);
-      }
-      if (struct.isSetJobCreationTime()) {
-        optionals.set(10);
-      }
-      if (struct.isSetNotificationsTo()) {
-        optionals.set(11);
-      }
-      if (struct.isSetWorkingDir()) {
-        optionals.set(12);
-      }
-      if (struct.isSetJobDescription()) {
-        optionals.set(13);
-      }
-      if (struct.isSetCreationTime()) {
-        optionals.set(14);
-      }
-      if (struct.isSetLastModifiedTime()) {
-        optionals.set(15);
-      }
-      if (struct.isSetWallTime()) {
-        optionals.set(16);
-      }
-      if (struct.isSetCpuCount()) {
-        optionals.set(17);
-      }
-      if (struct.isSetNodeCount()) {
-        optionals.set(18);
-      }
-      if (struct.isSetQueue()) {
-        optionals.set(19);
-      }
-      if (struct.isSetInputs()) {
-        optionals.set(20);
-      }
-      if (struct.isSetOutputs()) {
-        optionals.set(21);
-      }
-      if (struct.isSetStorageDir()) {
-        optionals.set(22);
-      }
-      if (struct.isSetErrors()) {
-        optionals.set(23);
-      }
-      oprot.writeBitSet(optionals, 24);
-      if (struct.isSetExperimentId()) {
-        oprot.writeString(struct.experimentId);
-      }
-      if (struct.isSetName()) {
-        oprot.writeString(struct.name);
-      }
-      if (struct.isSetDescription()) {
-        oprot.writeString(struct.description);
-      }
-      if (struct.isSetProject()) {
-        oprot.writeString(struct.project);
-      }
-      if (struct.isSetOwner()) {
-        oprot.writeString(struct.owner);
-      }
-      if (struct.isSetApplication()) {
-        oprot.writeString(struct.application);
-      }
-      if (struct.isSetComputeResource()) {
-        oprot.writeString(struct.computeResource);
-      }
-      if (struct.isSetJobName()) {
-        oprot.writeString(struct.jobName);
-      }
-      if (struct.isSetJobId()) {
-        oprot.writeString(struct.jobId);
-      }
-      if (struct.isSetJobStatus()) {
-        oprot.writeString(struct.jobStatus);
-      }
-      if (struct.isSetJobCreationTime()) {
-        oprot.writeString(struct.jobCreationTime);
-      }
-      if (struct.isSetNotificationsTo()) {
-        oprot.writeString(struct.notificationsTo);
-      }
-      if (struct.isSetWorkingDir()) {
-        oprot.writeString(struct.workingDir);
-      }
-      if (struct.isSetJobDescription()) {
-        oprot.writeString(struct.jobDescription);
-      }
-      if (struct.isSetCreationTime()) {
-        oprot.writeString(struct.creationTime);
-      }
-      if (struct.isSetLastModifiedTime()) {
-        oprot.writeString(struct.lastModifiedTime);
-      }
-      if (struct.isSetWallTime()) {
-        oprot.writeString(struct.wallTime);
-      }
-      if (struct.isSetCpuCount()) {
-        oprot.writeString(struct.cpuCount);
-      }
-      if (struct.isSetNodeCount()) {
-        oprot.writeString(struct.nodeCount);
-      }
-      if (struct.isSetQueue()) {
-        oprot.writeString(struct.queue);
-      }
-      if (struct.isSetInputs()) {
-        oprot.writeString(struct.inputs);
-      }
-      if (struct.isSetOutputs()) {
-        oprot.writeString(struct.outputs);
-      }
-      if (struct.isSetStorageDir()) {
-        oprot.writeString(struct.storageDir);
-      }
-      if (struct.isSetErrors()) {
-        oprot.writeString(struct.errors);
-      }
-    }
-
-    @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, CustomDashboard struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      struct.airavataInternalUserId = iprot.readString();
-      struct.setAiravataInternalUserIdIsSet(true);
-      java.util.BitSet incoming = iprot.readBitSet(24);
-      if (incoming.get(0)) {
-        struct.experimentId = iprot.readString();
-        struct.setExperimentIdIsSet(true);
-      }
-      if (incoming.get(1)) {
-        struct.name = iprot.readString();
-        struct.setNameIsSet(true);
-      }
-      if (incoming.get(2)) {
-        struct.description = iprot.readString();
-        struct.setDescriptionIsSet(true);
-      }
-      if (incoming.get(3)) {
-        struct.project = iprot.readString();
-        struct.setProjectIsSet(true);
-      }
-      if (incoming.get(4)) {
-        struct.owner = iprot.readString();
-        struct.setOwnerIsSet(true);
-      }
-      if (incoming.get(5)) {
-        struct.application = iprot.readString();
-        struct.setApplicationIsSet(true);
-      }
-      if (incoming.get(6)) {
-        struct.computeResource = iprot.readString();
-        struct.setComputeResourceIsSet(true);
-      }
-      if (incoming.get(7)) {
-        struct.jobName = iprot.readString();
-        struct.setJobNameIsSet(true);
-      }
-      if (incoming.get(8)) {
-        struct.jobId = iprot.readString();
-        struct.setJobIdIsSet(true);
-      }
-      if (incoming.get(9)) {
-        struct.jobStatus = iprot.readString();
-        struct.setJobStatusIsSet(true);
-      }
-      if (incoming.get(10)) {
-        struct.jobCreationTime = iprot.readString();
-        struct.setJobCreationTimeIsSet(true);
-      }
-      if (incoming.get(11)) {
-        struct.notificationsTo = iprot.readString();
-        struct.setNotificationsToIsSet(true);
-      }
-      if (incoming.get(12)) {
-        struct.workingDir = iprot.readString();
-        struct.setWorkingDirIsSet(true);
-      }
-      if (incoming.get(13)) {
-        struct.jobDescription = iprot.readString();
-        struct.setJobDescriptionIsSet(true);
-      }
-      if (incoming.get(14)) {
-        struct.creationTime = iprot.readString();
-        struct.setCreationTimeIsSet(true);
-      }
-      if (incoming.get(15)) {
-        struct.lastModifiedTime = iprot.readString();
-        struct.setLastModifiedTimeIsSet(true);
-      }
-      if (incoming.get(16)) {
-        struct.wallTime = iprot.readString();
-        struct.setWallTimeIsSet(true);
-      }
-      if (incoming.get(17)) {
-        struct.cpuCount = iprot.readString();
-        struct.setCpuCountIsSet(true);
-      }
-      if (incoming.get(18)) {
-        struct.nodeCount = iprot.readString();
-        struct.setNodeCountIsSet(true);
-      }
-      if (incoming.get(19)) {
-        struct.queue = iprot.readString();
-        struct.setQueueIsSet(true);
-      }
-      if (incoming.get(20)) {
-        struct.inputs = iprot.readString();
-        struct.setInputsIsSet(true);
-      }
-      if (incoming.get(21)) {
-        struct.outputs = iprot.readString();
-        struct.setOutputsIsSet(true);
-      }
-      if (incoming.get(22)) {
-        struct.storageDir = iprot.readString();
-        struct.setStorageDirIsSet(true);
-      }
-      if (incoming.get(23)) {
-        struct.errors = iprot.readString();
-        struct.setErrorsIsSet(true);
-      }
-    }
-  }
-
-  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-  }
-}
-
diff --git a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/NSFDemographics.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/NSFDemographics.java
index d24f6e5..351a1c5 100644
--- a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/NSFDemographics.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/NSFDemographics.java
@@ -1,22 +1,5 @@
 /**
- * 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.10.0)
+ * Autogenerated by Thrift Compiler (0.12.0)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -29,7 +12,7 @@ package org.apache.custos.profile.model.user;
  * 
  * 
  */
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-12")
 public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics, NSFDemographics._Fields>, java.io.Serializable, Cloneable, Comparable<NSFDemographics> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("NSFDemographics");
 
@@ -43,19 +26,23 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
   private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new NSFDemographicsStandardSchemeFactory();
   private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new NSFDemographicsTupleSchemeFactory();
 
-  private String custosInternalUserId; // required
-  private String gender; // optional
-  private USCitizenship usCitizenship; // optional
-  private java.util.List<ethnicity> ethnicities; // optional
-  private java.util.List<race> races; // optional
-  private java.util.List<disability> disabilities; // optional
+  public @org.apache.thrift.annotation.Nullable String custosInternalUserId; // required
+  public @org.apache.thrift.annotation.Nullable String gender; // optional
+  /**
+   * 
+   * @see USCitizenship
+   */
+  public @org.apache.thrift.annotation.Nullable USCitizenship usCitizenship; // optional
+  public @org.apache.thrift.annotation.Nullable java.util.List<ethnicity> ethnicities; // optional
+  public @org.apache.thrift.annotation.Nullable java.util.List<race> races; // optional
+  public @org.apache.thrift.annotation.Nullable java.util.List<disability> disabilities; // optional
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
     CUSTOS_INTERNAL_USER_ID((short)1, "custosInternalUserId"),
     GENDER((short)2, "gender"),
     /**
-     *
+     * 
      * @see USCitizenship
      */
     US_CITIZENSHIP((short)3, "usCitizenship"),
@@ -74,6 +61,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     /**
      * Find the _Fields constant that matches fieldId, or null if its not found.
      */
+    @org.apache.thrift.annotation.Nullable
     public static _Fields findByThriftId(int fieldId) {
       switch(fieldId) {
         case 1: // CUSTOS_INTERNAL_USER_ID
@@ -106,6 +94,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     /**
      * Find the _Fields constant that matches name, or null if its not found.
      */
+    @org.apache.thrift.annotation.Nullable
     public static _Fields findByName(String name) {
       return byName.get(name);
     }
@@ -128,24 +117,24 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
   }
 
   // isset id assignments
-  private static final _Fields optionals[] = {_Fields.GENDER, _Fields.US_CITIZENSHIP, _Fields.ETHNICITIES, _Fields.RACES, _Fields.DISABILITIES};
+  private static final _Fields optionals[] = {_Fields.GENDER,_Fields.US_CITIZENSHIP,_Fields.ETHNICITIES,_Fields.RACES,_Fields.DISABILITIES};
   public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
   static {
     java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.CUSTOS_INTERNAL_USER_ID, new org.apache.thrift.meta_data.FieldMetaData("custosInternalUserId", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.CUSTOS_INTERNAL_USER_ID, new org.apache.thrift.meta_data.FieldMetaData("custosInternalUserId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.GENDER, new org.apache.thrift.meta_data.FieldMetaData("gender", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.GENDER, new org.apache.thrift.meta_data.FieldMetaData("gender", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.US_CITIZENSHIP, new org.apache.thrift.meta_data.FieldMetaData("usCitizenship", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.US_CITIZENSHIP, new org.apache.thrift.meta_data.FieldMetaData("usCitizenship", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, USCitizenship.class)));
-    tmpMap.put(_Fields.ETHNICITIES, new org.apache.thrift.meta_data.FieldMetaData("ethnicities", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+    tmpMap.put(_Fields.ETHNICITIES, new org.apache.thrift.meta_data.FieldMetaData("ethnicities", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
             new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, ethnicity.class))));
-    tmpMap.put(_Fields.RACES, new org.apache.thrift.meta_data.FieldMetaData("races", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+    tmpMap.put(_Fields.RACES, new org.apache.thrift.meta_data.FieldMetaData("races", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
             new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, race.class))));
-    tmpMap.put(_Fields.DISABILITIES, new org.apache.thrift.meta_data.FieldMetaData("disabilities", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+    tmpMap.put(_Fields.DISABILITIES, new org.apache.thrift.meta_data.FieldMetaData("disabilities", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
             new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, disability.class))));
     metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(NSFDemographics.class, metaDataMap);
@@ -214,12 +203,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     this.disabilities = null;
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getCustosInternalUserId() {
     return this.custosInternalUserId;
   }
 
-  public void setCustosInternalUserId(String CustosInternalUserId) {
+  public NSFDemographics setCustosInternalUserId(@org.apache.thrift.annotation.Nullable String custosInternalUserId) {
     this.custosInternalUserId = custosInternalUserId;
+    return this;
   }
 
   public void unsetCustosInternalUserId() {
@@ -237,12 +228,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getGender() {
     return this.gender;
   }
 
-  public void setGender(String gender) {
+  public NSFDemographics setGender(@org.apache.thrift.annotation.Nullable String gender) {
     this.gender = gender;
+    return this;
   }
 
   public void unsetGender() {
@@ -261,19 +254,21 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
   }
 
   /**
-   *
+   * 
    * @see USCitizenship
    */
+  @org.apache.thrift.annotation.Nullable
   public USCitizenship getUsCitizenship() {
     return this.usCitizenship;
   }
 
   /**
-   *
+   * 
    * @see USCitizenship
    */
-  public void setUsCitizenship(USCitizenship usCitizenship) {
+  public NSFDemographics setUsCitizenship(@org.apache.thrift.annotation.Nullable USCitizenship usCitizenship) {
     this.usCitizenship = usCitizenship;
+    return this;
   }
 
   public void unsetUsCitizenship() {
@@ -295,6 +290,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     return (this.ethnicities == null) ? 0 : this.ethnicities.size();
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.Iterator<ethnicity> getEthnicitiesIterator() {
     return (this.ethnicities == null) ? null : this.ethnicities.iterator();
   }
@@ -306,12 +302,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     this.ethnicities.add(elem);
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.List<ethnicity> getEthnicities() {
     return this.ethnicities;
   }
 
-  public void setEthnicities(java.util.List<ethnicity> ethnicities) {
+  public NSFDemographics setEthnicities(@org.apache.thrift.annotation.Nullable java.util.List<ethnicity> ethnicities) {
     this.ethnicities = ethnicities;
+    return this;
   }
 
   public void unsetEthnicities() {
@@ -333,6 +331,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     return (this.races == null) ? 0 : this.races.size();
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.Iterator<race> getRacesIterator() {
     return (this.races == null) ? null : this.races.iterator();
   }
@@ -344,12 +343,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     this.races.add(elem);
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.List<race> getRaces() {
     return this.races;
   }
 
-  public void setRaces(java.util.List<race> races) {
+  public NSFDemographics setRaces(@org.apache.thrift.annotation.Nullable java.util.List<race> races) {
     this.races = races;
+    return this;
   }
 
   public void unsetRaces() {
@@ -371,6 +372,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     return (this.disabilities == null) ? 0 : this.disabilities.size();
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.Iterator<disability> getDisabilitiesIterator() {
     return (this.disabilities == null) ? null : this.disabilities.iterator();
   }
@@ -382,12 +384,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     this.disabilities.add(elem);
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.List<disability> getDisabilities() {
     return this.disabilities;
   }
 
-  public void setDisabilities(java.util.List<disability> disabilities) {
+  public NSFDemographics setDisabilities(@org.apache.thrift.annotation.Nullable java.util.List<disability> disabilities) {
     this.disabilities = disabilities;
+    return this;
   }
 
   public void unsetDisabilities() {
@@ -405,7 +409,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     }
   }
 
-  public void setFieldValue(_Fields field, Object value) {
+  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
     switch (field) {
     case CUSTOS_INTERNAL_USER_ID:
       if (value == null) {
@@ -458,6 +462,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public Object getFieldValue(_Fields field) {
     switch (field) {
     case CUSTOS_INTERNAL_USER_ID:
@@ -679,6 +684,7 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
     return 0;
   }
 
+  @org.apache.thrift.annotation.Nullable
   public _Fields fieldForId(int fieldId) {
     return _Fields.findByThriftId(fieldId);
   }
@@ -759,10 +765,9 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
 
   public void validate() throws org.apache.thrift.TException {
     // check for required fields
-    if (!isSetCustosInternalUserId()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'custosInternalUserId' is unset! Struct:" + toString());
+    if (custosInternalUserId == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'custosInternalUserId' was not present! Struct: " + toString());
     }
-
     // check for sub-struct validity
   }
 
@@ -829,11 +834,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
               {
                 org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
                 struct.ethnicities = new java.util.ArrayList<ethnicity>(_list0.size);
-                ethnicity _elem1;
+                @org.apache.thrift.annotation.Nullable ethnicity _elem1;
                 for (int _i2 = 0; _i2 < _list0.size; ++_i2)
                 {
                   _elem1 = ethnicity.findByValue(iprot.readI32());
-                  struct.ethnicities.add(_elem1);
+                  if (_elem1 != null)
+                  {
+                    struct.ethnicities.add(_elem1);
+                  }
                 }
                 iprot.readListEnd();
               }
@@ -847,11 +855,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
               {
                 org.apache.thrift.protocol.TList _list3 = iprot.readListBegin();
                 struct.races = new java.util.ArrayList<race>(_list3.size);
-                race _elem4;
+                @org.apache.thrift.annotation.Nullable race _elem4;
                 for (int _i5 = 0; _i5 < _list3.size; ++_i5)
                 {
                   _elem4 = race.findByValue(iprot.readI32());
-                  struct.races.add(_elem4);
+                  if (_elem4 != null)
+                  {
+                    struct.races.add(_elem4);
+                  }
                 }
                 iprot.readListEnd();
               }
@@ -865,11 +876,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
               {
                 org.apache.thrift.protocol.TList _list6 = iprot.readListBegin();
                 struct.disabilities = new java.util.ArrayList<disability>(_list6.size);
-                disability _elem7;
+                @org.apache.thrift.annotation.Nullable disability _elem7;
                 for (int _i8 = 0; _i8 < _list6.size; ++_i8)
                 {
                   _elem7 = disability.findByValue(iprot.readI32());
-                  struct.disabilities.add(_elem7);
+                  if (_elem7 != null)
+                  {
+                    struct.disabilities.add(_elem7);
+                  }
                 }
                 iprot.readListEnd();
               }
@@ -884,6 +898,8 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
         iprot.readFieldEnd();
       }
       iprot.readStructEnd();
+
+      // check for required fields of primitive type, which can't be checked in the validate method
       struct.validate();
     }
 
@@ -1040,11 +1056,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
         {
           org.apache.thrift.protocol.TList _list15 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32());
           struct.ethnicities = new java.util.ArrayList<ethnicity>(_list15.size);
-          ethnicity _elem16;
+          @org.apache.thrift.annotation.Nullable ethnicity _elem16;
           for (int _i17 = 0; _i17 < _list15.size; ++_i17)
           {
             _elem16 = ethnicity.findByValue(iprot.readI32());
-            struct.ethnicities.add(_elem16);
+            if (_elem16 != null)
+            {
+              struct.ethnicities.add(_elem16);
+            }
           }
         }
         struct.setEthnicitiesIsSet(true);
@@ -1053,11 +1072,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
         {
           org.apache.thrift.protocol.TList _list18 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32());
           struct.races = new java.util.ArrayList<race>(_list18.size);
-          race _elem19;
+          @org.apache.thrift.annotation.Nullable race _elem19;
           for (int _i20 = 0; _i20 < _list18.size; ++_i20)
           {
             _elem19 = race.findByValue(iprot.readI32());
-            struct.races.add(_elem19);
+            if (_elem19 != null)
+            {
+              struct.races.add(_elem19);
+            }
           }
         }
         struct.setRacesIsSet(true);
@@ -1066,11 +1088,14 @@ public class NSFDemographics implements org.apache.thrift.TBase<NSFDemographics,
         {
           org.apache.thrift.protocol.TList _list21 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32());
           struct.disabilities = new java.util.ArrayList<disability>(_list21.size);
-          disability _elem22;
+          @org.apache.thrift.annotation.Nullable disability _elem22;
           for (int _i23 = 0; _i23 < _list21.size; ++_i23)
           {
             _elem22 = disability.findByValue(iprot.readI32());
-            struct.disabilities.add(_elem22);
+            if (_elem22 != null)
+            {
+              struct.disabilities.add(_elem22);
+            }
           }
         }
         struct.setDisabilitiesIsSet(true);
diff --git a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/Status.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/Status.java
index 119a68b..a852d00 100644
--- a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/Status.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/Status.java
@@ -1,22 +1,5 @@
 /**
- * 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.10.0)
+ * Autogenerated by Thrift Compiler (0.12.0)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -24,9 +7,8 @@
 package org.apache.custos.profile.model.user;
 
 
-import org.apache.thrift.TEnum;
-
-public enum Status implements TEnum {
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-12")
+public enum Status implements org.apache.thrift.TEnum {
   ACTIVE(0),
   CONFIRMED(1),
   APPROVED(2),
@@ -59,6 +41,7 @@ public enum Status implements TEnum {
    * Find a the enum type by its integer value, as defined in the Thrift IDL.
    * @return null if the value is not found.
    */
+  @org.apache.thrift.annotation.Nullable
   public static Status findByValue(int value) { 
     switch (value) {
       case 0:
diff --git a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/USCitizenship.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/USCitizenship.java
index 89cfcc0..a8bb094 100644
--- a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/USCitizenship.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/USCitizenship.java
@@ -1,22 +1,5 @@
 /**
- * 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.10.0)
+ * Autogenerated by Thrift Compiler (0.12.0)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -24,13 +7,12 @@
 package org.apache.custos.profile.model.user;
 
 
-import org.apache.thrift.TEnum;
-
 /**
  * U.S. Citizen (see: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
  * 
  */
-public enum USCitizenship implements TEnum {
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-12")
+public enum USCitizenship implements org.apache.thrift.TEnum {
   US_CITIZEN(0),
   US_PERMANENT_RESIDENT(1),
   OTHER_NON_US_CITIZEN(2);
@@ -52,6 +34,7 @@ public enum USCitizenship implements TEnum {
    * Find a the enum type by its integer value, as defined in the Thrift IDL.
    * @return null if the value is not found.
    */
+  @org.apache.thrift.annotation.Nullable
   public static USCitizenship findByValue(int value) { 
     switch (value) {
       case 0:
diff --git a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/UserProfile.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/UserProfile.java
index e3c72ae..85bb2af 100644
--- a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/UserProfile.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/UserProfile.java
@@ -1,22 +1,5 @@
 /**
- * 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.10.0)
+ * Autogenerated by Thrift Compiler (0.12.0)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -37,8 +20,8 @@ package org.apache.custos.profile.model.user;
  * * userModelVersion:
  * *  Version number of profile
  * *
- * * airavataInternalUserId:
- * *  internal to Airavata, not intended to be used outside of the Airavata platform or possibly by gateways
+ * * custosInternalUserId:
+ * *  internal to custos, not intended to be used outside of the custos platform or possibly by gateways
  * *  (that is, never shown to users), never reassigned, REQUIRED
  * *
  * * userId:
@@ -55,7 +38,7 @@ package org.apache.custos.profile.model.user;
  * *   Email identifier are Verified, REQUIRED and MULTIVALUED
  * *
  * * userName:
- * *  Name-based identifiers can be multivalues. To keep it simple, Airavata will make it a string.
+ * *  Name-based identifiers can be multivalues. To keep it simple, custos will make it a string.
  * *   In the future these can be enumerated as:
  *     *   Official name (as asserted possibly by some external identity provider)
  *     *   Prefered name (as asserted or suggested by user directly)
@@ -73,7 +56,7 @@ package org.apache.custos.profile.model.user;
  * * nationality Countries of citizenship
  * *
  * * comments:
- * *   Free-form information (treated as opaque by Custos and simply passed to resource).
+ * *   Free-form information (treated as opaque by custos and simply passed to resource).
  * *
  * * labeledURI:
  *   * Google Scholar, Web of Science, ACS, e.t.c
@@ -82,7 +65,7 @@ package org.apache.custos.profile.model.user;
  * *  User’s preferred timezone - IANA Timezone Databases - http://www.iana.org/time-zones.
  * *
  */
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-12")
 public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserProfile._Fields>, java.io.Serializable, Cloneable, Comparable<UserProfile> {
   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UserProfile");
 
@@ -111,37 +94,39 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
   private static final org.apache.thrift.protocol.TField GPG_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("gpgKey", org.apache.thrift.protocol.TType.STRING, (short)23);
   private static final org.apache.thrift.protocol.TField TIME_ZONE_FIELD_DESC = new org.apache.thrift.protocol.TField("timeZone", org.apache.thrift.protocol.TType.STRING, (short)24);
   private static final org.apache.thrift.protocol.TField NSF_DEMOGRAPHICS_FIELD_DESC = new org.apache.thrift.protocol.TField("nsfDemographics", org.apache.thrift.protocol.TType.STRUCT, (short)25);
-  private static final org.apache.thrift.protocol.TField CUSTOM_DASHBOARD_FIELD_DESC = new org.apache.thrift.protocol.TField("customDashboard", org.apache.thrift.protocol.TType.STRUCT, (short)26);
 
   private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UserProfileStandardSchemeFactory();
   private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserProfileTupleSchemeFactory();
 
-  private String userModelVersion; // required
-  private String custosInternalUserId; // required
-  private String userId; // required
-  private String gatewayId; // required
-  private java.util.List<String> emails; // required
-  private String firstName; // required
-  private String lastName; // required
-  private String middleName; // optional
-  private String namePrefix; // optional
-  private String nameSuffix; // optional
-  private String orcidId; // optional
-  private java.util.List<String> phones; // optional
-  private String country; // optional
-  private java.util.List<String> nationality; // optional
-  private String homeOrganization; // optional
-  private String orginationAffiliation; // optional
-  private long creationTime; // required
-  private long lastAccessTime; // required
-  private long validUntil; // required
-  private Status State; // required
-  private String comments; // optional
-  private java.util.List<String> labeledURI; // optional
-  private String gpgKey; // optional
-  private String timeZone; // optional
-  private NSFDemographics nsfDemographics; // optional
-  private CustomDashboard customDashboard; // optional
+  public @org.apache.thrift.annotation.Nullable String userModelVersion; // required
+  public @org.apache.thrift.annotation.Nullable String custosInternalUserId; // required
+  public @org.apache.thrift.annotation.Nullable String userId; // required
+  public @org.apache.thrift.annotation.Nullable String gatewayId; // required
+  public @org.apache.thrift.annotation.Nullable java.util.List<String> emails; // required
+  public @org.apache.thrift.annotation.Nullable String firstName; // required
+  public @org.apache.thrift.annotation.Nullable String lastName; // required
+  public @org.apache.thrift.annotation.Nullable String middleName; // optional
+  public @org.apache.thrift.annotation.Nullable String namePrefix; // optional
+  public @org.apache.thrift.annotation.Nullable String nameSuffix; // optional
+  public @org.apache.thrift.annotation.Nullable String orcidId; // optional
+  public @org.apache.thrift.annotation.Nullable java.util.List<String> phones; // optional
+  public @org.apache.thrift.annotation.Nullable String country; // optional
+  public @org.apache.thrift.annotation.Nullable java.util.List<String> nationality; // optional
+  public @org.apache.thrift.annotation.Nullable String homeOrganization; // optional
+  public @org.apache.thrift.annotation.Nullable String orginationAffiliation; // optional
+  public long creationTime; // required
+  public long lastAccessTime; // required
+  public long validUntil; // required
+  /**
+   * 
+   * @see Status
+   */
+  public @org.apache.thrift.annotation.Nullable Status State; // required
+  public @org.apache.thrift.annotation.Nullable String comments; // optional
+  public @org.apache.thrift.annotation.Nullable java.util.List<String> labeledURI; // optional
+  public @org.apache.thrift.annotation.Nullable String gpgKey; // optional
+  public @org.apache.thrift.annotation.Nullable String timeZone; // optional
+  public @org.apache.thrift.annotation.Nullable NSFDemographics nsfDemographics; // optional
 
   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@@ -165,7 +150,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     LAST_ACCESS_TIME((short)18, "lastAccessTime"),
     VALID_UNTIL((short)19, "validUntil"),
     /**
-     *
+     * 
      * @see Status
      */
     STATE((short)20, "State"),
@@ -173,8 +158,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     LABELED_URI((short)22, "labeledURI"),
     GPG_KEY((short)23, "gpgKey"),
     TIME_ZONE((short)24, "timeZone"),
-    NSF_DEMOGRAPHICS((short)25, "nsfDemographics"),
-    CUSTOM_DASHBOARD((short)26, "customDashboard");
+    NSF_DEMOGRAPHICS((short)25, "nsfDemographics");
 
     private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
 
@@ -187,6 +171,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     /**
      * Find the _Fields constant that matches fieldId, or null if its not found.
      */
+    @org.apache.thrift.annotation.Nullable
     public static _Fields findByThriftId(int fieldId) {
       switch(fieldId) {
         case 1: // USER_MODEL_VERSION
@@ -239,8 +224,6 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
           return TIME_ZONE;
         case 25: // NSF_DEMOGRAPHICS
           return NSF_DEMOGRAPHICS;
-        case 26: // CUSTOM_DASHBOARD
-          return CUSTOM_DASHBOARD;
         default:
           return null;
       }
@@ -259,6 +242,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     /**
      * Find the _Fields constant that matches name, or null if its not found.
      */
+    @org.apache.thrift.annotation.Nullable
     public static _Fields findByName(String name) {
       return byName.get(name);
     }
@@ -285,66 +269,64 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
   private static final int __LASTACCESSTIME_ISSET_ID = 1;
   private static final int __VALIDUNTIL_ISSET_ID = 2;
   private byte __isset_bitfield = 0;
-  private static final _Fields optionals[] = {_Fields.MIDDLE_NAME, _Fields.NAME_PREFIX, _Fields.NAME_SUFFIX, _Fields.ORCID_ID, _Fields.PHONES, _Fields.COUNTRY, _Fields.NATIONALITY, _Fields.HOME_ORGANIZATION, _Fields.ORGINATION_AFFILIATION, _Fields.COMMENTS, _Fields.LABELED_URI, _Fields.GPG_KEY, _Fields.TIME_ZONE, _Fields.NSF_DEMOGRAPHICS, _Fields.CUSTOM_DASHBOARD};
+  private static final _Fields optionals[] = {_Fields.MIDDLE_NAME,_Fields.NAME_PREFIX,_Fields.NAME_SUFFIX,_Fields.ORCID_ID,_Fields.PHONES,_Fields.COUNTRY,_Fields.NATIONALITY,_Fields.HOME_ORGANIZATION,_Fields.ORGINATION_AFFILIATION,_Fields.COMMENTS,_Fields.LABELED_URI,_Fields.GPG_KEY,_Fields.TIME_ZONE,_Fields.NSF_DEMOGRAPHICS};
   public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
   static {
     java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.USER_MODEL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("userModelVersion", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.USER_MODEL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("userModelVersion", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.CUSTOS_INTERNAL_USER_ID, new org.apache.thrift.meta_data.FieldMetaData("custosInternalUserId", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.CUSTOS_INTERNAL_USER_ID, new org.apache.thrift.meta_data.FieldMetaData("custosInternalUserId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.USER_ID, new org.apache.thrift.meta_data.FieldMetaData("userId", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.USER_ID, new org.apache.thrift.meta_data.FieldMetaData("userId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.GATEWAY_ID, new org.apache.thrift.meta_data.FieldMetaData("gatewayId", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    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.EMAILS, new org.apache.thrift.meta_data.FieldMetaData("emails", org.apache.thrift.TFieldRequirementType.REQUIRED,
-        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+    tmpMap.put(_Fields.EMAILS, new org.apache.thrift.meta_data.FieldMetaData("emails", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
-    tmpMap.put(_Fields.FIRST_NAME, new org.apache.thrift.meta_data.FieldMetaData("firstName", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.FIRST_NAME, new org.apache.thrift.meta_data.FieldMetaData("firstName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.LAST_NAME, new org.apache.thrift.meta_data.FieldMetaData("lastName", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.LAST_NAME, new org.apache.thrift.meta_data.FieldMetaData("lastName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.MIDDLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("middleName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.MIDDLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("middleName", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.NAME_PREFIX, new org.apache.thrift.meta_data.FieldMetaData("namePrefix", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.NAME_PREFIX, new org.apache.thrift.meta_data.FieldMetaData("namePrefix", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.NAME_SUFFIX, new org.apache.thrift.meta_data.FieldMetaData("nameSuffix", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.NAME_SUFFIX, new org.apache.thrift.meta_data.FieldMetaData("nameSuffix", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.ORCID_ID, new org.apache.thrift.meta_data.FieldMetaData("orcidId", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.ORCID_ID, new org.apache.thrift.meta_data.FieldMetaData("orcidId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.PHONES, new org.apache.thrift.meta_data.FieldMetaData("phones", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+    tmpMap.put(_Fields.PHONES, new org.apache.thrift.meta_data.FieldMetaData("phones", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
-    tmpMap.put(_Fields.COUNTRY, new org.apache.thrift.meta_data.FieldMetaData("country", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.COUNTRY, new org.apache.thrift.meta_data.FieldMetaData("country", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.NATIONALITY, new org.apache.thrift.meta_data.FieldMetaData("nationality", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+    tmpMap.put(_Fields.NATIONALITY, new org.apache.thrift.meta_data.FieldMetaData("nationality", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
-    tmpMap.put(_Fields.HOME_ORGANIZATION, new org.apache.thrift.meta_data.FieldMetaData("homeOrganization", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.HOME_ORGANIZATION, new org.apache.thrift.meta_data.FieldMetaData("homeOrganization", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.ORGINATION_AFFILIATION, new org.apache.thrift.meta_data.FieldMetaData("orginationAffiliation", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.ORGINATION_AFFILIATION, new org.apache.thrift.meta_data.FieldMetaData("orginationAffiliation", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.CREATION_TIME, new org.apache.thrift.meta_data.FieldMetaData("creationTime", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.CREATION_TIME, new org.apache.thrift.meta_data.FieldMetaData("creationTime", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    tmpMap.put(_Fields.LAST_ACCESS_TIME, new org.apache.thrift.meta_data.FieldMetaData("lastAccessTime", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.LAST_ACCESS_TIME, new org.apache.thrift.meta_data.FieldMetaData("lastAccessTime", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    tmpMap.put(_Fields.VALID_UNTIL, new org.apache.thrift.meta_data.FieldMetaData("validUntil", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.VALID_UNTIL, new org.apache.thrift.meta_data.FieldMetaData("validUntil", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    tmpMap.put(_Fields.STATE, new org.apache.thrift.meta_data.FieldMetaData("State", org.apache.thrift.TFieldRequirementType.REQUIRED,
+    tmpMap.put(_Fields.STATE, new org.apache.thrift.meta_data.FieldMetaData("State", org.apache.thrift.TFieldRequirementType.REQUIRED, 
         new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Status.class)));
-    tmpMap.put(_Fields.COMMENTS, new org.apache.thrift.meta_data.FieldMetaData("comments", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.COMMENTS, new org.apache.thrift.meta_data.FieldMetaData("comments", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.LABELED_URI, new org.apache.thrift.meta_data.FieldMetaData("labeledURI", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
+    tmpMap.put(_Fields.LABELED_URI, new org.apache.thrift.meta_data.FieldMetaData("labeledURI", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
+        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
             new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
-    tmpMap.put(_Fields.GPG_KEY, new org.apache.thrift.meta_data.FieldMetaData("gpgKey", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.GPG_KEY, new org.apache.thrift.meta_data.FieldMetaData("gpgKey", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.TIME_ZONE, new org.apache.thrift.meta_data.FieldMetaData("timeZone", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.TIME_ZONE, new org.apache.thrift.meta_data.FieldMetaData("timeZone", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.NSF_DEMOGRAPHICS, new org.apache.thrift.meta_data.FieldMetaData("nsfDemographics", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+    tmpMap.put(_Fields.NSF_DEMOGRAPHICS, new org.apache.thrift.meta_data.FieldMetaData("nsfDemographics", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, NSFDemographics.class)));
-    tmpMap.put(_Fields.CUSTOM_DASHBOARD, new org.apache.thrift.meta_data.FieldMetaData("customDashboard", org.apache.thrift.TFieldRequirementType.OPTIONAL,
-        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CustomDashboard.class)));
     metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(UserProfile.class, metaDataMap);
   }
@@ -464,9 +446,6 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     if (other.isSetNsfDemographics()) {
       this.nsfDemographics = new NSFDemographics(other.nsfDemographics);
     }
-    if (other.isSetCustomDashboard()) {
-      this.customDashboard = new CustomDashboard(other.customDashboard);
-    }
   }
 
   public UserProfile deepCopy() {
@@ -505,15 +484,16 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     this.gpgKey = null;
     this.timeZone = null;
     this.nsfDemographics = null;
-    this.customDashboard = null;
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getUserModelVersion() {
     return this.userModelVersion;
   }
 
-  public void setUserModelVersion(String userModelVersion) {
+  public UserProfile setUserModelVersion(@org.apache.thrift.annotation.Nullable String userModelVersion) {
     this.userModelVersion = userModelVersion;
+    return this;
   }
 
   public void unsetUserModelVersion() {
@@ -531,12 +511,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getCustosInternalUserId() {
     return this.custosInternalUserId;
   }
 
-  public void setCustosInternalUserId(String custosInternalUserId) {
+  public UserProfile setCustosInternalUserId(@org.apache.thrift.annotation.Nullable String custosInternalUserId) {
     this.custosInternalUserId = custosInternalUserId;
+    return this;
   }
 
   public void unsetCustosInternalUserId() {
@@ -554,12 +536,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getUserId() {
     return this.userId;
   }
 
-  public void setUserId(String userId) {
+  public UserProfile setUserId(@org.apache.thrift.annotation.Nullable String userId) {
     this.userId = userId;
+    return this;
   }
 
   public void unsetUserId() {
@@ -577,12 +561,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getGatewayId() {
     return this.gatewayId;
   }
 
-  public void setGatewayId(String gatewayId) {
+  public UserProfile setGatewayId(@org.apache.thrift.annotation.Nullable String gatewayId) {
     this.gatewayId = gatewayId;
+    return this;
   }
 
   public void unsetGatewayId() {
@@ -604,6 +590,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     return (this.emails == null) ? 0 : this.emails.size();
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.Iterator<String> getEmailsIterator() {
     return (this.emails == null) ? null : this.emails.iterator();
   }
@@ -615,12 +602,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     this.emails.add(elem);
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.List<String> getEmails() {
     return this.emails;
   }
 
-  public void setEmails(java.util.List<String> emails) {
+  public UserProfile setEmails(@org.apache.thrift.annotation.Nullable java.util.List<String> emails) {
     this.emails = emails;
+    return this;
   }
 
   public void unsetEmails() {
@@ -638,12 +627,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getFirstName() {
     return this.firstName;
   }
 
-  public void setFirstName(String firstName) {
+  public UserProfile setFirstName(@org.apache.thrift.annotation.Nullable String firstName) {
     this.firstName = firstName;
+    return this;
   }
 
   public void unsetFirstName() {
@@ -661,12 +652,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getLastName() {
     return this.lastName;
   }
 
-  public void setLastName(String lastName) {
+  public UserProfile setLastName(@org.apache.thrift.annotation.Nullable String lastName) {
     this.lastName = lastName;
+    return this;
   }
 
   public void unsetLastName() {
@@ -684,12 +677,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getMiddleName() {
     return this.middleName;
   }
 
-  public void setMiddleName(String middleName) {
+  public UserProfile setMiddleName(@org.apache.thrift.annotation.Nullable String middleName) {
     this.middleName = middleName;
+    return this;
   }
 
   public void unsetMiddleName() {
@@ -707,12 +702,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getNamePrefix() {
     return this.namePrefix;
   }
 
-  public void setNamePrefix(String namePrefix) {
+  public UserProfile setNamePrefix(@org.apache.thrift.annotation.Nullable String namePrefix) {
     this.namePrefix = namePrefix;
+    return this;
   }
 
   public void unsetNamePrefix() {
@@ -730,12 +727,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getNameSuffix() {
     return this.nameSuffix;
   }
 
-  public void setNameSuffix(String nameSuffix) {
+  public UserProfile setNameSuffix(@org.apache.thrift.annotation.Nullable String nameSuffix) {
     this.nameSuffix = nameSuffix;
+    return this;
   }
 
   public void unsetNameSuffix() {
@@ -753,12 +752,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getOrcidId() {
     return this.orcidId;
   }
 
-  public void setOrcidId(String orcidId) {
+  public UserProfile setOrcidId(@org.apache.thrift.annotation.Nullable String orcidId) {
     this.orcidId = orcidId;
+    return this;
   }
 
   public void unsetOrcidId() {
@@ -780,6 +781,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     return (this.phones == null) ? 0 : this.phones.size();
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.Iterator<String> getPhonesIterator() {
     return (this.phones == null) ? null : this.phones.iterator();
   }
@@ -791,12 +793,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     this.phones.add(elem);
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.List<String> getPhones() {
     return this.phones;
   }
 
-  public void setPhones(java.util.List<String> phones) {
+  public UserProfile setPhones(@org.apache.thrift.annotation.Nullable java.util.List<String> phones) {
     this.phones = phones;
+    return this;
   }
 
   public void unsetPhones() {
@@ -814,12 +818,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getCountry() {
     return this.country;
   }
 
-  public void setCountry(String country) {
+  public UserProfile setCountry(@org.apache.thrift.annotation.Nullable String country) {
     this.country = country;
+    return this;
   }
 
   public void unsetCountry() {
@@ -841,6 +847,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     return (this.nationality == null) ? 0 : this.nationality.size();
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.Iterator<String> getNationalityIterator() {
     return (this.nationality == null) ? null : this.nationality.iterator();
   }
@@ -852,12 +859,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     this.nationality.add(elem);
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.List<String> getNationality() {
     return this.nationality;
   }
 
-  public void setNationality(java.util.List<String> nationality) {
+  public UserProfile setNationality(@org.apache.thrift.annotation.Nullable java.util.List<String> nationality) {
     this.nationality = nationality;
+    return this;
   }
 
   public void unsetNationality() {
@@ -875,12 +884,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getHomeOrganization() {
     return this.homeOrganization;
   }
 
-  public void setHomeOrganization(String homeOrganization) {
+  public UserProfile setHomeOrganization(@org.apache.thrift.annotation.Nullable String homeOrganization) {
     this.homeOrganization = homeOrganization;
+    return this;
   }
 
   public void unsetHomeOrganization() {
@@ -898,12 +909,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getOrginationAffiliation() {
     return this.orginationAffiliation;
   }
 
-  public void setOrginationAffiliation(String orginationAffiliation) {
+  public UserProfile setOrginationAffiliation(@org.apache.thrift.annotation.Nullable String orginationAffiliation) {
     this.orginationAffiliation = orginationAffiliation;
+    return this;
   }
 
   public void unsetOrginationAffiliation() {
@@ -925,9 +938,10 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     return this.creationTime;
   }
 
-  public void setCreationTime(long creationTime) {
+  public UserProfile setCreationTime(long creationTime) {
     this.creationTime = creationTime;
     setCreationTimeIsSet(true);
+    return this;
   }
 
   public void unsetCreationTime() {
@@ -947,9 +961,10 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     return this.lastAccessTime;
   }
 
-  public void setLastAccessTime(long lastAccessTime) {
+  public UserProfile setLastAccessTime(long lastAccessTime) {
     this.lastAccessTime = lastAccessTime;
     setLastAccessTimeIsSet(true);
+    return this;
   }
 
   public void unsetLastAccessTime() {
@@ -969,9 +984,10 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     return this.validUntil;
   }
 
-  public void setValidUntil(long validUntil) {
+  public UserProfile setValidUntil(long validUntil) {
     this.validUntil = validUntil;
     setValidUntilIsSet(true);
+    return this;
   }
 
   public void unsetValidUntil() {
@@ -988,19 +1004,21 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
   }
 
   /**
-   *
+   * 
    * @see Status
    */
+  @org.apache.thrift.annotation.Nullable
   public Status getState() {
     return this.State;
   }
 
   /**
-   *
+   * 
    * @see Status
    */
-  public void setState(Status State) {
+  public UserProfile setState(@org.apache.thrift.annotation.Nullable Status State) {
     this.State = State;
+    return this;
   }
 
   public void unsetState() {
@@ -1018,12 +1036,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getComments() {
     return this.comments;
   }
 
-  public void setComments(String comments) {
+  public UserProfile setComments(@org.apache.thrift.annotation.Nullable String comments) {
     this.comments = comments;
+    return this;
   }
 
   public void unsetComments() {
@@ -1045,6 +1065,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     return (this.labeledURI == null) ? 0 : this.labeledURI.size();
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.Iterator<String> getLabeledURIIterator() {
     return (this.labeledURI == null) ? null : this.labeledURI.iterator();
   }
@@ -1056,12 +1077,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     this.labeledURI.add(elem);
   }
 
+  @org.apache.thrift.annotation.Nullable
   public java.util.List<String> getLabeledURI() {
     return this.labeledURI;
   }
 
-  public void setLabeledURI(java.util.List<String> labeledURI) {
+  public UserProfile setLabeledURI(@org.apache.thrift.annotation.Nullable java.util.List<String> labeledURI) {
     this.labeledURI = labeledURI;
+    return this;
   }
 
   public void unsetLabeledURI() {
@@ -1079,12 +1102,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getGpgKey() {
     return this.gpgKey;
   }
 
-  public void setGpgKey(String gpgKey) {
+  public UserProfile setGpgKey(@org.apache.thrift.annotation.Nullable String gpgKey) {
     this.gpgKey = gpgKey;
+    return this;
   }
 
   public void unsetGpgKey() {
@@ -1102,12 +1127,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public String getTimeZone() {
     return this.timeZone;
   }
 
-  public void setTimeZone(String timeZone) {
+  public UserProfile setTimeZone(@org.apache.thrift.annotation.Nullable String timeZone) {
     this.timeZone = timeZone;
+    return this;
   }
 
   public void unsetTimeZone() {
@@ -1125,12 +1152,14 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public NSFDemographics getNsfDemographics() {
     return this.nsfDemographics;
   }
 
-  public void setNsfDemographics(NSFDemographics nsfDemographics) {
+  public UserProfile setNsfDemographics(@org.apache.thrift.annotation.Nullable NSFDemographics nsfDemographics) {
     this.nsfDemographics = nsfDemographics;
+    return this;
   }
 
   public void unsetNsfDemographics() {
@@ -1148,30 +1177,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     }
   }
 
-  public CustomDashboard getCustomDashboard() {
-    return this.customDashboard;
-  }
-
-  public void setCustomDashboard(CustomDashboard customDashboard) {
-    this.customDashboard = customDashboard;
-  }
-
-  public void unsetCustomDashboard() {
-    this.customDashboard = null;
-  }
-
-  /** Returns true if field customDashboard is set (has been assigned a value) and false otherwise */
-  public boolean isSetCustomDashboard() {
-    return this.customDashboard != null;
-  }
-
-  public void setCustomDashboardIsSet(boolean value) {
-    if (!value) {
-      this.customDashboard = null;
-    }
-  }
-
-  public void setFieldValue(_Fields field, Object value) {
+  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
     switch (field) {
     case USER_MODEL_VERSION:
       if (value == null) {
@@ -1373,17 +1379,10 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       }
       break;
 
-    case CUSTOM_DASHBOARD:
-      if (value == null) {
-        unsetCustomDashboard();
-      } else {
-        setCustomDashboard((CustomDashboard)value);
-      }
-      break;
-
     }
   }
 
+  @org.apache.thrift.annotation.Nullable
   public Object getFieldValue(_Fields field) {
     switch (field) {
     case USER_MODEL_VERSION:
@@ -1461,9 +1460,6 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     case NSF_DEMOGRAPHICS:
       return getNsfDemographics();
 
-    case CUSTOM_DASHBOARD:
-      return getCustomDashboard();
-
     }
     throw new IllegalStateException();
   }
@@ -1525,8 +1521,6 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       return isSetTimeZone();
     case NSF_DEMOGRAPHICS:
       return isSetNsfDemographics();
-    case CUSTOM_DASHBOARD:
-      return isSetCustomDashboard();
     }
     throw new IllegalStateException();
   }
@@ -1771,15 +1765,6 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         return false;
     }
 
-    boolean this_present_customDashboard = true && this.isSetCustomDashboard();
-    boolean that_present_customDashboard = true && that.isSetCustomDashboard();
-    if (this_present_customDashboard || that_present_customDashboard) {
-      if (!(this_present_customDashboard && that_present_customDashboard))
-        return false;
-      if (!this.customDashboard.equals(that.customDashboard))
-        return false;
-    }
-
     return true;
   }
 
@@ -1881,10 +1866,6 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
     if (isSetNsfDemographics())
       hashCode = hashCode * 8191 + nsfDemographics.hashCode();
 
-    hashCode = hashCode * 8191 + ((isSetCustomDashboard()) ? 131071 : 524287);
-    if (isSetCustomDashboard())
-      hashCode = hashCode * 8191 + customDashboard.hashCode();
-
     return hashCode;
   }
 
@@ -2146,19 +2127,10 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         return lastComparison;
       }
     }
-    lastComparison = Boolean.valueOf(isSetCustomDashboard()).compareTo(other.isSetCustomDashboard());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetCustomDashboard()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.customDashboard, other.customDashboard);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
     return 0;
   }
 
+  @org.apache.thrift.annotation.Nullable
   public _Fields fieldForId(int fieldId) {
     return _Fields.findByThriftId(fieldId);
   }
@@ -2391,73 +2363,43 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       }
       first = false;
     }
-    if (isSetCustomDashboard()) {
-      if (!first) sb.append(", ");
-      sb.append("customDashboard:");
-      if (this.customDashboard == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.customDashboard);
-      }
-      first = false;
-    }
     sb.append(")");
     return sb.toString();
   }
 
   public void validate() throws org.apache.thrift.TException {
     // check for required fields
-    if (!isSetUserModelVersion()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'userModelVersion' is unset! Struct:" + toString());
+    if (userModelVersion == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'userModelVersion' was not present! Struct: " + toString());
     }
-
-    if (!isSetCustosInternalUserId()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'custosInternalUserId' is unset! Struct:" + toString());
+    if (custosInternalUserId == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'custosInternalUserId' was not present! Struct: " + toString());
     }
-
-    if (!isSetUserId()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'userId' is unset! Struct:" + toString());
+    if (userId == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'userId' was not present! Struct: " + toString());
     }
-
-    if (!isSetGatewayId()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'gatewayId' is unset! Struct:" + toString());
+    if (gatewayId == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'gatewayId' was not present! Struct: " + toString());
     }
-
-    if (!isSetEmails()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'emails' is unset! Struct:" + toString());
+    if (emails == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'emails' was not present! Struct: " + toString());
     }
-
-    if (!isSetFirstName()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'firstName' is unset! Struct:" + toString());
+    if (firstName == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'firstName' was not present! Struct: " + toString());
     }
-
-    if (!isSetLastName()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'lastName' is unset! Struct:" + toString());
+    if (lastName == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'lastName' was not present! Struct: " + toString());
     }
-
-    if (!isSetCreationTime()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'creationTime' is unset! Struct:" + toString());
-    }
-
-    if (!isSetLastAccessTime()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'lastAccessTime' is unset! Struct:" + toString());
-    }
-
-    if (!isSetValidUntil()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'validUntil' is unset! Struct:" + toString());
+    // alas, we cannot check 'creationTime' because it's a primitive and you chose the non-beans generator.
+    // alas, we cannot check 'lastAccessTime' because it's a primitive and you chose the non-beans generator.
+    // alas, we cannot check 'validUntil' because it's a primitive and you chose the non-beans generator.
+    if (State == null) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'State' was not present! Struct: " + toString());
     }
-
-    if (!isSetState()) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'State' is unset! Struct:" + toString());
-    }
-
     // check for sub-struct validity
     if (nsfDemographics != null) {
       nsfDemographics.validate();
     }
-    if (customDashboard != null) {
-      customDashboard.validate();
-    }
   }
 
   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
@@ -2492,7 +2434,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       while (true)
       {
         schemeField = iprot.readFieldBegin();
-        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
           break;
         }
         switch (schemeField.id) {
@@ -2500,7 +2442,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.userModelVersion = iprot.readString();
               struct.setUserModelVersionIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2508,7 +2450,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.custosInternalUserId = iprot.readString();
               struct.setCustosInternalUserIdIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2516,7 +2458,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.userId = iprot.readString();
               struct.setUserIdIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2524,7 +2466,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.gatewayId = iprot.readString();
               struct.setGatewayIdIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2533,7 +2475,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
               {
                 org.apache.thrift.protocol.TList _list24 = iprot.readListBegin();
                 struct.emails = new java.util.ArrayList<String>(_list24.size);
-                String _elem25;
+                @org.apache.thrift.annotation.Nullable String _elem25;
                 for (int _i26 = 0; _i26 < _list24.size; ++_i26)
                 {
                   _elem25 = iprot.readString();
@@ -2542,7 +2484,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
                 iprot.readListEnd();
               }
               struct.setEmailsIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2550,7 +2492,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.firstName = iprot.readString();
               struct.setFirstNameIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2558,7 +2500,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.lastName = iprot.readString();
               struct.setLastNameIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2566,7 +2508,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.middleName = iprot.readString();
               struct.setMiddleNameIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2574,7 +2516,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.namePrefix = iprot.readString();
               struct.setNamePrefixIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2582,7 +2524,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.nameSuffix = iprot.readString();
               struct.setNameSuffixIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2590,7 +2532,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.orcidId = iprot.readString();
               struct.setOrcidIdIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2599,7 +2541,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
               {
                 org.apache.thrift.protocol.TList _list27 = iprot.readListBegin();
                 struct.phones = new java.util.ArrayList<String>(_list27.size);
-                String _elem28;
+                @org.apache.thrift.annotation.Nullable String _elem28;
                 for (int _i29 = 0; _i29 < _list27.size; ++_i29)
                 {
                   _elem28 = iprot.readString();
@@ -2608,7 +2550,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
                 iprot.readListEnd();
               }
               struct.setPhonesIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2616,7 +2558,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.country = iprot.readString();
               struct.setCountryIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2625,7 +2567,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
               {
                 org.apache.thrift.protocol.TList _list30 = iprot.readListBegin();
                 struct.nationality = new java.util.ArrayList<String>(_list30.size);
-                String _elem31;
+                @org.apache.thrift.annotation.Nullable String _elem31;
                 for (int _i32 = 0; _i32 < _list30.size; ++_i32)
                 {
                   _elem31 = iprot.readString();
@@ -2634,7 +2576,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
                 iprot.readListEnd();
               }
               struct.setNationalityIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2642,7 +2584,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.homeOrganization = iprot.readString();
               struct.setHomeOrganizationIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2650,7 +2592,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.orginationAffiliation = iprot.readString();
               struct.setOrginationAffiliationIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2658,7 +2600,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
               struct.creationTime = iprot.readI64();
               struct.setCreationTimeIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2666,7 +2608,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
               struct.lastAccessTime = iprot.readI64();
               struct.setLastAccessTimeIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2674,7 +2616,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
               struct.validUntil = iprot.readI64();
               struct.setValidUntilIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2682,7 +2624,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
               struct.State = Status.findByValue(iprot.readI32());
               struct.setStateIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2690,7 +2632,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.comments = iprot.readString();
               struct.setCommentsIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2699,7 +2641,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
               {
                 org.apache.thrift.protocol.TList _list33 = iprot.readListBegin();
                 struct.labeledURI = new java.util.ArrayList<String>(_list33.size);
-                String _elem34;
+                @org.apache.thrift.annotation.Nullable String _elem34;
                 for (int _i35 = 0; _i35 < _list33.size; ++_i35)
                 {
                   _elem34 = iprot.readString();
@@ -2708,7 +2650,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
                 iprot.readListEnd();
               }
               struct.setLabeledURIIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2716,7 +2658,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.gpgKey = iprot.readString();
               struct.setGpgKeyIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2724,7 +2666,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
               struct.timeZone = iprot.readString();
               struct.setTimeZoneIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2733,16 +2675,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
               struct.nsfDemographics = new NSFDemographics();
               struct.nsfDemographics.read(iprot);
               struct.setNsfDemographicsIsSet(true);
-            } else {
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 26: // CUSTOM_DASHBOARD
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
-              struct.customDashboard = new CustomDashboard();
-              struct.customDashboard.read(iprot);
-              struct.setCustomDashboardIsSet(true);
-            } else {
+            } else { 
               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
             }
             break;
@@ -2752,6 +2685,17 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         iprot.readFieldEnd();
       }
       iprot.readStructEnd();
+
+      // check for required fields of primitive type, which can't be checked in the validate method
+      if (!struct.isSetCreationTime()) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'creationTime' was not found in serialized data! Struct: " + toString());
+      }
+      if (!struct.isSetLastAccessTime()) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'lastAccessTime' was not found in serialized data! Struct: " + toString());
+      }
+      if (!struct.isSetValidUntil()) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'validUntil' was not found in serialized data! Struct: " + toString());
+      }
       struct.validate();
     }
 
@@ -2934,13 +2878,6 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
           oprot.writeFieldEnd();
         }
       }
-      if (struct.customDashboard != null) {
-        if (struct.isSetCustomDashboard()) {
-          oprot.writeFieldBegin(CUSTOM_DASHBOARD_FIELD_DESC);
-          struct.customDashboard.write(oprot);
-          oprot.writeFieldEnd();
-        }
-      }
       oprot.writeFieldStop();
       oprot.writeStructEnd();
     }
@@ -3018,10 +2955,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       if (struct.isSetNsfDemographics()) {
         optionals.set(13);
       }
-      if (struct.isSetCustomDashboard()) {
-        optionals.set(14);
-      }
-      oprot.writeBitSet(optionals, 15);
+      oprot.writeBitSet(optionals, 14);
       if (struct.isSetMiddleName()) {
         oprot.writeString(struct.middleName);
       }
@@ -3082,9 +3016,6 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       if (struct.isSetNsfDemographics()) {
         struct.nsfDemographics.write(oprot);
       }
-      if (struct.isSetCustomDashboard()) {
-        struct.customDashboard.write(oprot);
-      }
     }
 
     @Override
@@ -3101,7 +3032,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       {
         org.apache.thrift.protocol.TList _list44 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
         struct.emails = new java.util.ArrayList<String>(_list44.size);
-        String _elem45;
+        @org.apache.thrift.annotation.Nullable String _elem45;
         for (int _i46 = 0; _i46 < _list44.size; ++_i46)
         {
           _elem45 = iprot.readString();
@@ -3121,7 +3052,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
       struct.setValidUntilIsSet(true);
       struct.State = Status.findByValue(iprot.readI32());
       struct.setStateIsSet(true);
-      java.util.BitSet incoming = iprot.readBitSet(15);
+      java.util.BitSet incoming = iprot.readBitSet(14);
       if (incoming.get(0)) {
         struct.middleName = iprot.readString();
         struct.setMiddleNameIsSet(true);
@@ -3142,7 +3073,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         {
           org.apache.thrift.protocol.TList _list47 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
           struct.phones = new java.util.ArrayList<String>(_list47.size);
-          String _elem48;
+          @org.apache.thrift.annotation.Nullable String _elem48;
           for (int _i49 = 0; _i49 < _list47.size; ++_i49)
           {
             _elem48 = iprot.readString();
@@ -3159,7 +3090,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         {
           org.apache.thrift.protocol.TList _list50 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
           struct.nationality = new java.util.ArrayList<String>(_list50.size);
-          String _elem51;
+          @org.apache.thrift.annotation.Nullable String _elem51;
           for (int _i52 = 0; _i52 < _list50.size; ++_i52)
           {
             _elem51 = iprot.readString();
@@ -3184,7 +3115,7 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         {
           org.apache.thrift.protocol.TList _list53 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
           struct.labeledURI = new java.util.ArrayList<String>(_list53.size);
-          String _elem54;
+          @org.apache.thrift.annotation.Nullable String _elem54;
           for (int _i55 = 0; _i55 < _list53.size; ++_i55)
           {
             _elem54 = iprot.readString();
@@ -3206,11 +3137,6 @@ public class UserProfile implements org.apache.thrift.TBase<UserProfile, UserPro
         struct.nsfDemographics.read(iprot);
         struct.setNsfDemographicsIsSet(true);
       }
-      if (incoming.get(14)) {
-        struct.customDashboard = new CustomDashboard();
-        struct.customDashboard.read(iprot);
-        struct.setCustomDashboardIsSet(true);
-      }
     }
   }
 
diff --git a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/disability.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/disability.java
index eb0058c..c2f4a06 100644
--- a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/disability.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/disability.java
@@ -1,22 +1,5 @@
 /**
- * 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.10.0)
+ * Autogenerated by Thrift Compiler (0.12.0)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -24,9 +7,8 @@
 package org.apache.custos.profile.model.user;
 
 
-import org.apache.thrift.TEnum;
-
-public enum disability implements TEnum {
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-12")
+public enum disability implements org.apache.thrift.TEnum {
   HEARING_IMAPAIRED(0),
   VISUAL_IMPAIRED(1),
   MOBILITY_OR_ORTHOPEDIC_IMPAIRMENT(2),
@@ -49,6 +31,7 @@ public enum disability implements TEnum {
    * Find a the enum type by its integer value, as defined in the Thrift IDL.
    * @return null if the value is not found.
    */
+  @org.apache.thrift.annotation.Nullable
   public static disability findByValue(int value) { 
     switch (value) {
       case 0:
diff --git a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/ethnicity.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/ethnicity.java
index 955f16c..5d730df 100644
--- a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/ethnicity.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/ethnicity.java
@@ -1,22 +1,5 @@
 /**
- * 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.10.0)
+ * Autogenerated by Thrift Compiler (0.12.0)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -24,14 +7,13 @@
 package org.apache.custos.profile.model.user;
 
 
-import org.apache.thrift.TEnum;
-
 /**
  * Hispanic or Latino - a person of Mexican, Puerto Rican, Cuban, South or
  *  Central American, or other Spanish culture or origin, regardless of race.
  * 
  */
-public enum ethnicity implements TEnum {
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-12")
+public enum ethnicity implements org.apache.thrift.TEnum {
   HISPANIC_LATINO(0),
   NOT_HISPANIC_LATINO(1);
 
@@ -52,6 +34,7 @@ public enum ethnicity implements TEnum {
    * Find a the enum type by its integer value, as defined in the Thrift IDL.
    * @return null if the value is not found.
    */
+  @org.apache.thrift.annotation.Nullable
   public static ethnicity findByValue(int value) { 
     switch (value) {
       case 0:
diff --git a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/race.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/race.java
index 3bc91aa..6f86f51 100644
--- a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/race.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/race.java
@@ -1,22 +1,5 @@
 /**
- * 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.10.0)
+ * Autogenerated by Thrift Compiler (0.12.0)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -24,8 +7,6 @@
 package org.apache.custos.profile.model.user;
 
 
-import org.apache.thrift.TEnum;
-
 /**
  * * Asian - a person having origins in any of the original peoples of the Far East,
  * *      Southeast Asia, or the Indian subcontinent including, for example, Cambodia,
@@ -41,7 +22,8 @@ import org.apache.thrift.TEnum;
  * * White - a person having origins in any of the original peoples of Europe, the Middle East, or North Africa.
  * *
  */
-public enum race implements TEnum {
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-12")
+public enum race implements org.apache.thrift.TEnum {
   ASIAN(0),
   AMERICAN_INDIAN_OR_ALASKAN_NATIVE(1),
   BLACK_OR_AFRICAN_AMERICAN(2),
@@ -65,6 +47,7 @@ public enum race implements TEnum {
    * Find a the enum type by its integer value, as defined in the Thrift IDL.
    * @return null if the value is not found.
    */
+  @org.apache.thrift.annotation.Nullable
   public static race findByValue(int value) { 
     switch (value) {
       case 0:
diff --git a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/user_profile_modelConstants.java b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/user_profile_modelConstants.java
index 03b89d8..d7a5a42 100644
--- a/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/user_profile_modelConstants.java
+++ b/custos-profile-service/profile-service-model/src/main/java/org/apache/custos/profile/model/user/user_profile_modelConstants.java
@@ -1,22 +1,5 @@
 /**
- * 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.10.0)
+ * Autogenerated by Thrift Compiler (0.12.0)
  *
  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  *  @generated
@@ -28,4 +11,6 @@ public class user_profile_modelConstants {
 
   public static final String USER_PROFILE_VERSION = "1.0";
 
+  public static final String DEFAULT_ID = "DO_NOT_SET_AT_CLIENTS";
+
 }
diff --git a/ide-integration/src/main/resources/database_scripts/init/01-databases.sql b/ide-integration/src/main/resources/database_scripts/init/01-databases.sql
index 42e6d86..dabf29c 100644
--- a/ide-integration/src/main/resources/database_scripts/init/01-databases.sql
+++ b/ide-integration/src/main/resources/database_scripts/init/01-databases.sql
@@ -72,54 +72,6 @@ INSERT INTO `USER_PROFILE` VALUES ('default-admin@default','default-admin','defa
 /*!40000 ALTER TABLE `USER_PROFILE` ENABLE KEYS */;
 UNLOCK TABLES;
 
-
---
--- Table structure for table `CUSTOMIZED_DASHBOARD`
---
-
-DROP TABLE IF EXISTS `CUSTOMIZED_DASHBOARD`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `CUSTOMIZED_DASHBOARD` (
-  `CUSTOS_INTERNAL_USER_ID` varchar(255) NOT NULL,
-  `ENABLED_EXPERIMENT_ID` varchar(255) DEFAULT NULL,
-  `ENABLED_NAME` varchar(255) DEFAULT NULL,
-  `ENABLED_DESCRIPTION` varchar(255) DEFAULT NULL,
-  `ENABLED_PROJECT` varchar(255) DEFAULT NULL,
-  `ENABLED_OWNER` varchar(255) DEFAULT NULL,
-  `ENABLED_APPLICATION` varchar(255) DEFAULT NULL,
-  `ENABLED_COMPUTE_RESOURCE` varchar(255) DEFAULT NULL,
-  `ENABLED_JOB_NAME` varchar(255) DEFAULT NULL,
-  `ENABLED_JOB_ID` varchar(255) DEFAULT NULL,
-  `ENABLED_JOB_STATUS` varchar(255) DEFAULT NULL,
-  `ENABLED_JOB_CREATION_TIME` varchar(255) DEFAULT NULL,
-  `ENABLED_NOTIFICATIONS_TO` varchar(255) DEFAULT NULL,
-  `ENABLED_WORKING_DIR` varchar(255) DEFAULT NULL,
-  `ENABLED_JOB_DESCRIPTION` varchar(255) DEFAULT NULL,
-  `ENABLED_CREATION_TIME` varchar(255) DEFAULT NULL,
-  `ENABLED_LAST_MODIFIED_TIME` varchar(255) DEFAULT NULL,
-  `ENABLED_WALL_TIME` varchar(255) DEFAULT NULL,
-  `ENABLED_CPU_COUNT` varchar(255) DEFAULT NULL,
-  `ENABLED_NODE_COUNT` varchar(255) DEFAULT NULL,
-  `ENABLED_QUEUE` varchar(255) DEFAULT NULL,
-  `ENABLED_INPUTS` varchar(255) DEFAULT NULL,
-  `ENABLED_OUTPUTS` varchar(255) DEFAULT NULL,
-  `ENABLED_STORAGE_DIR` varchar(255) DEFAULT NULL,
-  `ENABLED_ERRORS` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`CUSTOS_INTERNAL_USER_ID`),
-  CONSTRAINT `customized_dashboard_ibfk_1` FOREIGN KEY (`CUSTOS_INTERNAL_USER_ID`) REFERENCES `USER_PROFILE` (`CUSTOS_INTERNAL_USER_ID`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `CUSTOMIZED_DASHBOARD`
---
-
-LOCK TABLES `CUSTOMIZED_DASHBOARD` WRITE;
-/*!40000 ALTER TABLE `CUSTOMIZED_DASHBOARD` DISABLE KEYS */;
-/*!40000 ALTER TABLE `CUSTOMIZED_DASHBOARD` ENABLE KEYS */;
-UNLOCK TABLES;
-
 --
 -- Table structure for table `GATEWAY`
 --
diff --git a/pom.xml b/pom.xml
index 6979179..63c9887 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,6 +22,7 @@
         <module>custos-authentication</module>
         <module>custos-profile-service</module>
         <module>custos-connectors</module>
+        <module>custos-sharing-registry-service</module>
     </modules>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/thrift-interfaces/profile-service/data-models/user-tenant-group-models/user_profile_model.thrift b/thrift-interfaces/profile-service/data-models/user-tenant-group-models/user_profile_model.thrift
index 808c5d9..3184f1f 100644
--- a/thrift-interfaces/profile-service/data-models/user-tenant-group-models/user_profile_model.thrift
+++ b/thrift-interfaces/profile-service/data-models/user-tenant-group-models/user_profile_model.thrift
@@ -108,39 +108,6 @@ struct NSFDemographics {
 }
 
 /**
- * A structure holding the cutomized admin dashboard information.
- *
- *
-*/
-struct CustomDashboard {
-    1: required string custosInternalUserId = DEFAULT_ID,
-    2: optional string experimentId,
-    3: optional string name,
-    4: optional string description,
-    5: optional string project,
-    6: optional string owner,
-    7: optional string application,
-    8: optional string computeResource,
-    9: optional string jobName,
-    10: optional string jobId,
-    11: optional string jobStatus,
-    12: optional string jobCreationTime,
-    13: optional string notificationsTo,
-    14: optional string workingDir,
-    15: optional string jobDescription,
-    16: optional string creationTime,
-    17: optional string lastModifiedTime,
-    18: optional string wallTime,
-    19: optional string cpuCount,
-    20: optional string nodeCount,
-    21: optional string queue,
-    22: optional string inputs,
-    23: optional string outputs,
-    24: optional string storageDir,
-    25: optional string errors
-}
-
-/**
  * A structure holding the user profile and its child models.
  *
  * Notes:
@@ -224,6 +191,5 @@ struct UserProfile {
     22: optional list<string> labeledURI,
     23: optional string gpgKey,
     24: optional string timeZone,
-    25: optional NSFDemographics nsfDemographics,
-    26: optional CustomDashboard customDashboard
+    25: optional NSFDemographics nsfDemographics
 }
\ No newline at end of file


[airavata-custos] 47/48: Added validations and refactored exception handling for sharing service

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 240a19b7fb45d9da8262225febccc9bdb68c952c
Merge: 409ac82 7fee0b2
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Thu Sep 5 13:06:12 2019 -0400

    Added validations and refactored exception handling for sharing service

 .../service/api/controllers/DomainsController.java |  28 +-
 .../service/api/controllers/EntityController.java  |  27 +-
 .../api/controllers/EntityTypeController.java      |  41 +--
 .../service/api/controllers/GroupController.java   | 135 ++-----
 .../api/controllers/PermissionTypeController.java  |  40 +--
 .../service/api/controllers/UsersController.java   |  36 +-
 .../src/main/resources/application.properties      |   3 +-
 .../core/exceptions/InvalidRequestException.java   |  16 +
 .../custos/sharing/service/core/models/Domain.java |   2 +-
 .../core/service/SharingRegistryService.java       | 396 ++++++++++++++++-----
 pom.xml                                            |   5 +
 11 files changed, 399 insertions(+), 330 deletions(-)


[airavata-custos] 14/48: added custos tenant profile

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 21e80c770c325f640290b04433ac0f239b74b8bc
Author: Aarushi <aa...@gmail.com>
AuthorDate: Fri Aug 9 12:26:02 2019 -0400

    added custos tenant profile
---
 custos-client/pom.xml                              |    16 +-
 .../service/AuthenticationServiceClient.java       |     2 +-
 .../service/CustosProfileServiceClientFactory.java |    77 +
 .../custos/commons/utils/ApplicationSettings.java  |    21 +-
 .../apache/custos/commons/utils/DBInitConfig.java  |    33 +
 .../apache/custos/commons/utils/DBInitializer.java |    71 +
 .../org/apache/custos/commons/utils/DBUtil.java    |   306 +
 .../custos/commons/utils/DatabaseCreator.java      |   378 +
 .../apache/custos/commons/utils/JDBCConfig.java    |    29 +
 .../org/apache/custos/commons/utils/JPAUtils.java  |    67 +
 .../custos/commons/utils/ServerSettings.java       |    36 +-
 custos-connectors/pom.xml                          |    48 +-
 .../manager/KeyCloakSecurityManager.java           |     2 -
 .../iam-admin-services}/pom.xml                    |    13 +-
 .../client/CustosIamAdminServiceClient.java        |    48 +
 .../services/core/TenantManagementInterface.java   |   206 +
 .../core/TenantManagementKeycloakImpl.java         |   815 +
 .../iam/admin/services/cpi/IamAdminServices.java   | 17956 +++++++++++++++++++
 .../cpi/exception/IamAdminServicesException.java   |   381 +
 .../cpi/iam_admin_services_cpiConstants.java       |    16 +
 .../services/handler/IamAdminServicesHandler.java  |   296 +
 custos-profile-service/pom.xml                     |    26 +
 .../profile-service-commons/pom.xml                |   124 +
 .../commons/repositories/AbstractRepository.java   |   124 +
 .../commons/tenant/entities/GatewayEntity.java     |   285 +
 .../user/entities/CustomizedDashboardEntity.java   |   325 +
 .../user/entities/NSFDemographicsEntity.java       |   108 +
 .../commons/user/entities/UserProfileEntity.java   |   345 +
 .../custos/profile/commons/utils/Committer.java    |    27 +
 .../custos/profile/commons/utils/JPAConstants.java |    34 +
 .../custos/profile/commons/utils/JPAUtils.java     |    53 +
 .../commons/utils/ObjectMapperSingleton.java       |    39 +
 .../commons/utils/ProfileServiceJDBCConfig.java    |    51 +
 .../profile/commons/utils/QueryConstants.java      |    36 +
 .../apache/custos/profile/commons/utils/Utils.java |   122 +
 .../src/main/resources/META-INF/persistence.xml    |    36 +
 .../profile-service-model/pom.xml                  |    15 +
 .../profile/model/tenant/PasswordCredential.java   |   996 +
 .../apache/custos/profile/model/tenant/Tenant.java |  1543 ++
 .../profile/model/tenant/TenantApprovalStatus.java |    78 +
 .../custos/profile/model/tenant/TenantConfig.java  |   699 +
 .../profile/model/tenant/TenantPreferences.java    |   594 +
 .../custos/profile/model/user/CustomDashboard.java |  2912 +++
 .../custos/profile/model/user/NSFDemographics.java |  1085 ++
 .../apache/custos/profile/model/user/Status.java   |    96 +
 .../custos/profile/model/user/USCitizenship.java   |    67 +
 .../custos/profile/model/user/UserProfile.java     |  3221 ++++
 .../custos/profile/model/user/disability.java      |    66 +
 .../custos/profile/model/user/ethnicity.java       |    65 +
 .../org/apache/custos/profile/model/user/race.java |    84 +
 .../model/user/user_profile_modelConstants.java    |    31 +
 .../custos/profile/model/workspace/Gateway.java    |  2383 +++
 .../model/workspace/GatewayApprovalStatus.java     |    78 +
 .../profile-service-server}/pom.xml                |    20 +-
 .../profile/server/ProfileServiceServer.java       |   197 +
 .../src/main/resources/log4j.properties            |    34 +
 .../tenant-profile-service}/pom.xml                |    20 +-
 .../tenant/core/TenantProfileRepository.java       |   104 +
 .../profile/tenant/cpi/TenantProfileService.java   |  9934 ++++++++++
 .../exception/TenantProfileServiceException.java   |   370 +
 .../tenant/cpi/profile_tenant_cpiConstants.java    |    16 +
 .../handler/TenantProfileServiceHandler.java       |   193 +
 .../user-profile-service}/pom.xml                  |    30 +-
 .../exceptions/UserProfileRegistryException.java   |    28 +
 .../core/repositories/UserProfileRepository.java   |   129 +
 .../core/utils/UserProfileCatalogDBInitConfig.java |    42 +
 .../core/utils/UserProfileCatalogJDBCConfig.java   |    52 +
 .../profile/user/cpi/UserProfileService.java       |  9611 ++++++++++
 .../cpi/exception/UserProfileServiceException.java |   370 +
 .../user/cpi/profile_user_cpiConstants.java        |    16 +
 .../user/handler/UserProfileServiceHandler.java    |   239 +
 ide-integration/log4j.properties                   |    34 +
 ide-integration/pom.xml                            |    10 +
 .../src/main/java/CustosAPIServerStarted.java      |     6 +
 .../src/main/resources/custos-server.properties    |    18 +
 .../database_scripts/init/01-databases.sql         |   355 +
 .../user-profile-catalog-derby.sql                 |   163 +
 .../user-profile-catalog-mysql.sql                 |   163 +
 .../src/main/resources/docker-compose.yml          |    14 +-
 .../src/main/resources/keystores/airavata.jks      |   Bin 0 -> 2679 bytes
 .../src/main/resources/keystores/airavata_sym.jks  |   Bin 0 -> 501 bytes
 .../main/resources/keystores/client_truststore.jks |   Bin 0 -> 1027 bytes
 log4j.properties                                   |    34 +
 pom.xml                                            |    38 +-
 .../tenant_profile_model.thrift                    |    73 +
 .../user_profile_model.thrift                      |   229 +
 .../workspace_model.thrift                         |    57 +
 .../iam-admin-services-cpi.thrift                  |   118 +
 .../iam_admin_services_cpi_errors.thrift           |    33 +
 .../profile-service/profile-service-cpi.thrift     |    29 +
 .../profile-tenant/profile-tenant-cpi.thrift       |    75 +
 .../profile_tenant_cpi_errors.thrift               |    33 +
 .../profile-user/profile-user-cpi.thrift           |    83 +
 .../profile-user/profile_user_cpi_errors.thrift    |    33 +
 94 files changed, 59477 insertions(+), 91 deletions(-)

diff --git a/custos-client/pom.xml b/custos-client/pom.xml
index 882305a..2c2ee4c 100644
--- a/custos-client/pom.xml
+++ b/custos-client/pom.xml
@@ -12,13 +12,25 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>profile-service-stubs</artifactId>
+            <artifactId>custos-authentication</artifactId>
             <version>1.0-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>custos-authentication</artifactId>
+            <artifactId>user-profile-service</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>iam-admin-services</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>tenant-profile-service</artifactId>
             <version>1.0-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
diff --git a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
index 4fc0444..7ef7cf4 100644
--- a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
+++ b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
@@ -8,7 +8,7 @@ import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 
-public class AuthenticationServiceClient {
+    public class AuthenticationServiceClient {
 
     public static CustosAuthenticationService.Client createAuthenticationServiceClient(String serverHost, int serverPort)  throws CustosAuthenticationServiceException {
         try {
diff --git a/custos-client/src/main/java/org/apache/custos/client/profile/service/CustosProfileServiceClientFactory.java b/custos-client/src/main/java/org/apache/custos/client/profile/service/CustosProfileServiceClientFactory.java
new file mode 100644
index 0000000..52724ef
--- /dev/null
+++ b/custos-client/src/main/java/org/apache/custos/client/profile/service/CustosProfileServiceClientFactory.java
@@ -0,0 +1,77 @@
+/**
+ *
+ * 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.custos.client.profile.service;
+
+import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants;
+import org.apache.custos.profile.tenant.cpi.TenantProfileService;
+import org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException;
+import org.apache.custos.profile.tenant.cpi.profile_tenant_cpiConstants;
+import org.apache.custos.profile.user.cpi.UserProfileService;
+import org.apache.custos.profile.user.cpi.exception.UserProfileServiceException;
+import org.apache.custos.profile.user.cpi.profile_user_cpiConstants;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TMultiplexedProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+/**
+ * Created by goshenoy on 03/08/2017.
+ */
+public class CustosProfileServiceClientFactory {
+    public static UserProfileService.Client createCustosUserProfileServiceClient(String serverHost, int serverPort)  throws UserProfileServiceException {
+        try {
+            TTransport transport = new TSocket(serverHost, serverPort);
+            transport.open();
+            TProtocol protocol = new TBinaryProtocol(transport);
+            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, profile_user_cpiConstants.USER_PROFILE_CPI_NAME);
+            return new UserProfileService.Client(multiplexedProtocol);
+        } catch (TTransportException e) {
+            throw new UserProfileServiceException(e.getMessage());
+        }
+    }
+
+    public static IamAdminServices.Client createCustosIamAdminServiceClient(String serverHost, int serverPort) throws IamAdminServicesException {
+        try {
+            TTransport transport = new TSocket(serverHost, serverPort);
+            transport.open();
+            TProtocol protocol = new TBinaryProtocol(transport);
+            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, iam_admin_services_cpiConstants.IAM_ADMIN_SERVICES_CPI_NAME);
+            return new IamAdminServices.Client(multiplexedProtocol);
+        } catch (TTransportException e) {
+            throw new IamAdminServicesException(e.getMessage());
+        }
+    }
+
+    public static TenantProfileService.Client createCustosTenantProfileServiceClient(String serverHost, int serverPort) throws TenantProfileServiceException {
+        try {
+            TTransport transport = new TSocket(serverHost, serverPort);
+            transport.open();
+            TProtocol protocol = new TBinaryProtocol(transport);
+            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, profile_tenant_cpiConstants.TENANT_PROFILE_CPI_NAME);
+            return new TenantProfileService.Client(multiplexedProtocol);
+        } catch (TTransportException e) {
+            throw new TenantProfileServiceException(e.getMessage());
+        }
+    }
+}
\ No newline at end of file
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
index 2233478..e494120 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
@@ -14,6 +14,7 @@ import java.util.*;
 import java.util.regex.Pattern;
 
 public class ApplicationSettings {
+    //private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
     protected static ApplicationSettings INSTANCE;
     private Exception propertyLoadException;
     public static final String SERVER_PROPERTIES="custos-server.properties";
@@ -21,12 +22,8 @@ public class ApplicationSettings {
     public static String ADDITIONAL_SETTINGS_FILES = "external.settings";
     protected static final String TRUST_STORE_PATH="trust.store";
     protected static final String TRUST_STORE_PASSWORD="trust.store.password";
-    private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
     protected Properties properties = new Properties();
 
-    // Authentication service constants
-    public static final String AUTHENTICATION_SERVICE_SERVER_PORT = "custos.authentication.server.port";
-    public static final String AUTHENTICATION_SERVICE_SERVER_HOST = "custos.authentication.server.host";
     {
         loadProperties();
     }
@@ -34,11 +31,11 @@ public class ApplicationSettings {
         URL url = getPropertyFileURL();
         try {
             properties.load(url.openStream());
-            logger.info("Settings loaded from "+url.toString());
+            //logger.info("Settings loaded from "+url.toString());
             URL[] externalSettingsFileURLs = getExternalSettingsFileURLs();
             for (URL externalSettings : externalSettingsFileURLs) {
                 mergeSettingsImpl(externalSettings.openStream());
-                logger.info("External settings merged from "+url.toString());
+                //logger.info("External settings merged from "+url.toString());
             }
         } catch (Exception e) {
             propertyLoadException=e;
@@ -57,7 +54,7 @@ public class ApplicationSettings {
             for (String externalSettingFile : externalSettingFiles) {
                 URL externalSettingFileURL = ApplicationSettings.loadFile(externalSettingFile);
                 if (externalSettingFileURL==null){
-                    logger.warn("Could not file external settings file "+externalSettingFile);
+                    //logger.warn("Could not file external settings file "+externalSettingFile);
                 }else{
                     externalSettingsFileURLs.add(externalSettingFileURL);
                 }
@@ -84,7 +81,7 @@ public class ApplicationSettings {
                     return asfile.toURI().toURL();
                 }
             } catch (MalformedURLException e) {
-                logger.error("Error parsing the file from custos.config.dir", custosConfigDir);
+                //logger.error("Error parsing the file from custos.config.dir", custosConfigDir);
             }
         }
 
@@ -117,7 +114,7 @@ public class ApplicationSettings {
                 throw new ApplicationSettingsException(url.getPath(), e);
             }
         }else{
-            logger.warn("Properties cannot be updated to location "+url.toString());
+            //logger.warn("Properties cannot be updated to location "+url.toString());
         }
     }
     private String getSettingImpl(String key, String defaultValue){
@@ -162,10 +159,4 @@ public class ApplicationSettings {
             throw new ApplicationSettingsException(propertyLoadException.getMessage(), propertyLoadException);
         }
     }
-    public static String getTrustStorePath() throws ApplicationSettingsException {
-        return getSetting(TRUST_STORE_PATH);
-    }
-    public static String getTrustStorePassword() throws ApplicationSettingsException {
-        return getSetting(TRUST_STORE_PASSWORD);
-    }
 }
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitConfig.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitConfig.java
new file mode 100644
index 0000000..123541a
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitConfig.java
@@ -0,0 +1,33 @@
+/*
+ * 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.custos.commons.utils;
+
+public interface DBInitConfig {
+    JDBCConfig getJDBCConfig();
+
+    String getDBInitScriptPrefix();
+
+    String getCheckTableName();
+
+    default void postInit() {
+
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitializer.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitializer.java
new file mode 100644
index 0000000..6e2038c
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitializer.java
@@ -0,0 +1,71 @@
+/*
+ * 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.custos.commons.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Connection;
+
+public class DBInitializer {
+    private static final Logger logger = LoggerFactory.getLogger(DBInitializer.class);
+
+    private JDBCConfig jdbcConfig;
+    private String initScriptPrefix;
+    private String checkTableName;
+
+    public DBInitializer(JDBCConfig jdbcConfig, String initScriptPrefix, String checkTableName) {
+        this.jdbcConfig = jdbcConfig;
+        this.initScriptPrefix = initScriptPrefix;
+        this.checkTableName = checkTableName;
+    }
+
+    public static void initializeDB(DBInitConfig dbInitConfig) {
+
+        JDBCConfig jdbcConfig = dbInitConfig.getJDBCConfig();
+        DBInitializer dbInitializer = new DBInitializer(jdbcConfig, dbInitConfig.getDBInitScriptPrefix(), dbInitConfig.getCheckTableName());
+        dbInitializer.initializeDB();
+        dbInitConfig.postInit();
+    }
+
+    public void initializeDB() {
+        // Create connection
+        Connection conn = null;
+        try {
+            DBUtil dbUtil = new DBUtil(jdbcConfig);
+            conn = dbUtil.getConnection();
+            if (!DatabaseCreator.isDatabaseStructureCreated(checkTableName, conn)) {
+                DatabaseCreator.createRegistryDatabase(initScriptPrefix, conn);
+                logger.info("New Database created from " + initScriptPrefix + " !!!");
+            } else {
+                logger.info("Table " + checkTableName + " already exists. Skipping database init script " + initScriptPrefix);
+            }
+
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to initialize database for " + initScriptPrefix, e);
+        } finally {
+            if (conn != null) {
+                DBUtil.cleanup(conn);
+            }
+        }
+
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBUtil.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBUtil.java
new file mode 100644
index 0000000..dede688
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBUtil.java
@@ -0,0 +1,306 @@
+/**
+ *
+ * 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.custos.commons.utils;
+import org.apache.commons.dbcp.BasicDataSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sql.DataSource;
+import java.sql.*;
+import java.util.Properties;
+
+/**
+ * Database lookup. Abstracts out JDBC operations.
+ */
+public class DBUtil {
+
+    private String jdbcUrl;
+    private String databaseUserName;
+    private String databasePassword;
+    private String driverName;
+
+    protected static Logger log = LoggerFactory.getLogger(DBUtil.class);
+
+    private Properties properties;
+
+    public DBUtil(String jdbcUrl, String userName, String password, String driver) throws InstantiationException,
+            IllegalAccessException, ClassNotFoundException {
+
+        this.jdbcUrl = jdbcUrl;
+        this.databaseUserName = userName;
+        this.databasePassword = password;
+        this.driverName = driver;
+
+        init();
+    }
+
+    public DBUtil(JDBCConfig jdbcConfig) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+        this(jdbcConfig.getURL(), jdbcConfig.getUser(), jdbcConfig.getPassword(), jdbcConfig.getDriver());
+    }
+
+    /**
+     * Initializes and load driver. Must be called this before calling anyother method.
+     * 
+     * @throws ClassNotFoundException
+     *             If DB driver is not found.
+     * @throws InstantiationException
+     *             If unable to create driver class.
+     * @throws IllegalAccessException
+     *             If security does not allow users to instantiate driver object.
+     */
+    private void init() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+        properties = new Properties();
+
+        properties.put("user", databaseUserName);
+        properties.put("password", databasePassword);
+        properties.put("characterEncoding", "ISO-8859-1");
+        properties.put("useUnicode", "true");
+
+        loadDriver();
+    }
+
+    /**
+     * Generic method to query values in the database.
+     * 
+     * @param tableName
+     *            Table name to query
+     * @param selectColumn
+     *            The column selecting
+     * @param whereValue
+     *            The condition query
+     * @return The value appropriate to the query.
+     * @throws SQLException
+     *             If an error occurred while querying
+     */
+    public String getMatchingColumnValue(String tableName, String selectColumn, String whereValue) throws SQLException {
+        return getMatchingColumnValue(tableName, selectColumn, selectColumn, whereValue);
+    }
+
+    /**
+     * Generic method to query values in the database.
+     * 
+     * @param tableName
+     *            Table name to query
+     * @param selectColumn
+     *            The column selecting
+     * @param whereColumn
+     *            The column which condition should apply
+     * @param whereValue
+     *            The condition query
+     * @return The value appropriate to the query.
+     * @throws SQLException
+     *             If an error occurred while querying
+     */
+    public String getMatchingColumnValue(String tableName, String selectColumn, String whereColumn, String whereValue)
+            throws SQLException {
+
+        StringBuilder stringBuilder = new StringBuilder();
+
+        stringBuilder.append("SELECT ").append(selectColumn).append(" FROM ").append(tableName).append(" WHERE ")
+                .append(whereColumn).append(" = ?");
+
+        String sql = stringBuilder.toString();
+
+        Connection connection = getConnection();
+
+        PreparedStatement ps = connection.prepareStatement(sql);
+        ResultSet rs = null;
+
+        try {
+            ps.setString(1, whereValue);
+            rs = ps.executeQuery();
+
+            if (rs.next()) {
+                return rs.getString(1);
+            }
+
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+
+                ps.close();
+                connection.close();
+
+            } catch (Exception ignore) {
+                log.error("An error occurred while closing database connections ", ignore);
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Create table utility method.
+     * 
+     * @param sql
+     *            SQL to be executed.
+     * @throws SQLException
+     *             If an error occurred while creating the table.
+     */
+    public void executeSQL(String sql) throws SQLException {
+
+        Connection connection = getConnection();
+
+        PreparedStatement ps = connection.prepareStatement(sql);
+
+        try {
+            ps.executeUpdate();
+            connection.commit();
+        } finally {
+            try {
+                if (ps != null) {
+                    ps.close();
+                }
+
+                connection.close();
+
+            } catch (Exception ignore) {
+                log.error("An error occurred while closing database connections ", ignore);
+            }
+        }
+
+    }
+
+    private void loadDriver() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+        Class.forName(driverName).newInstance();
+    }
+
+    /**
+     * Gets a new DBCP data source.
+     * 
+     * @return A new data source.
+     */
+    public DataSource getDataSource() {
+        BasicDataSource ds = new BasicDataSource();
+        ds.setDriverClassName(this.driverName);
+        ds.setUsername(this.databaseUserName);
+        ds.setPassword(this.databasePassword);
+        ds.setUrl(this.jdbcUrl);
+
+        return ds;
+    }
+
+    /**
+     * Creates a new JDBC connections based on provided DBCP properties.
+     * 
+     * @return A new DB connection.
+     * @throws SQLException
+     *             If an error occurred while creating the connection.
+     */
+    public Connection getConnection() throws SQLException {
+        Connection connection = DriverManager.getConnection(jdbcUrl, properties);
+        connection.setAutoCommit(false);
+        return connection;
+    }
+
+    /**
+     * Utility method to close statements and connections.
+     * 
+     * @param preparedStatement
+     *            The prepared statement to close.
+     * @param connection
+     *            The connection to close.
+     */
+    public static void cleanup(PreparedStatement preparedStatement, Connection connection) {
+        if (preparedStatement != null) {
+            try {
+                preparedStatement.close();
+            } catch (SQLException e) {
+                log.error("Error closing prepared statement.", e);
+            }
+        }
+        cleanup(connection);
+    }
+
+    /**
+     * Utility method to close statements and connections.
+     *
+     * @param preparedStatement
+     *            The prepared statement to close.
+     */
+    public static void cleanup(PreparedStatement preparedStatement) {
+        if (preparedStatement != null) {
+            try {
+                preparedStatement.close();
+            } catch (SQLException e) {
+                log.error("Error closing prepared statement.", e);
+            }
+        }
+    }
+
+    /**
+     * Utility method to close statements and connections.
+     *
+     * @param preparedStatement
+     *            The prepared statement to close.
+     */
+    public static void cleanup(PreparedStatement preparedStatement, ResultSet resultSet) {
+        if (resultSet != null) {
+            try {
+                resultSet.close();
+            } catch (SQLException e) {
+                log.error("Error closing prepared statement.", e);
+            }
+        }
+
+        cleanup(preparedStatement);
+    }
+
+    /**
+     * Cleanup the connection.
+     * @param connection The connection to close.
+     */
+    public static void cleanup(Connection connection) {
+        if (connection != null) {
+            try {
+                if (connection.isClosed()) {
+                    return;
+                }
+                if (!connection.getAutoCommit()) {
+                    connection.rollback();
+                }
+                connection.close();
+            } catch (SQLException e) {
+                throw new RuntimeException("Error closing connection", e);
+            }
+        }
+    }
+
+    /**
+     * Mainly useful for tests.
+     * 
+     * @param tableName
+     *            The table name.
+     * @param connection
+     *            The connection to be used.
+     */
+    public static void truncate(String tableName, Connection connection) throws SQLException {
+
+        String sql = "delete from " + tableName;
+
+        PreparedStatement preparedStatement = connection.prepareStatement(sql);
+        preparedStatement.executeUpdate();
+
+        connection.commit();
+
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DatabaseCreator.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DatabaseCreator.java
new file mode 100644
index 0000000..5340bf4
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/DatabaseCreator.java
@@ -0,0 +1,378 @@
+/*
+ * 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.custos.commons.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.*;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * This class creates the database tables required for airavata with default configuration this
+ * class creates derby database in server mode. User can specify required database in appropriate
+ * properties files.
+ */
+public class DatabaseCreator {
+    private final static Logger logger = LoggerFactory.getLogger(DatabaseCreator.class);
+
+    public enum DatabaseType {
+        derby("(?i).*derby.*"), mysql("(?i).*(mysql|mariadb).*"), other("");
+
+        private String pattern;
+
+        private DatabaseType(String matchingPattern) {
+            this.pattern = matchingPattern;
+        }
+
+        public String getMatchingPattern() {
+            return this.pattern;
+        }
+    }
+
+    private static DatabaseType[] supportedDatabase = new DatabaseType[] { DatabaseType.derby, DatabaseType.mysql };
+
+    private static Logger log = LoggerFactory.getLogger(DatabaseCreator.class);
+    private static final String delimiter = ";";
+
+    /**
+     * Creates database
+     *
+     * @throws Exception
+     */
+    public static void createRegistryDatabase(String prefix, Connection conn) throws Exception {
+        createDatabase(prefix, conn);
+    }
+
+
+
+    /**
+     * Checks whether database tables are created by using select * on given table name
+     *
+     * @param tableName
+     *            Table which should be existed
+     * @return <code>true</core> if checkSQL is success, else <code>false</code> .
+     */
+    public static boolean isDatabaseStructureCreated(String tableName, Connection conn) {
+        try {
+
+            log.debug("Running a query to test the database tables existence.");
+
+            // check whether the tables are already created with a query
+            Statement statement = null;
+            try {
+                statement = conn.createStatement();
+                ResultSet rs = statement.executeQuery("select * from " + tableName);
+                if (rs != null) {
+                    rs.close();
+                }
+            } finally {
+                try {
+                    if (statement != null) {
+                        statement.close();
+                    }
+                } catch (SQLException e) {
+                    return false;
+                }
+            }
+        } catch (SQLException e) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * executes given sql
+     *
+     * @param sql
+     * @throws Exception
+     */
+    private static void executeSQL(String sql, Connection conn) throws Exception {
+        // Check and ignore empty statements
+        if ("".equals(sql.trim())) {
+            return;
+        }
+
+        Statement statement = null;
+        try {
+            log.debug("SQL : " + sql);
+
+            boolean ret;
+            int updateCount = 0, updateCountTotal = 0;
+            statement = conn.createStatement();
+            ret = statement.execute(sql);
+            updateCount = statement.getUpdateCount();
+            do {
+                if (!ret) {
+                    if (updateCount != -1) {
+                        updateCountTotal += updateCount;
+                    }
+                }
+                ret = statement.getMoreResults();
+                if (ret) {
+                    updateCount = statement.getUpdateCount();
+                }
+            } while (ret);
+
+            log.debug(sql + " : " + updateCountTotal + " rows affected");
+
+            SQLWarning warning = conn.getWarnings();
+            while (warning != null) {
+                log.info(warning + " sql warning");
+                warning = warning.getNextWarning();
+            }
+            conn.clearWarnings();
+        } catch (SQLException e) {
+            if (e.getSQLState().equals("X0Y32")) {
+                // eliminating the table already exception for the derby
+                // database
+                log.info("Table Already Exists", e);
+            } else {
+                throw new Exception("Error occurred while executing : " + sql, e);
+            }
+        } finally {
+            if (statement != null) {
+                try {
+                    statement.close();
+                } catch (SQLException e) {
+                    log.error("Error occurred while closing result set.", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * computes relatational database type using database name
+     *
+     * @return DatabaseType
+     * @throws Exception
+     *
+     */
+    public static DatabaseType getDatabaseType(Connection conn) throws Exception {
+        try {
+            if (conn != null && (!conn.isClosed())) {
+                DatabaseMetaData metaData = conn.getMetaData();
+                String databaseProductName = metaData.getDatabaseProductName();
+                return checkType(databaseProductName);
+            }
+        } catch (SQLException e) {
+            String msg = "Failed to create Airavata database." + e.getMessage();
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+        return DatabaseType.other;
+    }
+
+    /**
+     * Overloaded method with String input
+     *
+     * @return DatabaseType
+     * @throws Exception
+     *
+     */
+    public static DatabaseType getDatabaseType(String dbUrl) throws Exception {
+        return checkType(dbUrl);
+    }
+
+    private static DatabaseType checkType(String text) throws Exception {
+        try {
+            if (text != null) {
+                for (DatabaseType type : supportedDatabase) {
+                    if (text.matches(type.getMatchingPattern()))
+                        return type;
+                }
+            }
+            String msg = "Unsupported database: " + text
+                    + ". Database will not be created automatically by the Airavata. "
+                    + "Please create the database using appropriate database scripts for " + "the database.";
+            throw new Exception(msg);
+
+        } catch (SQLException e) {
+            String msg = "Failed to create Airavatadatabase." + e.getMessage();
+            log.error(msg, e);
+            throw new Exception(msg, e);
+        }
+    }
+
+    /**
+     * Get scripts location which is prefix + "-" + databaseType + ".sql"
+     *
+     * @param prefix
+     * @param databaseType
+     * @return script location
+     */
+    private static String getScriptLocation(String prefix, DatabaseType databaseType) {
+        String scriptName = prefix + "-" + databaseType + ".sql";
+        log.debug("Loading database script from :" + scriptName);
+        return  scriptName;
+    }
+
+    private static void createDatabase(String prefix, Connection conn) throws Exception {
+        Statement statement = null;
+        try {
+            conn.setAutoCommit(false);
+            statement = conn.createStatement();
+            executeSQLScript(getScriptLocation(prefix, DatabaseCreator.getDatabaseType(conn)), conn);
+            conn.commit();
+            log.debug("Tables are created successfully.");
+        } catch (SQLException e) {
+            String msg = "Failed to create database tables for Airavata resource store. " + e.getMessage();
+            log.error(msg, e);
+            conn.rollback();
+            throw new Exception(msg, e);
+        } finally {
+            conn.setAutoCommit(true);
+            try {
+                if (statement != null) {
+                    statement.close();
+                }
+            } catch (SQLException e) {
+                log.error("Failed to close statement.", e);
+            }
+        }
+    }
+
+    private static void executeSQLScript(String dbscriptName, Connection conn) throws Exception {
+        StringBuffer sql = new StringBuffer();
+        BufferedReader reader = null;
+
+        try {
+            InputStream is = DatabaseCreator.class.getClassLoader().getResourceAsStream(dbscriptName);
+            if(is == null) {
+                logger.info("Script file not found at " + dbscriptName + ". Uses default database script file");
+                DatabaseType databaseType = DatabaseCreator.getDatabaseType(conn);
+                is = DatabaseCreator.class.getClassLoader().getResourceAsStream(
+                        getDBScriptFileName(databaseType, dbscriptName)
+                );
+            }
+            reader = new BufferedReader(new InputStreamReader(is));
+            String line;
+            while ((line = reader.readLine()) != null) {
+                line = line.trim();
+                if (line.startsWith("//")) {
+                    continue;
+                }
+                if (line.startsWith("--")) {
+                    continue;
+                }
+                StringTokenizer st = new StringTokenizer(line);
+                if (st.hasMoreTokens()) {
+                    String token = st.nextToken();
+                    if ("REM".equalsIgnoreCase(token)) {
+                        continue;
+                    }
+                }
+                sql.append(" ").append(line);
+
+                // SQL defines "--" as a comment to EOL
+                // and in Oracle it may contain a hint
+                // so we cannot just remove it, instead we must end it
+                if (line.indexOf("--") >= 0) {
+                    sql.append("\n");
+                }
+                if ((checkStringBufferEndsWith(sql, delimiter))) {
+                    executeSQL(sql.substring(0, sql.length() - delimiter.length()), conn);
+                    sql.replace(0, sql.length(), "");
+                }
+            }
+            // Catch any statements not followed by ;
+            if (sql.length() > 0) {
+                executeSQL(sql.toString(), conn);
+            }
+        } catch (IOException e) {
+            log.error("Error occurred while executing SQL script for creating Airavata database", e);
+            throw new Exception("Error occurred while executing SQL script for creating Airavata database", e);
+
+        } finally {
+            if (reader != null) {
+                reader.close();
+            }
+        }
+    }
+
+    /**
+     * Checks that a string buffer ends up with a given string. It may sound trivial with the existing JDK API but the
+     * various implementation among JDKs can make those methods extremely resource intensive and perform poorly due to
+     * massive memory allocation and copying. See
+     *
+     * @param buffer
+     *            the buffer to perform the check on
+     * @param suffix
+     *            the suffix
+     * @return <code>true</code> if the character sequence represented by the argument is a suffix of the character
+     *         sequence represented by the StringBuffer object; <code>false</code> otherwise. Note that the result will
+     *         be <code>true</code> if the argument is the empty string.
+     */
+    public static boolean checkStringBufferEndsWith(StringBuffer buffer, String suffix) {
+        if (suffix.length() > buffer.length()) {
+            return false;
+        }
+        // this loop is done on purpose to avoid memory allocation performance
+        // problems on various JDKs
+        // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and
+        // implementation is ok though does allocation/copying
+        // StringBuffer.toString().endsWith() does massive memory
+        // allocation/copying on JDK 1.5
+        // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169
+        int endIndex = suffix.length() - 1;
+        int bufferIndex = buffer.length() - 1;
+        while (endIndex >= 0) {
+            if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
+                return false;
+            }
+            bufferIndex--;
+            endIndex--;
+        }
+        return true;
+    }
+
+    /**
+     * Method will accept a filepath containing a database script (eg: /user/database_scripts/expcatalog.sql)
+     *  and return only the filename of the database script (eg: expcatalog.sql).
+     * @param databaseType
+     * @param scriptFilePath
+     * @return
+     */
+    private static String getDBScriptFileName(DatabaseType databaseType, String scriptFilePath) {
+        // pattern: {dir_name}/{scriptfile_name}-{dbtype}.sql".
+        // Eg: database_scripts/expcatalog-derby.sql
+        final String scriptFilePattern = "(\\w*)(-" + databaseType.toString() + ".sql)";
+        final Pattern pattern = Pattern.compile(scriptFilePattern);
+        final Matcher matcher = pattern.matcher(scriptFilePath);
+        String dbScriptFileName = null;
+        // find a match
+        if (matcher.find()) {
+            dbScriptFileName = matcher.group();
+        }
+        return dbScriptFileName;
+    }
+
+//    public static void main(String[] args) throws Exception {
+//        System.out.println(DatabaseCreator.getDBScriptFileName(DatabaseType.derby, "db/db/expcatalog-derby.sql"));
+//        System.out.println(DatabaseCreator.getDBScriptFileName(DatabaseType.mysql, "/expcatalog-mysql.sql"));
+//    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/JDBCConfig.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/JDBCConfig.java
new file mode 100644
index 0000000..5cdb0ec
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/JDBCConfig.java
@@ -0,0 +1,29 @@
+/*
+ * 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.custos.commons.utils;
+
+public interface JDBCConfig {
+    String getURL();
+    String getDriver();
+    String getUser();
+    String getPassword();
+    String getValidationQuery();
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/JPAUtils.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/JPAUtils.java
new file mode 100644
index 0000000..9e02ce7
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/JPAUtils.java
@@ -0,0 +1,67 @@
+package org.apache.custos.commons.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * JPAUtils
+ */
+public class JPAUtils {
+
+    private final static Logger logger = LoggerFactory.getLogger(JPAUtils.class);
+    private final static Map<String, String> DEFAULT_ENTITY_MANAGER_FACTORY_PROPERTIES;
+    static {
+        Map<String, String> properties = new HashMap<String, String>();
+        properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource");
+        properties.put("openjpa.DynamicEnhancementAgent", "true");
+        properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported");
+        properties.put("openjpa.RemoteCommitProvider", "sjvm");
+        properties.put("openjpa.Log", "DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO");
+        properties.put("openjpa.jdbc.SynchronizeMappings", "validate");
+        properties.put("openjpa.jdbc.QuerySQLCache", "false");
+        properties.put("openjpa.DetachState", "all");
+        properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72,"
+                + " PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000,  autoReconnect=true");
+        DEFAULT_ENTITY_MANAGER_FACTORY_PROPERTIES = properties;
+    }
+
+    /**
+     * Create an {@link EntityManagerFactory} with the default settings.
+     * @param persistenceUnitName
+     * @param jdbcConfig
+     * @return {@link EntityManagerFactory}
+     */
+    public static EntityManagerFactory getEntityManagerFactory(String persistenceUnitName, JDBCConfig jdbcConfig){
+
+        return getEntityManagerFactory(persistenceUnitName, jdbcConfig, Collections.emptyMap());
+    }
+
+    /**
+     * Create an {@link EntityManagerFactory}. The given properties will override the default properties.
+     * @param persistenceUnitName
+     * @param jdbcConfig
+     * @param properties
+     * @return {@link EntityManagerFactory}
+     */
+    public static EntityManagerFactory getEntityManagerFactory(String persistenceUnitName, JDBCConfig jdbcConfig, Map<String, String> properties) {
+
+        Map<String, String> finalProperties = new HashMap<>(DEFAULT_ENTITY_MANAGER_FACTORY_PROPERTIES);
+        finalProperties.putAll(createConnectionProperties(jdbcConfig));
+        finalProperties.putAll(properties);
+        return Persistence.createEntityManagerFactory(persistenceUnitName, finalProperties);
+    }
+
+    private static Map<String, String> createConnectionProperties(JDBCConfig jdbcConfig) {
+        String connectionProperties = "DriverClassName=" + jdbcConfig.getDriver() + "," + "Url=" + jdbcConfig.getURL()
+                + "?autoReconnect=true," + "Username=" + jdbcConfig.getUser() + "," + "Password="
+                + jdbcConfig.getPassword() + ",validationQuery=" + jdbcConfig.getValidationQuery();
+        logger.debug("Connection properties={}", connectionProperties);
+        return Collections.singletonMap("openjpa.ConnectionProperties", connectionProperties);
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
index 642f37e..7397d51 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
@@ -31,6 +31,13 @@ public class ServerSettings extends ApplicationSettings {
     public static final String IAM_SERVER_SUPER_ADMIN_USERNAME = "iam.server.super.admin.username";
     public static final String IAM_SERVER_SUPER_ADMIN_PASSWORD = "iam.server.super.admin.password";
 
+    // Authentication service constants
+    public static final String AUTHENTICATION_SERVICE_SERVER_PORT = "custos.authentication.server.port";
+    public static final String AUTHENTICATION_SERVICE_SERVER_HOST = "custos.authentication.server.host";
+
+    // Profile Service Constants
+    public static final String PROFILE_SERVICE_SERVER_HOST = "profile.service.server.host";
+    public static final String PROFILE_SERVICE_SERVER_PORT = "profile.service.server.port";
 
     public static int getCacheSize() throws ApplicationSettingsException {
         return Integer.valueOf(getSetting(Constants.IN_MEMORY_CACHE_SIZE));
@@ -43,22 +50,43 @@ public class ServerSettings extends ApplicationSettings {
         return getSetting(Constants.SECURITY_MANAGER_CLASS);
     }
     public static String getRemoteIDPServiceUrl() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.IAM_SERVER_URL);
+        return getSetting(IAM_SERVER_URL);
     }
     public static boolean isAuthzCacheEnabled() throws ApplicationSettingsException {
         return Boolean.valueOf(getSetting(Constants.AUTHZ_CACHE_ENABLED));
     }
     public static  String getAuthenticationServerPort() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.AUTHENTICATION_SERVICE_SERVER_PORT);
+        return getSetting(AUTHENTICATION_SERVICE_SERVER_PORT);
     }
     public static  String getAuthenticationServerHost() throws ApplicationSettingsException {
-        return getSetting(ServerSettings.AUTHENTICATION_SERVICE_SERVER_HOST);
+        return getSetting(AUTHENTICATION_SERVICE_SERVER_HOST);
     }
     public static String getKeyStorePath() throws ApplicationSettingsException {
         return getSetting(Constants.KEYSTORE_PATH);
     }
-
     public static String getKeyStorePassword() throws ApplicationSettingsException {
         return getSetting(Constants.KEYSTORE_PASSWORD);
     }
+    public static String getIamServerUrl() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.IAM_SERVER_URL);
+    }
+    public static String getTrustStorePath() throws ApplicationSettingsException {
+        return getSetting(TRUST_STORE_PATH);
+    }
+    public static String getTrustStorePassword() throws ApplicationSettingsException {
+        return getSetting(TRUST_STORE_PASSWORD);
+    }
+    public static String getIamServerSuperAdminUsername() throws ApplicationSettingsException{
+        return getSetting(IAM_SERVER_SUPER_ADMIN_USERNAME);
+    }
+    public static String getIamServerSuperAdminPassword() throws ApplicationSettingsException{
+        return getSetting(IAM_SERVER_SUPER_ADMIN_PASSWORD);
+    }
+    public static String getProfileServiceServerHost() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_HOST);
+    }
+    public static String getProfileServiceServerPort() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_PORT);
+    }
+
 }
diff --git a/custos-connectors/pom.xml b/custos-connectors/pom.xml
index 7b6ae79..f3ab17d 100644
--- a/custos-connectors/pom.xml
+++ b/custos-connectors/pom.xml
@@ -21,6 +21,11 @@
             <version>1.0-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>profile-service-model</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
             <groupId>com.google.inject</groupId>
             <artifactId>guice</artifactId>
             <version>4.0</version>
@@ -31,10 +36,45 @@
             <version>20131018</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>profile-service-stubs</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>3.1</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.2</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+            <version>2.0.1</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-client -->
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-client</artifactId>
+            <version>3.0.14.Final</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jackson2-provider -->
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jackson2-provider</artifactId>
+            <version>3.0.14.Final</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.5.4</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.keycloak/keycloak-admin-client -->
+        <dependency>
+            <groupId>org.keycloak</groupId>
+            <artifactId>keycloak-admin-client</artifactId>
+            <version>2.5.5.Final</version>
         </dependency>
     </dependencies>
 
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
index 6665c3f..3550f4f 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
@@ -26,7 +26,6 @@ import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.model.security.UserInfo;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.profile.tenant.cpi.TenantProfileService;
 import org.apache.custos.security.authzcache.*;
 import org.apache.custos.security.utils.TrustStoreManager;
 import org.apache.http.Consts;
@@ -55,7 +54,6 @@ import java.util.List;
 
 public class KeyCloakSecurityManager implements CustosSecurityManager {
     private final static Logger logger = LoggerFactory.getLogger(KeyCloakSecurityManager.class);
-    private TenantProfileService.Client tenantProfileClient = null;
     public KeyCloakSecurityManager() throws CustosSecurityException {
         initializeSecurityInfra();
     }
diff --git a/ide-integration/pom.xml b/custos-profile-service/iam-admin-services/pom.xml
similarity index 75%
copy from ide-integration/pom.xml
copy to custos-profile-service/iam-admin-services/pom.xml
index 2b945e5..e5136ae 100644
--- a/ide-integration/pom.xml
+++ b/custos-profile-service/iam-admin-services/pom.xml
@@ -3,27 +3,26 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>custos</artifactId>
+        <artifactId>custos-profile-service</artifactId>
         <groupId>org.apache.custos</groupId>
         <version>1.0-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>ide-integration</artifactId>
+    <artifactId>iam-admin-services</artifactId>
     <dependencies>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>profile-service-server</artifactId>
+            <artifactId>profile-service-model</artifactId>
             <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-authentication</artifactId>
             <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
         </dependency>
     </dependencies>
-
-
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
 </project>
\ No newline at end of file
diff --git a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/client/CustosIamAdminServiceClient.java b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/client/CustosIamAdminServiceClient.java
new file mode 100644
index 0000000..c6594f4
--- /dev/null
+++ b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/client/CustosIamAdminServiceClient.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * 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.custos.profile.iam.admin.services.client;
+
+import org.apache.custos.profile.iam.admin.services.cpi.IamAdminServices;
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.iam.admin.services.cpi.iam_admin_services_cpiConstants;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TMultiplexedProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+/**
+ * Created by goshenoy on 03/08/2017.
+ */
+public class CustosIamAdminServiceClient {
+
+    public static IamAdminServices.Client createCustosIamAdminServiceClient(String serverHost, int serverPort) throws IamAdminServicesException {
+        try {
+            TTransport transport = new TSocket(serverHost, serverPort);
+            transport.open();
+            TProtocol protocol = new TBinaryProtocol(transport);
+            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, iam_admin_services_cpiConstants.IAM_ADMIN_SERVICES_CPI_NAME);
+            return new IamAdminServices.Client(multiplexedProtocol);
+        } catch (TTransportException e) {
+            throw new IamAdminServicesException(e.getMessage());
+        }
+    }
+}
\ No newline at end of file
diff --git a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementInterface.java b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementInterface.java
new file mode 100644
index 0000000..fdd18de
--- /dev/null
+++ b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementInterface.java
@@ -0,0 +1,206 @@
+/*
+ *
+ * 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.custos.profile.iam.admin.services.core;
+
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.model.tenant.PasswordCredential;
+import org.apache.custos.profile.model.user.UserProfile;
+import org.apache.custos.profile.model.workspace.Gateway;
+
+import java.util.List;
+
+public interface TenantManagementInterface {
+
+    /**
+     * Method to add Identity server tenant for Custos gateway creation.
+     *
+     * @param isSuperAdminPasswordCreds identity server super admin credentials
+     * @param gatewayDetails gateway details from workspace catalog
+     * @return Gateway object.
+     */
+    Gateway addTenant(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException;
+
+    /**
+     * Method to add tenant Admin account in Identity Server.
+     *
+     * @param isSuperAdminPasswordCreds identity server super admin credentials
+     * @param gatewayDetails gateway details from workspace catalog
+     * @param gatewayAdminPassword password to use when creating tenant admin account
+     * @return Gateway object.
+     */
+    boolean createTenantAdminAccount(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails, String gatewayAdminPassword) throws IamAdminServicesException;
+
+    /**
+     * Method to configure application client in Identity Server
+     *
+     * @param isSuperAdminPasswordCreds identity server super admin credentials
+     * @param gatewayDetails gateway details from workspace catalog
+     * @return Gateway object.
+     */
+    Gateway configureClient(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException;
+
+    /**
+     * Check if username is available to be used for creating a new user account.
+     * @param accessToken needs to have access to searching across users by username
+     * @param tenantId
+     * @param username
+     * @return
+     */
+    boolean isUsernameAvailable(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Method to create user in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @param emailAddress
+     * @param firstName
+     * @param lastName
+     * @param newPassword
+     * @return true if user created
+     * @throws IamAdminServicesException
+     */
+    boolean createUser(String accessToken, String tenantId, String username, String emailAddress, String firstName, String lastName, String newPassword) throws IamAdminServicesException;
+
+    /**
+     * Method to enable user in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @return boolean.
+     */
+    boolean enableUserAccount(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Method to check if user is enabled in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @return boolean.
+     */
+    boolean isUserAccountEnabled(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Return whether user exists with username.
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @return
+     */
+    boolean isUserExist(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Get user profile information from Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @return
+     */
+    UserProfile getUser(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Get a paginated list of user profiles from Identity Server
+     * 
+     * @param accessToken
+     * @param tenantId
+     * @param offset
+     * @param limit
+     * @param search String - optional, if specified used to search user profiles
+     * @return
+     * @throws IamAdminServicesException
+     */
+    List<UserProfile> getUsers(String accessToken, String tenantId, int offset, int limit, String search) throws IamAdminServicesException;
+
+    /**
+     * Method to reset user password in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @param newPassword
+     * @return boolean
+     */
+    boolean resetUserPassword(String accessToken, String tenantId, String username, String newPassword) throws IamAdminServicesException;
+
+    /**
+     * Method to find user in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId required
+     * @param email required
+     * @param username can be null
+     * @return Gateway object.
+     */
+    List<UserProfile> findUser(String accessToken, String tenantId, String email, String username) throws IamAdminServicesException;
+
+    /**
+     * Update the user's profile in the Identity Server
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @param userDetails
+     */
+    void updateUserProfile(String accessToken, String tenantId, String username, UserProfile userDetails) throws IamAdminServicesException;
+
+    /**
+     * Add the given role to the user.
+     *
+     * @param realmAdminCreds
+     * @param tenantId
+     * @param username
+     * @param roleName
+     * @return
+     * @throws IamAdminServicesException
+     */
+    @Deprecated
+    boolean addRoleToUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException;
+
+    /**
+     * Remove the given role from the user.
+     *
+     * @param realmAdminCreds
+     * @param tenantId
+     * @param username
+     * @param roleName
+     * @return
+     * @throws IamAdminServicesException
+     */
+    @Deprecated
+    boolean removeRoleFromUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException;
+
+    /**
+     * Get all users having the given role.
+     *
+     * @param realmAdminCreds
+     * @param tenantId
+     * @param roleName
+     * @return
+     * @throws IamAdminServicesException
+     */
+    @Deprecated
+    List<UserProfile> getUsersWithRole(PasswordCredential realmAdminCreds, String tenantId, String roleName) throws IamAdminServicesException;
+}
diff --git a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementKeycloakImpl.java b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementKeycloakImpl.java
new file mode 100644
index 0000000..efc82c2
--- /dev/null
+++ b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/core/TenantManagementKeycloakImpl.java
@@ -0,0 +1,815 @@
+/*
+ *
+ * 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.custos.profile.iam.admin.services.core;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.utils.SecurityUtil;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.apache.custos.profile.model.tenant.PasswordCredential;
+import org.apache.custos.profile.model.user.Status;
+import org.apache.custos.profile.model.user.UserProfile;
+import org.apache.custos.profile.model.workspace.Gateway;
+import org.jboss.resteasy.client.jaxrs.ResteasyClient;
+import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
+import org.keycloak.admin.client.Keycloak;
+import org.keycloak.admin.client.KeycloakBuilder;
+import org.keycloak.admin.client.resource.RoleResource;
+import org.keycloak.admin.client.resource.UserResource;
+import org.keycloak.representations.idm.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.KeyStore;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class TenantManagementKeycloakImpl implements TenantManagementInterface {
+
+    private final static Logger logger = LoggerFactory.getLogger(TenantManagementKeycloakImpl.class);
+
+    private String superAdminRealmId = "master";
+
+    private static Keycloak getClient(String adminUrl, String realm, PasswordCredential AdminPasswordCreds) {
+
+        ResteasyClient resteasyClient = new ResteasyClientBuilder()
+                .connectionPoolSize(10)
+                .trustStore(loadKeyStore())
+                .build();
+        return KeycloakBuilder.builder()
+                .serverUrl(adminUrl)
+                .realm(realm)
+                .username(AdminPasswordCreds.getLoginUserName())
+                .password(AdminPasswordCreds.getPassword())
+                .clientId("admin-cli")
+                .resteasyClient(resteasyClient)
+                .build();
+    }
+
+    private static Keycloak getClient(String adminUrl, String realm, String accessToken) {
+
+        ResteasyClient resteasyClient = new ResteasyClientBuilder()
+                .connectionPoolSize(10)
+                .trustStore(loadKeyStore())
+                .build();
+        return KeycloakBuilder.builder()
+                .serverUrl(adminUrl)
+                .realm(realm)
+                .authorization(accessToken)
+                .resteasyClient(resteasyClient)
+                .build();
+    }
+
+    private static KeyStore loadKeyStore() {
+
+        InputStream is = null;
+        try {
+
+            String trustStorePath =  ServerSettings.getTrustStorePath();
+            File trustStoreFile = new File(trustStorePath);
+
+            if (trustStoreFile.exists()) {
+                logger.debug("Loading trust store file from path " + trustStorePath);
+                is = new FileInputStream(trustStorePath);
+            } else {
+                logger.debug("Trying to load trust store file form class path " + trustStorePath);
+                is = SecurityUtil.class.getClassLoader().getResourceAsStream(trustStorePath);
+                if (is != null) {
+                    logger.debug("Trust store file was loaded form class path " + trustStorePath);
+                }
+            }
+
+            if (is == null) {
+                throw new RuntimeException("Could not find a trust store file in path " + trustStorePath);
+            }
+
+            KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+            ks.load(is, ServerSettings.getTrustStorePassword().toCharArray());
+            return ks;
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to load trust store KeyStore instance", e);
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    logger.error("Failed to close trust store FileInputStream", e);
+                }
+            }
+        }
+    }
+
+    @Override
+    public Gateway addTenant(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException {
+        Keycloak client = null;
+        try {
+            // get client
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), this.superAdminRealmId, isSuperAdminPasswordCreds);
+            // create realm
+            RealmRepresentation newRealmDetails = new RealmRepresentation();
+            newRealmDetails.setEnabled(true);
+            newRealmDetails.setId(gatewayDetails.getGatewayId());
+            newRealmDetails.setDisplayName(gatewayDetails.getGatewayName());
+            newRealmDetails.setRealm(gatewayDetails.getGatewayId());
+            // Following two settings allow duplicate email addresses
+            newRealmDetails.setLoginWithEmailAllowed(false);
+            newRealmDetails.setDuplicateEmailsAllowed(true);
+            // Default access token lifespan to 30 minutes, SSO session idle to 60 minutes
+            newRealmDetails.setAccessTokenLifespan(1800);
+            newRealmDetails.setSsoSessionIdleTimeout(3600);
+            RealmRepresentation realmWithRoles = TenantManagementKeycloakImpl.createDefaultRoles(newRealmDetails);
+            client.realms().create(realmWithRoles);
+            return gatewayDetails;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting Iam server Url from property file, reason: " + ex.getMessage());
+            throw exception;
+        } catch (Exception ex){
+            logger.error("Error creating Realm in Keycloak Server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error creating Realm in Keycloak Server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    public static RealmRepresentation createDefaultRoles(RealmRepresentation realmDetails){
+        List<RoleRepresentation> defaultRoles = new ArrayList<RoleRepresentation>();
+        RoleRepresentation adminRole = new RoleRepresentation();
+        adminRole.setName("admin");
+        adminRole.setDescription("Admin role for PGA users");
+        defaultRoles.add(adminRole);
+        RoleRepresentation adminReadOnlyRole = new RoleRepresentation();
+        adminReadOnlyRole.setName("admin-read-only");
+        adminReadOnlyRole.setDescription("Read only role for PGA Admin users");
+        defaultRoles.add(adminReadOnlyRole);
+        RoleRepresentation gatewayUserRole = new RoleRepresentation();
+        gatewayUserRole.setName("gateway-user");
+        gatewayUserRole.setDescription("default role for PGA users");
+        defaultRoles.add(gatewayUserRole);
+        RoleRepresentation pendingUserRole = new RoleRepresentation();
+        pendingUserRole.setName("user-pending");
+        pendingUserRole.setDescription("role for newly registered PGA users");
+        defaultRoles.add(pendingUserRole);
+        RoleRepresentation gatewayProviderRole = new RoleRepresentation();
+        gatewayProviderRole.setName("gateway-provider");
+        gatewayProviderRole.setDescription("role for gateway providers in the super-admin PGA");
+        defaultRoles.add(gatewayProviderRole);
+        RolesRepresentation rolesRepresentation = new RolesRepresentation();
+        rolesRepresentation.setRealm(defaultRoles);
+        realmDetails.setRoles(rolesRepresentation);
+        return realmDetails;
+    }
+
+    @Override
+    public boolean createTenantAdminAccount(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails, String tenantAdminPassword) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), this.superAdminRealmId, isSuperAdminPasswordCreds);
+            UserRepresentation user = new UserRepresentation();
+            user.setUsername(gatewayDetails.getIdentityServerUserName());
+            user.setFirstName(gatewayDetails.getGatewayAdminFirstName());
+            user.setLastName(gatewayDetails.getGatewayAdminLastName());
+            user.setEmail(gatewayDetails.getGatewayAdminEmail());
+            user.setEmailVerified(true);
+            user.setEnabled(true);
+            Response httpResponse = client.realm(gatewayDetails.getGatewayId()).users().create(user);
+            logger.info("Tenant Admin account creation exited with code : " + httpResponse.getStatus()+" : " +httpResponse.getStatusInfo());
+            if (httpResponse.getStatus() == 201) { //HTTP code for record creation: HTTP 201
+                List<UserRepresentation> retrieveCreatedUserList = client.realm(gatewayDetails.getGatewayId()).users().search(user.getUsername(),
+                        user.getFirstName(),
+                        user.getLastName(),
+                        user.getEmail(),
+                        0, 1);
+                UserResource retrievedUser = client.realm(gatewayDetails.getGatewayId()).users().get(retrieveCreatedUserList.get(0).getId());
+
+                // Add user to the "admin" role
+                RoleResource adminRoleResource = client.realm(gatewayDetails.getGatewayId()).roles().get("admin");
+                retrievedUser.roles().realmLevel().add(Arrays.asList(adminRoleResource.toRepresentation()));
+
+                CredentialRepresentation credential = new CredentialRepresentation();
+                credential.setType(CredentialRepresentation.PASSWORD);
+                credential.setValue(tenantAdminPassword);
+                credential.setTemporary(false);
+                retrievedUser.resetPassword(credential);
+                List<ClientRepresentation> realmClients = client.realm(gatewayDetails.getGatewayId()).clients().findAll();
+                String realmManagementClientId=getRealmManagementClientId(client, gatewayDetails.getGatewayId());
+                for(ClientRepresentation realmClient : realmClients){
+                    if(realmClient.getClientId().equals("realm-management")){
+                        realmManagementClientId = realmClient.getId();
+                    }
+                }
+                retrievedUser.roles().clientLevel(realmManagementClientId).add(retrievedUser.roles().clientLevel(realmManagementClientId).listAvailable());
+                return true;
+            } else {
+                logger.error("Request for Tenant Admin Account Creation failed with HTTP code : " + httpResponse.getStatus());
+                logger.error("Reason for Tenant Admin account creation failure : " + httpResponse.getStatusInfo());
+                return false;
+            }
+        }catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        }catch (Exception ex){
+            logger.error("Error creating Realm Admin Account in keycloak server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error creating Realm Admin Account in keycloak server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public Gateway configureClient(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), this.superAdminRealmId, isSuperAdminPasswordCreds);
+            ClientRepresentation pgaClient = new ClientRepresentation();
+            pgaClient.setName("pga");
+            pgaClient.setClientId("pga");
+            pgaClient.setProtocol("openid-connect");
+            pgaClient.setStandardFlowEnabled(true);
+            pgaClient.setEnabled(true);
+            pgaClient.setAuthorizationServicesEnabled(true);
+            pgaClient.setDirectAccessGrantsEnabled(true);
+            pgaClient.setServiceAccountsEnabled(true);
+            pgaClient.setFullScopeAllowed(true);
+            pgaClient.setClientAuthenticatorType("client-secret");
+            List<String> redirectUris = new ArrayList<>();
+            if(gatewayDetails.getGatewayURL()!=null){
+                String gatewayURL = gatewayDetails.getGatewayURL();
+                // Remove trailing slash from gatewayURL
+                if(gatewayURL.endsWith("/")) {
+                    gatewayURL = gatewayURL.substring(0, gatewayURL.length() - 1);
+                }
+                // Add redirect URL after login
+                redirectUris.add(gatewayURL + "/callback-url"); // PGA
+                redirectUris.add(gatewayURL + "/auth/callback*"); // Django
+                // Add redirect URL after logout
+                redirectUris.add(gatewayURL);
+            } else {
+                logger.error("Request for Realm Client Creation failed, callback URL not present");
+                IamAdminServicesException ex = new IamAdminServicesException();
+                ex.setMessage("Gateway Url field in GatewayProfile cannot be empty, Realm Client creation failed");
+                throw ex;
+            }
+            pgaClient.setRedirectUris(redirectUris);
+            pgaClient.setPublicClient(false);
+            Response httpResponse = client.realms().realm(gatewayDetails.getGatewayId()).clients().create(pgaClient);
+            logger.info("Tenant Client configuration exited with code : " + httpResponse.getStatus()+" : " +httpResponse.getStatusInfo());
+
+            // Add the manage-users role to the web client
+            UserRepresentation serviceAccountUserRepresentation = getUserByUsername(client, gatewayDetails.getGatewayId(), "service-account-" + pgaClient.getClientId());
+            UserResource serviceAccountUser = client.realms().realm(gatewayDetails.getGatewayId()).users().get(serviceAccountUserRepresentation.getId());
+            String realmManagementClientId = getRealmManagementClientId(client, gatewayDetails.getGatewayId());
+            List<RoleRepresentation> manageUsersRole = serviceAccountUser.roles().clientLevel(realmManagementClientId).listAvailable()
+                    .stream()
+                    .filter(r -> r.getName().equals("manage-users"))
+                    .collect(Collectors.toList());
+            serviceAccountUser.roles().clientLevel(realmManagementClientId).add(manageUsersRole);
+
+            if(httpResponse.getStatus() == 201){
+                String ClientUUID = client.realms().realm(gatewayDetails.getGatewayId()).clients().findByClientId(pgaClient.getClientId()).get(0).getId();
+                CredentialRepresentation clientSecret = client.realms().realm(gatewayDetails.getGatewayId()).clients().get(ClientUUID).getSecret();
+                gatewayDetails.setOauthClientId(pgaClient.getClientId());
+                gatewayDetails.setOauthClientSecret(clientSecret.getValue());
+                return gatewayDetails;
+            } else {
+                logger.error("Request for Realm Client Creation failed with HTTP code : " + httpResponse.getStatus());
+                logger.error("Reason for Realm Client Creation failure : " + httpResponse.getStatusInfo());
+                return null;
+            }
+        }catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    private static String getRealmManagementClientId(Keycloak client, String realmId) {
+        List<ClientRepresentation> realmClients = client.realm(realmId).clients().findAll();
+        String realmManagementClientId=null;
+        for(ClientRepresentation realmClient : realmClients){
+            if(realmClient.getClientId().equals("realm-management")){
+                realmManagementClientId = realmClient.getId();
+            }
+        }
+        return realmManagementClientId;
+    }
+
+    @Override
+    public boolean isUsernameAvailable(String accessToken, String tenantId, String username) throws IamAdminServicesException {
+        Keycloak client = null;
+        try {
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            return userRepresentation == null;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean createUser(String accessToken, String tenantId, String username, String emailAddress, String firstName, String lastName, String newPassword) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation user = new UserRepresentation();
+            user.setUsername(username);
+            user.setFirstName(firstName);
+            user.setLastName(lastName);
+            user.setEmail(emailAddress);
+            user.setEnabled(false);
+            Response httpResponse = client.realm(tenantId).users().create(user);
+            if (httpResponse.getStatus() == 201) { //HTTP code for record creation: HTTP 201
+                List<UserRepresentation> retrieveCreatedUserList = client.realm(tenantId).users().search(user.getUsername(),
+                        user.getFirstName(),
+                        user.getLastName(),
+                        user.getEmail(),
+                        0, 1);
+                UserResource retrievedUser = client.realm(tenantId).users().get(retrieveCreatedUserList.get(0).getId());
+                CredentialRepresentation credential = new CredentialRepresentation();
+                credential.setType(CredentialRepresentation.PASSWORD);
+                credential.setValue(newPassword);
+                credential.setTemporary(false);
+                retrievedUser.resetPassword(credential);
+                return true;
+            } else {
+                logger.error("Request for user Account Creation failed with HTTP code : " + httpResponse.getStatus());
+                logger.error("Reason for user account creation failure : " + httpResponse.getStatusInfo());
+                return false;
+            }
+        }catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean enableUserAccount(String accessToken, String tenantId, String username) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            UserResource userResource = client.realm(tenantId).users().get(userRepresentation.getId());
+            UserRepresentation profile = userResource.toRepresentation();
+            profile.setEnabled(true);
+            // We require that a user verify their email before enabling the account
+            profile.setEmailVerified(true);
+            userResource.update(profile);
+            return true;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isUserAccountEnabled(String accessToken, String tenantId, String username) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            return userRepresentation != null && userRepresentation.isEnabled();
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isUserExist(String accessToken, String tenantId, String username) throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            return userRepresentation != null;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public UserProfile getUser(String accessToken, String tenantId, String username) throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            return userRepresentation != null ? convertUserRepresentationToUserProfile(userRepresentation, tenantId) : null;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public List<UserProfile> getUsers(String accessToken, String tenantId, int offset, int limit, String search)
+            throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            List<UserRepresentation> userRepresentationList = client.realm(tenantId).users().search(search, offset, limit);
+            return userRepresentationList.stream().map(ur -> convertUserRepresentationToUserProfile(ur, tenantId))
+                    .collect(Collectors.toList());
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean resetUserPassword(String accessToken, String tenantId, String username, String newPassword) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            if(userRepresentation != null)
+            {
+                UserResource retrievedUser = client.realm(tenantId).users().get(userRepresentation.getId());
+                CredentialRepresentation credential = new CredentialRepresentation();
+                credential.setType(CredentialRepresentation.PASSWORD);
+                credential.setValue(newPassword);
+                credential.setTemporary(false);
+                retrievedUser.resetPassword(credential);
+                // Remove the UPDATE_PASSWORD required action
+                userRepresentation = retrievedUser.toRepresentation();
+                userRepresentation.getRequiredActions().remove("UPDATE_PASSWORD");
+                retrievedUser.update(userRepresentation);
+                return true;
+            }else{
+                logger.error("requested User not found");
+                return false;
+            }
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } catch (Exception ex){
+            logger.error("Error resetting user password in keycloak server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error resetting user password in keycloak server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public List<UserProfile> findUser(String accessToken, String tenantId, String email, String userName) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            List<UserRepresentation> retrieveUserList = client.realm(tenantId).users().search(userName,
+                    null,
+                    null,
+                    email,
+                    0, 1);
+            if(!retrieveUserList.isEmpty())
+            {
+                List<UserProfile> userList = new ArrayList<>();
+                for(UserRepresentation user : retrieveUserList){
+                    UserProfile profile = new UserProfile();
+                    profile.setUserId(user.getUsername());
+                    profile.setFirstName(user.getFirstName());
+                    profile.setLastName(user.getLastName());
+                    profile.setEmails(Arrays.asList(new String[]{user.getEmail()}));
+                    userList.add(profile);
+                }
+                return userList;
+            }else{
+                logger.error("requested User not found");
+                return null;
+            }
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } catch (Exception ex){
+            logger.error("Error finding user in keycloak server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error finding user in keycloak server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public void updateUserProfile(String accessToken, String tenantId, String username, UserProfile userDetails) throws IamAdminServicesException {
+
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            if(userRepresentation != null)
+            {
+                userRepresentation.setFirstName(userDetails.getFirstName());
+                userRepresentation.setLastName(userDetails.getLastName());
+                userRepresentation.setEmail(userDetails.getEmails().get(0));
+                UserResource userResource = client.realm(tenantId).users().get(userRepresentation.getId());
+                userResource.update(userRepresentation);
+            }else{
+                throw new IamAdminServicesException("User [" + username + "] wasn't found in Keycloak!");
+            }
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } catch (Exception ex){
+            logger.error("Error updating user profile in keycloak server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error updating user profile in keycloak server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean addRoleToUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException {
+
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
+            List<UserRepresentation> retrieveCreatedUserList = client.realm(tenantId).users().search(username,
+                    null,
+                    null,
+                    null,
+                    0, 1);
+            UserResource retrievedUser = client.realm(tenantId).users().get(retrieveCreatedUserList.get(0).getId());
+
+            // Add user to the role
+            RoleResource roleResource = client.realm(tenantId).roles().get(roleName);
+            retrievedUser.roles().realmLevel().add(Arrays.asList(roleResource.toRepresentation()));
+            return true;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean removeRoleFromUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException {
+
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
+            List<UserRepresentation> retrieveCreatedUserList = client.realm(tenantId).users().search(username,
+                    null,
+                    null,
+                    null,
+                    0, 1);
+            UserResource retrievedUser = client.realm(tenantId).users().get(retrieveCreatedUserList.get(0).getId());
+
+            // Remove role from user
+            RoleResource roleResource = client.realm(tenantId).roles().get(roleName);
+            retrievedUser.roles().realmLevel().remove(Arrays.asList(roleResource.toRepresentation()));
+            return true;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    // TODO: this is needed for migrating from roles to group-based auth but after migration we can remove this
+    @Override
+    public List<UserProfile> getUsersWithRole(PasswordCredential realmAdminCreds, String tenantId, String roleName) throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
+            // FIXME: this only searches through the most recent 100 users for the given role (assuming there are no more than 10,000 users in the gateway)
+            int totalUserCount = client.realm(tenantId).users().count();
+            logger.debug("getUsersWithRole: totalUserCount=" + totalUserCount);
+            // Load all users in batches
+            List<UserRepresentation> allUsers = new ArrayList<>();
+            int userBatchSize = 100;
+            for (int start = 0; start < totalUserCount; start=start+userBatchSize) {
+
+                logger.debug("getUsersWithRole: fetching " + userBatchSize + " users...");
+                allUsers.addAll(client.realm(tenantId).users().search(null,
+                        null,
+                        null,
+                        null,
+                        start, userBatchSize));
+            }
+            logger.debug("getUsersWithRole: all users count=" + allUsers.size());
+            allUsers.sort((a, b) -> a.getCreatedTimestamp() - b.getCreatedTimestamp() > 0 ? -1 : 1);
+            // The 100 most recently created users
+            List<UserRepresentation> mostRecentUsers = allUsers.subList(0, Math.min(allUsers.size(), 100));
+            logger.debug("getUsersWithRole: most recent users count=" + mostRecentUsers.size());
+
+            List<UserProfile> usersWithRole = new ArrayList<>();
+            for (UserRepresentation user: mostRecentUsers) {
+                UserResource userResource = client.realm(tenantId).users().get(user.getId());
+
+                List<RoleRepresentation> roleRepresentations = userResource.roles().realmLevel().listAll();
+                for (RoleRepresentation roleRepresentation : roleRepresentations){
+                    if (roleRepresentation.getName().equals(roleName)) {
+                        usersWithRole.add(convertUserRepresentationToUserProfile(user, tenantId));
+                        break;
+                    }
+                }
+            }
+            logger.debug("getUsersWithRole: most recent users with role count=" + usersWithRole.size());
+            return usersWithRole;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                logger.debug("getUsersWithRole: closing client...");
+                client.close();
+                logger.debug("getUsersWithRole: client closed");
+            }
+        }
+    }
+
+    public List<String> getUserRoles(PasswordCredential realmAdminCreds, String tenantId, String username) throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
+            List<UserRepresentation> userRepresentationList = client.realm(tenantId).users().search(username,
+                    null,
+                    null,
+                    null,
+                    0, 1);
+            if (userRepresentationList.isEmpty()) {
+                logger.warn("No Keycloak user found for username [" + username + "] in tenant [" + tenantId + "].");
+                return null;
+            }
+            UserResource retrievedUser = client.realm(tenantId).users().get(userRepresentationList.get(0).getId());
+            return retrievedUser.roles().realmLevel().listAll()
+                    .stream()
+                    .map(roleRepresentation -> roleRepresentation.getName())
+                    .collect(Collectors.toList());
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                logger.debug("getUserRoles: closing client...");
+                client.close();
+                logger.debug("getUserRoles: client closed");
+            }
+        }
+    }
+
+    private UserProfile convertUserRepresentationToUserProfile(UserRepresentation userRepresentation, String tenantId) {
+
+        UserProfile profile = new UserProfile();
+        profile.setCustosInternalUserId(userRepresentation.getUsername() + "@" + tenantId);
+        profile.setGatewayId(tenantId);
+        profile.setUserId(userRepresentation.getUsername());
+        profile.setFirstName(userRepresentation.getFirstName());
+        profile.setLastName(userRepresentation.getLastName());
+        profile.setEmails(Arrays.asList(new String[]{userRepresentation.getEmail()}));
+        profile.setCreationTime(userRepresentation.getCreatedTimestamp());
+
+        // Just default these. UserProfile isn't a great data model for this data since it isn't actually the Airavata UserProfile
+        profile.setLastAccessTime(0);
+        profile.setValidUntil(0);
+        // Use state field to indicate whether user has been enabled or email verified in Keycloak
+        if (userRepresentation.isEnabled()) {
+            profile.setState(Status.ACTIVE);
+        } else if (userRepresentation.isEmailVerified()) {
+            profile.setState(Status.CONFIRMED);
+        } else {
+            profile.setState(Status.PENDING_CONFIRMATION);
+        }
+
+        return profile;
+    }
+
+    private static UserRepresentation getUserByUsername(Keycloak client, String tenantId, String username) {
+
+        // Searching for users by username returns also partial matches, so need to filter down to an exact match if it exists
+        List<UserRepresentation> userResourceList = client.realm(tenantId).users().search(
+                username, null, null, null, null, null);
+        for (UserRepresentation userRepresentation : userResourceList) {
+            if (userRepresentation.getUsername().equals(username)) {
+                return userRepresentation;
+            }
+        }
+        return null;
+    }
+
+//    public static void main(String[] args) throws IamAdminServicesException, ApplicationSettingsException {
+//        TenantManagementKeycloakImpl tenantManagementKeycloak = new TenantManagementKeycloakImpl();
+//        ServerSettings.setSetting("trust.store", "./modules/configuration/server/src/main/resources/client_truststore.jks");
+//        ServerSettings.setSetting("trust.store.password", "airavata");
+//        ServerSettings.setSetting("iam.server.url", "");
+//        String accessToken = "";
+//        String tenantId = "";
+//        String username = "";
+//        boolean isUsernameAvailable = tenantManagementKeycloak.isUsernameAvailable(accessToken, tenantId, username);
+//        System.out.println("Username " + username + " is " + (isUsernameAvailable ? "": "NOT ") + "available");
+//    }
+}
diff --git a/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/cpi/IamAdminServices.java b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/cpi/IamAdminServices.java
new file mode 100644
index 0000000..d994d84
--- /dev/null
+++ b/custos-profile-service/iam-admin-services/src/main/java/org/apache/custos/profile/iam/admin/services/cpi/IamAdminServices.java
@@ -0,0 +1,17956 @@
+/**
+ * Autogenerated by Thrift Compiler (0.12.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.profile.iam.admin.services.cpi;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-07-10")
+public class IamAdminServices {
+
+  public interface Iface {
+
+    public String getAPIVersion() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public org.apache.custos.profile.model.workspace.Gateway setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public boolean isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public boolean registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public boolean enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public boolean isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public boolean isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public org.apache.custos.profile.model.user.UserProfile getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public boolean resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public boolean addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public boolean removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException;
+
+  }
+
+  public interface AsyncIface {
+
+    public void getAPIVersion(org.apache.thrift.async.AsyncMethodCallback<String> resultHandler) throws org.apache.thrift.TException;
+
+    public void setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException;
+
+    public void isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException;
+
+    public void getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException;
+
+    public void resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException;
+
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException;
+
+    public void addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException;
+
+    public void getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException;
+
+  }
+
+  public static class Client extends org.apache.thrift.TServiceClient implements Iface {
+    public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {
+      public Factory() {}
+      public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
+        return new Client(prot);
+      }
+      public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
+        return new Client(iprot, oprot);
+      }
+    }
+
+    public Client(org.apache.thrift.protocol.TProtocol prot)
+    {
+      super(prot, prot);
+    }
+
+    public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
+      super(iprot, oprot);
+    }
+
+    public String getAPIVersion() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_getAPIVersion();
+      return recv_getAPIVersion();
+    }
+
+    public void send_getAPIVersion() throws org.apache.thrift.TException
+    {
+      getAPIVersion_args args = new getAPIVersion_args();
+      sendBase("getAPIVersion", args);
+    }
+
+    public String recv_getAPIVersion() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      getAPIVersion_result result = new getAPIVersion_result();
+      receiveBase(result, "getAPIVersion");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getAPIVersion failed: unknown result");
+    }
+
+    public org.apache.custos.profile.model.workspace.Gateway setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_setUpGateway(authzToken, gateway, tenantAdminPasswordCredential);
+      return recv_setUpGateway();
+    }
+
+    public void send_setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.thrift.TException
+    {
+      setUpGateway_args args = new setUpGateway_args();
+      args.setAuthzToken(authzToken);
+      args.setGateway(gateway);
+      args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
+      sendBase("setUpGateway", args);
+    }
+
+    public org.apache.custos.profile.model.workspace.Gateway recv_setUpGateway() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      setUpGateway_result result = new setUpGateway_result();
+      receiveBase(result, "setUpGateway");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "setUpGateway failed: unknown result");
+    }
+
+    public boolean isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_isUsernameAvailable(authzToken, username);
+      return recv_isUsernameAvailable();
+    }
+
+    public void send_isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
+    {
+      isUsernameAvailable_args args = new isUsernameAvailable_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      sendBase("isUsernameAvailable", args);
+    }
+
+    public boolean recv_isUsernameAvailable() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      isUsernameAvailable_result result = new isUsernameAvailable_result();
+      receiveBase(result, "isUsernameAvailable");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isUsernameAvailable failed: unknown result");
+    }
+
+    public boolean registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_registerUser(authzToken, username, emailAddress, firstName, lastName, newPassword);
+      return recv_registerUser();
+    }
+
+    public void send_registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword) throws org.apache.thrift.TException
+    {
+      registerUser_args args = new registerUser_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      args.setEmailAddress(emailAddress);
+      args.setFirstName(firstName);
+      args.setLastName(lastName);
+      args.setNewPassword(newPassword);
+      sendBase("registerUser", args);
+    }
+
+    public boolean recv_registerUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      registerUser_result result = new registerUser_result();
+      receiveBase(result, "registerUser");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "registerUser failed: unknown result");
+    }
+
+    public boolean enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_enableUser(authzToken, username);
+      return recv_enableUser();
+    }
+
+    public void send_enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
+    {
+      enableUser_args args = new enableUser_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      sendBase("enableUser", args);
+    }
+
+    public boolean recv_enableUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      enableUser_result result = new enableUser_result();
+      receiveBase(result, "enableUser");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "enableUser failed: unknown result");
+    }
+
+    public boolean isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_isUserEnabled(authzToken, username);
+      return recv_isUserEnabled();
+    }
+
+    public void send_isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
+    {
+      isUserEnabled_args args = new isUserEnabled_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      sendBase("isUserEnabled", args);
+    }
+
+    public boolean recv_isUserEnabled() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      isUserEnabled_result result = new isUserEnabled_result();
+      receiveBase(result, "isUserEnabled");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isUserEnabled failed: unknown result");
+    }
+
+    public boolean isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_isUserExist(authzToken, username);
+      return recv_isUserExist();
+    }
+
+    public void send_isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
+    {
+      isUserExist_args args = new isUserExist_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      sendBase("isUserExist", args);
+    }
+
+    public boolean recv_isUserExist() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      isUserExist_result result = new isUserExist_result();
+      receiveBase(result, "isUserExist");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "isUserExist failed: unknown result");
+    }
+
+    public org.apache.custos.profile.model.user.UserProfile getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_getUser(authzToken, username);
+      return recv_getUser();
+    }
+
+    public void send_getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username) throws org.apache.thrift.TException
+    {
+      getUser_args args = new getUser_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      sendBase("getUser", args);
+    }
+
+    public org.apache.custos.profile.model.user.UserProfile recv_getUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      getUser_result result = new getUser_result();
+      receiveBase(result, "getUser");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUser failed: unknown result");
+    }
+
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_getUsers(authzToken, offset, limit, search);
+      return recv_getUsers();
+    }
+
+    public void send_getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search) throws org.apache.thrift.TException
+    {
+      getUsers_args args = new getUsers_args();
+      args.setAuthzToken(authzToken);
+      args.setOffset(offset);
+      args.setLimit(limit);
+      args.setSearch(search);
+      sendBase("getUsers", args);
+    }
+
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> recv_getUsers() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      getUsers_result result = new getUsers_result();
+      receiveBase(result, "getUsers");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUsers failed: unknown result");
+    }
+
+    public boolean resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_resetUserPassword(authzToken, username, newPassword);
+      return recv_resetUserPassword();
+    }
+
+    public void send_resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword) throws org.apache.thrift.TException
+    {
+      resetUserPassword_args args = new resetUserPassword_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      args.setNewPassword(newPassword);
+      sendBase("resetUserPassword", args);
+    }
+
+    public boolean recv_resetUserPassword() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      resetUserPassword_result result = new resetUserPassword_result();
+      receiveBase(result, "resetUserPassword");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "resetUserPassword failed: unknown result");
+    }
+
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_findUsers(authzToken, email, userId);
+      return recv_findUsers();
+    }
+
+    public void send_findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId) throws org.apache.thrift.TException
+    {
+      findUsers_args args = new findUsers_args();
+      args.setAuthzToken(authzToken);
+      args.setEmail(email);
+      args.setUserId(userId);
+      sendBase("findUsers", args);
+    }
+
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> recv_findUsers() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      findUsers_result result = new findUsers_result();
+      receiveBase(result, "findUsers");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "findUsers failed: unknown result");
+    }
+
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_updateUserProfile(authzToken, userDetails);
+      recv_updateUserProfile();
+    }
+
+    public void send_updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails) throws org.apache.thrift.TException
+    {
+      updateUserProfile_args args = new updateUserProfile_args();
+      args.setAuthzToken(authzToken);
+      args.setUserDetails(userDetails);
+      sendBase("updateUserProfile", args);
+    }
+
+    public void recv_updateUserProfile() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      updateUserProfile_result result = new updateUserProfile_result();
+      receiveBase(result, "updateUserProfile");
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      return;
+    }
+
+    public boolean addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_addRoleToUser(authzToken, username, roleName, tenantAdminPasswordCredential);
+      return recv_addRoleToUser();
+    }
+
+    public void send_addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.thrift.TException
+    {
+      addRoleToUser_args args = new addRoleToUser_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      args.setRoleName(roleName);
+      args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
+      sendBase("addRoleToUser", args);
+    }
+
+    public boolean recv_addRoleToUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      addRoleToUser_result result = new addRoleToUser_result();
+      receiveBase(result, "addRoleToUser");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "addRoleToUser failed: unknown result");
+    }
+
+    public boolean removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_removeRoleFromUser(authzToken, username, roleName, tenantAdminPasswordCredential);
+      return recv_removeRoleFromUser();
+    }
+
+    public void send_removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.thrift.TException
+    {
+      removeRoleFromUser_args args = new removeRoleFromUser_args();
+      args.setAuthzToken(authzToken);
+      args.setUsername(username);
+      args.setRoleName(roleName);
+      args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
+      sendBase("removeRoleFromUser", args);
+    }
+
+    public boolean recv_removeRoleFromUser() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      removeRoleFromUser_result result = new removeRoleFromUser_result();
+      receiveBase(result, "removeRoleFromUser");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "removeRoleFromUser failed: unknown result");
+    }
+
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      send_getUsersWithRole(authzToken, roleName, tenantAdminPasswordCredential);
+      return recv_getUsersWithRole();
+    }
+
+    public void send_getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) throws org.apache.thrift.TException
+    {
+      getUsersWithRole_args args = new getUsersWithRole_args();
+      args.setAuthzToken(authzToken);
+      args.setRoleName(roleName);
+      args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
+      sendBase("getUsersWithRole", args);
+    }
+
+    public java.util.List<org.apache.custos.profile.model.user.UserProfile> recv_getUsersWithRole() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException
+    {
+      getUsersWithRole_result result = new getUsersWithRole_result();
+      receiveBase(result, "getUsersWithRole");
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.Idse != null) {
+        throw result.Idse;
+      }
+      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUsersWithRole failed: unknown result");
+    }
+
+  }
+  public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
+    public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
+      private org.apache.thrift.async.TAsyncClientManager clientManager;
+      private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
+      public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
+        this.clientManager = clientManager;
+        this.protocolFactory = protocolFactory;
+      }
+      public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
+        return new AsyncClient(protocolFactory, clientManager, transport);
+      }
+    }
+
+    public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
+      super(protocolFactory, clientManager, transport);
+    }
+
+    public void getAPIVersion(org.apache.thrift.async.AsyncMethodCallback<String> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      getAPIVersion_call method_call = new getAPIVersion_call(resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class getAPIVersion_call extends org.apache.thrift.async.TAsyncMethodCall<String> {
+      public getAPIVersion_call(org.apache.thrift.async.AsyncMethodCallback<String> 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);
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getAPIVersion", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        getAPIVersion_args args = new getAPIVersion_args();
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public String getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_getAPIVersion();
+      }
+    }
+
+    public void setUpGateway(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      setUpGateway_call method_call = new setUpGateway_call(authzToken, gateway, tenantAdminPasswordCredential, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class setUpGateway_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.profile.model.workspace.Gateway> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private org.apache.custos.profile.model.workspace.Gateway gateway;
+      private org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential;
+      public setUpGateway_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.workspace.Gateway gateway, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonb [...]
+        super(client, protocolFactory, transport, resultHandler, false);
+        this.authzToken = authzToken;
+        this.gateway = gateway;
+        this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("setUpGateway", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        setUpGateway_args args = new setUpGateway_args();
+        args.setAuthzToken(authzToken);
+        args.setGateway(gateway);
+        args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public org.apache.custos.profile.model.workspace.Gateway getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_setUpGateway();
+      }
+    }
+
+    public void isUsernameAvailable(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      isUsernameAvailable_call method_call = new isUsernameAvailable_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class isUsernameAvailable_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public isUsernameAvailable_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.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("isUsernameAvailable", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        isUsernameAvailable_args args = new isUsernameAvailable_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_isUsernameAvailable();
+      }
+    }
+
+    public void registerUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      registerUser_call method_call = new registerUser_call(authzToken, username, emailAddress, firstName, lastName, newPassword, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class registerUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      private String emailAddress;
+      private String firstName;
+      private String lastName;
+      private String newPassword;
+      public registerUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String emailAddress, String firstName, String lastName, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
+        this.emailAddress = emailAddress;
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.newPassword = newPassword;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("registerUser", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        registerUser_args args = new registerUser_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.setEmailAddress(emailAddress);
+        args.setFirstName(firstName);
+        args.setLastName(lastName);
+        args.setNewPassword(newPassword);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_registerUser();
+      }
+    }
+
+    public void enableUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      enableUser_call method_call = new enableUser_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class enableUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public enableUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.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("enableUser", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        enableUser_args args = new enableUser_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_enableUser();
+      }
+    }
+
+    public void isUserEnabled(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      isUserEnabled_call method_call = new isUserEnabled_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class isUserEnabled_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public isUserEnabled_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.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("isUserEnabled", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        isUserEnabled_args args = new isUserEnabled_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_isUserEnabled();
+      }
+    }
+
+    public void isUserExist(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      isUserExist_call method_call = new isUserExist_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class isUserExist_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public isUserExist_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.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("isUserExist", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        isUserExist_args args = new isUserExist_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_isUserExist();
+      }
+    }
+
+    public void getUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      getUser_call method_call = new getUser_call(authzToken, username, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class getUser_call extends org.apache.thrift.async.TAsyncMethodCall<org.apache.custos.profile.model.user.UserProfile> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      public getUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> 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.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("getUser", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        getUser_args args = new getUser_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public org.apache.custos.profile.model.user.UserProfile getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_getUser();
+      }
+    }
+
+    public void getUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      getUsers_call method_call = new getUsers_call(authzToken, offset, limit, search, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class getUsers_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private int offset;
+      private int limit;
+      private String search;
+      public getUsers_call(org.apache.custos.commons.model.security.AuthzToken authzToken, int offset, int limit, String search, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> 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.offset = offset;
+        this.limit = limit;
+        this.search = search;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUsers", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        getUsers_args args = new getUsers_args();
+        args.setAuthzToken(authzToken);
+        args.setOffset(offset);
+        args.setLimit(limit);
+        args.setSearch(search);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public java.util.List<org.apache.custos.profile.model.user.UserProfile> getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_getUsers();
+      }
+    }
+
+    public void resetUserPassword(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      resetUserPassword_call method_call = new resetUserPassword_call(authzToken, username, newPassword, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class resetUserPassword_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      private String newPassword;
+      public resetUserPassword_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String newPassword, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
+        this.newPassword = newPassword;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("resetUserPassword", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        resetUserPassword_args args = new resetUserPassword_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.setNewPassword(newPassword);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_resetUserPassword();
+      }
+    }
+
+    public void findUsers(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      findUsers_call method_call = new findUsers_call(authzToken, email, userId, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class findUsers_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String email;
+      private String userId;
+      public findUsers_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String email, String userId, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> 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.email = email;
+        this.userId = userId;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("findUsers", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        findUsers_args args = new findUsers_args();
+        args.setAuthzToken(authzToken);
+        args.setEmail(email);
+        args.setUserId(userId);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public java.util.List<org.apache.custos.profile.model.user.UserProfile> getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_findUsers();
+      }
+    }
+
+    public void updateUserProfile(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      updateUserProfile_call method_call = new updateUserProfile_call(authzToken, userDetails, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class updateUserProfile_call extends org.apache.thrift.async.TAsyncMethodCall<Void> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private org.apache.custos.profile.model.user.UserProfile userDetails;
+      public updateUserProfile_call(org.apache.custos.commons.model.security.AuthzToken authzToken, org.apache.custos.profile.model.user.UserProfile userDetails, org.apache.thrift.async.AsyncMethodCallback<Void> 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.userDetails = userDetails;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("updateUserProfile", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        updateUserProfile_args args = new updateUserProfile_args();
+        args.setAuthzToken(authzToken);
+        args.setUserDetails(userDetails);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Void getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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 null;
+      }
+    }
+
+    public void addRoleToUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      addRoleToUser_call method_call = new addRoleToUser_call(authzToken, username, roleName, tenantAdminPasswordCredential, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class addRoleToUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      private String roleName;
+      private org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential;
+      public addRoleToUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
+        this.roleName = roleName;
+        this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("addRoleToUser", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        addRoleToUser_args args = new addRoleToUser_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.setRoleName(roleName);
+        args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_addRoleToUser();
+      }
+    }
+
+    public void removeRoleFromUser(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      removeRoleFromUser_call method_call = new removeRoleFromUser_call(authzToken, username, roleName, tenantAdminPasswordCredential, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class removeRoleFromUser_call extends org.apache.thrift.async.TAsyncMethodCall<Boolean> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String username;
+      private String roleName;
+      private org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential;
+      public removeRoleFromUser_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String username, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<Boolean> 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.username = username;
+        this.roleName = roleName;
+        this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("removeRoleFromUser", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        removeRoleFromUser_args args = new removeRoleFromUser_args();
+        args.setAuthzToken(authzToken);
+        args.setUsername(username);
+        args.setRoleName(roleName);
+        args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public Boolean getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_removeRoleFromUser();
+      }
+    }
+
+    public void getUsersWithRole(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+      checkReady();
+      getUsersWithRole_call method_call = new getUsersWithRole_call(authzToken, roleName, tenantAdminPasswordCredential, resultHandler, this, ___protocolFactory, ___transport);
+      this.___currentMethod = method_call;
+      ___manager.call(method_call);
+    }
+
+    public static class getUsersWithRole_call extends org.apache.thrift.async.TAsyncMethodCall<java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
+      private org.apache.custos.commons.model.security.AuthzToken authzToken;
+      private String roleName;
+      private org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential;
+      public getUsersWithRole_call(org.apache.custos.commons.model.security.AuthzToken authzToken, String roleName, org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transp [...]
+        super(client, protocolFactory, transport, resultHandler, false);
+        this.authzToken = authzToken;
+        this.roleName = roleName;
+        this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
+      }
+
+      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
+        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUsersWithRole", org.apache.thrift.protocol.TMessageType.CALL, 0));
+        getUsersWithRole_args args = new getUsersWithRole_args();
+        args.setAuthzToken(authzToken);
+        args.setRoleName(roleName);
+        args.setTenantAdminPasswordCredential(tenantAdminPasswordCredential);
+        args.write(prot);
+        prot.writeMessageEnd();
+      }
+
+      public java.util.List<org.apache.custos.profile.model.user.UserProfile> getResult() throws org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException, org.apache.thrift.TException {
+        if (getState() != 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_getUsersWithRole();
+      }
+    }
+
+  }
+
+  public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
+    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName());
+    public Processor(I iface) {
+      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
+    }
+
+    protected Processor(I iface, java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) {
+      super(iface, getProcessMap(processMap));
+    }
+
+    private static <I extends Iface> java.util.Map<String,  org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<String, org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {
+      processMap.put("getAPIVersion", new getAPIVersion());
+      processMap.put("setUpGateway", new setUpGateway());
+      processMap.put("isUsernameAvailable", new isUsernameAvailable());
+      processMap.put("registerUser", new registerUser());
+      processMap.put("enableUser", new enableUser());
+      processMap.put("isUserEnabled", new isUserEnabled());
+      processMap.put("isUserExist", new isUserExist());
+      processMap.put("getUser", new getUser());
+      processMap.put("getUsers", new getUsers());
+      processMap.put("resetUserPassword", new resetUserPassword());
+      processMap.put("findUsers", new findUsers());
+      processMap.put("updateUserProfile", new updateUserProfile());
+      processMap.put("addRoleToUser", new addRoleToUser());
+      processMap.put("removeRoleFromUser", new removeRoleFromUser());
+      processMap.put("getUsersWithRole", new getUsersWithRole());
+      return processMap;
+    }
+
+    public static class getAPIVersion<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getAPIVersion_args> {
+      public getAPIVersion() {
+        super("getAPIVersion");
+      }
+
+      public getAPIVersion_args getEmptyArgsInstance() {
+        return new getAPIVersion_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public getAPIVersion_result getResult(I iface, getAPIVersion_args args) throws org.apache.thrift.TException {
+        getAPIVersion_result result = new getAPIVersion_result();
+        try {
+          result.success = iface.getAPIVersion();
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class setUpGateway<I extends Iface> extends org.apache.thrift.ProcessFunction<I, setUpGateway_args> {
+      public setUpGateway() {
+        super("setUpGateway");
+      }
+
+      public setUpGateway_args getEmptyArgsInstance() {
+        return new setUpGateway_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public setUpGateway_result getResult(I iface, setUpGateway_args args) throws org.apache.thrift.TException {
+        setUpGateway_result result = new setUpGateway_result();
+        try {
+          result.success = iface.setUpGateway(args.authzToken, args.gateway, args.tenantAdminPasswordCredential);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class isUsernameAvailable<I extends Iface> extends org.apache.thrift.ProcessFunction<I, isUsernameAvailable_args> {
+      public isUsernameAvailable() {
+        super("isUsernameAvailable");
+      }
+
+      public isUsernameAvailable_args getEmptyArgsInstance() {
+        return new isUsernameAvailable_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public isUsernameAvailable_result getResult(I iface, isUsernameAvailable_args args) throws org.apache.thrift.TException {
+        isUsernameAvailable_result result = new isUsernameAvailable_result();
+        try {
+          result.success = iface.isUsernameAvailable(args.authzToken, args.username);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class registerUser<I extends Iface> extends org.apache.thrift.ProcessFunction<I, registerUser_args> {
+      public registerUser() {
+        super("registerUser");
+      }
+
+      public registerUser_args getEmptyArgsInstance() {
+        return new registerUser_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public registerUser_result getResult(I iface, registerUser_args args) throws org.apache.thrift.TException {
+        registerUser_result result = new registerUser_result();
+        try {
+          result.success = iface.registerUser(args.authzToken, args.username, args.emailAddress, args.firstName, args.lastName, args.newPassword);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class enableUser<I extends Iface> extends org.apache.thrift.ProcessFunction<I, enableUser_args> {
+      public enableUser() {
+        super("enableUser");
+      }
+
+      public enableUser_args getEmptyArgsInstance() {
+        return new enableUser_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public enableUser_result getResult(I iface, enableUser_args args) throws org.apache.thrift.TException {
+        enableUser_result result = new enableUser_result();
+        try {
+          result.success = iface.enableUser(args.authzToken, args.username);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class isUserEnabled<I extends Iface> extends org.apache.thrift.ProcessFunction<I, isUserEnabled_args> {
+      public isUserEnabled() {
+        super("isUserEnabled");
+      }
+
+      public isUserEnabled_args getEmptyArgsInstance() {
+        return new isUserEnabled_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public isUserEnabled_result getResult(I iface, isUserEnabled_args args) throws org.apache.thrift.TException {
+        isUserEnabled_result result = new isUserEnabled_result();
+        try {
+          result.success = iface.isUserEnabled(args.authzToken, args.username);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class isUserExist<I extends Iface> extends org.apache.thrift.ProcessFunction<I, isUserExist_args> {
+      public isUserExist() {
+        super("isUserExist");
+      }
+
+      public isUserExist_args getEmptyArgsInstance() {
+        return new isUserExist_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public isUserExist_result getResult(I iface, isUserExist_args args) throws org.apache.thrift.TException {
+        isUserExist_result result = new isUserExist_result();
+        try {
+          result.success = iface.isUserExist(args.authzToken, args.username);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class getUser<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUser_args> {
+      public getUser() {
+        super("getUser");
+      }
+
+      public getUser_args getEmptyArgsInstance() {
+        return new getUser_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public getUser_result getResult(I iface, getUser_args args) throws org.apache.thrift.TException {
+        getUser_result result = new getUser_result();
+        try {
+          result.success = iface.getUser(args.authzToken, args.username);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class getUsers<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUsers_args> {
+      public getUsers() {
+        super("getUsers");
+      }
+
+      public getUsers_args getEmptyArgsInstance() {
+        return new getUsers_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public getUsers_result getResult(I iface, getUsers_args args) throws org.apache.thrift.TException {
+        getUsers_result result = new getUsers_result();
+        try {
+          result.success = iface.getUsers(args.authzToken, args.offset, args.limit, args.search);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class resetUserPassword<I extends Iface> extends org.apache.thrift.ProcessFunction<I, resetUserPassword_args> {
+      public resetUserPassword() {
+        super("resetUserPassword");
+      }
+
+      public resetUserPassword_args getEmptyArgsInstance() {
+        return new resetUserPassword_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public resetUserPassword_result getResult(I iface, resetUserPassword_args args) throws org.apache.thrift.TException {
+        resetUserPassword_result result = new resetUserPassword_result();
+        try {
+          result.success = iface.resetUserPassword(args.authzToken, args.username, args.newPassword);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class findUsers<I extends Iface> extends org.apache.thrift.ProcessFunction<I, findUsers_args> {
+      public findUsers() {
+        super("findUsers");
+      }
+
+      public findUsers_args getEmptyArgsInstance() {
+        return new findUsers_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public findUsers_result getResult(I iface, findUsers_args args) throws org.apache.thrift.TException {
+        findUsers_result result = new findUsers_result();
+        try {
+          result.success = iface.findUsers(args.authzToken, args.email, args.userId);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class updateUserProfile<I extends Iface> extends org.apache.thrift.ProcessFunction<I, updateUserProfile_args> {
+      public updateUserProfile() {
+        super("updateUserProfile");
+      }
+
+      public updateUserProfile_args getEmptyArgsInstance() {
+        return new updateUserProfile_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public updateUserProfile_result getResult(I iface, updateUserProfile_args args) throws org.apache.thrift.TException {
+        updateUserProfile_result result = new updateUserProfile_result();
+        try {
+          iface.updateUserProfile(args.authzToken, args.userDetails);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class addRoleToUser<I extends Iface> extends org.apache.thrift.ProcessFunction<I, addRoleToUser_args> {
+      public addRoleToUser() {
+        super("addRoleToUser");
+      }
+
+      public addRoleToUser_args getEmptyArgsInstance() {
+        return new addRoleToUser_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public addRoleToUser_result getResult(I iface, addRoleToUser_args args) throws org.apache.thrift.TException {
+        addRoleToUser_result result = new addRoleToUser_result();
+        try {
+          result.success = iface.addRoleToUser(args.authzToken, args.username, args.roleName, args.tenantAdminPasswordCredential);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class removeRoleFromUser<I extends Iface> extends org.apache.thrift.ProcessFunction<I, removeRoleFromUser_args> {
+      public removeRoleFromUser() {
+        super("removeRoleFromUser");
+      }
+
+      public removeRoleFromUser_args getEmptyArgsInstance() {
+        return new removeRoleFromUser_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public removeRoleFromUser_result getResult(I iface, removeRoleFromUser_args args) throws org.apache.thrift.TException {
+        removeRoleFromUser_result result = new removeRoleFromUser_result();
+        try {
+          result.success = iface.removeRoleFromUser(args.authzToken, args.username, args.roleName, args.tenantAdminPasswordCredential);
+          result.setSuccessIsSet(true);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+    public static class getUsersWithRole<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUsersWithRole_args> {
+      public getUsersWithRole() {
+        super("getUsersWithRole");
+      }
+
+      public getUsersWithRole_args getEmptyArgsInstance() {
+        return new getUsersWithRole_args();
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      @Override
+      protected boolean rethrowUnhandledExceptions() {
+        return false;
+      }
+
+      public getUsersWithRole_result getResult(I iface, getUsersWithRole_args args) throws org.apache.thrift.TException {
+        getUsersWithRole_result result = new getUsersWithRole_result();
+        try {
+          result.success = iface.getUsersWithRole(args.authzToken, args.roleName, args.tenantAdminPasswordCredential);
+        } catch (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+          result.Idse = Idse;
+        }
+        return result;
+      }
+    }
+
+  }
+
+  public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> {
+    private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName());
+    public AsyncProcessor(I iface) {
+      super(iface, getProcessMap(new java.util.HashMap<String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>()));
+    }
+
+    protected AsyncProcessor(I iface, java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
+      super(iface, getProcessMap(processMap));
+    }
+
+    private static <I extends AsyncIface> java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<String,  org.apache.thrift.AsyncProcessFunction<I, ? extends  org.apache.thrift.TBase, ?>> processMap) {
+      processMap.put("getAPIVersion", new getAPIVersion());
+      processMap.put("setUpGateway", new setUpGateway());
+      processMap.put("isUsernameAvailable", new isUsernameAvailable());
+      processMap.put("registerUser", new registerUser());
+      processMap.put("enableUser", new enableUser());
+      processMap.put("isUserEnabled", new isUserEnabled());
+      processMap.put("isUserExist", new isUserExist());
+      processMap.put("getUser", new getUser());
+      processMap.put("getUsers", new getUsers());
+      processMap.put("resetUserPassword", new resetUserPassword());
+      processMap.put("findUsers", new findUsers());
+      processMap.put("updateUserProfile", new updateUserProfile());
+      processMap.put("addRoleToUser", new addRoleToUser());
+      processMap.put("removeRoleFromUser", new removeRoleFromUser());
+      processMap.put("getUsersWithRole", new getUsersWithRole());
+      return processMap;
+    }
+
+    public static class getAPIVersion<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getAPIVersion_args, String> {
+      public getAPIVersion() {
+        super("getAPIVersion");
+      }
+
+      public getAPIVersion_args getEmptyArgsInstance() {
+        return new getAPIVersion_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<String> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<String>() {
+          public void onComplete(String o) {
+            getAPIVersion_result result = new getAPIVersion_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            getAPIVersion_result result = new getAPIVersion_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, getAPIVersion_args args, org.apache.thrift.async.AsyncMethodCallback<String> resultHandler) throws org.apache.thrift.TException {
+        iface.getAPIVersion(resultHandler);
+      }
+    }
+
+    public static class setUpGateway<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, setUpGateway_args, org.apache.custos.profile.model.workspace.Gateway> {
+      public setUpGateway() {
+        super("setUpGateway");
+      }
+
+      public setUpGateway_args getEmptyArgsInstance() {
+        return new setUpGateway_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway>() { 
+          public void onComplete(org.apache.custos.profile.model.workspace.Gateway o) {
+            setUpGateway_result result = new setUpGateway_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            setUpGateway_result result = new setUpGateway_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, setUpGateway_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.workspace.Gateway> resultHandler) throws org.apache.thrift.TException {
+        iface.setUpGateway(args.authzToken, args.gateway, args.tenantAdminPasswordCredential,resultHandler);
+      }
+    }
+
+    public static class isUsernameAvailable<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUsernameAvailable_args, Boolean> {
+      public isUsernameAvailable() {
+        super("isUsernameAvailable");
+      }
+
+      public isUsernameAvailable_args getEmptyArgsInstance() {
+        return new isUsernameAvailable_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            isUsernameAvailable_result result = new isUsernameAvailable_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            isUsernameAvailable_result result = new isUsernameAvailable_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, isUsernameAvailable_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.isUsernameAvailable(args.authzToken, args.username,resultHandler);
+      }
+    }
+
+    public static class registerUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, registerUser_args, Boolean> {
+      public registerUser() {
+        super("registerUser");
+      }
+
+      public registerUser_args getEmptyArgsInstance() {
+        return new registerUser_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            registerUser_result result = new registerUser_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            registerUser_result result = new registerUser_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, registerUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.registerUser(args.authzToken, args.username, args.emailAddress, args.firstName, args.lastName, args.newPassword,resultHandler);
+      }
+    }
+
+    public static class enableUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, enableUser_args, Boolean> {
+      public enableUser() {
+        super("enableUser");
+      }
+
+      public enableUser_args getEmptyArgsInstance() {
+        return new enableUser_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            enableUser_result result = new enableUser_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            enableUser_result result = new enableUser_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, enableUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.enableUser(args.authzToken, args.username,resultHandler);
+      }
+    }
+
+    public static class isUserEnabled<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUserEnabled_args, Boolean> {
+      public isUserEnabled() {
+        super("isUserEnabled");
+      }
+
+      public isUserEnabled_args getEmptyArgsInstance() {
+        return new isUserEnabled_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            isUserEnabled_result result = new isUserEnabled_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            isUserEnabled_result result = new isUserEnabled_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, isUserEnabled_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.isUserEnabled(args.authzToken, args.username,resultHandler);
+      }
+    }
+
+    public static class isUserExist<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, isUserExist_args, Boolean> {
+      public isUserExist() {
+        super("isUserExist");
+      }
+
+      public isUserExist_args getEmptyArgsInstance() {
+        return new isUserExist_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            isUserExist_result result = new isUserExist_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            isUserExist_result result = new isUserExist_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, isUserExist_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.isUserExist(args.authzToken, args.username,resultHandler);
+      }
+    }
+
+    public static class getUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUser_args, org.apache.custos.profile.model.user.UserProfile> {
+      public getUser() {
+        super("getUser");
+      }
+
+      public getUser_args getEmptyArgsInstance() {
+        return new getUser_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile>() { 
+          public void onComplete(org.apache.custos.profile.model.user.UserProfile o) {
+            getUser_result result = new getUser_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            getUser_result result = new getUser_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, getUser_args args, org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.profile.model.user.UserProfile> resultHandler) throws org.apache.thrift.TException {
+        iface.getUser(args.authzToken, args.username,resultHandler);
+      }
+    }
+
+    public static class getUsers<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUsers_args, java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
+      public getUsers() {
+        super("getUsers");
+      }
+
+      public getUsers_args getEmptyArgsInstance() {
+        return new getUsers_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>>() { 
+          public void onComplete(java.util.List<org.apache.custos.profile.model.user.UserProfile> o) {
+            getUsers_result result = new getUsers_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            getUsers_result result = new getUsers_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, getUsers_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+        iface.getUsers(args.authzToken, args.offset, args.limit, args.search,resultHandler);
+      }
+    }
+
+    public static class resetUserPassword<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, resetUserPassword_args, Boolean> {
+      public resetUserPassword() {
+        super("resetUserPassword");
+      }
+
+      public resetUserPassword_args getEmptyArgsInstance() {
+        return new resetUserPassword_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            resetUserPassword_result result = new resetUserPassword_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            resetUserPassword_result result = new resetUserPassword_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, resetUserPassword_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.resetUserPassword(args.authzToken, args.username, args.newPassword,resultHandler);
+      }
+    }
+
+    public static class findUsers<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, findUsers_args, java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
+      public findUsers() {
+        super("findUsers");
+      }
+
+      public findUsers_args getEmptyArgsInstance() {
+        return new findUsers_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>>() { 
+          public void onComplete(java.util.List<org.apache.custos.profile.model.user.UserProfile> o) {
+            findUsers_result result = new findUsers_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            findUsers_result result = new findUsers_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, findUsers_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+        iface.findUsers(args.authzToken, args.email, args.userId,resultHandler);
+      }
+    }
+
+    public static class updateUserProfile<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, updateUserProfile_args, Void> {
+      public updateUserProfile() {
+        super("updateUserProfile");
+      }
+
+      public updateUserProfile_args getEmptyArgsInstance() {
+        return new updateUserProfile_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Void> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Void>() { 
+          public void onComplete(Void o) {
+            updateUserProfile_result result = new updateUserProfile_result();
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            updateUserProfile_result result = new updateUserProfile_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, updateUserProfile_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException {
+        iface.updateUserProfile(args.authzToken, args.userDetails,resultHandler);
+      }
+    }
+
+    public static class addRoleToUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, addRoleToUser_args, Boolean> {
+      public addRoleToUser() {
+        super("addRoleToUser");
+      }
+
+      public addRoleToUser_args getEmptyArgsInstance() {
+        return new addRoleToUser_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            addRoleToUser_result result = new addRoleToUser_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            addRoleToUser_result result = new addRoleToUser_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, addRoleToUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.addRoleToUser(args.authzToken, args.username, args.roleName, args.tenantAdminPasswordCredential,resultHandler);
+      }
+    }
+
+    public static class removeRoleFromUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, removeRoleFromUser_args, Boolean> {
+      public removeRoleFromUser() {
+        super("removeRoleFromUser");
+      }
+
+      public removeRoleFromUser_args getEmptyArgsInstance() {
+        return new removeRoleFromUser_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<Boolean> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<Boolean>() {
+          public void onComplete(Boolean o) {
+            removeRoleFromUser_result result = new removeRoleFromUser_result();
+            result.success = o;
+            result.setSuccessIsSet(true);
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            removeRoleFromUser_result result = new removeRoleFromUser_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, removeRoleFromUser_args args, org.apache.thrift.async.AsyncMethodCallback<Boolean> resultHandler) throws org.apache.thrift.TException {
+        iface.removeRoleFromUser(args.authzToken, args.username, args.roleName, args.tenantAdminPasswordCredential,resultHandler);
+      }
+    }
+
+    public static class getUsersWithRole<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUsersWithRole_args, java.util.List<org.apache.custos.profile.model.user.UserProfile>> {
+      public getUsersWithRole() {
+        super("getUsersWithRole");
+      }
+
+      public getUsersWithRole_args getEmptyArgsInstance() {
+        return new getUsersWithRole_args();
+      }
+
+      public org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
+        final org.apache.thrift.AsyncProcessFunction fcall = this;
+        return new org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>>() { 
+          public void onComplete(java.util.List<org.apache.custos.profile.model.user.UserProfile> o) {
+            getUsersWithRole_result result = new getUsersWithRole_result();
+            result.success = o;
+            try {
+              fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
+            } catch (org.apache.thrift.transport.TTransportException e) {
+              _LOGGER.error("TTransportException writing to internal frame buffer", e);
+              fb.close();
+            } catch (Exception e) {
+              _LOGGER.error("Exception writing to internal frame buffer", e);
+              onError(e);
+            }
+          }
+          public void onError(Exception e) {
+            byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
+            org.apache.thrift.TSerializable msg;
+            getUsersWithRole_result result = new getUsersWithRole_result();
+            if (e instanceof org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) {
+              result.Idse = (org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException) e;
+              result.setIdseIsSet(true);
+              msg = result;
+            } else if (e instanceof org.apache.thrift.transport.TTransportException) {
+              _LOGGER.error("TTransportException inside handler", e);
+              fb.close();
+              return;
+            } else if (e instanceof org.apache.thrift.TApplicationException) {
+              _LOGGER.error("TApplicationException inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = (org.apache.thrift.TApplicationException)e;
+            } else {
+              _LOGGER.error("Exception inside handler", e);
+              msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
+              msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
+            }
+            try {
+              fcall.sendResponse(fb,msg,msgType,seqid);
+            } catch (Exception ex) {
+              _LOGGER.error("Exception writing to internal frame buffer", ex);
+              fb.close();
+            }
+          }
+        };
+      }
+
+      protected boolean isOneway() {
+        return false;
+      }
+
+      public void start(I iface, getUsersWithRole_args args, org.apache.thrift.async.AsyncMethodCallback<java.util.List<org.apache.custos.profile.model.user.UserProfile>> resultHandler) throws org.apache.thrift.TException {
+        iface.getUsersWithRole(args.authzToken, args.roleName, args.tenantAdminPasswordCredential,resultHandler);
+      }
+    }
+
+  }
+
+  public static class getAPIVersion_args implements org.apache.thrift.TBase<getAPIVersion_args, getAPIVersion_args._Fields>, java.io.Serializable, Cloneable, Comparable<getAPIVersion_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getAPIVersion_args");
+
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getAPIVersion_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getAPIVersion_argsTupleSchemeFactory();
+
+
+    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+;
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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;
+      }
+    }
+    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getAPIVersion_args.class, metaDataMap);
+    }
+
+    public getAPIVersion_args() {
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getAPIVersion_args(getAPIVersion_args other) {
+    }
+
+    public getAPIVersion_args deepCopy() {
+      return new getAPIVersion_args(this);
+    }
+
+    @Override
+    public void clear() {
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      }
+      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) {
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getAPIVersion_args)
+        return this.equals((getAPIVersion_args)that);
+      return false;
+    }
+
+    public boolean equals(getAPIVersion_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getAPIVersion_args other) {
+      if (!getClass().equals(other.getClass())) {
+        return getClass().getName().compareTo(other.getClass().getName());
+      }
+
+      int lastComparison = 0;
+
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getAPIVersion_args(");
+      boolean first = true;
+
+      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 getAPIVersion_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getAPIVersion_argsStandardScheme getScheme() {
+        return new getAPIVersion_argsStandardScheme();
+      }
+    }
+
+    private static class getAPIVersion_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getAPIVersion_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getAPIVersion_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) {
+            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, getAPIVersion_args struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getAPIVersion_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getAPIVersion_argsTupleScheme getScheme() {
+        return new getAPIVersion_argsTupleScheme();
+      }
+    }
+
+    private static class getAPIVersion_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getAPIVersion_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getAPIVersion_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getAPIVersion_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class getAPIVersion_result implements org.apache.thrift.TBase<getAPIVersion_result, getAPIVersion_result._Fields>, java.io.Serializable, Cloneable, Comparable<getAPIVersion_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getAPIVersion_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 IDSE_FIELD_DESC = new org.apache.thrift.protocol.TField("Idse", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getAPIVersion_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getAPIVersion_resultTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable String success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // 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"),
+      IDSE((short)1, "Idse");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // IDSE
+            return IDSE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getAPIVersion_result.class, metaDataMap);
+    }
+
+    public getAPIVersion_result() {
+    }
+
+    public getAPIVersion_result(
+      String success,
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse)
+    {
+      this();
+      this.success = success;
+      this.Idse = Idse;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getAPIVersion_result(getAPIVersion_result other) {
+      if (other.isSetSuccess()) {
+        this.success = other.success;
+      }
+      if (other.isSetIdse()) {
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
+      }
+    }
+
+    public getAPIVersion_result deepCopy() {
+      return new getAPIVersion_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+      this.Idse = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getSuccess() {
+      return this.success;
+    }
+
+    public getAPIVersion_result setSuccess(@org.apache.thrift.annotation.Nullable 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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
+      return this.Idse;
+    }
+
+    public getAPIVersion_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+      this.Idse = Idse;
+      return this;
+    }
+
+    public void unsetIdse() {
+      this.Idse = null;
+    }
+
+    /** Returns true if field Idse is set (has been assigned a value) and false otherwise */
+    public boolean isSetIdse() {
+      return this.Idse != null;
+    }
+
+    public void setIdseIsSet(boolean value) {
+      if (!value) {
+        this.Idse = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((String)value);
+        }
+        break;
+
+      case IDSE:
+        if (value == null) {
+          unsetIdse();
+        } else {
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      case IDSE:
+        return getIdse();
+
+      }
+      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 IDSE:
+        return isSetIdse();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getAPIVersion_result)
+        return this.equals((getAPIVersion_result)that);
+      return false;
+    }
+
+    public boolean equals(getAPIVersion_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_Idse = true && this.isSetIdse();
+      boolean that_present_Idse = true && that.isSetIdse();
+      if (this_present_Idse || that_present_Idse) {
+        if (!(this_present_Idse && that_present_Idse))
+          return false;
+        if (!this.Idse.equals(that.Idse))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
+      if (isSetSuccess())
+        hashCode = hashCode * 8191 + success.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetIdse()) ? 131071 : 524287);
+      if (isSetIdse())
+        hashCode = hashCode * 8191 + Idse.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(getAPIVersion_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(isSetIdse()).compareTo(other.isSetIdse());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetIdse()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.Idse, other.Idse);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getAPIVersion_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("Idse:");
+      if (this.Idse == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.Idse);
+      }
+      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 getAPIVersion_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getAPIVersion_resultStandardScheme getScheme() {
+        return new getAPIVersion_resultStandardScheme();
+      }
+    }
+
+    private static class getAPIVersion_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getAPIVersion_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, getAPIVersion_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: // IDSE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+                struct.Idse.read(iprot);
+                struct.setIdseIsSet(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, getAPIVersion_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.Idse != null) {
+          oprot.writeFieldBegin(IDSE_FIELD_DESC);
+          struct.Idse.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class getAPIVersion_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public getAPIVersion_resultTupleScheme getScheme() {
+        return new getAPIVersion_resultTupleScheme();
+      }
+    }
+
+    private static class getAPIVersion_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getAPIVersion_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, getAPIVersion_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetIdse()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          oprot.writeString(struct.success);
+        }
+        if (struct.isSetIdse()) {
+          struct.Idse.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, getAPIVersion_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = iprot.readString();
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+          struct.Idse.read(iprot);
+          struct.setIdseIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class setUpGateway_args implements org.apache.thrift.TBase<setUpGateway_args, setUpGateway_args._Fields>, java.io.Serializable, Cloneable, Comparable<setUpGateway_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setUpGateway_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_FIELD_DESC = new org.apache.thrift.protocol.TField("gateway", org.apache.thrift.protocol.TType.STRUCT, (short)2);
+    private static final org.apache.thrift.protocol.TField TENANT_ADMIN_PASSWORD_CREDENTIAL_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantAdminPasswordCredential", org.apache.thrift.protocol.TType.STRUCT, (short)3);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setUpGateway_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setUpGateway_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway gateway; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential; // 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((short)2, "gateway"),
+      TENANT_ADMIN_PASSWORD_CREDENTIAL((short)3, "tenantAdminPasswordCredential");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          case 2: // GATEWAY
+            return GATEWAY;
+          case 3: // TENANT_ADMIN_PASSWORD_CREDENTIAL
+            return TENANT_ADMIN_PASSWORD_CREDENTIAL;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
+      tmpMap.put(_Fields.GATEWAY, new org.apache.thrift.meta_data.FieldMetaData("gateway", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.workspace.Gateway.class)));
+      tmpMap.put(_Fields.TENANT_ADMIN_PASSWORD_CREDENTIAL, new org.apache.thrift.meta_data.FieldMetaData("tenantAdminPasswordCredential", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.tenant.PasswordCredential.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setUpGateway_args.class, metaDataMap);
+    }
+
+    public setUpGateway_args() {
+    }
+
+    public setUpGateway_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      org.apache.custos.profile.model.workspace.Gateway gateway,
+      org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential)
+    {
+      this();
+      this.authzToken = authzToken;
+      this.gateway = gateway;
+      this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public setUpGateway_args(setUpGateway_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+      if (other.isSetGateway()) {
+        this.gateway = new org.apache.custos.profile.model.workspace.Gateway(other.gateway);
+      }
+      if (other.isSetTenantAdminPasswordCredential()) {
+        this.tenantAdminPasswordCredential = new org.apache.custos.profile.model.tenant.PasswordCredential(other.tenantAdminPasswordCredential);
+      }
+    }
+
+    public setUpGateway_args deepCopy() {
+      return new setUpGateway_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+      this.gateway = null;
+      this.tenantAdminPasswordCredential = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public setUpGateway_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.model.workspace.Gateway getGateway() {
+      return this.gateway;
+    }
+
+    public setUpGateway_args setGateway(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway gateway) {
+      this.gateway = gateway;
+      return this;
+    }
+
+    public void unsetGateway() {
+      this.gateway = null;
+    }
+
+    /** Returns true if field gateway is set (has been assigned a value) and false otherwise */
+    public boolean isSetGateway() {
+      return this.gateway != null;
+    }
+
+    public void setGatewayIsSet(boolean value) {
+      if (!value) {
+        this.gateway = null;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.model.tenant.PasswordCredential getTenantAdminPasswordCredential() {
+      return this.tenantAdminPasswordCredential;
+    }
+
+    public setUpGateway_args setTenantAdminPasswordCredential(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.tenant.PasswordCredential tenantAdminPasswordCredential) {
+      this.tenantAdminPasswordCredential = tenantAdminPasswordCredential;
+      return this;
+    }
+
+    public void unsetTenantAdminPasswordCredential() {
+      this.tenantAdminPasswordCredential = null;
+    }
+
+    /** Returns true if field tenantAdminPasswordCredential is set (has been assigned a value) and false otherwise */
+    public boolean isSetTenantAdminPasswordCredential() {
+      return this.tenantAdminPasswordCredential != null;
+    }
+
+    public void setTenantAdminPasswordCredentialIsSet(boolean value) {
+      if (!value) {
+        this.tenantAdminPasswordCredential = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case GATEWAY:
+        if (value == null) {
+          unsetGateway();
+        } else {
+          setGateway((org.apache.custos.profile.model.workspace.Gateway)value);
+        }
+        break;
+
+      case TENANT_ADMIN_PASSWORD_CREDENTIAL:
+        if (value == null) {
+          unsetTenantAdminPasswordCredential();
+        } else {
+          setTenantAdminPasswordCredential((org.apache.custos.profile.model.tenant.PasswordCredential)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      case GATEWAY:
+        return getGateway();
+
+      case TENANT_ADMIN_PASSWORD_CREDENTIAL:
+        return getTenantAdminPasswordCredential();
+
+      }
+      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:
+        return isSetGateway();
+      case TENANT_ADMIN_PASSWORD_CREDENTIAL:
+        return isSetTenantAdminPasswordCredential();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof setUpGateway_args)
+        return this.equals((setUpGateway_args)that);
+      return false;
+    }
+
+    public boolean equals(setUpGateway_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_gateway = true && this.isSetGateway();
+      boolean that_present_gateway = true && that.isSetGateway();
+      if (this_present_gateway || that_present_gateway) {
+        if (!(this_present_gateway && that_present_gateway))
+          return false;
+        if (!this.gateway.equals(that.gateway))
+          return false;
+      }
+
+      boolean this_present_tenantAdminPasswordCredential = true && this.isSetTenantAdminPasswordCredential();
+      boolean that_present_tenantAdminPasswordCredential = true && that.isSetTenantAdminPasswordCredential();
+      if (this_present_tenantAdminPasswordCredential || that_present_tenantAdminPasswordCredential) {
+        if (!(this_present_tenantAdminPasswordCredential && that_present_tenantAdminPasswordCredential))
+          return false;
+        if (!this.tenantAdminPasswordCredential.equals(that.tenantAdminPasswordCredential))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetGateway()) ? 131071 : 524287);
+      if (isSetGateway())
+        hashCode = hashCode * 8191 + gateway.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetTenantAdminPasswordCredential()) ? 131071 : 524287);
+      if (isSetTenantAdminPasswordCredential())
+        hashCode = hashCode * 8191 + tenantAdminPasswordCredential.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(setUpGateway_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(isSetGateway()).compareTo(other.isSetGateway());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetGateway()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.gateway, other.gateway);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      lastComparison = Boolean.valueOf(isSetTenantAdminPasswordCredential()).compareTo(other.isSetTenantAdminPasswordCredential());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetTenantAdminPasswordCredential()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantAdminPasswordCredential, other.tenantAdminPasswordCredential);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("setUpGateway_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("gateway:");
+      if (this.gateway == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.gateway);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("tenantAdminPasswordCredential:");
+      if (this.tenantAdminPasswordCredential == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.tenantAdminPasswordCredential);
+      }
+      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 (gateway == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'gateway' was not present! Struct: " + toString());
+      }
+      if (tenantAdminPasswordCredential == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'tenantAdminPasswordCredential' was not present! Struct: " + toString());
+      }
+      // check for sub-struct validity
+      if (authzToken != null) {
+        authzToken.validate();
+      }
+      if (gateway != null) {
+        gateway.validate();
+      }
+      if (tenantAdminPasswordCredential != null) {
+        tenantAdminPasswordCredential.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 setUpGateway_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public setUpGateway_argsStandardScheme getScheme() {
+        return new setUpGateway_argsStandardScheme();
+      }
+    }
+
+    private static class setUpGateway_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<setUpGateway_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, setUpGateway_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.custos.commons.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 2: // GATEWAY
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.gateway = new org.apache.custos.profile.model.workspace.Gateway();
+                struct.gateway.read(iprot);
+                struct.setGatewayIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 3: // TENANT_ADMIN_PASSWORD_CREDENTIAL
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.tenantAdminPasswordCredential = new org.apache.custos.profile.model.tenant.PasswordCredential();
+                struct.tenantAdminPasswordCredential.read(iprot);
+                struct.setTenantAdminPasswordCredentialIsSet(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, setUpGateway_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.gateway != null) {
+          oprot.writeFieldBegin(GATEWAY_FIELD_DESC);
+          struct.gateway.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        if (struct.tenantAdminPasswordCredential != null) {
+          oprot.writeFieldBegin(TENANT_ADMIN_PASSWORD_CREDENTIAL_FIELD_DESC);
+          struct.tenantAdminPasswordCredential.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class setUpGateway_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public setUpGateway_argsTupleScheme getScheme() {
+        return new setUpGateway_argsTupleScheme();
+      }
+    }
+
+    private static class setUpGateway_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<setUpGateway_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, setUpGateway_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+        struct.gateway.write(oprot);
+        struct.tenantAdminPasswordCredential.write(oprot);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, setUpGateway_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+        struct.gateway = new org.apache.custos.profile.model.workspace.Gateway();
+        struct.gateway.read(iprot);
+        struct.setGatewayIsSet(true);
+        struct.tenantAdminPasswordCredential = new org.apache.custos.profile.model.tenant.PasswordCredential();
+        struct.tenantAdminPasswordCredential.read(iprot);
+        struct.setTenantAdminPasswordCredentialIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class setUpGateway_result implements org.apache.thrift.TBase<setUpGateway_result, setUpGateway_result._Fields>, java.io.Serializable, Cloneable, Comparable<setUpGateway_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("setUpGateway_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
+    private static final org.apache.thrift.protocol.TField IDSE_FIELD_DESC = new org.apache.thrift.protocol.TField("Idse", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new setUpGateway_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new setUpGateway_resultTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // 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"),
+      IDSE((short)1, "Idse");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // IDSE
+            return IDSE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.model.workspace.Gateway.class)));
+      tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(setUpGateway_result.class, metaDataMap);
+    }
+
+    public setUpGateway_result() {
+    }
+
+    public setUpGateway_result(
+      org.apache.custos.profile.model.workspace.Gateway success,
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse)
+    {
+      this();
+      this.success = success;
+      this.Idse = Idse;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public setUpGateway_result(setUpGateway_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new org.apache.custos.profile.model.workspace.Gateway(other.success);
+      }
+      if (other.isSetIdse()) {
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
+      }
+    }
+
+    public setUpGateway_result deepCopy() {
+      return new setUpGateway_result(this);
+    }
+
+    @Override
+    public void clear() {
+      this.success = null;
+      this.Idse = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.model.workspace.Gateway getSuccess() {
+      return this.success;
+    }
+
+    public setUpGateway_result setSuccess(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.model.workspace.Gateway 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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
+      return this.Idse;
+    }
+
+    public setUpGateway_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+      this.Idse = Idse;
+      return this;
+    }
+
+    public void unsetIdse() {
+      this.Idse = null;
+    }
+
+    /** Returns true if field Idse is set (has been assigned a value) and false otherwise */
+    public boolean isSetIdse() {
+      return this.Idse != null;
+    }
+
+    public void setIdseIsSet(boolean value) {
+      if (!value) {
+        this.Idse = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.custos.profile.model.workspace.Gateway)value);
+        }
+        break;
+
+      case IDSE:
+        if (value == null) {
+          unsetIdse();
+        } else {
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      case IDSE:
+        return getIdse();
+
+      }
+      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 IDSE:
+        return isSetIdse();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof setUpGateway_result)
+        return this.equals((setUpGateway_result)that);
+      return false;
+    }
+
+    public boolean equals(setUpGateway_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_Idse = true && this.isSetIdse();
+      boolean that_present_Idse = true && that.isSetIdse();
+      if (this_present_Idse || that_present_Idse) {
+        if (!(this_present_Idse && that_present_Idse))
+          return false;
+        if (!this.Idse.equals(that.Idse))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287);
+      if (isSetSuccess())
+        hashCode = hashCode * 8191 + success.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetIdse()) ? 131071 : 524287);
+      if (isSetIdse())
+        hashCode = hashCode * 8191 + Idse.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(setUpGateway_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(isSetIdse()).compareTo(other.isSetIdse());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetIdse()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.Idse, other.Idse);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("setUpGateway_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("Idse:");
+      if (this.Idse == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.Idse);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws org.apache.thrift.TException {
+      // check for required fields
+      // check for sub-struct validity
+      if (success != null) {
+        success.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 setUpGateway_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public setUpGateway_resultStandardScheme getScheme() {
+        return new setUpGateway_resultStandardScheme();
+      }
+    }
+
+    private static class setUpGateway_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<setUpGateway_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, setUpGateway_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.STRUCT) {
+                struct.success = new org.apache.custos.profile.model.workspace.Gateway();
+                struct.success.read(iprot);
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // IDSE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+                struct.Idse.read(iprot);
+                struct.setIdseIsSet(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, setUpGateway_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.success != null) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          struct.success.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        if (struct.Idse != null) {
+          oprot.writeFieldBegin(IDSE_FIELD_DESC);
+          struct.Idse.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class setUpGateway_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public setUpGateway_resultTupleScheme getScheme() {
+        return new setUpGateway_resultTupleScheme();
+      }
+    }
+
+    private static class setUpGateway_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<setUpGateway_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, setUpGateway_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetIdse()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          struct.success.write(oprot);
+        }
+        if (struct.isSetIdse()) {
+          struct.Idse.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, setUpGateway_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = new org.apache.custos.profile.model.workspace.Gateway();
+          struct.success.read(iprot);
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+          struct.Idse.read(iprot);
+          struct.setIdseIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class isUsernameAvailable_args implements org.apache.thrift.TBase<isUsernameAvailable_args, isUsernameAvailable_args._Fields>, java.io.Serializable, Cloneable, Comparable<isUsernameAvailable_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isUsernameAvailable_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 USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)2);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUsernameAvailable_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUsernameAvailable_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String username; // 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"),
+      USERNAME((short)2, "username");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          case 2: // USERNAME
+            return USERNAME;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
+      tmpMap.put(_Fields.USERNAME, 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)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUsernameAvailable_args.class, metaDataMap);
+    }
+
+    public isUsernameAvailable_args() {
+    }
+
+    public isUsernameAvailable_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String username)
+    {
+      this();
+      this.authzToken = authzToken;
+      this.username = username;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public isUsernameAvailable_args(isUsernameAvailable_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+      if (other.isSetUsername()) {
+        this.username = other.username;
+      }
+    }
+
+    public isUsernameAvailable_args deepCopy() {
+      return new isUsernameAvailable_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+      this.username = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public isUsernameAvailable_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getUsername() {
+      return this.username;
+    }
+
+    public isUsernameAvailable_args setUsername(@org.apache.thrift.annotation.Nullable 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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case USERNAME:
+        if (value == null) {
+          unsetUsername();
+        } else {
+          setUsername((String)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      case USERNAME:
+        return getUsername();
+
+      }
+      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 USERNAME:
+        return isSetUsername();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof isUsernameAvailable_args)
+        return this.equals((isUsernameAvailable_args)that);
+      return false;
+    }
+
+    public boolean equals(isUsernameAvailable_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetUsername()) ? 131071 : 524287);
+      if (isSetUsername())
+        hashCode = hashCode * 8191 + username.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(isUsernameAvailable_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(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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("isUsernameAvailable_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("username:");
+      if (this.username == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.username);
+      }
+      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 (username == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'username' 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 isUsernameAvailable_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUsernameAvailable_argsStandardScheme getScheme() {
+        return new isUsernameAvailable_argsStandardScheme();
+      }
+    }
+
+    private static class isUsernameAvailable_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<isUsernameAvailable_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, isUsernameAvailable_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.custos.commons.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 2: // USERNAME
+              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;
+            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, isUsernameAvailable_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.username != null) {
+          oprot.writeFieldBegin(USERNAME_FIELD_DESC);
+          oprot.writeString(struct.username);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class isUsernameAvailable_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUsernameAvailable_argsTupleScheme getScheme() {
+        return new isUsernameAvailable_argsTupleScheme();
+      }
+    }
+
+    private static class isUsernameAvailable_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<isUsernameAvailable_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, isUsernameAvailable_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+        oprot.writeString(struct.username);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, isUsernameAvailable_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+        struct.username = iprot.readString();
+        struct.setUsernameIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class isUsernameAvailable_result implements org.apache.thrift.TBase<isUsernameAvailable_result, isUsernameAvailable_result._Fields>, java.io.Serializable, Cloneable, Comparable<isUsernameAvailable_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("isUsernameAvailable_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0);
+    private static final org.apache.thrift.protocol.TField IDSE_FIELD_DESC = new org.apache.thrift.protocol.TField("Idse", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new isUsernameAvailable_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new isUsernameAvailable_resultTupleSchemeFactory();
+
+    public boolean success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // 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"),
+      IDSE((short)1, "Idse");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // IDSE
+            return IDSE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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
+    private static final int __SUCCESS_ISSET_ID = 0;
+    private byte __isset_bitfield = 0;
+    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.BOOL)));
+      tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUsernameAvailable_result.class, metaDataMap);
+    }
+
+    public isUsernameAvailable_result() {
+    }
+
+    public isUsernameAvailable_result(
+      boolean success,
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse)
+    {
+      this();
+      this.success = success;
+      setSuccessIsSet(true);
+      this.Idse = Idse;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public isUsernameAvailable_result(isUsernameAvailable_result other) {
+      __isset_bitfield = other.__isset_bitfield;
+      this.success = other.success;
+      if (other.isSetIdse()) {
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
+      }
+    }
+
+    public isUsernameAvailable_result deepCopy() {
+      return new isUsernameAvailable_result(this);
+    }
+
+    @Override
+    public void clear() {
+      setSuccessIsSet(false);
+      this.success = false;
+      this.Idse = null;
+    }
+
+    public boolean isSuccess() {
+      return this.success;
+    }
+
+    public isUsernameAvailable_result setSuccess(boolean success) {
+      this.success = success;
+      setSuccessIsSet(true);
+      return this;
+    }
+
+    public void unsetSuccess() {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    /** Returns true if field success is set (has been assigned a value) and false otherwise */
+    public boolean isSetSuccess() {
+      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    public void setSuccessIsSet(boolean value) {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
+      return this.Idse;
+    }
+
+    public isUsernameAvailable_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+      this.Idse = Idse;
+      return this;
+    }
+
+    public void unsetIdse() {
+      this.Idse = null;
+    }
+
+    /** Returns true if field Idse is set (has been assigned a value) and false otherwise */
+    public boolean isSetIdse() {
+      return this.Idse != null;
+    }
+
+    public void setIdseIsSet(boolean value) {
+      if (!value) {
+        this.Idse = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((Boolean)value);
+        }
+        break;
+
+      case IDSE:
+        if (value == null) {
+          unsetIdse();
+        } else {
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return isSuccess();
+
+      case IDSE:
+        return getIdse();
+
+      }
+      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 IDSE:
+        return isSetIdse();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof isUsernameAvailable_result)
+        return this.equals((isUsernameAvailable_result)that);
+      return false;
+    }
+
+    public boolean equals(isUsernameAvailable_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      boolean this_present_success = true;
+      boolean that_present_success = true;
+      if (this_present_success || that_present_success) {
+        if (!(this_present_success && that_present_success))
+          return false;
+        if (this.success != that.success)
+          return false;
+      }
+
+      boolean this_present_Idse = true && this.isSetIdse();
+      boolean that_present_Idse = true && that.isSetIdse();
+      if (this_present_Idse || that_present_Idse) {
+        if (!(this_present_Idse && that_present_Idse))
+          return false;
+        if (!this.Idse.equals(that.Idse))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((success) ? 131071 : 524287);
+
+      hashCode = hashCode * 8191 + ((isSetIdse()) ? 131071 : 524287);
+      if (isSetIdse())
+        hashCode = hashCode * 8191 + Idse.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(isUsernameAvailable_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(isSetIdse()).compareTo(other.isSetIdse());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetIdse()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.Idse, other.Idse);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("isUsernameAvailable_result(");
+      boolean first = true;
+
+      sb.append("success:");
+      sb.append(this.success);
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("Idse:");
+      if (this.Idse == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.Idse);
+      }
+      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 {
+        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+        __isset_bitfield = 0;
+        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 isUsernameAvailable_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUsernameAvailable_resultStandardScheme getScheme() {
+        return new isUsernameAvailable_resultStandardScheme();
+      }
+    }
+
+    private static class isUsernameAvailable_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<isUsernameAvailable_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, isUsernameAvailable_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.BOOL) {
+                struct.success = iprot.readBool();
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // IDSE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+                struct.Idse.read(iprot);
+                struct.setIdseIsSet(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, isUsernameAvailable_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.isSetSuccess()) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          oprot.writeBool(struct.success);
+          oprot.writeFieldEnd();
+        }
+        if (struct.Idse != null) {
+          oprot.writeFieldBegin(IDSE_FIELD_DESC);
+          struct.Idse.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class isUsernameAvailable_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public isUsernameAvailable_resultTupleScheme getScheme() {
+        return new isUsernameAvailable_resultTupleScheme();
+      }
+    }
+
+    private static class isUsernameAvailable_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<isUsernameAvailable_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, isUsernameAvailable_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetIdse()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          oprot.writeBool(struct.success);
+        }
+        if (struct.isSetIdse()) {
+          struct.Idse.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, isUsernameAvailable_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = iprot.readBool();
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+          struct.Idse.read(iprot);
+          struct.setIdseIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class registerUser_args implements org.apache.thrift.TBase<registerUser_args, registerUser_args._Fields>, java.io.Serializable, Cloneable, Comparable<registerUser_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("registerUser_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 USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)2);
+    private static final org.apache.thrift.protocol.TField EMAIL_ADDRESS_FIELD_DESC = new org.apache.thrift.protocol.TField("emailAddress", org.apache.thrift.protocol.TType.STRING, (short)3);
+    private static final org.apache.thrift.protocol.TField FIRST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("firstName", org.apache.thrift.protocol.TType.STRING, (short)4);
+    private static final org.apache.thrift.protocol.TField LAST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("lastName", org.apache.thrift.protocol.TType.STRING, (short)5);
+    private static final org.apache.thrift.protocol.TField NEW_PASSWORD_FIELD_DESC = new org.apache.thrift.protocol.TField("newPassword", org.apache.thrift.protocol.TType.STRING, (short)6);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new registerUser_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new registerUser_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String username; // required
+    public @org.apache.thrift.annotation.Nullable String emailAddress; // required
+    public @org.apache.thrift.annotation.Nullable String firstName; // required
+    public @org.apache.thrift.annotation.Nullable String lastName; // required
+    public @org.apache.thrift.annotation.Nullable String newPassword; // 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"),
+      USERNAME((short)2, "username"),
+      EMAIL_ADDRESS((short)3, "emailAddress"),
+      FIRST_NAME((short)4, "firstName"),
+      LAST_NAME((short)5, "lastName"),
+      NEW_PASSWORD((short)6, "newPassword");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          case 2: // USERNAME
+            return USERNAME;
+          case 3: // EMAIL_ADDRESS
+            return EMAIL_ADDRESS;
+          case 4: // FIRST_NAME
+            return FIRST_NAME;
+          case 5: // LAST_NAME
+            return LAST_NAME;
+          case 6: // NEW_PASSWORD
+            return NEW_PASSWORD;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
+      tmpMap.put(_Fields.USERNAME, 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.EMAIL_ADDRESS, new org.apache.thrift.meta_data.FieldMetaData("emailAddress", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+      tmpMap.put(_Fields.FIRST_NAME, new org.apache.thrift.meta_data.FieldMetaData("firstName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+      tmpMap.put(_Fields.LAST_NAME, new org.apache.thrift.meta_data.FieldMetaData("lastName", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+      tmpMap.put(_Fields.NEW_PASSWORD, new org.apache.thrift.meta_data.FieldMetaData("newPassword", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(registerUser_args.class, metaDataMap);
+    }
+
+    public registerUser_args() {
+    }
+
+    public registerUser_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String username,
+      String emailAddress,
+      String firstName,
+      String lastName,
+      String newPassword)
+    {
+      this();
+      this.authzToken = authzToken;
+      this.username = username;
+      this.emailAddress = emailAddress;
+      this.firstName = firstName;
+      this.lastName = lastName;
+      this.newPassword = newPassword;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public registerUser_args(registerUser_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+      if (other.isSetUsername()) {
+        this.username = other.username;
+      }
+      if (other.isSetEmailAddress()) {
+        this.emailAddress = other.emailAddress;
+      }
+      if (other.isSetFirstName()) {
+        this.firstName = other.firstName;
+      }
+      if (other.isSetLastName()) {
+        this.lastName = other.lastName;
+      }
+      if (other.isSetNewPassword()) {
+        this.newPassword = other.newPassword;
+      }
+    }
+
+    public registerUser_args deepCopy() {
+      return new registerUser_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+      this.username = null;
+      this.emailAddress = null;
+      this.firstName = null;
+      this.lastName = null;
+      this.newPassword = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public registerUser_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getUsername() {
+      return this.username;
+    }
+
+    public registerUser_args setUsername(@org.apache.thrift.annotation.Nullable 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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getEmailAddress() {
+      return this.emailAddress;
+    }
+
+    public registerUser_args setEmailAddress(@org.apache.thrift.annotation.Nullable String emailAddress) {
+      this.emailAddress = emailAddress;
+      return this;
+    }
+
+    public void unsetEmailAddress() {
+      this.emailAddress = null;
+    }
+
+    /** Returns true if field emailAddress is set (has been assigned a value) and false otherwise */
+    public boolean isSetEmailAddress() {
+      return this.emailAddress != null;
+    }
+
+    public void setEmailAddressIsSet(boolean value) {
+      if (!value) {
+        this.emailAddress = null;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getFirstName() {
+      return this.firstName;
+    }
+
+    public registerUser_args setFirstName(@org.apache.thrift.annotation.Nullable String firstName) {
+      this.firstName = firstName;
+      return this;
+    }
+
+    public void unsetFirstName() {
+      this.firstName = null;
+    }
+
+    /** Returns true if field firstName is set (has been assigned a value) and false otherwise */
+    public boolean isSetFirstName() {
+      return this.firstName != null;
+    }
+
+    public void setFirstNameIsSet(boolean value) {
+      if (!value) {
+        this.firstName = null;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getLastName() {
+      return this.lastName;
+    }
+
+    public registerUser_args setLastName(@org.apache.thrift.annotation.Nullable String lastName) {
+      this.lastName = lastName;
+      return this;
+    }
+
+    public void unsetLastName() {
+      this.lastName = null;
+    }
+
+    /** Returns true if field lastName is set (has been assigned a value) and false otherwise */
+    public boolean isSetLastName() {
+      return this.lastName != null;
+    }
+
+    public void setLastNameIsSet(boolean value) {
+      if (!value) {
+        this.lastName = null;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getNewPassword() {
+      return this.newPassword;
+    }
+
+    public registerUser_args setNewPassword(@org.apache.thrift.annotation.Nullable String newPassword) {
+      this.newPassword = newPassword;
+      return this;
+    }
+
+    public void unsetNewPassword() {
+      this.newPassword = null;
+    }
+
+    /** Returns true if field newPassword is set (has been assigned a value) and false otherwise */
+    public boolean isSetNewPassword() {
+      return this.newPassword != null;
+    }
+
+    public void setNewPasswordIsSet(boolean value) {
+      if (!value) {
+        this.newPassword = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case USERNAME:
+        if (value == null) {
+          unsetUsername();
+        } else {
+          setUsername((String)value);
+        }
+        break;
+
+      case EMAIL_ADDRESS:
+        if (value == null) {
+          unsetEmailAddress();
+        } else {
+          setEmailAddress((String)value);
+        }
+        break;
+
+      case FIRST_NAME:
+        if (value == null) {
+          unsetFirstName();
+        } else {
+          setFirstName((String)value);
+        }
+        break;
+
+      case LAST_NAME:
+        if (value == null) {
+          unsetLastName();
+        } else {
+          setLastName((String)value);
+        }
+        break;
+
+      case NEW_PASSWORD:
+        if (value == null) {
+          unsetNewPassword();
+        } else {
+          setNewPassword((String)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      case USERNAME:
+        return getUsername();
+
+      case EMAIL_ADDRESS:
+        return getEmailAddress();
+
+      case FIRST_NAME:
+        return getFirstName();
+
+      case LAST_NAME:
+        return getLastName();
+
+      case NEW_PASSWORD:
+        return getNewPassword();
+
+      }
+      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 USERNAME:
+        return isSetUsername();
+      case EMAIL_ADDRESS:
+        return isSetEmailAddress();
+      case FIRST_NAME:
+        return isSetFirstName();
+      case LAST_NAME:
+        return isSetLastName();
+      case NEW_PASSWORD:
+        return isSetNewPassword();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof registerUser_args)
+        return this.equals((registerUser_args)that);
+      return false;
+    }
+
+    public boolean equals(registerUser_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_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_emailAddress = true && this.isSetEmailAddress();
+      boolean that_present_emailAddress = true && that.isSetEmailAddress();
+      if (this_present_emailAddress || that_present_emailAddress) {
+        if (!(this_present_emailAddress && that_present_emailAddress))
+          return false;
+        if (!this.emailAddress.equals(that.emailAddress))
+          return false;
+      }
+
+      boolean this_present_firstName = true && this.isSetFirstName();
+      boolean that_present_firstName = true && that.isSetFirstName();
+      if (this_present_firstName || that_present_firstName) {
+        if (!(this_present_firstName && that_present_firstName))
+          return false;
+        if (!this.firstName.equals(that.firstName))
+          return false;
+      }
+
+      boolean this_present_lastName = true && this.isSetLastName();
+      boolean that_present_lastName = true && that.isSetLastName();
+      if (this_present_lastName || that_present_lastName) {
+        if (!(this_present_lastName && that_present_lastName))
+          return false;
+        if (!this.lastName.equals(that.lastName))
+          return false;
+      }
+
+      boolean this_present_newPassword = true && this.isSetNewPassword();
+      boolean that_present_newPassword = true && that.isSetNewPassword();
+      if (this_present_newPassword || that_present_newPassword) {
+        if (!(this_present_newPassword && that_present_newPassword))
+          return false;
+        if (!this.newPassword.equals(that.newPassword))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetUsername()) ? 131071 : 524287);
+      if (isSetUsername())
+        hashCode = hashCode * 8191 + username.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetEmailAddress()) ? 131071 : 524287);
+      if (isSetEmailAddress())
+        hashCode = hashCode * 8191 + emailAddress.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetFirstName()) ? 131071 : 524287);
+      if (isSetFirstName())
+        hashCode = hashCode * 8191 + firstName.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetLastName()) ? 131071 : 524287);
+      if (isSetLastName())
+        hashCode = hashCode * 8191 + lastName.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetNewPassword()) ? 131071 : 524287);
+      if (isSetNewPassword())
+        hashCode = hashCode * 8191 + newPassword.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(registerUser_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(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(isSetEmailAddress()).compareTo(other.isSetEmailAddress());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetEmailAddress()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.emailAddress, other.emailAddress);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      lastComparison = Boolean.valueOf(isSetFirstName()).compareTo(other.isSetFirstName());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetFirstName()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.firstName, other.firstName);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      lastComparison = Boolean.valueOf(isSetLastName()).compareTo(other.isSetLastName());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetLastName()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.lastName, other.lastName);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      lastComparison = Boolean.valueOf(isSetNewPassword()).compareTo(other.isSetNewPassword());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetNewPassword()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.newPassword, other.newPassword);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("registerUser_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("username:");
+      if (this.username == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.username);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("emailAddress:");
+      if (this.emailAddress == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.emailAddress);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("firstName:");
+      if (this.firstName == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.firstName);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("lastName:");
+      if (this.lastName == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.lastName);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("newPassword:");
+      if (this.newPassword == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.newPassword);
+      }
+      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 (username == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'username' was not present! Struct: " + toString());
+      }
+      if (emailAddress == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'emailAddress' was not present! Struct: " + toString());
+      }
+      if (firstName == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'firstName' was not present! Struct: " + toString());
+      }
+      if (lastName == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'lastName' was not present! Struct: " + toString());
+      }
+      if (newPassword == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'newPassword' 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 registerUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public registerUser_argsStandardScheme getScheme() {
+        return new registerUser_argsStandardScheme();
+      }
+    }
+
+    private static class registerUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<registerUser_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, registerUser_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.custos.commons.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 2: // USERNAME
+              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 3: // EMAIL_ADDRESS
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+                struct.emailAddress = iprot.readString();
+                struct.setEmailAddressIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 4: // FIRST_NAME
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+                struct.firstName = iprot.readString();
+                struct.setFirstNameIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 5: // LAST_NAME
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+                struct.lastName = iprot.readString();
+                struct.setLastNameIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 6: // NEW_PASSWORD
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+                struct.newPassword = iprot.readString();
+                struct.setNewPasswordIsSet(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, registerUser_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.username != null) {
+          oprot.writeFieldBegin(USERNAME_FIELD_DESC);
+          oprot.writeString(struct.username);
+          oprot.writeFieldEnd();
+        }
+        if (struct.emailAddress != null) {
+          oprot.writeFieldBegin(EMAIL_ADDRESS_FIELD_DESC);
+          oprot.writeString(struct.emailAddress);
+          oprot.writeFieldEnd();
+        }
+        if (struct.firstName != null) {
+          oprot.writeFieldBegin(FIRST_NAME_FIELD_DESC);
+          oprot.writeString(struct.firstName);
+          oprot.writeFieldEnd();
+        }
+        if (struct.lastName != null) {
+          oprot.writeFieldBegin(LAST_NAME_FIELD_DESC);
+          oprot.writeString(struct.lastName);
+          oprot.writeFieldEnd();
+        }
+        if (struct.newPassword != null) {
+          oprot.writeFieldBegin(NEW_PASSWORD_FIELD_DESC);
+          oprot.writeString(struct.newPassword);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class registerUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public registerUser_argsTupleScheme getScheme() {
+        return new registerUser_argsTupleScheme();
+      }
+    }
+
+    private static class registerUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<registerUser_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, registerUser_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+        oprot.writeString(struct.username);
+        oprot.writeString(struct.emailAddress);
+        oprot.writeString(struct.firstName);
+        oprot.writeString(struct.lastName);
+        oprot.writeString(struct.newPassword);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, registerUser_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+        struct.username = iprot.readString();
+        struct.setUsernameIsSet(true);
+        struct.emailAddress = iprot.readString();
+        struct.setEmailAddressIsSet(true);
+        struct.firstName = iprot.readString();
+        struct.setFirstNameIsSet(true);
+        struct.lastName = iprot.readString();
+        struct.setLastNameIsSet(true);
+        struct.newPassword = iprot.readString();
+        struct.setNewPasswordIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class registerUser_result implements org.apache.thrift.TBase<registerUser_result, registerUser_result._Fields>, java.io.Serializable, Cloneable, Comparable<registerUser_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("registerUser_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0);
+    private static final org.apache.thrift.protocol.TField IDSE_FIELD_DESC = new org.apache.thrift.protocol.TField("Idse", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new registerUser_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new registerUser_resultTupleSchemeFactory();
+
+    public boolean success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // 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"),
+      IDSE((short)1, "Idse");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // IDSE
+            return IDSE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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
+    private static final int __SUCCESS_ISSET_ID = 0;
+    private byte __isset_bitfield = 0;
+    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.BOOL)));
+      tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(registerUser_result.class, metaDataMap);
+    }
+
+    public registerUser_result() {
+    }
+
+    public registerUser_result(
+      boolean success,
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse)
+    {
+      this();
+      this.success = success;
+      setSuccessIsSet(true);
+      this.Idse = Idse;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public registerUser_result(registerUser_result other) {
+      __isset_bitfield = other.__isset_bitfield;
+      this.success = other.success;
+      if (other.isSetIdse()) {
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
+      }
+    }
+
+    public registerUser_result deepCopy() {
+      return new registerUser_result(this);
+    }
+
+    @Override
+    public void clear() {
+      setSuccessIsSet(false);
+      this.success = false;
+      this.Idse = null;
+    }
+
+    public boolean isSuccess() {
+      return this.success;
+    }
+
+    public registerUser_result setSuccess(boolean success) {
+      this.success = success;
+      setSuccessIsSet(true);
+      return this;
+    }
+
+    public void unsetSuccess() {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    /** Returns true if field success is set (has been assigned a value) and false otherwise */
+    public boolean isSetSuccess() {
+      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    public void setSuccessIsSet(boolean value) {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
+      return this.Idse;
+    }
+
+    public registerUser_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+      this.Idse = Idse;
+      return this;
+    }
+
+    public void unsetIdse() {
+      this.Idse = null;
+    }
+
+    /** Returns true if field Idse is set (has been assigned a value) and false otherwise */
+    public boolean isSetIdse() {
+      return this.Idse != null;
+    }
+
+    public void setIdseIsSet(boolean value) {
+      if (!value) {
+        this.Idse = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((Boolean)value);
+        }
+        break;
+
+      case IDSE:
+        if (value == null) {
+          unsetIdse();
+        } else {
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return isSuccess();
+
+      case IDSE:
+        return getIdse();
+
+      }
+      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 IDSE:
+        return isSetIdse();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof registerUser_result)
+        return this.equals((registerUser_result)that);
+      return false;
+    }
+
+    public boolean equals(registerUser_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      boolean this_present_success = true;
+      boolean that_present_success = true;
+      if (this_present_success || that_present_success) {
+        if (!(this_present_success && that_present_success))
+          return false;
+        if (this.success != that.success)
+          return false;
+      }
+
+      boolean this_present_Idse = true && this.isSetIdse();
+      boolean that_present_Idse = true && that.isSetIdse();
+      if (this_present_Idse || that_present_Idse) {
+        if (!(this_present_Idse && that_present_Idse))
+          return false;
+        if (!this.Idse.equals(that.Idse))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((success) ? 131071 : 524287);
+
+      hashCode = hashCode * 8191 + ((isSetIdse()) ? 131071 : 524287);
+      if (isSetIdse())
+        hashCode = hashCode * 8191 + Idse.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(registerUser_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(isSetIdse()).compareTo(other.isSetIdse());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetIdse()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.Idse, other.Idse);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("registerUser_result(");
+      boolean first = true;
+
+      sb.append("success:");
+      sb.append(this.success);
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("Idse:");
+      if (this.Idse == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.Idse);
+      }
+      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 {
+        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+        __isset_bitfield = 0;
+        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 registerUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public registerUser_resultStandardScheme getScheme() {
+        return new registerUser_resultStandardScheme();
+      }
+    }
+
+    private static class registerUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<registerUser_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, registerUser_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.BOOL) {
+                struct.success = iprot.readBool();
+                struct.setSuccessIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 1: // IDSE
+              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
+                struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+                struct.Idse.read(iprot);
+                struct.setIdseIsSet(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, registerUser_result struct) throws org.apache.thrift.TException {
+        struct.validate();
+
+        oprot.writeStructBegin(STRUCT_DESC);
+        if (struct.isSetSuccess()) {
+          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+          oprot.writeBool(struct.success);
+          oprot.writeFieldEnd();
+        }
+        if (struct.Idse != null) {
+          oprot.writeFieldBegin(IDSE_FIELD_DESC);
+          struct.Idse.write(oprot);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class registerUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public registerUser_resultTupleScheme getScheme() {
+        return new registerUser_resultTupleScheme();
+      }
+    }
+
+    private static class registerUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<registerUser_result> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, registerUser_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet optionals = new java.util.BitSet();
+        if (struct.isSetSuccess()) {
+          optionals.set(0);
+        }
+        if (struct.isSetIdse()) {
+          optionals.set(1);
+        }
+        oprot.writeBitSet(optionals, 2);
+        if (struct.isSetSuccess()) {
+          oprot.writeBool(struct.success);
+        }
+        if (struct.isSetIdse()) {
+          struct.Idse.write(oprot);
+        }
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, registerUser_result struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        java.util.BitSet incoming = iprot.readBitSet(2);
+        if (incoming.get(0)) {
+          struct.success = iprot.readBool();
+          struct.setSuccessIsSet(true);
+        }
+        if (incoming.get(1)) {
+          struct.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException();
+          struct.Idse.read(iprot);
+          struct.setIdseIsSet(true);
+        }
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class enableUser_args implements org.apache.thrift.TBase<enableUser_args, enableUser_args._Fields>, java.io.Serializable, Cloneable, Comparable<enableUser_args>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("enableUser_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 USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)2);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new enableUser_argsStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new enableUser_argsTupleSchemeFactory();
+
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.commons.model.security.AuthzToken authzToken; // required
+    public @org.apache.thrift.annotation.Nullable String username; // 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"),
+      USERNAME((short)2, "username");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 1: // AUTHZ_TOKEN
+            return AUTHZ_TOKEN;
+          case 2: // USERNAME
+            return USERNAME;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.class)));
+      tmpMap.put(_Fields.USERNAME, 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)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(enableUser_args.class, metaDataMap);
+    }
+
+    public enableUser_args() {
+    }
+
+    public enableUser_args(
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String username)
+    {
+      this();
+      this.authzToken = authzToken;
+      this.username = username;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public enableUser_args(enableUser_args other) {
+      if (other.isSetAuthzToken()) {
+        this.authzToken = new org.apache.custos.commons.model.security.AuthzToken(other.authzToken);
+      }
+      if (other.isSetUsername()) {
+        this.username = other.username;
+      }
+    }
+
+    public enableUser_args deepCopy() {
+      return new enableUser_args(this);
+    }
+
+    @Override
+    public void clear() {
+      this.authzToken = null;
+      this.username = null;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.commons.model.security.AuthzToken getAuthzToken() {
+      return this.authzToken;
+    }
+
+    public enableUser_args setAuthzToken(@org.apache.thrift.annotation.Nullable org.apache.custos.commons.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;
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public String getUsername() {
+      return this.username;
+    }
+
+    public enableUser_args setUsername(@org.apache.thrift.annotation.Nullable 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 void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
+
+      case USERNAME:
+        if (value == null) {
+          unsetUsername();
+        } else {
+          setUsername((String)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
+
+      case USERNAME:
+        return getUsername();
+
+      }
+      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 USERNAME:
+        return isSetUsername();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof enableUser_args)
+        return this.equals((enableUser_args)that);
+      return false;
+    }
+
+    public boolean equals(enableUser_args that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      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_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;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((isSetAuthzToken()) ? 131071 : 524287);
+      if (isSetAuthzToken())
+        hashCode = hashCode * 8191 + authzToken.hashCode();
+
+      hashCode = hashCode * 8191 + ((isSetUsername()) ? 131071 : 524287);
+      if (isSetUsername())
+        hashCode = hashCode * 8191 + username.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(enableUser_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(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;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("enableUser_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("username:");
+      if (this.username == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.username);
+      }
+      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 (username == null) {
+        throw new org.apache.thrift.protocol.TProtocolException("Required field 'username' 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 enableUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public enableUser_argsStandardScheme getScheme() {
+        return new enableUser_argsStandardScheme();
+      }
+    }
+
+    private static class enableUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<enableUser_args> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, enableUser_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.custos.commons.model.security.AuthzToken();
+                struct.authzToken.read(iprot);
+                struct.setAuthzTokenIsSet(true);
+              } else { 
+                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+              }
+              break;
+            case 2: // USERNAME
+              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;
+            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, enableUser_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.username != null) {
+          oprot.writeFieldBegin(USERNAME_FIELD_DESC);
+          oprot.writeString(struct.username);
+          oprot.writeFieldEnd();
+        }
+        oprot.writeFieldStop();
+        oprot.writeStructEnd();
+      }
+
+    }
+
+    private static class enableUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public enableUser_argsTupleScheme getScheme() {
+        return new enableUser_argsTupleScheme();
+      }
+    }
+
+    private static class enableUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<enableUser_args> {
+
+      @Override
+      public void write(org.apache.thrift.protocol.TProtocol prot, enableUser_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken.write(oprot);
+        oprot.writeString(struct.username);
+      }
+
+      @Override
+      public void read(org.apache.thrift.protocol.TProtocol prot, enableUser_args struct) throws org.apache.thrift.TException {
+        org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+        struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
+        struct.authzToken.read(iprot);
+        struct.setAuthzTokenIsSet(true);
+        struct.username = iprot.readString();
+        struct.setUsernameIsSet(true);
+      }
+    }
+
+    private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+      return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+    }
+  }
+
+  public static class enableUser_result implements org.apache.thrift.TBase<enableUser_result, enableUser_result._Fields>, java.io.Serializable, Cloneable, Comparable<enableUser_result>   {
+    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("enableUser_result");
+
+    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.BOOL, (short)0);
+    private static final org.apache.thrift.protocol.TField IDSE_FIELD_DESC = new org.apache.thrift.protocol.TField("Idse", org.apache.thrift.protocol.TType.STRUCT, (short)1);
+
+    private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new enableUser_resultStandardSchemeFactory();
+    private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new enableUser_resultTupleSchemeFactory();
+
+    public boolean success; // required
+    public @org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse; // 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"),
+      IDSE((short)1, "Idse");
+
+      private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      @org.apache.thrift.annotation.Nullable
+      public static _Fields findByThriftId(int fieldId) {
+        switch(fieldId) {
+          case 0: // SUCCESS
+            return SUCCESS;
+          case 1: // IDSE
+            return IDSE;
+          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.
+       */
+      @org.apache.thrift.annotation.Nullable
+      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
+    private static final int __SUCCESS_ISSET_ID = 0;
+    private byte __isset_bitfield = 0;
+    public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+    static {
+      java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.BOOL)));
+      tmpMap.put(_Fields.IDSE, new org.apache.thrift.meta_data.FieldMetaData("Idse", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException.class)));
+      metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(enableUser_result.class, metaDataMap);
+    }
+
+    public enableUser_result() {
+    }
+
+    public enableUser_result(
+      boolean success,
+      org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse)
+    {
+      this();
+      this.success = success;
+      setSuccessIsSet(true);
+      this.Idse = Idse;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public enableUser_result(enableUser_result other) {
+      __isset_bitfield = other.__isset_bitfield;
+      this.success = other.success;
+      if (other.isSetIdse()) {
+        this.Idse = new org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException(other.Idse);
+      }
+    }
+
+    public enableUser_result deepCopy() {
+      return new enableUser_result(this);
+    }
+
+    @Override
+    public void clear() {
+      setSuccessIsSet(false);
+      this.success = false;
+      this.Idse = null;
+    }
+
+    public boolean isSuccess() {
+      return this.success;
+    }
+
+    public enableUser_result setSuccess(boolean success) {
+      this.success = success;
+      setSuccessIsSet(true);
+      return this;
+    }
+
+    public void unsetSuccess() {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    /** Returns true if field success is set (has been assigned a value) and false otherwise */
+    public boolean isSetSuccess() {
+      return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID);
+    }
+
+    public void setSuccessIsSet(boolean value) {
+      __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value);
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException getIdse() {
+      return this.Idse;
+    }
+
+    public enableUser_result setIdse(@org.apache.thrift.annotation.Nullable org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException Idse) {
+      this.Idse = Idse;
+      return this;
+    }
+
+    public void unsetIdse() {
+      this.Idse = null;
+    }
+
+    /** Returns true if field Idse is set (has been assigned a value) and false otherwise */
+    public boolean isSetIdse() {
+      return this.Idse != null;
+    }
+
+    public void setIdseIsSet(boolean value) {
+      if (!value) {
+        this.Idse = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((Boolean)value);
+        }
+        break;
+
+      case IDSE:
+        if (value == null) {
+          unsetIdse();
+        } else {
+          setIdse((org.apache.custos.profile.iam.admin.services.cpi.exception.IamAdminServicesException)value);
+        }
+        break;
+
+      }
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return isSuccess();
+
+      case IDSE:
+        return getIdse();
+
+      }
+      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 IDSE:
+        return isSetIdse();
+      }
+      throw new IllegalStateException();
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof enableUser_result)
+        return this.equals((enableUser_result)that);
+      return false;
+    }
+
+    public boolean equals(enableUser_result that) {
+      if (that == null)
+        return false;
+      if (this == that)
+        return true;
+
+      boolean this_present_success = true;
+      boolean that_present_success = true;
+      if (this_present_success || that_present_success) {
+        if (!(this_present_success && that_present_success))
+          return false;
+        if (this.success != that.success)
+          return false;
+      }
+
+      boolean this_present_Idse = true && this.isSetIdse();
+      boolean that_present_Idse = true && that.isSetIdse();
+      if (this_present_Idse || that_present_Idse) {
+        if (!(this_present_Idse && that_present_Idse))
+          return false;
+        if (!this.Idse.equals(that.Idse))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      int hashCode = 1;
+
+      hashCode = hashCode * 8191 + ((success) ? 131071 : 524287);
+
+      hashCode = hashCode * 8191 + ((isSetIdse()) ? 131071 : 524287);
+      if (isSetIdse())
+        hashCode = hashCode * 8191 + Idse.hashCode();
+
+      return hashCode;
+    }
+
+    @Override
+    public int compareTo(enableUser_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(isSetIdse()).compareTo(other.isSetIdse());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      if (isSetIdse()) {
+        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.Idse, other.Idse);
+        if (lastComparison != 0) {
+          return lastComparison;
+        }
+      }
+      return 0;
+    }
+
+    @org.apache.thrift.annotation.Nullable
+    public _Fields fieldForId(int fieldId) {
+      return _Fields.findByThriftId(fieldId);
+    }
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
+      scheme(iprot).read(iprot, this);
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+      scheme(oprot).write(oprot, this);
+      }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("enableUser_result(");
+      boolean first = true;
+
+      sb.append("success:");
+      sb.append(this.success);
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("Idse:");
+      if (this.Idse == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.Idse);
+      }
+      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 {
+        // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+        __isset_bitfield = 0;
+        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 enableUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+      public enableUser_resultStandardScheme getScheme() {
+        return new enableUser_resultStandardScheme();
+      }
+    }
+
+    private static class enableUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<enableUser_result> {
+
+      public void read(org.apache.thrift.protocol.TProtocol iprot, enableUser_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;
+          }
... 50501 lines suppressed ...


[airavata-custos] 29/48: added samples for end to end testing and junit test cases

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a08c0b1f7ec431469612d08065822a1631f8b799
Author: Aarushi <aa...@gmail.com>
AuthorDate: Wed Aug 21 23:31:47 2019 -0400

    added samples for end to end testing and junit test cases
---
 ...ava => AuthenticationServiceClientFactory.java} |   2 +-
 .../manager/KeyCloakSecurityManager.java           |   3 +-
 .../src/main/resources/keystores/airavata.jks      | Bin
 .../src/main/resources/keystores/airavata_sym.jks  | Bin
 .../main/resources/keystores/client_truststore.jks | Bin
 .../user/handler/UserProfileServiceHandler.java    |  10 +-
 .../test/java/TestUserProfileServiceHandler.java   |  36 ++--
 .../custos-authentication-service-samples/pom.xml  |  15 ++
 .../sample/CustosAuthenticationServiceSample.java  | 108 +++++++++++
 .../custos-profile-service-samples/pom.xml         |  15 ++
 .../service/samples/TenantProfileSample.java       |  80 ++++++++
 .../profile/service/samples/UserProfileSample.java | 211 +++++++++++++++++++++
 .../samples/utils/ProfileServiceClientUtil.java    |  63 ++++++
 .../resources/profile-client-sample.properties     |  29 +++
 ide-integration/custos-services/pom.xml            |  15 ++
 .../server/start}/CustosAPIServerStarted.java      |   4 +-
 .../src/main/resources/custos-server.properties    |   2 +-
 .../database_scripts/init/01-databases.sql         |  43 +++--
 .../user-profile-catalog-derby.sql                 |  30 ---
 .../user-profile-catalog-mysql.sql                 |  30 ---
 .../src/main/resources/docker-compose.yml          |   0
 .../main/resources/keycloak/Default-export.json    |   0
 .../main/resources/keycloak/Default-export.json.bk |   0
 .../src/main/resources/keycloak/standalone.xml     |   0
 .../src/main/resources/keystores/airavata.jks      | Bin
 .../src/main/resources/keystores/airavata_sym.jks  | Bin
 .../main/resources/keystores/client_truststore.jks | Bin
 ide-integration/pom.xml                            |  18 ++
 28 files changed, 614 insertions(+), 100 deletions(-)

diff --git a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClientFactory.java
similarity index 95%
rename from custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
rename to custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClientFactory.java
index 4fc0444..734e55e 100644
--- a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
+++ b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClientFactory.java
@@ -8,7 +8,7 @@ import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportException;
 
-public class AuthenticationServiceClient {
+public class AuthenticationServiceClientFactory {
 
     public static CustosAuthenticationService.Client createAuthenticationServiceClient(String serverHost, int serverPort)  throws CustosAuthenticationServiceException {
         try {
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
index e7f8b30..13c925e 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
@@ -95,6 +95,7 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
         String accessToken = authzToken.getAccessToken();
         String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
         try {
+            initializeSecurityInfra();
             if (ServerSettings.isAuthzCacheEnabled()) {
                 //obtain an instance of AuthzCacheManager implementation.
                 AuthzCacheManager authzCacheManager = AuthzCacheManagerFactory.getAuthzCacheManager();
@@ -138,6 +139,7 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
     @Override
     public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId) throws CustosSecurityException {
         try {
+            initializeSecurityInfra();
             tenantProfileClient = getTenantProfileServiceClient();
             Gateway gateway = tenantProfileClient.getGatewayUsingGatewayId(authzToken, gatewayId);
             String tokenURL = getTokenEndpoint(gatewayId);
@@ -164,7 +166,6 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
     }
 
     private UserInfo getUserInfo(String gatewayId, String token) throws Exception {
-        //TODO: Confirm the difference between gatewayId and IdentityServerTenant, using gatewayId as of now
         String openIdConnectUrl = getOpenIDConfigurationUrl(gatewayId);
         JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, null));
         String userInfoEndPoint = openIdConnectConfig.getString("userinfo_endpoint");
diff --git a/ide-integration/src/main/resources/keystores/airavata.jks b/custos-connectors/src/main/resources/keystores/airavata.jks
similarity index 100%
copy from ide-integration/src/main/resources/keystores/airavata.jks
copy to custos-connectors/src/main/resources/keystores/airavata.jks
diff --git a/ide-integration/src/main/resources/keystores/airavata_sym.jks b/custos-connectors/src/main/resources/keystores/airavata_sym.jks
similarity index 100%
copy from ide-integration/src/main/resources/keystores/airavata_sym.jks
copy to custos-connectors/src/main/resources/keystores/airavata_sym.jks
diff --git a/ide-integration/src/main/resources/keystores/client_truststore.jks b/custos-connectors/src/main/resources/keystores/client_truststore.jks
similarity index 100%
copy from ide-integration/src/main/resources/keystores/client_truststore.jks
copy to custos-connectors/src/main/resources/keystores/client_truststore.jks
diff --git a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java
index e29b39d..e3c9d07 100644
--- a/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java
+++ b/custos-profile-service/user-profile-service/src/main/java/org/apache/custos/profile/user/handler/UserProfileServiceHandler.java
@@ -103,7 +103,6 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
         try{
             // Lowercase user id and internal id
             userProfile.setUserId(userProfile.getUserId().toLowerCase());
-            userProfile.setCustosInternalUserId(userProfile.getUserId() + "@" + userProfile.getGatewayId());
             userProfile = userProfileRepository.updateUserProfile(userProfile, getIAMUserProfileUpdater(authzToken, userProfile));
             if (null != userProfile) {
                 logger.info("Added UserProfile with userId: " + userProfile.getUserId());
@@ -232,4 +231,13 @@ public class UserProfileServiceHandler implements UserProfileService.Iface {
             throw ex;
         }
     }
+
+    private void updateCustosInternalId(UserProfile userProfile){
+        //TODO: check if other ids need to be changed
+        String internalId = userProfile.getUserId() + "@" + userProfile.getGatewayId();
+        userProfile.setCustosInternalUserId(internalId);
+        if(userProfile.isSetNsfDemographics()){
+            userProfile.setNsfDemographics(userProfile.getNsfDemographics().setCustosInternalUserId(internalId));
+        }
+    }
 }
diff --git a/custos-profile-service/user-profile-service/src/test/java/TestUserProfileServiceHandler.java b/custos-profile-service/user-profile-service/src/test/java/TestUserProfileServiceHandler.java
index b88cee2..75bf90e 100644
--- a/custos-profile-service/user-profile-service/src/test/java/TestUserProfileServiceHandler.java
+++ b/custos-profile-service/user-profile-service/src/test/java/TestUserProfileServiceHandler.java
@@ -9,7 +9,6 @@ import org.apache.custos.profile.user.cpi.exception.UserProfileServiceException;
 import org.apache.custos.profile.user.handler.UserProfileServiceHandler;
 import org.apache.custos.security.manager.CustosSecurityManager;
 import org.apache.custos.security.manager.SecurityManagerFactory;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -40,10 +39,6 @@ public class TestUserProfileServiceHandler {
         authzToken.setClaimsMap(map);
         authzToken.setAccessToken("access token");
     }
-    @After
-    public void cleanUp() {
-
-    }
     @Test
     public void testInitializeUserProfileWhenUserProfileDoesNotExist(@Mocked CustosSecurityManager mockedSecurityManager) throws UserProfileServiceException, CustosSecurityException {
         UserInfo userInfo = new UserInfo();
@@ -64,21 +59,36 @@ public class TestUserProfileServiceHandler {
     }
     @Test
     public void testInitializeUserProfileWhenUserProfileExists(@Mocked CustosSecurityManager mockedSecurityManager) throws UserProfileServiceException, CustosSecurityException{
+        //create a user
         UserInfo userInfo = new UserInfo();
         userInfo.setUsername("test-username");
-        userInfo.setEmailAddress("some-other-test@test.com");
-        userInfo.setFirstName("someother-test-first-name");
-        userInfo.setLastName("someother-test-last-name");
-        String old_email_address = "test@test.com";
+        userInfo.setEmailAddress("test@test.com");
+        userInfo.setFirstName("test-first-name");
+        userInfo.setLastName("test-last-name");
+        //create a user with same username
+        UserInfo userInfoCopy = new UserInfo();
+        userInfoCopy.setUsername("test-username");
+        userInfoCopy.setEmailAddress("some-other-test@test.com");
+        userInfoCopy.setFirstName("someother-test-first-name");
+        userInfoCopy.setLastName("someother-test-last-name");
+        AuthzToken authzTokenCopy = new AuthzToken();
+        HashMap<String,String> map = new HashMap<>();
+        map.put(Constants.GATEWAY_ID, GATEWAY_ID);
+        map.put(Constants.USER_NAME, userInfoCopy.getUsername());
+        authzTokenCopy.setClaimsMap(map);
+        authzTokenCopy.setAccessToken("access token");
+
         new MockUp<SecurityManagerFactory>() {
             @Mock
             public CustosSecurityManager getSecurityManager(){return mockedSecurityManager;};
         };
-        new Expectations() {{ mockedSecurityManager.getUserInfoFromAuthzToken(authzToken); result = userInfo;}};
+        new Expectations() {{
+            mockedSecurityManager.getUserInfoFromAuthzToken(authzToken); result = userInfo;
+            mockedSecurityManager.getUserInfoFromAuthzToken(authzTokenCopy); result = userInfoCopy;}};
 
-        UserProfile createdUserProfile = userProfileServiceHandler.initializeUserProfile(authzToken);
-        assertNotNull(createdUserProfile);
-        assertEquals(old_email_address,createdUserProfile.getEmails().get(0));
+        userProfileServiceHandler.initializeUserProfile(authzToken);
+        UserProfile createdUserProfile = userProfileServiceHandler.initializeUserProfile(authzTokenCopy);
+                assertNotNull(createdUserProfile);
         assertEquals(userInfo.getUsername().toLowerCase(), createdUserProfile.getUserId());
         assertEquals(GATEWAY_ID,createdUserProfile.getGatewayId());
     }
diff --git a/ide-integration/custos-authentication-service-samples/pom.xml b/ide-integration/custos-authentication-service-samples/pom.xml
new file mode 100644
index 0000000..5a035cd
--- /dev/null
+++ b/ide-integration/custos-authentication-service-samples/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>ide-integration</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-authentication-service-samples</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/ide-integration/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java b/ide-integration/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java
new file mode 100644
index 0000000..ac2c122
--- /dev/null
+++ b/ide-integration/custos-authentication-service-samples/src/main/java/org/apache/custos/authentication/service/sample/CustosAuthenticationServiceSample.java
@@ -0,0 +1,108 @@
+package org.apache.custos.authentication.service.sample;
+
+import org.apache.custos.authentication.cpi.CustosAuthenticationService;
+import org.apache.custos.client.authentication.service.AuthenticationServiceClientFactory;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.commons.utils.Constants;
+import org.apache.custos.security.manager.KeyCloakSecurityManager;
+import org.apache.http.Consts;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.apache.thrift.TException;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class CustosAuthenticationServiceSample {
+
+    private static final Logger log = LoggerFactory.getLogger(CustosAuthenticationServiceSample.class);
+    //present in keycloak json configuration
+    public static String USERNAME = "default-admin";
+    public static String GATEWAY_ID = "default";
+
+    public static void main(String[] args) throws Exception{
+
+        try {
+            //change this based on the port on which the server is started
+            String serverHost = "localhost";
+            int serverPort = 9091;
+            CustosAuthenticationService.Client client = AuthenticationServiceClientFactory.createAuthenticationServiceClient(serverHost, serverPort);
+            testUserAuthentication(client);
+        }catch (TException e) {
+            throw new Exception(e);
+        }catch (Exception e){
+            throw new Exception("Error setting up the authentication server", e);
+        }
+    }
+
+    public static void testUserAuthentication(CustosAuthenticationService.Client client) throws TException, CustosSecurityException {
+        boolean authenticated = false;
+        new KeyCloakSecurityManager().initializeSecurityInfra();
+        AuthzToken authzToken = new AuthzToken();
+        HashMap<String, String> map_ = new HashMap<>();
+        map_.put(Constants.GATEWAY_ID, GATEWAY_ID);
+        map_.put(Constants.USER_NAME, USERNAME);
+        authzToken.setClaimsMap(map_);
+        JSONObject json = getAccessToken();
+        if(json.has("access_token")){
+            String access_token = getAccessToken().get("access_token").toString();
+            authzToken.setAccessToken(access_token);
+            authenticated = client.isUserAuthenticated(authzToken);
+        }
+
+        assert (authenticated): "User authenticating failed";
+        if(authenticated){
+            log.info("User successfully authenticated");
+        }
+
+    }
+
+    private static JSONObject getAccessToken() {
+        String password = "123456";
+        String tokenEndPoint = "https://airavata.host:8443/auth/realms/default/protocol/openid-connect/token";
+        String grant_type = "password";
+        String client_id = "admin-cli";
+
+        CloseableHttpClient httpClient = HttpClients.createSystem();
+        HttpPost httpPost = new HttpPost(tokenEndPoint);
+        ;
+        List<NameValuePair> formParams = new ArrayList<>();
+        formParams.add(new BasicNameValuePair("grant_type", "password"));
+        formParams.add(new BasicNameValuePair("client_id", client_id));
+        formParams.add(new BasicNameValuePair("username", USERNAME));
+        formParams.add(new BasicNameValuePair("password", password));
+        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
+        httpPost.setEntity(entity);
+        try {
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            try {
+                String responseBody = EntityUtils.toString(response.getEntity());
+                JSONObject tokenInfo = new JSONObject(responseBody);
+                return tokenInfo;
+            } finally {
+                response.close();
+            }
+
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } finally {
+            try {
+                httpClient.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+}
diff --git a/ide-integration/custos-profile-service-samples/pom.xml b/ide-integration/custos-profile-service-samples/pom.xml
new file mode 100644
index 0000000..070cda2
--- /dev/null
+++ b/ide-integration/custos-profile-service-samples/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>ide-integration</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-profile-service-samples</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/TenantProfileSample.java b/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/TenantProfileSample.java
new file mode 100644
index 0000000..0e87e9a
--- /dev/null
+++ b/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/TenantProfileSample.java
@@ -0,0 +1,80 @@
+/**
+ *
+ * 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.custos.profile.service.samples;
+
+import org.apache.custos.client.profile.service.CustosProfileServiceClientFactory;
+import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.profile.model.workspace.Gateway;
+import org.apache.custos.profile.model.workspace.GatewayApprovalStatus;
+import org.apache.custos.profile.service.samples.utils.ProfileServiceClientUtil;
+import org.apache.custos.profile.tenant.cpi.TenantProfileService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * Created by goshenoy on 3/30/17.
+ */
+public class TenantProfileSample {
+    private static final Logger logger = LoggerFactory.getLogger(TenantProfileSample.class);
+    private static TenantProfileService.Client tenantProfileClient;
+    private static Gateway testGateway = null;
+    private static AuthzToken authzToken = new AuthzToken("empy_token");
+
+    public static void main(String[] args) throws Exception {
+        try {
+            String profileServiceServerHost = ProfileServiceClientUtil.getProfileServiceServerHost();
+            int profileServiceServerPort = ProfileServiceClientUtil.getProfileServiceServerPort();
+
+            tenantProfileClient = CustosProfileServiceClientFactory.createCustosTenantProfileServiceClient(profileServiceServerHost, profileServiceServerPort);
+
+            // test addGateway
+            testGateway = tenantProfileClient.addGateway(authzToken, getGateway("465"));
+            assert (testGateway != null) : "Gateway creation failed!";
+            System.out.println("Gateway created with gatewayId: " + testGateway);
+
+
+        } catch (Exception ex) {
+            logger.error("TenantProfile client-sample Exception: " + ex, ex);
+        }
+    }
+
+    private static Gateway getGateway(String gatewayId) {
+        // get random value for userId
+        int gatewayIdValue = ThreadLocalRandom.current().nextInt(1000);
+
+        if (gatewayId != null) {
+            gatewayIdValue = Integer.parseInt(gatewayId.replaceAll("test-gateway-", ""));
+        }
+
+        Gateway gateway = new Gateway();
+        gateway.setGatewayId("test-gateway-" + gatewayIdValue);
+        gateway.setGatewayApprovalStatus(GatewayApprovalStatus.APPROVED);
+        gateway.setGatewayName("test-gateway-name");
+        gateway.setDomain("test-gateway-domain");
+        gateway.setEmailAddress("test-gateway-" + gatewayIdValue + "@domain.com");
+        gateway.setGatewayURL("test-gateway-" + gatewayIdValue + ".domain.com");
+        gateway.setGatewayAdminFirstName("test-gateway-admin-fname");
+        gateway.setGatewayAdminLastName("test-gateway-admin-lname");
+        gateway.setGatewayAdminEmail("test-gateway-admin@email.domain.com");
+        return gateway;
+    }
+}
diff --git a/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/UserProfileSample.java b/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/UserProfileSample.java
new file mode 100644
index 0000000..41255fc
--- /dev/null
+++ b/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/UserProfileSample.java
@@ -0,0 +1,211 @@
+/**
+ *
+ * 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.custos.profile.service.samples;
+
+import org.apache.custos.client.profile.service.CustosProfileServiceClientFactory;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.model.security.AuthzToken;
+import org.apache.custos.commons.utils.Constants;
+import org.apache.custos.profile.model.user.*;
+import org.apache.custos.profile.service.samples.utils.ProfileServiceClientUtil;
+import org.apache.custos.profile.user.cpi.UserProfileService;
+import org.apache.custos.security.manager.KeyCloakSecurityManager;
+import org.apache.http.Consts;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * Created by goshenoy on 3/23/17.
+ */
+public class UserProfileSample {
+
+    private static final Logger logger = LoggerFactory.getLogger(UserProfileSample.class);
+    private static UserProfileService.Client userProfileClient;
+    private static UserProfile testUser = null;
+    private static String testGatewayId = "default";
+    private static String username = "default-admin";
+    private static AuthzToken authzToken;
+
+
+    /**
+     * Performs the following operations in sequence:
+     *  1. create new user
+     *  2. find user created
+     *  3. update created user's name
+     *  4. find all users in gateway
+     *  5. find created user by name
+     *  6. delete created user
+     *  7. check if user exists
+     * @param args
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        try {
+            String profileServiceServerHost = ProfileServiceClientUtil.getProfileServiceServerHost();
+            int profileServiceServerPort = ProfileServiceClientUtil.getProfileServiceServerPort();
+            authzToken = initializeAuthzToken();
+            userProfileClient = CustosProfileServiceClientFactory.createCustosUserProfileServiceClient(profileServiceServerHost, profileServiceServerPort);
+
+            // test add-user-profile
+            testUser = userProfileClient.addUserProfile(authzToken, getUserProfile(username));
+            assert (testUser != null) : "User creation failed. Null userId returned!";
+            System.out.println("User created with userId: " + testUser);
+
+            // test find-user-profile
+            UserProfile userProfile = userProfileClient.getUserProfileById(authzToken, testUser.getUserId(), testGatewayId);
+            assert (userProfile != null) : "Could not find user with userId: " + testUser + ", and gatewayID: " + testGatewayId;
+            System.out.println("UserProfile: " + userProfile);
+
+            // test update-user-profile : update name
+            userProfile = getUserProfile(testUser.getUserId());
+            String newFName = userProfile.getFirstName().replaceAll("fname", "fname-updated");
+            userProfile.setFirstName(newFName);
+            UserProfile updatedUserProfile = userProfileClient.updateUserProfile(authzToken, userProfile);
+            boolean updateSuccess = updatedUserProfile != null;
+            assert (updateSuccess) : "User update with new firstName: [" + newFName + "], Failed!";
+            System.out.println("User update with new firstName: [" + newFName + "], Successful!");
+
+            // test get-all-userprofiles
+            List<UserProfile> userProfileList = userProfileClient.getAllUserProfilesInGateway(authzToken, testGatewayId, 0, 5);
+            assert (userProfileList != null && !userProfileList.isEmpty()) : "Failed to retrieve users for gateway!";
+            System.out.println("Printing userList retrieved..");
+            for (UserProfile userProfile1 : userProfileList) {
+                System.out.println("\t [UserProfile] userId: " + userProfile1.getUserId());
+            }
+
+            // test delete-user-profile
+            boolean deleteSuccess = userProfileClient.deleteUserProfile(authzToken, testUser.getUserId(), testGatewayId) != null;
+            assert (deleteSuccess) : "Delete user failed for userId: " + testUser.getUserId();
+            System.out.println("Successfully deleted user with userId: " + testUser.getUserId());
+
+            // test-check-user-exist
+            boolean userExists = userProfileClient.doesUserExist(authzToken, testUser.getUserId(), testGatewayId);
+            assert (!userExists) : "User should not exist, but it does.";
+            System.out.println("User was deleted, hence does not exist!");
+            System.out.println("*** DONE ***");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            logger.error("UserProfile client-sample Exception: " + ex, ex);
+        }
+    }
+
+    private static UserProfile getUserProfile(String userId) {
+        // get random value for userId
+        int userIdValue = ThreadLocalRandom.current().nextInt(1000);
+        
+        // construct userProfile object
+        UserProfile userProfile = new UserProfile();
+        userProfile.setUserModelVersion("model-" + userIdValue);
+        userProfile.setCustosInternalUserId("test-user-internal-" + userIdValue);
+        userProfile.setUserId(userId);
+        userProfile.setFirstName("test-user-fname");
+        userProfile.setLastName("test-user-lname");
+        userProfile.setGatewayId(testGatewayId);
+        userProfile.addToEmails("test-user-" + userIdValue + "@domain1.com");
+        userProfile.addToEmails("test-user-" + userIdValue + "@domain2.com");
+        userProfile.setCreationTime(System.currentTimeMillis());
+        userProfile.setLastAccessTime(System.currentTimeMillis());
+        userProfile.setValidUntil(System.currentTimeMillis());
+        userProfile.setState(Status.ACTIVE);
+        userProfile.setNsfDemographics(getNSFDemographics(userIdValue));
+        return userProfile;
+    }
+
+    private static NSFDemographics getNSFDemographics(int userIdValue) {
+        // construct nsfdemographics object
+        NSFDemographics nsfDemographics = new NSFDemographics();
+        nsfDemographics.setCustosInternalUserId("test-user-internal-" + userIdValue);
+        nsfDemographics.setGender("male");
+        nsfDemographics.setUsCitizenship(USCitizenship.US_CITIZEN);
+        nsfDemographics.addToEthnicities(ethnicity.NOT_HISPANIC_LATINO);
+        nsfDemographics.addToRaces(race.AMERICAN_INDIAN_OR_ALASKAN_NATIVE);
+        return nsfDemographics;
+    }
+
+    private static AuthzToken initializeAuthzToken() throws Exception{
+         authzToken = new AuthzToken();
+        {
+            HashMap<String, String> map_ = new HashMap<>();
+            map_.put(Constants.GATEWAY_ID, testGatewayId);
+            map_.put(Constants.USER_NAME, username);
+            JSONObject json = getAccessToken();
+            if(json.has("access_token")) {
+                authzToken.setAccessToken(json.get("access_token").toString());
+            }
+            else{
+                throw new Exception("Cannot find access token for the user. Check if the user exists in the IDP");
+            }
+            authzToken.setClaimsMap(map_);
+            return authzToken;
+        }
+    }
+    private static JSONObject getAccessToken() throws CustosSecurityException {
+        new KeyCloakSecurityManager().initializeSecurityInfra();
+        String password = "123456";
+        String tokenEndPoint = "https://airavata.host:8443/auth/realms/default/protocol/openid-connect/token";
+        String grant_type = "password";
+        String client_id = "admin-cli";
+
+        CloseableHttpClient httpClient = HttpClients.createSystem();
+        HttpPost httpPost = new HttpPost(tokenEndPoint);
+        ;
+        List<NameValuePair> formParams = new ArrayList<>();
+        formParams.add(new BasicNameValuePair("grant_type", "password"));
+        formParams.add(new BasicNameValuePair("client_id", client_id));
+        formParams.add(new BasicNameValuePair("username", username));
+        formParams.add(new BasicNameValuePair("password", password));
+        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
+        httpPost.setEntity(entity);
+        try {
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            try {
+                String responseBody = EntityUtils.toString(response.getEntity());
+                JSONObject tokenInfo = new JSONObject(responseBody);
+                return tokenInfo;
+            } finally {
+                response.close();
+            }
+
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } finally {
+            try {
+                httpClient.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+}
diff --git a/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/utils/ProfileServiceClientUtil.java b/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/utils/ProfileServiceClientUtil.java
new file mode 100644
index 0000000..2ec4c92
--- /dev/null
+++ b/ide-integration/custos-profile-service-samples/src/main/java/org/apache/custos/profile/service/samples/utils/ProfileServiceClientUtil.java
@@ -0,0 +1,63 @@
+/**
+ *
+ * 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.custos.profile.service.samples.utils;
+
+import java.net.URL;
+import java.util.Properties;
+
+public class ProfileServiceClientUtil {
+
+    private static final String PROFILE_SERVICE_SERVER_HOST = "profile.service.server.host";
+    private static final String PROFILE_SERVICE_SERVER_PORT = "profile.service.server.port";
+    private static final String PROFILE_CLIENT_SAMPLE_PROPERTIES = "profile-client-sample.properties";
+
+    private static Properties properties;
+    private static Exception propertyLoadException;
+
+    static {
+        loadProperties();
+    }
+
+    private static void loadProperties() {
+        URL url = ProfileServiceClientUtil.class.getClassLoader().getResource(PROFILE_CLIENT_SAMPLE_PROPERTIES);
+        try {
+            properties = new Properties();
+            properties.load(url.openStream());
+        } catch (Exception ex) {
+            propertyLoadException = ex;
+        }
+    }
+
+    public static String  getProfileServiceServerHost() throws Exception {
+        validateSuccessfullPropertyLoad();
+        return properties.getProperty(PROFILE_SERVICE_SERVER_HOST);
+    }
+
+    public static int getProfileServiceServerPort() throws Exception {
+        validateSuccessfullPropertyLoad();
+        return Integer.parseInt(properties.getProperty(PROFILE_SERVICE_SERVER_PORT));
+    }
+
+    private static void validateSuccessfullPropertyLoad() throws Exception {
+        if (propertyLoadException != null) {
+            throw new Exception(propertyLoadException.getMessage(), propertyLoadException);
+        }
+    }
+}
diff --git a/ide-integration/custos-profile-service-samples/src/main/resources/profile-client-sample.properties b/ide-integration/custos-profile-service-samples/src/main/resources/profile-client-sample.properties
new file mode 100644
index 0000000..404d404
--- /dev/null
+++ b/ide-integration/custos-profile-service-samples/src/main/resources/profile-client-sample.properties
@@ -0,0 +1,29 @@
+#
+#
+# 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.
+#
+
+##################################################################################
+#
+#  This properties file provides configuration for profile-service sample client
+#
+##################################################################################
+
+profile.service.server.host=localhost
+profile.service.server.port=8081
+
diff --git a/ide-integration/custos-services/pom.xml b/ide-integration/custos-services/pom.xml
new file mode 100644
index 0000000..db15484
--- /dev/null
+++ b/ide-integration/custos-services/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>ide-integration</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-services-start</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/ide-integration/src/main/java/CustosAPIServerStarted.java b/ide-integration/custos-services/src/main/java/org/apache/custos/server/start/CustosAPIServerStarted.java
similarity index 92%
rename from ide-integration/src/main/java/CustosAPIServerStarted.java
rename to ide-integration/custos-services/src/main/java/org/apache/custos/server/start/CustosAPIServerStarted.java
index 909374e..81dd02b 100644
--- a/ide-integration/src/main/java/CustosAPIServerStarted.java
+++ b/ide-integration/custos-services/src/main/java/org/apache/custos/server/start/CustosAPIServerStarted.java
@@ -1,3 +1,5 @@
+package org.apache.custos.server.start;
+
 import org.apache.custos.authentication.server.CustosAuthenticationServer;
 import org.apache.custos.profile.server.ProfileServiceServer;
 
@@ -8,7 +10,5 @@ public class CustosAPIServerStarted {
 
         custosAuthenticationServer.start();
         custosProfileServer.start();
-
-
     }
 }
diff --git a/ide-integration/src/main/resources/custos-server.properties b/ide-integration/custos-services/src/main/resources/custos-server.properties
similarity index 98%
rename from ide-integration/src/main/resources/custos-server.properties
rename to ide-integration/custos-services/src/main/resources/custos-server.properties
index d9d59c3..2e07020 100644
--- a/ide-integration/src/main/resources/custos-server.properties
+++ b/ide-integration/custos-services/src/main/resources/custos-server.properties
@@ -54,7 +54,7 @@ in.memory.cache.size=1000
 # Profile Service Configuration
 ###########################################################################
 profile.service.server.host=0.0.0.0
-profile.service.server.port=9092
+profile.service.server.port=8081
 profile_service=org.apache.custos.profile.server.ProfileServiceServer
 
 # MariaDB properties
diff --git a/ide-integration/src/main/resources/database_scripts/init/01-databases.sql b/ide-integration/custos-services/src/main/resources/database_scripts/init/01-databases.sql
similarity index 88%
rename from ide-integration/src/main/resources/database_scripts/init/01-databases.sql
rename to ide-integration/custos-services/src/main/resources/database_scripts/init/01-databases.sql
index dabf29c..710065d 100644
--- a/ide-integration/src/main/resources/database_scripts/init/01-databases.sql
+++ b/ide-integration/custos-services/src/main/resources/database_scripts/init/01-databases.sql
@@ -80,27 +80,27 @@ DROP TABLE IF EXISTS `GATEWAY`;
 /*!40101 SET @saved_cs_client     = @@character_set_client */;
 /*!40101 SET character_set_client = utf8 */;
 CREATE TABLE `GATEWAY` (
-  `CUSTOS_INTERNAL_GATEWAY_ID` varchar(255) NOT NULL,
-  `DECLINED_REASON` varchar(255) DEFAULT NULL,
-  `GATEWAY_DOMAIN` varchar(255) DEFAULT NULL,
-  `EMAIL_ADDRESS` varchar(255) DEFAULT NULL,
-  `GATEWAY_ACRONYM` varchar(255) DEFAULT NULL,
-  `GATEWAY_ADMIN_EMAIL` varchar(255) DEFAULT NULL,
-  `GATEWAY_ADMIN_FIRST_NAME` varchar(255) DEFAULT NULL,
-  `GATEWAY_ADMIN_LAST_NAME` varchar(255) DEFAULT NULL,
-  `GATEWAY_APPROVAL_STATUS` varchar(255) DEFAULT NULL,
-  `GATEWAY_ID` varchar(255) DEFAULT NULL,
-  `GATEWAY_NAME` varchar(255) DEFAULT NULL,
-  `GATEWAY_PUBLIC_ABSTRACT` varchar(255) DEFAULT NULL,
-  `GATEWAY_URL` varchar(255) DEFAULT NULL,
-  `IDENTITY_SERVER_PASSWORD_TOKEN` varchar(255) DEFAULT NULL,
-  `IDENTITY_SERVER_USERNAME` varchar(255) DEFAULT NULL,
-  `OAUTH_CLIENT_ID` varchar(255) DEFAULT NULL,
-  `OAUTH_CLIENT_SECRET` varchar(255) DEFAULT NULL,
-  `REQUEST_CREATION_TIME` bigint(20) DEFAULT NULL,
-  `REQUESTER_USERNAME` varchar(255) DEFAULT NULL,
-  `GATEWAY_REVIEW_PROPOSAL_DESCRIPTION` varchar(255) DEFAULT NULL,
-  PRIMARY KEY (`CUSTOS_INTERNAL_GATEWAY_ID`)
+     `CUSTOS_INTERNAL_GATEWAY_ID` varchar(255) NOT NULL,
+     `DECLINED_REASON` varchar(255) DEFAULT NULL,
+     `GATEWAY_DOMAIN` varchar(255) DEFAULT NULL,
+     `EMAIL_ADDRESS` varchar(255) DEFAULT NULL,
+     `GATEWAY_ACRONYM` varchar(255) DEFAULT NULL,
+     `GATEWAY_ADMIN_EMAIL` varchar(255) DEFAULT NULL,
+     `GATEWAY_ADMIN_FIRST_NAME` varchar(255) DEFAULT NULL,
+     `GATEWAY_ADMIN_LAST_NAME` varchar(255) DEFAULT NULL,
+     `GATEWAY_APPROVAL_STATUS` varchar(255) DEFAULT NULL,
+     `GATEWAY_ID` varchar(255) DEFAULT NULL,
+     `GATEWAY_NAME` varchar(255) DEFAULT NULL,
+     `GATEWAY_PUBLIC_ABSTRACT` varchar(255) DEFAULT NULL,
+     `GATEWAY_URL` varchar(255) DEFAULT NULL,
+     `IDENTITY_SERVER_PASSWORD_TOKEN` varchar(255) DEFAULT NULL,
+     `IDENTITY_SERVER_USERNAME` varchar(255) DEFAULT NULL,
+     `OAUTH_CLIENT_ID` varchar(255) DEFAULT NULL,
+     `OAUTH_CLIENT_SECRET` varchar(255) DEFAULT NULL,
+     `REQUEST_CREATION_TIME` bigint(20) DEFAULT NULL,
+     `REQUESTER_USERNAME` varchar(255) DEFAULT NULL,
+     `GATEWAY_REVIEW_PROPOSAL_DESCRIPTION` varchar(255) DEFAULT NULL,
+     PRIMARY KEY (`CUSTOS_INTERNAL_GATEWAY_ID`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
@@ -110,6 +110,7 @@ CREATE TABLE `GATEWAY` (
 
 LOCK TABLES `GATEWAY` WRITE;
 /*!40000 ALTER TABLE `GATEWAY` DISABLE KEYS */;
+INSERT INTO `GATEWAY` VALUES ('default',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'APPROVED','default','default',NULL,NULL,NULL,NULL,'pga','9790c8c4-7d9b-4ccc-a820-ca5aac38d2ad','2019-02-25 18:40:06',NULL, NULL);
 /*!40000 ALTER TABLE `GATEWAY` ENABLE KEYS */;
 UNLOCK TABLES;
 
diff --git a/ide-integration/src/main/resources/database_scripts/user-profile-catalog-derby.sql b/ide-integration/custos-services/src/main/resources/database_scripts/user-profile-catalog-derby.sql
similarity index 81%
rename from ide-integration/src/main/resources/database_scripts/user-profile-catalog-derby.sql
rename to ide-integration/custos-services/src/main/resources/database_scripts/user-profile-catalog-derby.sql
index 7600772..08566a2 100644
--- a/ide-integration/src/main/resources/database_scripts/user-profile-catalog-derby.sql
+++ b/ide-integration/custos-services/src/main/resources/database_scripts/user-profile-catalog-derby.sql
@@ -123,36 +123,6 @@ CREATE TABLE NSF_DEMOGRAPHIC_DISABILITY (
     FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 );
 
-CREATE TABLE CUSTOMIZED_DASHBOARD (
-    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
-    ENABLED_EXPERIMENT_ID VARCHAR (255),
-    ENABLED_NAME VARCHAR (255),
-    ENABLED_DESCRIPTION VARCHAR (255),
-    ENABLED_PROJECT VARCHAR (255),
-    ENABLED_OWNER VARCHAR (255),
-    ENABLED_APPLICATION VARCHAR (255),
-    ENABLED_COMPUTE_RESOURCE VARCHAR (255),
-    ENABLED_JOB_NAME VARCHAR (255),
-    ENABLED_JOB_ID VARCHAR (255),
-    ENABLED_JOB_STATUS VARCHAR (255),
-    ENABLED_JOB_CREATION_TIME VARCHAR (255),
-    ENABLED_NOTIFICATIONS_TO VARCHAR (255),
-    ENABLED_WORKING_DIR VARCHAR (255),
-    ENABLED_JOB_DESCRIPTION VARCHAR (255),
-    ENABLED_CREATION_TIME VARCHAR (255),
-    ENABLED_LAST_MODIFIED_TIME VARCHAR (255),
-    ENABLED_WALL_TIME VARCHAR (255),
-    ENABLED_CPU_COUNT VARCHAR (255),
-    ENABLED_NODE_COUNT VARCHAR (255),
-    ENABLED_QUEUE VARCHAR (255),
-    ENABLED_INPUTS VARCHAR (255),
-    ENABLED_OUTPUTS VARCHAR (255),
-    ENABLED_STORAGE_DIR VARCHAR (255),
-    ENABLED_ERRORS VARCHAR (255),
-    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID),
-    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
-);
-
 CREATE TABLE CONFIGURATION
 (
         CONFIG_KEY VARCHAR(255) NOT NULL,
diff --git a/ide-integration/src/main/resources/database_scripts/user-profile-catalog-mysql.sql b/ide-integration/custos-services/src/main/resources/database_scripts/user-profile-catalog-mysql.sql
similarity index 82%
rename from ide-integration/src/main/resources/database_scripts/user-profile-catalog-mysql.sql
rename to ide-integration/custos-services/src/main/resources/database_scripts/user-profile-catalog-mysql.sql
index 6da1c93..4be0b66 100644
--- a/ide-integration/src/main/resources/database_scripts/user-profile-catalog-mysql.sql
+++ b/ide-integration/custos-services/src/main/resources/database_scripts/user-profile-catalog-mysql.sql
@@ -123,36 +123,6 @@ CREATE TABLE IF NOT EXISTS NSF_DEMOGRAPHIC_DISABILITY (
     FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES NSF_DEMOGRAPHIC(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
-CREATE TABLE IF NOT EXISTS CUSTOMIZED_DASHBOARD (
-    CUSTOS_INTERNAL_USER_ID VARCHAR (255) NOT NULL,
-    ENABLED_EXPERIMENT_ID VARCHAR (255),
-    ENABLED_NAME VARCHAR (255),
-    ENABLED_DESCRIPTION VARCHAR (255),
-    ENABLED_PROJECT VARCHAR (255),
-    ENABLED_OWNER VARCHAR (255),
-    ENABLED_APPLICATION VARCHAR (255),
-    ENABLED_COMPUTE_RESOURCE VARCHAR (255),
-    ENABLED_JOB_NAME VARCHAR (255),
-    ENABLED_JOB_ID VARCHAR (255),
-    ENABLED_JOB_STATUS VARCHAR (255),
-    ENABLED_JOB_CREATION_TIME VARCHAR (255),
-    ENABLED_NOTIFICATIONS_TO VARCHAR (255),
-    ENABLED_WORKING_DIR VARCHAR (255),
-    ENABLED_JOB_DESCRIPTION VARCHAR (255),
-    ENABLED_CREATION_TIME VARCHAR (255),
-    ENABLED_LAST_MODIFIED_TIME VARCHAR (255),
-    ENABLED_WALL_TIME VARCHAR (255),
-    ENABLED_CPU_COUNT VARCHAR (255),
-    ENABLED_NODE_COUNT VARCHAR (255),
-    ENABLED_QUEUE VARCHAR (255),
-    ENABLED_INPUTS VARCHAR (255),
-    ENABLED_OUTPUTS VARCHAR (255),
-    ENABLED_STORAGE_DIR VARCHAR (255),
-    ENABLED_ERRORS VARCHAR (255),
-    PRIMARY KEY (CUSTOS_INTERNAL_USER_ID),
-    FOREIGN KEY (CUSTOS_INTERNAL_USER_ID) REFERENCES USER_PROFILE(CUSTOS_INTERNAL_USER_ID) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
 CREATE TABLE CONFIGURATION
 (
         CONFIG_KEY VARCHAR(255) NOT NULL,
diff --git a/ide-integration/src/main/resources/docker-compose.yml b/ide-integration/custos-services/src/main/resources/docker-compose.yml
similarity index 100%
rename from ide-integration/src/main/resources/docker-compose.yml
rename to ide-integration/custos-services/src/main/resources/docker-compose.yml
diff --git a/ide-integration/src/main/resources/keycloak/Default-export.json b/ide-integration/custos-services/src/main/resources/keycloak/Default-export.json
similarity index 100%
rename from ide-integration/src/main/resources/keycloak/Default-export.json
rename to ide-integration/custos-services/src/main/resources/keycloak/Default-export.json
diff --git a/ide-integration/src/main/resources/keycloak/Default-export.json.bk b/ide-integration/custos-services/src/main/resources/keycloak/Default-export.json.bk
similarity index 100%
rename from ide-integration/src/main/resources/keycloak/Default-export.json.bk
rename to ide-integration/custos-services/src/main/resources/keycloak/Default-export.json.bk
diff --git a/ide-integration/src/main/resources/keycloak/standalone.xml b/ide-integration/custos-services/src/main/resources/keycloak/standalone.xml
similarity index 100%
rename from ide-integration/src/main/resources/keycloak/standalone.xml
rename to ide-integration/custos-services/src/main/resources/keycloak/standalone.xml
diff --git a/ide-integration/src/main/resources/keystores/airavata.jks b/ide-integration/custos-services/src/main/resources/keystores/airavata.jks
similarity index 100%
rename from ide-integration/src/main/resources/keystores/airavata.jks
rename to ide-integration/custos-services/src/main/resources/keystores/airavata.jks
diff --git a/ide-integration/src/main/resources/keystores/airavata_sym.jks b/ide-integration/custos-services/src/main/resources/keystores/airavata_sym.jks
similarity index 100%
rename from ide-integration/src/main/resources/keystores/airavata_sym.jks
rename to ide-integration/custos-services/src/main/resources/keystores/airavata_sym.jks
diff --git a/ide-integration/src/main/resources/keystores/client_truststore.jks b/ide-integration/custos-services/src/main/resources/keystores/client_truststore.jks
similarity index 100%
rename from ide-integration/src/main/resources/keystores/client_truststore.jks
rename to ide-integration/custos-services/src/main/resources/keystores/client_truststore.jks
diff --git a/ide-integration/pom.xml b/ide-integration/pom.xml
index ee1a01d..a91f3dc 100644
--- a/ide-integration/pom.xml
+++ b/ide-integration/pom.xml
@@ -10,6 +10,12 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>ide-integration</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>custos-profile-service-samples</module>
+        <module>custos-authentication-service-samples</module>
+        <module>custos-services</module>
+    </modules>
     <dependencies>
         <dependency>
             <groupId>org.slf4j</groupId>
@@ -31,6 +37,18 @@
             <artifactId>custos-authentication</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-client</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-client</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 


[airavata-custos] 02/48: added profile service, security service, custos common utilities and thrift files

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6aea83bbfdd4a5e09386f47819c5f68b8b9faae2
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Jun 24 10:30:34 2019 -0400

    added profile service, security service, custos common utilities and thrift files
---
 custos-commons/pom.xml                             |    29 +
 .../exceptions/ApplicationSettingsException.java   |    14 +
 .../custos/commons/exceptions/CustosException.java |    35 +
 .../exceptions/CustosSecurityException.java        |    39 +
 .../model/error/AuthenticationException.java       |   385 +
 .../model/error/AuthorizationException.java        |   385 +
 .../custos/commons/utils/ApplicationSettings.java  |   185 +
 .../org/apache/custos/commons/utils/Constants.java |    41 +
 .../apache/custos/commons/utils/CustosUtils.java   |    45 +
 .../apache/custos/commons/utils/DBInitConfig.java  |    33 +
 .../apache/custos/commons/utils/JDBCConfig.java    |    29 +
 .../org/apache/custos/commons/utils/JPAUtils.java  |    67 +
 .../commons/utils/KeyStorePasswordCallback.java    |    69 +
 .../apache/custos/commons/utils/SecurityUtil.java  |   192 +
 .../custos/commons/utils/ServerSettings.java       |    56 +
 .../apache/custos/commons/utils/StringUtil.java    |    43 +
 custos-services/custos-security-service/pom.xml    |    71 +
 .../custos/security/authzcache/AuthzCache.java     |    61 +
 .../security/authzcache/AuthzCacheEntry.java       |    63 +
 .../security/authzcache/AuthzCacheIndex.java       |    90 +
 .../security/authzcache/AuthzCacheManager.java     |    80 +
 .../authzcache/AuthzCacheManagerFactory.java       |    60 +
 .../security/authzcache/AuthzCachedStatus.java     |    34 +
 .../authzcache/DefaultAuthzCacheManager.java       |   106 +
 .../security/manager/CustosSecurityManager.java    |    60 +
 .../custos/security/manager/IdentityContext.java   |    44 +
 .../security/manager/KeyCloakSecurityManager.java  |   537 +
 .../security/manager/SecurityManagerFactory.java   |    60 +
 .../apache/custos/security/manager/UserInfo.java   |    84 +
 .../apache/custos/security/model/AuthzToken.java   |   541 +
 .../custos/security/oauth/DefaultOAuthClient.java  |    91 +
 .../security/service/SecurityServiceHandler.java   |    30 +
 .../custos/security/utils/TrustStoreManager.java   |   100 +
 .../custos/security/xacml/DefaultPAPClient.java    |   124 +
 .../custos/security/xacml/DefaultXACMLPEP.java     |   133 +
 custos-services/pom.xml                            |    34 +
 .../iam-admin-services-core/pom.xml                |    89 +
 .../core/impl/TenantManagementKeycloakImpl.java    |   821 +
 .../core/interfaces/TenantManagementInterface.java |   206 +
 .../admin/services/core/tests/SetupNewGateway.java |   141 +
 custos-services/profile-service/pom.xml            |    25 +
 .../java-client-samples/pom.xml                    |    35 +
 .../profile/client/samples/GroupManagerSample.java |    41 +
 .../client/samples/TenantProfileSample.java        |    61 +
 .../profile/client/samples/UserProfileSample.java  |   121 +
 .../client/util/ProfileServiceClientUtil.java      |    47 +
 .../resources/profile-client-sample.properties     |    29 +
 .../profile-service-client-sdks/pom.xml            |    31 +
 .../profile-service-commons/pom.xml                |   124 +
 .../commons/repositories/AbstractRepository.java   |   124 +
 .../commons/tenant/entities/GatewayEntity.java     |   285 +
 .../user/entities/CustomizedDashboardEntity.java   |   325 +
 .../user/entities/NSFDemographicsEntity.java       |   108 +
 .../commons/user/entities/UserProfileEntity.java   |   345 +
 .../service/profile/commons/utils/Committer.java   |    27 +
 .../profile/commons/utils/JPAConstants.java        |    34 +
 .../service/profile/commons/utils/JPAUtils.java    |    53 +
 .../commons/utils/ObjectMapperSingleton.java       |    39 +
 .../commons/utils/ProfileServiceJDBCConfig.java    |    51 +
 .../profile/commons/utils/QueryConstants.java      |    33 +
 .../service/profile/commons/utils/Utils.java       |   122 +
 .../src/main/resources/META-INF/persistence.xml    |    36 +
 .../profile-service/profile-service-models/pom.xml |    14 +
 .../profile/models/tenant/PasswordCredential.java  |   996 +
 .../custos/profile/models/tenant/Tenant.java       |  1543 ++
 .../models/tenant/TenantApprovalStatus.java        |    78 +
 .../custos/profile/models/tenant/TenantConfig.java |   699 +
 .../profile/models/tenant/TenantPreferences.java   |   594 +
 .../profile/models/user/CustomDashboard.java       |  2912 +++
 .../profile/models/user/NSFDemographics.java       |  1085 ++
 .../apache/custos/profile/models/user/Status.java  |    96 +
 .../custos/profile/models/user/USCitizenship.java  |    67 +
 .../custos/profile/models/user/UserProfile.java    |  3221 ++++
 .../custos/profile/models/user/disability.java     |    66 +
 .../custos/profile/models/user/ethnicity.java      |    65 +
 .../apache/custos/profile/models/user/race.java    |    84 +
 .../models/user/user_profile_modelConstants.java   |    31 +
 .../custos/profile/models/workspace/Gateway.java   |  2383 +++
 .../models/workspace/GatewayApprovalStatus.java    |    78 +
 .../profile-service/profile-service-server/pom.xml |    53 +
 .../handlers/GroupManagerServiceHandler.java       |   385 +
 .../profile/handlers/IamAdminServicesHandler.java  |   307 +
 .../handlers/TenantProfileServiceHandler.java      |   244 +
 .../handlers/UserProfileServiceHandler.java        |   239 +
 .../profile/server/ProfileServiceServer.java       |   201 +
 .../profile-service/profile-service-stubs/pom.xml  |    35 +
 .../client/ProfileServiceClientFactory.java        |    93 +
 .../groupmanager/cpi/GroupManagerService.java      | 17625 +++++++++++++++++
 .../exception/GroupManagerServiceException.java    |   381 +
 .../cpi/group_manager_cpiConstants.java            |    32 +
 .../iam/admin/services/cpi/IamAdminServices.java   | 18889 +++++++++++++++++++
 .../cpi/exception/IamAdminServicesException.java   |   381 +
 .../cpi/iam_admin_services_cpiConstants.java       |    32 +
 .../profile/tenant/cpi/TenantProfileService.java   |  9507 ++++++++++
 .../exception/TenantProfileServiceException.java   |   381 +
 .../tenant/cpi/profile_tenant_cpiConstants.java    |    32 +
 .../profile/user/cpi/UserProfileService.java       |  9858 ++++++++++
 .../cpi/exception/UserProfileServiceException.java |   381 +
 .../user/cpi/profile_user_cpiConstants.java        |    32 +
 .../profile-service/profile-services.iml           |    20 +
 .../profile-service/profile-tenant-core/pom.xml    |    43 +
 .../core/repositories/TenantProfileRepository.java |   105 +
 .../profile-service/profile-user-core/pom.xml      |    90 +
 .../exceptions/UserProfileRegistryException.java   |    28 +
 .../core/repositories/UserProfileRepository.java   |   129 +
 .../core/utils/UserProfileCatalogDBInitConfig.java |    42 +
 .../core/utils/UserProfileCatalogJDBCConfig.java   |    52 +
 .../user-profile-catalog-derby.sql                 |   163 +
 .../user-profile-catalog-mysql.sql                 |   163 +
 .../core/repositories/WorkspaceRepositoryTest.java |   176 +
 pom.xml                                            |    47 +
 .../custos-apis/airavata_errors.thrift             |    47 +
 .../custos-apis/security_model.thrift              |    15 +
 .../group_manager_model.thrift                     |    55 +
 .../tenant_profile_model.thrift                    |    75 +
 .../user_profile_model.thrift                      |   230 +
 .../workspace_model.thrift                         |    60 +
 thrift-interfaces/generate-thrift-stubs.sh         |   347 +
 .../group-manager/group-manager-cpi.thrift         |    98 +
 .../group-manager/group_manager_cpi_errors.thrift  |    33 +
 .../iam-admin-services-cpi.thrift                  |   127 +
 .../iam_admin_services_cpi_errors.thrift           |    33 +
 .../profile-service/profile-service-cpi.thrift     |    35 +
 .../profile-tenant/profile-tenant-cpi.thrift       |    80 +
 .../profile_tenant_cpi_errors.thrift               |    33 +
 .../profile-user/profile-user-cpi.thrift           |    86 +
 .../profile-user/profile_user_cpi_errors.thrift    |    33 +
 127 files changed, 82948 insertions(+)

diff --git a/custos-commons/pom.xml b/custos-commons/pom.xml
new file mode 100644
index 0000000..a1a9e93
--- /dev/null
+++ b/custos-commons/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>custos</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    
+    <groupId>org.apache.custos</groupId>
+    <artifactId>custos-commons</artifactId>
+    <version>${parent.version}</version>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>${thrift.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa</artifactId>
+            <version>${openjpa.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ApplicationSettingsException.java b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ApplicationSettingsException.java
new file mode 100644
index 0000000..25f6260
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ApplicationSettingsException.java
@@ -0,0 +1,14 @@
+package org.apache.custos.commons.exceptions;
+
+public class ApplicationSettingsException extends CustosException {
+
+	private static final long serialVersionUID = -4901850535475160411L;
+
+	public ApplicationSettingsException(String message) {
+		super(message);
+	}
+	
+	public ApplicationSettingsException(String message, Throwable e) {
+		super(message, e);
+	}
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/exceptions/CustosException.java b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/CustosException.java
new file mode 100644
index 0000000..1675205
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/CustosException.java
@@ -0,0 +1,35 @@
+/**
+ *
+ * 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.custos.commons.exceptions;
+
+public class CustosException extends Exception {
+
+	private static final long serialVersionUID = -5665822765183116821L;
+	public CustosException() {
+	}
+	
+	public CustosException(String message, Throwable e) {
+		super(message,e);
+	}
+	
+	public CustosException(String message) {
+		super(message);
+	}
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/exceptions/CustosSecurityException.java b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/CustosSecurityException.java
new file mode 100644
index 0000000..67cef95
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/CustosSecurityException.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * 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.custos.commons.exceptions;
+
+public class CustosSecurityException extends Exception {
+    public CustosSecurityException(String message) {
+        super(message);
+    }
+
+    public CustosSecurityException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public CustosSecurityException() {
+        super();
+    }
+
+    public CustosSecurityException(Throwable cause) {
+        super(cause);
+    }
+
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthenticationException.java b/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthenticationException.java
new file mode 100644
index 0000000..07ca704
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthenticationException.java
@@ -0,0 +1,385 @@
+/**
+ * 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.10.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.commons.model.error;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+/**
+ * This exception is thrown for invalid sshKeyAuthentication requests.
+ * 
+ *  message: contains the cause of the authorization failure.
+ */
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
+public class AuthenticationException extends org.apache.thrift.TException implements org.apache.thrift.TBase<AuthenticationException, AuthenticationException._Fields>, java.io.Serializable, Cloneable, Comparable<AuthenticationException> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthenticationException");
+
+  private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new AuthenticationExceptionStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new AuthenticationExceptionTupleSchemeFactory();
+
+  private String message; // 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 {
+    MESSAGE((short)1, "message");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.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: // MESSAGE
+          return MESSAGE;
+        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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthenticationException.class, metaDataMap);
+  }
+
+  public AuthenticationException() {
+  }
+
+  public AuthenticationException(
+    String message)
+  {
+    this();
+    this.message = message;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public AuthenticationException(AuthenticationException other) {
+    if (other.isSetMessage()) {
+      this.message = other.message;
+    }
+  }
+
+  public AuthenticationException deepCopy() {
+    return new AuthenticationException(this);
+  }
+
+  @Override
+  public void clear() {
+    this.message = null;
+  }
+
+  public String getMessage() {
+    return this.message;
+  }
+
+  public void setMessage(String message) {
+    this.message = message;
+  }
+
+  public void unsetMessage() {
+    this.message = null;
+  }
+
+  /** Returns true if field message is set (has been assigned a value) and false otherwise */
+  public boolean isSetMessage() {
+    return this.message != null;
+  }
+
+  public void setMessageIsSet(boolean value) {
+    if (!value) {
+      this.message = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case MESSAGE:
+      if (value == null) {
+        unsetMessage();
+      } else {
+        setMessage((String)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case MESSAGE:
+      return getMessage();
+
+    }
+    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 MESSAGE:
+      return isSetMessage();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof AuthenticationException)
+      return this.equals((AuthenticationException)that);
+    return false;
+  }
+
+  public boolean equals(AuthenticationException that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    boolean this_present_message = true && this.isSetMessage();
+    boolean that_present_message = true && that.isSetMessage();
+    if (this_present_message || that_present_message) {
+      if (!(this_present_message && that_present_message))
+        return false;
+      if (!this.message.equals(that.message))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
+    if (isSetMessage())
+      hashCode = hashCode * 8191 + message.hashCode();
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(AuthenticationException other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetMessage()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
+      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 {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("AuthenticationException(");
+    boolean first = true;
+
+    sb.append("message:");
+    if (this.message == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.message);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetMessage()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' is unset! Struct:" + toString());
+    }
+
+    // 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 AuthenticationExceptionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public AuthenticationExceptionStandardScheme getScheme() {
+      return new AuthenticationExceptionStandardScheme();
+    }
+  }
+
+  private static class AuthenticationExceptionStandardScheme extends org.apache.thrift.scheme.StandardScheme<AuthenticationException> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, AuthenticationException 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: // MESSAGE
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.message = iprot.readString();
+              struct.setMessageIsSet(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();
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, AuthenticationException struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.message != null) {
+        oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
+        oprot.writeString(struct.message);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class AuthenticationExceptionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public AuthenticationExceptionTupleScheme getScheme() {
+      return new AuthenticationExceptionTupleScheme();
+    }
+  }
+
+  private static class AuthenticationExceptionTupleScheme extends org.apache.thrift.scheme.TupleScheme<AuthenticationException> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, AuthenticationException struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      oprot.writeString(struct.message);
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, AuthenticationException struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      struct.message = iprot.readString();
+      struct.setMessageIsSet(true);
+    }
+  }
+
+  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+  }
+}
+
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthorizationException.java b/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthorizationException.java
new file mode 100644
index 0000000..dc84307
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/model/error/AuthorizationException.java
@@ -0,0 +1,385 @@
+/**
+ * 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.10.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.commons.model.error;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+/**
+ * This exception is thrown for invalid authorization requests such user does not have acces to an aplication or resource.
+ * 
+ *  message: contains the authorization failure message
+ */
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
+public class AuthorizationException extends org.apache.thrift.TException implements org.apache.thrift.TBase<AuthorizationException, AuthorizationException._Fields>, java.io.Serializable, Cloneable, Comparable<AuthorizationException> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthorizationException");
+
+  private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new AuthorizationExceptionStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new AuthorizationExceptionTupleSchemeFactory();
+
+  private String message; // 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 {
+    MESSAGE((short)1, "message");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.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: // MESSAGE
+          return MESSAGE;
+        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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthorizationException.class, metaDataMap);
+  }
+
+  public AuthorizationException() {
+  }
+
+  public AuthorizationException(
+    String message)
+  {
+    this();
+    this.message = message;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public AuthorizationException(AuthorizationException other) {
+    if (other.isSetMessage()) {
+      this.message = other.message;
+    }
+  }
+
+  public AuthorizationException deepCopy() {
+    return new AuthorizationException(this);
+  }
+
+  @Override
+  public void clear() {
+    this.message = null;
+  }
+
+  public String getMessage() {
+    return this.message;
+  }
+
+  public void setMessage(String message) {
+    this.message = message;
+  }
+
+  public void unsetMessage() {
+    this.message = null;
+  }
+
+  /** Returns true if field message is set (has been assigned a value) and false otherwise */
+  public boolean isSetMessage() {
+    return this.message != null;
+  }
+
+  public void setMessageIsSet(boolean value) {
+    if (!value) {
+      this.message = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case MESSAGE:
+      if (value == null) {
+        unsetMessage();
+      } else {
+        setMessage((String)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case MESSAGE:
+      return getMessage();
+
+    }
+    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 MESSAGE:
+      return isSetMessage();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof AuthorizationException)
+      return this.equals((AuthorizationException)that);
+    return false;
+  }
+
+  public boolean equals(AuthorizationException that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    boolean this_present_message = true && this.isSetMessage();
+    boolean that_present_message = true && that.isSetMessage();
+    if (this_present_message || that_present_message) {
+      if (!(this_present_message && that_present_message))
+        return false;
+      if (!this.message.equals(that.message))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
+    if (isSetMessage())
+      hashCode = hashCode * 8191 + message.hashCode();
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(AuthorizationException other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetMessage()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
+      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 {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("AuthorizationException(");
+    boolean first = true;
+
+    sb.append("message:");
+    if (this.message == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.message);
+    }
+    first = false;
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetMessage()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' is unset! Struct:" + toString());
+    }
+
+    // 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 AuthorizationExceptionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public AuthorizationExceptionStandardScheme getScheme() {
+      return new AuthorizationExceptionStandardScheme();
+    }
+  }
+
+  private static class AuthorizationExceptionStandardScheme extends org.apache.thrift.scheme.StandardScheme<AuthorizationException> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, AuthorizationException 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: // MESSAGE
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.message = iprot.readString();
+              struct.setMessageIsSet(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();
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, AuthorizationException struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.message != null) {
+        oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
+        oprot.writeString(struct.message);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class AuthorizationExceptionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public AuthorizationExceptionTupleScheme getScheme() {
+      return new AuthorizationExceptionTupleScheme();
+    }
+  }
+
+  private static class AuthorizationExceptionTupleScheme extends org.apache.thrift.scheme.TupleScheme<AuthorizationException> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, AuthorizationException struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      oprot.writeString(struct.message);
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, AuthorizationException struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      struct.message = iprot.readString();
+      struct.setMessageIsSet(true);
+    }
+  }
+
+  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+  }
+}
+
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
new file mode 100644
index 0000000..9f0ad54
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ApplicationSettings.java
@@ -0,0 +1,185 @@
+package org.apache.custos.commons.utils;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+import java.util.regex.Pattern;
+
+public class ApplicationSettings {
+    protected static ApplicationSettings INSTANCE;
+    private Exception propertyLoadException;
+    public static final String SERVER_PROPERTIES="custos-server.properties";
+    public static final String CUSTOS_CONFIG_DIR = "custos.config.dir";
+    public static String ADDITIONAL_SETTINGS_FILES = "external.settings";
+    protected static final String TRUST_STORE_PATH="trust.store";
+    protected static final String TRUST_STORE_PASSWORD="trust.store.password";
+    private final static Logger logger = LoggerFactory.getLogger(ApplicationSettings.class);
+    protected Properties properties = new Properties();
+    // Profile Service Constants
+    public static final String PROFILE_SERVICE_SERVER_HOST = "profile.service.server.host";
+    public static final String PROFILE_SERVICE_SERVER_PORT = "profile.service.server.port";
+
+    // Iam Server Constants
+    public static final String IAM_SERVER_URL = "iam.server.url";
+    public static final String IAM_SERVER_SUPER_ADMIN_USERNAME = "iam.server.super.admin.username";
+    public static final String IAM_SERVER_SUPER_ADMIN_PASSWORD = "iam.server.super.admin.password";
+    {
+        loadProperties();
+    }
+    private void loadProperties() {
+        URL url = getPropertyFileURL();
+        try {
+            properties.load(url.openStream());
+            logger.info("Settings loaded from "+url.toString());
+            URL[] externalSettingsFileURLs = getExternalSettingsFileURLs();
+            for (URL externalSettings : externalSettingsFileURLs) {
+                mergeSettingsImpl(externalSettings.openStream());
+                logger.info("External settings merged from "+url.toString());
+            }
+        } catch (Exception e) {
+            propertyLoadException=e;
+        }
+    }
+    public void mergeSettingsImpl(InputStream stream) throws IOException {
+        Properties tmpProp = new Properties();
+        tmpProp.load(stream);
+        properties.putAll(tmpProp);
+    }
+    private URL[] getExternalSettingsFileURLs(){
+        try {
+            List<URL> externalSettingsFileURLs=new ArrayList<URL>();
+            String externalSettingsFileNames = getSettingImpl(ADDITIONAL_SETTINGS_FILES);
+            String[] externalSettingFiles = externalSettingsFileNames.split(",");
+            for (String externalSettingFile : externalSettingFiles) {
+                URL externalSettingFileURL = ApplicationSettings.loadFile(externalSettingFile);
+                if (externalSettingFileURL==null){
+                    logger.warn("Could not file external settings file "+externalSettingFile);
+                }else{
+                    externalSettingsFileURLs.add(externalSettingFileURL);
+                }
+            }
+            return externalSettingsFileURLs.toArray(new URL[]{});
+        } catch (ApplicationSettingsException e) {
+            return new URL[]{};
+        }
+    }
+    private URL getPropertyFileURL() {
+        return ApplicationSettings.loadFile(SERVER_PROPERTIES);
+    }
+    private static URL loadFile(String fileName) {
+
+        if(System.getProperty(CUSTOS_CONFIG_DIR) != null) {
+            String custosConfigDir = System.getProperty(CUSTOS_CONFIG_DIR);
+            try {
+                custosConfigDir = custosConfigDir.endsWith(File.separator) ? custosConfigDir : custosConfigDir + File.separator;
+                String filePath = custosConfigDir + fileName;
+
+                File asfile  = new File(filePath);
+                if (asfile.exists()) {
+
+                    return asfile.toURI().toURL();
+                }
+            } catch (MalformedURLException e) {
+                logger.error("Error parsing the file from custos.config.dir", custosConfigDir);
+            }
+        }
+
+        return ApplicationSettings.class.getClassLoader().getResource(fileName);
+
+    }
+    protected static ApplicationSettings getInstance(){
+        if (INSTANCE==null){
+            INSTANCE=new ApplicationSettings();
+        }
+        return INSTANCE;
+    }
+    public static String getSetting(String key) throws ApplicationSettingsException {
+        return getInstance().getSettingImpl(key);
+    }
+    public static String getSetting(String key, String defaultValue) {
+        return getInstance().getSettingImpl(key,defaultValue);
+
+    }
+    public static void setSetting(String key, String value) throws ApplicationSettingsException{
+        getInstance().properties.setProperty(key, value);
+        getInstance().saveProperties();
+    }
+    private void saveProperties() throws ApplicationSettingsException{
+        URL url = getPropertyFileURL();
+        if (url.getProtocol().equalsIgnoreCase("file")){
+            try {
+                properties.store(new FileOutputStream(url.getPath()), Calendar.getInstance().toString());
+            } catch (Exception e) {
+                throw new ApplicationSettingsException(url.getPath(), e);
+            }
+        }else{
+            logger.warn("Properties cannot be updated to location "+url.toString());
+        }
+    }
+    private String getSettingImpl(String key, String defaultValue){
+        try {
+            return getSettingImpl(key);
+        } catch (ApplicationSettingsException e) {
+            //we'll ignore this error since a default value is provided
+        }
+        return defaultValue;
+    }
+    private String getSettingImpl(String key) throws ApplicationSettingsException{
+        String rawValue=null;
+        if (System.getProperties().containsKey(key)){
+            rawValue=System.getProperties().getProperty(key);
+        }else{
+            validateSuccessfulPropertyFileLoad();
+            if (properties.containsKey(key)){
+                rawValue=properties.getProperty(key);
+            }else{
+                throw new ApplicationSettingsException(key);
+            }
+        }
+        return deriveAbsoluteValueImpl(rawValue);
+    }
+    private String deriveAbsoluteValueImpl(String property){
+        if (property!=null){
+            Map<Integer, String> containedParameters = StringUtil.getContainedParameters(property);
+            List<String> parametersAlreadyProcessed=new ArrayList<String>();
+            for (String parameter : containedParameters.values()) {
+                if (!parametersAlreadyProcessed.contains(parameter)) {
+                    String parameterName = parameter.substring(2,parameter.length() - 1);
+                    String parameterValue = getSetting(parameterName,parameter);
+                    property = property.replaceAll(Pattern.quote(parameter), parameterValue);
+                    parametersAlreadyProcessed.add(parameter);
+                }
+            }
+        }
+        return property;
+    }
+    private void validateSuccessfulPropertyFileLoad() throws ApplicationSettingsException{
+        if (propertyLoadException!=null){
+            throw new ApplicationSettingsException(propertyLoadException.getMessage(), propertyLoadException);
+        }
+    }
+    public static String getTrustStorePath() throws ApplicationSettingsException {
+        return getSetting(TRUST_STORE_PATH);
+    }
+    public static String getTrustStorePassword() throws ApplicationSettingsException {
+        return getSetting(TRUST_STORE_PASSWORD);
+    }
+    public static String getIamServerUrl() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.IAM_SERVER_URL);
+    }
+    public static String getProfileServiceServerHost() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_HOST);
+    }
+
+    public static String getProfileServiceServerPort() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.PROFILE_SERVICE_SERVER_PORT);
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
new file mode 100644
index 0000000..1325f46
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
@@ -0,0 +1,41 @@
+/**
+ *
+ * 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.custos.commons.utils;
+
+/**
+ * Constants used in Custos should go here.
+ */
+public final class Constants {
+    public static final String IN_MEMORY_CACHE_SIZE = "in.memory.cache.size";
+    public static final String AUTHZ_CACHE_MANAGER_CLASS = "authz.cache.manager.class";
+    public static final String API_METHOD_NAME = "api.method.name";
+    public static final String IS_API_SECURED = "api.secured";
+    public static final String AUTHORIZATION_POLICY_NAME = "authorization.policy";
+    public static final String SECURITY_MANAGER_CLASS = "security.manager.class";
+    public static final String AUTHZ_CACHE_ENABLED = "authz.cache.enabled";
+
+    //Names of the attributes that could be passed in the AuthzToken's claims map.
+    public static final String USER_NAME = "userName";
+    public static final String GATEWAY_ID = "gatewayID";
+    public static final String IDENTITY_SERVER_TENANT = "identityServerTenant";
+
+    //constants in XACML authorization response.
+    public static final String PERMIT = "Permit";
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/CustosUtils.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/CustosUtils.java
new file mode 100644
index 0000000..35cfe54
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/CustosUtils.java
@@ -0,0 +1,45 @@
+/**
+ *
+ * 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.custos.commons.utils;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.UUID;
+
+public class CustosUtils {
+
+    public static Timestamp getCurrentTimestamp() {
+        Calendar calender = Calendar.getInstance();
+//        java.util.Date d = calender.getTimeInMillis();
+        return new Timestamp(calender.getTimeInMillis());
+    }
+
+    public static Timestamp getTime(long time) {
+        if (time == 0 || time < 0){
+            return getCurrentTimestamp();
+        }
+        return new Timestamp(time);
+    }
+
+    public static String getId (String name){
+        String id = name.trim().replaceAll("\\s|\\.", "_");
+        return id + "_" + UUID.randomUUID();
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitConfig.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitConfig.java
new file mode 100644
index 0000000..123541a
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/DBInitConfig.java
@@ -0,0 +1,33 @@
+/*
+ * 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.custos.commons.utils;
+
+public interface DBInitConfig {
+    JDBCConfig getJDBCConfig();
+
+    String getDBInitScriptPrefix();
+
+    String getCheckTableName();
+
+    default void postInit() {
+
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/JDBCConfig.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/JDBCConfig.java
new file mode 100644
index 0000000..5cdb0ec
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/JDBCConfig.java
@@ -0,0 +1,29 @@
+/*
+ * 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.custos.commons.utils;
+
+public interface JDBCConfig {
+    String getURL();
+    String getDriver();
+    String getUser();
+    String getPassword();
+    String getValidationQuery();
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/JPAUtils.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/JPAUtils.java
new file mode 100644
index 0000000..9e02ce7
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/JPAUtils.java
@@ -0,0 +1,67 @@
+package org.apache.custos.commons.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * JPAUtils
+ */
+public class JPAUtils {
+
+    private final static Logger logger = LoggerFactory.getLogger(JPAUtils.class);
+    private final static Map<String, String> DEFAULT_ENTITY_MANAGER_FACTORY_PROPERTIES;
+    static {
+        Map<String, String> properties = new HashMap<String, String>();
+        properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource");
+        properties.put("openjpa.DynamicEnhancementAgent", "true");
+        properties.put("openjpa.RuntimeUnenhancedClasses", "unsupported");
+        properties.put("openjpa.RemoteCommitProvider", "sjvm");
+        properties.put("openjpa.Log", "DefaultLevel=INFO, Runtime=INFO, Tool=INFO, SQL=INFO");
+        properties.put("openjpa.jdbc.SynchronizeMappings", "validate");
+        properties.put("openjpa.jdbc.QuerySQLCache", "false");
+        properties.put("openjpa.DetachState", "all");
+        properties.put("openjpa.ConnectionFactoryProperties", "PrettyPrint=true, PrettyPrintLineLength=72,"
+                + " PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=31536000,  autoReconnect=true");
+        DEFAULT_ENTITY_MANAGER_FACTORY_PROPERTIES = properties;
+    }
+
+    /**
+     * Create an {@link EntityManagerFactory} with the default settings.
+     * @param persistenceUnitName
+     * @param jdbcConfig
+     * @return {@link EntityManagerFactory}
+     */
+    public static EntityManagerFactory getEntityManagerFactory(String persistenceUnitName, JDBCConfig jdbcConfig){
+
+        return getEntityManagerFactory(persistenceUnitName, jdbcConfig, Collections.emptyMap());
+    }
+
+    /**
+     * Create an {@link EntityManagerFactory}. The given properties will override the default properties.
+     * @param persistenceUnitName
+     * @param jdbcConfig
+     * @param properties
+     * @return {@link EntityManagerFactory}
+     */
+    public static EntityManagerFactory getEntityManagerFactory(String persistenceUnitName, JDBCConfig jdbcConfig, Map<String, String> properties) {
+
+        Map<String, String> finalProperties = new HashMap<>(DEFAULT_ENTITY_MANAGER_FACTORY_PROPERTIES);
+        finalProperties.putAll(createConnectionProperties(jdbcConfig));
+        finalProperties.putAll(properties);
+        return Persistence.createEntityManagerFactory(persistenceUnitName, finalProperties);
+    }
+
+    private static Map<String, String> createConnectionProperties(JDBCConfig jdbcConfig) {
+        String connectionProperties = "DriverClassName=" + jdbcConfig.getDriver() + "," + "Url=" + jdbcConfig.getURL()
+                + "?autoReconnect=true," + "Username=" + jdbcConfig.getUser() + "," + "Password="
+                + jdbcConfig.getPassword() + ",validationQuery=" + jdbcConfig.getValidationQuery();
+        logger.debug("Connection properties={}", connectionProperties);
+        return Collections.singletonMap("openjpa.ConnectionProperties", connectionProperties);
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/KeyStorePasswordCallback.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/KeyStorePasswordCallback.java
new file mode 100644
index 0000000..f08f6c2
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/KeyStorePasswordCallback.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.custos.commons.utils;/*
+ *
+ * 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.
+ *
+ */
+
+/**
+ * User: AmilaJ (amilaj@apache.org)
+ * Date: 10/11/13
+ * Time: 11:30 AM
+ */
+
+/**
+ * An interface to get keystore password in a form of a callback.
+ */
+public interface KeyStorePasswordCallback {
+
+    /**
+     * Caller should implement the interface. Should return the password for
+     * the keystore. This should return the keystore password. i.e. password used to open the keystore.
+     * Instead of the actual file.
+     * @return The password to open the keystore.
+     */
+    char[] getStorePassword() throws RuntimeException;
+
+    /**
+     * Caller should implement the interface. Should return the pass phrase for
+     * the secret key.
+     * Instead of the actual file.
+     * @param keyAlias The alias of the key
+     * @return The pass phrase for the secret key.
+     */
+    char[] getSecretKeyPassPhrase(String keyAlias);
+
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/SecurityUtil.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/SecurityUtil.java
new file mode 100644
index 0000000..9a8cec3
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/SecurityUtil.java
@@ -0,0 +1,192 @@
+/**
+ *
+ * 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.custos.commons.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import java.io.*;
+import java.security.*;
+import java.security.cert.CertificateException;
+
+/**
+ * Class which includes security utilities.
+ */
+public class SecurityUtil {
+
+    public static final String PASSWORD_HASH_METHOD_PLAINTEXT = "PLAINTEXT";
+
+    public static final String CHARSET_ENCODING = "UTF-8";
+    public static final String ENCRYPTION_ALGORITHM = "AES";
+    public static final String PADDING_MECHANISM = "AES/CBC/PKCS5Padding";
+
+    private static final Logger logger = LoggerFactory.getLogger(SecurityUtil.class);
+
+    /**
+     * Creates a hash of given string with the given hash algorithm.
+     * 
+     * @param stringToDigest
+     *            The string to digest.
+     * @param digestingAlgorithm
+     *            Hash algorithm.
+     * @return The digested string.
+     * @throws NoSuchAlgorithmException
+     *             If given hash algorithm doesnt exists.
+     */
+    public static String digestString(String stringToDigest, String digestingAlgorithm) throws NoSuchAlgorithmException {
+
+        if (digestingAlgorithm == null || digestingAlgorithm.equals(PASSWORD_HASH_METHOD_PLAINTEXT)) {
+            return stringToDigest;
+        }
+
+        MessageDigest messageDigest = MessageDigest.getInstance(digestingAlgorithm);
+        try {
+            return new String(messageDigest.digest(stringToDigest.getBytes("UTF-8")));
+        } catch (UnsupportedEncodingException e) {
+            logger.error("Error encoding password string when creating digest", e);
+            throw new RuntimeException("Error encoding password string when creating digest", e);
+        }
+    }
+
+    /**
+     * Sets the truststore for application. Useful when communicating over HTTPS.
+     * 
+     * @param trustStoreFilePath
+     *            Where trust store is located.
+     * @param trustStorePassword
+     *            The trust store password.
+     */
+    public static void setTrustStoreParameters(String trustStoreFilePath, String trustStorePassword) {
+
+        if (System.getProperty("javax.net.ssl.trustStrore") == null) {
+            logger.info("Setting Java trust store to " + trustStoreFilePath);
+            System.setProperty("javax.net.ssl.trustStrore", trustStoreFilePath);
+        }
+
+        if (System.getProperty("javax.net.ssl.trustStorePassword") == null) {
+            System.setProperty("javax.net.ssl.trustStorePassword", trustStoreFilePath);
+        }
+
+    }
+
+    public static byte[] encryptString(String keyStorePath, String keyAlias,
+                                 KeyStorePasswordCallback passwordCallback, String value)
+            throws GeneralSecurityException, IOException {
+        return encrypt(keyStorePath, keyAlias, passwordCallback, value.getBytes(CHARSET_ENCODING));
+    }
+
+    public static byte[] encrypt(String keyStorePath, String keyAlias,
+                                 KeyStorePasswordCallback passwordCallback, byte[] value)
+            throws GeneralSecurityException, IOException {
+
+        Key secretKey = getSymmetricKey(keyStorePath, keyAlias, passwordCallback);
+
+        Cipher cipher = Cipher.getInstance(PADDING_MECHANISM);
+        cipher.init(Cipher.ENCRYPT_MODE, secretKey,
+                new IvParameterSpec(new byte[16]));
+        return cipher.doFinal(value);
+    }
+
+    private static Key getSymmetricKey(String keyStorePath, String keyAlias,
+                                       KeyStorePasswordCallback passwordCallback)
+            throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException,
+            UnrecoverableKeyException {
+
+        KeyStore ks = SecurityUtil.loadKeyStore(keyStorePath, "jceks", passwordCallback);
+
+        if (ks == null) {
+            throw new IOException("Unable to load Java keystore " + keyStorePath);
+        }
+
+        return ks.getKey(keyAlias, passwordCallback.getSecretKeyPassPhrase(keyAlias));
+
+    }
+
+    public static byte[] decrypt(String keyStorePath, String keyAlias,
+                                 KeyStorePasswordCallback passwordCallback, byte[] encrypted)
+            throws GeneralSecurityException, IOException {
+
+        Key secretKey = getSymmetricKey(keyStorePath, keyAlias, passwordCallback);
+
+        Cipher cipher = Cipher.getInstance(PADDING_MECHANISM);
+        cipher.init(Cipher.DECRYPT_MODE, secretKey,
+                new IvParameterSpec(new byte[16]));
+
+        return cipher.doFinal(encrypted);
+    }
+
+    public static String decryptString(String keyStorePath, String keyAlias,
+                                       KeyStorePasswordCallback passwordCallback, byte[] encrypted)
+            throws GeneralSecurityException, IOException {
+
+        byte[] decrypted = decrypt(keyStorePath, keyAlias, passwordCallback, encrypted);
+        return new String(decrypted, CHARSET_ENCODING);
+    }
+
+    public static KeyStore loadKeyStore(String keyStoreFilePath, String keyStoreType,
+                                        KeyStorePasswordCallback passwordCallback)
+            throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
+
+        File keystoreFile = new File(keyStoreFilePath);
+
+        InputStream is;
+        if (keystoreFile.exists()) {
+            logger.debug("Loading keystore file from path " + keyStoreFilePath);
+            is = new FileInputStream(keyStoreFilePath);
+        } else {
+            logger.debug("Trying to load keystore file form class path " + keyStoreFilePath);
+            is = SecurityUtil.class.getClassLoader().getResourceAsStream(keyStoreFilePath);
+            if (is != null) {
+                logger.debug("Trust store file was loaded form class path " + keyStoreFilePath);
+            }
+        }
+
+        if (is == null) {
+            throw new KeyStoreException("Could not find a keystore file in path " + keyStoreFilePath);
+        }
+
+        try {
+            return loadKeyStore(is, keyStoreType, passwordCallback);
+        } finally {
+            is.close();
+        }
+    }
+
+    public static KeyStore loadKeyStore(InputStream inputStream, String keyStoreType,
+                                        KeyStorePasswordCallback passwordCallback)
+            throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
+
+        if (keyStoreType == null) {
+            keyStoreType = KeyStore.getDefaultType();
+        }
+
+        KeyStore ks = KeyStore.getInstance(keyStoreType);
+        ks.load(inputStream, passwordCallback.getStorePassword());
+
+        return ks;
+    }
+
+
+
+
+
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
new file mode 100644
index 0000000..2ead9e3
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * 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.custos.commons.utils;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ServerSettings extends ApplicationSettings {
+
+    private static final Logger log = LoggerFactory.getLogger(ServerSettings.class);
+    public static int getCacheSize() throws ApplicationSettingsException {
+        return Integer.valueOf(getSetting(Constants.IN_MEMORY_CACHE_SIZE));
+    }
+    public static String getAuthzCacheManagerClassName() throws ApplicationSettingsException {
+        return getSetting(Constants.AUTHZ_CACHE_MANAGER_CLASS);
+    }
+    public static boolean isAPISecured() throws ApplicationSettingsException {
+        return Boolean.valueOf(getSetting(Constants.IS_API_SECURED));
+    }
+    public static String getAuthorizationPoliyName() throws ApplicationSettingsException {
+        return getSetting(Constants.AUTHORIZATION_POLICY_NAME);
+    }
+    public static String getSecurityManagerClassName() throws ApplicationSettingsException {
+        return getSetting(Constants.SECURITY_MANAGER_CLASS);
+    }
+    public static String getRemoteIDPServiceUrl() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.IAM_SERVER_URL);
+    }
+    public static boolean isAuthzCacheEnabled() throws ApplicationSettingsException {
+        return Boolean.valueOf(getSetting(Constants.AUTHZ_CACHE_ENABLED));
+    }
+    public static String getIamServerSuperAdminUsername() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.IAM_SERVER_SUPER_ADMIN_USERNAME);
+    }
+    public static String getIamServerSuperAdminPassword() throws ApplicationSettingsException {
+        return getSetting(ServerSettings.IAM_SERVER_SUPER_ADMIN_PASSWORD);
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/StringUtil.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/StringUtil.java
new file mode 100644
index 0000000..1306dbf
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/StringUtil.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * 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.custos.commons.utils;
+
+import java.util.*;
+
+public class StringUtil {
+	
+	public static Map<Integer, String> getContainedParameters(String s) {
+		Map<Integer,String> parameterMap=new HashMap<Integer,String>();
+		int i=0;
+		for(i=0;i<s.length();i++){
+			if (s.charAt(i)=='$' && (i+1)<s.length() && s.charAt(i+1)=='{'){
+				int i2=s.indexOf('{', i+2);
+				int e=s.indexOf('}', i+2);
+				if (e!=-1){
+					if (i2==-1 || e<i2){
+						parameterMap.put(i, s.substring(i,e+1));
+						i=e;
+					}
+				}
+			}
+		}
+		return parameterMap;
+	}
+}
\ No newline at end of file
diff --git a/custos-services/custos-security-service/pom.xml b/custos-services/custos-security-service/pom.xml
new file mode 100644
index 0000000..fe585cd
--- /dev/null
+++ b/custos-services/custos-security-service/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>custos-services</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>custos-security-service</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-commons</artifactId>
+            <version>${parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
+            <version>4.2.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2.wso2</groupId>
+            <artifactId>axis2</artifactId>
+            <version>1.6.1.wso2v4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.utils</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.identity.entitlement.stub</artifactId>
+            <version>4.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.wso2.carbon</groupId>
+            <artifactId>org.wso2.carbon.identity.entitlement.common</artifactId>
+            <version>4.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.inject</groupId>
+            <artifactId>guice</artifactId>
+            <version>4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>aopalliance</groupId>
+            <artifactId>aopalliance</artifactId>
+            <version>1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.oltu.oauth2</groupId>
+            <artifactId>org.apache.oltu.oauth2.client</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-mapper-asl</artifactId>
+            <version>1.9.13</version>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCache.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCache.java
new file mode 100644
index 0000000..5be2f04
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCache.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.
+ *
+ */
+package org.apache.custos.security.authzcache;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class AuthzCache extends LinkedHashMap<AuthzCacheIndex, AuthzCacheEntry> {
+
+    private static int MAX_SIZE;
+    private final static Logger logger = LoggerFactory.getLogger(AuthzCache.class);
+
+    private static AuthzCache authzCache = null;
+
+    public static AuthzCache getInstance() throws ApplicationSettingsException {
+        if (authzCache == null) {
+            synchronized (AuthzCache.class) {
+                if (authzCache == null) {
+                    authzCache = new AuthzCache(ServerSettings.getCacheSize());
+                }
+            }
+        }
+        return authzCache;
+    }
+
+    private AuthzCache(int initialCapacity) {
+        super(initialCapacity);
+        MAX_SIZE = initialCapacity;
+    }
+
+    @Override
+    protected boolean removeEldestEntry(Map.Entry<AuthzCacheIndex, AuthzCacheEntry> eldest) {
+        if (size() > MAX_SIZE) {
+            logger.info("Authz cache max size exceeded. Removing the old entries.");
+        }
+        return size() > MAX_SIZE;
+    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheEntry.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheEntry.java
new file mode 100644
index 0000000..967ea02
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheEntry.java
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.custos.security.authzcache;
+
+/**
+ * Cache entry in the default authorization cache.
+ */
+public class AuthzCacheEntry {
+    //authorization decision for the authorization request associated with this cache entry.
+    private boolean decision;
+    //time to live value for the access token in seconds.
+    private long expiryTime;
+    //time stamp in milli seconds at the time this entry is put into the cache
+    private long entryTimestamp;
+
+    public AuthzCacheEntry(boolean decision, long expiryTime, long entryTimestamp) {
+        this.decision = decision;
+        this.expiryTime = expiryTime;
+        this.entryTimestamp = entryTimestamp;
+    }
+
+    public long getEntryTimestamp() {
+        return entryTimestamp;
+    }
+
+    public void setEntryTimestamp(long entryTimestamp) {
+        this.entryTimestamp = entryTimestamp;
+    }
+
+    public long getExpiryTime() {
+        return expiryTime;
+    }
+
+    public void setExpiryTime(long timestamp) {
+        this.expiryTime = timestamp;
+    }
+
+    public boolean getDecision() {
+        return decision;
+    }
+
+    public void setDecision(boolean decision) {
+        this.decision = decision;
+    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheIndex.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheIndex.java
new file mode 100644
index 0000000..90c6f9d
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheIndex.java
@@ -0,0 +1,90 @@
+/*
+ *
+ * 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.custos.security.authzcache;
+
+/**
+ * Cache index of the default authorization cache.
+ */
+public class AuthzCacheIndex {
+
+    private String subject;
+    private String oauthAccessToken;
+//    private String action;
+    private String gatewayId;
+
+    public AuthzCacheIndex(String userName, String gatewayId, String accessToken) {
+        this.subject = userName;
+        this.oauthAccessToken = accessToken;
+//        this.action = actionString;
+        this.gatewayId = gatewayId;
+    }
+
+    public String getSubject() {
+        return subject;
+    }
+
+    public void setSubject(String subject) {
+        this.subject = subject;
+    }
+
+//    public String getAction() {
+//        return action;
+//    }
+//
+//    public void setAction(String action) {
+//        this.action = action;
+//    }
+
+    public String getOauthAccessToken() {
+        return oauthAccessToken;
+    }
+
+    public void setOauthAccessToken(String oauthAccessToken) {
+        this.oauthAccessToken = oauthAccessToken;
+    }
+
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    /*Equals and hash code methods are overridden since this is being used as an index of a map and that containsKey method
+        * should return true if the values of two index objects are equal.*/
+    @Override
+    public boolean equals(Object other) {
+        if (other == null || other.getClass() != getClass()) {
+            return false;
+        }
+        return ((this.getSubject().equals(((AuthzCacheIndex) other).getSubject()))
+                && (this.getGatewayId().equals(((AuthzCacheIndex) other).getGatewayId()))
+                && (this.getOauthAccessToken().equals(((AuthzCacheIndex) other).getOauthAccessToken())));
+                //&& (this.getAction().equals(((AuthzCacheIndex) other).getAction())));
+    }
+
+    @Override
+    public int hashCode() {
+        return this.getSubject().hashCode() + this.getOauthAccessToken().hashCode() + this.getGatewayId().hashCode();
+                //+ this.getAction().hashCode();
+    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManager.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManager.java
new file mode 100644
index 0000000..8c39897
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManager.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.custos.security.authzcache;
+
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+
+/**
+ * This is the interface through which security manager accesses the underlying caching implementation
+ * See the DefaultAuthzCacheManager.java for an example implementation of this interface.
+ */
+public interface AuthzCacheManager {
+    /**
+     * Returns the status of the cache w.r.t the given authorization request which is encapsulated in
+     * the AuthzCacheIndex.
+     *
+     * @param authzCacheIndex
+     * @return
+     */
+    public AuthzCachedStatus getAuthzCachedStatus(AuthzCacheIndex authzCacheIndex) throws CustosSecurityException;
+
+    /**
+     * Add to cache the authorization decision pertaining to a given authorization request.
+     *
+     * @param authzCacheIndex
+     * @param authzCacheEntry
+     * @throws CustosSecurityException
+     */
+    public void addToAuthzCache(AuthzCacheIndex authzCacheIndex, AuthzCacheEntry authzCacheEntry) throws CustosSecurityException;
+
+    /**
+     * Check if a valid decision is cached for a given authorization request.
+     *
+     * @param authzCacheIndex
+     * @return
+     */
+    public boolean isAuthzDecisionCached(AuthzCacheIndex authzCacheIndex) throws CustosSecurityException;
+
+    /**
+     * Returns the AuthzCacheEntry for a given authorization request.
+     *
+     * @param authzCacheIndex
+     * @return
+     * @throws CustosSecurityException
+     */
+    public AuthzCacheEntry getAuthzCacheEntry(AuthzCacheIndex authzCacheIndex) throws CustosSecurityException;
+
+    /**
+     * Removes the authorization cache entry for a given authorization request.
+     *
+     * @param authzCacheIndex
+     * @throws CustosSecurityException
+     */
+    public void removeAuthzCacheEntry(AuthzCacheIndex authzCacheIndex) throws CustosSecurityException;
+
+    /**
+     * Clear the authorization cache.
+     *
+     * @return
+     */
+    public void clearCache() throws CustosSecurityException;
+
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManagerFactory.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManagerFactory.java
new file mode 100644
index 0000000..d9a8d68
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCacheManagerFactory.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.custos.security.authzcache;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This initializes the AuthzCacheManager implementation to be used as defined by the configuration.
+ */
+public class AuthzCacheManagerFactory {
+    private final static Logger logger = LoggerFactory.getLogger(AuthzCacheManagerFactory.class);
+
+    public static AuthzCacheManager getAuthzCacheManager() throws CustosSecurityException {
+        try {
+            Class authzCacheManagerImpl = Class.forName(ServerSettings.getAuthzCacheManagerClassName());
+            AuthzCacheManager authzCacheManager  = (AuthzCacheManager) authzCacheManagerImpl.newInstance();
+            return  authzCacheManager;
+        } catch (ClassNotFoundException e) {
+            String error = "Authorization Cache Manager class could not be found.";
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException(error);
+        } catch (ApplicationSettingsException e) {
+            String error = "Error in reading the configuration related to Authorization Cache Manager class.";
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException(error);
+        } catch (InstantiationException e) {
+            String error = "Error in instantiating the Authorization Cache Manager class.";
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException(error);
+        } catch (IllegalAccessException e) {
+            String error = "Error in instantiating the Authorization Cache Manager class.";
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException(error);
+
+        }
+    }
+
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCachedStatus.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCachedStatus.java
new file mode 100644
index 0000000..182f072
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/AuthzCachedStatus.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.custos.security.authzcache;
+
+/**
+ * This enum defines the status of the authorization cache returned by the authorization cache manager
+ * when an authorization status is checked against an authorization request.
+ */
+public enum AuthzCachedStatus {
+    /*Authorization decision is cached for the given authrization request and the decision authorizes the request.*/
+    AUTHORIZED,
+    /*Authorization decision is cached for the given authorization request and the decision denies authorization.*/
+    NOT_AUTHORIZED,
+    /*Authorization decision is not either cached or the cached entry is invalid such that re-authorization is needed.*/
+    NOT_CACHED
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/DefaultAuthzCacheManager.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/DefaultAuthzCacheManager.java
new file mode 100644
index 0000000..7b8754a
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/authzcache/DefaultAuthzCacheManager.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * 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.custos.security.authzcache;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DefaultAuthzCacheManager implements AuthzCacheManager {
+
+    private final static Logger logger = LoggerFactory.getLogger(DefaultAuthzCacheManager.class);
+
+    @Override
+    public AuthzCachedStatus getAuthzCachedStatus(AuthzCacheIndex authzCacheIndex) throws CustosSecurityException {
+        if (isAuthzDecisionCached(authzCacheIndex)) {
+            AuthzCacheEntry cacheEntry = getAuthzCacheEntry(authzCacheIndex);
+            long expiryTime = cacheEntry.getExpiryTime();
+            long currentTime = System.currentTimeMillis();
+            long timePassed = (currentTime - cacheEntry.getEntryTimestamp()) / 1000;
+            if (expiryTime > timePassed) {
+                //access token is still valid. Hence, return the cached decision
+                if (cacheEntry.getDecision()) {
+                    return AuthzCachedStatus.AUTHORIZED;
+                } else {
+                    return AuthzCachedStatus.NOT_AUTHORIZED;
+                }
+            } else {
+                //access token has been expired. Hence, remove the entry and return.
+                removeAuthzCacheEntry(authzCacheIndex);
+                return AuthzCachedStatus.NOT_CACHED;
+            }
+        } else {
+            return AuthzCachedStatus.NOT_CACHED;
+        }
+    }
+
+    @Override
+    public void addToAuthzCache(AuthzCacheIndex authzCacheIndex, AuthzCacheEntry authzCacheEntry) throws CustosSecurityException {
+        try {
+            AuthzCache.getInstance().put(authzCacheIndex, authzCacheEntry);
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in obtaining the authorization cache instance.");
+        }
+    }
+
+    @Override
+    public boolean isAuthzDecisionCached(AuthzCacheIndex authzCacheIndex) throws CustosSecurityException {
+        try {
+            return AuthzCache.getInstance().containsKey(authzCacheIndex);
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in obtaining the authorization cache instance.");
+        }
+    }
+
+    @Override
+    public AuthzCacheEntry getAuthzCacheEntry(AuthzCacheIndex authzCacheIndex) throws CustosSecurityException {
+        try {
+            return AuthzCache.getInstance().get(authzCacheIndex);
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in obtaining the authorization cache instance.");
+        }
+    }
+
+    @Override
+    public void removeAuthzCacheEntry(AuthzCacheIndex authzCacheIndex) throws CustosSecurityException {
+        try {
+            AuthzCache.getInstance().remove(authzCacheIndex);
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in obtaining the authorization cache instance.");
+        }
+    }
+
+    @Override
+    public void clearCache() throws CustosSecurityException {
+        try {
+            AuthzCache.getInstance().clear();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in obtaining the authorization cache instance.");
+
+        }
+    }
+}
\ No newline at end of file
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/CustosSecurityManager.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/CustosSecurityManager.java
new file mode 100644
index 0000000..afeb1d2
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/CustosSecurityManager.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.custos.security.manager;
+
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.security.model.AuthzToken;
+
+import java.util.Map;
+
+public interface CustosSecurityManager {
+    /**
+     * Implement this method in your SecurityManager to perform necessary initializations at the server startup.
+     * @throws CustosSecurityException
+     */
+    public void initializeSecurityInfra() throws CustosSecurityException;
+
+    /**
+     * Implement this method with the user authentication/authorization logic in your SecurityManager.
+     * @param authzToken : this includes OAuth token and user's claims
+     * @param metaData : this includes other meta data needed for security enforcements.
+     * @return
+     * @throws CustosSecurityException
+     */
+    public boolean isUserAuthorized(AuthzToken authzToken, Map<String, String> metaData) throws CustosSecurityException;
+
+
+    /**
+     * Return an AuthzToken that has the appropriate access to manage user's in the IAM service.
+     * @param gatewayId
+     * @return
+     * @throws CustosSecurityException
+     */
+    public AuthzToken getUserManagementServiceAccountAuthzToken(String gatewayId, String clientId, String clientSecret) throws CustosSecurityException;
+
+    /**
+     * Get OpenID Connect user profile information from the given AuthzToken.
+     * @param authzToken
+     * @return
+     * @throws CustosSecurityException
+     */
+    public UserInfo getUserInfoFromAuthzToken(AuthzToken authzToken, String identityServerRealm) throws CustosSecurityException;
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/IdentityContext.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/IdentityContext.java
new file mode 100644
index 0000000..f5648ba
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/IdentityContext.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.custos.security.manager;
+
+import org.apache.custos.security.model.AuthzToken;
+
+/**
+ * This provides a thread local container for AuthzToken through out the execution of a particular thread.
+ */
+public class IdentityContext {
+    private static ThreadLocal authzTokenContainer = new ThreadLocal();
+
+    public static void set(AuthzToken authzToken){
+        authzTokenContainer.set(authzToken);
+    }
+
+    public static void unset(){
+        authzTokenContainer.remove();
+    }
+
+    public static AuthzToken get(){
+        return (AuthzToken) authzTokenContainer.get();
+    }
+
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/KeyCloakSecurityManager.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/KeyCloakSecurityManager.java
new file mode 100644
index 0000000..ea1cbb2
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/KeyCloakSecurityManager.java
@@ -0,0 +1,537 @@
+/*
+ *
+ * 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.custos.security.manager;
+
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.utils.Constants;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.security.authzcache.*;
+import org.apache.custos.security.model.AuthzToken;
+import org.apache.custos.security.utils.TrustStoreManager;
+import org.apache.http.Consts;
+import org.apache.http.HttpHeaders;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.List;
+import java.util.Map;
+
+public class KeyCloakSecurityManager implements CustosSecurityManager {
+    private final static Logger logger = LoggerFactory.getLogger(KeyCloakSecurityManager.class);
+
+//    private HashMap<String, String> rolePermissionConfig = new HashMap<>();
+//
+//    // Methods that users user to manage their user resource profile
+//    private final static String USER_RESOURCE_PROFILE_USER_METHODS = "/airavata/registerUserResourceProfile|/airavata/getUserResourceProfile" +
+//            "|/airavata/updateUserResourceProfile|/airavata/deleteUserResourceProfile|/airavata/addUserComputeResourcePreference" +
+//            "|/airavata/addUserStoragePreference|/airavata/getUserComputeResourcePreference|/airavata/getUserStoragePreference" +
+//            "|/airavata/getAllUserComputeResourcePreferences|/airavata/getAllUserStoragePreferences" +
+//            "|/airavata/updateUserComputeResourcePreference|/airavata/updateUserStoragePreference" +
+//            "|/airavata/deleteUserComputeResourcePreference|/airavata/deleteUserStoragePreference" +
+//            "|/airavata/generateAndRegisterSSHKeys|/airavata/getAllCredentialSummaryForUsersInGateway" +
+//            "|/airavata/deleteSSHPubKey|/airavata/isUserResourceProfileExists";
+//    private final static String SHARING_RESOURCE_METHODS = "/airavata/shareResourceWithUsers|/airavata/revokeSharingOfResourceFromUsers" +
+//            "|/airavata/shareResourceWithGroups|/airavata/revokeSharingOfResourceFromGroups|/airavata/getAllAccessibleUsers" +
+//            "|/airavata/getAllAccessibleGroups|/airavata/userHasAccess|/airavata/getAllDirectlyAccessibleUsers" +
+//            "|/airavata/getAllDirectlyAccessibleGroups";
+//    private final static String SSH_ACCOUNT_PROVISIONER_METHODS =
+//            "/airavata/getSSHAccountProvisioners|/airavata/doesUserHaveSSHAccount|/airavata" +
+//                    "/setupUserComputeResourcePreferencesForSSH|" +
+//                    // getGatewayResourceProfile is needed to look up whether ssh account provisioning is
+//                    // configured for a gateway's compute resource preference
+//                    "/airavata/getGatewayResourceProfile";
+//    // These methods are protected by sharing registry authorization
+//    private final static String GROUP_RESOURCE_PROFILE_METHODS =
+//            "/airavata/createGroupResourceProfile|/airavata/updateGroupResourceProfile|/airavata/getGroupResourceProfile" +
+//                    "|/airavata/removeGroupResourceProfile|/airavata/getGroupResourceList|/airavata/removeGroupComputePrefs" +
+//                    "|/airavata/removeGroupComputeResourcePolicy|/airavata/removeGroupBatchQueueResourcePolicy" +
+//                    "|/airavata/getGroupComputeResourcePreference|/airavata/getGroupComputeResourcePolicy" +
+//                    "|/airavata/getBatchQueueResourcePolicy|/airavata/getGroupComputeResourcePrefList" +
+//                    "|/airavata/getGroupBatchQueueResourcePolicyList|/airavata/getGroupComputeResourcePolicyList";
+//    // These methods are protected by sharing registry authorization
+//    private final static String APPLICATION_DEPLOYMENT_METHODS =
+//            "/airavata/registerApplicationDeployment|/airavata/getApplicationDeployment|/airavata/updateApplicationDeployment" +
+//                    "|/airavata/deleteApplicationDeployment|/airavata/getAllApplicationDeployments|/airavata/getAccessibleApplicationDeployments" +
+//                    "|/airavata/getApplicationDeploymentsForAppModuleAndGroupResourceProfile";
+//    private final static String APPLICATION_MODULE_METHODS = "/airavata/getAccessibleAppModules";
+//    private final static String CREDENTIAL_TOKEN_METHODS = "/airavata/getCredentialSummary|/airavata/getAllCredentialSummaries|/airavata/generateAndRegisterSSHKeys|/airavata/registerPwdCredential|/airavata/deleteSSHPubKey|/airavata/deletePWDCredential";
+//    // Misc. other methods needed for group based authorization
+//    private final static String GROUP_BASED_AUTH_METHODS = "/airavata/getGatewayGroups";
+//
+//    private RegistryService.Client registryServiceClient = null;
+//    private SharingRegistryService.Client sharingRegistryServiceClient = null;
+//
+//    private static class GatewayGroupMembership {
+//        private boolean inAdminsGroup = false;
+//        private boolean inReadOnlyAdminsGroup = false;
+//
+//        public boolean isInAdminsGroup() {
+//            return inAdminsGroup;
+//        }
+//
+//        public void setInAdminsGroup(boolean inAdminsGroup) {
+//            this.inAdminsGroup = inAdminsGroup;
+//        }
+//
+//        public boolean isInReadOnlyAdminsGroup() {
+//            return inReadOnlyAdminsGroup;
+//        }
+//
+//        public void setInReadOnlyAdminsGroup(boolean inReadOnlyAdminsGroup) {
+//            this.inReadOnlyAdminsGroup = inReadOnlyAdminsGroup;
+//        }
+//    }
+
+    public KeyCloakSecurityManager() throws CustosSecurityException {
+//        rolePermissionConfig.put("admin", "/airavata/.*");
+//        rolePermissionConfig.put("gateway-provider", "/airavata/.*");
+//        rolePermissionConfig.put("admin-read-only", "/airavata/getSSHPubKey|/airavata/getAllGatewaySSHPubKeys" +
+//                "|/airavata/getAllGatewayPWDCredentials|/airavata/getApplicationModule|/airavata/getAllAppModules" +
+//                "|/airavata/getApplicationDeployment|/airavata/getAllApplicationDeployments|/airavata/getAppModuleDeployedResources" +
+//                "|/airavata/getStorageResource|/airavata/getAllStorageResourceNames|/airavata/getSCPDataMovement" +
+//                "|/airavata/getUnicoreDataMovement|/airavata/getGridFTPDataMovement|/airavata/getResourceJobManager" +
+//                "|/airavata/deleteResourceJobManager|/airavata/getGatewayResourceProfile|/airavata/getGatewayComputeResourcePreference" +
+//                "|/airavata/getGatewayStoragePreference|/airavata/getAllGatewayComputeResourcePreferences" +
+//                "|/airavata/getAllGatewayStoragePreferences|/airavata/getAllGatewayResourceProfiles|/airavata/getAPIVersion" +
+//                "|/airavata/getNotification|/airavata/getAllNotifications|/airavata/createProject|/airavata/updateProject" +
+//                "|/airavata/getProject|/airavata/deleteProject|/airavata/getUserProjects|/airavata/searchProjectsByProjectName" +
+//                "|/airavata/searchProjectsByProjectDesc|/airavata/searchExperimentsByName|/airavata/searchExperimentsByDesc" +
+//                "|/airavata/searchExperimentsByApplication|/airavata/searchExperimentsByStatus|/airavata/searchExperimentsByCreationTime" +
+//                "|/airavata/searchExperiments|/airavata/getExperimentStatistics|/airavata/getExperimentsInProject" +
+//                "|/airavata/getUserExperiments|/airavata/createExperiment|/airavata/deleteExperiment|/airavata/getExperiment" +
+//                "|/airavata/getDetailedExperimentTree|/airavata/updateExperiment|/airavata/updateExperimentConfiguration" +
+//                "|/airavata/updateResourceScheduleing|/airavata/validateExperiment|/airavata/launchExperiment" +
+//                "|/airavata/getExperimentStatus|/airavata/getExperimentOutputs|/airavata/getIntermediateOutputs" +
+//                "|/airavata/getJobStatuses|/airavata/getJobDetails|/airavata/cloneExperiment|/airavata/terminateExperiment" +
+//                "|/airavata/getApplicationInterface|/airavata/getAllApplicationInterfaceNames|/airavata/getAllApplicationInterfaces" +
+//                "|/airavata/getApplicationInputs|/airavata/getApplicationOutputs|/airavata/getAvailableAppInterfaceComputeResources" +
+//                "|/airavata/getComputeResource|/airavata/getAllComputeResourceNames|/airavata/getWorkflow|/airavata/getWorkflowTemplateId" +
+//                "|/airavata/isWorkflowExistWithName|/airavata/registerDataProduct|/airavata/getDataProduct|/airavata/registerReplicaLocation" +
+//                "|/airavata/getParentDataProduct|/airavata/getChildDataProducts|/airavata/getAllAccessibleUsers" +
+//                "|/airavata/getExperimentByAdmin|/airavata/cloneExperimentByAdmin|/airavata/getAllCredentialSummaryForGateway" +
+//                "|" + USER_RESOURCE_PROFILE_USER_METHODS + "|/airavata/getAllUserResourceProfiles" +
+//                "|" + SHARING_RESOURCE_METHODS + "|/airavata/getGateway|" + SSH_ACCOUNT_PROVISIONER_METHODS + "|" + GROUP_RESOURCE_PROFILE_METHODS +
+//                "|" + APPLICATION_DEPLOYMENT_METHODS + "|" + GROUP_BASED_AUTH_METHODS + "|" + APPLICATION_MODULE_METHODS +
+//                "|" + CREDENTIAL_TOKEN_METHODS);
+//        rolePermissionConfig.put("gateway-user", "/airavata/getAPIVersion|/airavata/getNotification|/airavata/getAllNotifications|" +
+//                "/airavata/createProject|/airavata/updateProject|/airavata/getProject|/airavata/deleteProject|/airavata/getUserProjects|" +
+//                "/airavata/searchProjectsByProjectName|/airavata/searchProjectsByProjectDesc|/airavata/searchExperimentsByName|" +
+//                "/airavata/searchExperimentsByDesc|/airavata/searchExperimentsByApplication|/airavata/searchExperimentsByStatus|" +
+//                "/airavata/searchExperimentsByCreationTime|/airavata/searchExperiments|/airavata/getExperimentStatistics|" +
+//                "/airavata/getExperimentsInProject|/airavata/getUserExperiments|/airavata/createExperiment|/airavata/deleteExperiment|" +
+//                "/airavata/getExperiment|/airavata/getDetailedExperimentTree|/airavata/updateExperiment|/airavata/updateExperimentConfiguration|" +
+//                "/airavata/updateResourceScheduleing|/airavata/validateExperiment|/airavata/launchExperiment|/airavata/getExperimentStatus|" +
+//                "/airavata/getExperimentOutputs|/airavata/getIntermediateOutputs|/airavata/getJobStatuses|/airavata/getJobDetails|" +
+//                "/airavata/cloneExperiment|/airavata/terminateExperiment|/airavata/getApplicationInterface|/airavata/getAllApplicationInterfaceNames|" +
+//                "/airavata/getAllApplicationInterfaces|/airavata/getApplicationInputs|/airavata/getApplicationOutputs|" +
+//                "/airavata/getAvailableAppInterfaceComputeResources|/airavata/getComputeResource|/airavata/getAllComputeResourceNames|" +
+//                "/airavata/getWorkflow|/airavata/getWorkflowTemplateId|/airavata/isWorkflowExistWithName|/airavata/registerDataProduct|" +
+//                "/airavata/getDataProduct|/airavata/registerReplicaLocation|/airavata/getParentDataProduct|/airavata/getChildDataProducts|" +
+//                "/airavata/getAllAccessibleUsers|/airavata/getAllApplicationDeployments|/airavata/getAllAppModules|/airavata/getApplicationModule|" + USER_RESOURCE_PROFILE_USER_METHODS + "|" +
+//                SHARING_RESOURCE_METHODS + "|" + SSH_ACCOUNT_PROVISIONER_METHODS + "|" + GROUP_RESOURCE_PROFILE_METHODS +
+//                "|" + APPLICATION_DEPLOYMENT_METHODS + "|" + GROUP_BASED_AUTH_METHODS + "|" + APPLICATION_MODULE_METHODS +
+//                "|" + CREDENTIAL_TOKEN_METHODS);
+
+        initializeSecurityInfra();
+    }
+
+    /**
+     * Implement this method in your SecurityManager to perform necessary initializations at the server startup.
+     *
+     * @throws CustosSecurityException
+     */
+    @Override
+    public void initializeSecurityInfra() throws CustosSecurityException {
+        try {
+            //initialize SSL context with the trust store that contains the public cert of WSO2 Identity Server.
+            TrustStoreManager trustStoreManager = new TrustStoreManager();
+            trustStoreManager.initializeTrustStoreManager(ServerSettings.getTrustStorePath(),
+                    ServerSettings.getTrustStorePassword());
+        } catch (Exception e) {
+            throw new CustosSecurityException(e.getMessage(), e);
+        }
+
+    }
+
+    /**
+     * Implement this method with the user authentication/authorization logic in your SecurityManager.
+     *
+     * @param authzToken : this includes OAuth token and user's claims
+     * @param metaData   : this includes other meta data needed for security enforcements.
+     * @return
+     * @throws CustosSecurityException
+     */
+    @Override
+    public boolean isUserAuthorized(AuthzToken authzToken, Map<String, String> metaData) throws CustosSecurityException {
+        String subject = authzToken.getClaimsMap().get(Constants.USER_NAME);
+        String accessToken = authzToken.getAccessToken();
+        String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
+        String identityServerRealm = metaData.get(Constants.IDENTITY_SERVER_TENANT);
+        //String action = "/airavata/" + metaData.get(Constants.API_METHOD_NAME);
+        try {
+//            if (!ServerSettings.isAPISecured()) {
+//                return true;
+//            }
+//            initServiceClients();
+
+            if (ServerSettings.isAuthzCacheEnabled()) {
+                //obtain an instance of AuthzCacheManager implementation.
+                AuthzCacheManager authzCacheManager = AuthzCacheManagerFactory.getAuthzCacheManager();
+
+                //check in the cache
+                AuthzCachedStatus authzCachedStatus = authzCacheManager.getAuthzCachedStatus(
+                        new AuthzCacheIndex(subject, gatewayId, accessToken));
+
+                if (AuthzCachedStatus.AUTHORIZED.equals(authzCachedStatus)) {
+                    logger.debug("Authz decision for: (" + subject + ", " + accessToken + ") is retrieved from cache.");
+                    return true;
+                } else if (AuthzCachedStatus.NOT_AUTHORIZED.equals(authzCachedStatus)) {
+                    logger.debug("Authz decision for: (" + subject + ", " + accessToken + ") is retrieved from cache.");
+                    return false;
+                } else if (AuthzCachedStatus.NOT_CACHED.equals(authzCachedStatus)) {
+                    logger.debug("Authz decision for: (" + subject + ", " + accessToken + ") is not in the cache. " +
+                            "Generating decision based on group membership.");
+//                    GatewayGroupMembership gatewayGroupMembership = getGatewayGroupMembership(subject, accessToken, gatewayId);
+//                    boolean authorizationDecision = hasPermission(gatewayGroupMembership, action);
+                    boolean authorizationDecision = validateToken(subject, accessToken, gatewayId, identityServerRealm);
+                    //cache the authorization decision
+                    long currentTime = System.currentTimeMillis();
+                    //TODO get the actual token expiration time
+                    authzCacheManager.addToAuthzCache(new AuthzCacheIndex(subject, gatewayId, accessToken),
+                            new AuthzCacheEntry(authorizationDecision, currentTime + 1000 * 60 * 60, currentTime));
+                    return authorizationDecision;
+                } else {
+                    //undefined status returned from the authz cache manager
+                    throw new CustosSecurityException("Error in reading from the authorization cache.");
+                }
+            } else {
+//                GatewayGroupMembership gatewayGroupMembership = getGatewayGroupMembership(subject, accessToken, gatewayId);
+//                return hasPermission(gatewayGroupMembership, action);
+                return validateToken(subject, accessToken, gatewayId, identityServerRealm);
+            }
+
+        } catch (ApplicationSettingsException e) {
+            logger.error("Missing or invalid application setting.", e);
+            throw new CustosSecurityException(e.getMessage(), e);
+        } catch (Exception e) {
+            logger.error("Error occurred while checking if user: " + subject + " is authorized in gateway: " + gatewayId, e);
+            throw new CustosSecurityException(e.getMessage(), e);
+        }
+//        } finally {
+//            closeServiceClients();
+//        }
+    }
+
+    @Override
+    public AuthzToken getUserManagementServiceAccountAuthzToken(String gatewayId, String clientId, String clientSecret) throws CustosSecurityException {
+        try {
+//            initServiceClients();
+//            Gateway gateway = registryServiceClient.getGateway(gatewayId);
+            String tokenURL = getTokenEndpoint(gatewayId);
+//            JSONObject clientCredentials = getClientCredentials(tokenURL, gateway.getOauthClientId(), gateway.getOauthClientSecret());
+            JSONObject clientCredentials = getClientCredentials(tokenURL, clientId, clientSecret);
+            String accessToken = clientCredentials.getString("access_token");
+            AuthzToken authzToken = new AuthzToken(accessToken);
+            authzToken.putToClaimsMap(Constants.GATEWAY_ID, gatewayId);
+            authzToken.putToClaimsMap(Constants.USER_NAME, clientId);
+            return authzToken;
+        } catch (Exception e) {
+            throw new CustosSecurityException(e);
+        }
+//        } finally {
+//            closeServiceClients();
+//        }
+    }
+
+    @Override
+    public UserInfo getUserInfoFromAuthzToken(AuthzToken authzToken, String identityServerRealm) throws CustosSecurityException {
+        try {
+//            initServiceClients();
+            final String gatewayId = authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
+            final String token = authzToken.getAccessToken();
+            return getUserInfo(gatewayId, token, identityServerRealm);
+        } catch (Exception e) {
+            throw new CustosSecurityException(e);
+        }
+//        } finally {
+//            closeServiceClients();
+//        }
+    }
+
+    private UserInfo getUserInfo(String gatewayId, String token, String identityServerRealm) throws Exception {
+//        GatewayResourceProfile gwrp = registryServiceClient.getGatewayResourceProfile(gatewayId);
+//        String identityServerRealm = gwrp.getIdentityServerTenant();
+        String openIdConnectUrl = getOpenIDConfigurationUrl(identityServerRealm);
+        JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, null));
+        String userInfoEndPoint = openIdConnectConfig.getString("userinfo_endpoint");
+        JSONObject userInfo = new JSONObject(getFromUrl(userInfoEndPoint, token));
+        return new UserInfo()
+                .setSub(userInfo.getString("sub"))
+                .setFullName(userInfo.getString("name"))
+                .setFirstName(userInfo.getString("given_name"))
+                .setLastName(userInfo.getString("family_name"))
+                .setEmailAddress(userInfo.getString("email"))
+                .setUsername(userInfo.getString("preferred_username"));
+    }
+
+//    private GatewayGroupMembership getGatewayGroupMembership(String username, String token, String gatewayId) throws Exception {
+//        validateToken(username, token, gatewayId);
+//        GatewayGroups gatewayGroups = getGatewayGroups(gatewayId);
+//        List<UserGroup> userGroups = sharingRegistryServiceClient.getAllMemberGroupsForUser(gatewayId, username + "@" + gatewayId);
+//        List<String> userGroupIds = userGroups.stream().map(g -> g.getGroupId()).collect(Collectors.toList());
+//        GatewayGroupMembership gatewayGroupMembership = new GatewayGroupMembership();
+//        gatewayGroupMembership.setInAdminsGroup(userGroupIds.contains(gatewayGroups.getAdminsGroupId()));
+//        gatewayGroupMembership.setInReadOnlyAdminsGroup(userGroupIds.contains(gatewayGroups.getReadOnlyAdminsGroupId()));
+//        return gatewayGroupMembership;
+//    }
+
+//    private GatewayGroups getGatewayGroups(String gatewayId) throws Exception {
+//        if (registryServiceClient.isGatewayGroupsExists(gatewayId)) {
+//            return registryServiceClient.getGatewayGroups(gatewayId);
+//        } else {
+//            return GatewayGroupsInitializer.initializeGatewayGroups(gatewayId);
+//        }
+//    }
+
+    private boolean validateToken(String username, String token, String gatewayId, String identityServerRealm) throws Exception {
+        UserInfo userInfo = getUserInfo(gatewayId, token, identityServerRealm);
+        if (!username.equals(userInfo.getUsername())) {
+            throw new CustosSecurityException("Subject name and username for the token doesn't match");
+        }
+        return true;
+    }
+
+//    private String[] getUserRolesFromOAuthToken(String username, String token, String gatewayId) throws Exception {
+//        GatewayResourceProfile gwrp = getRegistryServiceClient().getGatewayResourceProfile(gatewayId);
+//        String identityServerRealm = gwrp.getIdentityServerTenant();
+//        String openIdConnectUrl = getOpenIDConfigurationUrl(identityServerRealm);
+//        JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, token));
+//        String userInfoEndPoint = openIdConnectConfig.getString("userinfo_endpoint");
+//        JSONObject userInfo = new JSONObject(getFromUrl(userInfoEndPoint, token));
+//        if (!username.equals(userInfo.get("preferred_username"))) {
+//            throw new CustosSecurityException("Subject name and username for the token doesn't match");
+//        }
+//        String userId = userInfo.getString("sub");
+//
+//        String userRoleMappingUrl = ServerSettings.getRemoteIDPServiceUrl() + "/admin/realms/"
+//                + identityServerRealm + "/users/"
+//                + userId + "/role-mappings/realm";
+//        JSONArray roleMappings = new JSONArray(getFromUrl(userRoleMappingUrl, getAdminAccessToken(gatewayId)));
+//        String[] roles = new String[roleMappings.length()];
+//        for (int i = 0; i < roleMappings.length(); i++) {
+//            roles[i] = (new JSONObject(roleMappings.get(i).toString())).get("name").toString();
+//        }
+//
+//        return roles;
+//    }
+
+    private String getOpenIDConfigurationUrl(String realm) throws ApplicationSettingsException {
+        return ServerSettings.getRemoteIDPServiceUrl() + "/realms/" + realm + "/.well-known/openid-configuration";
+    }
+
+    private String getFromUrl(String urlToRead, String token) throws Exception {
+        StringBuilder result = new StringBuilder();
+        URL url = new URL(urlToRead);
+        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+        conn.setRequestMethod("GET");
+        conn.setDoInput(true);
+        if (token != null) {
+            String bearerAuth = "Bearer " + token;
+            conn.setRequestProperty("Authorization", bearerAuth);
+        }
+        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+        String line;
+        while ((line = rd.readLine()) != null) {
+            result.append(line);
+        }
+        rd.close();
+        return result.toString();
+    }
+
+//    private String getAdminAccessToken(String gatewayId) throws Exception {
+//        CredentialStoreService.Client csClient = getCredentialStoreServiceClient();
+//        GatewayResourceProfile gwrp = getRegistryServiceClient().getGatewayResourceProfile(gatewayId);
+//        String identityServerRealm = gwrp.getIdentityServerTenant();
+//        String openIdConnectUrl = getOpenIDConfigurationUrl(identityServerRealm);
+//        JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, null));
+//        PasswordCredential credential = csClient.getPasswordCredential(gwrp.getIdentityServerPwdCredToken(), gwrp.getGatewayID());
+//        String username = credential.getLoginUserName();
+//        String password = credential.getPassword();
+//        String urlString = openIdConnectConfig.getString("token_endpoint");
+//        StringBuilder result = new StringBuilder();
+//        URL url = new URL(urlString);
+//        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+//        conn.setRequestMethod("POST");
+//        conn.setDoOutput(true);
+//        String postFields = "client_id=admin-cli&username=" + username + "&password=" + password + "&grant_type=password";
+//        conn.getOutputStream().write(postFields.getBytes());
+//        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+//        String line;
+//        while ((line = rd.readLine()) != null) {
+//            result.append(line);
+//        }
+//        rd.close();
+//        JSONObject tokenInfo = new JSONObject(result.toString());
+//        return tokenInfo.get("access_token").toString();
+//    }
+
+    private String getTokenEndpoint(String gatewayId) throws Exception {
+        String openIdConnectUrl = getOpenIDConfigurationUrl(gatewayId);
+        JSONObject openIdConnectConfig = new JSONObject(getFromUrl(openIdConnectUrl, null));
+        return openIdConnectConfig.getString("token_endpoint");
+    }
+
+    private JSONObject getClientCredentials(String tokenURL, String clientId, String clientSecret) throws ApplicationSettingsException, CustosSecurityException {
+
+        CloseableHttpClient httpClient = HttpClients.createSystem();
+
+        HttpPost httpPost = new HttpPost(tokenURL);
+        String encoded = Base64.getEncoder().encodeToString((clientId+":"+clientSecret).getBytes(StandardCharsets.UTF_8));
+        httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + encoded);
+        List<NameValuePair> formParams = new ArrayList<>();
+        formParams.add(new BasicNameValuePair("grant_type", "client_credentials"));
+        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, Consts.UTF_8);
+        httpPost.setEntity(entity);
+        try {
+            CloseableHttpResponse response = httpClient.execute(httpPost);
+            try {
+                String responseBody = EntityUtils.toString(response.getEntity());
+                JSONObject tokenInfo = new JSONObject(responseBody);
+                return tokenInfo;
+            } finally {
+                response.close();
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } finally {
+            try {
+                httpClient.close();
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+//    private boolean hasPermission(GatewayGroupMembership gatewayGroupMembership, String apiMethod) {
+//
+//        // Note: as a stopgap solution, until all resources are secured with group-based authorization, map the Admins
+//        // and Read Only Admins groups to the corresponding roles
+//        final String role;
+//        if (gatewayGroupMembership.isInAdminsGroup()) {
+//            return true;
+//        } else if (gatewayGroupMembership.isInReadOnlyAdminsGroup()) {
+//            role = "admin-read-only";
+//        } else {
+//            // If not in Admins or Read Only Admins groups, treat as a gateway-user
+//            role = "gateway-user";
+//        }
+//        Pattern pattern = Pattern.compile(this.rolePermissionConfig.get(role));
+//        Matcher matcher = pattern.matcher(apiMethod);
+//        return matcher.matches();
+//    }
+//
+//    private boolean hasPermission(String[] roles, String apiMethod) {
+//        for (int i = 0; i < roles.length; i++) {
+//            String role = roles[i];
+//            if (this.rolePermissionConfig.keySet().contains(role)) {
+//                Pattern pattern = Pattern.compile(this.rolePermissionConfig.get(role));
+//                Matcher matcher = pattern.matcher(apiMethod);
+//                if (matcher.matches())
+//                    return true;
+//            }
+//        }
+//        return false;
+//    }
+//
+//    private void initServiceClients() throws TException, ApplicationSettingsException {
+//        registryServiceClient = getRegistryServiceClient();
+//        sharingRegistryServiceClient = getSharingRegistryServiceClient();
+//    }
+
+//    private void closeServiceClients() {
+//        if (registryServiceClient != null) {
+//            ThriftUtils.close(registryServiceClient);
+//        }
+//        if (sharingRegistryServiceClient != null) {
+//            ThriftUtils.close(sharingRegistryServiceClient);
+//        }
+//    }
+
+//    private RegistryService.Client getRegistryServiceClient() throws TException, ApplicationSettingsException {
+//        final int serverPort = Integer.parseInt(ServerSettings.getRegistryServerPort());
+//        final String serverHost = ServerSettings.getRegistryServerHost();
+//        try {
+//            return RegistryServiceClientFactory.createRegistryClient(serverHost, serverPort);
+//        } catch (RegistryServiceException e) {
+//            throw new TException("Unable to create registry client...", e);
+//        }
+//    }
+//
+//    private CredentialStoreService.Client getCredentialStoreServiceClient() throws TException, ApplicationSettingsException {
+//        final int serverPort = Integer.parseInt(ServerSettings.getCredentialStoreServerPort());
+//        final String serverHost = ServerSettings.getCredentialStoreServerHost();
+//        try {
+//            return CredentialStoreClientFactory.createAiravataCSClient(serverHost, serverPort);
+//        } catch (CredentialStoreException e) {
+//            throw new TException("Unable to create credential store client...", e);
+//        }
+//    }
+//
+//    private SharingRegistryService.Client getSharingRegistryServiceClient() throws TException, ApplicationSettingsException {
+//        final int serverPort = Integer.parseInt(ServerSettings.getSharingRegistryPort());
+//        final String serverHost = ServerSettings.getSharingRegistryHost();
+//        try {
+//            return SharingRegistryServiceClientFactory.createSharingRegistryClient(serverHost, serverPort);
+//        } catch (SharingRegistryException e) {
+//            throw new TException("Unable to create sharing registry client...", e);
+//        }
+//    }
+
+//    public static void main(String[] args) throws CustosSecurityException, ApplicationSettingsException {
+//        ServerSettings.setSetting("trust.store", "./modules/configuration/server/src/main/resources/client_truststore.jks");
+//        ServerSettings.setSetting("trust.store.password", "airavata");
+//        KeyCloakSecurityManager keyCloakSecurityManager = new KeyCloakSecurityManager();
+//        final String tokenURL = "...";
+//        final String clientId = "...";
+//        final String clientSecret = "...";
+//        JSONObject jsonObject = keyCloakSecurityManager.getClientCredentials(tokenURL, clientId, clientSecret);
+//        System.out.println("access_token=" + jsonObject.getString("access_token"));
+//    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/SecurityManagerFactory.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/SecurityManagerFactory.java
new file mode 100644
index 0000000..42f0af1
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/SecurityManagerFactory.java
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.custos.security.manager;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This initializes an instance of the appropriate security manager according to the
+ * configuration.
+ */
+public class SecurityManagerFactory {
+    private final static Logger logger = LoggerFactory.getLogger(SecurityManagerFactory.class);
+
+    public static CustosSecurityManager getSecurityManager() throws CustosSecurityException {
+        try {
+            Class secManagerImpl = Class.forName(ServerSettings.getSecurityManagerClassName());
+            CustosSecurityManager securityManager = (CustosSecurityManager) secManagerImpl.newInstance();
+            return securityManager;
+        } catch (ClassNotFoundException e) {
+            String error = "Security Manager class could not be found.";
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException(error);
+        } catch (ApplicationSettingsException e) {
+            String error = "Error in reading the configuration related to Security Manager class.";
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException(error);
+        } catch (InstantiationException e) {
+            String error = "Error in instantiating the Security Manager class.";
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException(error);
+        } catch (IllegalAccessException e) {
+            String error = "Error in instantiating the Security Manager class.";
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException(error);
+
+        }
+    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/UserInfo.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/UserInfo.java
new file mode 100644
index 0000000..4687748
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/manager/UserInfo.java
@@ -0,0 +1,84 @@
+/*
+ * 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.custos.security.manager;
+
+public class UserInfo {
+    private String sub;
+    private String firstName;
+    private String lastName;
+    private String fullName;
+    private String emailAddress;
+    private String username;
+
+    public String getSub() {
+        return sub;
+    }
+
+    public UserInfo setSub(String sub) {
+        this.sub = sub;
+        return this;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public UserInfo setFirstName(String firstName) {
+        this.firstName = firstName;
+        return this;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public UserInfo setLastName(String lastName) {
+        this.lastName = lastName;
+        return this;
+    }
+
+    public String getFullName() {
+        return fullName;
+    }
+
+    public UserInfo setFullName(String fullName) {
+        this.fullName = fullName;
+        return this;
+    }
+
+    public String getEmailAddress() {
+        return emailAddress;
+    }
+
+    public UserInfo setEmailAddress(String emailAddress) {
+        this.emailAddress = emailAddress;
+        return this;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public UserInfo setUsername(String username) {
+        this.username = username;
+        return this;
+    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/model/AuthzToken.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/model/AuthzToken.java
new file mode 100644
index 0000000..448df68
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/model/AuthzToken.java
@@ -0,0 +1,541 @@
+/**
+ * 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.10.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.security.model;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
+public class AuthzToken implements org.apache.thrift.TBase<AuthzToken, AuthzToken._Fields>, java.io.Serializable, Cloneable, Comparable<AuthzToken> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AuthzToken");
+
+  private static final org.apache.thrift.protocol.TField ACCESS_TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("accessToken", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField CLAIMS_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("claimsMap", org.apache.thrift.protocol.TType.MAP, (short)2);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new AuthzTokenStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new AuthzTokenTupleSchemeFactory();
+
+  private String accessToken; // required
+  private java.util.Map<String, String> claimsMap; // optional
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    ACCESS_TOKEN((short)1, "accessToken"),
+    CLAIMS_MAP((short)2, "claimsMap");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.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: // ACCESS_TOKEN
+          return ACCESS_TOKEN;
+        case 2: // CLAIMS_MAP
+          return CLAIMS_MAP;
+        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
+  private static final _Fields optionals[] = {_Fields.CLAIMS_MAP};
+  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.ACCESS_TOKEN, new org.apache.thrift.meta_data.FieldMetaData("accessToken", org.apache.thrift.TFieldRequirementType.REQUIRED,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.CLAIMS_MAP, new org.apache.thrift.meta_data.FieldMetaData("claimsMap", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
+            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AuthzToken.class, metaDataMap);
+  }
+
+  public AuthzToken() {
+  }
+
+  public AuthzToken(
+    String accessToken)
+  {
+    this();
+    this.accessToken = accessToken;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public AuthzToken(AuthzToken other) {
+    if (other.isSetAccessToken()) {
+      this.accessToken = other.accessToken;
+    }
+    if (other.isSetClaimsMap()) {
+      java.util.Map<String, String> __this__claimsMap = new java.util.HashMap<String, String>(other.claimsMap);
+      this.claimsMap = __this__claimsMap;
+    }
+  }
+
+  public AuthzToken deepCopy() {
+    return new AuthzToken(this);
+  }
+
+  @Override
+  public void clear() {
+    this.accessToken = null;
+    this.claimsMap = null;
+  }
+
+  public String getAccessToken() {
+    return this.accessToken;
+  }
+
+  public void setAccessToken(String accessToken) {
+    this.accessToken = accessToken;
+  }
+
+  public void unsetAccessToken() {
+    this.accessToken = null;
+  }
+
+  /** Returns true if field accessToken is set (has been assigned a value) and false otherwise */
+  public boolean isSetAccessToken() {
+    return this.accessToken != null;
+  }
+
+  public void setAccessTokenIsSet(boolean value) {
+    if (!value) {
+      this.accessToken = null;
+    }
+  }
+
+  public int getClaimsMapSize() {
+    return (this.claimsMap == null) ? 0 : this.claimsMap.size();
+  }
+
+  public void putToClaimsMap(String key, String val) {
+    if (this.claimsMap == null) {
+      this.claimsMap = new java.util.HashMap<String, String>();
+    }
+    this.claimsMap.put(key, val);
+  }
+
+  public java.util.Map<String, String> getClaimsMap() {
+    return this.claimsMap;
+  }
+
+  public void setClaimsMap(java.util.Map<String, String> claimsMap) {
+    this.claimsMap = claimsMap;
+  }
+
+  public void unsetClaimsMap() {
+    this.claimsMap = null;
+  }
+
+  /** Returns true if field claimsMap is set (has been assigned a value) and false otherwise */
+  public boolean isSetClaimsMap() {
+    return this.claimsMap != null;
+  }
+
+  public void setClaimsMapIsSet(boolean value) {
+    if (!value) {
+      this.claimsMap = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case ACCESS_TOKEN:
+      if (value == null) {
+        unsetAccessToken();
+      } else {
+        setAccessToken((String)value);
+      }
+      break;
+
+    case CLAIMS_MAP:
+      if (value == null) {
+        unsetClaimsMap();
+      } else {
+        setClaimsMap((java.util.Map<String, String>)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case ACCESS_TOKEN:
+      return getAccessToken();
+
+    case CLAIMS_MAP:
+      return getClaimsMap();
+
+    }
+    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 ACCESS_TOKEN:
+      return isSetAccessToken();
+    case CLAIMS_MAP:
+      return isSetClaimsMap();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof AuthzToken)
+      return this.equals((AuthzToken)that);
+    return false;
+  }
+
+  public boolean equals(AuthzToken that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    boolean this_present_accessToken = true && this.isSetAccessToken();
+    boolean that_present_accessToken = true && that.isSetAccessToken();
+    if (this_present_accessToken || that_present_accessToken) {
+      if (!(this_present_accessToken && that_present_accessToken))
+        return false;
+      if (!this.accessToken.equals(that.accessToken))
+        return false;
+    }
+
+    boolean this_present_claimsMap = true && this.isSetClaimsMap();
+    boolean that_present_claimsMap = true && that.isSetClaimsMap();
+    if (this_present_claimsMap || that_present_claimsMap) {
+      if (!(this_present_claimsMap && that_present_claimsMap))
+        return false;
+      if (!this.claimsMap.equals(that.claimsMap))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetAccessToken()) ? 131071 : 524287);
+    if (isSetAccessToken())
+      hashCode = hashCode * 8191 + accessToken.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetClaimsMap()) ? 131071 : 524287);
+    if (isSetClaimsMap())
+      hashCode = hashCode * 8191 + claimsMap.hashCode();
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(AuthzToken other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetAccessToken()).compareTo(other.isSetAccessToken());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetAccessToken()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.accessToken, other.accessToken);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetClaimsMap()).compareTo(other.isSetClaimsMap());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetClaimsMap()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.claimsMap, other.claimsMap);
+      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 {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("AuthzToken(");
+    boolean first = true;
+
+    sb.append("accessToken:");
+    if (this.accessToken == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.accessToken);
+    }
+    first = false;
+    if (isSetClaimsMap()) {
+      if (!first) sb.append(", ");
+      sb.append("claimsMap:");
+      if (this.claimsMap == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.claimsMap);
+      }
+      first = false;
+    }
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetAccessToken()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'accessToken' is unset! Struct:" + toString());
+    }
+
+    // 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 AuthzTokenStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public AuthzTokenStandardScheme getScheme() {
+      return new AuthzTokenStandardScheme();
+    }
+  }
+
+  private static class AuthzTokenStandardScheme extends org.apache.thrift.scheme.StandardScheme<AuthzToken> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, AuthzToken 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: // ACCESS_TOKEN
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.accessToken = iprot.readString();
+              struct.setAccessTokenIsSet(true);
+            } else {
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 2: // CLAIMS_MAP
+            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
+              {
+                org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin();
+                struct.claimsMap = new java.util.HashMap<String, String>(2*_map0.size);
+                String _key1;
+                String _val2;
+                for (int _i3 = 0; _i3 < _map0.size; ++_i3)
+                {
+                  _key1 = iprot.readString();
+                  _val2 = iprot.readString();
+                  struct.claimsMap.put(_key1, _val2);
+                }
+                iprot.readMapEnd();
+              }
+              struct.setClaimsMapIsSet(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();
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, AuthzToken struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.accessToken != null) {
+        oprot.writeFieldBegin(ACCESS_TOKEN_FIELD_DESC);
+        oprot.writeString(struct.accessToken);
+        oprot.writeFieldEnd();
+      }
+      if (struct.claimsMap != null) {
+        if (struct.isSetClaimsMap()) {
+          oprot.writeFieldBegin(CLAIMS_MAP_FIELD_DESC);
+          {
+            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.claimsMap.size()));
+            for (java.util.Map.Entry<String, String> _iter4 : struct.claimsMap.entrySet())
+            {
+              oprot.writeString(_iter4.getKey());
+              oprot.writeString(_iter4.getValue());
+            }
+            oprot.writeMapEnd();
+          }
+          oprot.writeFieldEnd();
+        }
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class AuthzTokenTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public AuthzTokenTupleScheme getScheme() {
+      return new AuthzTokenTupleScheme();
+    }
+  }
+
+  private static class AuthzTokenTupleScheme extends org.apache.thrift.scheme.TupleScheme<AuthzToken> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, AuthzToken struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      oprot.writeString(struct.accessToken);
+      java.util.BitSet optionals = new java.util.BitSet();
+      if (struct.isSetClaimsMap()) {
+        optionals.set(0);
+      }
+      oprot.writeBitSet(optionals, 1);
+      if (struct.isSetClaimsMap()) {
+        {
+          oprot.writeI32(struct.claimsMap.size());
+          for (java.util.Map.Entry<String, String> _iter5 : struct.claimsMap.entrySet())
+          {
+            oprot.writeString(_iter5.getKey());
+            oprot.writeString(_iter5.getValue());
+          }
+        }
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, AuthzToken struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      struct.accessToken = iprot.readString();
+      struct.setAccessTokenIsSet(true);
+      java.util.BitSet incoming = iprot.readBitSet(1);
+      if (incoming.get(0)) {
+        {
+          org.apache.thrift.protocol.TMap _map6 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
+          struct.claimsMap = new java.util.HashMap<String, String>(2*_map6.size);
+          String _key7;
+          String _val8;
+          for (int _i9 = 0; _i9 < _map6.size; ++_i9)
+          {
+            _key7 = iprot.readString();
+            _val8 = iprot.readString();
+            struct.claimsMap.put(_key7, _val8);
+          }
+        }
+        struct.setClaimsMapIsSet(true);
+      }
+    }
+  }
+
+  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+  }
+}
+
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/oauth/DefaultOAuthClient.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/oauth/DefaultOAuthClient.java
new file mode 100644
index 0000000..505b489
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/oauth/DefaultOAuthClient.java
@@ -0,0 +1,91 @@
+/*
+ *
+ * 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.custos.security.oauth;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub;
+import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO;
+import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken;
+import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import java.rmi.RemoteException;
+
+/**
+ * This is the default OAuth Client that talks to WSO2 IS's OAuth Authentication Server
+ * to get the OAuth token validated.
+ */
+public class DefaultOAuthClient {
+
+    private OAuth2TokenValidationServiceStub stub;
+    private final static Logger logger = LoggerFactory.getLogger(DefaultOAuthClient.class);
+    public static final String BEARER_TOKEN_TYPE = "bearer";
+
+    /**
+     * OAuth2TokenValidationService Admin Service Client
+     *
+     * @param auhorizationServerURL
+     * @param username
+     * @param password
+     * @param configCtx
+     * @throws Exception
+     */
+    public DefaultOAuthClient(String auhorizationServerURL, String username, String password,
+                              ConfigurationContext configCtx) throws CustosSecurityException {
+        try {
+            String serviceURL = auhorizationServerURL + "OAuth2TokenValidationService";
+            stub = new OAuth2TokenValidationServiceStub(configCtx, serviceURL);
+            CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, stub._getServiceClient());
+        } catch (AxisFault e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error initializing OAuth client.");
+        }
+    }
+
+    /**
+     * Validates the OAuth 2.0 access token
+     *
+     * @param accessToken
+     * @return
+     * @throws Exception
+     */
+    public OAuth2TokenValidationResponseDTO validateAccessToken(String accessToken)
+            throws CustosSecurityException {
+
+        try {
+            OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO();
+            OAuth2TokenValidationRequestDTO_OAuth2AccessToken token =
+                    new OAuth2TokenValidationRequestDTO_OAuth2AccessToken();
+            token.setIdentifier(accessToken);
+            token.setTokenType(BEARER_TOKEN_TYPE);
+            oauthReq.setAccessToken(token);
+            return stub.validate(oauthReq);
+        } catch (RemoteException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in validating the OAuth access token.");
+        }
+    }
+
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/service/SecurityServiceHandler.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/service/SecurityServiceHandler.java
new file mode 100644
index 0000000..058ed87
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/service/SecurityServiceHandler.java
@@ -0,0 +1,30 @@
+package org.apache.custos.security.service;
+
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.model.error.AuthorizationException;
+import org.apache.custos.security.manager.CustosSecurityManager;
+import org.apache.custos.security.manager.SecurityManagerFactory;
+import org.apache.custos.security.model.AuthzToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+public class SecurityServiceHandler {
+
+    private final static Logger logger = LoggerFactory.getLogger(SecurityServiceHandler.class);
+
+    public boolean authorize(AuthzToken authzToken, Map<String, String> metaData) throws AuthorizationException {
+        try {
+            CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
+            boolean isAuthz = securityManager.isUserAuthorized(authzToken, metaData);
+            if (!isAuthz) {
+                throw new AuthorizationException("User is not authenticated or authorized.");
+            }
+        } catch (CustosSecurityException e) {
+            logger.error(e.getMessage(), e);
+            throw new AuthorizationException("Error in authenticating or authorizing user.");
+        }
+        return true;
+    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/utils/TrustStoreManager.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/utils/TrustStoreManager.java
new file mode 100644
index 0000000..4477207
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/utils/TrustStoreManager.java
@@ -0,0 +1,100 @@
+/**
+ *
+ * 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.custos.security.utils;
+
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.utils.SecurityUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import java.io.*;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+
+public class TrustStoreManager {
+    private final static Logger logger = LoggerFactory.getLogger(TrustStoreManager.class);
+    public SSLContext initializeTrustStoreManager(String trustStorePath, String trustStorePassword)
+            throws CustosSecurityException {
+        try {
+            // load and initialize the trust store
+
+            File trustStoreFile = new File(trustStorePath);
+            InputStream is;
+            if (trustStoreFile.exists()) {
+                logger.debug("Loading trust store file from path " + trustStorePath);
+                is = new FileInputStream(trustStorePath);
+            } else {
+                logger.debug("Trying to load trust store file form class path " + trustStorePath);
+                is = SecurityUtil.class.getClassLoader().getResourceAsStream(trustStorePath);
+                if (is != null) {
+                    logger.debug("Trust store file was loaded form class path " + trustStorePath);
+                }
+            }
+
+            if (is == null) {
+                throw new CustosSecurityException("Could not find a trust store file in path " + trustStorePath);
+            }
+
+            KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+
+            char[] trustPassword = trustStorePassword.toCharArray();
+
+            trustStore.load(is, trustPassword);
+
+            // initialize a trust manager factory
+            TrustManagerFactory trustFactory =
+                    TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+            trustFactory.init(trustStore);
+
+            // get the trust managers from the factory
+            TrustManager[] trustManagers = trustFactory.getTrustManagers();
+
+            // initialize an ssl context to use these managers and set as default
+            SSLContext sslContext = SSLContext.getInstance("SSL");
+            sslContext.init(null, trustManagers, null);
+            SSLContext.setDefault(sslContext);
+            return sslContext;
+        } catch (CertificateException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in initializing the trust store.");
+        } catch (NoSuchAlgorithmException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in initializing the trust store.");
+        } catch (KeyStoreException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in initializing the trust store.");
+        } catch (KeyManagementException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in initializing the trust store.");
+        } catch (FileNotFoundException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in initializing the trust store.");
+        } catch (IOException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in initializing the trust store.");
+        }
+    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/xacml/DefaultPAPClient.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/xacml/DefaultPAPClient.java
new file mode 100644
index 0000000..c76c301
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/xacml/DefaultPAPClient.java
@@ -0,0 +1,124 @@
+/*
+ *
+ * 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.custos.security.xacml;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.wso2.carbon.identity.entitlement.common.EntitlementConstants;
+import org.wso2.carbon.identity.entitlement.stub.EntitlementPolicyAdminServiceEntitlementException;
+import org.wso2.carbon.identity.entitlement.stub.EntitlementPolicyAdminServiceStub;
+import org.wso2.carbon.identity.entitlement.stub.dto.PaginatedStatusHolder;
+import org.wso2.carbon.identity.entitlement.stub.dto.PolicyDTO;
+import org.wso2.carbon.identity.entitlement.stub.dto.StatusHolder;
+import org.wso2.carbon.utils.CarbonUtils;
+import java.rmi.RemoteException;
+
+/**
+ * This publishes the airavata-default-xacml-policy.xml to the PDP via PAP API (of WSO2 Identity Server)
+ */
+public class DefaultPAPClient {
+
+    private final static Logger logger = LoggerFactory.getLogger(DefaultPAPClient.class);
+    private EntitlementPolicyAdminServiceStub entitlementPolicyAdminServiceStub;
+
+    public DefaultPAPClient(String auhorizationServerURL, String username, String password,
+                            ConfigurationContext configCtx) throws CustosSecurityException {
+        try {
+
+            String PDPURL = auhorizationServerURL + "EntitlementPolicyAdminService";
+            entitlementPolicyAdminServiceStub = new EntitlementPolicyAdminServiceStub(configCtx, PDPURL);
+            CarbonUtils.setBasicAccessSecurityHeaders(username, password, true,
+                    entitlementPolicyAdminServiceStub._getServiceClient());
+        } catch (AxisFault e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error initializing XACML PEP client.");
+        }
+
+    }
+
+    public boolean isPolicyAdded(String policyName) {
+        try {
+            PolicyDTO policyDTO = entitlementPolicyAdminServiceStub.getPolicy(policyName, false);
+        } catch (RemoteException e) {
+            logger.debug("Error in retrieving the policy.", e);
+            return false;
+        } catch (EntitlementPolicyAdminServiceEntitlementException e) {
+            logger.debug("Error in retrieving the policy.", e);
+            return false;
+        }
+        return true;
+    }
+
+    public void addPolicy(String policy) throws CustosSecurityException {
+        new Thread() {
+            public void run() {
+                try {
+                    PolicyDTO policyDTO = new PolicyDTO();
+                    policyDTO.setPolicy(policy);
+                    entitlementPolicyAdminServiceStub.addPolicy(policyDTO);
+                    entitlementPolicyAdminServiceStub.publishToPDP(new String[]{ServerSettings.getAuthorizationPoliyName()},
+                            EntitlementConstants.PolicyPublish.ACTION_CREATE, null, false, 0);
+
+                    //Since policy publishing happens asynchronously, we need to retrieve the status and verify.
+                    Thread.sleep(2000);
+                    PaginatedStatusHolder paginatedStatusHolder = entitlementPolicyAdminServiceStub.
+                            getStatusData(EntitlementConstants.Status.ABOUT_POLICY, ServerSettings.getAuthorizationPoliyName(),
+                                    EntitlementConstants.StatusTypes.PUBLISH_POLICY, "*", 1);
+                    StatusHolder statusHolder = paginatedStatusHolder.getStatusHolders()[0];
+                    if (statusHolder.getSuccess() && EntitlementConstants.PolicyPublish.ACTION_CREATE.equals(statusHolder.getTargetAction())) {
+                        logger.info("Authorization policy is published successfully.");
+                    } else {
+                        throw new CustosSecurityException("Failed to publish the authorization policy.");
+                    }
+
+                    //enable the published policy
+                    entitlementPolicyAdminServiceStub.enableDisablePolicy(ServerSettings.getAuthorizationPoliyName(), true);
+                    //Since policy enabling happens asynchronously, we need to retrieve the status and verify.
+                    Thread.sleep(2000);
+                    paginatedStatusHolder = entitlementPolicyAdminServiceStub.
+                            getStatusData(EntitlementConstants.Status.ABOUT_POLICY, ServerSettings.getAuthorizationPoliyName(),
+                                    EntitlementConstants.StatusTypes.PUBLISH_POLICY, "*", 1);
+                    statusHolder = paginatedStatusHolder.getStatusHolders()[0];
+                    if (statusHolder.getSuccess() && EntitlementConstants.PolicyPublish.ACTION_ENABLE.equals(statusHolder.getTargetAction())) {
+                        logger.info("Authorization policy is enabled successfully.");
+                    } else {
+                        throw new CustosSecurityException("Failed to enable the authorization policy.");
+                    }
+                } catch (RemoteException e) {
+                    logger.error(e.getMessage(), e);
+                } catch (InterruptedException e) {
+                    logger.error(e.getMessage(), e);
+                } catch (ApplicationSettingsException e) {
+                    logger.error(e.getMessage(), e);
+                } catch (CustosSecurityException e) {
+                    logger.error(e.getMessage(), e);
+                } catch (EntitlementPolicyAdminServiceEntitlementException e) {
+                    logger.error(e.getMessage(), e);
+                }
+            }
+        }.start();
+    }
+}
diff --git a/custos-services/custos-security-service/src/main/java/org/apache/custos/security/xacml/DefaultXACMLPEP.java b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/xacml/DefaultXACMLPEP.java
new file mode 100644
index 0000000..741ffcc
--- /dev/null
+++ b/custos-services/custos-security-service/src/main/java/org/apache/custos/security/xacml/DefaultXACMLPEP.java
@@ -0,0 +1,133 @@
+/*
+ *
+ * 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.custos.security.xacml;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.custos.commons.exceptions.CustosSecurityException;
+import org.apache.custos.commons.utils.Constants;
+import org.apache.custos.security.model.AuthzToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.wso2.carbon.identity.entitlement.stub.EntitlementServiceException;
+import org.wso2.carbon.identity.entitlement.stub.EntitlementServiceStub;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.rmi.RemoteException;
+import java.util.Map;
+
+/**
+ * This enforces XACML based fine grained authorization on the API calls, by authorizing the API calls
+ * through default PDP which is WSO2 Identity Server.
+ */
+public class DefaultXACMLPEP {
+
+    private final static Logger logger = LoggerFactory.getLogger(DefaultXACMLPEP.class);
+    private EntitlementServiceStub entitlementServiceStub;
+
+    public DefaultXACMLPEP(String auhorizationServerURL, String username, String password,
+                           ConfigurationContext configCtx) throws CustosSecurityException {
+        try {
+
+            String PDPURL = auhorizationServerURL + "EntitlementService";
+            entitlementServiceStub = new EntitlementServiceStub(configCtx, PDPURL);
+            CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, entitlementServiceStub._getServiceClient());
+        } catch (AxisFault e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error initializing XACML PEP client.");
+        }
+
+    }
+
+    /**
+     * Send the XACML authorization request to XAML PDP and return the authorization decision.
+     *
+     * @param authzToken
+     * @param metaData
+     * @return
+     */
+    public boolean getAuthorizationDecision(AuthzToken authzToken, Map<String, String> metaData) throws CustosSecurityException {
+        String decision;
+        try {
+            String subject = authzToken.getClaimsMap().get(Constants.USER_NAME);
+            //FIXME hacky way to fix OpenID -> CILogon issue in WSO2 IS
+            if(subject.startsWith("http://")){
+                subject = subject.substring(6);
+            }
+            String action = "/airavata/" + metaData.get(Constants.API_METHOD_NAME);
+            String decisionString = entitlementServiceStub.getDecisionByAttributes(subject, null, action, null);
+            //parse the XML decision string and obtain the decision
+            decision = parseDecisionString(decisionString);
+            if (Constants.PERMIT.equals(decision)) {
+                return true;
+            } else {
+                logger.error("Authorization decision is: " + decision);
+                return false;
+            }
+        } catch (RemoteException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in authorizing the user.");
+        } catch (EntitlementServiceException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in authorizing the user.");
+        }
+    }
+
+    /**
+     * This parses the XML based authorization response by the PDP and returns the decision string.
+     *
+     * @param decisionString
+     * @return
+     * @throws CustosSecurityException
+     */
+    private String parseDecisionString(String decisionString) throws CustosSecurityException {
+        try {
+            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+            InputStream inputStream = new ByteArrayInputStream(decisionString.getBytes("UTF-8"));
+            Document doc = docBuilderFactory.newDocumentBuilder().parse(inputStream);
+            Node resultNode = doc.getDocumentElement().getFirstChild();
+            Node decisionNode = resultNode.getFirstChild();
+            String decision = decisionNode.getTextContent();
+            return decision;
+        } catch (ParserConfigurationException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in parsing XACML authorization response.");
+        } catch (UnsupportedEncodingException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in parsing XACML authorization response.");
+        } catch (SAXException e) {
+            logger.error(e.getMessage(), e);
+            throw new CustosSecurityException("Error in parsing XACML authorization response.");
+        } catch (IOException e) {
+            logger.error("Error in parsing XACML authorization response.");
+            throw new CustosSecurityException("Error in parsing XACML authorization response.");
+        }
+    }
+}
diff --git a/custos-services/pom.xml b/custos-services/pom.xml
new file mode 100644
index 0000000..d0e8239
--- /dev/null
+++ b/custos-services/pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>custos</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>custos-services</artifactId>
+    <packaging>pom</packaging>
+    <name>Custos Services</name>
+
+    <modules>
+        <module>profile-service</module>
+        <module>custos-security-service</module>
+    </modules>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <openjpa.version>2.4.3</openjpa.version>
+    </properties>
+</project>
\ No newline at end of file
diff --git a/custos-services/profile-service/iam-admin-services-core/pom.xml b/custos-services/profile-service/iam-admin-services-core/pom.xml
new file mode 100644
index 0000000..bc2a6d0
--- /dev/null
+++ b/custos-services/profile-service/iam-admin-services-core/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>8</source>
+                    <target>8</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <parent>
+        <groupId>org.apache.custos</groupId>
+        <artifactId>profile-service</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    
+    <artifactId>iam-admin-services-core</artifactId>
+    <name>Iam Admin Services</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>3.1</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.2</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api -->
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+            <version>2.0.1</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-client -->
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-client</artifactId>
+            <version>3.0.14.Final</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jackson2-provider -->
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jackson2-provider</artifactId>
+            <version>3.0.14.Final</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.5.4</version>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/org.keycloak/keycloak-admin-client -->
+        <dependency>
+            <groupId>org.keycloak</groupId>
+            <artifactId>keycloak-admin-client</artifactId>
+            <version>2.5.5.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>profile-service-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-commons</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>profile-service-models</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+    
+</project>
\ No newline at end of file
diff --git a/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java b/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
new file mode 100644
index 0000000..bab92a2
--- /dev/null
+++ b/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/impl/TenantManagementKeycloakImpl.java
@@ -0,0 +1,821 @@
+/*
+ *
+ * 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.custos.service.profile.iam.admin.services.core.impl;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.utils.SecurityUtil;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.apache.custos.profile.models.tenant.PasswordCredential;
+import org.apache.custos.profile.models.user.Status;
+import org.apache.custos.profile.models.user.UserProfile;
+import org.apache.custos.profile.models.workspace.Gateway;
+import org.apache.custos.service.profile.iam.admin.services.core.interfaces.TenantManagementInterface;
+import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.jboss.resteasy.client.jaxrs.ResteasyClient;
+import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
+import org.keycloak.admin.client.Keycloak;
+import org.keycloak.admin.client.KeycloakBuilder;
+import org.keycloak.admin.client.resource.RoleResource;
+import org.keycloak.admin.client.resource.UserResource;
+import org.keycloak.representations.idm.ClientRepresentation;
+import org.keycloak.representations.idm.CredentialRepresentation;
+import org.keycloak.representations.idm.RealmRepresentation;
+import org.keycloak.representations.idm.RoleRepresentation;
+import org.keycloak.representations.idm.RolesRepresentation;
+import org.keycloak.representations.idm.UserRepresentation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.KeyStore;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class TenantManagementKeycloakImpl implements TenantManagementInterface {
+
+    private final static Logger logger = LoggerFactory.getLogger(TenantManagementKeycloakImpl.class);
+
+    private String superAdminRealmId = "master";
+
+    private static Keycloak getClient(String adminUrl, String realm, PasswordCredential AdminPasswordCreds) {
+
+        ResteasyClient resteasyClient = new ResteasyClientBuilder()
+                .connectionPoolSize(10)
+                .trustStore(loadKeyStore())
+                .build();
+        return KeycloakBuilder.builder()
+                .serverUrl(adminUrl)
+                .realm(realm)
+                .username(AdminPasswordCreds.getLoginUserName())
+                .password(AdminPasswordCreds.getPassword())
+                .clientId("admin-cli")
+                .resteasyClient(resteasyClient)
+                .build();
+    }
+
+    private static Keycloak getClient(String adminUrl, String realm, String accessToken) {
+
+        ResteasyClient resteasyClient = new ResteasyClientBuilder()
+                .connectionPoolSize(10)
+                .trustStore(loadKeyStore())
+                .build();
+        return KeycloakBuilder.builder()
+                .serverUrl(adminUrl)
+                .realm(realm)
+                .authorization(accessToken)
+                .resteasyClient(resteasyClient)
+                .build();
+    }
+
+    private static KeyStore loadKeyStore() {
+
+        InputStream is = null;
+        try {
+
+            String trustStorePath =  ServerSettings.getTrustStorePath();
+            File trustStoreFile = new File(trustStorePath);
+
+            if (trustStoreFile.exists()) {
+                logger.debug("Loading trust store file from path " + trustStorePath);
+                is = new FileInputStream(trustStorePath);
+            } else {
+                logger.debug("Trying to load trust store file form class path " + trustStorePath);
+                is = SecurityUtil.class.getClassLoader().getResourceAsStream(trustStorePath);
+                if (is != null) {
+                    logger.debug("Trust store file was loaded form class path " + trustStorePath);
+                }
+            }
+
+            if (is == null) {
+                throw new RuntimeException("Could not find a trust store file in path " + trustStorePath);
+            }
+
+            KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+            ks.load(is, ServerSettings.getTrustStorePassword().toCharArray());
+            return ks;
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to load trust store KeyStore instance", e);
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    logger.error("Failed to close trust store FileInputStream", e);
+                }
+            }
+        }
+    }
+
+    @Override
+    public Gateway addTenant(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException {
+        Keycloak client = null;
+        try {
+            // get client
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), this.superAdminRealmId, isSuperAdminPasswordCreds);
+            // create realm
+            RealmRepresentation newRealmDetails = new RealmRepresentation();
+            newRealmDetails.setEnabled(true);
+            newRealmDetails.setId(gatewayDetails.getGatewayId());
+            newRealmDetails.setDisplayName(gatewayDetails.getGatewayName());
+            newRealmDetails.setRealm(gatewayDetails.getGatewayId());
+            // Following two settings allow duplicate email addresses
+            newRealmDetails.setLoginWithEmailAllowed(false);
+            newRealmDetails.setDuplicateEmailsAllowed(true);
+            // Default access token lifespan to 30 minutes, SSO session idle to 60 minutes
+            newRealmDetails.setAccessTokenLifespan(1800);
+            newRealmDetails.setSsoSessionIdleTimeout(3600);
+            RealmRepresentation realmWithRoles = TenantManagementKeycloakImpl.createDefaultRoles(newRealmDetails);
+            client.realms().create(realmWithRoles);
+            return gatewayDetails;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting Iam server Url from property file, reason: " + ex.getMessage());
+            throw exception;
+        } catch (Exception ex){
+            logger.error("Error creating Realm in Keycloak Server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error creating Realm in Keycloak Server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    public static RealmRepresentation createDefaultRoles(RealmRepresentation realmDetails){
+        List<RoleRepresentation> defaultRoles = new ArrayList<RoleRepresentation>();
+        RoleRepresentation adminRole = new RoleRepresentation();
+        adminRole.setName("admin");
+        adminRole.setDescription("Admin role for PGA users");
+        defaultRoles.add(adminRole);
+        RoleRepresentation adminReadOnlyRole = new RoleRepresentation();
+        adminReadOnlyRole.setName("admin-read-only");
+        adminReadOnlyRole.setDescription("Read only role for PGA Admin users");
+        defaultRoles.add(adminReadOnlyRole);
+        RoleRepresentation gatewayUserRole = new RoleRepresentation();
+        gatewayUserRole.setName("gateway-user");
+        gatewayUserRole.setDescription("default role for PGA users");
+        defaultRoles.add(gatewayUserRole);
+        RoleRepresentation pendingUserRole = new RoleRepresentation();
+        pendingUserRole.setName("user-pending");
+        pendingUserRole.setDescription("role for newly registered PGA users");
+        defaultRoles.add(pendingUserRole);
+        RoleRepresentation gatewayProviderRole = new RoleRepresentation();
+        gatewayProviderRole.setName("gateway-provider");
+        gatewayProviderRole.setDescription("role for gateway providers in the super-admin PGA");
+        defaultRoles.add(gatewayProviderRole);
+        RolesRepresentation rolesRepresentation = new RolesRepresentation();
+        rolesRepresentation.setRealm(defaultRoles);
+        realmDetails.setRoles(rolesRepresentation);
+        return realmDetails;
+    }
+
+    @Override
+    public boolean createTenantAdminAccount(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails, String tenantAdminPassword) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), this.superAdminRealmId, isSuperAdminPasswordCreds);
+            UserRepresentation user = new UserRepresentation();
+            user.setUsername(gatewayDetails.getIdentityServerUserName());
+            user.setFirstName(gatewayDetails.getGatewayAdminFirstName());
+            user.setLastName(gatewayDetails.getGatewayAdminLastName());
+            user.setEmail(gatewayDetails.getGatewayAdminEmail());
+            user.setEmailVerified(true);
+            user.setEnabled(true);
+            Response httpResponse = client.realm(gatewayDetails.getGatewayId()).users().create(user);
+            logger.info("Tenant Admin account creation exited with code : " + httpResponse.getStatus()+" : " +httpResponse.getStatusInfo());
+            if (httpResponse.getStatus() == 201) { //HTTP code for record creation: HTTP 201
+                List<UserRepresentation> retrieveCreatedUserList = client.realm(gatewayDetails.getGatewayId()).users().search(user.getUsername(),
+                        user.getFirstName(),
+                        user.getLastName(),
+                        user.getEmail(),
+                        0, 1);
+                UserResource retrievedUser = client.realm(gatewayDetails.getGatewayId()).users().get(retrieveCreatedUserList.get(0).getId());
+
+                // Add user to the "admin" role
+                RoleResource adminRoleResource = client.realm(gatewayDetails.getGatewayId()).roles().get("admin");
+                retrievedUser.roles().realmLevel().add(Arrays.asList(adminRoleResource.toRepresentation()));
+
+                CredentialRepresentation credential = new CredentialRepresentation();
+                credential.setType(CredentialRepresentation.PASSWORD);
+                credential.setValue(tenantAdminPassword);
+                credential.setTemporary(false);
+                retrievedUser.resetPassword(credential);
+                List<ClientRepresentation> realmClients = client.realm(gatewayDetails.getGatewayId()).clients().findAll();
+                String realmManagementClientId=getRealmManagementClientId(client, gatewayDetails.getGatewayId());
+                for(ClientRepresentation realmClient : realmClients){
+                    if(realmClient.getClientId().equals("realm-management")){
+                        realmManagementClientId = realmClient.getId();
+                    }
+                }
+                retrievedUser.roles().clientLevel(realmManagementClientId).add(retrievedUser.roles().clientLevel(realmManagementClientId).listAvailable());
+                return true;
+            } else {
+                logger.error("Request for Tenant Admin Account Creation failed with HTTP code : " + httpResponse.getStatus());
+                logger.error("Reason for Tenant Admin account creation failure : " + httpResponse.getStatusInfo());
+                return false;
+            }
+        }catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        }catch (Exception ex){
+            logger.error("Error creating Realm Admin Account in keycloak server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error creating Realm Admin Account in keycloak server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public Gateway configureClient(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), this.superAdminRealmId, isSuperAdminPasswordCreds);
+            ClientRepresentation pgaClient = new ClientRepresentation();
+            pgaClient.setName("pga");
+            pgaClient.setClientId("pga");
+            pgaClient.setProtocol("openid-connect");
+            pgaClient.setStandardFlowEnabled(true);
+            pgaClient.setEnabled(true);
+            pgaClient.setAuthorizationServicesEnabled(true);
+            pgaClient.setDirectAccessGrantsEnabled(true);
+            pgaClient.setServiceAccountsEnabled(true);
+            pgaClient.setFullScopeAllowed(true);
+            pgaClient.setClientAuthenticatorType("client-secret");
+            List<String> redirectUris = new ArrayList<>();
+            if(gatewayDetails.getGatewayURL()!=null){
+                String gatewayURL = gatewayDetails.getGatewayURL();
+                // Remove trailing slash from gatewayURL
+                if(gatewayURL.endsWith("/")) {
+                    gatewayURL = gatewayURL.substring(0, gatewayURL.length() - 1);
+                }
+                // Add redirect URL after login
+                redirectUris.add(gatewayURL + "/callback-url"); // PGA
+                redirectUris.add(gatewayURL + "/auth/callback*"); // Django
+                // Add redirect URL after logout
+                redirectUris.add(gatewayURL);
+            } else {
+                logger.error("Request for Realm Client Creation failed, callback URL not present");
+                IamAdminServicesException ex = new IamAdminServicesException();
+                ex.setMessage("Gateway Url field in GatewayProfile cannot be empty, Realm Client creation failed");
+                throw ex;
+            }
+            pgaClient.setRedirectUris(redirectUris);
+            pgaClient.setPublicClient(false);
+            Response httpResponse = client.realms().realm(gatewayDetails.getGatewayId()).clients().create(pgaClient);
+            logger.info("Tenant Client configuration exited with code : " + httpResponse.getStatus()+" : " +httpResponse.getStatusInfo());
+
+            // Add the manage-users role to the web client
+            UserRepresentation serviceAccountUserRepresentation = getUserByUsername(client, gatewayDetails.getGatewayId(), "service-account-" + pgaClient.getClientId());
+            UserResource serviceAccountUser = client.realms().realm(gatewayDetails.getGatewayId()).users().get(serviceAccountUserRepresentation.getId());
+            String realmManagementClientId = getRealmManagementClientId(client, gatewayDetails.getGatewayId());
+            List<RoleRepresentation> manageUsersRole = serviceAccountUser.roles().clientLevel(realmManagementClientId).listAvailable()
+                    .stream()
+                    .filter(r -> r.getName().equals("manage-users"))
+                    .collect(Collectors.toList());
+            serviceAccountUser.roles().clientLevel(realmManagementClientId).add(manageUsersRole);
+
+            if(httpResponse.getStatus() == 201){
+                String ClientUUID = client.realms().realm(gatewayDetails.getGatewayId()).clients().findByClientId(pgaClient.getClientId()).get(0).getId();
+                CredentialRepresentation clientSecret = client.realms().realm(gatewayDetails.getGatewayId()).clients().get(ClientUUID).getSecret();
+                gatewayDetails.setOauthClientId(pgaClient.getClientId());
+                gatewayDetails.setOauthClientSecret(clientSecret.getValue());
+                return gatewayDetails;
+            } else {
+                logger.error("Request for Realm Client Creation failed with HTTP code : " + httpResponse.getStatus());
+                logger.error("Reason for Realm Client Creation failure : " + httpResponse.getStatusInfo());
+                return null;
+            }
+        }catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    private static String getRealmManagementClientId(Keycloak client, String realmId) {
+        List<ClientRepresentation> realmClients = client.realm(realmId).clients().findAll();
+        String realmManagementClientId=null;
+        for(ClientRepresentation realmClient : realmClients){
+            if(realmClient.getClientId().equals("realm-management")){
+                realmManagementClientId = realmClient.getId();
+            }
+        }
+        return realmManagementClientId;
+    }
+
+    @Override
+    public boolean isUsernameAvailable(String accessToken, String tenantId, String username) throws IamAdminServicesException {
+        Keycloak client = null;
+        try {
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            return userRepresentation == null;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean createUser(String accessToken, String tenantId, String username, String emailAddress, String firstName, String lastName, String newPassword) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation user = new UserRepresentation();
+            user.setUsername(username);
+            user.setFirstName(firstName);
+            user.setLastName(lastName);
+            user.setEmail(emailAddress);
+            user.setEnabled(false);
+            Response httpResponse = client.realm(tenantId).users().create(user);
+            if (httpResponse.getStatus() == 201) { //HTTP code for record creation: HTTP 201
+                List<UserRepresentation> retrieveCreatedUserList = client.realm(tenantId).users().search(user.getUsername(),
+                        user.getFirstName(),
+                        user.getLastName(),
+                        user.getEmail(),
+                        0, 1);
+                UserResource retrievedUser = client.realm(tenantId).users().get(retrieveCreatedUserList.get(0).getId());
+                CredentialRepresentation credential = new CredentialRepresentation();
+                credential.setType(CredentialRepresentation.PASSWORD);
+                credential.setValue(newPassword);
+                credential.setTemporary(false);
+                retrievedUser.resetPassword(credential);
+                return true;
+            } else {
+                logger.error("Request for user Account Creation failed with HTTP code : " + httpResponse.getStatus());
+                logger.error("Reason for user account creation failure : " + httpResponse.getStatusInfo());
+                return false;
+            }
+        }catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean enableUserAccount(String accessToken, String tenantId, String username) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            UserResource userResource = client.realm(tenantId).users().get(userRepresentation.getId());
+            UserRepresentation profile = userResource.toRepresentation();
+            profile.setEnabled(true);
+            // We require that a user verify their email before enabling the account
+            profile.setEmailVerified(true);
+            userResource.update(profile);
+            return true;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isUserAccountEnabled(String accessToken, String tenantId, String username) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            return userRepresentation != null && userRepresentation.isEnabled();
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean isUserExist(String accessToken, String tenantId, String username) throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            return userRepresentation != null;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public UserProfile getUser(String accessToken, String tenantId, String username) throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            return userRepresentation != null ? convertUserRepresentationToUserProfile(userRepresentation, tenantId) : null;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public List<UserProfile> getUsers(String accessToken, String tenantId, int offset, int limit, String search)
+            throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            List<UserRepresentation> userRepresentationList = client.realm(tenantId).users().search(search, offset, limit);
+            return userRepresentationList.stream().map(ur -> convertUserRepresentationToUserProfile(ur, tenantId))
+                    .collect(Collectors.toList());
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean resetUserPassword(String accessToken, String tenantId, String username, String newPassword) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            if(userRepresentation != null)
+            {
+                UserResource retrievedUser = client.realm(tenantId).users().get(userRepresentation.getId());
+                CredentialRepresentation credential = new CredentialRepresentation();
+                credential.setType(CredentialRepresentation.PASSWORD);
+                credential.setValue(newPassword);
+                credential.setTemporary(false);
+                retrievedUser.resetPassword(credential);
+                // Remove the UPDATE_PASSWORD required action
+                userRepresentation = retrievedUser.toRepresentation();
+                userRepresentation.getRequiredActions().remove("UPDATE_PASSWORD");
+                retrievedUser.update(userRepresentation);
+                return true;
+            }else{
+                logger.error("requested User not found");
+                return false;
+            }
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } catch (Exception ex){
+            logger.error("Error resetting user password in keycloak server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error resetting user password in keycloak server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public List<UserProfile> findUser(String accessToken, String tenantId, String email, String userName) throws IamAdminServicesException{
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            List<UserRepresentation> retrieveUserList = client.realm(tenantId).users().search(userName,
+                    null,
+                    null,
+                    email,
+                    0, 1);
+            if(!retrieveUserList.isEmpty())
+            {
+                List<UserProfile> userList = new ArrayList<>();
+                for(UserRepresentation user : retrieveUserList){
+                    UserProfile profile = new UserProfile();
+                    profile.setUserId(user.getUsername());
+                    profile.setFirstName(user.getFirstName());
+                    profile.setLastName(user.getLastName());
+                    profile.setEmails(Arrays.asList(new String[]{user.getEmail()}));
+                    userList.add(profile);
+                }
+                return userList;
+            }else{
+                logger.error("requested User not found");
+                return null;
+            }
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } catch (Exception ex){
+            logger.error("Error finding user in keycloak server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error finding user in keycloak server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public void updateUserProfile(String accessToken, String tenantId, String username, UserProfile userDetails) throws IamAdminServicesException {
+
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, accessToken);
+            UserRepresentation userRepresentation = getUserByUsername(client, tenantId, username);
+            if(userRepresentation != null)
+            {
+                userRepresentation.setFirstName(userDetails.getFirstName());
+                userRepresentation.setLastName(userDetails.getLastName());
+                userRepresentation.setEmail(userDetails.getEmails().get(0));
+                UserResource userResource = client.realm(tenantId).users().get(userRepresentation.getId());
+                userResource.update(userRepresentation);
+            }else{
+                throw new IamAdminServicesException("User [" + username + "] wasn't found in Keycloak!");
+            }
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } catch (Exception ex){
+            logger.error("Error updating user profile in keycloak server, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error updating user profile in keycloak server, reason: " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean addRoleToUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException {
+
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
+            List<UserRepresentation> retrieveCreatedUserList = client.realm(tenantId).users().search(username,
+                    null,
+                    null,
+                    null,
+                    0, 1);
+            UserResource retrievedUser = client.realm(tenantId).users().get(retrieveCreatedUserList.get(0).getId());
+
+            // Add user to the role
+            RoleResource roleResource = client.realm(tenantId).roles().get(roleName);
+            retrievedUser.roles().realmLevel().add(Arrays.asList(roleResource.toRepresentation()));
+            return true;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    @Override
+    public boolean removeRoleFromUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException {
+
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
+            List<UserRepresentation> retrieveCreatedUserList = client.realm(tenantId).users().search(username,
+                    null,
+                    null,
+                    null,
+                    0, 1);
+            UserResource retrievedUser = client.realm(tenantId).users().get(retrieveCreatedUserList.get(0).getId());
+
+            // Remove role from user
+            RoleResource roleResource = client.realm(tenantId).roles().get(roleName);
+            retrievedUser.roles().realmLevel().remove(Arrays.asList(roleResource.toRepresentation()));
+            return true;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                client.close();
+            }
+        }
+    }
+
+    // TODO: this is needed for migrating from roles to group-based auth but after migration we can remove this
+    @Override
+    public List<UserProfile> getUsersWithRole(PasswordCredential realmAdminCreds, String tenantId, String roleName) throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
+            // FIXME: this only searches through the most recent 100 users for the given role (assuming there are no more than 10,000 users in the gateway)
+            int totalUserCount = client.realm(tenantId).users().count();
+            logger.debug("getUsersWithRole: totalUserCount=" + totalUserCount);
+            // Load all users in batches
+            List<UserRepresentation> allUsers = new ArrayList<>();
+            int userBatchSize = 100;
+            for (int start = 0; start < totalUserCount; start=start+userBatchSize) {
+
+                logger.debug("getUsersWithRole: fetching " + userBatchSize + " users...");
+                allUsers.addAll(client.realm(tenantId).users().search(null,
+                        null,
+                        null,
+                        null,
+                        start, userBatchSize));
+            }
+            logger.debug("getUsersWithRole: all users count=" + allUsers.size());
+            allUsers.sort((a, b) -> a.getCreatedTimestamp() - b.getCreatedTimestamp() > 0 ? -1 : 1);
+            // The 100 most recently created users
+            List<UserRepresentation> mostRecentUsers = allUsers.subList(0, Math.min(allUsers.size(), 100));
+            logger.debug("getUsersWithRole: most recent users count=" + mostRecentUsers.size());
+
+            List<UserProfile> usersWithRole = new ArrayList<>();
+            for (UserRepresentation user: mostRecentUsers) {
+                UserResource userResource = client.realm(tenantId).users().get(user.getId());
+
+                List<RoleRepresentation> roleRepresentations = userResource.roles().realmLevel().listAll();
+                for (RoleRepresentation roleRepresentation : roleRepresentations){
+                    if (roleRepresentation.getName().equals(roleName)) {
+                        usersWithRole.add(convertUserRepresentationToUserProfile(user, tenantId));
+                        break;
+                    }
+                }
+            }
+            logger.debug("getUsersWithRole: most recent users with role count=" + usersWithRole.size());
+            return usersWithRole;
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                logger.debug("getUsersWithRole: closing client...");
+                client.close();
+                logger.debug("getUsersWithRole: client closed");
+            }
+        }
+    }
+
+    public List<String> getUserRoles(PasswordCredential realmAdminCreds, String tenantId, String username) throws IamAdminServicesException {
+        Keycloak client = null;
+        try{
+            client = TenantManagementKeycloakImpl.getClient(ServerSettings.getIamServerUrl(), tenantId, realmAdminCreds);
+            List<UserRepresentation> userRepresentationList = client.realm(tenantId).users().search(username,
+                    null,
+                    null,
+                    null,
+                    0, 1);
+            if (userRepresentationList.isEmpty()) {
+                logger.warn("No Keycloak user found for username [" + username + "] in tenant [" + tenantId + "].");
+                return null;
+            }
+            UserResource retrievedUser = client.realm(tenantId).users().get(userRepresentationList.get(0).getId());
+            return retrievedUser.roles().realmLevel().listAll()
+                    .stream()
+                    .map(roleRepresentation -> roleRepresentation.getName())
+                    .collect(Collectors.toList());
+        } catch (ApplicationSettingsException ex) {
+            logger.error("Error getting values from property file, reason: " + ex.getMessage(), ex);
+            IamAdminServicesException exception = new IamAdminServicesException();
+            exception.setMessage("Error getting values from property file, reason " + ex.getMessage());
+            throw exception;
+        } finally {
+            if (client != null) {
+                logger.debug("getUserRoles: closing client...");
+                client.close();
+                logger.debug("getUserRoles: client closed");
+            }
+        }
+    }
+
+    private UserProfile convertUserRepresentationToUserProfile(UserRepresentation userRepresentation, String tenantId) {
+
+        UserProfile profile = new UserProfile();
+        profile.setAiravataInternalUserId(userRepresentation.getUsername() + "@" + tenantId);
+        profile.setGatewayId(tenantId);
+        profile.setUserId(userRepresentation.getUsername());
+        profile.setFirstName(userRepresentation.getFirstName());
+        profile.setLastName(userRepresentation.getLastName());
+        profile.setEmails(Arrays.asList(new String[]{userRepresentation.getEmail()}));
+        profile.setCreationTime(userRepresentation.getCreatedTimestamp());
+
+        // Just default these. UserProfile isn't a great data model for this data since it isn't actually the Airavata UserProfile
+        profile.setLastAccessTime(0);
+        profile.setValidUntil(0);
+        // Use state field to indicate whether user has been enabled or email verified in Keycloak
+        if (userRepresentation.isEnabled()) {
+            profile.setState(Status.ACTIVE);
+        } else if (userRepresentation.isEmailVerified()) {
+            profile.setState(Status.CONFIRMED);
+        } else {
+            profile.setState(Status.PENDING_CONFIRMATION);
+        }
+
+        return profile;
+    }
+
+    private static UserRepresentation getUserByUsername(Keycloak client, String tenantId, String username) {
+
+        // Searching for users by username returns also partial matches, so need to filter down to an exact match if it exists
+        List<UserRepresentation> userResourceList = client.realm(tenantId).users().search(
+                username, null, null, null, null, null);
+        for (UserRepresentation userRepresentation : userResourceList) {
+            if (userRepresentation.getUsername().equals(username)) {
+                return userRepresentation;
+            }
+        }
+        return null;
+    }
+
+    public static void main(String[] args) throws IamAdminServicesException, ApplicationSettingsException {
+        TenantManagementKeycloakImpl tenantManagementKeycloak = new TenantManagementKeycloakImpl();
+        ServerSettings.setSetting("trust.store", "./modules/configuration/server/src/main/resources/client_truststore.jks");
+        ServerSettings.setSetting("trust.store.password", "airavata");
+        ServerSettings.setSetting("iam.server.url", "");
+        String accessToken = "";
+        String tenantId = "";
+        String username = "";
+        boolean isUsernameAvailable = tenantManagementKeycloak.isUsernameAvailable(accessToken, tenantId, username);
+        System.out.println("Username " + username + " is " + (isUsernameAvailable ? "": "NOT ") + "available");
+    }
+}
diff --git a/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java b/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java
new file mode 100644
index 0000000..d809ad2
--- /dev/null
+++ b/custos-services/profile-service/iam-admin-services-core/src/main/java/org/apache/custos/service/profile/iam/admin/services/core/interfaces/TenantManagementInterface.java
@@ -0,0 +1,206 @@
+/*
+ *
+ * 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.custos.service.profile.iam.admin.services.core.interfaces;
+
+import org.apache.custos.profile.models.tenant.PasswordCredential;
+import org.apache.custos.profile.models.user.UserProfile;
+import org.apache.custos.profile.models.workspace.Gateway;
+import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+
+import java.util.List;
+
+public interface TenantManagementInterface {
+
+    /**
+     * Method to add Identity server tenant for Airavata gateway creation.
+     *
+     * @param isSuperAdminPasswordCreds identity server super admin credentials
+     * @param gatewayDetails gateway details from workspace catalog
+     * @return Gateway object.
+     */
+    Gateway addTenant(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException;
+
+    /**
+     * Method to add tenant Admin account in Identity Server.
+     *
+     * @param isSuperAdminPasswordCreds identity server super admin credentials
+     * @param gatewayDetails gateway details from workspace catalog
+     * @param gatewayAdminPassword password to use when creating tenant admin account
+     * @return Gateway object.
+     */
+    boolean createTenantAdminAccount(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails, String gatewayAdminPassword) throws IamAdminServicesException;
+
+    /**
+     * Method to configure application client in Identity Server
+     *
+     * @param isSuperAdminPasswordCreds identity server super admin credentials
+     * @param gatewayDetails gateway details from workspace catalog
+     * @return Gateway object.
+     */
+    Gateway configureClient(PasswordCredential isSuperAdminPasswordCreds, Gateway gatewayDetails) throws IamAdminServicesException;
+
+    /**
+     * Check if username is available to be used for creating a new user account.
+     * @param accessToken needs to have access to searching across users by username
+     * @param tenantId
+     * @param username
+     * @return
+     */
+    boolean isUsernameAvailable(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Method to create user in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @param emailAddress
+     * @param firstName
+     * @param lastName
+     * @param newPassword
+     * @return true if user created
+     * @throws IamAdminServicesException
+     */
+    boolean createUser(String accessToken, String tenantId, String username, String emailAddress, String firstName, String lastName, String newPassword) throws IamAdminServicesException;
+
+    /**
+     * Method to enable user in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @return boolean.
+     */
+    boolean enableUserAccount(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Method to check if user is enabled in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @return boolean.
+     */
+    boolean isUserAccountEnabled(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Return whether user exists with username.
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @return
+     */
+    boolean isUserExist(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Get user profile information from Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @return
+     */
+    UserProfile getUser(String accessToken, String tenantId, String username) throws IamAdminServicesException;
+
+    /**
+     * Get a paginated list of user profiles from Identity Server
+     * 
+     * @param accessToken
+     * @param tenantId
+     * @param offset
+     * @param limit
+     * @param search String - optional, if specified used to search user profiles
+     * @return
+     * @throws IamAdminServicesException
+     */
+    List<UserProfile> getUsers(String accessToken, String tenantId, int offset, int limit, String search) throws IamAdminServicesException;
+
+    /**
+     * Method to reset user password in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @param newPassword
+     * @return boolean
+     */
+    boolean resetUserPassword(String accessToken, String tenantId, String username, String newPassword) throws IamAdminServicesException;
+
+    /**
+     * Method to find user in Identity Server
+     *
+     * @param accessToken
+     * @param tenantId required
+     * @param email required
+     * @param username can be null
+     * @return Gateway object.
+     */
+    List<UserProfile> findUser(String accessToken, String tenantId, String email, String username) throws IamAdminServicesException;
+
+    /**
+     * Update the user's profile in the Identity Server
+     * @param accessToken
+     * @param tenantId
+     * @param username
+     * @param userDetails
+     */
+    void updateUserProfile(String accessToken, String tenantId, String username, UserProfile userDetails) throws IamAdminServicesException;
+
+    /**
+     * Add the given role to the user.
+     *
+     * @param realmAdminCreds
+     * @param tenantId
+     * @param username
+     * @param roleName
+     * @return
+     * @throws IamAdminServicesException
+     */
+    @Deprecated
+    boolean addRoleToUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException;
+
+    /**
+     * Remove the given role from the user.
+     *
+     * @param realmAdminCreds
+     * @param tenantId
+     * @param username
+     * @param roleName
+     * @return
+     * @throws IamAdminServicesException
+     */
+    @Deprecated
+    boolean removeRoleFromUser(PasswordCredential realmAdminCreds, String tenantId, String username, String roleName) throws IamAdminServicesException;
+
+    /**
+     * Get all users having the given role.
+     *
+     * @param realmAdminCreds
+     * @param tenantId
+     * @param roleName
+     * @return
+     * @throws IamAdminServicesException
+     */
+    @Deprecated
+    List<UserProfile> getUsersWithRole(PasswordCredential realmAdminCreds, String tenantId, String roleName) throws IamAdminServicesException;
+}
diff --git a/custos-services/profile-service/iam-admin-services-core/src/test/java/org/apache/custos/service/profile/iam/admin/services/core/tests/SetupNewGateway.java b/custos-services/profile-service/iam-admin-services-core/src/test/java/org/apache/custos/service/profile/iam/admin/services/core/tests/SetupNewGateway.java
new file mode 100644
index 0000000..387ed1c
--- /dev/null
+++ b/custos-services/profile-service/iam-admin-services-core/src/test/java/org/apache/custos/service/profile/iam/admin/services/core/tests/SetupNewGateway.java
@@ -0,0 +1,141 @@
+package org.apache.custos.service.profile.iam.admin.services.core.tests;
+
+import org.apache.custos.profile.models.tenant.PasswordCredential;
+import org.apache.custos.profile.models.user.UserProfile;
+import org.apache.custos.profile.models.workspace.Gateway;
+import org.apache.custos.service.profile.iam.admin.services.core.impl.TenantManagementKeycloakImpl;
+import org.apache.custos.service.profile.iam.admin.services.cpi.exception.IamAdminServicesException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SetupNewGateway {
+
+    private final static Logger logger = LoggerFactory.getLogger(SetupNewGateway.class);
+
+    public static void main(String[] args) {
+        findUser();
+//        final PasswordCredential tenantAdminCreds = createTenantAdminCreds("tenant", "admin", "admin-password");
+//        getUserRoles(tenantAdminCreds, "username");
+    }
+
+    public static void setUpGateway(){
+        Gateway testGateway = new Gateway();
+        testGateway.setGatewayId("maven.test.gateway");
+        testGateway.setGatewayName("maven test gateway");
+        testGateway.setIdentityServerUserName("mavenTest");
+        testGateway.setGatewayAdminFirstName("Maven");
+        testGateway.setGatewayAdminLastName("Test");
+        testGateway.setGatewayAdminEmail("some.man@gmail.com");
+        PasswordCredential superAdminCreds = new PasswordCredential();
+        superAdminCreds.setGatewayId(testGateway.getGatewayId());
+        superAdminCreds.setDescription("test credentials for IS admin creation");
+        superAdminCreds.setLoginUserName("airavataAdmin");
+        superAdminCreds.setPassword("Airavata@123");
+        superAdminCreds.setPortalUserName("superAdmin");
+        TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
+        try {
+            client.addTenant(superAdminCreds, testGateway);
+            if (!client.createTenantAdminAccount(superAdminCreds, testGateway, "Test@123")) {
+                logger.error("Admin account creation failed !!, please refer error logs for reason");
+            }
+            Gateway gatewayWithIdAndSecret = client.configureClient(superAdminCreds, testGateway);
+            System.out.println(gatewayWithIdAndSecret.getOauthClientId());
+            System.out.println(gatewayWithIdAndSecret.getOauthClientSecret());
+        } catch (IamAdminServicesException ex) {
+            logger.error("Gateway Setup Failed, reason: " + ex.getCause(), ex);
+        }
+    }
+     public static void UserRegistration(){
+         UserProfile user = new UserProfile();
+         user.setUserId("testuser");
+         user.setFirstName("test-firstname");
+         user.setLastName("test-lastname");
+         List<String> emails = new ArrayList<>();
+         emails.add("some.man@outlook.com");
+         user.setGatewayId("maven.test.gateway");
+         user.setEmails(emails);
+        PasswordCredential tenantAdminCreds = new PasswordCredential();
+         tenantAdminCreds.setGatewayId(user.getGatewayId());
+         tenantAdminCreds.setDescription("test credentials for tenant admin creation");
+         tenantAdminCreds.setLoginUserName("mavenTest");
+         tenantAdminCreds.setPassword("Test@1234");
+         tenantAdminCreds.setPortalUserName("TenantAdmin");
+
+         TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
+         try {
+             // FIXME: get an access token from tenant admin creds
+             String accessToken = "";
+             client.createUser(accessToken, user.getGatewayId(), user.getUserId(), user.getEmails().get(0), user.getFirstName(), user.getLastName(),"test@123");
+             client.enableUserAccount(accessToken, user.getGatewayId(), user.getUserId());
+         } catch (IamAdminServicesException e) {
+             e.printStackTrace();
+         }
+     }
+
+//     public static void resetPassword(){
+//         UserProfile user = new UserProfile();
+//         user.setUserId("testuser");
+//         List<String> emails = new ArrayList<>();
+//         emails.add("some.man@outlook.com");
+//         user.setGatewayId("maven.test.gateway");
+//         user.setEmails(emails);
+//         TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
+//         try {
+//             PasswordCredential tenantAdminCreds = new PasswordCredential();
+//             tenantAdminCreds.setGatewayId(user.getGatewayId());
+//             tenantAdminCreds.setDescription("test credentials for tenant admin creation");
+//             tenantAdminCreds.setLoginUserName("mavenTest");
+//             tenantAdminCreds.setPassword("Test@1234");
+//             tenantAdminCreds.setPortalUserName("TenantAdmin");
+//             client.resetUserPassword(tenantAdminCreds,user,"test@123");
+//         } catch (IamAdminServicesException e) {
+//             e.printStackTrace();
+//         }
+//     }
+
+     public static void findUser(){
+         UserProfile user = new UserProfile();
+
+         List<String> emails = new ArrayList<>();
+         emails.add("some.man@outlook.com");
+         user.setGatewayId("maven.test.gateway");
+         user.setEmails(emails);
+         TenantManagementKeycloakImpl client = new TenantManagementKeycloakImpl();
+         try {
+             PasswordCredential tenantAdminCreds = new PasswordCredential();
+             tenantAdminCreds.setGatewayId(user.getGatewayId());
+             tenantAdminCreds.setDescription("test credentials for tenant admin creation");
+             tenantAdminCreds.setLoginUserName("mavenTest");
+             tenantAdminCreds.setPassword("Test@1234");
+             tenantAdminCreds.setPortalUserName("TenantAdmin");
+             // FIXME: get an access token from tenant admin creds
+             String accessToken = "";
+             List<UserProfile> list = client.findUser(accessToken,"maven.test.gateway","some.man@outlook.com",null);
+             System.out.println(list.get(0).getUserId());
+         } catch (IamAdminServicesException e) {
+             e.printStackTrace();
+         }
+     }
+
+     public static void getUserRoles(PasswordCredential tenantAdminCreds, String username) {
+         TenantManagementKeycloakImpl keycloakClient = new TenantManagementKeycloakImpl();
+
+         try {
+             List<String> roleNames = keycloakClient.getUserRoles(tenantAdminCreds, tenantAdminCreds.getGatewayId(), username);
+             System.out.println("Roles=" + roleNames);
+         } catch (IamAdminServicesException e) {
+             e.printStackTrace();
+         }
+     }
+
+    private static PasswordCredential createTenantAdminCreds(String tenantId, String username, String password) {
+        PasswordCredential tenantAdminCreds = new PasswordCredential();
+        tenantAdminCreds.setGatewayId(tenantId);
+        tenantAdminCreds.setLoginUserName(username);
+        tenantAdminCreds.setPassword(password);
+        return tenantAdminCreds;
+    }
+}
diff --git a/custos-services/profile-service/pom.xml b/custos-services/profile-service/pom.xml
new file mode 100644
index 0000000..64056a6
--- /dev/null
+++ b/custos-services/profile-service/pom.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>custos-services</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>profile-service</artifactId>
+    <packaging>pom</packaging>
+    <name>profile-service</name>
+    <modules>
+        <module>iam-admin-services-core</module>
+        <module>profile-tenant-core</module>
+        <module>profile-user-core</module>
+        <module>profile-service-server</module>
+        <module>profile-service-commons</module>
+        <module>profile-service-client-sdks</module>
+        <module>profile-service-stubs</module>
+        <module>profile-service-models</module>
+    </modules>
+</project>
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-client-sdks/java-client-samples/pom.xml b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/pom.xml
new file mode 100644
index 0000000..01d0bee
--- /dev/null
+++ b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/pom.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <artifactId>profile-service-client-sdks</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <name>Profile Service Client Samples</name>
+    <artifactId>profile-service-client-samples</artifactId>
+    <packaging>jar</packaging>
+    <url>http://airavata.apache.org/</url>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>profile-service-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/samples/GroupManagerSample.java b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/samples/GroupManagerSample.java
new file mode 100644
index 0000000..4d108e4
--- /dev/null
+++ b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/samples/GroupManagerSample.java
@@ -0,0 +1,41 @@
+package org.apache.custos.service.profile.client.samples;
+
+import org.apache.airavata.common.utils.Constants;
+import org.apache.airavata.model.security.AuthzToken;
+import org.apache.custos.service.profile.client.ProfileServiceClientFactory;
+import org.apache.custos.service.profile.groupmanager.cpi.GroupManagerService;
+import org.apache.custos.service.profile.client.util.ProfileServiceClientUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GroupManagerSample {
+
+    private static final Logger logger = LoggerFactory.getLogger(UserProfileSample.class);
+    private static GroupManagerService.Client groupMangerClient;
+    private static String testGatewayId = "test-gateway-465";
+    private static AuthzToken authzToken = new AuthzToken("empy_token");
+
+    public static void main(String args[]) throws Exception {
+        try {
+            String profileServiceServerHost = ProfileServiceClientUtil.getProfileServiceServerHost();
+            int profileServiceServerPort = ProfileServiceClientUtil.getProfileServiceServerPort();
+
+            groupMangerClient = ProfileServiceClientFactory.createGroupManagerServiceClient(profileServiceServerHost, profileServiceServerPort);
+            Map<String, String> claimsMap = new HashMap<>();
+            claimsMap.put(Constants.GATEWAY_ID,testGatewayId);
+            authzToken.setClaimsMap(claimsMap);
+
+            //NOTE: Only these two methods can be tested as other methods require us to create a group.
+            // createGroup() needs createUser() to be executed. Currently ownerId is set from createUser()
+            // method which requires a sharingServiceClient. Hence, verifying only this method for now.
+            System.out.println("hasAdminAccess() should return [false]: "+ groupMangerClient.hasAdminAccess(authzToken,"test-group-1", "test-user-1"));
+        }
+        catch (Exception ex) {
+            ex.printStackTrace();
+            logger.error("GroupManager client-sample Exception: " + ex, ex);
+        }
+    }
+}
diff --git a/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/samples/TenantProfileSample.java b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/samples/TenantProfileSample.java
new file mode 100644
index 0000000..da4ed19
--- /dev/null
+++ b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/samples/TenantProfileSample.java
@@ -0,0 +1,61 @@
+package org.apache.custos.service.profile.client.samples;
+
+import org.apache.airavata.model.security.AuthzToken;
+import org.apache.airavata.model.workspace.Gateway;
+import org.apache.airavata.model.workspace.GatewayApprovalStatus;
+import org.apache.custos.service.profile.client.ProfileServiceClientFactory;
+import org.apache.custos.service.profile.tenant.cpi.TenantProfileService;
+import org.apache.custos.service.profile.client.util.ProfileServiceClientUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * Created by goshenoy on 3/30/17.
+ */
+public class TenantProfileSample {
+    private static final Logger logger = LoggerFactory.getLogger(TenantProfileSample.class);
+    private static TenantProfileService.Client tenantProfileClient;
+    private static String testGatewayId = null;
+    private static AuthzToken authzToken = new AuthzToken("empy_token");
+
+    public static void main(String[] args) throws Exception {
+        try {
+            String profileServiceServerHost = ProfileServiceClientUtil.getProfileServiceServerHost();
+            int profileServiceServerPort = ProfileServiceClientUtil.getProfileServiceServerPort();
+
+            tenantProfileClient = ProfileServiceClientFactory.createTenantProfileServiceClient(profileServiceServerHost, profileServiceServerPort);
+
+            // test addGateway
+            testGatewayId = tenantProfileClient.addGateway(authzToken, getGateway("465"));
+            assert (testGatewayId != null) : "Gateway creation failed!";
+            System.out.println("Gateway created with gatewayId: " + testGatewayId);
+
+
+        } catch (Exception ex) {
+            logger.error("TenantProfile client-sample Exception: " + ex, ex);
+        }
+    }
+
+    private static Gateway getGateway(String gatewayId) {
+        // get random value for userId
+        int gatewayIdValue = ThreadLocalRandom.current().nextInt(1000);
+
+        if (gatewayId != null) {
+            gatewayIdValue = Integer.parseInt(gatewayId.replaceAll("test-gateway-", ""));
+        }
+
+        Gateway gateway = new Gateway();
+        gateway.setGatewayId("test-gateway-" + gatewayIdValue);
+        gateway.setGatewayApprovalStatus(GatewayApprovalStatus.APPROVED);
+        gateway.setGatewayName("test-gateway-name");
+        gateway.setDomain("test-gateway-domain");
+        gateway.setEmailAddress("test-gateway-" + gatewayIdValue + "@domain.com");
+        gateway.setGatewayURL("test-gateway-" + gatewayIdValue + ".domain.com");
+        gateway.setGatewayAdminFirstName("test-gateway-admin-fname");
+        gateway.setGatewayAdminLastName("test-gateway-admin-lname");
+        gateway.setGatewayAdminEmail("test-gateway-admin@email.domain.com");
+        return gateway;
+    }
+}
diff --git a/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/samples/UserProfileSample.java b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/samples/UserProfileSample.java
new file mode 100644
index 0000000..b6d9b59
--- /dev/null
+++ b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/samples/UserProfileSample.java
@@ -0,0 +1,121 @@
+package org.apache.custos.service.profile.client.samples;
+
+import org.apache.airavata.model.security.AuthzToken;
+import org.apache.airavata.model.user.*;
+import org.apache.custos.service.profile.client.ProfileServiceClientFactory;
+import org.apache.custos.service.profile.user.cpi.UserProfileService;
+import org.apache.custos.service.profile.client.util.ProfileServiceClientUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * Created by goshenoy on 3/23/17.
+ */
+public class UserProfileSample {
+
+    private static final Logger logger = LoggerFactory.getLogger(UserProfileSample.class);
+    private static UserProfileService.Client userProfileClient;
+    private static String testUserId = null;
+    private static String testGatewayId = "test-gateway-465";
+    private static AuthzToken authzToken = new AuthzToken("empy_token");
+
+    /**
+     * Performs the following operations in sequence:
+     *  1. create new user
+     *  2. find user created
+     *  3. update created user's name
+     *  4. find all users in gateway
+     *  5. find created user by name
+     *  6. delete created user
+     *  7. check if user exists
+     * @param args
+     * @throws Exception
+     */
+    public static void main(String[] args) throws Exception {
+        try {
+            String profileServiceServerHost = ProfileServiceClientUtil.getProfileServiceServerHost();
+            int profileServiceServerPort = ProfileServiceClientUtil.getProfileServiceServerPort();
+
+            userProfileClient = ProfileServiceClientFactory.createUserProfileServiceClient(profileServiceServerHost, profileServiceServerPort);
+
+            // test add-user-profile
+            testUserId = userProfileClient.addUserProfile(authzToken, getUserProfile(null));
+            assert (testUserId != null) : "User creation failed. Null userId returned!";
+            System.out.println("User created with userId: " + testUserId);
+
+            // test find-user-profile
+            UserProfile userProfile = userProfileClient.getUserProfileById(authzToken, testUserId, testGatewayId);
+            assert (userProfile != null) : "Could not find user with userId: " + testUserId + ", and gatewayID: " + testGatewayId;
+            System.out.println("UserProfile: " + userProfile);
+
+            // test update-user-profile : update name
+            userProfile = getUserProfile(testUserId);
+            String newFName = userProfile.getFirstName().replaceAll("fname", "fname-updated");
+            userProfile.setFirstName(newFName);
+            boolean updateSuccess = userProfileClient.updateUserProfile(authzToken, userProfile);
+            assert (updateSuccess) : "User update with new firstName: [" + newFName + "], Failed!";
+            System.out.println("User update with new firstName: [" + newFName + "], Successful!");
+
+            // test get-all-userprofiles
+            List<UserProfile> userProfileList = userProfileClient.getAllUserProfilesInGateway(authzToken, testGatewayId, 0, 5);
+            assert (userProfileList != null && !userProfileList.isEmpty()) : "Failed to retrieve users for gateway!";
+            System.out.println("Printing userList retrieved..");
+            for (UserProfile userProfile1 : userProfileList) {
+                System.out.println("\t [UserProfile] userId: " + userProfile1.getUserId());
+            }
+
+            // test delete-user-profile
+            boolean deleteSuccess = userProfileClient.deleteUserProfile(authzToken, testUserId, testGatewayId);
+            assert (deleteSuccess) : "Delete user failed for userId: " + testUserId;
+            System.out.println("Successfully deleted user with userId: " + testUserId);
+
+            // test-check-user-exist
+            boolean userExists = userProfileClient.doesUserExist(authzToken, testUserId, testGatewayId);
+            assert (!userExists) : "User should not exist, but it does.";
+            System.out.println("User was deleted, hence does not exist!");
+            System.out.println("*** DONE ***");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            logger.error("UserProfile client-sample Exception: " + ex, ex);
+        }
+    }
+
+    private static UserProfile getUserProfile(String userId) {
+        // get random value for userId
+        int userIdValue = ThreadLocalRandom.current().nextInt(1000);
+
+        if (userId != null) {
+            userIdValue = Integer.parseInt(userId.replaceAll("test-user-", ""));
+        }
+        // construct userProfile object
+        UserProfile userProfile = new UserProfile();
+        userProfile.setUserModelVersion("model-" + userIdValue);
+        userProfile.setAiravataInternalUserId("test-user-internal-" + userIdValue);
+        userProfile.setUserId("test-user-" + userIdValue);
+        userProfile.setFirstName("test-user-fname");
+        userProfile.setLastName("test-user-lname");
+        userProfile.setGatewayId(testGatewayId);
+        userProfile.addToEmails("test-user-" + userIdValue + "@domain1.com");
+        userProfile.addToEmails("test-user-" + userIdValue + "@domain2.com");
+        userProfile.setCreationTime(System.currentTimeMillis());
+        userProfile.setLastAccessTime(System.currentTimeMillis());
+        userProfile.setValidUntil(System.currentTimeMillis());
+        userProfile.setState(Status.ACTIVE);
+        userProfile.setNsfDemographics(getNSFDemographics(userIdValue));
+        return userProfile;
+    }
+
+    private static NSFDemographics getNSFDemographics(int userIdValue) {
+        // construct nsfdemographics object
+        NSFDemographics nsfDemographics = new NSFDemographics();
+        nsfDemographics.setAiravataInternalUserId("test-user-internal-" + userIdValue);
+        nsfDemographics.setGender("male");
+        nsfDemographics.setUsCitizenship(USCitizenship.US_CITIZEN);
+        nsfDemographics.addToEthnicities(ethnicity.NOT_HISPANIC_LATINO);
+        nsfDemographics.addToRaces(race.AMERICAN_INDIAN_OR_ALASKAN_NATIVE);
+        return nsfDemographics;
+    }
+}
diff --git a/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/util/ProfileServiceClientUtil.java b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/util/ProfileServiceClientUtil.java
new file mode 100644
index 0000000..993e3ec
--- /dev/null
+++ b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/java/org/apache/custos/service/profile/client/util/ProfileServiceClientUtil.java
@@ -0,0 +1,47 @@
+package org.apache.custos.service.profile.client.util;
+
+import java.net.URL;
+import java.util.Properties;
+
+/**
+ * Created by goshenoy on 3/23/17.
+ */
+public class ProfileServiceClientUtil {
+
+    private static final String PROFILE_SERVICE_SERVER_HOST = "profile.service.server.host";
+    private static final String PROFILE_SERVICE_SERVER_PORT = "profile.service.server.port";
+    private static final String PROFILE_CLIENT_SAMPLE_PROPERTIES = "profile-client-sample.properties";
+
+    private static Properties properties;
+    private static Exception propertyLoadException;
+
+    static {
+        loadProperties();
+    }
+
+    private static void loadProperties() {
+        URL url = ProfileServiceClientUtil.class.getClassLoader().getResource(PROFILE_CLIENT_SAMPLE_PROPERTIES);
+        try {
+            properties = new Properties();
+            properties.load(url.openStream());
+        } catch (Exception ex) {
+            propertyLoadException = ex;
+        }
+    }
+
+    public static String  getProfileServiceServerHost() throws Exception {
+        validateSuccessfullPropertyLoad();
+        return properties.getProperty(PROFILE_SERVICE_SERVER_HOST);
+    }
+
+    public static int getProfileServiceServerPort() throws Exception {
+        validateSuccessfullPropertyLoad();
+        return Integer.parseInt(properties.getProperty(PROFILE_SERVICE_SERVER_PORT));
+    }
+
+    private static void validateSuccessfullPropertyLoad() throws Exception {
+        if (propertyLoadException != null) {
+            throw new Exception(propertyLoadException.getMessage(), propertyLoadException);
+        }
+    }
+}
diff --git a/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/resources/profile-client-sample.properties b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/resources/profile-client-sample.properties
new file mode 100644
index 0000000..a38fc41
--- /dev/null
+++ b/custos-services/profile-service/profile-service-client-sdks/java-client-samples/src/main/resources/profile-client-sample.properties
@@ -0,0 +1,29 @@
+#
+#
+# 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.
+#
+
+##################################################################################
+#
+#  This properties file provides configuration for profile-service sample client
+#
+##################################################################################
+
+profile.service.server.host=localhost
+profile.service.server.port=8962
+
diff --git a/custos-services/profile-service/profile-service-client-sdks/pom.xml b/custos-services/profile-service/profile-service-client-sdks/pom.xml
new file mode 100644
index 0000000..d3151e3
--- /dev/null
+++ b/custos-services/profile-service/profile-service-client-sdks/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <artifactId>profile-service</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <name>Profile Service Client SDKs</name>
+    <artifactId>profile-service-client-sdks</artifactId>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>java-client-samples</module>
+    </modules>
+
+
+</project>
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-commons/pom.xml b/custos-services/profile-service/profile-service-commons/pom.xml
new file mode 100644
index 0000000..184a4cf
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/pom.xml
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>profile-service</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>profile-service-commons</artifactId>
+    <name>Custos Profile Service Commons</name>
+    <description>Module to expose a profile-service-commons as a thrift service</description>
+
+    <properties>
+        <derby.version>10.11.1.1</derby.version>
+        <surefire.version>2.18.1</surefire.version>
+        <skipTests>true</skipTests>
+        <mysql.connector.version>5.1.34</mysql.connector.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>net.sf.dozer</groupId>
+            <artifactId>dozer</artifactId>
+            <version>5.4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.openjpa</groupId>
+            <artifactId>openjpa</artifactId>
+            <version>${openjpa.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>${mysql.connector.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>${derby.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbyclient</artifactId>
+            <version>${derby.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbynet</artifactId>
+            <version>${derby.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbytools</artifactId>
+            <version>${derby.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>custos-commons</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>profile-service-models</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.openjpa</groupId>
+                <artifactId>openjpa-maven-plugin</artifactId>
+                <version>2.4.3</version>
+                <configuration>
+                    <includes>**/entities/*.class</includes>
+                    <excludes>**/entities/XML*.class</excludes>
+                    <addDefaultConstructor>true</addDefaultConstructor>
+                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>enhancer</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+                <inherited>true</inherited>
+                <configuration>
+                    <failIfNoTests>false</failIfNoTests>
+                    <skipTests>${skipTests}</skipTests>
+                    <workingDirectory>${project.build.testOutputDirectory}</workingDirectory>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/repositories/AbstractRepository.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/repositories/AbstractRepository.java
new file mode 100644
index 0000000..1a778a3
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/repositories/AbstractRepository.java
@@ -0,0 +1,124 @@
+/*
+ *
+ * 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.custos.service.profile.commons.repositories;
+
+import org.apache.custos.service.profile.commons.utils.JPAUtils;
+import org.apache.custos.service.profile.commons.utils.ObjectMapperSingleton;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class AbstractRepository<T, E, Id> {
+    private final static Logger logger = LoggerFactory.getLogger(AbstractRepository.class);
+
+    private Class<T> thriftGenericClass;
+    private Class<E> dbEntityGenericClass;
+
+    public AbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass) {
+        this.thriftGenericClass = thriftGenericClass;
+        this.dbEntityGenericClass = dbEntityGenericClass;
+    }
+
+    public T create(T t) {
+        return update(t);
+    }
+
+    public T update(T t) {
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        E entity = mapper.map(t, dbEntityGenericClass);
+        E persistedCopy = JPAUtils.execute(entityManager -> entityManager.merge(entity));
+        return mapper.map(persistedCopy, thriftGenericClass);
+    }
+
+    public boolean delete(Id id) {
+        JPAUtils.execute(entityManager -> {
+            E entity = entityManager.find(dbEntityGenericClass, id);
+            entityManager.remove(entity);
+            return entity;
+        });
+        return true;
+    }
+
+    public T get(Id id) {
+        E entity = JPAUtils.execute(entityManager -> entityManager
+                .find(dbEntityGenericClass, id));
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        return mapper.map(entity, thriftGenericClass);
+    }
+
+    public List<T> select(String query) {
+        List resultSet = (List) JPAUtils.execute(entityManager -> entityManager.createQuery(query).getResultList());
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> resultList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, thriftGenericClass)));
+        return resultList;
+    }
+
+    public List<T> select(String query, int limit, int offset) {
+        List resultSet = (List) JPAUtils.execute(entityManager -> entityManager.createQuery(query).setFirstResult(offset)
+                .setMaxResults(limit).getResultList());
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> resultList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, thriftGenericClass)));
+        return resultList;
+    }
+
+    public List<T> select(String query, int limit, int offset, Map<String, Object> queryParams) {
+        List resultSet = (List) JPAUtils.execute(entityManager -> {
+            Query jpaQuery = entityManager.createQuery(query);
+
+            for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
+
+                jpaQuery.setParameter(entry.getKey(), entry.getValue());
+            }
+
+            return jpaQuery.setFirstResult(offset).setMaxResults(limit).getResultList();
+
+        });
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> resultList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, thriftGenericClass)));
+        return resultList;
+    }
+
+    public List<T> select(String query, Map<String, Object> queryParams) {
+        List resultSet = (List) JPAUtils.execute(entityManager -> {
+            Query jpaQuery = entityManager.createQuery(query);
+
+            for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
+
+                jpaQuery.setParameter(entry.getKey(), entry.getValue());
+            }
+
+            return jpaQuery.getResultList();
+
+        });
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> resultList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, thriftGenericClass)));
+        return resultList;
+    }
+}
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/tenant/entities/GatewayEntity.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/tenant/entities/GatewayEntity.java
new file mode 100644
index 0000000..c3506e3
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/tenant/entities/GatewayEntity.java
@@ -0,0 +1,285 @@
+/**
+ *
+ * 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.custos.service.profile.commons.tenant.entities;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.*;
+import java.util.UUID;
+
+@Entity
+@Table(name = "GATEWAY")
+public class GatewayEntity {
+    private final static Logger logger = LoggerFactory.getLogger(GatewayEntity.class);
+    private String custosInternalGatewayId;
+    private String gatewayId;
+    private String gatewayName;
+    private String domain;
+    private String emailAddress;
+    private String gatewayApprovalStatus;
+    private String gatewayAcronym;
+    private String gatewayUrl;
+    private String gatewayPublicAbstract;
+    private String reviewProposalDescription;
+    private String gatewayAdminFirstName;
+    private String gatewayAdminLastName;
+    private String gatewayAdminEmail;
+    private String identityServerUserName;
+    private String identityServerPasswordToken;
+    private String declinedReason;
+    private String oauthClientId;
+    private String oauthClientSecret;
+    private long requestCreationTime;
+    private String requesterUsername;
+
+    // set random value for internalGatewayId
+    public GatewayEntity() {
+        this.custosInternalGatewayId = UUID.randomUUID().toString();
+    }
+
+    @Id
+    @Column(name = "CUSTOS_INTERNAL_GATEWAY_ID")
+    public String getCustosInternalGatewayId() {
+        return custosInternalGatewayId;
+    }
+
+    public void setCustosInternalGatewayId(String custosInternalGatewayId) {
+        this.custosInternalGatewayId = custosInternalGatewayId;
+    }
+
+    @Column(name = "GATEWAY_ID")
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    @Column(name = "GATEWAY_NAME")
+    public String getGatewayName() {
+        return gatewayName;
+    }
+
+    public void setGatewayName(String gatewayName) {
+        this.gatewayName = gatewayName;
+    }
+
+    @Column(name = "GATEWAY_DOMAIN")
+    public String getDomain() {
+        return domain;
+    }
+
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+
+    @Column(name = "EMAIL_ADDRESS")
+    public String getEmailAddress() {
+        return emailAddress;
+    }
+
+    public void setEmailAddress(String emailAddress) {
+        this.emailAddress = emailAddress;
+    }
+
+    @Column(name = "GATEWAY_APPROVAL_STATUS")
+    public String getGatewayApprovalStatus() {
+        return gatewayApprovalStatus;
+    }
+
+    public void setGatewayApprovalStatus(String gatewayApprovalStatus) {
+        this.gatewayApprovalStatus = gatewayApprovalStatus;
+    }
+
+    @Column(name = "GATEWAY_ACRONYM")
+    public String getGatewayAcronym() {
+        return gatewayAcronym;
+    }
+
+    public void setGatewayAcronym(String gatewayAcronym) {
+        this.gatewayAcronym = gatewayAcronym;
+    }
+
+    @Column(name = "GATEWAY_URL")
+    public String getGatewayUrl() {
+        return gatewayUrl;
+    }
+
+    public void setGatewayUrl(String gatewayUrl) {
+        this.gatewayUrl = gatewayUrl;
+    }
+
+    @Column(name = "GATEWAY_PUBLIC_ABSTRACT")
+    public String getGatewayPublicAbstract() {
+        return gatewayPublicAbstract;
+    }
+
+    public void setGatewayPublicAbstract(String gatewayPublicAbstract) {
+        this.gatewayPublicAbstract = gatewayPublicAbstract;
+    }
+
+    @Column(name = "GATEWAY_REVIEW_PROPOSAL_DESCRIPTION")
+    public String getReviewProposalDescription() {
+        return reviewProposalDescription;
+    }
+
+    public void setReviewProposalDescription(String reviewProposalDescription) {
+        this.reviewProposalDescription = reviewProposalDescription;
+    }
+
+    @Column(name = "GATEWAY_ADMIN_FIRST_NAME")
+    public String getGatewayAdminFirstName() {
+        return gatewayAdminFirstName;
+    }
+
+    public void setGatewayAdminFirstName(String gatewayAdminFirstName) {
+        this.gatewayAdminFirstName = gatewayAdminFirstName;
+    }
+
+    @Column(name = "GATEWAY_ADMIN_LAST_NAME")
+    public String getGatewayAdminLastName() {
+        return gatewayAdminLastName;
+    }
+
+    public void setGatewayAdminLastName(String gatewayAdminLastName) {
+        this.gatewayAdminLastName = gatewayAdminLastName;
+    }
+
+    @Column(name = "GATEWAY_ADMIN_EMAIL")
+    public String getGatewayAdminEmail() {
+        return gatewayAdminEmail;
+    }
+
+    public void setGatewayAdminEmail(String gatewayAdminEmail) {
+        this.gatewayAdminEmail = gatewayAdminEmail;
+    }
+
+    @Column(name = "IDENTITY_SERVER_USERNAME")
+    public String getIdentityServerUserName() {
+        return identityServerUserName;
+    }
+
+    public void setIdentityServerUserName(String identityServerUserName) {
+        this.identityServerUserName = identityServerUserName;
+    }
+
+    @Column(name = "IDENTITY_SERVER_PASSWORD_TOKEN")
+    public String getIdentityServerPasswordToken() {
+        return identityServerPasswordToken;
+    }
+
+    public void setIdentityServerPasswordToken(String identityServerPasswordToken) {
+        this.identityServerPasswordToken = identityServerPasswordToken;
+    }
+
+    @Column(name = "REQUESTER_USERNAME")
+    public String getRequesterUsername() {
+        return requesterUsername;
+    }
+
+    public void setRequesterUsername(String requesterUsername) {
+        this.requesterUsername = requesterUsername;
+    }
+
+    @Column(name = "DECLINED_REASON")
+    public String getDeclinedReason() {
+        return declinedReason;
+    }
+
+    public void setDeclinedReason(String declinedReason) {
+        this.declinedReason = declinedReason;
+    }
+
+    @Column(name = "OAUTH_CLIENT_ID")
+    public String getOauthClientId() {
+        return oauthClientId;
+    }
+
+    public void setOauthClientId(String oauthClientId) {
+        this.oauthClientId = oauthClientId;
+    }
+
+    @Column(name = "REQUEST_CREATION_TIME")
+    public long getRequestCreationTime() {
+        return requestCreationTime;
+    }
+
+    public void setRequestCreationTime(long requestCreationTime) {
+        this.requestCreationTime = requestCreationTime;
+    }
+
+    @Column(name = "OAUTH_CLIENT_SECRET")
+    public String getOauthClientSecret() {
+        return oauthClientSecret;
+    }
+
+    public void setOauthClientSecret(String oauthClientSecret) {
+        this.oauthClientSecret = oauthClientSecret;
+    }
+
+    @PrePersist
+    void createdAt() {
+        this.requestCreationTime = System.currentTimeMillis();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (!(obj instanceof GatewayEntity)) {
+            return false;
+        }
+        GatewayEntity gwy = (GatewayEntity) obj;
+        return getCustosInternalGatewayId().equals(gwy.getCustosInternalGatewayId());
+    }
+
+    @Override
+    public String toString() {
+        return "GatewayEntity{" +
+                "custosInternalGatewayId='" + custosInternalGatewayId + '\'' +
+                ", gatewayId='" + gatewayId + '\'' +
+                ", gatewayName='" + gatewayName + '\'' +
+                ", domain='" + domain + '\'' +
+                ", emailAddress='" + emailAddress + '\'' +
+                ", gatewayApprovalStatus='" + gatewayApprovalStatus + '\'' +
+                ", gatewayAcronym='" + gatewayAcronym + '\'' +
+                ", gatewayUrl='" + gatewayUrl + '\'' +
+                ", gatewayPublicAbstract='" + gatewayPublicAbstract + '\'' +
+                ", reviewProposalDescription='" + reviewProposalDescription + '\'' +
+                ", gatewayAdminFirstName='" + gatewayAdminFirstName + '\'' +
+                ", gatewayAdminLastName='" + gatewayAdminLastName + '\'' +
+                ", gatewayAdminEmail='" + gatewayAdminEmail + '\'' +
+                ", identityServerUserName='" + identityServerUserName + '\'' +
+                ", identityServerPasswordToken='" + identityServerPasswordToken + '\'' +
+                ", declinedReason='" + declinedReason + '\'' +
+                ", oauthClientId='" + oauthClientId + '\'' +
+                ", oauthClientSecret='" + oauthClientSecret + '\'' +
+                ", requestCreationTime=" + requestCreationTime +
+                ", requesterUsername='" + requesterUsername + '\'' +
+                '}';
+    }
+}
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/CustomizedDashboardEntity.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/CustomizedDashboardEntity.java
new file mode 100644
index 0000000..1ee3845
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/CustomizedDashboardEntity.java
@@ -0,0 +1,325 @@
+/*
+ *
+ * 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.custos.service.profile.commons.user.entities;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name = "CUSTOMIZED_DASHBOARD")
+public class CustomizedDashboardEntity {
+
+    private String custosInternalUserId;
+    private String experimentId;
+    private String name;
+    private String description;
+    private String project;
+    private String owner;
+    private String application;
+    private String computeResource;
+    private String jobName;
+    private String jobId;
+    private String jobStatus;
+    private String jobCreationTime;
+    private String notificationsTo;
+    private String workingDir;
+    private String jobDescription;
+    private String creationTime;
+    private String lastModifiedTime;
+    private String wallTime;
+    private String cpuCount;
+    private String nodeCount;
+    private String queue;
+    private String inputs;
+    private String outputs;
+    private String storageDir;
+    private String errors;
+
+    private UserProfileEntity userProfileEntity;
+
+    @Id
+    @Column(name = "AIRAVATA_INTERNAL_USER_ID")
+    public String getCustosInternalUserId() {
+        return custosInternalUserId;
+    }
+
+    public void setCustosInternalUserId(String custosInternalUserId) {
+        this.custosInternalUserId = custosInternalUserId;
+    }
+
+    @Column(name = "ENABLED_EXPERIMENT_ID")
+    public String getExperimentId() {
+        return experimentId;
+    }
+
+    public void setExperimentId(String experimentId) {
+        this.experimentId = experimentId;
+    }
+
+    @Column(name = "ENABLED_NAME")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Column(name = "ENABLED_DESCRIPTION")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Column(name = "ENABLED_PROJECT")
+    public String getProject() {
+        return project;
+    }
+
+    public void setProject(String project) {
+        this.project = project;
+    }
+
+    @Column(name = "ENABLED_OWNER")
+    public String getOwner() {
+        return owner;
+    }
+
+    public void setOwner(String owner) {
+        this.owner = owner;
+    }
+
+    @Column(name = "ENABLED_APPLICATION")
+    public String getApplication() {
+        return application;
+    }
+
+    public void setApplication(String application) {
+        this.application = application;
+    }
+
+    @Column(name = "ENABLED_COMPUTE_RESOURCE")
+    public String getComputeResource() {
+        return computeResource;
+    }
+
+    public void setComputeResource(String computeResource) {
+        this.computeResource = computeResource;
+    }
+
+    @Column(name = "ENABLED_JOB_NAME")
+    public String getJobName() {
+        return jobName;
+    }
+
+    public void setJobName(String jobName) {
+        this.jobName = jobName;
+    }
+
+    @Column(name = "ENABLED_JOB_ID")
+    public String getJobId() {
+        return jobId;
+    }
+
+    public void setJobId(String jobId) {
+        this.jobId = jobId;
+    }
+
+    @Column(name = "ENABLED_JOB_STATUS")
+    public String getJobStatus() {
+        return jobStatus;
+    }
+
+    public void setJobStatus(String jobStatus) {
+        this.jobStatus = jobStatus;
+    }
+
+    @Column(name = "ENABLED_JOB_CREATION_TIME")
+    public String getJobCreationTime() {
+        return jobCreationTime;
+    }
+
+    public void setJobCreationTime(String jobCreationTime) {
+        this.jobCreationTime = jobCreationTime;
+    }
+
+    @Column(name = "ENABLED_NOTIFICATIONS_TO")
+    public String getNotificationsTo() {
+        return notificationsTo;
+    }
+
+    public void setNotificationsTo(String notificationsTo) {
+        this.notificationsTo = notificationsTo;
+    }
+
+    @Column(name = "ENABLED_WORKING_DIR")
+    public String getWorkingDir() {
+        return workingDir;
+    }
+
+    public void setWorkingDir(String workingDir) {
+        this.workingDir = workingDir;
+    }
+
+    @Column(name = "ENABLED_JOB_DESCRIPTION")
+    public String getJobDescription() {
+        return jobDescription;
+    }
+
+    public void setJobDescription(String jobDescription) {
+        this.jobDescription = jobDescription;
+    }
+
+    @Column(name = "ENABLED_CREATION_TIME")
+    public String getCreationTime() {
+        return creationTime;
+    }
+
+    public void setCreationTime(String creationTime) {
+        this.creationTime = creationTime;
+    }
+
+    @Column(name = "ENABLED_LAST_MODIFIED_TIME")
+    public String getLastModifiedTime() {
+        return lastModifiedTime;
+    }
+
+    public void setLastModifiedTime(String lastModifiedTime) {
+        this.lastModifiedTime = lastModifiedTime;
+    }
+
+    @Column(name = "ENABLED_WALL_TIME")
+    public String getWallTime() {
+        return wallTime;
+    }
+
+    public void setWallTime(String wallTime) {
+        this.wallTime = wallTime;
+    }
+
+    @Column(name = "ENABLED_CPU_COUNT")
+    public String getCpuCount() {
+        return cpuCount;
+    }
+
+    public void setCpuCount(String cpuCount) {
+        this.cpuCount = cpuCount;
+    }
+
+    @Column(name = "ENABLED_NODE_COUNT")
+    public String getNodeCount() {
+        return nodeCount;
+    }
+
+    public void setNodeCount(String nodeCount) {
+        this.nodeCount = nodeCount;
+    }
+
+    @Column(name = "ENABLED_QUEUE")
+    public String getQueue() {
+        return queue;
+    }
+
+    public void setQueue(String queue) {
+        this.queue = queue;
+    }
+
+    @Column(name = "ENABLED_INPUTS")
+    public String getInputs() {
+        return inputs;
+    }
+
+    public void setInputs(String inputs) {
+        this.inputs = inputs;
+    }
+
+    @Column(name = "ENABLED_OUTPUTS")
+    public String getOutputs() {
+        return outputs;
+    }
+
+    public void setOutputs(String outputs) {
+        this.outputs = outputs;
+    }
+
+    @Column(name = "ENABLED_STORAGE_DIR")
+    public String getStorageDir() {
+        return storageDir;
+    }
+
+    public void setStorageDir(String storageDir) {
+        this.storageDir = storageDir;
+    }
+
+    @Column(name = "ENABLED_ERRORS")
+    public String getErrors() {
+        return errors;
+    }
+
+    public void setErrors(String errors) {
+        this.errors = errors;
+    }
+
+    @OneToOne(targetEntity = UserProfileEntity.class, cascade = CascadeType.ALL)
+    @PrimaryKeyJoinColumn(name = "AIRAVATA_INTERNAL_USER_ID", referencedColumnName = "AIRAVATA_INTERNAL_USER_ID")
+    public UserProfileEntity getUserProfileEntity() {
+        return userProfileEntity;
+    }
+
+    public void setUserProfileEntity(UserProfileEntity userProfileEntity) {
+        this.userProfileEntity = userProfileEntity;
+    }
+
+    @Override
+    public String toString() {
+        return "CustomizedDashboardEntity{" +
+                "custosInternalUserId='" + custosInternalUserId + '\'' +
+                ", experimentId='" + experimentId + '\'' +
+                ", name='" + name + '\'' +
+                ", description='" + description + '\'' +
+                ", project='" + project + '\'' +
+                ", owner='" + owner + '\'' +
+                ", application='" + application + '\'' +
+                ", computeResource='" + computeResource + '\'' +
+                ", jobName='" + jobName + '\'' +
+                ", jobId='" + jobId + '\'' +
+                ", jobStatus='" + jobStatus + '\'' +
+                ", jobCreationTime='" + jobCreationTime + '\'' +
+                ", notificationsTo='" + notificationsTo + '\'' +
+                ", workingDir='" + workingDir + '\'' +
+                ", jobDescription='" + jobDescription + '\'' +
+                ", creationTime='" + creationTime + '\'' +
+                ", lastModifiedTime='" + lastModifiedTime + '\'' +
+                ", wallTime='" + wallTime + '\'' +
+                ", cpuCount='" + cpuCount + '\'' +
+                ", nodeCount='" + nodeCount + '\'' +
+                ", queue='" + queue + '\'' +
+                ", inputs='" + inputs + '\'' +
+                ", outputs='" + outputs + '\'' +
+                ", storageDir='" + storageDir + '\'' +
+                ", errors='" + errors + '\'' +
+                '}';
+    }
+}
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/NSFDemographicsEntity.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/NSFDemographicsEntity.java
new file mode 100644
index 0000000..f336444
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/NSFDemographicsEntity.java
@@ -0,0 +1,108 @@
+/*
+ *
+ * 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.custos.service.profile.commons.user.entities;
+
+import javax.persistence.*;
+import java.util.List;
+
+@Entity
+@Table(name = "NSF_DEMOGRAPHIC")
+public class NSFDemographicsEntity {
+    private String custosInternalUserId;
+    private String gender;
+    private List<String> ethnicities;
+    private List<String> races;
+    private List<String> disabilities;
+    private UserProfileEntity userProfile;
+
+    @Id
+    @Column(name = "CUSTOS_INTERNAL_USER_ID")
+    public String getCustosInternalUserId() {
+        return custosInternalUserId;
+    }
+
+    public void setCustosInternalUserId(String userId) {
+        this.custosInternalUserId = userId;
+    }
+
+    @Column(name = "GENDER")
+    public String getGender() {
+        return gender;
+    }
+
+    public void setGender(String gender) {
+        this.gender = gender;
+    }
+
+    @ElementCollection
+    @CollectionTable(name="NSF_DEMOGRAPHIC_ETHNICITY", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @Column(name = "ETHNICITY")
+    public List<String> getEthnicities() {
+        return ethnicities;
+    }
+
+    public void setEthnicities(List<String> ethnicities) {
+        this.ethnicities = ethnicities;
+    }
+
+    @ElementCollection
+    @CollectionTable(name="NSF_DEMOGRAPHIC_RACE", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @Column(name = "RACE")
+    public List<String> getRaces() {
+        return races;
+    }
+
+    public void setRaces(List<String> races) {
+        this.races = races;
+    }
+
+    @ElementCollection
+    @CollectionTable(name="NSF_DEMOGRAPHIC_DISABILITY", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @Column(name = "DISABILITY")
+    public List<String> getDisabilities() {
+        return disabilities;
+    }
+
+    public void setDisabilities(List<String> disabilities) {
+        this.disabilities = disabilities;
+    }
+
+    @OneToOne(targetEntity = UserProfileEntity.class, cascade = CascadeType.ALL)
+    @PrimaryKeyJoinColumn(name = "AIRAVATA_INTERNAL_USER_ID", referencedColumnName = "AIRAVATA_INTERNAL_USER_ID")
+    public UserProfileEntity getUserProfile() {
+        return userProfile;
+    }
+
+    public void setUserProfile(UserProfileEntity userProfile) {
+        this.userProfile = userProfile;
+    }
+
+    @Override
+    public String toString() {
+        return "NSFDemographicsEntity{" +
+                "custosInternalUserId='" + custosInternalUserId + '\'' +
+                ", gender='" + gender + '\'' +
+                ", ethnicities=" + ethnicities +
+                ", races=" + races +
+                ", disabilities=" + disabilities +
+                '}';
+    }
+}
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/UserProfileEntity.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/UserProfileEntity.java
new file mode 100644
index 0000000..c95f2c0
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/user/entities/UserProfileEntity.java
@@ -0,0 +1,345 @@
+/*
+ *
+ * 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.custos.service.profile.commons.user.entities;
+
+import javax.persistence.*;
+import java.util.Date;
+import java.util.List;
+
+@Entity
+@Table(name="USER_PROFILE")
+public class UserProfileEntity {
+    private String custosInternalUserId;
+    private String userId;
+    private String gatewayId;
+    private String userModelVersion;
+    private String firstName;
+    private String lastName;
+    private String middleName;
+    private String namePrefix;
+    private String nameSuffix;
+    private String orcidId;
+    private String country;
+    private String homeOrganization;
+    private String orginationAffiliation;
+    private Date creationTime;
+    private Date lastAccessTime;
+    private Date validUntil;
+    private String state;
+    private String comments;
+    private List<String> labeledURI;
+    private String gpgKey;
+    private String timeZone;
+
+    private List<String> nationality;
+    private List<String> emails;
+    private List<String> phones;
+    private NSFDemographicsEntity nsfDemographics;
+    private CustomizedDashboardEntity customizedDashboardEntity;
+
+    @Id
+    @Column(name = "AIRAVATA_INTERNAL_USER_ID")
+    public String getCustosInternalUserId() {
+        return custosInternalUserId;
+    }
+
+    public void setCustosInternalUserId(String id) {
+        this.custosInternalUserId = id;
+    }
+
+    @Column(name = "USER_ID")
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    @Column(name = "GATEWAY_ID")
+    public String getGatewayId() {
+        return gatewayId;
+    }
+
+    public void setGatewayId(String gatewayId) {
+        this.gatewayId = gatewayId;
+    }
+
+    @Column(name = "USER_MODEL_VERSION")
+    public String getUserModelVersion() {
+        return userModelVersion;
+    }
+
+    public void setUserModelVersion(String userModelVersion) {
+        this.userModelVersion = userModelVersion;
+    }
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    @CollectionTable(name="USER_PROFILE_EMAIL", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @Column(name = "EMAIL")
+    public List<String> getEmails() {
+        return emails;
+    }
+
+    public void setEmails(List<String> emails) {
+        this.emails = emails;
+    }
+
+    @Column(name = "FIRST_NAME")
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    @Column(name = "LAST_NAME")
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    @Column(name = "MIDDLE_NAME")
+    public String getMiddleName() {
+        return middleName;
+    }
+
+    public void setMiddleName(String middleName) {
+        this.middleName = middleName;
+    }
+
+    @Column(name = "NAME_PREFIX")
+    public String getNamePrefix() {
+        return namePrefix;
+    }
+
+    public void setNamePrefix(String namePrefix) {
+        this.namePrefix = namePrefix;
+    }
+
+    @Column(name = "NAME_SUFFIX")
+    public String getNameSuffix() {
+        return nameSuffix;
+    }
+
+    public void setNameSuffix(String nameSuffix) {
+        this.nameSuffix = nameSuffix;
+    }
+
+    @Column(name = "ORCID_ID")
+    public String getOrcidId() {
+        return orcidId;
+    }
+
+    public void setOrcidId(String orcidId) {
+        this.orcidId = orcidId;
+    }
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    @CollectionTable(name="USER_PROFILE_PHONE", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @Column(name = "PHONE")
+    public List<String> getPhones() {
+        return phones;
+    }
+
+    public void setPhones(List<String> phones) {
+        this.phones = phones;
+    }
+
+    @Column(name = "COUNTRY")
+    public String getCountry() {
+        return country;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    @CollectionTable(name="USER_PROFILE_NATIONALITY", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @Column(name = "NATIONALITY")
+    public List<String> getNationality() {
+        return nationality;
+    }
+
+    public void setNationality(List<String> nationality) {
+        this.nationality = nationality;
+    }
+
+    @Column(name = "HOME_ORGANIZATION")
+    public String getHomeOrganization() {
+        return homeOrganization;
+    }
+
+    public void setHomeOrganization(String homeOrganization) {
+        this.homeOrganization = homeOrganization;
+    }
+
+    @Column(name = "ORIGINATION_AFFILIATION")
+    public String getOrginationAffiliation() {
+        return orginationAffiliation;
+    }
+
+    public void setOrginationAffiliation(String orginationAffiliation) {
+        this.orginationAffiliation = orginationAffiliation;
+    }
+
+    @Column(name="CREATION_TIME")
+    public Date getCreationTime() {
+        return creationTime;
+    }
+
+    private void setCreationTime(Date creationTime) {
+        this.creationTime = creationTime;
+    }
+
+    @Column(name = "LAST_ACCESS_TIME")
+    public Date getLastAccessTime() {
+        return lastAccessTime;
+    }
+
+    private void setLastAccessTime(Date lastAccessTime) {
+        this.lastAccessTime = lastAccessTime;
+    }
+
+    @Column(name = "VALID_UNTIL")
+    public Date getValidUntil() {
+        return validUntil;
+    }
+
+    public void setValidUntil(Date validUntil) {
+        this.validUntil = validUntil;
+    }
+
+    @Column(name = "STATE")
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    @Lob
+    @Column(name = "COMMENTS")
+    public String getComments() {
+        return comments;
+    }
+
+    public void setComments(String comments) {
+        this.comments = comments;
+    }
+
+    @ElementCollection(fetch = FetchType.EAGER)
+    @CollectionTable(name="USER_PROFILE_LABELED_URI", joinColumns = @JoinColumn(name="AIRAVATA_INTERNAL_USER_ID"))
+    @Column(name = "LABELED_URI")
+    public List<String> getLabeledURI() {
+        return labeledURI;
+    }
+
+    public void setLabeledURI(List<String> labeledURI) {
+        this.labeledURI = labeledURI;
+    }
+
+    @Lob
+    @Column(name = "GPG_KEY")
+    public String getGpgKey() {
+        return gpgKey;
+    }
+
+    public void setGpgKey(String gpgKey) {
+        this.gpgKey = gpgKey;
+    }
+
+    @Column(name = "TIME_ZONE")
+    public String getTimeZone() {
+        return timeZone;
+    }
+
+    public void setTimeZone(String timeZone) {
+        this.timeZone = timeZone;
+    }
+
+    @OneToOne(targetEntity = NSFDemographicsEntity.class, cascade = CascadeType.ALL,
+            mappedBy = "userProfile", fetch = FetchType.EAGER)
+    public NSFDemographicsEntity getNsfDemographics() {
+        return nsfDemographics;
+    }
+
+    public void setNsfDemographics(NSFDemographicsEntity nsfDemographics) {
+        this.nsfDemographics = nsfDemographics;
+    }
+
+    @OneToOne(targetEntity = CustomizedDashboardEntity.class, cascade = CascadeType.ALL,
+            mappedBy = "userProfileEntity", fetch = FetchType.EAGER)
+    public CustomizedDashboardEntity getCustomizedDashboardEntity() {
+        return customizedDashboardEntity;
+    }
+
+    public void setCustomizedDashboardEntity(CustomizedDashboardEntity customizedDashboardEntity) {
+        this.customizedDashboardEntity = customizedDashboardEntity;
+    }
+
+    @PrePersist
+    void createdAt() {
+        this.creationTime = this.lastAccessTime = new Date();
+    }
+
+    @PreUpdate
+    void updatedAt() {
+        this.lastAccessTime = new Date();
+    }
+
+    @Override
+    public String toString() {
+        return "UserProfileEntity{" +
+                "custosInternalUserId='" + custosInternalUserId + '\'' +
+                ", userId='" + userId + '\'' +
+                ", gatewayId='" + gatewayId + '\'' +
+                ", userModelVersion='" + userModelVersion + '\'' +
+                ", firstName='" + firstName + '\'' +
+                ", lastName='" + lastName + '\'' +
+                ", middleName='" + middleName + '\'' +
+                ", namePrefix='" + namePrefix + '\'' +
+                ", nameSuffix='" + nameSuffix + '\'' +
+                ", orcidId='" + orcidId + '\'' +
+                ", country='" + country + '\'' +
+                ", homeOrganization='" + homeOrganization + '\'' +
+                ", orginationAffiliation='" + orginationAffiliation + '\'' +
+                ", creationTime=" + creationTime +
+                ", lastAccessTime=" + lastAccessTime +
+                ", validUntil=" + validUntil +
+                ", state='" + state + '\'' +
+                ", comments='" + comments + '\'' +
+                ", labeledURI=" + labeledURI +
+                ", gpgKey='" + gpgKey + '\'' +
+                ", timeZone='" + timeZone + '\'' +
+                ", nationality=" + nationality +
+                ", emails=" + emails +
+                ", phones=" + phones +
+                ", nsfDemographics=" + nsfDemographics +
+                '}';
+    }
+}
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Committer.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Committer.java
new file mode 100644
index 0000000..aa2dc58
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Committer.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.custos.service.profile.commons.utils;
+
+@FunctionalInterface
+public interface Committer<T, R>  {
+
+    R commit(T t);
+}
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAConstants.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAConstants.java
new file mode 100644
index 0000000..f029df0
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAConstants.java
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.custos.service.profile.commons.utils;
+
+public class JPAConstants {
+	public static final String KEY_JDBC_URL = "profile.service.jdbc.url";
+	public static final String KEY_JDBC_USER = "profile.service.jdbc.user";
+	public static final String KEY_JDBC_PASSWORD = "profile.service.jdbc.password";
+	public static final String KEY_JDBC_DRIVER = "profile.service.jdbc.driver";
+
+	// TODO: is this needed?
+	public static final String KEY_DERBY_START_ENABLE = "profile.service.start.derby.server.mode";
+	public static final String VALIDATION_QUERY = "profile.service.validationQuery";
+	public static final String JPA_CACHE_SIZE = "profile.service.jpa.cache.size";
+	public static final String ENABLE_CACHING = "profile.service.cache.enable";
+}
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAUtils.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAUtils.java
new file mode 100644
index 0000000..2cae126
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/JPAUtils.java
@@ -0,0 +1,53 @@
+/*
+ *
+ * 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.custos.service.profile.commons.utils;
+
+import org.apache.custos.commons.utils.JDBCConfig;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+public class JPAUtils {
+    private static final String PERSISTENCE_UNIT_NAME = "profile_service";
+    private static final JDBCConfig JDBC_CONFIG = new ProfileServiceJDBCConfig();
+    private static final EntityManagerFactory factory = org.apache.custos.commons.utils.JPAUtils.getEntityManagerFactory(PERSISTENCE_UNIT_NAME, JDBC_CONFIG);
+
+    public static EntityManager getEntityManager() {
+        return factory.createEntityManager();
+    }
+
+    public static <R> R execute(Committer<EntityManager, R> committer){
+        EntityManager entityManager = JPAUtils.getEntityManager();
+        try {
+            entityManager.getTransaction().begin();
+            R r = committer.commit(entityManager);
+            entityManager.getTransaction().commit();
+            return  r;
+        }finally {
+            if (entityManager != null && entityManager.isOpen()) {
+                if (entityManager.getTransaction().isActive()) {
+                    entityManager.getTransaction().rollback();
+                }
+                entityManager.close();
+            }
+        }
+    }
+}
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ObjectMapperSingleton.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ObjectMapperSingleton.java
new file mode 100644
index 0000000..e5cd0f1
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ObjectMapperSingleton.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * 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.custos.service.profile.commons.utils;
+
+import org.dozer.DozerBeanMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ObjectMapperSingleton extends DozerBeanMapper{
+    private final static Logger logger = LoggerFactory.getLogger(ObjectMapperSingleton.class);
+
+    private static ObjectMapperSingleton instance;
+
+    private ObjectMapperSingleton(){}
+
+    public static ObjectMapperSingleton getInstance(){
+        if(instance == null)
+            instance = new ObjectMapperSingleton();
+        return instance;
+    }
+}
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ProfileServiceJDBCConfig.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ProfileServiceJDBCConfig.java
new file mode 100644
index 0000000..fe2db70
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/ProfileServiceJDBCConfig.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.custos.service.profile.commons.utils;
+
+import org.apache.custos.commons.utils.JDBCConfig;
+
+public class ProfileServiceJDBCConfig implements JDBCConfig {
+
+    @Override
+    public String getURL() {
+        return Utils.getJDBCURL();
+    }
+
+    @Override
+    public String getDriver() {
+        return Utils.getJDBCDriver();
+    }
+
+    @Override
+    public String getUser() {
+        return Utils.getJDBCUser();
+    }
+
+    @Override
+    public String getPassword() {
+        return Utils.getJDBCPassword();
+    }
+
+    @Override
+    public String getValidationQuery() {
+        return Utils.getValidationQuery();
+    }
+}
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/QueryConstants.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/QueryConstants.java
new file mode 100644
index 0000000..6b3da31
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/QueryConstants.java
@@ -0,0 +1,33 @@
+package org.apache.custos.service.profile.commons.utils;
+
+import org.apache.custos.profile.models.user.UserProfile;
+import org.apache.custos.profile.models.workspace.Gateway;
+
+/**
+ * Created by goshenoy on 03/08/2017.
+ */
+public class QueryConstants {
+
+
+    public static final String FIND_USER_PROFILE_BY_USER_ID = "SELECT u FROM UserProfileEntity u " +
+            "where u.userId LIKE :" + UserProfile._Fields.USER_ID.getFieldName() + " " +
+            "AND u.gatewayId LIKE :" + UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
+
+    public static final String FIND_ALL_USER_PROFILES_BY_GATEWAY_ID = "SELECT u FROM UserProfileEntity u " +
+            "where u.gatewayId LIKE :" + UserProfile._Fields.GATEWAY_ID.getFieldName() + "";
+
+    public static final String FIND_GATEWAY_BY_INTERNAL_ID = "SELECT g FROM GatewayEntity g " +
+            "where g.airavataInternalGatewayId LIKE :" + Gateway._Fields.AIRAVATA_INTERNAL_GATEWAY_ID.getFieldName();
+
+    public static final String FIND_DUPLICATE_GATEWAY = "SELECT g FROM GatewayEntity g " +
+            "where g.gatewayApprovalStatus IN :" + Gateway._Fields.GATEWAY_APPROVAL_STATUS.getFieldName() + " " +
+            "and (g.gatewayId LIKE :" + Gateway._Fields.GATEWAY_ID.getFieldName() + " " +
+            "     or g.gatewayName LIKE :" + Gateway._Fields.GATEWAY_NAME.getFieldName() + " " +
+            "     or g.gatewayUrl LIKE :" + Gateway._Fields.GATEWAY_URL.getFieldName() + " " +
+            "    )";
+
+    public static final String GET_ALL_GATEWAYS = "SELECT g FROM GatewayEntity g";
+
+    public static final String GET_USER_GATEWAYS = "SELECT g from GatewayEntity g " +
+            "where g.requesterUsername LIKE :" + Gateway._Fields.REQUESTER_USERNAME.getFieldName() + "";
+}
diff --git a/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Utils.java b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Utils.java
new file mode 100644
index 0000000..78033cc
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/java/org/apache/custos/service/profile/commons/utils/Utils.java
@@ -0,0 +1,122 @@
+/*
+ *
+ * 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.custos.service.profile.commons.utils;
+
+import org.apache.custos.commons.exceptions.ApplicationSettingsException;
+import org.apache.custos.commons.utils.ServerSettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URI;
+
+
+public class Utils {
+    private final static Logger logger = LoggerFactory.getLogger(Utils.class);
+
+    public static String getJDBCURL(){
+    	try {
+            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_URL);
+		} catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            return null;
+        }
+    }
+
+    public static String getHost(){
+        try{
+            String jdbcURL = getJDBCURL();
+            String cleanURI = jdbcURL.substring(5);
+            URI uri = URI.create(cleanURI);
+            return uri.getHost();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return null;
+        }
+    }
+
+    public static int getPort(){
+        try{
+            String jdbcURL = getJDBCURL();
+            String cleanURI = jdbcURL.substring(5);
+            URI uri = URI.create(cleanURI);
+            return uri.getPort();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            return -1;
+        }
+    }
+
+    public static int getJPACacheSize (){
+        try {
+            String cache = ServerSettings.getSetting(JPAConstants.JPA_CACHE_SIZE, "5000");
+            return Integer.parseInt(cache);
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            return -1;
+        }
+    }
+
+    public static String isCachingEnabled (){
+        try {
+            return ServerSettings.getSetting(JPAConstants.ENABLE_CACHING, "true");
+        }catch (Exception e){
+            logger.error(e.getMessage(), e);
+            return "true";
+        }
+    }
+
+    public static String getJDBCUser(){
+    	try {
+		    return ServerSettings.getSetting(JPAConstants.KEY_JDBC_USER);
+		} catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            return null;
+		}
+    }
+
+    public static String getValidationQuery(){
+    	try {
+            return ServerSettings.getSetting(JPAConstants.VALIDATION_QUERY);
+		} catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            return null;
+		}
+    }
+
+    public static String getJDBCPassword(){
+    	try {
+            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_PASSWORD);
+		} catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            return null;
+		}
+
+    }
+
+    public static String getJDBCDriver(){
+    	try {
+            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_DRIVER);
+		} catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            return null;
+		}
+    }
+}
diff --git a/custos-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml b/custos-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..9f20353
--- /dev/null
+++ b/custos-services/profile-service/profile-service-commons/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!--*
+ *
+ * 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.
+ *
+* -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+    <persistence-unit name="profile_service">
+        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+        <class>org.apache.custos.service.profile.commons.user.entities.UserProfileEntity</class>
+        <class>org.apache.custos.service.profile.commons.user.entities.NSFDemographicsEntity</class>
+        <class>org.apache.custos.service.profile.commons.user.entities.CustomizedDashboardEntity</class>
+        <class>org.apache.custos.service.profile.commons.tenant.entities.GatewayEntity</class>
+        <exclude-unlisted-classes>true</exclude-unlisted-classes>
+
+        <properties>
+            <property name="openjpa.jdbc.MappingDefaults"
+                      value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade" />
+        </properties>
+    </persistence-unit>
+</persistence>
diff --git a/custos-services/profile-service/profile-service-models/pom.xml b/custos-services/profile-service/profile-service-models/pom.xml
new file mode 100644
index 0000000..dcae7be
--- /dev/null
+++ b/custos-services/profile-service/profile-service-models/pom.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>profile-service</artifactId>
+        <groupId>org.apache.custos</groupId>
+        <version>1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>profile-service-models</artifactId>
+</project>
\ No newline at end of file
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/PasswordCredential.java b/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/PasswordCredential.java
new file mode 100644
index 0000000..7a225c7
--- /dev/null
+++ b/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/PasswordCredential.java
@@ -0,0 +1,996 @@
+/**
+ * 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.10.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.profile.models.tenant;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
+public class PasswordCredential implements org.apache.thrift.TBase<PasswordCredential, PasswordCredential._Fields>, java.io.Serializable, Cloneable, Comparable<PasswordCredential> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("PasswordCredential");
+
+  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)1);
+  private static final org.apache.thrift.protocol.TField PORTAL_USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("portalUserName", org.apache.thrift.protocol.TType.STRING, (short)2);
+  private static final org.apache.thrift.protocol.TField LOGIN_USER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("loginUserName", org.apache.thrift.protocol.TType.STRING, (short)3);
+  private static final org.apache.thrift.protocol.TField PASSWORD_FIELD_DESC = new org.apache.thrift.protocol.TField("password", org.apache.thrift.protocol.TType.STRING, (short)4);
+  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)5);
+  private static final org.apache.thrift.protocol.TField PERSISTED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("persistedTime", org.apache.thrift.protocol.TType.I64, (short)6);
+  private static final org.apache.thrift.protocol.TField TOKEN_FIELD_DESC = new org.apache.thrift.protocol.TField("token", org.apache.thrift.protocol.TType.STRING, (short)7);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new PasswordCredentialStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new PasswordCredentialTupleSchemeFactory();
+
+  private String gatewayId; // required
+  private String portalUserName; // required
+  private String loginUserName; // required
+  private String password; // required
+  private String description; // optional
+  private long persistedTime; // optional
+  private String token; // optional
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    GATEWAY_ID((short)1, "gatewayId"),
+    PORTAL_USER_NAME((short)2, "portalUserName"),
+    LOGIN_USER_NAME((short)3, "loginUserName"),
+    PASSWORD((short)4, "password"),
+    DESCRIPTION((short)5, "description"),
+    PERSISTED_TIME((short)6, "persistedTime"),
+    TOKEN((short)7, "token");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.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: // GATEWAY_ID
+          return GATEWAY_ID;
+        case 2: // PORTAL_USER_NAME
+          return PORTAL_USER_NAME;
+        case 3: // LOGIN_USER_NAME
+          return LOGIN_USER_NAME;
+        case 4: // PASSWORD
+          return PASSWORD;
+        case 5: // DESCRIPTION
+          return DESCRIPTION;
+        case 6: // PERSISTED_TIME
+          return PERSISTED_TIME;
+        case 7: // TOKEN
+          return TOKEN;
+        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
+  private static final int __PERSISTEDTIME_ISSET_ID = 0;
+  private byte __isset_bitfield = 0;
+  private static final _Fields optionals[] = {_Fields.DESCRIPTION, _Fields.PERSISTED_TIME, _Fields.TOKEN};
+  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.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.PORTAL_USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("portalUserName", org.apache.thrift.TFieldRequirementType.REQUIRED,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.LOGIN_USER_NAME, new org.apache.thrift.meta_data.FieldMetaData("loginUserName", org.apache.thrift.TFieldRequirementType.REQUIRED,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.PASSWORD, new org.apache.thrift.meta_data.FieldMetaData("password", 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.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.PERSISTED_TIME, new org.apache.thrift.meta_data.FieldMetaData("persistedTime", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.TOKEN, new org.apache.thrift.meta_data.FieldMetaData("token", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(PasswordCredential.class, metaDataMap);
+  }
+
+  public PasswordCredential() {
+  }
+
+  public PasswordCredential(
+    String gatewayId,
+    String portalUserName,
+    String loginUserName,
+    String password)
+  {
+    this();
+    this.gatewayId = gatewayId;
+    this.portalUserName = portalUserName;
+    this.loginUserName = loginUserName;
+    this.password = password;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public PasswordCredential(PasswordCredential other) {
+    __isset_bitfield = other.__isset_bitfield;
+    if (other.isSetGatewayId()) {
+      this.gatewayId = other.gatewayId;
+    }
+    if (other.isSetPortalUserName()) {
+      this.portalUserName = other.portalUserName;
+    }
+    if (other.isSetLoginUserName()) {
+      this.loginUserName = other.loginUserName;
+    }
+    if (other.isSetPassword()) {
+      this.password = other.password;
+    }
+    if (other.isSetDescription()) {
+      this.description = other.description;
+    }
+    this.persistedTime = other.persistedTime;
+    if (other.isSetToken()) {
+      this.token = other.token;
+    }
+  }
+
+  public PasswordCredential deepCopy() {
+    return new PasswordCredential(this);
+  }
+
+  @Override
+  public void clear() {
+    this.gatewayId = null;
+    this.portalUserName = null;
+    this.loginUserName = null;
+    this.password = null;
+    this.description = null;
+    setPersistedTimeIsSet(false);
+    this.persistedTime = 0;
+    this.token = null;
+  }
+
+  public String getGatewayId() {
+    return this.gatewayId;
+  }
+
+  public void setGatewayId(String gatewayId) {
+    this.gatewayId = gatewayId;
+  }
+
+  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 getPortalUserName() {
+    return this.portalUserName;
+  }
+
+  public void setPortalUserName(String portalUserName) {
+    this.portalUserName = portalUserName;
+  }
+
+  public void unsetPortalUserName() {
+    this.portalUserName = null;
+  }
+
+  /** Returns true if field portalUserName is set (has been assigned a value) and false otherwise */
+  public boolean isSetPortalUserName() {
+    return this.portalUserName != null;
+  }
+
+  public void setPortalUserNameIsSet(boolean value) {
+    if (!value) {
+      this.portalUserName = null;
+    }
+  }
+
+  public String getLoginUserName() {
+    return this.loginUserName;
+  }
+
+  public void setLoginUserName(String loginUserName) {
+    this.loginUserName = loginUserName;
+  }
+
+  public void unsetLoginUserName() {
+    this.loginUserName = null;
+  }
+
+  /** Returns true if field loginUserName is set (has been assigned a value) and false otherwise */
+  public boolean isSetLoginUserName() {
+    return this.loginUserName != null;
+  }
+
+  public void setLoginUserNameIsSet(boolean value) {
+    if (!value) {
+      this.loginUserName = null;
+    }
+  }
+
+  public String getPassword() {
+    return this.password;
+  }
+
+  public void setPassword(String password) {
+    this.password = password;
+  }
+
+  public void unsetPassword() {
+    this.password = null;
+  }
+
+  /** Returns true if field password is set (has been assigned a value) and false otherwise */
+  public boolean isSetPassword() {
+    return this.password != null;
+  }
+
+  public void setPasswordIsSet(boolean value) {
+    if (!value) {
+      this.password = null;
+    }
+  }
+
+  public String getDescription() {
+    return this.description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  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 long getPersistedTime() {
+    return this.persistedTime;
+  }
+
+  public void setPersistedTime(long persistedTime) {
+    this.persistedTime = persistedTime;
+    setPersistedTimeIsSet(true);
+  }
+
+  public void unsetPersistedTime() {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __PERSISTEDTIME_ISSET_ID);
+  }
+
+  /** Returns true if field persistedTime is set (has been assigned a value) and false otherwise */
+  public boolean isSetPersistedTime() {
+    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __PERSISTEDTIME_ISSET_ID);
+  }
+
+  public void setPersistedTimeIsSet(boolean value) {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __PERSISTEDTIME_ISSET_ID, value);
+  }
+
+  public String getToken() {
+    return this.token;
+  }
+
+  public void setToken(String token) {
+    this.token = token;
+  }
+
+  public void unsetToken() {
+    this.token = null;
+  }
+
+  /** Returns true if field token is set (has been assigned a value) and false otherwise */
+  public boolean isSetToken() {
+    return this.token != null;
+  }
+
+  public void setTokenIsSet(boolean value) {
+    if (!value) {
+      this.token = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case GATEWAY_ID:
+      if (value == null) {
+        unsetGatewayId();
+      } else {
+        setGatewayId((String)value);
+      }
+      break;
+
+    case PORTAL_USER_NAME:
+      if (value == null) {
+        unsetPortalUserName();
+      } else {
+        setPortalUserName((String)value);
+      }
+      break;
+
+    case LOGIN_USER_NAME:
+      if (value == null) {
+        unsetLoginUserName();
+      } else {
+        setLoginUserName((String)value);
+      }
+      break;
+
+    case PASSWORD:
+      if (value == null) {
+        unsetPassword();
+      } else {
+        setPassword((String)value);
+      }
+      break;
+
+    case DESCRIPTION:
+      if (value == null) {
+        unsetDescription();
+      } else {
+        setDescription((String)value);
+      }
+      break;
+
+    case PERSISTED_TIME:
+      if (value == null) {
+        unsetPersistedTime();
+      } else {
+        setPersistedTime((Long)value);
+      }
+      break;
+
+    case TOKEN:
+      if (value == null) {
+        unsetToken();
+      } else {
+        setToken((String)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case GATEWAY_ID:
+      return getGatewayId();
+
+    case PORTAL_USER_NAME:
+      return getPortalUserName();
+
+    case LOGIN_USER_NAME:
+      return getLoginUserName();
+
+    case PASSWORD:
+      return getPassword();
+
+    case DESCRIPTION:
+      return getDescription();
+
+    case PERSISTED_TIME:
+      return getPersistedTime();
+
+    case TOKEN:
+      return getToken();
+
+    }
+    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 GATEWAY_ID:
+      return isSetGatewayId();
+    case PORTAL_USER_NAME:
+      return isSetPortalUserName();
+    case LOGIN_USER_NAME:
+      return isSetLoginUserName();
+    case PASSWORD:
+      return isSetPassword();
+    case DESCRIPTION:
+      return isSetDescription();
+    case PERSISTED_TIME:
+      return isSetPersistedTime();
+    case TOKEN:
+      return isSetToken();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof PasswordCredential)
+      return this.equals((PasswordCredential)that);
+    return false;
+  }
+
+  public boolean equals(PasswordCredential that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    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_portalUserName = true && this.isSetPortalUserName();
+    boolean that_present_portalUserName = true && that.isSetPortalUserName();
+    if (this_present_portalUserName || that_present_portalUserName) {
+      if (!(this_present_portalUserName && that_present_portalUserName))
+        return false;
+      if (!this.portalUserName.equals(that.portalUserName))
+        return false;
+    }
+
+    boolean this_present_loginUserName = true && this.isSetLoginUserName();
+    boolean that_present_loginUserName = true && that.isSetLoginUserName();
+    if (this_present_loginUserName || that_present_loginUserName) {
+      if (!(this_present_loginUserName && that_present_loginUserName))
+        return false;
+      if (!this.loginUserName.equals(that.loginUserName))
+        return false;
+    }
+
+    boolean this_present_password = true && this.isSetPassword();
+    boolean that_present_password = true && that.isSetPassword();
+    if (this_present_password || that_present_password) {
+      if (!(this_present_password && that_present_password))
+        return false;
+      if (!this.password.equals(that.password))
+        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_persistedTime = true && this.isSetPersistedTime();
+    boolean that_present_persistedTime = true && that.isSetPersistedTime();
+    if (this_present_persistedTime || that_present_persistedTime) {
+      if (!(this_present_persistedTime && that_present_persistedTime))
+        return false;
+      if (this.persistedTime != that.persistedTime)
+        return false;
+    }
+
+    boolean this_present_token = true && this.isSetToken();
+    boolean that_present_token = true && that.isSetToken();
+    if (this_present_token || that_present_token) {
+      if (!(this_present_token && that_present_token))
+        return false;
+      if (!this.token.equals(that.token))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetGatewayId()) ? 131071 : 524287);
+    if (isSetGatewayId())
+      hashCode = hashCode * 8191 + gatewayId.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetPortalUserName()) ? 131071 : 524287);
+    if (isSetPortalUserName())
+      hashCode = hashCode * 8191 + portalUserName.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetLoginUserName()) ? 131071 : 524287);
+    if (isSetLoginUserName())
+      hashCode = hashCode * 8191 + loginUserName.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetPassword()) ? 131071 : 524287);
+    if (isSetPassword())
+      hashCode = hashCode * 8191 + password.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetDescription()) ? 131071 : 524287);
+    if (isSetDescription())
+      hashCode = hashCode * 8191 + description.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetPersistedTime()) ? 131071 : 524287);
+    if (isSetPersistedTime())
+      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(persistedTime);
+
+    hashCode = hashCode * 8191 + ((isSetToken()) ? 131071 : 524287);
+    if (isSetToken())
+      hashCode = hashCode * 8191 + token.hashCode();
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(PasswordCredential other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    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(isSetPortalUserName()).compareTo(other.isSetPortalUserName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetPortalUserName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.portalUserName, other.portalUserName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetLoginUserName()).compareTo(other.isSetLoginUserName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetLoginUserName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.loginUserName, other.loginUserName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetPassword()).compareTo(other.isSetPassword());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetPassword()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.password, other.password);
+      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;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetPersistedTime()).compareTo(other.isSetPersistedTime());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetPersistedTime()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.persistedTime, other.persistedTime);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetToken()).compareTo(other.isSetToken());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetToken()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.token, other.token);
+      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 {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("PasswordCredential(");
+    boolean first = true;
+
+    sb.append("gatewayId:");
+    if (this.gatewayId == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.gatewayId);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("portalUserName:");
+    if (this.portalUserName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.portalUserName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("loginUserName:");
+    if (this.loginUserName == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.loginUserName);
+    }
+    first = false;
+    if (!first) sb.append(", ");
+    sb.append("password:");
+    if (this.password == null) {
+      sb.append("null");
+    } else {
+      sb.append(this.password);
+    }
+    first = false;
+    if (isSetDescription()) {
+      if (!first) sb.append(", ");
+      sb.append("description:");
+      if (this.description == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.description);
+      }
+      first = false;
+    }
+    if (isSetPersistedTime()) {
+      if (!first) sb.append(", ");
+      sb.append("persistedTime:");
+      sb.append(this.persistedTime);
+      first = false;
+    }
+    if (isSetToken()) {
+      if (!first) sb.append(", ");
+      sb.append("token:");
+      if (this.token == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.token);
+      }
+      first = false;
+    }
+    sb.append(")");
+    return sb.toString();
+  }
+
+  public void validate() throws org.apache.thrift.TException {
+    // check for required fields
+    if (!isSetGatewayId()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'gatewayId' is unset! Struct:" + toString());
+    }
+
+    if (!isSetPortalUserName()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'portalUserName' is unset! Struct:" + toString());
+    }
+
+    if (!isSetLoginUserName()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'loginUserName' is unset! Struct:" + toString());
+    }
+
+    if (!isSetPassword()) {
+      throw new org.apache.thrift.protocol.TProtocolException("Required field 'password' is unset! Struct:" + toString());
+    }
+
+    // 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 {
+      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
+      __isset_bitfield = 0;
+      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 PasswordCredentialStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public PasswordCredentialStandardScheme getScheme() {
+      return new PasswordCredentialStandardScheme();
+    }
+  }
+
+  private static class PasswordCredentialStandardScheme extends org.apache.thrift.scheme.StandardScheme<PasswordCredential> {
+
+    public void read(org.apache.thrift.protocol.TProtocol iprot, PasswordCredential 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: // 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 2: // PORTAL_USER_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.portalUserName = iprot.readString();
+              struct.setPortalUserNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 3: // LOGIN_USER_NAME
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.loginUserName = iprot.readString();
+              struct.setLoginUserNameIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 4: // PASSWORD
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.password = iprot.readString();
+              struct.setPasswordIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 5: // 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 6: // PERSISTED_TIME
+            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
+              struct.persistedTime = iprot.readI64();
+              struct.setPersistedTimeIsSet(true);
+            } else { 
+              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
+            }
+            break;
+          case 7: // TOKEN
+            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+              struct.token = iprot.readString();
+              struct.setTokenIsSet(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();
+      struct.validate();
+    }
+
+    public void write(org.apache.thrift.protocol.TProtocol oprot, PasswordCredential struct) throws org.apache.thrift.TException {
+      struct.validate();
+
+      oprot.writeStructBegin(STRUCT_DESC);
+      if (struct.gatewayId != null) {
+        oprot.writeFieldBegin(GATEWAY_ID_FIELD_DESC);
+        oprot.writeString(struct.gatewayId);
+        oprot.writeFieldEnd();
+      }
+      if (struct.portalUserName != null) {
+        oprot.writeFieldBegin(PORTAL_USER_NAME_FIELD_DESC);
+        oprot.writeString(struct.portalUserName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.loginUserName != null) {
+        oprot.writeFieldBegin(LOGIN_USER_NAME_FIELD_DESC);
+        oprot.writeString(struct.loginUserName);
+        oprot.writeFieldEnd();
+      }
+      if (struct.password != null) {
+        oprot.writeFieldBegin(PASSWORD_FIELD_DESC);
+        oprot.writeString(struct.password);
+        oprot.writeFieldEnd();
+      }
+      if (struct.description != null) {
+        if (struct.isSetDescription()) {
+          oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC);
+          oprot.writeString(struct.description);
+          oprot.writeFieldEnd();
+        }
+      }
+      if (struct.isSetPersistedTime()) {
+        oprot.writeFieldBegin(PERSISTED_TIME_FIELD_DESC);
+        oprot.writeI64(struct.persistedTime);
+        oprot.writeFieldEnd();
+      }
+      if (struct.token != null) {
+        if (struct.isSetToken()) {
+          oprot.writeFieldBegin(TOKEN_FIELD_DESC);
+          oprot.writeString(struct.token);
+          oprot.writeFieldEnd();
+        }
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+  }
+
+  private static class PasswordCredentialTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
+    public PasswordCredentialTupleScheme getScheme() {
+      return new PasswordCredentialTupleScheme();
+    }
+  }
+
+  private static class PasswordCredentialTupleScheme extends org.apache.thrift.scheme.TupleScheme<PasswordCredential> {
+
+    @Override
+    public void write(org.apache.thrift.protocol.TProtocol prot, PasswordCredential struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      oprot.writeString(struct.gatewayId);
+      oprot.writeString(struct.portalUserName);
+      oprot.writeString(struct.loginUserName);
+      oprot.writeString(struct.password);
+      java.util.BitSet optionals = new java.util.BitSet();
+      if (struct.isSetDescription()) {
+        optionals.set(0);
+      }
+      if (struct.isSetPersistedTime()) {
+        optionals.set(1);
+      }
+      if (struct.isSetToken()) {
+        optionals.set(2);
+      }
+      oprot.writeBitSet(optionals, 3);
+      if (struct.isSetDescription()) {
+        oprot.writeString(struct.description);
+      }
+      if (struct.isSetPersistedTime()) {
+        oprot.writeI64(struct.persistedTime);
+      }
+      if (struct.isSetToken()) {
+        oprot.writeString(struct.token);
+      }
+    }
+
+    @Override
+    public void read(org.apache.thrift.protocol.TProtocol prot, PasswordCredential struct) throws org.apache.thrift.TException {
+      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
+      struct.gatewayId = iprot.readString();
+      struct.setGatewayIdIsSet(true);
+      struct.portalUserName = iprot.readString();
+      struct.setPortalUserNameIsSet(true);
+      struct.loginUserName = iprot.readString();
+      struct.setLoginUserNameIsSet(true);
+      struct.password = iprot.readString();
+      struct.setPasswordIsSet(true);
+      java.util.BitSet incoming = iprot.readBitSet(3);
+      if (incoming.get(0)) {
+        struct.description = iprot.readString();
+        struct.setDescriptionIsSet(true);
+      }
+      if (incoming.get(1)) {
+        struct.persistedTime = iprot.readI64();
+        struct.setPersistedTimeIsSet(true);
+      }
+      if (incoming.get(2)) {
+        struct.token = iprot.readString();
+        struct.setTokenIsSet(true);
+      }
+    }
+  }
+
+  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
+    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+  }
+}
+
diff --git a/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/Tenant.java b/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/Tenant.java
new file mode 100644
index 0000000..68b6bfd
--- /dev/null
+++ b/custos-services/profile-service/profile-service-models/src/main/java/org/apache/custos/profile/models/tenant/Tenant.java
@@ -0,0 +1,1543 @@
+/**
+ * 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.10.0)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ *  @generated
+ */
+package org.apache.custos.profile.models.tenant;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.10.0)")
+public class Tenant implements org.apache.thrift.TBase<Tenant, Tenant._Fields>, java.io.Serializable, Cloneable, Comparable<Tenant> {
+  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Tenant");
+
+  private static final org.apache.thrift.protocol.TField TENANT_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantId", org.apache.thrift.protocol.TType.STRING, (short)1);
+  private static final org.apache.thrift.protocol.TField TENANT_APPROVAL_STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantApprovalStatus", org.apache.thrift.protocol.TType.I32, (short)2);
+  private static final org.apache.thrift.protocol.TField TENANT_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantName", org.apache.thrift.protocol.TType.STRING, (short)3);
+  private static final org.apache.thrift.protocol.TField DOMAIN_FIELD_DESC = new org.apache.thrift.protocol.TField("domain", org.apache.thrift.protocol.TType.STRING, (short)4);
+  private static final org.apache.thrift.protocol.TField EMAIL_ADDRESS_FIELD_DESC = new org.apache.thrift.protocol.TField("emailAddress", org.apache.thrift.protocol.TType.STRING, (short)5);
+  private static final org.apache.thrift.protocol.TField TENANT_ACRONYM_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantAcronym", org.apache.thrift.protocol.TType.STRING, (short)6);
+  private static final org.apache.thrift.protocol.TField TENANT_URL_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantURL", org.apache.thrift.protocol.TType.STRING, (short)7);
+  private static final org.apache.thrift.protocol.TField TENANT_PUBLIC_ABSTRACT_FIELD_DESC = new org.apache.thrift.protocol.TField("tenantPublicAbstract", org.apache.thrift.protocol.TType.STRING, (short)8);
+  private static final org.apache.thrift.protocol.TField REVIEW_PROPOSAL_DESCRIPTION_FIELD_DESC = new org.apache.thrift.protocol.TField("reviewProposalDescription", org.apache.thrift.protocol.TType.STRING, (short)9);
+  private static final org.apache.thrift.protocol.TField DECLINED_REASON_FIELD_DESC = new org.apache.thrift.protocol.TField("declinedReason", org.apache.thrift.protocol.TType.STRING, (short)15);
+  private static final org.apache.thrift.protocol.TField REQUEST_CREATION_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("requestCreationTime", org.apache.thrift.protocol.TType.I64, (short)18);
+  private static final org.apache.thrift.protocol.TField REQUESTER_USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("requesterUsername", org.apache.thrift.protocol.TType.STRING, (short)19);
+
+  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TenantStandardSchemeFactory();
+  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TenantTupleSchemeFactory();
+
+  private String tenantId; // required
+  private TenantApprovalStatus tenantApprovalStatus; // required
+  private String tenantName; // optional
+  private String domain; // optional
+  private String emailAddress; // optional
+  private String tenantAcronym; // optional
+  private String tenantURL; // optional
+  private String tenantPublicAbstract; // optional
+  private String reviewProposalDescription; // optional
+  private String declinedReason; // optional
+  private long requestCreationTime; // optional
+  private String requesterUsername; // optional
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+    TENANT_ID((short)1, "tenantId"),
+    /**
+     *
+     * @see TenantApprovalStatus
+     */
+    TENANT_APPROVAL_STATUS((short)2, "tenantApprovalStatus"),
+    TENANT_NAME((short)3, "tenantName"),
+    DOMAIN((short)4, "domain"),
+    EMAIL_ADDRESS((short)5, "emailAddress"),
+    TENANT_ACRONYM((short)6, "tenantAcronym"),
+    TENANT_URL((short)7, "tenantURL"),
+    TENANT_PUBLIC_ABSTRACT((short)8, "tenantPublicAbstract"),
+    REVIEW_PROPOSAL_DESCRIPTION((short)9, "reviewProposalDescription"),
+    DECLINED_REASON((short)15, "declinedReason"),
+    REQUEST_CREATION_TIME((short)18, "requestCreationTime"),
+    REQUESTER_USERNAME((short)19, "requesterUsername");
+
+    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : java.util.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: // TENANT_ID
+          return TENANT_ID;
+        case 2: // TENANT_APPROVAL_STATUS
+          return TENANT_APPROVAL_STATUS;
+        case 3: // TENANT_NAME
+          return TENANT_NAME;
+        case 4: // DOMAIN
+          return DOMAIN;
+        case 5: // EMAIL_ADDRESS
+          return EMAIL_ADDRESS;
+        case 6: // TENANT_ACRONYM
+          return TENANT_ACRONYM;
+        case 7: // TENANT_URL
+          return TENANT_URL;
+        case 8: // TENANT_PUBLIC_ABSTRACT
+          return TENANT_PUBLIC_ABSTRACT;
+        case 9: // REVIEW_PROPOSAL_DESCRIPTION
+          return REVIEW_PROPOSAL_DESCRIPTION;
+        case 15: // DECLINED_REASON
+          return DECLINED_REASON;
+        case 18: // REQUEST_CREATION_TIME
+          return REQUEST_CREATION_TIME;
+        case 19: // REQUESTER_USERNAME
+          return REQUESTER_USERNAME;
+        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
+  private static final int __REQUESTCREATIONTIME_ISSET_ID = 0;
+  private byte __isset_bitfield = 0;
+  private static final _Fields optionals[] = {_Fields.TENANT_NAME, _Fields.DOMAIN, _Fields.EMAIL_ADDRESS, _Fields.TENANT_ACRONYM, _Fields.TENANT_URL, _Fields.TENANT_PUBLIC_ABSTRACT, _Fields.REVIEW_PROPOSAL_DESCRIPTION, _Fields.DECLINED_REASON, _Fields.REQUEST_CREATION_TIME, _Fields.REQUESTER_USERNAME};
+  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
+  static {
+    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.TENANT_ID, new org.apache.thrift.meta_data.FieldMetaData("tenantId", org.apache.thrift.TFieldRequirementType.REQUIRED,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.TENANT_APPROVAL_STATUS, new org.apache.thrift.meta_data.FieldMetaData("tenantApprovalStatus", org.apache.thrift.TFieldRequirementType.REQUIRED,
+        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TenantApprovalStatus.class)));
+    tmpMap.put(_Fields.TENANT_NAME, new org.apache.thrift.meta_data.FieldMetaData("tenantName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.DOMAIN, new org.apache.thrift.meta_data.FieldMetaData("domain", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.EMAIL_ADDRESS, new org.apache.thrift.meta_data.FieldMetaData("emailAddress", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.TENANT_ACRONYM, new org.apache.thrift.meta_data.FieldMetaData("tenantAcronym", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.TENANT_URL, new org.apache.thrift.meta_data.FieldMetaData("tenantURL", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.TENANT_PUBLIC_ABSTRACT, new org.apache.thrift.meta_data.FieldMetaData("tenantPublicAbstract", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.REVIEW_PROPOSAL_DESCRIPTION, new org.apache.thrift.meta_data.FieldMetaData("reviewProposalDescription", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.DECLINED_REASON, new org.apache.thrift.meta_data.FieldMetaData("declinedReason", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    tmpMap.put(_Fields.REQUEST_CREATION_TIME, new org.apache.thrift.meta_data.FieldMetaData("requestCreationTime", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+    tmpMap.put(_Fields.REQUESTER_USERNAME, new org.apache.thrift.meta_data.FieldMetaData("requesterUsername", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
+    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Tenant.class, metaDataMap);
+  }
+
+  public Tenant() {
+  }
+
+  public Tenant(
+    String tenantId,
+    TenantApprovalStatus tenantApprovalStatus)
+  {
+    this();
+    this.tenantId = tenantId;
+    this.tenantApprovalStatus = tenantApprovalStatus;
+  }
+
+  /**
+   * Performs a deep copy on <i>other</i>.
+   */
+  public Tenant(Tenant other) {
+    __isset_bitfield = other.__isset_bitfield;
+    if (other.isSetTenantId()) {
+      this.tenantId = other.tenantId;
+    }
+    if (other.isSetTenantApprovalStatus()) {
+      this.tenantApprovalStatus = other.tenantApprovalStatus;
+    }
+    if (other.isSetTenantName()) {
+      this.tenantName = other.tenantName;
+    }
+    if (other.isSetDomain()) {
+      this.domain = other.domain;
+    }
+    if (other.isSetEmailAddress()) {
+      this.emailAddress = other.emailAddress;
+    }
+    if (other.isSetTenantAcronym()) {
+      this.tenantAcronym = other.tenantAcronym;
+    }
+    if (other.isSetTenantURL()) {
+      this.tenantURL = other.tenantURL;
+    }
+    if (other.isSetTenantPublicAbstract()) {
+      this.tenantPublicAbstract = other.tenantPublicAbstract;
+    }
+    if (other.isSetReviewProposalDescription()) {
+      this.reviewProposalDescription = other.reviewProposalDescription;
+    }
+    if (other.isSetDeclinedReason()) {
+      this.declinedReason = other.declinedReason;
+    }
+    this.requestCreationTime = other.requestCreationTime;
+    if (other.isSetRequesterUsername()) {
+      this.requesterUsername = other.requesterUsername;
+    }
+  }
+
+  public Tenant deepCopy() {
+    return new Tenant(this);
+  }
+
+  @Override
+  public void clear() {
+    this.tenantId = null;
+    this.tenantApprovalStatus = null;
+    this.tenantName = null;
+    this.domain = null;
+    this.emailAddress = null;
+    this.tenantAcronym = null;
+    this.tenantURL = null;
+    this.tenantPublicAbstract = null;
+    this.reviewProposalDescription = null;
+    this.declinedReason = null;
+    setRequestCreationTimeIsSet(false);
+    this.requestCreationTime = 0;
+    this.requesterUsername = null;
+  }
+
+  public String getTenantId() {
+    return this.tenantId;
+  }
+
+  public void setTenantId(String tenantId) {
+    this.tenantId = tenantId;
+  }
+
+  public void unsetTenantId() {
+    this.tenantId = null;
+  }
+
+  /** Returns true if field tenantId is set (has been assigned a value) and false otherwise */
+  public boolean isSetTenantId() {
+    return this.tenantId != null;
+  }
+
+  public void setTenantIdIsSet(boolean value) {
+    if (!value) {
+      this.tenantId = null;
+    }
+  }
+
+  /**
+   *
+   * @see TenantApprovalStatus
+   */
+  public TenantApprovalStatus getTenantApprovalStatus() {
+    return this.tenantApprovalStatus;
+  }
+
+  /**
+   *
+   * @see TenantApprovalStatus
+   */
+  public void setTenantApprovalStatus(TenantApprovalStatus tenantApprovalStatus) {
+    this.tenantApprovalStatus = tenantApprovalStatus;
+  }
+
+  public void unsetTenantApprovalStatus() {
+    this.tenantApprovalStatus = null;
+  }
+
+  /** Returns true if field tenantApprovalStatus is set (has been assigned a value) and false otherwise */
+  public boolean isSetTenantApprovalStatus() {
+    return this.tenantApprovalStatus != null;
+  }
+
+  public void setTenantApprovalStatusIsSet(boolean value) {
+    if (!value) {
+      this.tenantApprovalStatus = null;
+    }
+  }
+
+  public String getTenantName() {
+    return this.tenantName;
+  }
+
+  public void setTenantName(String tenantName) {
+    this.tenantName = tenantName;
+  }
+
+  public void unsetTenantName() {
+    this.tenantName = null;
+  }
+
+  /** Returns true if field tenantName is set (has been assigned a value) and false otherwise */
+  public boolean isSetTenantName() {
+    return this.tenantName != null;
+  }
+
+  public void setTenantNameIsSet(boolean value) {
+    if (!value) {
+      this.tenantName = null;
+    }
+  }
+
+  public String getDomain() {
+    return this.domain;
+  }
+
+  public void setDomain(String domain) {
+    this.domain = domain;
+  }
+
+  public void unsetDomain() {
+    this.domain = null;
+  }
+
+  /** Returns true if field domain is set (has been assigned a value) and false otherwise */
+  public boolean isSetDomain() {
+    return this.domain != null;
+  }
+
+  public void setDomainIsSet(boolean value) {
+    if (!value) {
+      this.domain = null;
+    }
+  }
+
+  public String getEmailAddress() {
+    return this.emailAddress;
+  }
+
+  public void setEmailAddress(String emailAddress) {
+    this.emailAddress = emailAddress;
+  }
+
+  public void unsetEmailAddress() {
+    this.emailAddress = null;
+  }
+
+  /** Returns true if field emailAddress is set (has been assigned a value) and false otherwise */
+  public boolean isSetEmailAddress() {
+    return this.emailAddress != null;
+  }
+
+  public void setEmailAddressIsSet(boolean value) {
+    if (!value) {
+      this.emailAddress = null;
+    }
+  }
+
+  public String getTenantAcronym() {
+    return this.tenantAcronym;
+  }
+
+  public void setTenantAcronym(String tenantAcronym) {
+    this.tenantAcronym = tenantAcronym;
+  }
+
+  public void unsetTenantAcronym() {
+    this.tenantAcronym = null;
+  }
+
+  /** Returns true if field tenantAcronym is set (has been assigned a value) and false otherwise */
+  public boolean isSetTenantAcronym() {
+    return this.tenantAcronym != null;
+  }
+
+  public void setTenantAcronymIsSet(boolean value) {
+    if (!value) {
+      this.tenantAcronym = null;
+    }
+  }
+
+  public String getTenantURL() {
+    return this.tenantURL;
+  }
+
+  public void setTenantURL(String tenantURL) {
+    this.tenantURL = tenantURL;
+  }
+
+  public void unsetTenantURL() {
+    this.tenantURL = null;
+  }
+
+  /** Returns true if field tenantURL is set (has been assigned a value) and false otherwise */
+  public boolean isSetTenantURL() {
+    return this.tenantURL != null;
+  }
+
+  public void setTenantURLIsSet(boolean value) {
+    if (!value) {
+      this.tenantURL = null;
+    }
+  }
+
+  public String getTenantPublicAbstract() {
+    return this.tenantPublicAbstract;
+  }
+
+  public void setTenantPublicAbstract(String tenantPublicAbstract) {
+    this.tenantPublicAbstract = tenantPublicAbstract;
+  }
+
+  public void unsetTenantPublicAbstract() {
+    this.tenantPublicAbstract = null;
+  }
+
+  /** Returns true if field tenantPublicAbstract is set (has been assigned a value) and false otherwise */
+  public boolean isSetTenantPublicAbstract() {
+    return this.tenantPublicAbstract != null;
+  }
+
+  public void setTenantPublicAbstractIsSet(boolean value) {
+    if (!value) {
+      this.tenantPublicAbstract = null;
+    }
+  }
+
+  public String getReviewProposalDescription() {
+    return this.reviewProposalDescription;
+  }
+
+  public void setReviewProposalDescription(String reviewProposalDescription) {
+    this.reviewProposalDescription = reviewProposalDescription;
+  }
+
+  public void unsetReviewProposalDescription() {
+    this.reviewProposalDescription = null;
+  }
+
+  /** Returns true if field reviewProposalDescription is set (has been assigned a value) and false otherwise */
+  public boolean isSetReviewProposalDescription() {
+    return this.reviewProposalDescription != null;
+  }
+
+  public void setReviewProposalDescriptionIsSet(boolean value) {
+    if (!value) {
+      this.reviewProposalDescription = null;
+    }
+  }
+
+  public String getDeclinedReason() {
+    return this.declinedReason;
+  }
+
+  public void setDeclinedReason(String declinedReason) {
+    this.declinedReason = declinedReason;
+  }
+
+  public void unsetDeclinedReason() {
+    this.declinedReason = null;
+  }
+
+  /** Returns true if field declinedReason is set (has been assigned a value) and false otherwise */
+  public boolean isSetDeclinedReason() {
+    return this.declinedReason != null;
+  }
+
+  public void setDeclinedReasonIsSet(boolean value) {
+    if (!value) {
+      this.declinedReason = null;
+    }
+  }
+
+  public long getRequestCreationTime() {
+    return this.requestCreationTime;
+  }
+
+  public void setRequestCreationTime(long requestCreationTime) {
+    this.requestCreationTime = requestCreationTime;
+    setRequestCreationTimeIsSet(true);
+  }
+
+  public void unsetRequestCreationTime() {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __REQUESTCREATIONTIME_ISSET_ID);
+  }
+
+  /** Returns true if field requestCreationTime is set (has been assigned a value) and false otherwise */
+  public boolean isSetRequestCreationTime() {
+    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __REQUESTCREATIONTIME_ISSET_ID);
+  }
+
+  public void setRequestCreationTimeIsSet(boolean value) {
+    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __REQUESTCREATIONTIME_ISSET_ID, value);
+  }
+
+  public String getRequesterUsername() {
+    return this.requesterUsername;
+  }
+
+  public void setRequesterUsername(String requesterUsername) {
+    this.requesterUsername = requesterUsername;
+  }
+
+  public void unsetRequesterUsername() {
+    this.requesterUsername = null;
+  }
+
+  /** Returns true if field requesterUsername is set (has been assigned a value) and false otherwise */
+  public boolean isSetRequesterUsername() {
+    return this.requesterUsername != null;
+  }
+
+  public void setRequesterUsernameIsSet(boolean value) {
+    if (!value) {
+      this.requesterUsername = null;
+    }
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
+    case TENANT_ID:
+      if (value == null) {
+        unsetTenantId();
+      } else {
+        setTenantId((String)value);
+      }
+      break;
+
+    case TENANT_APPROVAL_STATUS:
+      if (value == null) {
+        unsetTenantApprovalStatus();
+      } else {
+        setTenantApprovalStatus((TenantApprovalStatus)value);
+      }
+      break;
+
+    case TENANT_NAME:
+      if (value == null) {
+        unsetTenantName();
+      } else {
+        setTenantName((String)value);
+      }
+      break;
+
+    case DOMAIN:
+      if (value == null) {
+        unsetDomain();
+      } else {
+        setDomain((String)value);
+      }
+      break;
+
+    case EMAIL_ADDRESS:
+      if (value == null) {
+        unsetEmailAddress();
+      } else {
+        setEmailAddress((String)value);
+      }
+      break;
+
+    case TENANT_ACRONYM:
+      if (value == null) {
+        unsetTenantAcronym();
+      } else {
+        setTenantAcronym((String)value);
+      }
+      break;
+
+    case TENANT_URL:
+      if (value == null) {
+        unsetTenantURL();
+      } else {
+        setTenantURL((String)value);
+      }
+      break;
+
+    case TENANT_PUBLIC_ABSTRACT:
+      if (value == null) {
+        unsetTenantPublicAbstract();
+      } else {
+        setTenantPublicAbstract((String)value);
+      }
+      break;
+
+    case REVIEW_PROPOSAL_DESCRIPTION:
+      if (value == null) {
+        unsetReviewProposalDescription();
+      } else {
+        setReviewProposalDescription((String)value);
+      }
+      break;
+
+    case DECLINED_REASON:
+      if (value == null) {
+        unsetDeclinedReason();
+      } else {
+        setDeclinedReason((String)value);
+      }
+      break;
+
+    case REQUEST_CREATION_TIME:
+      if (value == null) {
+        unsetRequestCreationTime();
+      } else {
+        setRequestCreationTime((Long)value);
+      }
+      break;
+
+    case REQUESTER_USERNAME:
+      if (value == null) {
+        unsetRequesterUsername();
+      } else {
+        setRequesterUsername((String)value);
+      }
+      break;
+
+    }
+  }
+
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
+    case TENANT_ID:
+      return getTenantId();
+
+    case TENANT_APPROVAL_STATUS:
+      return getTenantApprovalStatus();
+
+    case TENANT_NAME:
+      return getTenantName();
+
+    case DOMAIN:
+      return getDomain();
+
+    case EMAIL_ADDRESS:
+      return getEmailAddress();
+
+    case TENANT_ACRONYM:
+      return getTenantAcronym();
+
+    case TENANT_URL:
+      return getTenantURL();
+
+    case TENANT_PUBLIC_ABSTRACT:
+      return getTenantPublicAbstract();
+
+    case REVIEW_PROPOSAL_DESCRIPTION:
+      return getReviewProposalDescription();
+
+    case DECLINED_REASON:
+      return getDeclinedReason();
+
+    case REQUEST_CREATION_TIME:
+      return getRequestCreationTime();
+
+    case REQUESTER_USERNAME:
+      return getRequesterUsername();
+
+    }
+    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 TENANT_ID:
+      return isSetTenantId();
+    case TENANT_APPROVAL_STATUS:
+      return isSetTenantApprovalStatus();
+    case TENANT_NAME:
+      return isSetTenantName();
+    case DOMAIN:
+      return isSetDomain();
+    case EMAIL_ADDRESS:
+      return isSetEmailAddress();
+    case TENANT_ACRONYM:
+      return isSetTenantAcronym();
+    case TENANT_URL:
+      return isSetTenantURL();
+    case TENANT_PUBLIC_ABSTRACT:
+      return isSetTenantPublicAbstract();
+    case REVIEW_PROPOSAL_DESCRIPTION:
+      return isSetReviewProposalDescription();
+    case DECLINED_REASON:
+      return isSetDeclinedReason();
+    case REQUEST_CREATION_TIME:
+      return isSetRequestCreationTime();
+    case REQUESTER_USERNAME:
+      return isSetRequesterUsername();
+    }
+    throw new IllegalStateException();
+  }
+
+  @Override
+  public boolean equals(Object that) {
+    if (that == null)
+      return false;
+    if (that instanceof Tenant)
+      return this.equals((Tenant)that);
+    return false;
+  }
+
+  public boolean equals(Tenant that) {
+    if (that == null)
+      return false;
+    if (this == that)
+      return true;
+
+    boolean this_present_tenantId = true && this.isSetTenantId();
+    boolean that_present_tenantId = true && that.isSetTenantId();
+    if (this_present_tenantId || that_present_tenantId) {
+      if (!(this_present_tenantId && that_present_tenantId))
+        return false;
+      if (!this.tenantId.equals(that.tenantId))
+        return false;
+    }
+
+    boolean this_present_tenantApprovalStatus = true && this.isSetTenantApprovalStatus();
+    boolean that_present_tenantApprovalStatus = true && that.isSetTenantApprovalStatus();
+    if (this_present_tenantApprovalStatus || that_present_tenantApprovalStatus) {
+      if (!(this_present_tenantApprovalStatus && that_present_tenantApprovalStatus))
+        return false;
+      if (!this.tenantApprovalStatus.equals(that.tenantApprovalStatus))
+        return false;
+    }
+
+    boolean this_present_tenantName = true && this.isSetTenantName();
+    boolean that_present_tenantName = true && that.isSetTenantName();
+    if (this_present_tenantName || that_present_tenantName) {
+      if (!(this_present_tenantName && that_present_tenantName))
+        return false;
+      if (!this.tenantName.equals(that.tenantName))
+        return false;
+    }
+
+    boolean this_present_domain = true && this.isSetDomain();
+    boolean that_present_domain = true && that.isSetDomain();
+    if (this_present_domain || that_present_domain) {
+      if (!(this_present_domain && that_present_domain))
+        return false;
+      if (!this.domain.equals(that.domain))
+        return false;
+    }
+
+    boolean this_present_emailAddress = true && this.isSetEmailAddress();
+    boolean that_present_emailAddress = true && that.isSetEmailAddress();
+    if (this_present_emailAddress || that_present_emailAddress) {
+      if (!(this_present_emailAddress && that_present_emailAddress))
+        return false;
+      if (!this.emailAddress.equals(that.emailAddress))
+        return false;
+    }
+
+    boolean this_present_tenantAcronym = true && this.isSetTenantAcronym();
+    boolean that_present_tenantAcronym = true && that.isSetTenantAcronym();
+    if (this_present_tenantAcronym || that_present_tenantAcronym) {
+      if (!(this_present_tenantAcronym && that_present_tenantAcronym))
+        return false;
+      if (!this.tenantAcronym.equals(that.tenantAcronym))
+        return false;
+    }
+
+    boolean this_present_tenantURL = true && this.isSetTenantURL();
+    boolean that_present_tenantURL = true && that.isSetTenantURL();
+    if (this_present_tenantURL || that_present_tenantURL) {
+      if (!(this_present_tenantURL && that_present_tenantURL))
+        return false;
+      if (!this.tenantURL.equals(that.tenantURL))
+        return false;
+    }
+
+    boolean this_present_tenantPublicAbstract = true && this.isSetTenantPublicAbstract();
+    boolean that_present_tenantPublicAbstract = true && that.isSetTenantPublicAbstract();
+    if (this_present_tenantPublicAbstract || that_present_tenantPublicAbstract) {
+      if (!(this_present_tenantPublicAbstract && that_present_tenantPublicAbstract))
+        return false;
+      if (!this.tenantPublicAbstract.equals(that.tenantPublicAbstract))
+        return false;
+    }
+
+    boolean this_present_reviewProposalDescription = true && this.isSetReviewProposalDescription();
+    boolean that_present_reviewProposalDescription = true && that.isSetReviewProposalDescription();
+    if (this_present_reviewProposalDescription || that_present_reviewProposalDescription) {
+      if (!(this_present_reviewProposalDescription && that_present_reviewProposalDescription))
+        return false;
+      if (!this.reviewProposalDescription.equals(that.reviewProposalDescription))
+        return false;
+    }
+
+    boolean this_present_declinedReason = true && this.isSetDeclinedReason();
+    boolean that_present_declinedReason = true && that.isSetDeclinedReason();
+    if (this_present_declinedReason || that_present_declinedReason) {
+      if (!(this_present_declinedReason && that_present_declinedReason))
+        return false;
+      if (!this.declinedReason.equals(that.declinedReason))
+        return false;
+    }
+
+    boolean this_present_requestCreationTime = true && this.isSetRequestCreationTime();
+    boolean that_present_requestCreationTime = true && that.isSetRequestCreationTime();
+    if (this_present_requestCreationTime || that_present_requestCreationTime) {
+      if (!(this_present_requestCreationTime && that_present_requestCreationTime))
+        return false;
+      if (this.requestCreationTime != that.requestCreationTime)
+        return false;
+    }
+
+    boolean this_present_requesterUsername = true && this.isSetRequesterUsername();
+    boolean that_present_requesterUsername = true && that.isSetRequesterUsername();
+    if (this_present_requesterUsername || that_present_requesterUsername) {
+      if (!(this_present_requesterUsername && that_present_requesterUsername))
+        return false;
+      if (!this.requesterUsername.equals(that.requesterUsername))
+        return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int hashCode = 1;
+
+    hashCode = hashCode * 8191 + ((isSetTenantId()) ? 131071 : 524287);
+    if (isSetTenantId())
+      hashCode = hashCode * 8191 + tenantId.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetTenantApprovalStatus()) ? 131071 : 524287);
+    if (isSetTenantApprovalStatus())
+      hashCode = hashCode * 8191 + tenantApprovalStatus.getValue();
+
+    hashCode = hashCode * 8191 + ((isSetTenantName()) ? 131071 : 524287);
+    if (isSetTenantName())
+      hashCode = hashCode * 8191 + tenantName.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetDomain()) ? 131071 : 524287);
+    if (isSetDomain())
+      hashCode = hashCode * 8191 + domain.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetEmailAddress()) ? 131071 : 524287);
+    if (isSetEmailAddress())
+      hashCode = hashCode * 8191 + emailAddress.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetTenantAcronym()) ? 131071 : 524287);
+    if (isSetTenantAcronym())
+      hashCode = hashCode * 8191 + tenantAcronym.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetTenantURL()) ? 131071 : 524287);
+    if (isSetTenantURL())
+      hashCode = hashCode * 8191 + tenantURL.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetTenantPublicAbstract()) ? 131071 : 524287);
+    if (isSetTenantPublicAbstract())
+      hashCode = hashCode * 8191 + tenantPublicAbstract.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetReviewProposalDescription()) ? 131071 : 524287);
+    if (isSetReviewProposalDescription())
+      hashCode = hashCode * 8191 + reviewProposalDescription.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetDeclinedReason()) ? 131071 : 524287);
+    if (isSetDeclinedReason())
+      hashCode = hashCode * 8191 + declinedReason.hashCode();
+
+    hashCode = hashCode * 8191 + ((isSetRequestCreationTime()) ? 131071 : 524287);
+    if (isSetRequestCreationTime())
+      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(requestCreationTime);
+
+    hashCode = hashCode * 8191 + ((isSetRequesterUsername()) ? 131071 : 524287);
+    if (isSetRequesterUsername())
+      hashCode = hashCode * 8191 + requesterUsername.hashCode();
+
+    return hashCode;
+  }
+
+  @Override
+  public int compareTo(Tenant other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+
+    lastComparison = Boolean.valueOf(isSetTenantId()).compareTo(other.isSetTenantId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetTenantId()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantId, other.tenantId);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetTenantApprovalStatus()).compareTo(other.isSetTenantApprovalStatus());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetTenantApprovalStatus()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantApprovalStatus, other.tenantApprovalStatus);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetTenantName()).compareTo(other.isSetTenantName());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetTenantName()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantName, other.tenantName);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetDomain()).compareTo(other.isSetDomain());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetDomain()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.domain, other.domain);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetEmailAddress()).compareTo(other.isSetEmailAddress());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetEmailAddress()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.emailAddress, other.emailAddress);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetTenantAcronym()).compareTo(other.isSetTenantAcronym());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetTenantAcronym()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantAcronym, other.tenantAcronym);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetTenantURL()).compareTo(other.isSetTenantURL());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetTenantURL()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantURL, other.tenantURL);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetTenantPublicAbstract()).compareTo(other.isSetTenantPublicAbstract());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetTenantPublicAbstract()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tenantPublicAbstract, other.tenantPublicAbstract);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetReviewProposalDescription()).compareTo(other.isSetReviewProposalDescription());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetReviewProposalDescription()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.reviewProposalDescription, other.reviewProposalDescription);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetDeclinedReason()).compareTo(other.isSetDeclinedReason());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetDeclinedReason()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.declinedReason, other.declinedReason);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetRequestCreationTime()).compareTo(other.isSetRequestCreationTime());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetRequestCreationTime()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requestCreationTime, other.requestCreationTime);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetRequesterUsername()).compareTo(other.isSetRequesterUsername());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetRequesterUsername()) {
+      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requesterUsername, other.requesterUsername);
+      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 {
+    scheme(iprot).read(iprot, this);
+  }
+
+  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
+    scheme(oprot).write(oprot, this);
+  }
+
... 73877 lines suppressed ...


[airavata-custos] 48/48: Merge pull request #6 from aarushiibisht/master

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a57cdd662f57107dea7366c15a7c36bce15fdea6
Merge: 2e3135a 240a19b
Author: Suresh Marru <sm...@apache.org>
AuthorDate: Mon Sep 9 15:17:00 2019 -0400

    Merge pull request #6 from aarushiibisht/master
    
    Refactored exception handling in sharing registry to return appropriate HTTP status to the user.

 .../service/api/controllers/DomainsController.java |  28 +-
 .../service/api/controllers/EntityController.java  |  27 +-
 .../api/controllers/EntityTypeController.java      |  41 +--
 .../service/api/controllers/GroupController.java   | 135 ++-----
 .../api/controllers/PermissionTypeController.java  |  40 +--
 .../service/api/controllers/UsersController.java   |  36 +-
 .../src/main/resources/application.properties      |   3 +-
 .../core/exceptions/InvalidRequestException.java   |  16 +
 .../custos/sharing/service/core/models/Domain.java |   2 +-
 .../core/service/SharingRegistryService.java       | 396 ++++++++++++++++-----
 pom.xml                                            |   5 +
 11 files changed, 399 insertions(+), 330 deletions(-)


[airavata-custos] 39/48: added a readme

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e59c4d8efb9ebfe2a2e74364b28d68b894126830
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Sep 2 19:53:45 2019 -0400

    added a readme
---
 .../SharingRegistryServiceClientFactory.java       | 44 ----------------------
 custos-profile-service/README                      |  3 --
 custos-sharing-registry-service/README             |  3 ++
 3 files changed, 3 insertions(+), 47 deletions(-)

diff --git a/custos-client/src/main/java/org/apache/custos/client/sharing/service/SharingRegistryServiceClientFactory.java b/custos-client/src/main/java/org/apache/custos/client/sharing/service/SharingRegistryServiceClientFactory.java
deleted file mode 100644
index 3fc60a4..0000000
--- a/custos-client/src/main/java/org/apache/custos/client/sharing/service/SharingRegistryServiceClientFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *
- * 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.custos.client.sharing.service;
-
-import org.apache.custos.sharing.registry.models.SharingRegistryException;
-import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SharingRegistryServiceClientFactory {
-    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServiceClientFactory.class);
-
-    public static SharingRegistryService.Client createSharingRegistryClient(String serverHost, int serverPort) throws SharingRegistryException {
-        try {
-            TSocket e = new TSocket(serverHost, serverPort);
-            e.open();
-            TBinaryProtocol protocol = new TBinaryProtocol(e);
-            return new SharingRegistryService.Client(protocol);
-        } catch (TTransportException var4) {
-            logger.error("failed to create sharing registry client", var4);
-            throw new SharingRegistryException();
-        }
-    }
-}
\ No newline at end of file
diff --git a/custos-profile-service/README b/custos-profile-service/README
deleted file mode 100644
index 9d83e76..0000000
--- a/custos-profile-service/README
+++ /dev/null
@@ -1,3 +0,0 @@
-Custos Profile Service
-
-The thrift files associated with Profile services are in thrift-interfaces/profile-service folder
diff --git a/custos-sharing-registry-service/README b/custos-sharing-registry-service/README
new file mode 100644
index 0000000..fa8e509
--- /dev/null
+++ b/custos-sharing-registry-service/README
@@ -0,0 +1,3 @@
+Custos Sharing Registry Service
+
+To start the service go to org.apache.custos.sharing.service.api and run Application.java


[airavata-custos] 18/48: Merge pull request #3 from aarushiibisht/custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 44b6bb18d6974709ea9f5be5b18d488de195fd3a
Merge: 611cb4a 6fa92d1
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Mon Aug 12 12:31:09 2019 -0400

    Merge pull request #3 from aarushiibisht/custos-dev-abisht
    
    removed hard coded version from the pom.xml files which now uses project.version
    uncommented logging

 custos-authentication/pom.xml                                |  8 +++-----
 custos-client/pom.xml                                        | 12 ++++--------
 .../authentication/service/AuthenticationServiceClient.java  |  2 +-
 custos-commons/pom.xml                                       |  5 ++---
 .../org/apache/custos/commons/utils/ApplicationSettings.java | 12 ++++++------
 custos-connectors/pom.xml                                    |  4 ++--
 custos-profile-service/iam-admin-services/pom.xml            |  4 ++--
 custos-profile-service/profile-service-commons/pom.xml       |  5 ++---
 custos-profile-service/profile-service-server/pom.xml        |  9 +++------
 custos-profile-service/tenant-profile-service/pom.xml        | 10 +++-------
 custos-profile-service/user-profile-service/pom.xml          |  9 +++------
 ide-integration/pom.xml                                      |  6 ++----
 12 files changed, 33 insertions(+), 53 deletions(-)


[airavata-custos] 37/48: updated the sharing registry apis

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7534acbc380d6c9f7d6a237e9026f8c065c665e3
Author: Aarushi <aa...@gmail.com>
AuthorDate: Mon Sep 2 19:35:54 2019 -0400

    updated the sharing registry apis
---
 custos-commons/pom.xml                             |   6 +
 .../exceptions/ServiceConnectionException.java     |  11 +
 .../custos/commons/utils/ServiceRequest.java       |  36 -
 .../custos/commons/utils/ServiceRequestClient.java | 101 +++
 .../src/main/resources/custos-server.properties    |  10 +-
 .../group-profile-core/pom.xml                     |  23 +
 .../service/core/service/GroupProfileService.java  | 730 ++++++++++-----------
 custos-profile-service/pom.xml                     |   1 +
 custos-sharing-registry-service/pom.xml            |   5 +-
 .../sharing-service-api/pom.xml                    |   6 +
 .../custos/sharing/service/api/AppConfig.java      |  15 -
 .../custos/sharing/service/api/Application.java    |   2 +-
 .../api/constants/SharingRegistryEndpoints.java    |  88 ++-
 .../service/api/controllers/AccessController.java  |  31 +-
 .../service/api/controllers/DomainsController.java |  43 +-
 .../service/api/controllers/EntityController.java  |  49 +-
 .../api/controllers/EntityTypeController.java      |  37 +-
 .../service/api/controllers/GroupController.java   |  85 ++-
 .../api/controllers/PermissionTypeController.java  |  38 +-
 .../service/api/controllers/UsersController.java   |  36 +-
 .../sharing-service-core/pom.xml                   |  39 +-
 .../service/core/db/entities/DomainEntity.java     |   1 -
 .../core/db/repositories/EntityRepository.java     |   2 +-
 .../sharing/service/core/db/utils/JPAUtils.java    |   2 +-
 .../custos/sharing/service/core/models/Domain.java |  21 +-
 .../custos/sharing/service/core/models/Entity.java |  39 +-
 .../sharing/service/core/models/EntityType.java    |  23 +-
 .../service/core/models/GroupMembership.java       |  12 +-
 .../service/core/models/PermissionType.java        |  21 +-
 .../sharing/service/core/models/Sharing.java       |  12 +-
 .../custos/sharing/service/core/models/User.java   |  33 +-
 .../sharing/service/core/models/UserGroup.java     |  30 +-
 .../core/service/SharingRegistryService.java       |  42 +-
 .../database_scripts/init/01-databases.sql         | 187 +++---
 ide-integration/pom.xml                            |   8 +-
 .../custos-authentication-service-samples/pom.xml  |   2 +-
 .../samples/custos-profile-service-samples/pom.xml |   2 +-
 pom.xml                                            |   5 +
 38 files changed, 1063 insertions(+), 771 deletions(-)

diff --git a/custos-commons/pom.xml b/custos-commons/pom.xml
index 5a78df1..5a98a4a 100644
--- a/custos-commons/pom.xml
+++ b/custos-commons/pom.xml
@@ -31,6 +31,12 @@
             <artifactId>commons-dbcp</artifactId>
             <version>1.4</version>
         </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20160212</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ServiceConnectionException.java b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ServiceConnectionException.java
new file mode 100644
index 0000000..bdfaf29
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/exceptions/ServiceConnectionException.java
@@ -0,0 +1,11 @@
+package org.apache.custos.commons.exceptions;
+
+public class ServiceConnectionException extends RuntimeException {
+
+    public ServiceConnectionException(String errorMessage, Throwable err) {
+        super(errorMessage, err);
+    }
+    public ServiceConnectionException(String errorMessage) {
+        super(errorMessage);
+    }
+}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServiceRequest.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServiceRequest.java
deleted file mode 100644
index 23e0061..0000000
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServiceRequest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.apache.custos.commons.utils;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.springframework.stereotype.Component;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Map;
-
-@Component
-public class ServiceRequest {
-
-    public String httpGet(String baseUrl, String requestUrl) throws Exception{
-            StringBuilder result = new StringBuilder();
-            URL url = new URL(baseUrl + requestUrl);
-            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-            conn.setRequestMethod("GET");
-            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
-            String line;
-            while ((line = rd.readLine()) != null) {
-                result.append(line);
-            }
-            rd.close();
-            return result.toString();
-    }
-
-    public void httpPost(String baseUrl, String requestUrl, Object jsonObject){
-//        ObjectMapper obj = new ObjectMapper();
-//        String postBodyString = obj.writeValueAsString(jsonObject);
-//        StringEntity requestEntity = new StringEntity(postBodyString, ContentType.APPLICATION_JSON);
-    }
-}
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServiceRequestClient.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServiceRequestClient.java
new file mode 100644
index 0000000..0a3756d
--- /dev/null
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServiceRequestClient.java
@@ -0,0 +1,101 @@
+package org.apache.custos.commons.utils;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.custos.commons.exceptions.ServiceConnectionException;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.*;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+/*
+* This class is a helper class.
+* It acts as an HTTP client and returns the http response back to the caller
+*/
+
+@Component
+public class ServiceRequestClient {
+
+    private final static Logger logger = LoggerFactory.getLogger(ServiceRequestClient.class);
+
+    public HttpResponse httpGet(String baseUrl, String requestUrl) throws ServiceConnectionException{
+
+        try {
+            HttpClient client = HttpClientBuilder.create().build();
+            HttpGet request = new HttpGet(baseUrl + requestUrl);
+            HttpResponse response = client.execute(request);
+            return response;
+        }catch (Exception ex){
+            String error = String.format("Could not fulfill request from Url: %s", baseUrl+requestUrl);
+            logger.error(error, ex);
+            throw new ServiceConnectionException(error, ex);
+        }
+    }
+
+    public HttpResponse httpPost(String baseUrl, String requestUrl, Object jsonObject) throws ServiceConnectionException{
+        try{
+            HttpClient client = HttpClientBuilder.create().build();
+            HttpPost post = new HttpPost(baseUrl+requestUrl);
+            ObjectMapper obj = new ObjectMapper();
+            String postBodyString = obj.writeValueAsString(jsonObject);
+            StringEntity requestEntity = new StringEntity(postBodyString, ContentType.APPLICATION_JSON);
+            post.setEntity(requestEntity);
+            HttpResponse response = client.execute(post);
+            return response;
+    }catch (Exception ex){
+            String error = String.format("Could not fulfill request from Url: %s", baseUrl+requestUrl);
+            logger.error(error, ex);
+            throw new ServiceConnectionException(error, ex);
+        }
+    }
+
+    public HttpResponse httpDelete(String baseUrl, String requestUrl){
+        try{
+            HttpClient client = HttpClientBuilder.create().build();
+            HttpDelete delete = new HttpDelete(baseUrl+requestUrl);
+            HttpResponse response = client.execute(delete);
+            return response;
+        }catch (Exception ex){
+            String error = String.format("Could not fulfill request from Url: %s", baseUrl+requestUrl);
+            logger.error(error, ex);
+            throw new ServiceConnectionException(error, ex);
+        }
+    }
+
+    public HttpResponse httpHead(String baseUrl, String requestUrl){
+        try{
+            HttpClient client = HttpClientBuilder.create().build();
+            HttpHead head = new HttpHead(baseUrl+requestUrl);
+            HttpResponse response = client.execute(head);
+            return response;
+        }catch (Exception ex){
+            String error = String.format("Could not fulfill request from Url: %s", baseUrl+requestUrl);
+            logger.error(error, ex);
+            throw new ServiceConnectionException(error, ex);
+        }
+    }
+
+    public HttpResponse httpPut(String baseUrl, String requestUrl, Object jsonObject){
+        try{
+            HttpClient client = HttpClientBuilder.create().build();
+            HttpPut put = new HttpPut(baseUrl+requestUrl);
+            ObjectMapper obj = new ObjectMapper();
+            String putBodyString = obj.writeValueAsString(jsonObject);
+            StringEntity requestEntity = new StringEntity(putBodyString, ContentType.APPLICATION_JSON);
+            put.setEntity(requestEntity);
+            HttpResponse response = client.execute(put);
+            return response;
+        }catch (Exception ex){
+            String error = String.format("Could not fulfill request from Url: %s", baseUrl+requestUrl);
+            logger.error(error, ex);
+            throw new ServiceConnectionException(error, ex);
+        }
+    }
+}
diff --git a/custos-commons/src/main/resources/custos-server.properties b/custos-commons/src/main/resources/custos-server.properties
index c2cb842..7321e50 100644
--- a/custos-commons/src/main/resources/custos-server.properties
+++ b/custos-commons/src/main/resources/custos-server.properties
@@ -71,12 +71,4 @@ sharingcatalog.jdbc.driver=org.mariadb.jdbc.Driver
 sharingcatalog.jdbc.url=jdbc:mariadb://localhost:13306/sharing_catalog
 sharingcatalog.jdbc.user=root
 sharingcatalog.jdbc.password=123456
-sharingcatalog.validationQuery=SELECT 1 from CONFIGURATION
-
-###########################################################################
-#  Sharing Registry Server Configuration
-###########################################################################
-sharing_server=org.apache.custos.sharing.registry.server.SharingRegistryServer
-sharing.registry.server.host=0.0.0.0
-sharing.registry.server.port=7878
-sharing.tls.enabled=false
\ No newline at end of file
+sharingcatalog.validationQuery=SELECT 1 from CONFIGURATION
\ No newline at end of file
diff --git a/custos-profile-service/group-profile-service/group-profile-core/pom.xml b/custos-profile-service/group-profile-service/group-profile-core/pom.xml
index 49575e0..7945596 100644
--- a/custos-profile-service/group-profile-service/group-profile-core/pom.xml
+++ b/custos-profile-service/group-profile-service/group-profile-core/pom.xml
@@ -16,6 +16,29 @@
             <artifactId>user-profile-service</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-service-api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>profile-service-commons</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20160212</version>
+            <scope>compile</scope>
+        </dependency>
+        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.8.5</version>
+        </dependency>
     </dependencies>
 
 
diff --git a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java
index f4843cd..b11b4df 100644
--- a/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java
+++ b/custos-profile-service/group-profile-service/group-profile-core/src/main/java/org/apache/custos/profile/service/core/service/GroupProfileService.java
@@ -1,374 +1,355 @@
-//package org.apache.custos.profile.service.core.service;
-//
-//import org.apache.custos.commons.utils.ServiceRequest;
-//import org.apache.custos.profile.user.core.repositories.UserProfileRepository;
-//import org.apache.custos.sharing.service.api.constants.SharingRegistryEndpoints;
-//import org.apache.custos.sharing.service.core.models.GroupCardinality;
-//import org.apache.custos.sharing.service.core.models.GroupType;
-//import org.apache.custos.sharing.service.core.models.UserGroup;
-//import org.apache.custos.profile.service.core.models.*;
-//import org.apache.custos.profile.service.core.exceptions.*;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-//import org.springframework.beans.factory.annotation.Autowired;
-//
-//import java.util.ArrayList;
-//import java.util.List;
-//import java.util.UUID;
-//import java.util.stream.Collectors;
-//
-//public class GroupProfileService {
-//
-//    @Autowired
-//    private static ServiceRequest serviceRequest;
-//
-//    @Autowired
-//    private static SharingRegistryEndpoints SharingRegistryEndpoints;
-//
-//    private static final Logger logger = LoggerFactory.getLogger(GroupProfileService.class);
-//    private static final String GROUP_MANAGER_CPI_VERSION = "1.0";
-//    private UserProfileRepository userProfileRepository = new UserProfileRepository();
-//    private static final String SHARING_SERVICE_BASE_URL = SharingRegistryEndpoints.BASE_URL;
-//
-//    public String getAPIVersion() {
-//        return GROUP_MANAGER_CPI_VERSION;
-//    }
-//
-//    public String createGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
-//        try {
-//
-//            UserGroup sharingUserGroup = new UserGroup();
-//            sharingUserGroup.setGroupId(UUID.randomUUID().toString());
-//            sharingUserGroup.setName(groupModel.getName());
-//            sharingUserGroup.setDescription(groupModel.getDescription());
-//            sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
-//            sharingUserGroup.setGroupCardinality(GroupCardinality.MULTI_USER);
-//            sharingUserGroup.setDomainId(gatewayId);
-//            sharingUserGroup.setOwnerId(userId);
-//
-//            String groupId = serviceRequest.httpPost(SHARING_SERVICE_BASE_URL, SharingRegistryEndpoints.CREATE_GROUP, );
-//            //TODO: should happen in one rest call
-//            //internalAddUsersToGroup(sharingClient, gatewayId, groupModel.getMembers(), groupId);
-//            //addGroupAdmins(authzToken,groupId,groupModel.getAdmins());
-//            return groupId;
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Creating Group" ;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    public boolean updateGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
-//        try {
-//            if (!(sharingClient.hasOwnerAccess(domainId, groupModel.getId(), userId)
-//                    || sharingClient.hasAdminAccess(domainId, groupModel.getId(), userId))) {
-//                throw new GroupManagerServiceException("User does not have permission to update group");
-//            }
-//
-//            UserGroup sharingUserGroup = new UserGroup();
-//            sharingUserGroup.setGroupId(groupModel.getId());
-//            sharingUserGroup.setName(groupModel.getName());
-//            sharingUserGroup.setDescription(groupModel.getDescription());
-//            sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
-//            sharingUserGroup.setDomainId(gatewayId);
-//
-//            //adding and removal of users should be handle separately??
-//            String response = serviceRequest.httpPut(SHARING_SERVICE_BASE_URL, SharingRegistryEndpoints.UPDATE_GROUP);
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Updating Group" ;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    public boolean deleteGroup(AuthzToken authzToken, String groupId, String ownerId) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try {
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            String userId = getUserId(authzToken);
-//            String domainId = getDomainId(authzToken);
-//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId))) {
-//                throw new GroupManagerServiceException("User does not have permission to delete group");
-//            }
-//
-//            sharingClient.deleteGroup(getDomainId(authzToken), groupId);
-//            return true;
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Deleting Group. Group ID: " + groupId ;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    @Override
-//    @SecurityCheck
-//    public GroupModel getGroup(AuthzToken authzToken, String groupId) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try {
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            final String domainId = getDomainId(authzToken);
-//            UserGroup userGroup = sharingClient.getGroup(domainId, groupId);
-//
-//            GroupModel groupModel = convertToGroupModel(userGroup, sharingClient);
-//
-//            return groupModel;
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Retreiving Group. Group ID: " + groupId ;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    @Override
-//    @SecurityCheck
-//    public List<GroupModel> getGroups(AuthzToken authzToken) throws GroupManagerServiceException, AuthorizationException, TException {
-//        final String domainId = getDomainId(authzToken);
-//        SharingRegistryService.Client sharingClient = null;
-//        try {
-//            sharingClient = getSharingRegistryServiceClient();
-//            List<UserGroup> userGroups = sharingClient.getGroups(domainId, 0, -1);
-//
-//            return convertToGroupModels(userGroups, sharingClient);
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Retrieving Groups. Domain ID: " + domainId;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        } finally {
-//            closeSharingClient(sharingClient);
-//        }
-//    }
-//
-//    @Override
-//    @SecurityCheck
-//    public List<GroupModel> getAllGroupsUserBelongs(AuthzToken authzToken, String userName) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try {
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            List<GroupModel> groupModels = new ArrayList<GroupModel>();
-//            final String domainId = getDomainId(authzToken);
-//            List<UserGroup> userGroups = sharingClient.getAllMemberGroupsForUser(domainId, userName);
-//
-//            return convertToGroupModels(userGroups, sharingClient);
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Retreiving All Groups for User. User ID: " + userName ;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    @Override
-//    public boolean addUsersToGroup(AuthzToken authzToken, List<String> userIds, String groupId) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try {
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            String userId = getUserId(authzToken);
-//            String domainId = getDomainId(authzToken);
-//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId)
-//                    || sharingClient.hasAdminAccess(domainId, groupId, userId))) {
-//                throw new GroupManagerServiceException("User does not have access to add users to the group");
-//            }
-//            return internalAddUsersToGroup(sharingClient, domainId, userIds, groupId);
-//
-//        } catch (Exception e) {
-//            String msg = "Error adding users to group. Group ID: " + groupId ;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    @Override
-//    public boolean removeUsersFromGroup(AuthzToken authzToken, List<String> userIds, String groupId) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try {
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            String userId = getUserId(authzToken);
-//            String domainId = getDomainId(authzToken);
-//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId)
-//                    || sharingClient.hasAdminAccess(domainId, groupId, userId))) {
-//                throw new GroupManagerServiceException("User does not have access to remove users to the group");
-//            }
-//            return sharingClient.removeUsersFromGroup(domainId, userIds, groupId);
-//        } catch (Exception e) {
-//            String msg = "Error remove users to group. Group ID: " + groupId ;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    @Override
-//    @SecurityCheck
-//    public boolean transferGroupOwnership(AuthzToken authzToken, String groupId, String newOwnerId) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try{
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            String userId = getUserId(authzToken);
-//            String domainId = getDomainId(authzToken);
-//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId))) {
-//                throw new GroupManagerServiceException("User does not have Owner permission to transfer group ownership");
-//            }
-//            return sharingClient.transferGroupOwnership(getDomainId(authzToken), groupId, newOwnerId);
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Transferring Group Ownership";
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//
-//    }
-//
-//    @Override
-//    @SecurityCheck
-//    public boolean addGroupAdmins(AuthzToken authzToken, String groupId, List<String> adminIds) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try {
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            String userId = getUserId(authzToken);
-//            String domainId = getDomainId(authzToken);
-//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId))) {
-//                throw new GroupManagerServiceException("User does not have Owner permission to add group admins");
-//            }
-//            return sharingClient.addGroupAdmins(getDomainId(authzToken), groupId, adminIds);
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Adding Admins to Group. Group ID: " + groupId;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    @Override
-//    @SecurityCheck
-//    public boolean removeGroupAdmins(AuthzToken authzToken, String groupId, List<String> adminIds) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try {
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            String userId = getUserId(authzToken);
-//            String domainId = getDomainId(authzToken);
-//            if (!(sharingClient.hasOwnerAccess(domainId, groupId, userId))) {
-//                throw new GroupManagerServiceException("User does not have Owner permission to remove group admins");
-//            }
-//            return sharingClient.removeGroupAdmins(getDomainId(authzToken), groupId, adminIds);
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Removing Admins from the Group. Group ID: " + groupId;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    @Override
-//    @SecurityCheck
-//    public boolean hasAdminAccess(AuthzToken authzToken, String groupId, String adminId) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try {
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            return sharingClient.hasAdminAccess(getDomainId(authzToken), groupId, adminId);
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Checking Admin Access for the Group. Group ID: " + groupId + " Admin ID: " + adminId;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    @Override
-//    @SecurityCheck
-//    public boolean hasOwnerAccess(AuthzToken authzToken, String groupId, String ownerId) throws GroupManagerServiceException, AuthorizationException, TException {
-//        try {
-//            SharingRegistryService.Client sharingClient = getSharingRegistryServiceClient();
-//            return sharingClient.hasOwnerAccess(getDomainId(authzToken), groupId, ownerId);
-//        }
-//        catch (Exception e) {
-//            String msg = "Error Checking Owner Access for the Group. Group ID: " + groupId + " Owner ID: " + ownerId;
-//            logger.error(msg, e);
-//            GroupManagerServiceException exception = new GroupManagerServiceException();
-//            exception.setMessage(msg + " More info : " + e.getMessage());
-//            throw exception;
-//        }
-//    }
-//
-//    // TODO: replace these methods with ThriftClientPool (see AIRAVATA-2607)
-//    private SharingRegistryService.Client getSharingRegistryServiceClient() throws TException, ApplicationSettingsException {
-//        final int serverPort = Integer.parseInt(ServerSettings.getSharingRegistryPort());
-//        final String serverHost = ServerSettings.getSharingRegistryHost();
-//        try {
-//            return SharingRegistryServiceClientFactory.createSharingRegistryClient(serverHost, serverPort);
-//        } catch (SharingRegistryException e) {
-//            throw new TException("Unable to create sharing registry client...", e);
-//        }
-//    }
-//
-//    private String getDomainId(AuthzToken authzToken) {
-//        return authzToken.getClaimsMap().get(Constants.GATEWAY_ID);
-//    }
-//
-//    private String getUserId(AuthzToken authzToken) {
-//        return authzToken.getClaimsMap().get(Constants.USER_NAME) + "@" + getDomainId(authzToken);
-//    }
-//
-//    private List<GroupModel> convertToGroupModels(List<UserGroup> userGroups, SharingRegistryService.Client sharingClient) throws TException {
-//
-//        List<GroupModel> groupModels = new ArrayList<>();
-//
-//        for (UserGroup userGroup: userGroups) {
-//            GroupModel groupModel = convertToGroupModel(userGroup, sharingClient);
-//
-//            groupModels.add(groupModel);
-//        }
-//        return groupModels;
-//    }
-//
-//    private GroupModel convertToGroupModel(UserGroup userGroup, SharingRegistryService.Client sharingClient) throws TException {
-//        GroupModel groupModel = new GroupModel();
-//        groupModel.setId(userGroup.getGroupId());
-//        groupModel.setName(userGroup.getName());
-//        groupModel.setDescription(userGroup.getDescription());
-//        groupModel.setOwnerId(userGroup.getOwnerId());
-//        final List<String> admins = userGroup.getGroupAdmins().stream()
-//                .map(groupAdmin -> groupAdmin.getAdminId())
-//                .collect(Collectors.toList());
-//        groupModel.setAdmins(admins);
-//
-//        sharingClient.getGroupMembersOfTypeUser(userGroup.getDomainId(), userGroup.getGroupId(), 0, -1).stream().forEach(user->
-//                groupModel.addToMembers(user.getUserId())
+package org.apache.custos.profile.service.core.service;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.google.gson.Gson;
+import org.apache.custos.commons.exceptions.ServiceConnectionException;
+import org.apache.custos.commons.utils.ServiceRequestClient;
+import org.apache.custos.profile.commons.repositories.UserProfileRepository;
+import org.apache.custos.sharing.service.api.constants.SharingRegistryEndpoints;
+import org.apache.custos.sharing.service.core.exceptions.SharingRegistryException;
+import org.apache.custos.sharing.service.core.models.GroupCardinality;
+import org.apache.custos.sharing.service.core.models.GroupType;
+import org.apache.custos.sharing.service.core.models.UserGroup;
+import org.apache.custos.profile.service.core.models.*;
+import org.apache.custos.profile.service.core.exceptions.*;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.json.HTTP;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class GroupProfileService {
+
+    private static final Logger logger = LoggerFactory.getLogger(GroupProfileService.class);
+
+    @Autowired
+    ServiceRequestClient serviceRequestClient;
+
+    @Autowired
+    SharingRegistryEndpoints sharingRegistryEndpoints;
+
+    private static final String GROUP_MANAGER_CPI_VERSION = "1.0";
+    private UserProfileRepository userProfileRepository = new UserProfileRepository();
+    private String SHARING_SERVICE_BASE_URL = sharingRegistryEndpoints.getBaseUrl();
+
+    public String getAPIVersion() {
+        return GROUP_MANAGER_CPI_VERSION;
+    }
+
+    private JSONObject getResponseBody(HttpResponse response) throws Exception {
+
+        try {
+            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                StringBuffer result = new StringBuffer();
+                String line = "";
+                while ((line = rd.readLine()) != null) {
+                    result.append(line);
+                }
+                JSONObject jsonObject = new JSONObject(result.toString());
+                return jsonObject;
+            } else {
+                throw new Exception();
+            }
+        } catch (Exception ex) {
+            //TODO: sharing service did not return correct response
+            throw ex;
+        }
+    }
+
+    private boolean validateHeadHttpRequest(HttpResponse response) throws Exception{
+        if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+            return true;
+        }else if(response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
+            return false;
+        }
+        else {
+            //TODO: this will be sharing server error
+            throw new Exception();
+        }
+    }
+
+    private boolean validatePutHttpRequest(HttpResponse response) throws Exception{
+        if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+            return true;
+        } else {
+            //TODO: this will be sharing server error
+            throw new Exception();
+        }
+    }
+
+    public String createGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
+        try {
+
+            UserGroup sharingUserGroup = new UserGroup();
+            sharingUserGroup.setGroupId(groupModel.getId());
+            sharingUserGroup.setName(groupModel.getName());
+            sharingUserGroup.setDescription(groupModel.getDescription());
+            sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
+            sharingUserGroup.setGroupCardinality(GroupCardinality.MULTI_USER);
+            sharingUserGroup.setDomainId(groupModel.getGatewayId());
+            sharingUserGroup.setOwnerId(groupModel.getOwnerId());
+
+            HttpResponse response = serviceRequestClient.httpPost(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getCreateGroupApi(groupModel.getGatewayId()), sharingUserGroup);
+
+            //TODO: should happen in one rest call
+            //internalAddUsersToGroup(sharingClient, gatewayId, groupModel.getMembers(), groupId);
+            //addGroupAdmins(authzToken,groupId,groupModel.getAdmins());
+            JSONObject responseEntity = getResponseBody(response);
+            return responseEntity.get("groupId").toString();
+        }catch (ServiceConnectionException ex) {
+            //TODO: reason could not make connection request to sharing service
+            throw ex;
+        }
+        catch (Exception e) {
+            String msg = "Error Creating Group" ;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public boolean updateGroup(GroupModel groupModel, String gatewayId, String userId) throws GroupManagerServiceException{
+        try {
+            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(gatewayId, groupModel.getId(), userId)));
+            boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(gatewayId, groupModel.getId(), userId)));
+            if (!ownerAccess || ! adminAccess) {
+                throw new GroupManagerServiceException("User does not have permission to update group");
+            }
+
+            UserGroup sharingUserGroup = new UserGroup();
+            sharingUserGroup.setGroupId(groupModel.getId());
+            sharingUserGroup.setName(groupModel.getName());
+            sharingUserGroup.setDescription(groupModel.getDescription());
+            sharingUserGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
+            sharingUserGroup.setDomainId(gatewayId);
+
+            //adding and removal of users should be handle separately??
+            HttpResponse response = serviceRequestClient.httpPut(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getUpdateGroupApi(groupModel.getGatewayId()), null);
+            return validatePutHttpRequest(response);
+        }
+        catch (Exception e) {
+            String msg = "Error Updating Group" ;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public boolean deleteGroup(String groupId, String groupGatewayId, String domainId, String ownerId) throws GroupManagerServiceException{
+        try {
+            boolean hasOwnerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, ownerId)));
+            if (!hasOwnerAccess) {
+                throw new GroupManagerServiceException("User does not have permission to delete group");
+            }
+
+
+            serviceRequestClient.httpDelete(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getDeleteGroupApi(groupGatewayId,groupId));
+            return true;
+        }
+        catch (Exception e) {
+            String msg = "Error Deleting Group. Group ID: " + groupId ;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public GroupModel getGroup(String groupId, String groupGatewayId) throws GroupManagerServiceException{
+        try {
+            JSONObject jsonObject = getResponseBody(serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGetGroupApi(groupGatewayId, groupId)));
+            UserGroup userGroup = new Gson().fromJson(jsonObject.toString(),UserGroup.class);
+            GroupModel groupModel = convertToGroupModel(userGroup);
+            return groupModel;
+        }
+        catch (Exception e) {
+            String msg = "Error Retreiving Group. Group ID: " + groupId ;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public List<GroupModel> getGroups(String groupGatewayId) throws GroupManagerServiceException{
+        try {
+            JSONObject jsonObject = getResponseBody(serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGetGroupsApi(groupGatewayId, 0, -1)));
+            //List<UserGroup> userGroups = new Gson().fromJson(jsonObject.toString(),UserGroup.class);
+            List<UserGroup> userGroups = new ArrayList<>();
+            return convertToGroupModels(userGroups);
+        }
+        catch (Exception e) {
+            String msg = "Error Retrieving Groups. Domain ID: " + groupGatewayId;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public List<GroupModel> getAllGroupsUserBelongs(String userId, String groupGatewayId) throws GroupManagerServiceException{
+        try {
+            List<GroupModel> groupModels = new ArrayList<GroupModel>();
+            JSONObject jsonObject= getResponseBody(serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGetGroupsForUserApi(groupGatewayId, userId)));
+            List<UserGroup> userGroups = new ArrayList<>();
+            return convertToGroupModels(userGroups);
+        }
+        catch (Exception e) {
+            String msg = "Error Retreiving All Groups for User. User ID: " + userId ;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public boolean addUsersToGroup(List<String> userIds, String groupId, String groupGatewayId, String userId, String domainId) throws GroupManagerServiceException{
+        try {
+            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
+            boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(domainId, groupId, userId)));
+            if (! ownerAccess || !adminAccess) {
+                throw new GroupManagerServiceException("User does not have access to add users to the group");
+            }
+            return internalAddUsersToGroup(domainId, userIds, groupId);
+
+        } catch (Exception e) {
+            String msg = "Error adding users to group. Group ID: " + groupId ;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public boolean removeUsersFromGroup(List<String> userIds, String groupId, String groupGatewayId, String userId, String domainId) throws GroupManagerServiceException {
+        try {
+            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
+            boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(domainId, groupId, userId)));
+            if (! ownerAccess || !adminAccess)  {
+                throw new GroupManagerServiceException("User does not have access to remove users to the group");
+            }
+            return validateHeadHttpRequest(serviceRequestClient.httpDelete(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getRemoveUsersFromGroupApi(groupGatewayId, groupId)));
+        } catch (Exception e) {
+            String msg = "Error remove users to group. Group ID: " + groupId ;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public boolean transferGroupOwnership(String groupId, String groupGatewayId, String newOwnerId, String userId, String domainId) throws GroupManagerServiceException {
+        try{
+            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
+            if (!ownerAccess) {
+                throw new GroupManagerServiceException("User does not have Owner permission to transfer group ownership");
+            }
+            return validatePutHttpRequest(serviceRequestClient.httpPut(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getTransferGroupOwnershipApi(groupGatewayId, groupId, newOwnerId), null));
+        }
+        catch (Exception e) {
+            String msg = "Error Transferring Group Ownership";
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+
+    }
+
+    public boolean addGroupAdmins(String groupId,String groupGatewayId, List<String> adminIds, String userId, String domainId) throws GroupManagerServiceException {
+        try {
+            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
+            if (!ownerAccess) {
+                throw new GroupManagerServiceException("User does not have Owner permission to add group admins");
+            }
+            return validatePutHttpRequest(serviceRequestClient.httpPost(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getAddGroupAdminsApi(groupGatewayId, groupId), adminIds));
+        }
+        catch (Exception e) {
+            String msg = "Error Adding Admins to Group. Group ID: " + groupId;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public boolean removeGroupAdmins(String groupId, String groupGatewayId,List<String> adminIds, String userId, String domainId) throws GroupManagerServiceException{
+        try {
+            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(domainId, groupId, userId)));
+            if (!ownerAccess) {
+                throw new GroupManagerServiceException("User does not have Owner permission to remove group admins");
+            }
+            return validatePutHttpRequest(serviceRequestClient.httpDelete(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getRemoveGroupAdminsApi(groupGatewayId, groupId)));
+        }
+        catch (Exception e) {
+            String msg = "Error Removing Admins from the Group. Group ID: " + groupId;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public boolean hasAdminAccess(String groupId, String adminId, String groupGatewayId) throws GroupManagerServiceException{
+        try {
+            boolean adminAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasAdminAccessApi(groupGatewayId, groupId, adminId)));
+            return adminAccess;
+        }
+        catch (Exception e) {
+            String msg = "Error Checking Admin Access for the Group. Group ID: " + groupId + " Admin ID: " + adminId;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    public boolean hasOwnerAccess(String groupId, String groupGatewayId, String ownerId) throws GroupManagerServiceException{
+        try {
+            boolean ownerAccess = validateHeadHttpRequest(serviceRequestClient.httpHead(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getHasOwnerAccessApi(groupGatewayId, groupId, ownerId)));
+            return ownerAccess;
+        }
+        catch (Exception e) {
+            String msg = "Error Checking Owner Access for the Group. Group ID: " + groupId + " Owner ID: " + ownerId;
+            logger.error(msg, e);
+            GroupManagerServiceException exception = new GroupManagerServiceException(msg + " More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+
+    private List<GroupModel> convertToGroupModels(List<UserGroup> userGroups){
+
+        List<GroupModel> groupModels = new ArrayList<>();
+
+        for (UserGroup userGroup: userGroups) {
+            GroupModel groupModel = convertToGroupModel(userGroup);
+
+            groupModels.add(groupModel);
+        }
+        return groupModels;
+    }
+
+    private GroupModel convertToGroupModel(UserGroup userGroup) {
+        GroupModel groupModel = new GroupModel();
+        groupModel.setId(userGroup.getGroupId());
+        groupModel.setName(userGroup.getName());
+        groupModel.setDescription(userGroup.getDescription());
+        groupModel.setOwnerId(userGroup.getOwnerId());
+        final List<String> admins = userGroup.getGroupAdmins().stream()
+                .map(groupAdmin -> groupAdmin.getAdminId())
+                .collect(Collectors.toList());
+        groupModel.setAdmins(admins);
+
+//        serviceRequestClient.httpGet(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getGroupMemebersOfTypeUserApi(userGroup.getDomainId(), userGroup.getGroupId(), 0, -1)).stream().forEach(user->
+//                groupModel.getMembers().add((user.getUserId())
 //        );
-//        return groupModel;
-//    }
-//
-//    private void closeSharingClient(SharingRegistryService.Client sharingClient) {
-//        if (sharingClient != null) {
-//            if (sharingClient.getInputProtocol().getTransport().isOpen()) {
-//                sharingClient.getInputProtocol().getTransport().close();
-//            }
-//            if (sharingClient.getOutputProtocol().getTransport().isOpen()) {
-//                sharingClient.getOutputProtocol().getTransport().close();
-//            }
-//        }
-//    }
-//
-//    private boolean internalAddUsersToGroup(SharingRegistryService.Client sharingClient, String domainId, List<String> userIds, String groupId) throws SharingRegistryException, TException {
-//
-//        // FIXME: workaround for UserProfiles that failed to sync to the sharing
-//        // registry: create any missing users in the sharing registry
+        return groupModel;
+    }
+
+    private boolean internalAddUsersToGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException {
+
+        // FIXME: workaround for UserProfiles that failed to sync to the sharing
+        // registry: create any missing users in the sharing registry
 //        for (String userId : userIds) {
 //            if (!sharingClient.isUserExists(domainId, userId)) {
 //                User user = new User();
@@ -383,8 +364,7 @@
 //                sharingClient.createUser(user);
 //            }
 //        }
-//        return sharingClient.addUsersToGroup(domainId, userIds, groupId);
-//    }
-//}
-//
-//}
+//        return serviceRequestClient.httpPost(SHARING_SERVICE_BASE_URL, sharingRegistryEndpoints.getAddUsersToGroupApi(domainId, groupId), userIds);
+        return true;
+    }
+}
diff --git a/custos-profile-service/pom.xml b/custos-profile-service/pom.xml
index e0ca29a..c1802cb 100644
--- a/custos-profile-service/pom.xml
+++ b/custos-profile-service/pom.xml
@@ -18,6 +18,7 @@
         <module>profile-service-model</module>
         <module>profile-service-server</module>
         <module>tenant-profile-service</module>
+        <module>group-profile-service</module>
     </modules>
     <properties>
         <java.version>1.8</java.version>
diff --git a/custos-sharing-registry-service/pom.xml b/custos-sharing-registry-service/pom.xml
index 9637a81..0879d25 100644
--- a/custos-sharing-registry-service/pom.xml
+++ b/custos-sharing-registry-service/pom.xml
@@ -13,9 +13,8 @@
     <packaging>pom</packaging>
 
     <modules>
-        <module>sharing-registry-distribution</module>
-        <module>sharing-registry-server</module>
-        <module>sharing-registry-stubs</module>
+        <module>sharing-service-api</module>
+        <module>sharing-service-core</module>
     </modules>
 
 </project>
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-service-api/pom.xml b/custos-sharing-registry-service/sharing-service-api/pom.xml
index 5811ff9..95fa802 100644
--- a/custos-sharing-registry-service/sharing-service-api/pom.xml
+++ b/custos-sharing-registry-service/sharing-service-api/pom.xml
@@ -17,6 +17,12 @@
             <version>1.0-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20160212</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
 
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/AppConfig.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/AppConfig.java
index ecc0943..df1bc56 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/AppConfig.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/AppConfig.java
@@ -1,22 +1,7 @@
 package org.apache.custos.sharing.service.api;
 
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.sharing.service.core.db.utils.SharingRegistryDBInitConfig;
-import org.apache.custos.sharing.service.core.service.SharingRegistryService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
 @Configuration
 public class AppConfig {
-    @Autowired
-    SharingRegistryDBInitConfig sharingRegistryDBInitConfig;
-    @Bean
-    public SharingRegistryDBInitConfig SharingRegistryDBInitConfigBeanMapper(){
-        return new SharingRegistryDBInitConfig();
-    }
-    @Bean
-    public SharingRegistryService SharingRegistryServiceBeanMapper() throws ApplicationSettingsException {
-        return new SharingRegistryService(sharingRegistryDBInitConfig);
-    }
 }
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/Application.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/Application.java
index ebdd989..09c47b9 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/Application.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/Application.java
@@ -24,7 +24,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.ComponentScan;
 
 @SpringBootApplication
-@ComponentScan(basePackages = {"org.apache.custos.sharing.service.api.controllers"})
+@ComponentScan(basePackages = {"org.apache.custos.sharing.service"})
 public class Application {
     public static void main(String[] args){
         SpringApplication.run(Application.class, args);
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/constants/SharingRegistryEndpoints.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/constants/SharingRegistryEndpoints.java
index 27f1b8c..c71a310 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/constants/SharingRegistryEndpoints.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/constants/SharingRegistryEndpoints.java
@@ -1,22 +1,88 @@
 package org.apache.custos.sharing.service.api.constants;
 
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.commons.utils.ServerSettings;
 import org.springframework.stereotype.Component;
 
 @Component
 public class SharingRegistryEndpoints {
 
-    public String BASE_URL;
+    public String BASE_URL = "http://localhost:7070";
 
-    //group APIs
-    public String CREATE_GROUP = "/group";
-    public String UPDATE_GROUP = "/group";
-    public String IS_GROUP_EXISTS = "/group/exists/id/{groupId}/domain/{domainId}";
-    public String DELETE_GROUP = "/group/id/{groupId}/domain/{domainId}";
-    public String GET_GROUP = "/group/id/{groupId}/domain/{domainId}";
+    //Group APIs getters
+    public String getCreateGroupApi(String domainId) {
+        return String.format("/domains/%s/groups", domainId);
+    }
+
+    public String getUpdateGroupApi(String domainId) {
+        return String.format("/domains/%s/groups", domainId);
+    }
+
+    public String getIsGroupExistsApi(String domainId, String groupId) {
+        return String.format("/domains/%s/groups/%s", domainId, groupId);
+    }
+
+    public String getDeleteGroupApi(String domainId, String groupId) {
+        return String.format("/domains/%s/groups/%s", domainId, groupId);
+    }
+
+    public String getGetGroupApi(String domainId, String groupId) {
+        return String.format("/domains/%s/groups/%s", domainId, groupId);
+    }
+
+    public String getGetGroupsApi(String domainId, int offset, int limit) {
+        return String.format("/domains/%s/groups?offset=%d&limit=%d", domainId,offset, limit);
+    }
+
+    public String getAddUsersToGroupApi(String domainId, String groupId) {
+        return String.format("/domains/%s/groups/%s/users", domainId, groupId);
+    }
+
+    public String getRemoveUsersFromGroupApi(String domainId, String groupId) {
+        return String.format("/domains/%s/groups/%s/users", domainId, groupId);
+    }
+
+    public String getTransferGroupOwnershipApi(String domainId, String groupId, String ownerId) {
+        return String.format("/domains/%s/groups/%s/owners/%s", domainId, groupId, ownerId);
+    }
+
+    public String getAddGroupAdminsApi(String domainId, String groupId) {
+        return String.format("/domains/%s/groups/%s/admins", domainId, groupId);
+    }
 
-    SharingRegistryEndpoints() throws ApplicationSettingsException {
-        BASE_URL = ServerSettings.getSharingRegistryServerHost() + ":" + ServerSettings.getSharingRegistryServerPort();
+    public String getRemoveGroupAdminsApi(String domainId, String groupId) {
+        return String.format("/domains/%s/groups/%s/admins", domainId, groupId);
     }
+
+    public String getHasAdminAccessApi(String domainId, String groupId, String adminId) {
+        return String.format("/domains/%s/groups/%s/admins/%s", domainId, groupId, adminId);
+    }
+
+    public String getHasOwnerAccessApi(String domainId, String groupId, String ownerId) {
+        return String.format("/domains/%s/groups/%s/owners/%s", domainId, groupId, ownerId);
+    }
+
+    public String getGroupMemebersOfTypeUserApi(String domainId, String groupId, int offset, int limit) {
+        return String.format("/domains/%s/groups/%s/users?offset=%d&limit=%d", domainId, groupId, offset, limit);
+    }
+
+    public String getGroupMembersOfTypeGroupApi(String domainId, String groupId, int offset, int limit) {
+        return String.format("/domains/%s/groups/%s/subgroups?offset=%d&limit=%d", domainId, groupId, offset, limit);
+    }
+
+    public String getAddGroupsApi(String domainId, String groupId) {
+        return String.format("/domains/%s/groups/%s/subgroups", domainId, groupId);
+    }
+
+    public String getRemoveGroupsApi(String domainId, String groupId) {
+        return String.format("/domains/%s/groups/%s/subgroups", domainId, groupId);
+    }
+
+    public String getGetGroupsForUserApi(String domainId, String userId) {
+        return String.format("/domains/%s/groups/users/%s", domainId, userId);
+    }
+
+    public String getBaseUrl() {
+        return BASE_URL;
+    }
+
+
 }
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/AccessController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/AccessController.java
index 238c8d0..4cee997 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/AccessController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/AccessController.java
@@ -6,12 +6,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
-
-import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
 @RestController
+@RequestMapping("/domains/{domainId}/entities/{entityId}/permissionTypes/{permissionTypeId}")
 public class AccessController {
 
     @Autowired
@@ -20,8 +18,8 @@ public class AccessController {
     /**
      <p>API method to share an entity with users</p>
      */
-    @RequestMapping(value = "share/users/domain/{domainId}/entity/{entityId}/permissionType/{permissionTypeId}/cascadePermission/{cascadePermission}", method = RequestMethod.PUT)
-    public ResponseEntity<String> shareEntityWithUsers(@RequestBody List<String> userList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId, @PathVariable("cascadePermission") boolean cascadePermission){
+    @RequestMapping(value = "/users", method = RequestMethod.POST)
+    public ResponseEntity<String> shareEntityWithUsers(@RequestParam("ids") List<String> userList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionTypeId") String permissionTypeId, @RequestParam("cascadePermission") boolean cascadePermission){
 
         boolean response = sharingRegistryService.shareEntityWithUsers(domainId, entityId, userList, permissionTypeId, cascadePermission);
         if(response) return new ResponseEntity<>(HttpStatus.OK);
@@ -32,8 +30,8 @@ public class AccessController {
     /**
      <p>API method to revoke sharing from a list of users</p>
      */
-    @RequestMapping(value = "revoke/users/domain/{domainId}/entity/{entityId}/permissionType/{permissionTypeId}", method = RequestMethod.PUT)
-    public ResponseEntity<String> revokeEntitySharingFromUsers(@RequestBody List<String> userList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId){
+    @RequestMapping(value = "/users", method = RequestMethod.DELETE)
+    public ResponseEntity<String> revokeEntitySharingFromUsers(@RequestParam("ids") List<String> userList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionTypeId") String permissionTypeId){
         boolean response = sharingRegistryService.revokeEntitySharingFromUsers(domainId, entityId, userList, permissionTypeId);
         if(response) return new ResponseEntity<>(HttpStatus.OK);
         else throw new SharingRegistryException("Revoking entity sharing with users failed");
@@ -42,8 +40,8 @@ public class AccessController {
     /**
      <p>API method to share an entity with list of groups</p>
      */
-    @RequestMapping(value = "share/groups/domain/{domainId}/entity/{entityId}/permissionType/{permissionTypeId}/cascadePermission/{cascadePermission}", method = RequestMethod.PUT)
-    public ResponseEntity<String> shareEntityWithGroups(@RequestBody List<String> groupList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId, @PathVariable("cascadePermission") boolean cascadePermission){
+    @RequestMapping(value = "/groups", method = RequestMethod.POST)
+    public ResponseEntity<String> shareEntityWithGroups(@RequestParam("groupIds") List<String> groupList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionTypeId") String permissionTypeId, @RequestParam("cascadePermission") boolean cascadePermission){
        boolean response = sharingRegistryService.shareEntityWithGroups(domainId,entityId, groupList, permissionTypeId, cascadePermission);
         if(response) return new ResponseEntity<>(HttpStatus.OK);
         else throw new SharingRegistryException("Sharing entity with groups failed");
@@ -52,8 +50,8 @@ public class AccessController {
     /**
      <p>API method to revoke sharing from list of users</p>
      */
-    @RequestMapping(value = "revoke/groups/domain/{domainId}/entity/{entityId}/permissionType/{permissionTypeId}", method = RequestMethod.PUT)
-    public ResponseEntity<String> revokeEntitySharingFromGroups(@RequestBody List<String> groupList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId){
+    @RequestMapping(value = "/groups", method = RequestMethod.DELETE)
+    public ResponseEntity<String> revokeEntitySharingFromGroups(@RequestParam("groupIds") List<String> groupList, @PathVariable("domainId") String domainId, @PathVariable("entityId") String entityId, @PathVariable("permissionTypeId") String permissionTypeId){
         boolean response = sharingRegistryService.revokeEntitySharingFromGroups(domainId, entityId, groupList, permissionTypeId);
         if(response) return new ResponseEntity<>(HttpStatus.OK);
         else throw new SharingRegistryException("Revoking entity sharing with groups failed");
@@ -62,10 +60,13 @@ public class AccessController {
     /**
      <p>API method to check whether a user has access to a specific entity</p>
      */
-    @RequestMapping(value = "hasaccess/domain/{domainId}/user/{userId}/entity/{entityId}/permissionType/{permissionTypeId}", method = RequestMethod.PUT)
-    public @ResponseBody
-    Map<String, Boolean> userHasAccess(@PathVariable("domainId") String domainId, @PathVariable("userId") String userId, @PathVariable("entityId") String entityId, @PathVariable("permissionType") String permissionTypeId){
+    @RequestMapping(value = "/users/{userId}", method = RequestMethod.HEAD)
+    public ResponseEntity<String> userHasAccess(@PathVariable("domainId") String domainId, @PathVariable("userId") String userId, @PathVariable("entityId") String entityId, @PathVariable("permissionTypeId") String permissionTypeId){
         boolean response = sharingRegistryService.userHasAccess(domainId, userId, entityId, permissionTypeId);
-        return Collections.singletonMap("access", response);
+        HttpStatus status = HttpStatus.NOT_FOUND;
+        if(response){
+            status = HttpStatus.OK;
+        }
+        return new ResponseEntity<>(status);
     }
 }
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java
index ccfbd16..9ab93e9 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/DomainsController.java
@@ -7,33 +7,31 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
-
-import java.util.Collections;
+import javax.validation.Valid;
 import java.util.List;
-import java.util.Map;
 
 @RestController
-@RequestMapping("/domain")
+@RequestMapping("/domains")
 public class DomainsController {
 
     @Autowired
-    private static SharingRegistryService sharingRegistryService;
+    SharingRegistryService sharingRegistryService;
 
     /**
      <p>API method to create a new domain</p>
      */
-    @RequestMapping(value = "/create", method= RequestMethod.POST)
-    public ResponseEntity<String> createDomain(@RequestBody Domain domain){
-        String domainId = sharingRegistryService.createDomain(domain);
-        if(domainId.equals(domain.getDomainId())) return new ResponseEntity<>(HttpStatus.OK);
+    @RequestMapping(method= RequestMethod.POST)
+    public @ResponseBody Domain createDomain(@Valid @RequestBody Domain domain){
+        Domain createdDomain = sharingRegistryService.createDomain(domain);
+        if(createdDomain != null) return createdDomain;
         else throw new SharingRegistryException("Domain creation failed");
     }
 
     /**
      <p>API method to update a domain</p>
      */
-    @RequestMapping(value = "/update", method = RequestMethod.PUT)
-    public ResponseEntity<String> updateDomain(@RequestBody Domain domain){
+    @RequestMapping(method = RequestMethod.PUT)
+    public ResponseEntity<String> updateDomain(@Valid @RequestBody Domain domain){
         boolean response = sharingRegistryService.updateDomain(domain);
         if(response) return new ResponseEntity<>(HttpStatus.OK);
         else throw new SharingRegistryException("Domain update failed");
@@ -42,11 +40,14 @@ public class DomainsController {
     /**
      <p>API method to check Domain Exists</p>
      */
-    @RequestMapping(value = "/exists/{domainId}", method = RequestMethod.GET)
-    public @ResponseBody
-    Map<String, Boolean> isDomainExists(@PathVariable("domainId") String domainId) {
+    @RequestMapping(value = "/{domainId}", method = RequestMethod.HEAD)
+    public ResponseEntity<String> isDomainExists(@PathVariable("domainId") String domainId) {
         boolean response = sharingRegistryService.isDomainExists(domainId);
-        return Collections.singletonMap("exists", response);
+        HttpStatus status = HttpStatus.NOT_FOUND;
+        if(response){
+            status = HttpStatus.OK;
+        }
+        return new ResponseEntity<>(status);
     }
 
     /**
@@ -63,16 +64,20 @@ public class DomainsController {
      <p>API method to delete domain</p>
      */
     @RequestMapping(value = "/{domainId}", method = RequestMethod.DELETE)
-    public @ResponseBody Map<String, Boolean> deleteDomain(@PathVariable("domainId") String domainId){
+    public ResponseEntity<String> deleteDomain(@PathVariable("domainId") String domainId){
         boolean response = sharingRegistryService.deleteDomain(domainId);
-        return Collections.singletonMap("success", response);
+        if(response){
+            return new ResponseEntity<>(HttpStatus.OK);
+        }else{
+            throw new SharingRegistryException("Could not delete the domain");
+        }
     }
 
     /**
      <p>API method to get all domain.</p>
      */
-    @RequestMapping(value = "/offset/{offset}/limit/{limit}", method = RequestMethod.GET)
-    public @ResponseBody List<Domain> getDomains(@PathVariable("offset") int offset, @PathVariable("limit") int limit){
+    @RequestMapping(method = RequestMethod.GET)
+    public @ResponseBody List<Domain> getDomains(@RequestParam(value = "offset") int offset, @RequestParam(value = "limit") int limit){
         return sharingRegistryService.getDomains(offset, limit);
     }
 
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java
index 60fdc6a..b155fd7 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityController.java
@@ -1,5 +1,6 @@
 package org.apache.custos.sharing.service.api.controllers;
 
+import org.apache.custos.sharing.service.core.exceptions.ResourceNotFoundException;
 import org.apache.custos.sharing.service.core.models.Entity;
 import org.apache.custos.sharing.service.core.models.SearchCriteria;
 import org.apache.custos.sharing.service.core.models.User;
@@ -11,12 +12,11 @@ import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Collections;
+import javax.validation.Valid;
 import java.util.List;
-import java.util.Map;
 
 @RestController
-@RequestMapping("/entity")
+@RequestMapping("/domains/{domainId}/entities")
 public class EntityController {
 
     @Autowired
@@ -25,11 +25,11 @@ public class EntityController {
     /**
      <p>API method to register new entity</p>
      */
-    @RequestMapping(value = "/create", method = RequestMethod.POST)
-    public ResponseEntity<String> createEntity(@RequestBody Entity entity){
-        String createdEntityId = sharingRegistryService.createEntity(entity);
-        if(createdEntityId.equals(entity.getEntityId())){
-            return new ResponseEntity<>(HttpStatus.OK);
+    @RequestMapping(method = RequestMethod.POST)
+    public @ResponseBody Entity createEntity(@Valid @RequestBody Entity entity){
+        Entity createdEntity = sharingRegistryService.createEntity(entity);
+        if(createdEntity != null){
+            return createdEntity;
         }
         else throw new SharingRegistryException("Failed to create the entity");
     }
@@ -37,8 +37,8 @@ public class EntityController {
     /**
      <p>API method to update entity</p>
      */
-    @RequestMapping(value = "/update", method = RequestMethod.PUT)
-    public ResponseEntity<String> updateEntity(@RequestBody Entity entity){
+    @RequestMapping(method = RequestMethod.PUT)
+    public ResponseEntity<String> updateEntity(@Valid @RequestBody Entity entity){
         boolean response = sharingRegistryService.updateEntity(entity);
         if(response) return new ResponseEntity<>(HttpStatus.OK);
         else throw new SharingRegistryException("Failed to update the entity");
@@ -47,16 +47,20 @@ public class EntityController {
     /**
      <p>API method to check Entity Exists</p>
      */
-    @RequestMapping(value = "/exists/id/{entityId}/domain/{domainId}", method = RequestMethod.GET)
-    public @ResponseBody Map<String, Boolean> isEntityExists(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
+    @RequestMapping(value = "/{entityId}", method = RequestMethod.HEAD)
+    public ResponseEntity<String> isEntityExists(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
         boolean response = sharingRegistryService.isEntityExists(entityId, domainId);
-        return Collections.singletonMap("exists", response);
+        HttpStatus status = HttpStatus.NOT_FOUND;
+        if(response){
+            status = HttpStatus.OK;
+        }
+        return new ResponseEntity<>(status);
     }
 
     /**
      <p>API method to delete entity</p>
      */
-    @RequestMapping(value = "/id/{entityId}/domain/{domainId}", method = RequestMethod.DELETE)
+    @RequestMapping(value = "/{entityId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> deleteEntity(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
         boolean response = sharingRegistryService.deleteEntity(domainId, entityId);
         if(response) return new ResponseEntity<>(HttpStatus.OK);
@@ -66,19 +70,18 @@ public class EntityController {
     /**
      <p>API method to get entity</p>
      */
-    @RequestMapping(value = "/id/{entityId}/domain/{domainId}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{entityId}", method = RequestMethod.GET)
     public @ResponseBody Entity getEntity(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId){
         Entity entity = sharingRegistryService.getEntity(domainId, entityId);
         if(entity != null) return entity;
-        //TODO: not found exception should be thrown??
-        else throw new SharingRegistryException("Could not retrieve the entity");
+        else throw new ResourceNotFoundException("Could not find entity with entityId:" + entityId + " in domain:" + domainId);
     }
 
     /**
      <p>API method to search entities</p>
      */
-    @RequestMapping(value = "/search/domain/{domainId}/user/{userId}/offset/{offset}/limit/{limit}", method = RequestMethod.POST)
-    public @ResponseBody List<Entity> searchEntities(@RequestBody List<SearchCriteria> filters, @PathVariable("domainId") String domainId, @PathVariable("userId") String userId, @PathVariable("offset") int offset, @PathVariable("limit") int limit){
+    @RequestMapping(value = "/users/{userId}", method = RequestMethod.GET)
+    public @ResponseBody List<Entity> searchEntities(@RequestBody List<SearchCriteria> filters, @PathVariable("domainId") String domainId, @PathVariable("userId") String userId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
         List<Entity> entities = sharingRegistryService.searchEntities(domainId, userId, filters, offset, limit);
         return entities;
     }
@@ -86,7 +89,7 @@ public class EntityController {
     /**
      <p>API method to get a list of shared users given the entity id</p>
      */
-    @RequestMapping(value = "/sharedUsers/id/{entityId}/domain/{domainId}/permissionType/{permissionTypeId}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{entityId}/permissionType/{permissionTypeId}/users", method = RequestMethod.GET)
     public @ResponseBody List<User> getListOfSharedUsers(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId, @PathVariable("permissionTypeId") String permissionTypeId){
         return sharingRegistryService.getListOfSharedUsers(domainId, entityId, permissionTypeId);
     }
@@ -94,7 +97,7 @@ public class EntityController {
     /**
      <p>API method to get a list of shared users given the entity id where the sharing type is directly applied</p>
      */
-    @RequestMapping(value = "/directlySharedUsers/id/{entityId}/domain/{domainId}/permissionType/{permissionTypeId}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{entityId}/permissionType/{permissionTypeId}/directUsers/", method = RequestMethod.GET)
     public @ResponseBody List<User> getListOfDirectlySharedUsers(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId, @PathVariable("permissionTypeId") String permissionTypeId){
         return sharingRegistryService.getListOfDirectlySharedUsers(domainId, entityId, permissionTypeId);
     }
@@ -102,7 +105,7 @@ public class EntityController {
     /**
      <p>API method to get a list of shared groups given the entity id</p>
      */
-    @RequestMapping(value = "/sharedGroups/id/{entityId}/domain/{domainId}/permissionType/{permissionTypeId}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{entityId}/permissionType/{permissionTypeId}/groups", method = RequestMethod.GET)
     public @ResponseBody List<UserGroup> getListOfSharedGroups(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId, @PathVariable("permissionTypeId") String permissionTypeId){
         return sharingRegistryService.getListOfSharedGroups(domainId, entityId, permissionTypeId);
     }
@@ -110,7 +113,7 @@ public class EntityController {
     /**
      <p>API method to get a list of directly shared groups given the entity id where the sharing type is directly applied</p>
      */
-    @RequestMapping(value = "/directlySharedGroups/id/{entityId}/domain/{domainId}/permissionType/{permissionTypeId}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{entityId}/permissionType/{permissionTypeId}/directGroups", method = RequestMethod.GET)
     public @ResponseBody List<UserGroup> getListOfDirectlySharedGroups(@PathVariable("entityId") String entityId, @PathVariable("domainId") String domainId, @PathVariable("permissionTypeId") String permissionTypeId){
         return sharingRegistryService.getListOfDirectlySharedGroups(domainId, entityId, permissionTypeId);
     }
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java
index a806c38..1b8624b 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/EntityTypeController.java
@@ -9,24 +9,25 @@ import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
 @RestController
-@RequestMapping("/entityType")
+@RequestMapping("/domains/{domainId}/entityTypes")
 public class EntityTypeController {
 
     @Autowired
-    private static SharingRegistryService sharingRegistryService;
+    SharingRegistryService sharingRegistryService;
     /**
      <p>API method to create a new entity type</p>
      */
-    @RequestMapping(value = "/create", method = RequestMethod.POST)
-    public ResponseEntity<String> createEntityType(@RequestBody EntityType entityType){
-        String createdEntityTypeId = sharingRegistryService.createEntityType(entityType);
-        if(createdEntityTypeId.equals(entityType.getEntityTypeId())){
-            return new ResponseEntity<>(HttpStatus.OK);
+    @RequestMapping(method = RequestMethod.POST)
+    public EntityType createEntityType(@Valid @RequestBody EntityType entityType){
+        EntityType createdEntityType = sharingRegistryService.createEntityType(entityType);
+        if(createdEntityType != null){
+            return createdEntityType;
         }
         else{
             throw new SharingRegistryException("Failed to create the entity type");
@@ -36,8 +37,8 @@ public class EntityTypeController {
     /**
      <p>API method to update entity type</p>
      */
-    @RequestMapping(value = "/update", method = RequestMethod.PUT)
-    public ResponseEntity<String> updateEntityType(@RequestBody EntityType entityType){
+    @RequestMapping(method = RequestMethod.PUT)
+    public ResponseEntity<String> updateEntityType(@Valid @RequestBody EntityType entityType){
         boolean response = sharingRegistryService.updateEntityType(entityType);
         if(response){
             return new ResponseEntity<>(HttpStatus.OK);
@@ -50,16 +51,20 @@ public class EntityTypeController {
     /**
      <p>API method to check EntityType Exists</p>
      */
-    @RequestMapping(value = "/exists/id/{entityTypeId/domain/{domainId}", method = RequestMethod.GET)
-    public @ResponseBody Map<String, Boolean> isEntityTypeExists(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
+    @RequestMapping(value = "/{entityTypeId}", method = RequestMethod.HEAD)
+    public ResponseEntity<String> isEntityTypeExists(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
         boolean response = sharingRegistryService.isEntityTypeExists(domainId, entityTypeId);
-        return Collections.singletonMap("exists", response);
+        HttpStatus status = HttpStatus.NOT_FOUND;
+        if(response){
+            status = HttpStatus.OK;
+        }
+        return new ResponseEntity<>(status);
     }
 
     /**
      <p>API method to delete entity type</p>
      */
-    @RequestMapping(value = "/id/{entityTypeId}/domain/{domainId}", method = RequestMethod.DELETE)
+    @RequestMapping(value = "/{entityTypeId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> deleteEntityType(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
         boolean response = sharingRegistryService.deleteEntityType(domainId, entityTypeId);
         if(response){
@@ -73,7 +78,7 @@ public class EntityTypeController {
     /**
      <p>API method to get an entity type</p>
      */
-    @RequestMapping(value = "/id/{entityTypeId}/domain/{domainId}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{entityTypeId}", method = RequestMethod.GET)
     public @ResponseBody EntityType getEntityType(@PathVariable("entityTypeId") String entityTypeId, @PathVariable("domainId") String domainId){
         EntityType entityType = sharingRegistryService.getEntityType(domainId, entityTypeId);
         if(entityType != null){
@@ -87,8 +92,8 @@ public class EntityTypeController {
     /**
      <p>API method to get entity types in a domainId.</p>
      */
-    @RequestMapping(value = "/domain/{domainId}/offset/{offset}/limit/{limit}", method = RequestMethod.GET)
-    public @ResponseBody List<EntityType> getEntityTypes(@PathVariable("domainId") String domainId, @PathVariable("offset") int offset, @PathVariable("limit") int limit){
+    @RequestMapping(method = RequestMethod.GET)
+    public @ResponseBody List<EntityType> getEntityTypes(@PathVariable("domainId") String domainId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
        List<EntityType> entityTypes = sharingRegistryService.getEntityTypes(domainId, offset, limit);
        return entityTypes;
     }
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java
index 0c1eced..6dbc993 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/GroupController.java
@@ -11,24 +11,24 @@ import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Collections;
+import javax.validation.Valid;
 import java.util.List;
-import java.util.Map;
 
 @RestController
+@RequestMapping("/domains/{domainId}/groups")
 public class GroupController {
 
     @Autowired
-    private static SharingRegistryService sharingRegistryService;
+    SharingRegistryService sharingRegistryService;
 
     /**
      <p>API method to create a new group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups", method = RequestMethod.POST)
-    public ResponseEntity<String> createGroup(@RequestBody UserGroup group){
-        String createdGroupId = sharingRegistryService.createGroup(group);
-        if(createdGroupId.equals(group.getGroupId())){
-            return new ResponseEntity<>(HttpStatus.OK);
+    @RequestMapping(method = RequestMethod.POST)
+    public @ResponseBody UserGroup createGroup(@Valid @RequestBody UserGroup group){
+        UserGroup createdUserGroup = sharingRegistryService.createGroup(group);
+        if(createdUserGroup != null){
+            return createdUserGroup;
         }else{
             throw new SharingRegistryException("Failed to create group");
         }
@@ -37,8 +37,8 @@ public class GroupController {
     /**
      <p>API method to update a group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups", method = RequestMethod.PUT)
-    public ResponseEntity<String> updateGroup(@RequestBody UserGroup group){
+    @RequestMapping(method = RequestMethod.PUT)
+    public ResponseEntity<String> updateGroup(@Valid @RequestBody UserGroup group){
         boolean response = sharingRegistryService.updateGroup(group);
         if(response){
             return new ResponseEntity<>(HttpStatus.OK);
@@ -51,7 +51,7 @@ public class GroupController {
     /**
      <p>API method to check Group Exists</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}", method = RequestMethod.HEAD)
+    @RequestMapping(value = "/{groupId}", method = RequestMethod.HEAD)
     public ResponseEntity<String> isGroupExists(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId){
         boolean response = sharingRegistryService.isGroupExists(domainId, groupId);
         HttpStatus status = HttpStatus.NOT_FOUND;
@@ -64,7 +64,7 @@ public class GroupController {
     /**
      <p>API method to delete a group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}", method = RequestMethod.DELETE)
+    @RequestMapping(value = "/{groupId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> deleteGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId){
         boolean response = sharingRegistryService.deleteGroup(domainId, groupId);
         if(response){
@@ -78,7 +78,7 @@ public class GroupController {
     /**
      <p>API method to get a group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{groupId}", method = RequestMethod.GET)
     public @ResponseBody UserGroup getGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId){
         UserGroup userGroup = sharingRegistryService.getGroup(domainId,groupId);
         if(userGroup != null){
@@ -91,7 +91,7 @@ public class GroupController {
     /**
      <p>API method to get groups in a domainId.</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups",method = RequestMethod.GET)
+    @RequestMapping(value = "/groups",method = RequestMethod.GET)
     public @ResponseBody List<UserGroup> getGroups(@PathVariable("domainId") String domainId, @RequestParam int offset, @RequestParam int limit){
         return sharingRegistryService.getGroups(domainId, offset, limit);
     }
@@ -99,7 +99,7 @@ public class GroupController {
     /**
      <p>API method to add list of users to a group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/users", method = RequestMethod.POST)
+    @RequestMapping(value = "/{groupId}/users", method = RequestMethod.POST)
     public ResponseEntity<String> addUsersToGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId, @RequestBody List<String> userIds){
         boolean response = sharingRegistryService.addUsersToGroup(domainId, userIds, groupId);
         if(response){
@@ -113,8 +113,8 @@ public class GroupController {
     /**
      <p>API method to remove users from a group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/users", method = RequestMethod.DELETE)
-    public ResponseEntity<String> removeUsersFromGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId, @RequestBody List<String> userIds){
+    @RequestMapping(value = "/{groupId}/users", method = RequestMethod.DELETE)
+    public ResponseEntity<String> removeUsersFromGroup(@PathVariable("groupId") String groupId, @PathVariable("domainId") String domainId, @RequestParam("ids") List<String> userIds){
         boolean response = sharingRegistryService.removeUsersFromGroup(domainId, userIds, groupId);
         if(response){
             return new ResponseEntity<>(HttpStatus.OK);
@@ -127,7 +127,7 @@ public class GroupController {
     /**
      <p>API method to transfer group ownership</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/owners/{ownerId}", method = RequestMethod.PUT)
+    @RequestMapping(value = "/{groupId}/owners/{ownerId}", method = RequestMethod.PUT)
     public ResponseEntity<String> transferGroupOwnership(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @PathVariable("ownerId") String newOwnerId){
         boolean response = sharingRegistryService.transferGroupOwnership(domainId,groupId, newOwnerId);
         if(response){
@@ -141,7 +141,7 @@ public class GroupController {
     /**
      <p>API method to add Admin for a group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/admins", method = RequestMethod.POST)
+    @RequestMapping(value = "/{groupId}/admins", method = RequestMethod.POST)
     public ResponseEntity<String> addGroupAdmins(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @RequestBody List<GroupAdmin> admins){
         boolean response = sharingRegistryService.addGroupAdmins(domainId,groupId, admins);
         if(response){
@@ -155,8 +155,8 @@ public class GroupController {
     /**
      <p>API method to remove Admin for a group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/admins", method = RequestMethod.DELETE)
-    public ResponseEntity<String> removeGroupAdmins(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @RequestBody List<String> adminIds){
+    @RequestMapping(value = "/{groupId}/admins", method = RequestMethod.DELETE)
+    public ResponseEntity<String> removeGroupAdmins(@PathVariable("domainId") String domainId,@PathVariable("groupId") String groupId, @RequestParam("ids") List<String> adminIds){
         boolean response = sharingRegistryService.removeGroupAdmins(domainId,groupId, adminIds);
         if(response){
             return new ResponseEntity<>(HttpStatus.OK);
@@ -169,7 +169,7 @@ public class GroupController {
     /**
      <p>API method to check whether the user has Admin access for the group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/admin/{adminId}", method = RequestMethod.HEAD)
+    @RequestMapping(value = "/{groupId}/admins/{adminId}", method = RequestMethod.HEAD)
     public ResponseEntity<String> hasAdminAccess(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @PathVariable("adminId") String adminId){
         boolean response = sharingRegistryService.hasAdminAccess(domainId, groupId, adminId);
         HttpStatus status = HttpStatus.NOT_FOUND;
@@ -182,7 +182,7 @@ public class GroupController {
     /**
      <p>API method to check whether the user has Owner access for the group</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/owner/{ownerId}", method = RequestMethod.HEAD)
+    @RequestMapping(value = "/{groupId}/owners/{ownerId}", method = RequestMethod.HEAD)
     public ResponseEntity<String> hasOwnerAccess(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
         boolean response = sharingRegistryService.hasOwnerAccess(domainId, groupId, ownerId);
         HttpStatus status = HttpStatus.NOT_FOUND;
@@ -195,23 +195,23 @@ public class GroupController {
     /**
      <p>API method to get list of child users in a group. Only the direct members will be returned.</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/users", method = RequestMethod.GET)
-    public List<User> getGroupMembersOfTypeUser(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
+    @RequestMapping(value = "/{groupId}/users", method = RequestMethod.GET)
+    public @ResponseBody List<User> getGroupMembersOfTypeUser(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
         return sharingRegistryService.getGroupMembersOfTypeUser(domainId, groupId, offset, limit);
     }
 
     /**
      <p>API method to get list of child groups in a group. Only the direct members will be returned.</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/subgroups", method = RequestMethod.GET)
-    public List<UserGroup> getGroupMembersOfTypeGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
+    @RequestMapping(value = "/{groupId}/subgroups", method = RequestMethod.GET)
+    public @ResponseBody List<UserGroup> getGroupMembersOfTypeGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
         return sharingRegistryService.getGroupMembersOfTypeGroup(domainId, groupId, offset, limit);
     }
 
     /**
      <p>API method to add a child group to a parent group.</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/subgroups", method = RequestMethod.POST)
+    @RequestMapping(value = "/{groupId}/subgroups", method = RequestMethod.POST)
     public ResponseEntity<String> addChildGroupsToParentGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @RequestBody List<String> childIds){
         boolean response = sharingRegistryService.addChildGroupsToParentGroup(domainId, childIds, groupId);
         if(response){
@@ -224,7 +224,7 @@ public class GroupController {
     /**
      <p>API method to remove a child group from parent group.</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/groups/{groupId}/subgroups", method = RequestMethod.DELETE)
+    @RequestMapping(value = "/{groupId}/subgroups/{childGroupId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> removeChildGroupFromParentGroup(@PathVariable("domainId") String domainId, @PathVariable("groupId") String groupId, @PathVariable("childGroupId") String childGroupId){
         boolean response = sharingRegistryService.removeChildGroupFromParentGroup(domainId, childGroupId, groupId);
         if(response){
@@ -237,8 +237,33 @@ public class GroupController {
     /**
      <p>API method to get all groups user is a member of.</p>
      */
-    @RequestMapping(value = "/domains/{domainId}/users/{userId}/groups", method = RequestMethod.PUT)
+    @RequestMapping(value = "/users/{userId}", method = RequestMethod.GET)
     public @ResponseBody List<UserGroup> getAllMemberGroupsForUser(@PathVariable("domainId") String domainId, @PathVariable("userId") String userId){
         return sharingRegistryService.getAllMemberGroupsForUser(domainId, userId);
     }
+
+//    public static void main(String[] args) throws Exception{
+//        String url = "http://localhost:7070";
+//        String r = "/domains/default/groups";
+//        UserGroup test = new UserGroup();
+//        test.setGroupId("teqq1");
+//        test.setDomainId("default");
+//        test.setOwnerId("default-admin@default");
+//        test.setName("");
+//        test.setGroupType(GroupType.USER_LEVEL_GROUP);
+//        ServiceRequest serviceRequest = new ServiceRequest();
+//        HttpResponse response = serviceRequest.httpPost(url, r, test);
+//        System.out.println(response);
+//        if(response.getStatusLine().getStatusCode() == org.apache.http.HttpStatus.SC_OK) {
+//            BufferedReader rd = new BufferedReader(
+//                    new InputStreamReader(response.getEntity().getContent()));
+//            StringBuffer result = new StringBuffer();
+//            String line = "";
+//            while ((line = rd.readLine()) != null) {
+//                result.append(line);
+//            }
+//            JSONObject jsonObject = new JSONObject(result.toString());
+//            System.out.println(jsonObject.get("groupId"));
+//        }
+//    }
 }
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java
index cfcf567..81c9941 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/PermissionTypeController.java
@@ -9,24 +9,25 @@ import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
 @RestController
-@RequestMapping("/permissionType")
+@RequestMapping("domain/{domainId}/permissionTypes")
 public class PermissionTypeController {
 
     @Autowired
-    private static SharingRegistryService sharingRegistryService;
+    SharingRegistryService sharingRegistryService;
     /**
      <p>API method to create permission type</p>
      */
-    @RequestMapping(value= "/create", method = RequestMethod.POST)
-    public ResponseEntity<String> createPermissionType(@RequestBody PermissionType permissionType){
-        String permissionTypeId = sharingRegistryService.createPermissionType(permissionType);
-        if(permissionTypeId.equals(permissionType.getPermissionTypeId())){
-            return new ResponseEntity<>(HttpStatus.OK);
+    @RequestMapping(method = RequestMethod.POST)
+    public @ResponseBody PermissionType createPermissionType(@Valid @RequestBody PermissionType permissionType){
+        PermissionType createdPermissionType = sharingRegistryService.createPermissionType(permissionType);
+        if(createdPermissionType != null){
+            return createdPermissionType;
         }else{
             throw new SharingRegistryException("Could not create the permission type");
         }
@@ -35,8 +36,8 @@ public class PermissionTypeController {
     /**
      <p>API method to update permission type</p>
      */
-    @RequestMapping(value= "/update", method = RequestMethod.PUT)
-    public ResponseEntity<String> updatePermissionType(@RequestBody PermissionType permissionType){
+    @RequestMapping(method = RequestMethod.PUT)
+    public ResponseEntity<String> updatePermissionType(@Valid @RequestBody PermissionType permissionType){
 
         boolean response = sharingRegistryService.updatePermissionType(permissionType);
         if(response){
@@ -49,17 +50,20 @@ public class PermissionTypeController {
     /**
      <p>API method to check Permission Exists</p>
      */
-    @RequestMapping(value= "/exists/id/{permissionId}/domain/{domainId}", method = RequestMethod.GET)
-    public @ResponseBody
-    Map<String, Boolean> isPermissionExists(@PathVariable("permissionId") String permissionId, @PathVariable("domainId") String domainId){
+    @RequestMapping(value= "/{permissionId}", method = RequestMethod.HEAD)
+    public ResponseEntity<String> isPermissionExists(@PathVariable("permissionId") String permissionId, @PathVariable("domainId") String domainId){
         boolean response = sharingRegistryService.isPermissionExists(domainId, permissionId);
-        return Collections.singletonMap("exists", response);
+        HttpStatus status = HttpStatus.NOT_FOUND;
+        if(response){
+            status = HttpStatus.OK;
+        }
+        return new ResponseEntity<>(status);
     }
 
     /**
      <p>API method to delete permission type</p>
      */
-    @RequestMapping(value= "/id/{permissionTypeId}/domain/{domainId}", method = RequestMethod.DELETE)
+    @RequestMapping(value= "/{permissionTypeId}", method = RequestMethod.DELETE)
     public ResponseEntity<String> deletePermissionType(@PathVariable("permissionTypeId") String permissionTypeId, @PathVariable("domainId") String domainId){
         boolean response = sharingRegistryService.deletePermissionType(domainId,permissionTypeId);
         if(response){
@@ -72,7 +76,7 @@ public class PermissionTypeController {
     /**
      <p>API method to get permission type</p>
      */
-    @RequestMapping(value= "/id/{permissionTypeId}/domain/{domainId}", method = RequestMethod.GET)
+    @RequestMapping(value= "/{permissionTypeId}", method = RequestMethod.GET)
     public @ResponseBody PermissionType getPermissionType(@PathVariable("permissionTypeId") String permissionTypeId, @PathVariable("domainId") String domainId){
         PermissionType permissionType = sharingRegistryService.getPermissionType(domainId, permissionTypeId);
         if(permissionType != null){
@@ -85,9 +89,9 @@ public class PermissionTypeController {
     /**
      <p>API method to get list of permission types in a given domainId.</p>
      */
-    @RequestMapping(value= "/domain/{domainId}/offset/{offset}/limit/{limit}", method = RequestMethod.GET)
+    @RequestMapping(method = RequestMethod.GET)
     public @ResponseBody
-    List<PermissionType> getPermissionTypes(@PathVariable("domainId") String domainId, @PathVariable("offset") int offset, @PathVariable("limit") int limit){
+    List<PermissionType> getPermissionTypes(@PathVariable("domainId") String domainId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
         return sharingRegistryService.getPermissionTypes(domainId, offset, limit);
     }
 
diff --git a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java
index 00ef0a4..b880170 100644
--- a/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java
+++ b/custos-sharing-registry-service/sharing-service-api/src/main/java/org/apache/custos/sharing/service/api/controllers/UsersController.java
@@ -9,25 +9,24 @@ import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Collections;
+import javax.validation.Valid;
 import java.util.List;
-import java.util.Map;
 
 @RestController
-@RequestMapping("/user")
+@RequestMapping("/domains/{domainId}/users")
 public class UsersController {
 
     @Autowired
-    private static SharingRegistryService sharingRegistryService;
+    SharingRegistryService sharingRegistryService;
 
     /**
      <p>API method to register a user in the system</p>
      */
     @RequestMapping(method = RequestMethod.POST)
-    public ResponseEntity<String> createUser(@RequestBody User user){
-        String userId = sharingRegistryService.createUser(user);
-        if(userId.equals(user.getUserId())){
-            return new ResponseEntity<>(HttpStatus.OK);
+    public @ResponseBody User createUser(@Valid @RequestBody User user){
+        User createdUser = sharingRegistryService.createUser(user);
+        if(createdUser != null){
+            return createdUser;
         }else{
             throw new SharingRegistryException("Failed to create the user");
         }
@@ -37,7 +36,7 @@ public class UsersController {
      <p>API method to update existing user</p>
      */
     @RequestMapping(method = RequestMethod.PUT)
-    public ResponseEntity<String> updateUser(@RequestBody User user){
+    public ResponseEntity<String> updateUser(@Valid @RequestBody User user){
         boolean response = sharingRegistryService.updatedUser(user);
         if(response){
             return new ResponseEntity<>(HttpStatus.OK);
@@ -49,17 +48,20 @@ public class UsersController {
     /**
      <p>API method to check User Exists</p>
      */
-    @RequestMapping(value = "/exists/domainId/{domainId}/userId/{userId}", method = RequestMethod.GET)
-    public @ResponseBody
-    Map<String, Boolean> isUserExists(@PathVariable("domainId") String domainId, @PathVariable("userId") String userId){
+    @RequestMapping(value = "/{userId}", method = RequestMethod.HEAD)
+    public ResponseEntity<String> isUserExists(@PathVariable("domainId") String domainId, @PathVariable("userId") String userId){
         boolean response = sharingRegistryService.isUserExists(domainId, userId);
-        return Collections.singletonMap("exists", response);
+        if(response){
+            return new ResponseEntity<>(HttpStatus.OK);
+        }else{
+            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+        }
     }
 
     /**
      <p>API method to delete user</p>
      */
-    @RequestMapping(value="/id/{userId}/domain/{domainId}",method = RequestMethod.DELETE)
+    @RequestMapping(value="/{userId}",method = RequestMethod.DELETE)
     public ResponseEntity<String> deleteUser(@PathVariable("userId") String userId, @PathVariable("domainId") String domainId){
         boolean response = sharingRegistryService.deleteUser(domainId, userId);
         if(response){
@@ -72,7 +74,7 @@ public class UsersController {
     /**
      <p>API method to get a user</p>
      */
-    @RequestMapping(value = "/domain/{domainId}/user/{userId}", method = RequestMethod.GET)
+    @RequestMapping(value = "/{userId}", method = RequestMethod.GET)
     public User getUser(@PathVariable("domainId") String domainId,@PathVariable("userId") String userId){
         User user = sharingRegistryService.getUser(domainId, userId);
         if(user != null){
@@ -88,8 +90,8 @@ public class UsersController {
      <li>offset : Starting result number</li>
      <li>limit : Number of max results to be sent</li>
      */
-    @RequestMapping(value = "/domainId/{domainId}/offset/{offset}/limit/{limit}")
-    public List<User> getUsers(@PathVariable("domainId") String domainId, @PathVariable("offset") int offset, @PathVariable("limit") int limit){
+    @RequestMapping(method = RequestMethod.GET)
+    public List<User> getUsers(@PathVariable("domainId") String domainId, @RequestParam("offset") int offset, @RequestParam("limit") int limit){
         return sharingRegistryService.getUsers(domainId,offset, limit);
     }
 }
diff --git a/custos-sharing-registry-service/sharing-service-core/pom.xml b/custos-sharing-registry-service/sharing-service-core/pom.xml
index 7922b89..60e8baa 100644
--- a/custos-sharing-registry-service/sharing-service-core/pom.xml
+++ b/custos-sharing-registry-service/sharing-service-core/pom.xml
@@ -54,5 +54,42 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.5.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.3.2</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.openjpa</groupId>
+                <artifactId>openjpa-maven-plugin</artifactId>
+                <version>${openjpa.version}</version>
+                <configuration>
+                    <includes>**/entities/*.class</includes>
+                    <excludes>**/entities/XML*.class</excludes>
+                    <addDefaultConstructor>true</addDefaultConstructor>
+                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>enhancer</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>enhance</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 </project>
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/DomainEntity.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/DomainEntity.java
index ad960a5..d550367 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/DomainEntity.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/entities/DomainEntity.java
@@ -21,7 +21,6 @@ package org.apache.custos.sharing.service.core.db.entities;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import javax.persistence.*;
 
 @Entity
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/EntityRepository.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/EntityRepository.java
index 2f16f60..42fc050 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/EntityRepository.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/repositories/EntityRepository.java
@@ -148,7 +148,7 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity, E
             entity.setDescription((String)(rs[6]));
             entity.setBinaryData((byte[]) (rs[7]));
             entity.setFullText((String) (rs[8]));
-            entity.setSharedCount((long) rs[9]);
+            entity.setSharedCount((int) rs[9]);
             entity.setOriginalEntityCreationTime((long) (rs[10]));
             entity.setCreatedTime((long) (rs[11]));
             entity.setUpdatedTime((long) (rs[12]));
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/JPAUtils.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/JPAUtils.java
index 6640c46..8838018 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/JPAUtils.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/db/utils/JPAUtils.java
@@ -25,7 +25,7 @@ import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 
 public class JPAUtils {
-    public static final String PERSISTENCE_UNIT_NAME = "airavata-sharing-registry";
+    public static final String PERSISTENCE_UNIT_NAME = "custos-sharing-registry";
     private static final JDBCConfig JDBC_CONFIG = new SharingRegistryJDBCConfig();
     private static final EntityManagerFactory factory = org.apache.custos.commons.utils.JPAUtils.getEntityManagerFactory(PERSISTENCE_UNIT_NAME, JDBC_CONFIG);
 
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java
index b7f8733..fe71464 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Domain.java
@@ -1,11 +1,20 @@
 package org.apache.custos.sharing.service.core.models;
 
+import javax.validation.constraints.NotNull;
+
 public class Domain {
-    private String domainId = "DO_NOT_SET_AT_CLIENTS_ID";
+
+    @NotNull(message = "Domain id cannot be null")
+    private String domainId;
+
+    @NotNull(message = "Domain name cannot be null")
     private String name;
+
     private String description;
-    private double createdTime;
-    private double updatedTime;
+
+    private Long createdTime;
+
+    private Long updatedTime;
 
     public String getDomainId() {
         return domainId;
@@ -31,11 +40,11 @@ public class Domain {
         this.description = description;
     }
 
-    public double getCreatedTime() {
+    public Long getCreatedTime() {
         return createdTime;
     }
 
-    public void setCreatedTime(double createdTime) {
+    public void setCreatedTime(Long createdTime) {
         this.createdTime = createdTime;
     }
 
@@ -43,7 +52,7 @@ public class Domain {
         return updatedTime;
     }
 
-    public void setUpdatedTime(double updatedTime) {
+    public void setUpdatedTime(Long updatedTime) {
         this.updatedTime = updatedTime;
     }
 }
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Entity.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Entity.java
index 0410130..1531057 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Entity.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Entity.java
@@ -1,19 +1,34 @@
 package org.apache.custos.sharing.service.core.models;
 
+import javax.validation.constraints.NotNull;
+
 public class Entity {
+    
+    @NotNull(message = "Entity id cannot be null")
     private String entityId;
+
+    @NotNull(message = "Domain id for the Entity id cannot be null")
     private String domainId;
+
+    @NotNull(message = "Entity type id cannot be null")
     private String entityTypeId;
+
+    @NotNull(message = "Owner id cannot be null")
     private String ownerId;
+    
     private String parentEntityId;
+    
     private String name;
+    
     private String description;
+
     private byte[] binaryData;
     private String fullText;
-    private double sharedCount = 0;
-    private double originalEntityCreationTime;
-    private double createdTime;
-    private double updatedTime;
+    private Long originalEntityCreationTime;
+    private int sharedCount;
+    private Long createdTime;
+    private Long updatedTime;
+
 
     public String getEntityId() {
         return entityId;
@@ -87,35 +102,35 @@ public class Entity {
         this.fullText = fullText;
     }
 
-    public double getSharedCount() {
+    public int getSharedCount() {
         return sharedCount;
     }
 
-    public void setSharedCount(double sharedCount) {
+    public void setSharedCount(int sharedCount) {
         this.sharedCount = sharedCount;
     }
 
-    public double getOriginalEntityCreationTime() {
+    public Long getOriginalEntityCreationTime() {
         return originalEntityCreationTime;
     }
 
-    public void setOriginalEntityCreationTime(double originalEntityCreationTime) {
+    public void setOriginalEntityCreationTime(Long originalEntityCreationTime) {
         this.originalEntityCreationTime = originalEntityCreationTime;
     }
 
-    public double getCreatedTime() {
+    public Long getCreatedTime() {
         return createdTime;
     }
 
-    public void setCreatedTime(double createdTime) {
+    public void setCreatedTime(Long createdTime) {
         this.createdTime = createdTime;
     }
 
-    public double getUpdatedTime() {
+    public Long getUpdatedTime() {
         return updatedTime;
     }
 
-    public void setUpdatedTime(double updatedTime) {
+    public void setUpdatedTime(Long updatedTime) {
         this.updatedTime = updatedTime;
     }
 }
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/EntityType.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/EntityType.java
index 1df393d..34681d2 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/EntityType.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/EntityType.java
@@ -1,12 +1,23 @@
 package org.apache.custos.sharing.service.core.models;
 
+import javax.validation.constraints.NotNull;
+
 public class EntityType {
+
+    @NotNull(message = "Entity type id cannot be null")
     private String entityTypeId;
+
+    @NotNull(message = "Domain id for entity type cannot be null")
     private String domainId;
+
+    @NotNull(message = "Name for entity type cannot be null")
     private String name;
+
     private String description;
-    private double createdTime;
-    private double updatedTime;
+
+    private Long createdTime;
+
+    private Long updatedTime;
 
     public String getEntityTypeId() {
         return entityTypeId;
@@ -40,19 +51,19 @@ public class EntityType {
         this.description = description;
     }
 
-    public double getCreatedTime() {
+    public Long getCreatedTime() {
         return createdTime;
     }
 
-    public void setCreatedTime(double createdTime) {
+    public void setCreatedTime(Long createdTime) {
         this.createdTime = createdTime;
     }
 
-    public double getUpdatedTime() {
+    public Long getUpdatedTime() {
         return updatedTime;
     }
 
-    public void setUpdatedTime(double updatedTime) {
+    public void setUpdatedTime(Long updatedTime) {
         this.updatedTime = updatedTime;
     }
 }
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupMembership.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupMembership.java
index d07a002..4089473 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupMembership.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/GroupMembership.java
@@ -6,8 +6,8 @@ public class GroupMembership {
     private String childId;
     private String domainId;
     private GroupChildType childType;
-    private double createdTime;
-    private double updatedTime;
+    private Long createdTime;
+    private Long updatedTime;
 
     public String getParentId() {
         return parentId;
@@ -41,19 +41,19 @@ public class GroupMembership {
         this.childType = childType;
     }
 
-    public double getCreatedTime() {
+    public Long getCreatedTime() {
         return createdTime;
     }
 
-    public void setCreatedTime(double createdTime) {
+    public void setCreatedTime(Long createdTime) {
         this.createdTime = createdTime;
     }
 
-    public double getUpdatedTime() {
+    public Long getUpdatedTime() {
         return updatedTime;
     }
 
-    public void setUpdatedTime(double updatedTime) {
+    public void setUpdatedTime(Long updatedTime) {
         this.updatedTime = updatedTime;
     }
 
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/PermissionType.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/PermissionType.java
index 1ae87c2..35f815e 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/PermissionType.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/PermissionType.java
@@ -1,13 +1,22 @@
 package org.apache.custos.sharing.service.core.models;
 
+import javax.validation.constraints.NotNull;
+
 public class PermissionType {
 
+    @NotNull(message = "Permission type id cannot be null")
     private String permissionTypeId;
+
+    @NotNull(message = "Domain id cannot be null")
     private String domainId;
+
     private String name;
+
     private String description;
-    private double createdTime;
-    private double updatedTime;
+
+    private Long createdTime;
+
+    private Long updatedTime;
 
     public String getPermissionTypeId() {
         return permissionTypeId;
@@ -41,19 +50,19 @@ public class PermissionType {
         this.description = description;
     }
 
-    public double getCreatedTime() {
+    public Long getCreatedTime() {
         return createdTime;
     }
 
-    public void setCreatedTime(double createdTime) {
+    public void setCreatedTime(Long createdTime) {
         this.createdTime = createdTime;
     }
 
-    public double getUpdatedTime() {
+    public Long getUpdatedTime() {
         return updatedTime;
     }
 
-    public void setUpdatedTime(double updatedTime) {
+    public void setUpdatedTime(Long updatedTime) {
         this.updatedTime = updatedTime;
     }
 
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Sharing.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Sharing.java
index 83f22ee..3568a64 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Sharing.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/Sharing.java
@@ -8,8 +8,8 @@ public class Sharing {
     private SharingType sharingType;
     private String domainId;
     private String inheritedParentId;
-    private double createdTime;
-    private double updatedTime;
+    private Long createdTime;
+    private Long updatedTime;
 
     public String getPermissionTypeId() {
         return permissionTypeId;
@@ -59,19 +59,19 @@ public class Sharing {
         this.inheritedParentId = inheritedParentId;
     }
 
-    public double getCreatedTime() {
+    public Long getCreatedTime() {
         return createdTime;
     }
 
-    public void setCreatedTime(double createdTime) {
+    public void setCreatedTime(Long createdTime) {
         this.createdTime = createdTime;
     }
 
-    public double getUpdatedTime() {
+    public Long getUpdatedTime() {
         return updatedTime;
     }
 
-    public void setUpdatedTime(double updatedTime) {
+    public void setUpdatedTime(Long updatedTime) {
         this.updatedTime = updatedTime;
     }
 
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/User.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/User.java
index f4f2174..877d487 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/User.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/User.java
@@ -1,15 +1,30 @@
 package org.apache.custos.sharing.service.core.models;
 
+import javax.validation.constraints.NotNull;
+import java.nio.ByteBuffer;
+
 public class User {
+
+    @NotNull(message = "User id cannot be null")
     private String userId;
+
+    @NotNull(message = "Domain to which user belongs cannot be null")
     private String domainId;
+
+    @NotNull(message = "username cannot be null")
     private String userName;
+
     private String firstName;
+
     private String lastName;
+
     private String email;
-    private byte icon;
-    private double createdTime;
-    private double updatedTime;
+
+    private ByteBuffer icon;
+
+    private Long createdTime;
+    
+    private Long updatedTime;
 
     public String getUserId() {
         return userId;
@@ -59,27 +74,27 @@ public class User {
         this.email = email;
     }
 
-    public byte getIcon() {
+    public ByteBuffer getIcon() {
         return icon;
     }
 
-    public void setIcon(byte icon) {
+    public void setIcon(ByteBuffer icon) {
         this.icon = icon;
     }
 
-    public double getCreatedTime() {
+    public Long getCreatedTime() {
         return createdTime;
     }
 
-    public void setCreatedTime(double createdTime) {
+    public void setCreatedTime(Long createdTime) {
         this.createdTime = createdTime;
     }
 
-    public double getUpdatedTime() {
+    public Long getUpdatedTime() {
         return updatedTime;
     }
 
-    public void setUpdatedTime(double updatedTime) {
+    public void setUpdatedTime(Long updatedTime) {
         this.updatedTime = updatedTime;
     }
 }
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/UserGroup.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/UserGroup.java
index 16457f0..f5eb466 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/UserGroup.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/models/UserGroup.java
@@ -1,19 +1,35 @@
 package org.apache.custos.sharing.service.core.models;
 
+import javax.validation.constraints.NotNull;
+import java.util.ArrayList;
 import java.util.List;
 
 public class UserGroup {
 
+    @NotNull(message = "Group id cannot be null")
     private String groupId;
+
+    @NotNull(message = "Domain id from the group cannot be null")
     private String domainId;
+
+    @NotNull(message = "Name from the group cannot be null")
     private String name;
+    
     private String description;
+
+    @NotNull(message = "OwnerId of the group cannot be null")
     private String ownerId;
+
+    @NotNull(message = "Group type cannot be null")
     private GroupType groupType;
+    
     private GroupCardinality groupCardinality;
-    private double createdTime;
-    private double updatedTime;
-    private List<GroupAdmin> groupAdmins;
+    
+    private Long createdTime;
+    
+    private Long updatedTime;
+
+    private List<GroupAdmin> groupAdmins = new ArrayList<>();
 
     public String getGroupId() {
         return groupId;
@@ -71,19 +87,19 @@ public class UserGroup {
         this.groupCardinality = groupCardinality;
     }
 
-    public double getCreatedTime() {
+    public Long getCreatedTime() {
         return createdTime;
     }
 
-    public void setCreatedTime(double createdTime) {
+    public void setCreatedTime(Long createdTime) {
         this.createdTime = createdTime;
     }
 
-    public double getUpdatedTime() {
+    public Long getUpdatedTime() {
         return updatedTime;
     }
 
-    public void setUpdatedTime(double updatedTime) {
+    public void setUpdatedTime(Long updatedTime) {
         this.updatedTime = updatedTime;
     }
 
diff --git a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java
index fef39c9..921adc5 100644
--- a/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java
+++ b/custos-sharing-registry-service/sharing-service-core/src/main/java/org/apache/custos/sharing/service/core/service/SharingRegistryService.java
@@ -20,7 +20,6 @@
 package org.apache.custos.sharing.service.core.service;
 
 import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
 import org.apache.custos.commons.utils.DBInitializer;
 import org.apache.custos.sharing.service.core.models.*;
 import org.apache.custos.sharing.service.core.db.entities.*;
@@ -32,7 +31,6 @@ import org.apache.custos.sharing.service.core.exceptions.SharingRegistryExceptio
 import org.apache.thrift.TException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.lang.reflect.Field;
@@ -46,7 +44,7 @@ public class SharingRegistryService {
     public static String OWNER_PERMISSION_NAME = "OWNER";
     public static String SHARING_CPI_VERSION = "1.0";
 
-    public SharingRegistryService(SharingRegistryDBInitConfig sharingRegistryDBInitConfig)  throws ApplicationSettingsException {
+    public SharingRegistryService(SharingRegistryDBInitConfig sharingRegistryDBInitConfig) {
         DBInitializer.initializeDB(sharingRegistryDBInitConfig);
     }
 
@@ -59,15 +57,15 @@ public class SharingRegistryService {
      * *
      */
 
-    public String createDomain(Domain domain) throws SharingRegistryException, DuplicateEntryException {
+    public Domain createDomain(Domain domain) throws SharingRegistryException, DuplicateEntryException {
         try{
-            domain.setDomainId(domain.getName());
+            domain.setDomainId(domain.getDomainId());
             if((new DomainRepository()).get(domain.getDomainId()) != null)
                 throw new DuplicateEntryException("There exist domain with given domain id");
 
             domain.setCreatedTime(System.currentTimeMillis());
             domain.setUpdatedTime(System.currentTimeMillis());
-            (new DomainRepository()).create(domain);
+            Domain createdDomain = (new DomainRepository()).create(domain);
 
             //create the global permission for the domain
             PermissionType permissionType = new PermissionType();
@@ -79,7 +77,7 @@ public class SharingRegistryService {
             permissionType.setUpdatedTime(System.currentTimeMillis());
             (new PermissionTypeRepository()).create(permissionType);
 
-            return domain.getDomainId();
+            return createdDomain;
         }catch (Throwable ex){
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -116,8 +114,7 @@ public class SharingRegistryService {
 
     public boolean deleteDomain(String domainId) throws SharingRegistryException {
         try{
-            (new DomainRepository()).delete(domainId);
-            return true;
+            return (new DomainRepository()).delete(domainId);
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -146,7 +143,7 @@ public class SharingRegistryService {
      * * User Operations
      * *
      */
-    public String createUser(User user) throws SharingRegistryException, DuplicateEntryException {
+    public User createUser(User user) throws SharingRegistryException, DuplicateEntryException {
         try{
             UserPK userPK = new UserPK();
             userPK.setUserId(user.getUserId());
@@ -156,7 +153,7 @@ public class SharingRegistryService {
 
             user.setCreatedTime(System.currentTimeMillis());
             user.setUpdatedTime(System.currentTimeMillis());
-            (new UserRepository()).create(user);
+            User createdUser = (new UserRepository()).create(user);
 
             UserGroup userGroup = new UserGroup();
             userGroup.setGroupId(user.getUserId());
@@ -168,7 +165,7 @@ public class SharingRegistryService {
             userGroup.setGroupCardinality(GroupCardinality.SINGLE_USER);
             (new UserGroupRepository()).create(userGroup);
 
-            return user.getUserId();
+            return createdUser;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -262,7 +259,7 @@ public class SharingRegistryService {
      * * Group Operations
      * *
      */
-    public String createGroup(UserGroup group) throws DuplicateEntryException, SharingRegistryException{
+    public UserGroup createGroup(UserGroup group) throws DuplicateEntryException, SharingRegistryException{
         try {
             UserGroupPK userGroupPK = new UserGroupPK();
             userGroupPK.setGroupId(group.getGroupId());
@@ -275,11 +272,11 @@ public class SharingRegistryService {
             group.setUpdatedTime(System.currentTimeMillis());
             //Add group admins once the group is created
             //group.unsetGroupAdmins();
-            (new UserGroupRepository()).create(group);
+            UserGroup createdUserGroup = (new UserGroupRepository()).create(group);
 
             addUsersToGroup(group.getDomainId(), Arrays.asList(group.getOwnerId()), group.getGroupId());
             addGroupAdmins(group.getDomainId(), group.getGroupId(), group.getGroupAdmins());
-            return group.getGroupId();
+            return createdUserGroup;
         } catch (DuplicateEntryException ex) {
             logger.error(ex.getMessage(), ex);
             throw ex;
@@ -603,7 +600,7 @@ public class SharingRegistryService {
      * * EntityType Operations
      * *
      */
-    public String createEntityType(EntityType entityType) throws SharingRegistryException, DuplicateEntryException {
+    public EntityType createEntityType(EntityType entityType) throws SharingRegistryException, DuplicateEntryException {
         try{
             EntityTypePK entityTypePK = new EntityTypePK();
             entityTypePK.setDomainId(entityType.getDomainId());
@@ -613,8 +610,7 @@ public class SharingRegistryService {
 
             entityType.setCreatedTime(System.currentTimeMillis());
             entityType.setUpdatedTime(System.currentTimeMillis());
-            (new EntityTypeRepository()).create(entityType);
-            return entityType.getEntityTypeId();
+            return (new EntityTypeRepository()).create(entityType);
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -695,7 +691,7 @@ public class SharingRegistryService {
      * * Permission Operations
      * *
      */
-    public String createPermissionType(PermissionType permissionType) throws SharingRegistryException, DuplicateEntryException {
+    public PermissionType createPermissionType(PermissionType permissionType) throws SharingRegistryException, DuplicateEntryException {
         try{
             PermissionTypePK permissionTypePK =  new PermissionTypePK();
             permissionTypePK.setDomainId(permissionType.getDomainId());
@@ -705,7 +701,7 @@ public class SharingRegistryService {
             permissionType.setCreatedTime(System.currentTimeMillis());
             permissionType.setUpdatedTime(System.currentTimeMillis());
             (new PermissionTypeRepository()).create(permissionType);
-            return permissionType.getPermissionTypeId();
+            return permissionType;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
@@ -785,7 +781,7 @@ public class SharingRegistryService {
      * * Entity Operations
      * *
      */
-    public String createEntity(Entity entity) throws SharingRegistryException, DuplicateEntryException {
+    public Entity createEntity(Entity entity) throws SharingRegistryException, DuplicateEntryException {
         try{
             EntityPK entityPK = new EntityPK();
             entityPK.setDomainId(entity.getDomainId());
@@ -811,7 +807,7 @@ public class SharingRegistryService {
             if(entity.getOriginalEntityCreationTime()==0){
                 entity.setOriginalEntityCreationTime(entity.getCreatedTime());
             }
-            (new EntityRepository()).create(entity);
+            Entity createdEntity = (new EntityRepository()).create(entity);
 
             //Assigning global permission for the owner
             Sharing newSharing = new Sharing();
@@ -831,7 +827,7 @@ public class SharingRegistryService {
                 addCascadingPermissionsForEntity(entity);
             }
 
-            return entity.getEntityId();
+            return createdEntity;
         }catch (Throwable ex) {
             logger.error(ex.getMessage(), ex);
             throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
diff --git a/ide-integration/custos-services/src/main/resources/database_scripts/init/01-databases.sql b/ide-integration/custos-services/src/main/resources/database_scripts/init/01-databases.sql
index a04f70c..98b10a1 100644
--- a/ide-integration/custos-services/src/main/resources/database_scripts/init/01-databases.sql
+++ b/ide-integration/custos-services/src/main/resources/database_scripts/init/01-databases.sql
@@ -368,6 +368,69 @@ INSERT INTO `DOMAIN` VALUES ('default','default','Domain entry for default',1551
 UNLOCK TABLES;
 
 --
+-- Table structure for table `ENTITY_TYPE`
+--
+
+DROP TABLE IF EXISTS `ENTITY_TYPE`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `ENTITY_TYPE` (
+  `ENTITY_TYPE_ID` varchar(255) NOT NULL,
+  `DOMAIN_ID` varchar(255) NOT NULL,
+  `NAME` varchar(255) NOT NULL,
+  `DESCRIPTION` varchar(255) DEFAULT NULL,
+  `CREATED_TIME` bigint(20) NOT NULL,
+  `UPDATED_TIME` bigint(20) NOT NULL,
+  PRIMARY KEY (`ENTITY_TYPE_ID`,`DOMAIN_ID`),
+  KEY `DOMAIN_ID` (`DOMAIN_ID`),
+  CONSTRAINT `entity_type_ibfk_1` FOREIGN KEY (`DOMAIN_ID`) REFERENCES `DOMAIN` (`DOMAIN_ID`) ON DELETE CASCADE ON UPDATE NO ACTION
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `ENTITY_TYPE`
+--
+
+LOCK TABLES `ENTITY_TYPE` WRITE;
+/*!40000 ALTER TABLE `ENTITY_TYPE` DISABLE KEYS */;
+INSERT INTO `ENTITY_TYPE` VALUES ('default:APPLICATION_DEPLOYMENT','default','APPLICATION-DEPLOYMENT','Application Deployment entity type',1551138011706,1551138011706),('default:CREDENTIAL_TOKEN','default','CREDENTIAL_TOKEN','Credential Store Token entity type',1551138011735,1551138011735),('default:EXPERIMENT','default','EXPERIMENT','Experiment entity type',1551138011685,1551138011685),('default:FILE','default','FILE','File entity type',1551138011696,1551138011696),('default:GROUP_RESOU [...]
+/*!40000 ALTER TABLE `ENTITY_TYPE` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Table structure for table `SHARING_USER`
+--
+
+DROP TABLE IF EXISTS `SHARING_USER`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `SHARING_USER` (
+  `USER_ID` varchar(255) NOT NULL,
+  `DOMAIN_ID` varchar(255) NOT NULL,
+  `USER_NAME` varchar(255) NOT NULL,
+  `FIRST_NAME` varchar(255) DEFAULT NULL,
+  `LAST_NAME` varchar(255) DEFAULT NULL,
+  `EMAIL` varchar(255) DEFAULT NULL,
+  `ICON` blob,
+  `CREATED_TIME` bigint(20) NOT NULL,
+  `UPDATED_TIME` bigint(20) NOT NULL,
+  PRIMARY KEY (`USER_ID`,`DOMAIN_ID`),
+  KEY `DOMAIN_ID` (`DOMAIN_ID`),
+  CONSTRAINT `sharing_user_ibfk_1` FOREIGN KEY (`DOMAIN_ID`) REFERENCES `DOMAIN` (`DOMAIN_ID`) ON DELETE CASCADE ON UPDATE NO ACTION
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `SHARING_USER`
+--
+
+LOCK TABLES `SHARING_USER` WRITE;
+/*!40000 ALTER TABLE `SHARING_USER` DISABLE KEYS */;
+INSERT INTO `SHARING_USER` VALUES ('default-admin@default','default','dim Upe',NULL,NULL,'dimuthu.upeksha2@gmail.com',NULL,1551138011603,1551138404868);
+/*!40000 ALTER TABLE `SHARING_USER` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
 -- Table structure for table `ENTITY`
 --
 
@@ -410,59 +473,63 @@ INSERT INTO `ENTITY` VALUES ('46a99a5a-8b55-4982-bfd7-90fe72b00d46','default','d
 UNLOCK TABLES;
 
 --
--- Table structure for table `ENTITY_TYPE`
+-- Table structure for table `GROUP_ADMIN`
 --
 
-DROP TABLE IF EXISTS `ENTITY_TYPE`;
+DROP TABLE IF EXISTS `GROUP_ADMIN`;
 /*!40101 SET @saved_cs_client     = @@character_set_client */;
 /*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `ENTITY_TYPE` (
-  `ENTITY_TYPE_ID` varchar(255) NOT NULL,
+CREATE TABLE `GROUP_ADMIN` (
+  `ADMIN_ID` varchar(255) NOT NULL,
+  `GROUP_ID` varchar(255) NOT NULL,
   `DOMAIN_ID` varchar(255) NOT NULL,
-  `NAME` varchar(255) NOT NULL,
-  `DESCRIPTION` varchar(255) DEFAULT NULL,
-  `CREATED_TIME` bigint(20) NOT NULL,
-  `UPDATED_TIME` bigint(20) NOT NULL,
-  PRIMARY KEY (`ENTITY_TYPE_ID`,`DOMAIN_ID`),
-  KEY `DOMAIN_ID` (`DOMAIN_ID`),
-  CONSTRAINT `entity_type_ibfk_1` FOREIGN KEY (`DOMAIN_ID`) REFERENCES `DOMAIN` (`DOMAIN_ID`) ON DELETE CASCADE ON UPDATE NO ACTION
+  PRIMARY KEY (`ADMIN_ID`,`GROUP_ID`,`DOMAIN_ID`),
+  KEY `ADMIN_ID` (`ADMIN_ID`,`DOMAIN_ID`),
+  CONSTRAINT `group_admin_ibfk_1` FOREIGN KEY (`ADMIN_ID`, `DOMAIN_ID`) REFERENCES `SHARING_USER` (`USER_ID`, `DOMAIN_ID`) ON DELETE CASCADE ON UPDATE NO ACTION
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
--- Dumping data for table `ENTITY_TYPE`
+-- Dumping data for table `GROUP_ADMIN`
 --
 
-LOCK TABLES `ENTITY_TYPE` WRITE;
-/*!40000 ALTER TABLE `ENTITY_TYPE` DISABLE KEYS */;
-INSERT INTO `ENTITY_TYPE` VALUES ('default:APPLICATION_DEPLOYMENT','default','APPLICATION-DEPLOYMENT','Application Deployment entity type',1551138011706,1551138011706),('default:CREDENTIAL_TOKEN','default','CREDENTIAL_TOKEN','Credential Store Token entity type',1551138011735,1551138011735),('default:EXPERIMENT','default','EXPERIMENT','Experiment entity type',1551138011685,1551138011685),('default:FILE','default','FILE','File entity type',1551138011696,1551138011696),('default:GROUP_RESOU [...]
-/*!40000 ALTER TABLE `ENTITY_TYPE` ENABLE KEYS */;
+LOCK TABLES `GROUP_ADMIN` WRITE;
+/*!40000 ALTER TABLE `GROUP_ADMIN` DISABLE KEYS */;
+/*!40000 ALTER TABLE `GROUP_ADMIN` ENABLE KEYS */;
 UNLOCK TABLES;
 
+
 --
--- Table structure for table `GROUP_ADMIN`
+-- Table structure for table `USER_GROUP`
 --
 
-DROP TABLE IF EXISTS `GROUP_ADMIN`;
+DROP TABLE IF EXISTS `USER_GROUP`;
 /*!40101 SET @saved_cs_client     = @@character_set_client */;
 /*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `GROUP_ADMIN` (
-  `ADMIN_ID` varchar(255) NOT NULL,
+CREATE TABLE `USER_GROUP` (
   `GROUP_ID` varchar(255) NOT NULL,
   `DOMAIN_ID` varchar(255) NOT NULL,
-  PRIMARY KEY (`ADMIN_ID`,`GROUP_ID`,`DOMAIN_ID`),
-  KEY `ADMIN_ID` (`ADMIN_ID`,`DOMAIN_ID`),
-  CONSTRAINT `group_admin_ibfk_1` FOREIGN KEY (`ADMIN_ID`, `DOMAIN_ID`) REFERENCES `SHARING_USER` (`USER_ID`, `DOMAIN_ID`) ON DELETE CASCADE ON UPDATE NO ACTION
+  `NAME` varchar(255) NOT NULL,
+  `DESCRIPTION` varchar(255) DEFAULT NULL,
+  `OWNER_ID` varchar(255) NOT NULL,
+  `GROUP_TYPE` varchar(255) NOT NULL,
+  `GROUP_CARDINALITY` varchar(255) NOT NULL,
+  `CREATED_TIME` bigint(20) NOT NULL,
+  `UPDATED_TIME` bigint(20) NOT NULL,
+  PRIMARY KEY (`GROUP_ID`,`DOMAIN_ID`),
+  KEY `OWNER_ID` (`OWNER_ID`,`DOMAIN_ID`),
+  CONSTRAINT `user_group_ibfk_1` FOREIGN KEY (`OWNER_ID`, `DOMAIN_ID`) REFERENCES `SHARING_USER` (`USER_ID`, `DOMAIN_ID`) ON DELETE CASCADE ON UPDATE NO ACTION
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
--- Dumping data for table `GROUP_ADMIN`
+-- Dumping data for table `USER_GROUP`
 --
 
-LOCK TABLES `GROUP_ADMIN` WRITE;
-/*!40000 ALTER TABLE `GROUP_ADMIN` DISABLE KEYS */;
-/*!40000 ALTER TABLE `GROUP_ADMIN` ENABLE KEYS */;
+LOCK TABLES `USER_GROUP` WRITE;
+/*!40000 ALTER TABLE `USER_GROUP` DISABLE KEYS */;
+INSERT INTO `USER_GROUP` VALUES ('Admin_Users_ba3e4af7-9b1d-4f46-b43a-2b44790f6868','default','Admin Users','Admin users group.','default-admin@default','DOMAIN_LEVEL_GROUP','MULTI_USER',1551138405064,1551138405064),('default-admin@default','default','dim Upe','user dim Upe group','default-admin@default','USER_LEVEL_GROUP','SINGLE_USER',0,1551138404890),('Gateway_Users_2e4e6eb4-05ad-4a0f-92d1-02aa26c56004','default','Gateway Users','Default group for users of the gateway.','default-admin [...]
+/*!40000 ALTER TABLE `USER_GROUP` ENABLE KEYS */;
 UNLOCK TABLES;
 
 --
@@ -564,69 +631,3 @@ LOCK TABLES `SHARING` WRITE;
 INSERT INTO `SHARING` VALUES ('default:OWNER','46a99a5a-8b55-4982-bfd7-90fe72b00d46','default','default-admin@default','DIRECT_CASCADING','46a99a5a-8b55-4982-bfd7-90fe72b00d46',1551139607745,1551139607745),('default:OWNER','af03c63d-a40e-4ed1-aee0-759a6ed0202c','default','default-admin@default','DIRECT_CASCADING','af03c63d-a40e-4ed1-aee0-759a6ed0202c',1552318871935,1552318871935),('default:OWNER','Clone_of_Clone_of_Echo_on_Mar_11,_2019_12:24_PM_9182a6b7-520d-4a8d-92e1-24463aae530b','defa [...]
 /*!40000 ALTER TABLE `SHARING` ENABLE KEYS */;
 UNLOCK TABLES;
-
---
--- Table structure for table `SHARING_USER`
---
-
-DROP TABLE IF EXISTS `SHARING_USER`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `SHARING_USER` (
-  `USER_ID` varchar(255) NOT NULL,
-  `DOMAIN_ID` varchar(255) NOT NULL,
-  `USER_NAME` varchar(255) NOT NULL,
-  `FIRST_NAME` varchar(255) DEFAULT NULL,
-  `LAST_NAME` varchar(255) DEFAULT NULL,
-  `EMAIL` varchar(255) DEFAULT NULL,
-  `ICON` blob,
-  `CREATED_TIME` bigint(20) NOT NULL,
-  `UPDATED_TIME` bigint(20) NOT NULL,
-  PRIMARY KEY (`USER_ID`,`DOMAIN_ID`),
-  KEY `DOMAIN_ID` (`DOMAIN_ID`),
-  CONSTRAINT `sharing_user_ibfk_1` FOREIGN KEY (`DOMAIN_ID`) REFERENCES `DOMAIN` (`DOMAIN_ID`) ON DELETE CASCADE ON UPDATE NO ACTION
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `SHARING_USER`
---
-
-LOCK TABLES `SHARING_USER` WRITE;
-/*!40000 ALTER TABLE `SHARING_USER` DISABLE KEYS */;
-INSERT INTO `SHARING_USER` VALUES ('default-admin@default','default','dim Upe',NULL,NULL,'dimuthu.upeksha2@gmail.com',NULL,1551138011603,1551138404868);
-/*!40000 ALTER TABLE `SHARING_USER` ENABLE KEYS */;
-UNLOCK TABLES;
-
---
--- Table structure for table `USER_GROUP`
---
-
-DROP TABLE IF EXISTS `USER_GROUP`;
-/*!40101 SET @saved_cs_client     = @@character_set_client */;
-/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `USER_GROUP` (
-  `GROUP_ID` varchar(255) NOT NULL,
-  `DOMAIN_ID` varchar(255) NOT NULL,
-  `NAME` varchar(255) NOT NULL,
-  `DESCRIPTION` varchar(255) DEFAULT NULL,
-  `OWNER_ID` varchar(255) NOT NULL,
-  `GROUP_TYPE` varchar(255) NOT NULL,
-  `GROUP_CARDINALITY` varchar(255) NOT NULL,
-  `CREATED_TIME` bigint(20) NOT NULL,
-  `UPDATED_TIME` bigint(20) NOT NULL,
-  PRIMARY KEY (`GROUP_ID`,`DOMAIN_ID`),
-  KEY `OWNER_ID` (`OWNER_ID`,`DOMAIN_ID`),
-  CONSTRAINT `user_group_ibfk_1` FOREIGN KEY (`OWNER_ID`, `DOMAIN_ID`) REFERENCES `SHARING_USER` (`USER_ID`, `DOMAIN_ID`) ON DELETE CASCADE ON UPDATE NO ACTION
-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-/*!40101 SET character_set_client = @saved_cs_client */;
-
---
--- Dumping data for table `USER_GROUP`
---
-
-LOCK TABLES `USER_GROUP` WRITE;
-/*!40000 ALTER TABLE `USER_GROUP` DISABLE KEYS */;
-INSERT INTO `USER_GROUP` VALUES ('Admin_Users_ba3e4af7-9b1d-4f46-b43a-2b44790f6868','default','Admin Users','Admin users group.','default-admin@default','DOMAIN_LEVEL_GROUP','MULTI_USER',1551138405064,1551138405064),('default-admin@default','default','dim Upe','user dim Upe group','default-admin@default','USER_LEVEL_GROUP','SINGLE_USER',0,1551138404890),('Gateway_Users_2e4e6eb4-05ad-4a0f-92d1-02aa26c56004','default','Gateway Users','Default group for users of the gateway.','default-admin [...]
-/*!40000 ALTER TABLE `USER_GROUP` ENABLE KEYS */;
-UNLOCK TABLES;
diff --git a/ide-integration/pom.xml b/ide-integration/pom.xml
index 969fd9f..d1864e3 100644
--- a/ide-integration/pom.xml
+++ b/ide-integration/pom.xml
@@ -10,7 +10,9 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>ide-integration</artifactId>
+    <version>1.0-SNAPSHOT</version>
     <packaging>pom</packaging>
+
     <modules>
         <module>custos-services</module>
         <module>samples</module>
@@ -39,14 +41,12 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-client</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-client</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
 
diff --git a/ide-integration/samples/custos-authentication-service-samples/pom.xml b/ide-integration/samples/custos-authentication-service-samples/pom.xml
index 37037fc..b21012c 100644
--- a/ide-integration/samples/custos-authentication-service-samples/pom.xml
+++ b/ide-integration/samples/custos-authentication-service-samples/pom.xml
@@ -3,7 +3,7 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>ide-integration</artifactId>
+        <artifactId>samples</artifactId>
         <groupId>org.apache.custos</groupId>
         <version>1.0-SNAPSHOT</version>
     </parent>
diff --git a/ide-integration/samples/custos-profile-service-samples/pom.xml b/ide-integration/samples/custos-profile-service-samples/pom.xml
index cce4841..4687181 100644
--- a/ide-integration/samples/custos-profile-service-samples/pom.xml
+++ b/ide-integration/samples/custos-profile-service-samples/pom.xml
@@ -3,7 +3,7 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>ide-integration</artifactId>
+        <artifactId>samples</artifactId>
         <groupId>org.apache.custos</groupId>
         <version>1.0-SNAPSHOT</version>
     </parent>
diff --git a/pom.xml b/pom.xml
index 5168d60..1ba86f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,11 @@
             <artifactId>mariadb-java-client</artifactId>
             <version>2.0.2</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <version>2.1.6.RELEASE</version>
+        </dependency>
     </dependencies>
     <build>
         <plugins>


[airavata-custos] 11/48: corrected the authentication client

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a01e225324d32802c0ef2e851d0d49df06f15855
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Jul 9 00:24:30 2019 -0400

    corrected the authentication client
---
 .../cpi/CustosAuthenticationService.java           | 384 ++++++++++-----------
 .../handler/CustosAuthenticationHandler.java       |   6 +-
 .../service/AuthenticationServiceClient.java       |   4 +-
 .../org/apache/custos/commons/utils/Constants.java |   2 +
 .../custos/commons/utils/ServerSettings.java       |   8 +-
 .../manager/KeyCloakSecurityManager.java           |   7 +-
 .../src/main/resources/custos-server.properties    |  14 +
 pom.xml                                            |   2 +
 8 files changed, 221 insertions(+), 206 deletions(-)

diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
index 551cead..396506a 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/cpi/CustosAuthenticationService.java
@@ -457,7 +457,7 @@ public class CustosAuthenticationService {
 
       public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo>() {
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.UserInfo>() { 
           public void onComplete(org.apache.custos.commons.model.security.UserInfo o) {
             getUserInfoFromAuthzToken_result result = new getUserInfoFromAuthzToken_result();
             result.success = o;
@@ -522,7 +522,7 @@ public class CustosAuthenticationService {
 
       public org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) {
         final org.apache.thrift.AsyncProcessFunction fcall = this;
-        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken>() {
+        return new org.apache.thrift.async.AsyncMethodCallback<org.apache.custos.commons.model.security.AuthzToken>() { 
           public void onComplete(org.apache.custos.commons.model.security.AuthzToken o) {
             getUserManagementServiceAccountAuthzToken_result result = new getUserManagementServiceAccountAuthzToken_result();
             result.success = o;
@@ -652,8 +652,8 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.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.custos.commons.model.security.AuthzToken.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_args.class, metaDataMap);
     }
@@ -662,7 +662,7 @@ public class CustosAuthenticationService {
     }
 
     public isUserAuthenticated_args(
-            org.apache.custos.commons.model.security.AuthzToken authzToken)
+      org.apache.custos.commons.model.security.AuthzToken authzToken)
     {
       this();
       this.authzToken = authzToken;
@@ -713,13 +713,13 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-        case AUTHZ_TOKEN:
-          if (value == null) {
-            unsetAuthzToken();
-          } else {
-            setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
-          }
-          break;
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
 
       }
     }
@@ -727,8 +727,8 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-        case AUTHZ_TOKEN:
-          return getAuthzToken();
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
 
       }
       throw new IllegalStateException();
@@ -741,8 +741,8 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-        case AUTHZ_TOKEN:
-          return isSetAuthzToken();
+      case AUTHZ_TOKEN:
+        return isSetAuthzToken();
       }
       throw new IllegalStateException();
     }
@@ -876,7 +876,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
             break;
           }
           switch (schemeField.id) {
@@ -885,7 +885,7 @@ public class CustosAuthenticationService {
                 struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -1024,10 +1024,10 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.BOOL)));
-      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT,
-              new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.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.BOOL)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(isUserAuthenticated_result.class, metaDataMap);
     }
@@ -1036,8 +1036,8 @@ public class CustosAuthenticationService {
     }
 
     public isUserAuthenticated_result(
-            boolean success,
-            org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+      boolean success,
+      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
     {
       this();
       this.success = success;
@@ -1117,21 +1117,21 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-        case SUCCESS:
-          if (value == null) {
-            unsetSuccess();
-          } else {
-            setSuccess((Boolean)value);
-          }
-          break;
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((Boolean)value);
+        }
+        break;
 
-        case AE:
-          if (value == null) {
-            unsetAe();
-          } else {
-            setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
-          }
-          break;
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+        }
+        break;
 
       }
     }
@@ -1139,11 +1139,11 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-        case SUCCESS:
-          return isSuccess();
+      case SUCCESS:
+        return isSuccess();
 
-        case AE:
-          return getAe();
+      case AE:
+        return getAe();
 
       }
       throw new IllegalStateException();
@@ -1156,10 +1156,10 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-        case SUCCESS:
-          return isSetSuccess();
-        case AE:
-          return isSetAe();
+      case SUCCESS:
+        return isSetSuccess();
+      case AE:
+        return isSetAe();
       }
       throw new IllegalStateException();
     }
@@ -1255,7 +1255,7 @@ public class CustosAuthenticationService {
 
     public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
       scheme(oprot).write(oprot, this);
-    }
+      }
 
     @Override
     public String toString() {
@@ -1314,7 +1314,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
             break;
           }
           switch (schemeField.id) {
@@ -1322,7 +1322,7 @@ public class CustosAuthenticationService {
               if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                 struct.success = iprot.readBool();
                 struct.setSuccessIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -1331,7 +1331,7 @@ public class CustosAuthenticationService {
                 struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -1488,8 +1488,8 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.model.security.AuthzToken.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.custos.commons.model.security.AuthzToken.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_args.class, metaDataMap);
     }
@@ -1498,7 +1498,7 @@ public class CustosAuthenticationService {
     }
 
     public getUserInfoFromAuthzToken_args(
-            org.apache.custos.commons.model.security.AuthzToken authzToken)
+      org.apache.custos.commons.model.security.AuthzToken authzToken)
     {
       this();
       this.authzToken = authzToken;
@@ -1549,13 +1549,13 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-        case AUTHZ_TOKEN:
-          if (value == null) {
-            unsetAuthzToken();
-          } else {
-            setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
-          }
-          break;
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
 
       }
     }
@@ -1563,8 +1563,8 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-        case AUTHZ_TOKEN:
-          return getAuthzToken();
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
 
       }
       throw new IllegalStateException();
@@ -1577,8 +1577,8 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-        case AUTHZ_TOKEN:
-          return isSetAuthzToken();
+      case AUTHZ_TOKEN:
+        return isSetAuthzToken();
       }
       throw new IllegalStateException();
     }
@@ -1712,7 +1712,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
             break;
           }
           switch (schemeField.id) {
@@ -1721,7 +1721,7 @@ public class CustosAuthenticationService {
                 struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -1858,10 +1858,10 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.UserInfo.class)));
-      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT,
-              new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.UserInfo.class)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserInfoFromAuthzToken_result.class, metaDataMap);
     }
@@ -1870,8 +1870,8 @@ public class CustosAuthenticationService {
     }
 
     public getUserInfoFromAuthzToken_result(
-            org.apache.custos.commons.model.security.UserInfo success,
-            org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+      org.apache.custos.commons.model.security.UserInfo success,
+      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
     {
       this();
       this.success = success;
@@ -1952,21 +1952,21 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-        case SUCCESS:
-          if (value == null) {
-            unsetSuccess();
-          } else {
-            setSuccess((org.apache.custos.commons.model.security.UserInfo)value);
-          }
-          break;
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.custos.commons.model.security.UserInfo)value);
+        }
+        break;
 
-        case AE:
-          if (value == null) {
-            unsetAe();
-          } else {
-            setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
-          }
-          break;
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+        }
+        break;
 
       }
     }
@@ -1974,11 +1974,11 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-        case SUCCESS:
-          return getSuccess();
+      case SUCCESS:
+        return getSuccess();
 
-        case AE:
-          return getAe();
+      case AE:
+        return getAe();
 
       }
       throw new IllegalStateException();
@@ -1991,10 +1991,10 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-        case SUCCESS:
-          return isSetSuccess();
-        case AE:
-          return isSetAe();
+      case SUCCESS:
+        return isSetSuccess();
+      case AE:
+        return isSetAe();
       }
       throw new IllegalStateException();
     }
@@ -2092,7 +2092,7 @@ public class CustosAuthenticationService {
 
     public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
       scheme(oprot).write(oprot, this);
-    }
+      }
 
     @Override
     public String toString() {
@@ -2156,7 +2156,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
             break;
           }
           switch (schemeField.id) {
@@ -2165,7 +2165,7 @@ public class CustosAuthenticationService {
                 struct.success = new org.apache.custos.commons.model.security.UserInfo();
                 struct.success.read(iprot);
                 struct.setSuccessIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -2174,7 +2174,7 @@ public class CustosAuthenticationService {
                 struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -2347,14 +2347,14 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.custos.commons.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.CLIENT_ID, new org.apache.thrift.meta_data.FieldMetaData("clientId", org.apache.thrift.TFieldRequirementType.REQUIRED,
-              new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-      tmpMap.put(_Fields.CLIENT_SECRET, new org.apache.thrift.meta_data.FieldMetaData("clientSecret", org.apache.thrift.TFieldRequirementType.REQUIRED,
-              new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+      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.custos.commons.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.CLIENT_ID, new org.apache.thrift.meta_data.FieldMetaData("clientId", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+      tmpMap.put(_Fields.CLIENT_SECRET, new org.apache.thrift.meta_data.FieldMetaData("clientSecret", org.apache.thrift.TFieldRequirementType.REQUIRED, 
+          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_args.class, metaDataMap);
     }
@@ -2363,10 +2363,10 @@ public class CustosAuthenticationService {
     }
 
     public getUserManagementServiceAccountAuthzToken_args(
-            org.apache.custos.commons.model.security.AuthzToken authzToken,
-            String gatewayId,
-            String clientId,
-            String clientSecret)
+      org.apache.custos.commons.model.security.AuthzToken authzToken,
+      String gatewayId,
+      String clientId,
+      String clientSecret)
     {
       this();
       this.authzToken = authzToken;
@@ -2507,37 +2507,37 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-        case AUTHZ_TOKEN:
-          if (value == null) {
-            unsetAuthzToken();
-          } else {
-            setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
-          }
-          break;
+      case AUTHZ_TOKEN:
+        if (value == null) {
+          unsetAuthzToken();
+        } else {
+          setAuthzToken((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
 
-        case GATEWAY_ID:
-          if (value == null) {
-            unsetGatewayId();
-          } else {
-            setGatewayId((String)value);
-          }
-          break;
+      case GATEWAY_ID:
+        if (value == null) {
+          unsetGatewayId();
+        } else {
+          setGatewayId((String)value);
+        }
+        break;
 
-        case CLIENT_ID:
-          if (value == null) {
-            unsetClientId();
-          } else {
-            setClientId((String)value);
-          }
-          break;
+      case CLIENT_ID:
+        if (value == null) {
+          unsetClientId();
+        } else {
+          setClientId((String)value);
+        }
+        break;
 
-        case CLIENT_SECRET:
-          if (value == null) {
-            unsetClientSecret();
-          } else {
-            setClientSecret((String)value);
-          }
-          break;
+      case CLIENT_SECRET:
+        if (value == null) {
+          unsetClientSecret();
+        } else {
+          setClientSecret((String)value);
+        }
+        break;
 
       }
     }
@@ -2545,17 +2545,17 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-        case AUTHZ_TOKEN:
-          return getAuthzToken();
+      case AUTHZ_TOKEN:
+        return getAuthzToken();
 
-        case GATEWAY_ID:
-          return getGatewayId();
+      case GATEWAY_ID:
+        return getGatewayId();
 
-        case CLIENT_ID:
-          return getClientId();
+      case CLIENT_ID:
+        return getClientId();
 
-        case CLIENT_SECRET:
-          return getClientSecret();
+      case CLIENT_SECRET:
+        return getClientSecret();
 
       }
       throw new IllegalStateException();
@@ -2568,14 +2568,14 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-        case AUTHZ_TOKEN:
-          return isSetAuthzToken();
-        case GATEWAY_ID:
-          return isSetGatewayId();
-        case CLIENT_ID:
-          return isSetClientId();
-        case CLIENT_SECRET:
-          return isSetClientSecret();
+      case AUTHZ_TOKEN:
+        return isSetAuthzToken();
+      case GATEWAY_ID:
+        return isSetGatewayId();
+      case CLIENT_ID:
+        return isSetClientId();
+      case CLIENT_SECRET:
+        return isSetClientSecret();
       }
       throw new IllegalStateException();
     }
@@ -2811,7 +2811,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
             break;
           }
           switch (schemeField.id) {
@@ -2820,7 +2820,7 @@ public class CustosAuthenticationService {
                 struct.authzToken = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.authzToken.read(iprot);
                 struct.setAuthzTokenIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -2828,7 +2828,7 @@ public class CustosAuthenticationService {
               if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                 struct.gatewayId = iprot.readString();
                 struct.setGatewayIdIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -2836,7 +2836,7 @@ public class CustosAuthenticationService {
               if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                 struct.clientId = iprot.readString();
                 struct.setClientIdIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -2844,7 +2844,7 @@ public class CustosAuthenticationService {
               if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                 struct.clientSecret = iprot.readString();
                 struct.setClientSecretIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -3005,10 +3005,10 @@ public class CustosAuthenticationService {
     public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
     static {
       java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.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.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
-      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT,
-              new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
+      tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.commons.model.security.AuthzToken.class)));
+      tmpMap.put(_Fields.AE, new org.apache.thrift.meta_data.FieldMetaData("ae", org.apache.thrift.TFieldRequirementType.DEFAULT, 
+          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException.class)));
       metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
       org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserManagementServiceAccountAuthzToken_result.class, metaDataMap);
     }
@@ -3017,8 +3017,8 @@ public class CustosAuthenticationService {
     }
 
     public getUserManagementServiceAccountAuthzToken_result(
-            org.apache.custos.commons.model.security.AuthzToken success,
-            org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
+      org.apache.custos.commons.model.security.AuthzToken success,
+      org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException ae)
     {
       this();
       this.success = success;
@@ -3099,21 +3099,21 @@ public class CustosAuthenticationService {
 
     public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
       switch (field) {
-        case SUCCESS:
-          if (value == null) {
-            unsetSuccess();
-          } else {
-            setSuccess((org.apache.custos.commons.model.security.AuthzToken)value);
-          }
-          break;
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.custos.commons.model.security.AuthzToken)value);
+        }
+        break;
 
-        case AE:
-          if (value == null) {
-            unsetAe();
-          } else {
-            setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
-          }
-          break;
+      case AE:
+        if (value == null) {
+          unsetAe();
+        } else {
+          setAe((org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException)value);
+        }
+        break;
 
       }
     }
@@ -3121,11 +3121,11 @@ public class CustosAuthenticationService {
     @org.apache.thrift.annotation.Nullable
     public Object getFieldValue(_Fields field) {
       switch (field) {
-        case SUCCESS:
-          return getSuccess();
+      case SUCCESS:
+        return getSuccess();
 
-        case AE:
-          return getAe();
+      case AE:
+        return getAe();
 
       }
       throw new IllegalStateException();
@@ -3138,10 +3138,10 @@ public class CustosAuthenticationService {
       }
 
       switch (field) {
-        case SUCCESS:
-          return isSetSuccess();
-        case AE:
-          return isSetAe();
+      case SUCCESS:
+        return isSetSuccess();
+      case AE:
+        return isSetAe();
       }
       throw new IllegalStateException();
     }
@@ -3239,7 +3239,7 @@ public class CustosAuthenticationService {
 
     public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
       scheme(oprot).write(oprot, this);
-    }
+      }
 
     @Override
     public String toString() {
@@ -3303,7 +3303,7 @@ public class CustosAuthenticationService {
         while (true)
         {
           schemeField = iprot.readFieldBegin();
-          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
             break;
           }
           switch (schemeField.id) {
@@ -3312,7 +3312,7 @@ public class CustosAuthenticationService {
                 struct.success = new org.apache.custos.commons.model.security.AuthzToken();
                 struct.success.read(iprot);
                 struct.setSuccessIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -3321,7 +3321,7 @@ public class CustosAuthenticationService {
                 struct.ae = new org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException();
                 struct.ae.read(iprot);
                 struct.setAeIsSet(true);
-              } else {
+              } else { 
                 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
               }
               break;
@@ -3405,4 +3405,4 @@ public class CustosAuthenticationService {
     }
   }
 
-}
\ No newline at end of file
+}
diff --git a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
index 1c078e0..0a2f43c 100644
--- a/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
+++ b/custos-authentication/src/main/java/org/apache/custos/authentication/handler/CustosAuthenticationHandler.java
@@ -35,8 +35,7 @@ public class CustosAuthenticationHandler implements CustosAuthenticationService.
     public UserInfo getUserInfoFromAuthzToken(AuthzToken authzToken) throws CustosAuthenticationServiceException {
         try{
             CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
-            UserInfo userInfo = securityManager.getUserInfoFromAuthzToken(authzToken);
-            return userInfo;
+            return securityManager.getUserInfoFromAuthzToken(authzToken);
         }catch (CustosSecurityException e){
             logger.error(e.getMessage(), e);
             throw new CustosAuthenticationServiceException("Could not retrieve user info");
@@ -46,8 +45,7 @@ public class CustosAuthenticationHandler implements CustosAuthenticationService.
     public AuthzToken getUserManagementServiceAccountAuthzToken(AuthzToken authzToken, String gatewayId, String clientId, String clientSecret) throws CustosAuthenticationServiceException {
         try{
             CustosSecurityManager securityManager = SecurityManagerFactory.getSecurityManager();
-            AuthzToken managementServiceAccountAuthzToken = securityManager.getUserManagementServiceAccountAuthzToken(authzToken, gatewayId, clientId, clientSecret);
-            return managementServiceAccountAuthzToken;
+            return securityManager.getUserManagementServiceAccountAuthzToken(authzToken, gatewayId, clientId, clientSecret);
         }catch (CustosSecurityException e){
             logger.error(e.getMessage(), e);
             throw new CustosAuthenticationServiceException("Could get user management account authz token");
diff --git a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
index 054a5c1..4fc0444 100644
--- a/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
+++ b/custos-client/src/main/java/org/apache/custos/client/authentication/service/AuthenticationServiceClient.java
@@ -3,7 +3,6 @@ package org.apache.custos.client.authentication.service;
 import org.apache.custos.authentication.cpi.CustosAuthenticationService;
 import org.apache.custos.authentication.cpi.exception.CustosAuthenticationServiceException;
 import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TMultiplexedProtocol;
 import org.apache.thrift.protocol.TProtocol;
 import org.apache.thrift.transport.TSocket;
 import org.apache.thrift.transport.TTransport;
@@ -16,8 +15,7 @@ public class AuthenticationServiceClient {
             TTransport transport = new TSocket(serverHost, serverPort);
             transport.open();
             TProtocol protocol = new TBinaryProtocol(transport);
-            TMultiplexedProtocol multiplexedProtocol = new TMultiplexedProtocol(protocol, "CustosAuthenticationService");
-            return new CustosAuthenticationService.Client(multiplexedProtocol);
+            return new CustosAuthenticationService.Client(protocol);
         } catch (TTransportException e) {
             throw new CustosAuthenticationServiceException(e.getMessage());
         }
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
index 306c6be..7bb6c8e 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/Constants.java
@@ -27,6 +27,8 @@ public final class Constants {
     public static final String AUTHZ_CACHE_MANAGER_CLASS = "authz.cache.manager.class";
     public static final String SECURITY_MANAGER_CLASS = "security.manager.class";
     public static final String AUTHZ_CACHE_ENABLED = "authz.cache.enabled";
+    public static final String KEYSTORE_PATH = "keystore.path";
+    public static final String KEYSTORE_PASSWORD = "keystore.password";
 
     //Names of the attributes that could be passed in the AuthzToken's claims map.
     public static final String USER_NAME = "userName";
diff --git a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
index 78570f7..642f37e 100644
--- a/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
+++ b/custos-commons/src/main/java/org/apache/custos/commons/utils/ServerSettings.java
@@ -31,6 +31,7 @@ public class ServerSettings extends ApplicationSettings {
     public static final String IAM_SERVER_SUPER_ADMIN_USERNAME = "iam.server.super.admin.username";
     public static final String IAM_SERVER_SUPER_ADMIN_PASSWORD = "iam.server.super.admin.password";
 
+
     public static int getCacheSize() throws ApplicationSettingsException {
         return Integer.valueOf(getSetting(Constants.IN_MEMORY_CACHE_SIZE));
     }
@@ -53,6 +54,11 @@ public class ServerSettings extends ApplicationSettings {
     public static  String getAuthenticationServerHost() throws ApplicationSettingsException {
         return getSetting(ServerSettings.AUTHENTICATION_SERVICE_SERVER_HOST);
     }
+    public static String getKeyStorePath() throws ApplicationSettingsException {
+        return getSetting(Constants.KEYSTORE_PATH);
+    }
 
-
+    public static String getKeyStorePassword() throws ApplicationSettingsException {
+        return getSetting(Constants.KEYSTORE_PASSWORD);
+    }
 }
diff --git a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
index 0b4d16e..ad058f3 100644
--- a/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
+++ b/custos-connectors/src/main/java/org.apache.custos.security/manager/KeyCloakSecurityManager.java
@@ -26,11 +26,7 @@ import org.apache.custos.commons.model.security.AuthzToken;
 import org.apache.custos.commons.model.security.UserInfo;
 import org.apache.custos.commons.utils.Constants;
 import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.commons.utils.ThriftUtils;
-import org.apache.custos.profile.client.ProfileServiceClientFactory;
-import org.apache.custos.profile.model.workspace.Gateway;
 import org.apache.custos.profile.tenant.cpi.TenantProfileService;
-import org.apache.custos.profile.tenant.cpi.exception.TenantProfileServiceException;
 import org.apache.custos.security.authzcache.*;
 import org.apache.custos.security.utils.TrustStoreManager;
 import org.apache.http.Consts;
@@ -43,7 +39,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.util.EntityUtils;
-import org.apache.thrift.TException;
 import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -62,7 +57,7 @@ public class KeyCloakSecurityManager implements CustosSecurityManager {
     private final static Logger logger = LoggerFactory.getLogger(KeyCloakSecurityManager.class);
     private TenantProfileService.Client tenantProfileClient = null;
     public KeyCloakSecurityManager() throws CustosSecurityException {
-        initializeSecurityInfra();
+        //initializeSecurityInfra();
     }
 
     /**
diff --git a/ide-integration/src/main/resources/custos-server.properties b/ide-integration/src/main/resources/custos-server.properties
index 8686ed0..3741eab 100644
--- a/ide-integration/src/main/resources/custos-server.properties
+++ b/ide-integration/src/main/resources/custos-server.properties
@@ -29,4 +29,18 @@
 ###########################################################################
 custos.authentication.server.port = 9091
 custos.authentication.server.host = localhost
+security.manager.class=org.apache.custos.security.manager.KeyCloakSecurityManager
 
+###########################################################################
+# Iam Admin services Configuration
+###########################################################################
+iam.server.url=https://localhost:8443/auth
+iam.server.super.admin.username=admin
+iam.server.super.admin.password=admin
+
+#### keystore configuration ####
+keystore.path=keystores/airavata.jks
+keystore.password=airavata
+#### trust store configuration ####
+trust.store=keystores/client_truststore.jks
+trust.store.password=airavata
diff --git a/pom.xml b/pom.xml
index ac024f0..736fad9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,6 +23,7 @@
         <module>custos-authentication</module>
     </modules>
     <properties>
+        <java.version>1.8</java.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
         <org.slf4j.version>1.7.25</org.slf4j.version>
@@ -62,4 +63,5 @@
             <version>${log4j.version}</version>
         </dependency>
     </dependencies>
+
 </project>
\ No newline at end of file


[airavata-custos] 40/48: Merge pull request #9 from aarushiibisht/custos_sharing_registry_changes

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit da05787ec5b79d12f38d57ac815b5a9d8e00f5d2
Merge: 0a94161 e59c4d8
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Mon Sep 2 19:57:28 2019 -0400

    Merge pull request #9 from aarushiibisht/custos_sharing_registry_changes
    
    Added instructions to start the sharing registry service

 .../SharingRegistryServiceClientFactory.java       | 44 ----------------------
 custos-profile-service/README                      |  3 --
 custos-sharing-registry-service/README             |  3 ++
 3 files changed, 3 insertions(+), 47 deletions(-)


[airavata-custos] 31/48: Merge pull request #4 from aarushiibisht/custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 469150f89cc2d2d4b224136f27eb9fc638f7ea4a
Merge: e01fd7c 5595257
Author: Suresh Marru <sm...@apache.org>
AuthorDate: Tue Aug 27 02:15:16 2019 -0400

    Merge pull request #4 from aarushiibisht/custos-dev-abisht
    
    merging the PR for README and sample testing

 .../handler/CustosAuthenticationHandler.java       |   2 +-
 ...ava => AuthenticationServiceClientFactory.java} |   2 +-
 custos-commons/custos-server.properties            |   0
 .../src/main/resources/custos-server.properties    |  10 +-
 .../manager/KeyCloakSecurityManager.java           |   3 +-
 .../main/resources/keystores/client_truststore.jks | Bin 0 -> 963 bytes
 .../user/handler/UserProfileServiceHandler.java    |  10 +-
 .../test/java/TestUserProfileServiceHandler.java   |  36 +++--
 ide-integration/README.md                          |  64 +++++++++
 ide-integration/custos-services/pom.xml            |  15 ++
 .../server/start}/CustosAPIServerStarted.java      |   4 +-
 .../src/main/resources/custos-server.properties    |  10 +-
 .../database_scripts/init/01-databases.sql         |  43 +++---
 .../user-profile-catalog-derby.sql                 |  30 ----
 .../user-profile-catalog-mysql.sql                 |  30 ----
 .../src/main/resources/docker-compose.yml          |   2 +-
 .../main/resources/keycloak/Default-export.json    |   0
 .../main/resources/keycloak/Default-export.json.bk |   0
 .../src/main/resources/keycloak/standalone.xml     |   2 +-
 .../src/main/resources/keystores/custos.jks        | Bin 0 -> 2252 bytes
 .../src/main/resources}/log4j.properties           |   8 +-
 ide-integration/pom.xml                            |  17 +++
 ide-integration/samples/commons/pom.xml            |  15 ++
 .../org/apache/samples/common/SamplesCommon.java   |  60 ++++++++
 .../custos-authentication-service-samples/pom.xml  |  23 +++
 .../sample/CustosAuthenticationServiceSample.java  |  64 +++++++++
 .../src/main/resources/log4j.properties            |  10 +-
 .../samples/custos-profile-service-samples/pom.xml |  22 +++
 .../service/samples/TenantProfileSample.java       |  80 +++++++++++
 .../profile/service/samples/UserProfileSample.java | 160 +++++++++++++++++++++
 .../samples/utils/ProfileServiceClientUtil.java    |  63 ++++++++
 .../src/main/resources/log4j.properties            |  10 +-
 .../resources/profile-client-sample.properties     |  29 ++++
 ide-integration/samples/pom.xml                    |  20 +++
 .../src/main/resources/keystores/airavata.jks      | Bin 2679 -> 0 bytes
 .../src/main/resources/keystores/airavata_sym.jks  | Bin 501 -> 0 bytes
 .../main/resources/keystores/client_truststore.jks | Bin 1027 -> 0 bytes
 37 files changed, 715 insertions(+), 129 deletions(-)


[airavata-custos] 35/48: Merge pull request #7 from aarushiibisht/custos_sharing_registry_changes

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b211e6ddced3a8e750745e6a749171a1beea3a80
Merge: a0b6462 757fe55
Author: Aarushi Bisht <39...@users.noreply.github.com>
AuthorDate: Sat Aug 31 13:16:49 2019 -0400

    Merge pull request #7 from aarushiibisht/custos_sharing_registry_changes
    
    Custos sharing registry changes

 custos-client/pom.xml                              |    6 +
 .../SharingRegistryServiceClientFactory.java       |   44 +
 .../org/apache/custos/commons/utils/Constants.java |    4 +
 .../custos/commons/utils/ServerSettings.java       |    7 +-
 .../custos/commons/utils/ServiceRequest.java       |   36 +
 .../src/main/resources/custos-server.properties    |   17 +
 custos-profile-service/README                      |    3 +
 .../group-profile-api/pom.xml                      |   21 +
 .../group/profile/service/api/Application.java     |   28 +
 .../api/controllers/GroupServiceController.java    |   82 ++
 .../group-profile-core/pom.xml                     |   22 +
 .../exceptions/GroupManagerServiceException.java   |   16 +
 .../profile/service/core/models/GroupModel.java    |   73 ++
 .../service/core/service/GroupProfileService.java  |  390 +++++++
 .../group-profile-service/pom.xml                  |   20 +
 custos-sharing-registry-service/pom.xml            |   21 +
 .../sharing-service-api/pom.xml                    |   23 +
 .../custos/sharing/service/api/AppConfig.java      |   22 +
 .../custos/sharing/service/api/Application.java    |   32 +
 .../api/constants/SharingRegistryEndpoints.java    |   22 +
 .../service/api/controllers/AccessController.java  |   71 ++
 .../service/api/controllers/DomainsController.java |   79 ++
 .../service/api/controllers/EntityController.java  |  117 ++
 .../api/controllers/EntityTypeController.java      |   95 ++
 .../service/api/controllers/GroupController.java   |  244 ++++
 .../api/controllers/PermissionTypeController.java  |   94 ++
 .../service/api/controllers/UsersController.java   |   95 ++
 .../sharing-service-core/pom.xml                   |   58 +
 .../service/core/db/entities/DomainEntity.java     |  116 ++
 .../service/core/db/entities/EntityEntity.java     |  219 ++++
 .../sharing/service/core/db/entities/EntityPK.java |   76 ++
 .../service/core/db/entities/EntityTypeEntity.java |  130 +++
 .../service/core/db/entities/EntityTypePK.java     |   76 ++
 .../service/core/db/entities/GroupAdminEntity.java |   80 ++
 .../service/core/db/entities/GroupAdminPK.java     |   66 ++
 .../core/db/entities/GroupMembershipEntity.java    |  126 ++
 .../core/db/entities/GroupMembershipPK.java        |   88 ++
 .../core/db/entities/PermissionTypeEntity.java     |  128 +++
 .../service/core/db/entities/PermissionTypePK.java |   76 ++
 .../service/core/db/entities/SharingEntity.java    |  149 +++
 .../service/core/db/entities/SharingPK.java        |  116 ++
 .../service/core/db/entities/UserEntity.java       |  161 +++
 .../service/core/db/entities/UserGroupEntity.java  |  178 +++
 .../service/core/db/entities/UserGroupPK.java      |   75 ++
 .../sharing/service/core/db/entities/UserPK.java   |   75 ++
 .../core/db/repositories/AbstractRepository.java   |  169 +++
 .../core/db/repositories/DomainRepository.java     |   33 +
 .../core/db/repositories/EntityRepository.java     |  180 +++
 .../core/db/repositories/EntityTypeRepository.java |   34 +
 .../core/db/repositories/GroupAdminRepository.java |   17 +
 .../db/repositories/GroupMembershipRepository.java |  105 ++
 .../db/repositories/PermissionTypeRepository.java  |   52 +
 .../core/db/repositories/SharingRepository.java    |  114 ++
 .../core/db/repositories/UserGroupRepository.java  |   95 ++
 .../core/db/repositories/UserRepository.java       |   79 ++
 .../sharing/service/core/db/utils/Committer.java   |   26 +
 .../sharing/service/core/db/utils/DBConstants.java |  106 ++
 .../sharing/service/core/db/utils/JPAUtils.java    |   35 +
 .../core/db/utils/ObjectMapperSingleton.java       |   38 +
 .../core/db/utils/SharingRegistryDBInitConfig.java |   50 +
 .../core/db/utils/SharingRegistryJDBCConfig.java   |   67 ++
 .../core/exceptions/DuplicateEntryException.java   |   15 +
 .../core/exceptions/ResourceNotFoundException.java |   16 +
 .../core/exceptions/SharingRegistryException.java  |   16 +
 .../custos/sharing/service/core/models/Domain.java |   49 +
 .../custos/sharing/service/core/models/Entity.java |  121 ++
 .../service/core/models/EntitySearchField.java     |   14 +
 .../sharing/service/core/models/EntityType.java    |   58 +
 .../sharing/service/core/models/GroupAdmin.java    |   33 +
 .../service/core/models/GroupCardinality.java      |    6 +
 .../service/core/models/GroupChildType.java        |    6 +
 .../service/core/models/GroupMembership.java       |   60 +
 .../sharing/service/core/models/GroupType.java     |    6 +
 .../service/core/models/PermissionType.java        |   60 +
 .../service/core/models/SearchCondition.java       |   10 +
 .../service/core/models/SearchCriteria.java        |   31 +
 .../sharing/service/core/models/Sharing.java       |   78 ++
 .../sharing/service/core/models/SharingType.java   |    7 +
 .../custos/sharing/service/core/models/User.java   |   85 ++
 .../sharing/service/core/models/UserGroup.java     |   97 ++
 .../core/service/SharingRegistryService.java       | 1216 ++++++++++++++++++++
 .../database_scripts/init/01-databases.sql         |  326 +++++-
 pom.xml                                            |    3 +
 .../sharing-service/sharing-cpi/sharing_cpi.thrift |  274 +++++
 .../sharing-models/sharing_models.thrift           |  303 +++++
 85 files changed, 7765 insertions(+), 2 deletions(-)


[airavata-custos] 28/48: Merge pull request #2 from aarushiibisht/master

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e01fd7c47ccb431807a94af225e3d7f33acdd35b
Merge: 3802acd 7ba18f6
Author: Suresh Marru <sm...@apache.org>
AuthorDate: Tue Aug 20 11:21:52 2019 -0400

    Merge pull request #2 from aarushiibisht/master
    
    I think this looks good enough to merge, we need to do a dertailed code-review after custos repo is bootstrapped

 .gitignore                                         |    39 +
 custos-authentication/pom.xml                      |    27 +
 .../CustosAuthenticationService.java               |  3198 ++++
 .../cpi/CustosAuthenticationService.java           |  3198 ++++
 .../CustosAuthenticationServiceException.java      |   370 +
 .../handler/CustosAuthenticationHandler.java       |    54 +
 .../server/CustosAuthenticationServer.java         |   137 +
 custos-client/pom.xml                              |    41 +
 .../service/AuthenticationServiceClient.java       |    23 +
 .../service/CustosProfileServiceClientFactory.java |    77 +
 custos-commons/custos-server.properties            |     0
 custos-commons/pom.xml                             |    36 +
 .../exceptions/ApplicationSettingsException.java   |    14 +
 .../custos/commons/exceptions/CustosException.java |    35 +
 .../exceptions/CustosSecurityException.java        |    39 +
 .../custos/commons/model/security/AuthzToken.java  |   541 +
 .../custos/commons/model/security/UserInfo.java    |   875 +
 .../custos/commons/utils/ApplicationSettings.java  |   162 +
 .../org/apache/custos/commons/utils/Constants.java |    39 +
 .../apache/custos/commons/utils/CustosUtils.java   |    45 +
 .../apache/custos/commons/utils/DBInitConfig.java  |    33 +
 .../apache/custos/commons/utils/DBInitializer.java |    71 +
 .../org/apache/custos/commons/utils/DBUtil.java    |   306 +
 .../custos/commons/utils/DatabaseCreator.java      |   378 +
 .../org/apache/custos/commons/utils/IServer.java   |    49 +
 .../apache/custos/commons/utils/JDBCConfig.java    |    29 +
 .../org/apache/custos/commons/utils/JPAUtils.java  |    67 +
 .../commons/utils/KeyStorePasswordCallback.java    |    69 +
 .../apache/custos/commons/utils/SecurityUtil.java  |   192 +
 .../custos/commons/utils/ServerSettings.java       |    92 +
 .../apache/custos/commons/utils/StringUtil.java    |    43 +
 .../apache/custos/commons/utils/ThriftUtils.java   |    34 +
 .../src/main/resources/custos-server.properties    |    65 +
 custos-connectors/pom.xml                          |    86 +
 .../authzcache/AuthzCache.java                     |    61 +
 .../authzcache/AuthzCacheEntry.java                |    63 +
 .../authzcache/AuthzCacheIndex.java                |    90 +
 .../authzcache/AuthzCacheManager.java              |    80 +
 .../authzcache/AuthzCacheManagerFactory.java       |    60 +
 .../authzcache/AuthzCachedStatus.java              |    34 +
 .../authzcache/DefaultAuthzCacheManager.java       |   106 +
 .../manager/CustosSecurityManager.java             |    60 +
 .../manager/IdentityContext.java                   |    45 +
 .../manager/KeyCloakSecurityManager.java           |   259 +
 .../manager/SecurityManagerFactory.java            |    60 +
 .../utils/TrustStoreManager.java                   |   100 +
 custos-profile-service/iam-admin-services/pom.xml  |    28 +
 .../client/CustosIamAdminServiceClient.java        |    48 +
 .../services/core/TenantManagementInterface.java   |   216 +
 .../core/TenantManagementKeycloakImpl.java         |   845 +
 .../iam/admin/services/cpi/IamAdminServices.java   | 19063 +++++++++++++++++++
 .../cpi/exception/IamAdminServicesException.java   |   381 +
 .../cpi/iam_admin_services_cpiConstants.java       |    16 +
 .../services/handler/IamAdminServicesHandler.java  |   318 +
 custos-profile-service/pom.xml                     |    26 +
 .../profile-service-commons/pom.xml                |   123 +
 .../commons/repositories/AbstractRepository.java   |   124 +
 .../repositories/TenantProfileRepository.java      |   119 +
 .../repositories/UserProfileRepository.java        |   128 +
 .../commons/tenant/entities/GatewayEntity.java     |   285 +
 .../user/entities/NSFDemographicsEntity.java       |   108 +
 .../commons/user/entities/UserProfileEntity.java   |   334 +
 .../custos/profile/commons/utils/Committer.java    |    27 +
 .../custos/profile/commons/utils/JPAConstants.java |    34 +
 .../custos/profile/commons/utils/JPAUtils.java     |    53 +
 .../commons/utils/ObjectMapperSingleton.java       |    39 +
 .../commons/utils/ProfileServiceJDBCConfig.java    |    51 +
 .../profile/commons/utils/QueryConstants.java      |    36 +
 .../apache/custos/profile/commons/utils/Utils.java |   122 +
 .../src/main/resources/META-INF/persistence.xml    |    35 +
 .../profile-service-model/pom.xml                  |    15 +
 .../profile/model/tenant/PasswordCredential.java   |   996 +
 .../apache/custos/profile/model/tenant/Tenant.java |  1543 ++
 .../profile/model/tenant/TenantApprovalStatus.java |    78 +
 .../custos/profile/model/tenant/TenantConfig.java  |   699 +
 .../profile/model/tenant/TenantPreferences.java    |   594 +
 .../custos/profile/model/user/NSFDemographics.java |  1110 ++
 .../apache/custos/profile/model/user/Status.java   |    79 +
 .../custos/profile/model/user/USCitizenship.java   |    50 +
 .../custos/profile/model/user/UserProfile.java     |  3147 +++
 .../custos/profile/model/user/disability.java      |    49 +
 .../custos/profile/model/user/ethnicity.java       |    48 +
 .../org/apache/custos/profile/model/user/race.java |    67 +
 .../model/user/user_profile_modelConstants.java    |    16 +
 .../custos/profile/model/workspace/Gateway.java    |  2383 +++
 .../model/workspace/GatewayApprovalStatus.java     |    78 +
 .../profile-service-server/pom.xml                 |    32 +
 .../profile/server/ProfileServiceServer.java       |   197 +
 .../src/main/resources/log4j.properties            |    34 +
 .../tenant-profile-service/pom.xml                 |    31 +
 .../profile/tenant/client/TenantProfileClient.java |    26 +
 .../profile/tenant/cpi/TenantProfileService.java   | 11041 +++++++++++
 .../exception/TenantProfileServiceException.java   |   370 +
 .../tenant/cpi/profile_tenant_cpiConstants.java    |    16 +
 .../handler/TenantProfileServiceHandler.java       |   208 +
 .../user-profile-service/pom.xml                   |    54 +
 .../profile/user/client/UserProfileClient.java     |     4 +
 .../exceptions/UserProfileRegistryException.java   |    28 +
 .../core/utils/UserProfileCatalogDBInitConfig.java |    42 +
 .../core/utils/UserProfileCatalogJDBCConfig.java   |    52 +
 .../profile/user/cpi/UserProfileService.java       |  9191 +++++++++
 .../cpi/exception/UserProfileServiceException.java |   370 +
 .../user/cpi/profile_user_cpiConstants.java        |    16 +
 .../user/handler/UserProfileServiceHandler.java    |   235 +
 .../test/java/TestUserProfileServiceHandler.java   |   110 +
 ide-integration/log4j.properties                   |    34 +
 ide-integration/pom.xml                            |    37 +
 .../src/main/java/CustosAPIServerStarted.java      |    14 +
 .../src/main/resources/custos-server.properties    |    65 +
 .../database_scripts/init/01-databases.sql         |   307 +
 .../user-profile-catalog-derby.sql                 |   163 +
 .../user-profile-catalog-mysql.sql                 |   163 +
 .../src/main/resources/docker-compose.yml          |    27 +
 .../main/resources/keycloak/Default-export.json    |  1508 ++
 .../main/resources/keycloak/Default-export.json.bk |  1507 ++
 .../src/main/resources/keycloak/standalone.xml     |   521 +
 .../src/main/resources/keystores/airavata.jks      |   Bin 0 -> 2679 bytes
 .../src/main/resources/keystores/airavata_sym.jks  |   Bin 0 -> 501 bytes
 .../main/resources/keystores/client_truststore.jks |   Bin 0 -> 1027 bytes
 log4j.properties                                   |    34 +
 pom.xml                                            |    61 +
 .../authentication-service-cpi.thrift              |    14 +
 .../authentication_service_cpi_errors.thrift       |    27 +
 .../authentication-service/security_model.thrift   |    15 +
 .../authentication-service/userInfo_model.thrift   |    33 +
 .../tenant_profile_model.thrift                    |    73 +
 .../user_profile_model.thrift                      |   195 +
 .../workspace_model.thrift                         |    57 +
 .../iam-admin-services-cpi.thrift                  |   122 +
 .../iam_admin_services_cpi_errors.thrift           |    33 +
 .../profile-service/profile-service-cpi.thrift     |    29 +
 .../profile-tenant/profile-tenant-cpi.thrift       |    79 +
 .../profile_tenant_cpi_errors.thrift               |    33 +
 .../profile-user/profile-user-cpi.thrift           |    79 +
 .../profile-user/profile_user_cpi_errors.thrift    |    33 +
 135 files changed, 72313 insertions(+)


[airavata-custos] 32/48: created apis from group service and sharing service

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d89e0ded39a80d8f4aa5ce62b8f4e227f22b29a5
Author: Aarushi <aa...@gmail.com>
AuthorDate: Sat Aug 31 13:08:09 2019 -0400

    created apis from group service and sharing service
---
 .../group/profile/service/api/Application.java     |    14 +-
 .../api/controllers/GroupServiceController.java    |    82 +
 .../sharing-registry-distribution/pom.xml          |    87 -
 .../src/main/assembly/bin-assembly.xml             |    75 -
 .../src/main/resources/bin/setenv.sh               |    61 -
 .../src/main/resources/bin/sharing-registry.sh     |    90 -
 .../sharing-registry-server/pom.xml                |   130 -
 .../sharing/registry/db/entities/DomainEntity.java |   116 -
 .../sharing/registry/db/entities/EntityEntity.java |   219 -
 .../sharing/registry/db/entities/EntityPK.java     |    76 -
 .../registry/db/entities/EntityTypeEntity.java     |   130 -
 .../sharing/registry/db/entities/EntityTypePK.java |    76 -
 .../registry/db/entities/GroupAdminEntity.java     |    80 -
 .../sharing/registry/db/entities/GroupAdminPK.java |    66 -
 .../db/entities/GroupMembershipEntity.java         |   126 -
 .../registry/db/entities/GroupMembershipPK.java    |    88 -
 .../registry/db/entities/PermissionTypeEntity.java |   128 -
 .../registry/db/entities/PermissionTypePK.java     |    76 -
 .../registry/db/entities/SharingEntity.java        |   149 -
 .../sharing/registry/db/entities/SharingPK.java    |   116 -
 .../sharing/registry/db/entities/UserEntity.java   |   161 -
 .../registry/db/entities/UserGroupEntity.java      |   178 -
 .../sharing/registry/db/entities/UserGroupPK.java  |    75 -
 .../sharing/registry/db/entities/UserPK.java       |    75 -
 .../db/repositories/AbstractRepository.java        |   168 -
 .../registry/db/repositories/DomainRepository.java |    33 -
 .../registry/db/repositories/EntityRepository.java |   173 -
 .../db/repositories/EntityTypeRepository.java      |    34 -
 .../db/repositories/GroupAdminRepository.java      |    17 -
 .../db/repositories/GroupMembershipRepository.java |   104 -
 .../db/repositories/PermissionTypeRepository.java  |    52 -
 .../db/repositories/SharingRepository.java         |   115 -
 .../db/repositories/UserGroupRepository.java       |    95 -
 .../registry/db/repositories/UserRepository.java   |    79 -
 .../sharing/registry/db/utils/DBConstants.java     |   106 -
 .../custos/sharing/registry/db/utils/JPAUtils.java |    35 -
 .../registry/db/utils/ObjectMapperSingleton.java   |    38 -
 .../db/utils/SharingRegistryDBInitConfig.java      |    47 -
 .../db/utils/SharingRegistryJDBCConfig.java        |    67 -
 .../custos/sharing/registry/server/ServerMain.java |   101 -
 .../registry/server/SharingRegistryServer.java     |   191 -
 .../server/SharingRegistryServerHandler.java       |  1273 -
 .../src/main/resources/META-INF/persistence.xml    |    16 -
 .../src/main/resources/airavata.jks                |   Bin 1410 -> 0 bytes
 .../src/main/resources/client_truststore.jks       |   Bin 5312 -> 0 bytes
 .../src/main/resources/sharing-registry-derby.sql  |   147 -
 .../src/main/resources/sharing-registry-mysql.sql  |   146 -
 .../apache/custos/sharing/registry/CipresTest.java |   632 -
 .../registry/SharingRegistryServerHandlerTest.java |   386 -
 .../registry/SharingRegistryServiceTest.java       |   419 -
 .../src/test/resources/airavata.jks                |   Bin 1410 -> 0 bytes
 .../src/test/resources/client_truststore.jks       |   Bin 5312 -> 0 bytes
 .../src/test/resources/logback.xml                 |    31 -
 .../sharing-registry-stubs/pom.xml                 |    77 -
 .../SharingRegistryServiceClientFactory.java       |    44 -
 .../custos/sharing/registry/models/Domain.java     |   805 -
 .../registry/models/DuplicateEntryException.java   |   377 -
 .../custos/sharing/registry/models/Entity.java     |  1663 -
 .../sharing/registry/models/EntitySearchField.java |    79 -
 .../custos/sharing/registry/models/EntityType.java |   908 -
 .../custos/sharing/registry/models/GroupAdmin.java |   589 -
 .../sharing/registry/models/GroupCardinality.java  |    48 -
 .../sharing/registry/models/GroupChildType.java    |    47 -
 .../sharing/registry/models/GroupMembership.java   |   918 -
 .../custos/sharing/registry/models/GroupType.java  |    47 -
 .../sharing/registry/models/PermissionType.java    |   908 -
 .../sharing/registry/models/SearchCondition.java   |    64 -
 .../sharing/registry/models/SearchCriteria.java    |   628 -
 .../custos/sharing/registry/models/Sharing.java    |  1132 -
 .../registry/models/SharingRegistryException.java  |   374 -
 .../sharing/registry/models/SharingType.java       |    50 -
 .../custos/sharing/registry/models/User.java       |  1246 -
 .../custos/sharing/registry/models/UserGroup.java  |  1427 -
 .../registry/models/sharing_modelsConstants.java   |    14 -
 .../service/cpi/SharingRegistryService.java        | 67599 -------------------
 .../registry/service/cpi/sharing_cpiConstants.java |    14 -
 .../sharing-service-docs/api-docs/index.html       |   104 -
 .../sharing-service-docs/api-docs/sharing_cpi.html |   389 -
 .../api-docs/sharing_models.html                   |   308 -
 .../sharing-service-docs/api-docs/style.css        |   184 -
 .../sharing-service-docs/index.html                |   389 -
 .../sharing-service-docs/sharing_overview.png      |   Bin 49205 -> 0 bytes
 .../sharing-service-docs/style.css                 |   194 -
 .../thrift_models/thrift-gen.sh                    |    43 -
 84 files changed, 90 insertions(+), 87558 deletions(-)

diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/Committer.java b/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/Application.java
similarity index 72%
rename from custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/Committer.java
rename to custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/Application.java
index 28d2e09..75f11de 100644
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/Committer.java
+++ b/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/Application.java
@@ -1,4 +1,4 @@
-/**
+/*
  *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -17,10 +17,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.custos.sharing.registry.db.utils;
+package org.apache.group.profile.service.api;
 
-@FunctionalInterface
-public interface Committer<T, R>  {
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
 
-    R commit(T t);
-}
\ No newline at end of file
+@SpringBootApplication
+@ComponentScan(basePackages = {"org.apache.custos.group.profile.api.controllers"})
+public class Application {
+}
diff --git a/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/controllers/GroupServiceController.java b/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/controllers/GroupServiceController.java
new file mode 100644
index 0000000..04b8dba
--- /dev/null
+++ b/custos-profile-service/group-profile-service/group-profile-api/src/main/java/org/apache/group/profile/service/api/controllers/GroupServiceController.java
@@ -0,0 +1,82 @@
+package org.apache.group.profile.service.api.controllers;
+
+import org.apache.custos.profile.service.core.models.GroupModel;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/group")
+public class GroupServiceController {
+
+    @RequestMapping(method = RequestMethod.POST)
+    public ResponseEntity<String> createGroup(@RequestBody GroupModel groupModel){
+        return null;
+    }
+
+    @RequestMapping(method = RequestMethod.PUT)
+    public ResponseEntity<String> updateGroup(@RequestBody GroupModel groupModel){
+        return null;
+    }
+
+    @RequestMapping(value = "/id/{groupId}/owner/{ownerId}", method = RequestMethod.DELETE)
+    public ResponseEntity<String> deleteGroup(@PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
+        return null;
+    }
+
+    @RequestMapping(value = "/id/{groupId}", method = RequestMethod.GET)
+    public ResponseEntity<String> getGroup(@PathVariable("groupId") String groupId){
+        return null;
+    }
+
+    @RequestMapping(value = "/all", method = RequestMethod.GET)
+    public @ResponseBody
+    List<GroupModel> getGroups(){
+        return null;
+    }
+
+    @RequestMapping(value = "/username/{username}", method = RequestMethod.GET)
+    public @ResponseBody
+    List<GroupModel> getAllGroupsUserBelongs(@PathVariable("username") String username){
+        return null;
+    }
+
+    @RequestMapping(value = "/id/{groupId}", method = RequestMethod.PUT)
+    public ResponseEntity<String> addUsersToGroup(@PathVariable("groupId") String groupId, @RequestBody List<String> userIds){
+        return null;
+    }
+
+    @RequestMapping(value = "/id/{groupId}", method = RequestMethod.PUT)
+    public ResponseEntity<String> removeUsersFromGroup(@PathVariable("groupId") String groupId, @RequestBody List<String> userIds){
+        return null;
+    }
+
+    @RequestMapping(value = "/id/{groupId}/owner/{ownerId}", method = RequestMethod.PUT)
+    public ResponseEntity<String> transferGroupOwnership(@PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
+        return null;
+    }
+
+    @RequestMapping(value = "addAdmins/id/{groupId}", method = RequestMethod.PUT)
+    public ResponseEntity<String> addGroupAdmins(@PathVariable("groupId") String groupId, @RequestBody List<String> adminIds){
+        return null;
+    }
+
+    @RequestMapping(value = "removeAdmins/id/{groupId}", method = RequestMethod.PUT)
+    public ResponseEntity<String> removeGroupAdmins(@PathVariable("groupId") String groupId, @RequestBody List<String> adminIds){
+        return null;
+    }
+
+    @RequestMapping(value = "/id/{groupId}/admin/{adminId}", method = RequestMethod.GET)
+    public @ResponseBody
+    Map<String, Boolean> hasAdminAccess(@PathVariable("groupId") String groupId, @PathVariable("adminId") String adminId){
+        return null;
+    }
+
+    @RequestMapping(value = "/id/{groupId}/owner/{ownerId}", method = RequestMethod.GET)
+    public @ResponseBody
+    Map<String, Boolean> hasOwnerAccess(@PathVariable("groupId") String groupId, @PathVariable("ownerId") String ownerId){
+        return null;
+    }
+}
diff --git a/custos-sharing-registry-service/sharing-registry-distribution/pom.xml b/custos-sharing-registry-service/sharing-registry-distribution/pom.xml
deleted file mode 100644
index 3e709f6..0000000
--- a/custos-sharing-registry-service/sharing-registry-distribution/pom.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-
-    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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>custos-sharing-registry-service</artifactId>
-        <groupId>org.apache.custos</groupId>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>custos-sharing-registry-distribution</artifactId>
-    <packaging>jar</packaging>
-    <name>Sharing Registry Distribution</name>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>1.7.10</version>
-        </dependency>
-        <dependency>
-            <groupId>net.sf.dozer</groupId>
-            <artifactId>dozer</artifactId>
-            <version>5.4.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa</artifactId>
-            <version>${openjpa.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-            <version>${mysql.connector.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.thrift</groupId>
-            <artifactId>libthrift</artifactId>
-            <version>${thrift.version}</version>
-        </dependency>
-    </dependencies>
-
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-assembly-plugin</artifactId>
-                <version>${maven.assembly.plugin}</version>
-                <executions>
-                    <execution>
-                        <id>distribution-package</id>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>single</goal>
-                        </goals>
-                        <configuration>
-                            <descriptors>
-                                <descriptor>src/main/assembly/bin-assembly.xml</descriptor>
-                            </descriptors>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-</project>
diff --git a/custos-sharing-registry-service/sharing-registry-distribution/src/main/assembly/bin-assembly.xml b/custos-sharing-registry-service/sharing-registry-distribution/src/main/assembly/bin-assembly.xml
deleted file mode 100644
index 038a065..0000000
--- a/custos-sharing-registry-service/sharing-registry-distribution/src/main/assembly/bin-assembly.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<!--
-
-
-    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.
-
--->
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
-          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
-          http://maven.apache.org/xsd/assembly-1.1.2.xsd">
-    <id>bin</id>
-    <includeBaseDirectory>true</includeBaseDirectory>
-    <baseDirectory>sharing-registry</baseDirectory>
-    <formats>
-        <format>tar.gz</format>
-    </formats>
-
-    <fileSets>
-        <fileSet>
-            <directory>src/main/resources/bin</directory>
-            <outputDirectory>bin</outputDirectory>
-            <includes>
-                <include>*.sh</include>
-            </includes>
-            <fileMode>755</fileMode>
-        </fileSet>
-
-        <!-- ********************** copy airavata-server.properties and key stores ********************** -->
-        <fileSet>
-            <directory>../../configuration/server/src/main/resources/</directory>
-            <outputDirectory>bin</outputDirectory>
-            <includes>
-                <include>airavata-server.properties</include>
-                <include>log4j.properties</include>
-                <include>airavata.jks</include>
-                <include>client_truststore.jks</include>
-            </includes>
-        </fileSet>
-
-        <!-- ********************** copy database scripts ********************** -->
-        <fileSet>
-            <directory>../sharing-registry-server/src/main/resources/
-            </directory>
-            <outputDirectory>bin/database_scripts
-            </outputDirectory>
-            <includes>
-                <include>*sql*</include>
-            </includes>
-        </fileSet>
-    </fileSets>
-
-    <dependencySets>
-        <dependencySet>
-            <outputDirectory>/lib</outputDirectory>
-            <includes>
-                <include>*:jar:*</include>
-            </includes>
-        </dependencySet>
-    </dependencySets>
-</assembly>
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/setenv.sh b/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/setenv.sh
deleted file mode 100644
index 1e5475d..0000000
--- a/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/setenv.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/sh
-
-# 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.
-
-# Get standard environment variables
-# if JAVA_HOME is not set we're not happy
-if [ -z "$JAVA_HOME" ]; then
-  echo "You must set the JAVA_HOME variable before running sharing-registry scripts."
-  exit 1
-fi
-
-# OS specific support.  $var _must_ be set to either true or false.
-cygwin=false
-os400=false
-case "`uname`" in
-CYGWIN*) cygwin=true;;
-OS400*) os400=true;;
-esac
-
-# resolve links - $0 may be a softlink
-PRG="$0"
-
-while [ -h "$PRG" ]; do
-  ls=`ls -ld "$PRG"`
-  link=`expr "$ls" : '.*-> \(.*\)$'`
-  if expr "$link" : '.*/.*' > /dev/null; then
-    PRG="$link"
-  else
-    PRG=`dirname "$PRG"`/"$link"
-  fi
-done
-
-PRGDIR=`dirname "$PRG"`
-
-# Only set SHARING_REGISTRY_HOME if not already set
-[ -z "$SHARING_REGISTRY_HOME" ] && SHARING_REGISTRY_HOME=`cd "$PRGDIR/.." ; pwd`
-
-SHARING_REGISTRY_CLASSPATH=""
-
-for f in "$SHARING_REGISTRY_HOME"/lib/*.jar
-do
-  SHARING_REGISTRY_CLASSPATH="$SHARING_REGISTRY_CLASSPATH":$f
-done
-
-export SHARING_REGISTRY_HOME
-export SHARING_REGISTRY_CLASSPATH
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh b/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh
deleted file mode 100644
index 07c7612..0000000
--- a/custos-sharing-registry-service/sharing-registry-distribution/src/main/resources/bin/sharing-registry.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/bash
-
-# 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.
-
-. `dirname $0`/setenv.sh
-cd $SHARING_REGISTRY_HOME/bin
-
-IS_DAEMON_MODE=false
-SHARING_REGISTRY_COMMAND=""
-STOP=false
-FORCE=false
-JAVA_OPTS=""
-
-for var in "$@"
-do
-    case $var in
-    -xdebug)
-        	AIRAVATA_COMMAND="${AIRAVATA_COMMAND}"
-            JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=8000"
-            shift
-        ;;
-	start)
-	    IS_DAEMON_MODE=true
-            shift
-        ;;
-	stop)
-	    STOP=true
-	    SHARING_REGISTRY_COMMAND="$
-	    SHARING_REGISTRY_COMMAND $var"
-            shift
-        ;;
-        -h)
-            echo "Usage: sharing-registry.sh [command-options]"
-            echo "command options:"
-	    echo "  start              Start server in daemon mode"
-	    echo "  stop               Stop server."
-	    echo "  -xdebug			   Start Sharing Registry Server under JPDA debugger"
-	    echo "  -h                 Display this help and exit"
-	        shift
-            exit 0
-        ;;
-	*)
-	    SHARING_REGISTRY_COMMAND="$SHARING_REGISTRY_COMMAND $var"
-            shift
-    esac
-done
-
-if $STOP;
-then
-	for f in `find . -name "server_start_*"`; do
-		IFS='_' read -a f_split <<< "$f"
-		echo "Found process file : $f"
-		echo -n "    Sending kill signals to process ${f_split[2]}..."
-		out=`kill -9 ${f_split[2]} 2>&1`
-		if [ -z "$out" ]; then
-		    echo "done"
-		else
-		    echo "failed (REASON: $out)"
-		fi
-		echo -n "    Removing process file..."
-		out=`rm $f 2>&1`
-		if [ -z "$out" ]; then
-		    echo "done"
-		else
-		    echo "failed (REASON: $out)"
-		fi
-	done
-else
-	if $IS_DAEMON_MODE ; then
-		echo "Starting Sharing Registry Server in daemon mode..."
-		$JAVA_HOME/bin/java ${JAVA_OPTS} -classpath "$SHARING_REGISTRY_CLASSPATH"  org.apache.airavata.sharing.registry.server.ServerMain $* > /dev/null 2>&1 &
-	else
-		$JAVA_HOME/bin/java ${JAVA_OPTS} -classpath "$SHARING_REGISTRY_CLASSPATH"  org.apache.airavata.sharing.registry.server.ServerMain $*
-	fi
-fi
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/pom.xml b/custos-sharing-registry-service/sharing-registry-server/pom.xml
deleted file mode 100644
index d530cd7..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/pom.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-
-    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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>custos-sharing-registry-service</artifactId>
-        <groupId>org.apache.custos</groupId>
-        <relativePath>../pom.xml</relativePath>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>custos-sharing-registry-server</artifactId>
-    <packaging>jar</packaging>
-    <name>Sharing Registry Server</name>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <version>1.7.10</version>
-        </dependency>
-        <dependency>
-            <groupId>net.sf.dozer</groupId>
-            <artifactId>dozer</artifactId>
-            <version>5.4.0</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa</artifactId>
-            <version>${openjpa.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-            <version>${mysql.connector.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.thrift</groupId>
-            <artifactId>libthrift</artifactId>
-            <version>${thrift.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.databene</groupId>
-            <artifactId>contiperf</artifactId>
-            <version>2.3.4</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>custos-commons</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.custos</groupId>
-            <artifactId>custos-sharing-registry-stubs</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit.version}</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.5.1</version>
-                <configuration>
-                    <source>1.8</source>
-                    <target>1.8</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
-                <version>2.3.2</version>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.openjpa</groupId>
-                <artifactId>openjpa-maven-plugin</artifactId>
-                <version>${openjpa.version}</version>
-                <configuration>
-                    <includes>**/entities/*.class</includes>
-                    <excludes>**/entities/XML*.class</excludes>
-                    <addDefaultConstructor>true</addDefaultConstructor>
-                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>enhancer</id>
-                        <phase>process-classes</phase>
-                        <goals>
-                            <goal>enhance</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/DomainEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/DomainEntity.java
deleted file mode 100644
index 620c9b4..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/DomainEntity.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "DOMAIN", schema = "" )
-public class DomainEntity {
-    private final static Logger logger = LoggerFactory.getLogger(DomainEntity.class);
-    private String domainId;
-    private String name;
-    private String description;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        DomainEntity that = (DomainEntity) o;
-
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
-        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
-            return false;
-        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
-            return false;
-        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getDomainId() != null ? getDomainId().hashCode() : 0;
-        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
-        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
-        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
-        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityEntity.java
deleted file mode 100644
index a87fbf4..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityEntity.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-import java.nio.ByteBuffer;
-
-@Entity
-@Table(name = "ENTITY", schema = "")
-@IdClass(EntityPK.class)
-public class EntityEntity {
-    private final static Logger logger = LoggerFactory.getLogger(EntityEntity.class);
-    private String entityId;
-    private String domainId;
-    private String entityTypeId;
-    private String ownerId;
-    private String parentEntityId;
-    private String name;
-    private String description;
-    private ByteBuffer binaryData;
-    private String fullText;
-    private Long originalEntityCreationTime;
-    private Long sharedCount;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "ENTITY_ID")
-    public String getEntityId() {
-        return entityId;
-    }
-
-    public void setEntityId(String entityId) {
-        this.entityId = entityId;
-    }
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "ENTITY_TYPE_ID")
-    public String getEntityTypeId() {
-        return entityTypeId;
-    }
-
-    public void setEntityTypeId(String entityTypeId) {
-        this.entityTypeId = entityTypeId;
-    }
-
-    @Basic
-    @Column(name = "OWNER_ID")
-    public String getOwnerId() {
-        return ownerId;
-    }
-
-    public void setOwnerId(String ownerId) {
-        this.ownerId = ownerId;
-    }
-
-    @Basic
-    @Column(name = "PARENT_ENTITY_ID")
-    public String getParentEntityId() {
-        return parentEntityId;
-    }
-
-    public void setParentEntityId(String parentEntityId) {
-        this.parentEntityId = parentEntityId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Lob
-    @Column(name="BINARY_DATA")
-    public ByteBuffer getBinaryData() {
-        return binaryData;
-    }
-
-    public void setBinaryData(ByteBuffer binaryData) {
-        this.binaryData = binaryData;
-    }
-
-    @Basic
-    @Column(name = "FULL_TEXT")
-    public String getFullText() {
-        return fullText;
-    }
-
-    public void setFullText(String fullText) {
-        this.fullText = fullText;
-    }
-
-    @Basic
-    @Column(name = "ORIGINAL_ENTITY_CREATION_TIME")
-    public Long getOriginalEntityCreationTime() {
-        return originalEntityCreationTime;
-    }
-
-    public void setOriginalEntityCreationTime(Long originalEntityCreationTime) {
-        this.originalEntityCreationTime = originalEntityCreationTime;
-    }
-
-    @Basic
-    @Column(name = "SHARED_COUNT")
-    public Long getSharedCount() {
-        return sharedCount;
-    }
-
-    public void setSharedCount(Long sharedCount) {
-        this.sharedCount = sharedCount;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        EntityEntity that = (EntityEntity) o;
-
-        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
-            return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-        if (getParentEntityId() != null ? !getParentEntityId().equals(that.getParentEntityId()) : that.getParentEntityId() != null)
-            return false;
-        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
-        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
-            return false;
-        if (getBinaryData().equals(that.getBinaryData())) return false;
-        if (getFullText() != null ? !getFullText().equals(that.getFullText()) : that.getFullText() != null)
-            return false;
-        if (getOriginalEntityCreationTime() != null ? !getOriginalEntityCreationTime().equals(that.getOriginalEntityCreationTime())
-                : that.getOriginalEntityCreationTime() != null) return false;
-        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
-            return false;
-        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
-            return false;
-        if (getOwnerId() != null ? !getOwnerId().equals(that.getOwnerId()) : that.getOwnerId() != null) return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getEntityId() != null ? getEntityId().hashCode() : 0;
-        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
-        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
-        result = 31 * result + (getBinaryData() != null ? getBinaryData().hashCode() : 0);
-        result = 31 * result + (getFullText() != null ? getFullText().hashCode() : 0);
-        result = 31 * result + (getOriginalEntityCreationTime() != null ? getOriginalEntityCreationTime().hashCode() : 0);
-        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
-        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityPK.java
deleted file mode 100644
index 9999743..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityPK.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class EntityPK implements Serializable {
-    private final static Logger logger = LoggerFactory.getLogger(EntityPK.class);
-    private String entityId;
-    private String domainId;
-
-
-    @Column(name = "ENTITY_ID")
-    @Id
-    public String getEntityId() {
-        return entityId;
-    }
-
-    public void setEntityId(String entityId) {
-        this.entityId = entityId;
-    }
-
-    @Column(name = "DOMAIN_ID")
-    @Id
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        EntityPK that = (EntityPK) o;
-
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getDomainId() != null ? getDomainId().hashCode() : 0;
-        result = 31 * result + (getEntityId() != null ? getEntityId().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypeEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypeEntity.java
deleted file mode 100644
index 458a4a9..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypeEntity.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "ENTITY_TYPE", schema = "")
-@IdClass(EntityTypePK.class)
-public class EntityTypeEntity {
-    private final static Logger logger = LoggerFactory.getLogger(EntityTypeEntity.class);
-    private String entityTypeId;
-    private String domainId;
-    private String name;
-    private String description;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "ENTITY_TYPE_ID")
-    public String getEntityTypeId() {
-        return entityTypeId;
-    }
-
-    public void setEntityTypeId(String entityTypeId) {
-        this.entityTypeId = entityTypeId;
-    }
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        EntityTypeEntity that = (EntityTypeEntity) o;
-
-        if (getEntityTypeId() != null ? !getEntityTypeId().equals(that.getEntityTypeId()) : that.getEntityTypeId() != null)
-            return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
-        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
-            return false;
-        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
-            return false;
-        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getEntityTypeId() != null ? getEntityTypeId().hashCode() : 0;
-        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
-        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
-        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
-        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypePK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypePK.java
deleted file mode 100644
index f162b3b..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/EntityTypePK.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class EntityTypePK implements Serializable {
-    private final static Logger logger = LoggerFactory.getLogger(EntityTypePK.class);
-    private String entityTypeId;
-    private String domainId;
-
-
-    @Column(name = "ENTITY_TYPE_ID")
-    @Id
-    public String getEntityTypeId() {
-        return entityTypeId;
-    }
-
-    public void setEntityTypeId(String entityTypeId) {
-        this.entityTypeId = entityTypeId;
-    }
-
-    @Column(name = "DOMAIN_ID")
-    @Id
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        EntityTypePK that = (EntityTypePK) o;
-
-        if (getEntityTypeId() != null ? !getEntityTypeId().equals(that.getEntityTypeId()) : that.getEntityTypeId() != null)
-            return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getEntityTypeId() != null ? getEntityTypeId().hashCode() : 0;
-        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminEntity.java
deleted file mode 100644
index 26fe095..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminEntity.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.apache.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "GROUP_ADMIN", schema = "")
-@IdClass(GroupAdminPK.class)
-public class GroupAdminEntity {
-    private final static Logger logger = LoggerFactory.getLogger(GroupAdminEntity.class);
-    private String groupId;
-    private String domainId;
-    private String adminId;
-    private UserGroupEntity userGroup;
-
-    @Id
-    @Column(name = "GROUP_ID")
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Id
-    @Column(name = "ADMIN_ID")
-    public String getAdminId() {
-        return adminId;
-    }
-
-    public void setAdminId(String adminId) {
-        this.adminId = adminId;
-    }
-
-    @ManyToOne(targetEntity = UserGroupEntity.class, cascade = CascadeType.MERGE)
-    @JoinColumns({
-            @JoinColumn(name="GROUP_ID", referencedColumnName="GROUP_ID"),
-            @JoinColumn(name="DOMAIN_ID", referencedColumnName="DOMAIN_ID")
-    })
-    public UserGroupEntity getUserGroup() {
-        return userGroup;
-    }
-
-    public void setUserGroup(UserGroupEntity userGroup) {
-        this.userGroup = userGroup;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        GroupAdminEntity that = (GroupAdminEntity) o;
-
-        if (!getGroupId().equals(that.getGroupId())) return false;
-        if (!getDomainId().equals(that.getDomainId())) return false;
-        return getAdminId().equals(that.getAdminId());
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getGroupId().hashCode();
-        result = 31 * result + getDomainId().hashCode();
-        result = 31 * result + getAdminId().hashCode();
-        return result;
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminPK.java
deleted file mode 100644
index a036cf9..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupAdminPK.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.apache.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class GroupAdminPK implements Serializable{
-
-    private final static Logger logger = LoggerFactory.getLogger(GroupAdminPK.class);
-    private String groupId;
-    private String domainId;
-    private String adminId;
-
-    @Id
-    @Column(name = "GROUP_ID")
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Id
-    @Column(name = "ADMIN_ID")
-    public String getAdminId() {
-        return adminId;
-    }
-
-    public void setAdminId(String adminId) {
-        this.adminId = adminId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        GroupAdminPK groupAdminPK = (GroupAdminPK) o;
-
-        if (!getGroupId().equals(groupAdminPK.getGroupId())) return false;
-        if (!getDomainId().equals(groupAdminPK.getDomainId())) return false;
-        return getAdminId().equals(groupAdminPK.getAdminId());
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getGroupId().hashCode();
-        result = 31 * result + getDomainId().hashCode();
-        result = 31 * result + getAdminId().hashCode();
-        return result;
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipEntity.java
deleted file mode 100644
index 692411d..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipEntity.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "GROUP_MEMBERSHIP", schema = "")
-@IdClass(GroupMembershipPK.class)
-public class GroupMembershipEntity {
-    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipEntity.class);
-    private String parentId;
-    private String childId;
-    private String childType;
-    private String domainId;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "PARENT_ID")
-    public String getParentId() {
-        return parentId;
-    }
-
-    public void setParentId(String parentId) {
-        this.parentId = parentId;
-    }
-
-    @Id
-    @Column(name = "CHILD_ID")
-    public String getChildId() {
-        return childId;
-    }
-
-    public void setChildId(String childId) {
-        this.childId = childId;
-    }
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "CHILD_TYPE")
-    public String getChildType() {
-        return childType;
-    }
-
-    public void setChildType(String childType) {
-        this.childType = childType;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        GroupMembershipEntity that = (GroupMembershipEntity) o;
-
-        if (getParentId() != null ? !getParentId().equals(that.getParentId()) : that.getParentId() != null)
-            return false;
-        if (getChildId() != null ? !getChildId().equals(that.getChildId()) : that.getChildId() != null) return false;
-        if (getChildType() != null ? !getChildType().equals(that.getChildType()) : that.getChildType() != null)
-            return false;
-        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
-            return false;
-        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getParentId() != null ? getParentId().hashCode() : 0;
-        result = 31 * result + (getChildId() != null ? getChildId().hashCode() : 0);
-        result = 31 * result + (getChildType() != null ? getChildType().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipPK.java
deleted file mode 100644
index 37c83c0..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/GroupMembershipPK.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class GroupMembershipPK implements Serializable {
-    private final static Logger logger = LoggerFactory.getLogger(GroupMembershipPK.class);
-    private String parentId;
-    private String childId;
-    private String domainId;
-
-    @Column(name = "PARENT_ID")
-    @Id
-    public String getParentId() {
-        return parentId;
-    }
-
-    public void setParentId(String parentId) {
-        this.parentId = parentId;
-    }
-
-    @Column(name = "CHILD_ID")
-    @Id
-    public String getChildId() {
-        return childId;
-    }
-
-    public void setChildId(String childId) {
-        this.childId = childId;
-    }
-
-    @Column(name = "DOMAIN_ID")
-    @Id
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        GroupMembershipPK that = (GroupMembershipPK) o;
-
-        if (getParentId() != null ? !getParentId().equals(that.getParentId()) : that.getParentId() != null)
-            return false;
-        if (getChildId() != null ? !getChildId().equals(that.getChildId()) : that.getChildId() != null) return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getParentId() != null ? getParentId().hashCode() : 0;
-        result = 31 * result + (getChildId() != null ? getChildId().hashCode() : 0);
-        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypeEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypeEntity.java
deleted file mode 100644
index 53882c0..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypeEntity.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "PERMISSION_TYPE", schema = "")
-@IdClass(PermissionTypePK.class)
-public class PermissionTypeEntity {
-    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeEntity.class);
-    private String permissionTypeId;
-    private String domainId;
-    private String name;
-    private String description;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "PERMISSION_TYPE_ID")
-    public String getPermissionTypeId() {
-        return permissionTypeId;
-    }
-
-    public void setPermissionTypeId(String permissionTypeId) {
-        this.permissionTypeId = permissionTypeId;
-    }
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        PermissionTypeEntity that = (PermissionTypeEntity) o;
-
-        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
-            return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
-        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
-            return false;
-        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
-        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
-        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
-        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypePK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypePK.java
deleted file mode 100644
index 836316f..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/PermissionTypePK.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class PermissionTypePK implements Serializable {
-    private final static Logger logger = LoggerFactory.getLogger(PermissionTypePK.class);
-    private String permissionTypeId;
-    private String domainId;
-
-
-    @Column(name = "PERMISSION_TYPE_ID")
-    @Id
-    public String getPermissionTypeId() {
-        return permissionTypeId;
-    }
-
-    public void setPermissionTypeId(String permissionTypeId) {
-        this.permissionTypeId = permissionTypeId;
-    }
-
-    @Column(name = "DOMAIN_ID")
-    @Id
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        PermissionTypePK that = (PermissionTypePK) o;
-
-        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
-            return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
-        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingEntity.java
deleted file mode 100644
index f52f574..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingEntity.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-
-@Entity
-@Table(name = "SHARING", schema = "")
-@IdClass(SharingPK.class)
-public class SharingEntity {
-    private final static Logger logger = LoggerFactory.getLogger(SharingEntity.class);
-    private String permissionTypeId;
-    private String entityId;
-    private String groupId;
-    private String domainId;
-    private String sharingType;
-    private String inheritedParentId;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "PERMISSION_TYPE_ID")
-    public String getPermissionTypeId() {
-        return permissionTypeId;
-    }
-
-    public void setPermissionTypeId(String permissionTypeId) {
-        this.permissionTypeId = permissionTypeId;
-    }
-
-    @Id
-    @Column(name = "ENTITY_ID")
-    public String getEntityId() {
-        return entityId;
-    }
-
-    public void setEntityId(String entityId) {
-        this.entityId = entityId;
-    }
-
-    @Id
-    @Column(name = "GROUP_ID")
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-
-    @Id
-    @Column(name = "INHERITED_PARENT_ID")
-    public String getInheritedParentId() {
-        return inheritedParentId;
-    }
-
-    public void setInheritedParentId(String inheritedParentId) {
-        this.inheritedParentId = inheritedParentId;
-    }
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "SHARING_TYPE")
-    public String getSharingType() {
-        return sharingType;
-    }
-
-    public void setSharingType(String sharingType) {
-        this.sharingType = sharingType;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        SharingEntity that = (SharingEntity) o;
-
-        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
-            return false;
-        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
-            return false;
-        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
-        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
-            return false;
-        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
-        result = 31 * result + (getEntityId() != null ? getEntityId().hashCode() : 0);
-        result = 31 * result + (getGroupId() != null ? getGroupId().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingPK.java
deleted file mode 100644
index 506b486..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/SharingPK.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class SharingPK implements Serializable {
-    private final static Logger logger = LoggerFactory.getLogger(SharingPK.class);
-    private String permissionTypeId;
-    private String entityId;
-    private String groupId;
-    private String inheritedParentId;
-    private String domainId;
-
-    @Column(name = "PERMISSION_TYPE_ID")
-    @Id
-    public String getPermissionTypeId() {
-        return permissionTypeId;
-    }
-
-    public void setPermissionTypeId(String permissionTypeId) {
-        this.permissionTypeId = permissionTypeId;
-    }
-
-    @Column(name = "ENTITY_ID")
-    @Id
-    public String getEntityId() {
-        return entityId;
-    }
-
-    public void setEntityId(String entityId) {
-        this.entityId = entityId;
-    }
-
-    @Column(name = "GROUP_ID")
-    @Id
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-    @Column(name = "INHERITED_PARENT_ID")
-    @Id
-    public String getInheritedParentId() {
-        return inheritedParentId;
-    }
-
-    public void setInheritedParentId(String inheritedParentId) {
-        this.inheritedParentId = inheritedParentId;
-    }
-
-    @Column(name = "DOMAIN_ID")
-    @Id
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        SharingPK that = (SharingPK) o;
-
-        if (getPermissionTypeId() != null ? !getPermissionTypeId().equals(that.getPermissionTypeId()) : that.getPermissionTypeId() != null)
-            return false;
-        if (getEntityId() != null ? !getEntityId().equals(that.getEntityId()) : that.getEntityId() != null)
-            return false;
-        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
-        if (getInheritedParentId() != null ? !getInheritedParentId().equals(that.getInheritedParentId()) : that.getInheritedParentId() != null)
-            return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getPermissionTypeId() != null ? getPermissionTypeId().hashCode() : 0;
-        result = 31 * result + (getEntityId() != null ? getEntityId().hashCode() : 0);
-        result = 31 * result + (getGroupId() != null ? getGroupId().hashCode() : 0);
-        result = 31 * result + (getInheritedParentId() != null ? getInheritedParentId().hashCode() : 0);
-        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserEntity.java
deleted file mode 100644
index 25fd4a5..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserEntity.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-import java.nio.ByteBuffer;
-
-@Entity
-@Table(name = "SHARING_USER", schema = "") // USER is a reserved term in derby
-@IdClass(UserPK.class)
-public class UserEntity {
-    private final static Logger logger = LoggerFactory.getLogger(UserEntity.class);
-    private String userId;
-    private String domainId;
-    private String userName;
-    private String firstName;
-    private String lastName;
-    private String email;
-    private ByteBuffer icon;
-    private Long createdTime;
-    private Long updatedTime;
-
-    @Id
-    @Column(name = "USER_ID")
-    public String getUserId() {
-        return userId;
-    }
-
-    public void setUserId(String userId) {
-        this.userId = userId;
-    }
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "USER_NAME")
-    public String getUserName() {
-        return userName;
-    }
-
-    public void setUserName(String userName) {
-        this.userName = userName;
-    }
-
-    @Basic
-    @Column(name = "FIRST_NAME")
-    public String getFirstName() {
-        return firstName;
-    }
-
-    public void setFirstName(String firstName) {
-        this.firstName = firstName;
-    }
-
-    @Basic
-    @Column(name = "LAST_NAME")
-    public String getLastName() {
-        return lastName;
-    }
-
-    public void setLastName(String lastName) {
-        this.lastName = lastName;
-    }
-
-    @Basic
-    @Column(name = "EMAIL")
-    public String getEmail() {
-        return email;
-    }
-
-    public void setEmail(String email) {
-        this.email = email;
-    }
-
-    @Lob
-    @Column(name = "ICON")
-    public ByteBuffer getIcon() {
-        return icon;
-    }
-
-    public void setIcon(ByteBuffer icon) {
-        this.icon = icon;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        UserEntity that = (UserEntity) o;
-
-        if (getUserId() != null ? !getUserId().equals(that.getUserId()) : that.getUserId() != null) return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-        if (getUserName() != null ? !getUserName().equals(that.getUserName()) : that.getUserName() != null)
-            return false;
-        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
-            return false;
-        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getUserId() != null ? getUserId().hashCode() : 0;
-        result = 31 * result + (getUserName() != null ? getUserName().hashCode() : 0);
-        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
-        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupEntity.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupEntity.java
deleted file mode 100644
index 9d8a3ea..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupEntity.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.*;
-import java.util.List;
-
-@Entity
-@Table(name = "USER_GROUP", schema = "")
-@IdClass(UserGroupPK.class)
-public class UserGroupEntity {
-    private final static Logger logger = LoggerFactory.getLogger(UserGroupEntity.class);
-    private String groupId;
-    private String domainId;
-    private String name;
-    private String description;
-    private String ownerId;
-    private String groupType;
-    private String groupCardinality;
-    private Long createdTime;
-    private Long updatedTime;
-    private List<GroupAdminEntity> groupAdmins;
-
-    @Id
-    @Column(name = "GROUP_ID")
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-    @Id
-    @Column(name = "DOMAIN_ID")
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Basic
-    @Column(name = "OWNER_ID")
-    public String getOwnerId() {
-        return ownerId;
-    }
-
-    public void setOwnerId(String ownerId) {
-        this.ownerId = ownerId;
-    }
-
-    @Basic
-    @Column(name = "NAME")
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @Basic
-    @Column(name = "DESCRIPTION")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @Basic
-    @Column(name = "GROUP_CARDINALITY")
-    public String getGroupCardinality() {
-        return groupCardinality;
-    }
-
-    public void setGroupCardinality(String groupCardinality) {
-        this.groupCardinality = groupCardinality;
-    }
-
-    @Basic
-    @Column(name = "GROUP_TYPE")
-    public String getGroupType() {
-        return groupType;
-    }
-
-    public void setGroupType(String type) {
-        this.groupType = type;
-    }
-
-    @Basic
-    @Column(name = "CREATED_TIME")
-    public Long getCreatedTime() {
-        return createdTime;
-    }
-
-    public void setCreatedTime(Long createdTime) {
-        this.createdTime = createdTime;
-    }
-
-    @Basic
-    @Column(name = "UPDATED_TIME")
-    public Long getUpdatedTime() {
-        return updatedTime;
-    }
-
-    public void setUpdatedTime(Long updatedTime) {
-        this.updatedTime = updatedTime;
-    }
-
-    @OneToMany(targetEntity = GroupAdminEntity.class, cascade = CascadeType.ALL,
-            mappedBy = "userGroup", fetch = FetchType.EAGER)
-    public List<GroupAdminEntity> getGroupAdmins() {
-        return groupAdmins;
-    }
-
-    public void setGroupAdmins(List<GroupAdminEntity> groupAdmins) {
-        this.groupAdmins = groupAdmins;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        UserGroupEntity that = (UserGroupEntity) o;
-
-        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-        if (getOwnerId() != null ? !getOwnerId().equals(that.getOwnerId()) : that.getOwnerId() != null) return false;
-        if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
-        if (getDescription() != null ? !getDescription().equals(that.getDescription()) : that.getDescription() != null)
-            return false;
-        if (getGroupType() != null ? !getGroupType().equals(that.getGroupType()) : that.getGroupType() != null)
-            return false;
-        if (getCreatedTime() != null ? !getCreatedTime().equals(that.getCreatedTime()) : that.getCreatedTime() != null)
-            return false;
-        if (getUpdatedTime() != null ? !getUpdatedTime().equals(that.getUpdatedTime()) : that.getUpdatedTime() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getGroupId() != null ? getGroupId().hashCode() : 0;
-        result = 31 * result + (getName() != null ? getName().hashCode() : 0);
-        result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
-        result = 31 * result + (getGroupType() != null ? getGroupType().hashCode() : 0);
-        result = 31 * result + (getCreatedTime() != null ? getCreatedTime().hashCode() : 0);
-        result = 31 * result + (getUpdatedTime() != null ? getUpdatedTime().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupPK.java
deleted file mode 100644
index dc12feb..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserGroupPK.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class UserGroupPK implements Serializable {
-    private final static Logger logger = LoggerFactory.getLogger(UserGroupPK.class);
-    private String groupId;
-    private String domainId;
-
-    @Column(name = "GROUP_ID")
-    @Id
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public void setGroupId(String groupId) {
-        this.groupId = groupId;
-    }
-
-    @Column(name = "DOMAIN_ID")
-    @Id
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        UserGroupPK that = (UserGroupPK) o;
-
-        if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null)
-            return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getGroupId() != null ? getGroupId().hashCode() : 0;
-        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserPK.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserPK.java
deleted file mode 100644
index 9f68aa0..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/entities/UserPK.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.entities;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.Column;
-import javax.persistence.Id;
-import java.io.Serializable;
-
-public class UserPK implements Serializable {
-    private final static Logger logger = LoggerFactory.getLogger(UserPK.class);
-    private String userId;
-    private String domainId;
-
-    @Column(name = "USER_ID")
-    @Id
-    public String getUserId() {
-        return userId;
-    }
-
-    public void setUserId(String userId) {
-        this.userId = userId;
-    }
-
-    @Column(name = "DOMAIN_ID")
-    @Id
-    public String getDomainId() {
-        return domainId;
-    }
-
-    public void setDomainId(String domainId) {
-        this.domainId = domainId;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        UserPK that = (UserPK) o;
-
-        if (getUserId() != null ? !getUserId().equals(that.getUserId()) : that.getUserId() != null)
-            return false;
-        if (getDomainId() != null ? !getDomainId().equals(that.getDomainId()) : that.getDomainId() != null)
-            return false;
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = getUserId() != null ? getUserId().hashCode() : 0;
-        result = 31 * result + (getDomainId() != null ? getDomainId().hashCode() : 0);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/AbstractRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/AbstractRepository.java
deleted file mode 100644
index 3823faa..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/AbstractRepository.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.utils.Committer;
-import org.apache.custos.sharing.registry.db.utils.DBConstants;
-import org.apache.custos.sharing.registry.db.utils.JPAUtils;
-import org.apache.custos.sharing.registry.db.utils.ObjectMapperSingleton;
-import org.apache.custos.sharing.registry.models.SharingRegistryException;
-import org.dozer.Mapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public abstract class AbstractRepository<T, E, Id> {
-    private final static Logger logger = LoggerFactory.getLogger(AbstractRepository.class);
-
-    private Class<T> thriftGenericClass;
-    private Class<E> dbEntityGenericClass;
-
-    public AbstractRepository(Class<T> thriftGenericClass, Class<E> dbEntityGenericClass){
-        this.thriftGenericClass = thriftGenericClass;
-        this.dbEntityGenericClass = dbEntityGenericClass;
-    }
-
-    public T create(T t) throws SharingRegistryException {
-        return update(t);
-    }
-
-    //FIXME do a bulk insert
-    public List<T> create(List<T> tList) throws SharingRegistryException {
-        return update(tList);
-    }
-
-    public  T update(T t) throws SharingRegistryException {
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        E entity = mapper.map(t, dbEntityGenericClass);
-        E persistedCopy = execute(entityManager -> entityManager.merge(entity));
-        return mapper.map(persistedCopy, thriftGenericClass);
-    }
-
-    //FIXME do a bulk update
-    public  List<T> update(List<T> tList) throws SharingRegistryException {
-        List<T> returnList = new ArrayList<>();
-        for(T temp : tList)
-            returnList.add(update(temp));
-        return returnList;
-    }
-
-    public boolean delete(Id id) throws SharingRegistryException {
-        execute(entityManager -> {
-             E entity = entityManager.find(dbEntityGenericClass, id);
-             entityManager.remove(entity);
-             return entity;
-         });
-        return true;
-    }
-
-    public boolean delete(List<Id> idList) throws SharingRegistryException {
-        for(Id id : idList)
-            delete(id);
-        return true;
-    }
-
-    public T get(Id id) throws SharingRegistryException {
-        E entity = execute(entityManager -> entityManager
-                .find(dbEntityGenericClass, id));
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        if(entity == null)
-            return null;
-        return mapper.map(entity, thriftGenericClass);
-    }
-
-    public boolean isExists(Id id) throws SharingRegistryException {
-        return get(id) != null;
-    }
-
-    public List<T> get(List<Id> idList) throws SharingRegistryException {
-        List<T> returnList = new ArrayList<>();
-        for(Id id : idList)
-            returnList.add(get(id));
-        return returnList;
-    }
-
-    public List<T> select(Map<String, String> filters, int offset, int limit) throws SharingRegistryException {
-        String query = "SELECT DISTINCT p from " + dbEntityGenericClass.getSimpleName() + " as p";
-        ArrayList<String> parameters = new ArrayList<>();
-        int parameterCount = 1;
-        if (filters != null && filters.size() != 0) {
-            query += " WHERE ";
-            for (String k : filters.keySet()) {
-                query += "p." + k + " = ?" + parameterCount + " AND ";
-                parameters.add(filters.get(k));
-                parameterCount++;
-            }
-            query = query.substring(0, query.length() - 5);
-        }
-
-        query += " ORDER BY p.createdTime DESC";
-        String queryString = query;
-        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
-        List resultSet = execute(entityManager -> {
-            javax.persistence.Query q = entityManager.createQuery(queryString);
-            for (int i = 0; i < parameters.size(); i++) {
-                q.setParameter(i + 1, parameters.get(i));
-            }
-            return q.setFirstResult(offset).setMaxResults(newLimit).getResultList();
-        });
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        List<T> gatewayList = new ArrayList<>();
-        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
-        return gatewayList;
-    }
-
-    public List<T> select(String queryString, Map<String,Object> queryParameters, int offset, int limit) throws SharingRegistryException {
-        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
-        List resultSet = execute(entityManager -> {
-            Query q =  entityManager.createQuery(queryString);
-            for(Map.Entry<String, Object> queryParam : queryParameters.entrySet()){
-                q.setParameter(queryParam.getKey(), queryParam.getValue());
-            }
-            return q.setFirstResult(offset).setMaxResults(newLimit).getResultList();
-        });
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        List<T> gatewayList = new ArrayList<>();
-        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
-        return gatewayList;
-    }
-
-    public <R> R execute(Committer<EntityManager, R> committer) throws SharingRegistryException {
-        EntityManager entityManager = JPAUtils.getEntityManager();
-        try {
-            entityManager.getTransaction().begin();
-            R r = committer.commit(entityManager);
-            entityManager.getTransaction().commit();
-            return r;
-        } finally {
-            if (entityManager.isOpen()) {
-                if (entityManager.getTransaction().isActive()) {
-                    entityManager.getTransaction().rollback();
-                }
-                entityManager.close();
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/DomainRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/DomainRepository.java
deleted file mode 100644
index beb4be3..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/DomainRepository.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.entities.DomainEntity;
-import org.apache.custos.sharing.registry.models.Domain;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DomainRepository extends AbstractRepository<Domain, DomainEntity, String> {
-    private final static Logger logger = LoggerFactory.getLogger(DomainRepository.class);
-
-    public DomainRepository(){
-        super(Domain.class, DomainEntity.class);
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityRepository.java
deleted file mode 100644
index 8c16ab1..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityRepository.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.entities.EntityEntity;
-import org.apache.custos.sharing.registry.db.entities.EntityPK;
-import org.apache.custos.sharing.registry.db.utils.DBConstants;
-import org.apache.custos.sharing.registry.db.utils.SharingRegistryJDBCConfig;
-import org.apache.custos.sharing.registry.models.*;
-
-import java.util.*;
-
-public class EntityRepository extends AbstractRepository<Entity, EntityEntity, EntityPK> {
-
-    public EntityRepository() {
-        super(Entity.class, EntityEntity.class);
-    }
-
-    public List<Entity> getChildEntities(String domainId, String parentId) throws SharingRegistryException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.EntityTable.DOMAIN_ID, domainId);
-        filters.put(DBConstants.EntityTable.PARENT_ENTITY_ID, parentId);
-        return select(filters, 0, -1);
-    }
-
-    //TODO Replace with prepared statements
-    public List<Entity> searchEntities(String domainId, List<String> groupIds, List<SearchCriteria> filters,
-                                       int offset, int limit) throws SharingRegistryException {
-        String groupIdString = "'";
-        for(String groupId : groupIds)
-            groupIdString += groupId + "','";
-        groupIdString = groupIdString.substring(0, groupIdString.length()-2);
-
-        String query = "SELECT ENTITY.* FROM ENTITY WHERE ENTITY.ENTITY_ID IN (SELECT DISTINCT E.ENTITY_ID FROM ENTITY AS E INNER JOIN SHARING AS S ON (E.ENTITY_ID=S.ENTITY_ID AND E.DOMAIN_ID=S.DOMAIN_ID) WHERE " +
-                "E.DOMAIN_ID = '" + domainId + "' AND " + "S.GROUP_ID IN(" + groupIdString + ") AND ";
-
-        for(SearchCriteria searchCriteria : filters){
-            if(searchCriteria.getSearchField().equals(EntitySearchField.NAME)){
-                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
-                    query += "E.NAME != '" + searchCriteria.getValue() + "' AND ";
-                } else {
-                    query += "E.NAME LIKE '%" + searchCriteria.getValue() + "%' AND ";
-                }
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.DESCRIPTION)){
-                query += "E.DESCRIPTION LIKE '%" + searchCriteria.getValue() + "%' AND ";
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.PERMISSION_TYPE_ID)){
-                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
-                    query += "S.PERMISSION_TYPE_ID != '" + searchCriteria.getValue() + "' AND ";
-                } else {
-                    query += "S.PERMISSION_TYPE_ID IN ('" + searchCriteria.getValue() + "', '"
-                            + (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId) + "') AND ";
-                }
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.FULL_TEXT)){
-                if (new SharingRegistryJDBCConfig().getDriver().contains("derby")) {
-                    query += "E.FULL_TEXT LIKE '%" + searchCriteria.getValue() + "%' AND ";
-                } else {
-                    // FULL TEXT Search with Query Expansion
-                    String queryTerms = "";
-                    for (String word : searchCriteria.getValue().trim().replaceAll(" +", " ").split(" ")) {
-                        queryTerms += queryTerms + " +" + word;
-                    }
-                    queryTerms = queryTerms.trim();
-                    query += "MATCH(E.FULL_TEXT) AGAINST ('" + queryTerms + "' IN BOOLEAN MODE) AND ";
-                }
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.PARRENT_ENTITY_ID)){
-                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
-                    query += "E.PARENT_ENTITY_ID != '" + searchCriteria.getValue() + "' AND ";
-                } else {
-                    query += "E.PARENT_ENTITY_ID = '" + searchCriteria.getValue() + "' AND ";
-                }
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.OWNER_ID)){
-                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
-                    query += "E.OWNER_ID != '" + searchCriteria.getValue() + "' AND ";
-                } else {
-                    query += "E.OWNER_ID = '" + searchCriteria.getValue() + "' AND ";
-                }
-            } else if (searchCriteria.getSearchField().equals(EntitySearchField.ENTITY_TYPE_ID)) {
-                if (searchCriteria.getSearchCondition() != null && searchCriteria.getSearchCondition().equals(SearchCondition.NOT)) {
-                    query += "E.ENTITY_TYPE_ID != '" + searchCriteria.getValue() + "' AND ";
-                } else {
-                    query += "E.ENTITY_TYPE_ID = '" + searchCriteria.getValue() + "' AND ";
-                }
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.CREATED_TIME)){
-                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
-                    query += "E.CREATED_TIME >= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
-                }else{
-                    query += "E.CREATED_TIME <= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
-                }
-            }else if(searchCriteria.getSearchField().equals(EntitySearchField.UPDATED_TIME)){
-                if(searchCriteria.getSearchCondition().equals(SearchCondition.GTE)){
-                    query += "E.UPDATED_TIME >= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
-                }else{
-                    query += "E.UPDATED_TIME <= " + Long.parseLong(searchCriteria.getValue().trim()) + " AND ";
-                }
-            } else if (searchCriteria.getSearchField().equals(EntitySearchField.SHARED_COUNT)) {
-                if (searchCriteria.getSearchCondition().equals(SearchCondition.GTE)) {
-                    query += "E.SHARED_COUNT >= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
-                } else {
-                    query += "E.SHARED_COUNT <= " + Integer.parseInt(searchCriteria.getValue().trim()) + " AND ";
-                }
-            }
-        }
-
-        query = query.substring(0, query.length() - 5);
-        query += ") ORDER BY ENTITY.CREATED_TIME DESC";
-
-        final String nativeQuery = query;
-        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
-
-        List<Object[]> temp = execute(entityManager -> entityManager.createNativeQuery(nativeQuery).setFirstResult(offset)
-                .setMaxResults(newLimit).getResultList());
-        List<Entity> resultSet = new ArrayList<>();
-
-        HashMap<String, Object> keys = new HashMap<>();
-
-        temp.stream().forEach(rs->{
-            Entity entity = new Entity();
-            entity.setEntityId((String)(rs[0]));
-            entity.setDomainId((String) (rs[1]));
-            entity.setEntityTypeId((String) (rs[2]));
-            entity.setOwnerId((String) (rs[3]));
-            entity.setParentEntityId((String) (rs[4]));
-            entity.setName((String) (rs[5]));
-            entity.setDescription((String)(rs[6]));
-            entity.setBinaryData((byte[]) (rs[7]));
-            entity.setFullText((String) (rs[8]));
-            entity.setSharedCount((long) rs[9]);
-            entity.setOriginalEntityCreationTime((long) (rs[10]));
-            entity.setCreatedTime((long) (rs[11]));
-            entity.setUpdatedTime((long) (rs[12]));
-
-            //Removing duplicates. Another option is to change the query to remove duplicates.
-            if (!keys.containsKey(entity + domainId + "," + entity.getEntityId())) {
-                resultSet.add(entity);
-                keys.put(entity + domainId + "," + entity.getEntityId(), null);
-            }
-        });
-
-        return resultSet;
-    }
-
-    public String getSelectQuery(Map<String, String> filters){
-        String query = "SELECT p from " + EntityEntity.class.getSimpleName() + " as p";
-        if(filters != null && filters.size() != 0){
-            query += " WHERE ";
-            for(String k : filters.keySet()){
-                query += "p." + k + " = '" + filters.get(k) + "' AND ";
-            }
-            query = query.substring(0, query.length()-5);
-        }
-
-        query += " ORDER BY p."+DBConstants.EntityTable.ORIGINAL_ENTITY_CREATION_TIME+" DESC";
-
-        return query;
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityTypeRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityTypeRepository.java
deleted file mode 100644
index 8bbc083..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/EntityTypeRepository.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.entities.EntityTypeEntity;
-import org.apache.custos.sharing.registry.db.entities.EntityTypePK;
-import org.apache.custos.sharing.registry.models.EntityType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EntityTypeRepository extends AbstractRepository<EntityType, EntityTypeEntity, EntityTypePK> {
-    private final static Logger logger = LoggerFactory.getLogger(EntityTypeRepository.class);
-
-    public EntityTypeRepository() {
-        super(EntityType.class, EntityTypeEntity.class);
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupAdminRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupAdminRepository.java
deleted file mode 100644
index a7b94a2..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupAdminRepository.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.entities.GroupAdminEntity;
-import org.apache.custos.sharing.registry.db.entities.GroupAdminPK;
-import org.apache.custos.sharing.registry.models.GroupAdmin;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GroupAdminRepository extends AbstractRepository<GroupAdmin, GroupAdminEntity, GroupAdminPK> {
-
-    private final static Logger logger = LoggerFactory.getLogger(GroupAdminRepository.class);
-
-    public GroupAdminRepository() {
-        super(GroupAdmin.class, GroupAdminEntity.class);
-    }
-
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupMembershipRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupMembershipRepository.java
deleted file mode 100644
index a260400..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/GroupMembershipRepository.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.entities.GroupMembershipEntity;
-import org.apache.custos.sharing.registry.db.entities.GroupMembershipPK;
-import org.apache.custos.sharing.registry.db.entities.UserEntity;
-import org.apache.custos.sharing.registry.db.entities.UserGroupEntity;
-import org.apache.custos.sharing.registry.db.utils.DBConstants;
-import org.apache.custos.sharing.registry.models.*;
-
-import java.util.*;
-
-public class GroupMembershipRepository extends AbstractRepository<GroupMembership, GroupMembershipEntity, GroupMembershipPK> {
-
-    public GroupMembershipRepository() {
-        super(GroupMembership.class, GroupMembershipEntity.class);
-    }
-
-    public List<User> getAllChildUsers(String domainId, String groupId) throws SharingRegistryException {
-        String queryString = "SELECT DISTINCT U FROM " + UserEntity.class.getSimpleName() + " U, " + GroupMembershipEntity.class.getSimpleName()
-                + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = U." + DBConstants.UserTable.USER_ID + " AND " +
-                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = U." + DBConstants.UserTable.DOMAIN_ID + " AND " +
-                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + "=:" + DBConstants.GroupMembershipTable.DOMAIN_ID + " AND "+
-                "GM." + DBConstants.GroupMembershipTable.PARENT_ID + "=:" + DBConstants.GroupMembershipTable.PARENT_ID + " AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
-                + "=:" + DBConstants.GroupMembershipTable.CHILD_TYPE;
-        Map<String,Object> queryParameters = new HashMap<>();
-        queryParameters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
-        queryParameters.put(DBConstants.GroupMembershipTable.PARENT_ID, groupId);
-        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_TYPE, GroupChildType.USER.toString());
-        UserRepository userRepository = new UserRepository();
-        List<User> users = userRepository.select(queryString, queryParameters, 0, -1);
-        return users;
-    }
-
-    public List<UserGroup> getAllChildGroups(String domainId, String groupId) throws SharingRegistryException {
-        String queryString = "SELECT DISTINCT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName()
-                + " GM WHERE GM." + DBConstants.GroupMembershipTable.CHILD_ID + " = G." + DBConstants.UserGroupTable.GROUP_ID + " AND " +
-                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = G." + DBConstants.UserGroupTable.DOMAIN_ID + " AND " +
-                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID+"=:"+DBConstants.GroupMembershipTable.DOMAIN_ID + " AND "+
-                "GM." + DBConstants.GroupMembershipTable.PARENT_ID+"=:"+DBConstants.GroupMembershipTable.PARENT_ID + " AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
-                + "=:" + DBConstants.GroupMembershipTable.CHILD_TYPE;
-        Map<String,Object> queryParameters = new HashMap<>();
-        queryParameters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
-        queryParameters.put(DBConstants.GroupMembershipTable.PARENT_ID, groupId);
-        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_TYPE, GroupChildType.GROUP.toString());
-        UserGroupRepository userGroupRepository = new UserGroupRepository();
-        List<UserGroup> groups = userGroupRepository.select(queryString, queryParameters,0, -1);
-        return groups;
-    }
-
-    public List<UserGroup> getAllMemberGroupsForUser(String domainId, String userId) throws SharingRegistryException {
-        String queryString = "SELECT DISTINCT G FROM " + UserGroupEntity.class.getSimpleName() + " G, " + GroupMembershipEntity.class.getSimpleName()
-                + " GM WHERE GM." + DBConstants.GroupMembershipTable.PARENT_ID + " = G." + DBConstants.UserGroupTable.GROUP_ID + " AND " +
-                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID + " = G." + DBConstants.UserGroupTable.DOMAIN_ID + " AND " +
-                "GM." + DBConstants.GroupMembershipTable.DOMAIN_ID+"=:"+DBConstants.GroupMembershipTable.DOMAIN_ID + " AND "+
-                "GM." + DBConstants.GroupMembershipTable.CHILD_ID+"=:"+DBConstants.GroupMembershipTable.CHILD_ID + " AND GM." + DBConstants.GroupMembershipTable.CHILD_TYPE
-                + "=:" + DBConstants.GroupMembershipTable.CHILD_TYPE + " AND " +
-                "G." + DBConstants.UserGroupTable.GROUP_CARDINALITY + "=:" + DBConstants.UserGroupTable.GROUP_CARDINALITY;
-        Map<String,Object> queryParameters = new HashMap<>();
-        queryParameters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
-        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_ID, userId);
-        queryParameters.put(DBConstants.GroupMembershipTable.CHILD_TYPE, GroupChildType.USER.toString());
-        queryParameters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.name());
-        UserGroupRepository userGroupRepository = new UserGroupRepository();
-        List<UserGroup> groups = userGroupRepository.select(queryString, queryParameters, 0, -1);
-        return groups;
-    }
-
-    public List<GroupMembership> getAllParentMembershipsForChild(String domainId, String childId) throws SharingRegistryException {
-        List<GroupMembership> finalParentGroups = new ArrayList<>();
-        Map<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.GroupMembershipTable.CHILD_ID, childId);
-        filters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
-        LinkedList<GroupMembership> temp = new LinkedList<>();
-        select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
-        while (temp.size() > 0){
-            GroupMembership gm = temp.pop();
-            filters = new HashMap<>();
-            filters.put(DBConstants.GroupMembershipTable.CHILD_ID, gm.getParentId());
-            filters.put(DBConstants.GroupMembershipTable.DOMAIN_ID, domainId);
-            select(filters, 0, -1).stream().forEach(m -> temp.addLast(m));
-            finalParentGroups.add(gm);
-        }
-        return finalParentGroups;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/PermissionTypeRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/PermissionTypeRepository.java
deleted file mode 100644
index c3c4a67..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/PermissionTypeRepository.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.entities.PermissionTypeEntity;
-import org.apache.custos.sharing.registry.db.entities.PermissionTypePK;
-import org.apache.custos.sharing.registry.db.utils.DBConstants;
-import org.apache.custos.sharing.registry.models.PermissionType;
-import org.apache.custos.sharing.registry.models.SharingRegistryException;
-import org.apache.custos.sharing.registry.server.SharingRegistryServerHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.List;
-
-public class PermissionTypeRepository extends AbstractRepository<PermissionType, PermissionTypeEntity, PermissionTypePK> {
-    private final static Logger logger = LoggerFactory.getLogger(PermissionTypeRepository.class);
-
-    public PermissionTypeRepository() {
-        super(PermissionType.class, PermissionTypeEntity.class);
-    }
-
-    public String getOwnerPermissionTypeIdForDomain(String domainId) throws SharingRegistryException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domainId);
-        filters.put(DBConstants.PermissionTypeTable.NAME, SharingRegistryServerHandler.OWNER_PERMISSION_NAME);
-        List<PermissionType> permissionTypeList = select(filters, 0, -1);
-        if(permissionTypeList.size() != 1){
-            throw new SharingRegistryException("GLOBAL Permission inconsistency. Found " + permissionTypeList.size()
-                    + " records with " + SharingRegistryServerHandler.OWNER_PERMISSION_NAME + " name");
-        }
-        return permissionTypeList.get(0).getPermissionTypeId();
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/SharingRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/SharingRepository.java
deleted file mode 100644
index 29ee9a9..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/SharingRepository.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.entities.SharingEntity;
-import org.apache.custos.sharing.registry.db.entities.SharingPK;
-import org.apache.custos.sharing.registry.db.utils.DBConstants;
-import org.apache.custos.sharing.registry.models.Sharing;
-import org.apache.custos.sharing.registry.models.SharingRegistryException;
-import org.apache.custos.sharing.registry.models.SharingType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.Query;
-
-public class SharingRepository extends AbstractRepository<Sharing, SharingEntity, SharingPK> {
-    private final static Logger logger = LoggerFactory.getLogger(SharingRepository.class);
-
-    public SharingRepository() {
-        super(Sharing.class, SharingEntity.class);
-    }
-
-    public List<Sharing> getIndirectSharedChildren(String domainId, String parentId, String permissionTypeId) throws SharingRegistryException {
-        HashMap<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
-        filters.put(DBConstants.SharingTable.INHERITED_PARENT_ID, parentId);
-        filters.put(DBConstants.SharingTable.SHARING_TYPE, SharingType.INDIRECT_CASCADING.toString());
-        filters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
-
-        return select(filters, 0, -1);
-    }
-
-    public List<Sharing> getCascadingPermissionsForEntity(String domainId, String entityId) throws SharingRegistryException {
-        String query = "SELECT DISTINCT p from " + SharingEntity.class.getSimpleName() + " as p";
-        query += " WHERE ";
-        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
-        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
-        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " IN('" + SharingType.DIRECT_CASCADING.toString()
-                + "', '" + SharingType.INDIRECT_CASCADING + "') ";
-        query += " ORDER BY p.createdTime DESC";
-        Map<String,Object> queryParameters = new HashMap<>();
-        queryParameters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
-        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
-        return select(query, queryParameters, 0, -1);
-    }
-
-    public boolean hasAccess(String domainId, String entityId, List<String> groupIds, List<String> permissionTypeIds) throws SharingRegistryException {
-        Map<String,Object> queryParameters = new HashMap<>();
-        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
-        query += " WHERE ";
-        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
-        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
-        queryParameters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
-        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
-        query += "p." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " IN :" + DBConstants.SharingTable.PERMISSION_TYPE_ID + " AND ";
-        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeIds);
-        query += "p." + DBConstants.SharingTable.GROUP_ID + " IN :" + DBConstants.SharingTable.GROUP_ID + " ";
-        queryParameters.put(DBConstants.SharingTable.GROUP_ID, groupIds);
-        query += " ORDER BY p.createdTime DESC";
-        return select(query, queryParameters, 0, -1).size() > 0;
-    }
-
-    public int getSharedCount(String domainId, String entityId) throws SharingRegistryException {
-        Map<String,Object> queryParameters = new HashMap<>();
-        String query = "SELECT p from " + SharingEntity.class.getSimpleName() + " as p";
-        query += " WHERE ";
-        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
-        queryParameters.put(DBConstants.SharingTable.DOMAIN_ID, domainId);
-        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
-        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
-        String permissionTypeIdString = (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId);
-        query += "p." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " <> :" + DBConstants.SharingTable.PERMISSION_TYPE_ID + " AND ";
-        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeIdString);
-        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " <> :" + DBConstants.SharingTable.SHARING_TYPE;
-        queryParameters.put(DBConstants.SharingTable.SHARING_TYPE, SharingType.INDIRECT_CASCADING.toString());
-        return select(query, queryParameters, 0, -1).size();
-    }
-
-    public void removeAllIndirectCascadingPermissionsForEntity(String domainId, String entityId) throws SharingRegistryException {
-        String query = "DELETE from " + SharingEntity.class.getSimpleName() + " as p";
-        query += " WHERE ";
-        query += "p." + DBConstants.SharingTable.DOMAIN_ID + " = :" + DBConstants.SharingTable.DOMAIN_ID + " AND ";
-        query += "p." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
-        query += "p." + DBConstants.SharingTable.SHARING_TYPE + " = '" + SharingType.INDIRECT_CASCADING.toString() + "' ";
-        final String finalQuery = query;
-        execute(em -> {
-            Query q = em.createQuery(finalQuery);
-            q.setParameter(DBConstants.SharingTable.DOMAIN_ID, domainId);
-            q.setParameter(DBConstants.SharingTable.ENTITY_ID, entityId);
-            q.executeUpdate();
-            return true;
-        });
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserGroupRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserGroupRepository.java
deleted file mode 100644
index 9cac79c..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserGroupRepository.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.entities.SharingEntity;
-import org.apache.custos.sharing.registry.db.entities.UserGroupEntity;
-import org.apache.custos.sharing.registry.db.entities.UserGroupPK;
-import org.apache.custos.sharing.registry.db.utils.DBConstants;
-import org.apache.custos.sharing.registry.models.GroupCardinality;
-import org.apache.custos.sharing.registry.models.SharingRegistryException;
-import org.apache.custos.sharing.registry.models.SharingType;
-import org.apache.custos.sharing.registry.models.UserGroup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-public class UserGroupRepository extends AbstractRepository<UserGroup, UserGroupEntity, UserGroupPK> {
-    private final static Logger logger = LoggerFactory.getLogger(UserGroupRepository.class);
-
-    public UserGroupRepository() {
-        super(UserGroup.class, UserGroupEntity.class);
-    }
-
-    public List<UserGroup> getAccessibleGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
-        return getAccessibleGroupsInternal(domainId, entityId, permissionTypeId);
-    }
-
-    public List<UserGroup> getDirectlyAccessibleGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
-        return getAccessibleGroupsInternal(domainId, entityId, permissionTypeId, SharingType.DIRECT_CASCADING, SharingType.DIRECT_NON_CASCADING);
-    }
-
-    private List<UserGroup> getAccessibleGroupsInternal(String domainId, String entityId, String permissionTypeId, SharingType... sharingTypes) throws SharingRegistryException {
-        String query = "SELECT DISTINCT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
-        query += " WHERE ";
-        query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
-        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
-        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = :" + DBConstants.UserGroupTable.DOMAIN_ID + " AND ";
-        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
-        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = :" + DBConstants.SharingTable.PERMISSION_TYPE_ID + " AND ";
-        query += "g." + DBConstants.UserGroupTable.GROUP_CARDINALITY + " = :" + DBConstants.UserGroupTable.GROUP_CARDINALITY;
-        if (!Arrays.asList(sharingTypes).isEmpty()) {
-            query += " AND s." + DBConstants.SharingTable.SHARING_TYPE + " IN :" + DBConstants.SharingTable.SHARING_TYPE;
-        }
-        query += " ORDER BY s.createdTime DESC";
-        Map<String,Object> queryParameters = new HashMap<>();
-        queryParameters.put(DBConstants.UserGroupTable.DOMAIN_ID, domainId);
-        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
-        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
-        queryParameters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.toString());
-        if (!Arrays.asList(sharingTypes).isEmpty()) {
-            queryParameters.put(DBConstants.SharingTable.SHARING_TYPE, Arrays.asList(sharingTypes).stream().map(s -> s.name()).collect(Collectors.toList()));
-        }
-        return select(query, queryParameters, 0, -1);
-    }
-
-    //checks whether is shared with any user or group with any permission
-    public boolean isShared(String domainId, String entityId) throws SharingRegistryException {
-        String query = "SELECT DISTINCT g from " + UserGroupEntity.class.getSimpleName() + " g, " + SharingEntity.class.getSimpleName() + " s";
-        query += " WHERE ";
-        query += "g." + DBConstants.UserGroupTable.GROUP_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
-        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
-        query += "g." + DBConstants.UserGroupTable.DOMAIN_ID + " = :" + DBConstants.UserGroupTable.DOMAIN_ID + " AND ";
-        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
-        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " <> :" + DBConstants.SharingTable.PERMISSION_TYPE_ID;
-        query += " ORDER BY s.createdTime DESC";
-        Map<String,Object> queryParameters = new HashMap<>();
-        queryParameters.put(DBConstants.UserGroupTable.DOMAIN_ID, domainId);
-        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
-        String ownerPermissionTypeIdForDomain = (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId);
-        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, ownerPermissionTypeIdForDomain);
-        return select(query, queryParameters, 0, -1).size() != 0;
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserRepository.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserRepository.java
deleted file mode 100644
index 4d28229..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/repositories/UserRepository.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.repositories;
-
-import org.apache.custos.sharing.registry.db.entities.SharingEntity;
-import org.apache.custos.sharing.registry.db.entities.UserEntity;
-import org.apache.custos.sharing.registry.db.entities.UserPK;
-import org.apache.custos.sharing.registry.db.utils.DBConstants;
-import org.apache.custos.sharing.registry.models.SharingRegistryException;
-import org.apache.custos.sharing.registry.models.SharingType;
-import org.apache.custos.sharing.registry.models.User;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-public class UserRepository extends AbstractRepository<User, UserEntity, UserPK> {
-    private final static Logger logger = LoggerFactory.getLogger(UserRepository.class);
-
-    public UserRepository() {
-        super(User.class, UserEntity.class);
-    }
-
-
-    public List<User> getAccessibleUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
-        if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
-            return getAccessibleUsersInternal(domainId, entityId, permissionTypeId, SharingType.DIRECT_CASCADING, SharingType.DIRECT_NON_CASCADING);
-        } else {
-            return getAccessibleUsersInternal(domainId, entityId, permissionTypeId);
-        }
-    }
-
-    public List<User> getDirectlyAccessibleUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException {
-        return getAccessibleUsersInternal(domainId, entityId, permissionTypeId, SharingType.DIRECT_CASCADING, SharingType.DIRECT_NON_CASCADING);
-    }
-
-    private List<User> getAccessibleUsersInternal(String domainId, String entityId, String permissionTypeId, SharingType... sharingTypes) throws SharingRegistryException {
-        Map<String,Object> queryParameters = new HashMap<>();
-        String query = "SELECT DISTINCT u from " + UserEntity.class.getSimpleName() + " u, " + SharingEntity.class.getSimpleName() + " s";
-        query += " WHERE ";
-        query += "u." + DBConstants.UserTable.USER_ID + " = s." + DBConstants.SharingTable.GROUP_ID + " AND ";
-        query += "u." + DBConstants.UserTable.DOMAIN_ID + " = s." + DBConstants.SharingTable.DOMAIN_ID + " AND ";
-        query += "u." + DBConstants.UserTable.DOMAIN_ID + " = :" + DBConstants.UserTable.DOMAIN_ID + " AND ";
-        query += "s." + DBConstants.SharingTable.ENTITY_ID + " = :" + DBConstants.SharingTable.ENTITY_ID + " AND ";
-        query += "s." + DBConstants.SharingTable.PERMISSION_TYPE_ID + " = :" + DBConstants.SharingTable.PERMISSION_TYPE_ID;
-        queryParameters.put(DBConstants.UserTable.DOMAIN_ID, domainId);
-        queryParameters.put(DBConstants.SharingTable.ENTITY_ID, entityId);
-        queryParameters.put(DBConstants.SharingTable.PERMISSION_TYPE_ID, permissionTypeId);
-
-        if (!Arrays.asList(sharingTypes).isEmpty()) {
-            query += " AND s." + DBConstants.SharingTable.SHARING_TYPE + " IN :" + DBConstants.SharingTable.SHARING_TYPE;
-            queryParameters.put(DBConstants.SharingTable.SHARING_TYPE, Arrays.asList(sharingTypes).stream().map(s -> s.name()).collect(Collectors.toList()));
-        }
-
-        query += " ORDER BY s.createdTime DESC";
-        return select(query, queryParameters,0, -1);
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/DBConstants.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/DBConstants.java
deleted file mode 100644
index 5f8f549..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/DBConstants.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DBConstants {
-    private final static Logger logger = LoggerFactory.getLogger(DBConstants.class);
-
-    public static int SELECT_MAX_ROWS = 1000;
-
-    public static class DomainTable {
-        public static final String DOMAIN_ID = "domainId";
-        public static final String NAME = "name";
-        public static final String DESCRIPTION = "description";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class UserTable {
-        public static final String USER_ID = "userId";
-        public static final String DOMAIN_ID = "domainId";
-        public static final String USER_NAME = "userName";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class UserGroupTable {
-        public static final String GROUP_ID = "groupId";
-        public static final String DOMAIN_ID = "domainId";
-        public static final String NAME = "name";
-        public static final String DESCRIPTION = "description";
-        public static final String OWNER_ID = "ownerId";
-        public static final String GROUP_TYPE = "groupType";
-        public static final String GROUP_CARDINALITY = "groupCardinality";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class GroupMembershipTable {
-        public static final String PARENT_ID = "parentId";
-        public static final String CHILD_ID = "childId";
-        public static final String CHILD_TYPE = "childType";
-        public static final String DOMAIN_ID = "domainId";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class EntityTypeTable {
-        public static final String ENTITY_TYPE_ID = "entityTypeId";
-        public static final String DOMAIN_ID = "domainId";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class PermissionTypeTable {
-        public static final String ENTITY_TYPE_ID = "permissionTypeId";
-        public static final String DOMAIN_ID = "domainId";
-        public static final String NAME = "name";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-
-    public static class EntityTable {
-        public static final String ENTITY_ID = "entityId";
-        public static final String PARENT_ENTITY_ID = "parentEntityId";
-        public static final String ENTITY_TYPE_ID = "entityTypeId";
-        public static final String NAME = "name";
-        public static final String DESCRIPTION = "description";
-        public static final String FULL_TEXT = "fullText";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-        public static final String DOMAIN_ID = "domainId";
-        public static final String ORIGINAL_ENTITY_CREATION_TIME = "originalEntityCreationTime";
-        public static final String SHARED = "shared";
-    }
-
-    public static class SharingTable {
-        public static final String DOMAIN_ID = "domainId";
-        public static final String PERMISSION_TYPE_ID = "permissionTypeId";
-        public static final String ENTITY_ID = "entityId";
-        public static final String GROUP_ID = "groupId";
-        public static final String INHERITED_PARENT_ID = "inheritedParentId";
-        public static final String SHARING_TYPE = "sharingType";
-        public static final String CREATED_TIME = "createdTime";
-        public static final String UPDATED_TIME = "updatedTime";
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/JPAUtils.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/JPAUtils.java
deleted file mode 100644
index f562c15..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/JPAUtils.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.utils;
-
-import org.apache.custos.commons.utils.JDBCConfig;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-public class JPAUtils {
-    public static final String PERSISTENCE_UNIT_NAME = "airavata-sharing-registry";
-    private static final JDBCConfig JDBC_CONFIG = new SharingRegistryJDBCConfig();
-    private static final EntityManagerFactory factory = org.apache.custos.commons.utils.JPAUtils.getEntityManagerFactory(PERSISTENCE_UNIT_NAME, JDBC_CONFIG);
-
-    public static EntityManager getEntityManager() {
-        return factory.createEntityManager();
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/ObjectMapperSingleton.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/ObjectMapperSingleton.java
deleted file mode 100644
index 935e949..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/ObjectMapperSingleton.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.db.utils;
-
-import org.dozer.DozerBeanMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ObjectMapperSingleton extends DozerBeanMapper{
-    private final static Logger logger = LoggerFactory.getLogger(ObjectMapperSingleton.class);
-
-    private static ObjectMapperSingleton instance;
-
-    private ObjectMapperSingleton(){}
-
-    public static ObjectMapperSingleton getInstance(){
-        if(instance == null)
-            instance = new ObjectMapperSingleton();
-        return instance;
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryDBInitConfig.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryDBInitConfig.java
deleted file mode 100644
index f95246a..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryDBInitConfig.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.custos.sharing.registry.db.utils;
-
-
-import org.apache.custos.commons.utils.DBInitConfig;
-import org.apache.custos.commons.utils.JDBCConfig;
-
-public class SharingRegistryDBInitConfig implements DBInitConfig {
-    private String dbInitScriptPrefix = "database_scripts/sharing-registry";
-
-    @Override
-    public JDBCConfig getJDBCConfig() {
-        return new SharingRegistryJDBCConfig();
-    }
-
-    @Override
-    public String getDBInitScriptPrefix() {
-        return this.dbInitScriptPrefix;
-    }
-
-    @Override
-    public String getCheckTableName() {
-        return "CONFIGURATION";
-    }
-
-    public void setDBInitScriptPrefix(String dbInitScriptPrefix) {
-        this.dbInitScriptPrefix = dbInitScriptPrefix;
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryJDBCConfig.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryJDBCConfig.java
deleted file mode 100644
index 747d93f..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/db/utils/SharingRegistryJDBCConfig.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.custos.sharing.registry.db.utils;
-
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.commons.utils.JDBCConfig;
-import org.apache.custos.commons.utils.ServerSettings;
-
-public class SharingRegistryJDBCConfig implements JDBCConfig {
-
-    private static final String SHARING_REG_JDBC_DRIVER = "sharingcatalog.jdbc.driver";
-    private static final String SHARING_REG_JDBC_URL = "sharingcatalog.jdbc.url";
-    private static final String SHARING_REG_JDBC_USER = "sharingcatalog.jdbc.user";
-    private static final String SHARING_REG_JDBC_PWD = "sharingcatalog.jdbc.password";
-    private static final String SHARING_REG_VALIDATION_QUERY = "sharingcatalog.validationQuery";
-
-    @Override
-    public String getURL() {
-        return readServerProperties(SHARING_REG_JDBC_URL);
-    }
-
-    @Override
-    public String getDriver() {
-        return readServerProperties(SHARING_REG_JDBC_DRIVER);
-    }
-
-    @Override
-    public String getUser() {
-        return readServerProperties(SHARING_REG_JDBC_USER);
-    }
-
-    @Override
-    public String getPassword() {
-        return readServerProperties(SHARING_REG_JDBC_PWD);
-    }
-
-    @Override
-    public String getValidationQuery() {
-        return readServerProperties(SHARING_REG_VALIDATION_QUERY);
-    }
-
-    private String readServerProperties(String propertyName) {
-        try {
-            return ServerSettings.getSetting(propertyName);
-        } catch (ApplicationSettingsException e) {
-            throw new RuntimeException("Unable to read server.properties...", e);
-        }
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/ServerMain.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/ServerMain.java
deleted file mode 100644
index 0128361..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/ServerMain.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.server;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-public class ServerMain {
-    private final static Logger logger = LoggerFactory.getLogger(ServerMain.class);
-
-    private static int serverPID = -1;
-    private static final String stopFileNamePrefix = "server_stop";
-    private static final String serverStartedFileNamePrefix = "server_start";
-
-    public static void main(String[] args) {
-        try {
-            setServerStarted();
-            new SharingRegistryServer().start();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-        }
-    }
-
-    @SuppressWarnings({"resource"})
-    private static void setServerStarted() {
-        try {
-            serverPID = getPID();
-            deleteOldStopRequests();
-            File serverStartedFile = null;
-            serverStartedFile = new File(getServerStartedFileName());
-            serverStartedFile.createNewFile();
-            serverStartedFile.deleteOnExit();
-            new RandomAccessFile(serverStartedFile, "rw").getChannel().lock();
-        } catch (FileNotFoundException e) {
-            logger.warn(e.getMessage(), e);
-        } catch (IOException e) {
-            logger.warn(e.getMessage(), e);
-        }
-    }
-
-    private static String getServerStartedFileName() {
-        String SHARING_REGISTRY_HOME = System.getenv("" +"SHARING_REGISTRY_HOME");
-        if(SHARING_REGISTRY_HOME==null)
-            SHARING_REGISTRY_HOME = "/tmp";
-        else
-            SHARING_REGISTRY_HOME = SHARING_REGISTRY_HOME + "/bin";
-        return new File(SHARING_REGISTRY_HOME, serverStartedFileNamePrefix + "_" + Integer.toString(serverPID)).toString();
-    }
-
-    private static int getPID() {
-        try {
-            java.lang.management.RuntimeMXBean runtime = java.lang.management.ManagementFactory
-                    .getRuntimeMXBean();
-            java.lang.reflect.Field jvm = runtime.getClass()
-                    .getDeclaredField("jvm");
-            jvm.setAccessible(true);
-            sun.management.VMManagement mgmt = (sun.management.VMManagement) jvm
-                    .get(runtime);
-            java.lang.reflect.Method pid_method = mgmt.getClass()
-                    .getDeclaredMethod("getProcessId");
-            pid_method.setAccessible(true);
-
-            int pid = (Integer) pid_method.invoke(mgmt);
-            return pid;
-        } catch (Exception e) {
-            return -1;
-        }
-    }
-
-    private static void deleteOldStopRequests() {
-        File[] files = new File(".").listFiles();
-        for (File file : files) {
-            if (file.getName().contains(stopFileNamePrefix)) {
-                file.delete();
-            }
-
-        }
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServer.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServer.java
deleted file mode 100644
index 78fbb51..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServer.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.server;
-
-import org.apache.custos.commons.exceptions.CustosException;
-import org.apache.custos.commons.utils.IServer;
-import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.sharing.registry.db.utils.SharingRegistryDBInitConfig;
-import org.apache.custos.sharing.registry.models.SharingRegistryException;
-import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
-import org.apache.thrift.server.TServer;
-import org.apache.thrift.server.TThreadPoolServer;
-import org.apache.thrift.transport.TSSLTransportFactory;
-import org.apache.thrift.transport.TServerSocket;
-import org.apache.thrift.transport.TServerTransport;
-import org.apache.thrift.transport.TTransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-
-public class SharingRegistryServer implements IServer {
-    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServer.class);
-
-    public static final String SHARING_REG_SERVER_HOST = "sharing.registry.server.host";
-    public static final String SHARING_REG_SERVER_PORT = "sharing.registry.server.port";
-
-    private static final String SERVER_NAME = "Sharing Registry Server";
-    private static final String SERVER_VERSION = "1.0";
-
-    private IServer.ServerStatus status;
-    private TServer server;
-    private boolean testMode = false;
-
-    public SharingRegistryServer() {
-        setStatus(IServer.ServerStatus.STOPPED);
-    }
-
-    @Override
-    public String getName() {
-        return SERVER_NAME;
-    }
-
-    @Override
-    public String getVersion() {
-        return SERVER_VERSION;
-    }
-
-    @Override
-    public void start() throws Exception {
-        try {
-            setStatus(IServer.ServerStatus.STARTING);
-
-            final int serverPort = Integer.parseInt(ServerSettings.getSetting(SHARING_REG_SERVER_PORT));
-            final String serverHost = ServerSettings.getSetting(SHARING_REG_SERVER_HOST);
-            SharingRegistryService.Processor processor = new SharingRegistryService.Processor(
-                    new SharingRegistryServerHandler(createSharingRegistryDBInitConfig()));
-
-            TServerTransport serverTransport;
-
-            if (!ServerSettings.isSharingTLSEnabled()) {
-                InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
-                serverTransport = new TServerSocket(inetSocketAddress);
-                TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
-                options.minWorkerThreads = 30;
-                server = new TThreadPoolServer(options.processor(processor));
-            }else{
-                TSSLTransportFactory.TSSLTransportParameters TLSParams =
-                        new TSSLTransportFactory.TSSLTransportParameters();
-                TLSParams.requireClientAuth(true);
-                TLSParams.setKeyStore(ServerSettings.getKeyStorePath(), ServerSettings.getKeyStorePassword());
-                TLSParams.setTrustStore(ServerSettings.getTrustStorePath(), ServerSettings.getTrustStorePassword());
-                TServerSocket TLSServerTransport = TSSLTransportFactory.getServerSocket(
-                        serverPort, ServerSettings.getTLSClientTimeout(),
-                        InetAddress.getByName(serverHost), TLSParams);
-                TThreadPoolServer.Args options = new TThreadPoolServer.Args(TLSServerTransport);
-                options.minWorkerThreads = 30;
-                server = new TThreadPoolServer(options.processor(processor));
-            }
-
-            new Thread() {
-                public void run() {
-                    server.serve();
-                    setStatus(IServer.ServerStatus.STOPPED);
-                    logger.info("Sharing Registry Server Stopped.");
-                }
-            }.start();
-            new Thread() {
-                public void run() {
-                    while (!server.isServing()) {
-                        try {
-                            Thread.sleep(500);
-                        } catch (InterruptedException e) {
-                            break;
-                        }
-                    }
-                    if (server.isServing()) {
-//                        try {
-//                            logger.info("Register sharing service with DB Event publishers");
-//                            //SharingServiceDBEventMessagingFactory.registerSharingServiceWithPublishers(Constants.PUBLISHERS);
-//
-//                            logger.info("Start sharing service DB Event subscriber");
-//                            //SharingServiceDBEventMessagingFactory.getDBEventSubscriber();
-//                        } catch (CustosException | SharingRegistryException e) {
-//                            logger.error("Error starting sharing service. Error setting up DB event services.");
-//                            server.stop();
-//                        }
-                        setStatus(IServer.ServerStatus.STARTED);
-                        logger.info("Starting Sharing Registry Server on Port " + serverPort);
-                        logger.info("Listening to Sharing Registry server clients ....");
-                    }
-                }
-            }.start();
-
-        } catch (TTransportException e) {
-            setStatus(IServer.ServerStatus.FAILED);
-            throw new Exception("Error while starting the Sharing Registry service", e);
-        }
-    }
-
-    @Override
-    public void stop() throws Exception {
-        if (server!=null && server.isServing()){
-            setStatus(IServer.ServerStatus.STOPING);
-            server.stop();
-        }
-    }
-
-    @Override
-    public void restart() throws Exception {
-        stop();
-        start();
-    }
-
-    @Override
-    public void configure() throws Exception {
-
-    }
-
-    @Override
-    public IServer.ServerStatus getStatus() throws Exception {
-        return status;
-    }
-
-    private void setStatus(IServer.ServerStatus stat){
-        status=stat;
-        status.updateTime();
-    }
-
-    public TServer getServer() {
-        return server;
-    }
-
-    public void setServer(TServer server) {
-        this.server = server;
-    }
-
-    public boolean isTestMode() {
-        return testMode;
-    }
-
-    public void setTestMode(boolean testMode) {
-        this.testMode = testMode;
-    }
-
-    private SharingRegistryDBInitConfig createSharingRegistryDBInitConfig() {
-        SharingRegistryDBInitConfig sharingRegistryDBInitConfig = new SharingRegistryDBInitConfig();
-        if (this.testMode) {
-            sharingRegistryDBInitConfig.setDBInitScriptPrefix("sharing-registry");
-        }
-        return sharingRegistryDBInitConfig;
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServerHandler.java b/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServerHandler.java
deleted file mode 100644
index fa9fa3b..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/java/org/apache/custos/sharing/registry/server/SharingRegistryServerHandler.java
+++ /dev/null
@@ -1,1273 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.server;
-
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.commons.utils.DBInitializer;
-import org.apache.custos.sharing.registry.db.entities.*;
-import org.apache.custos.sharing.registry.db.repositories.*;
-import org.apache.custos.sharing.registry.db.utils.DBConstants;
-import org.apache.custos.sharing.registry.db.utils.SharingRegistryDBInitConfig;
-import org.apache.custos.sharing.registry.models.*;
-import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
-import org.apache.custos.sharing.registry.service.cpi.sharing_cpiConstants;
-import org.apache.thrift.TException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.*;
-
-public class SharingRegistryServerHandler implements SharingRegistryService.Iface{
-    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServerHandler.class);
-
-    public static String OWNER_PERMISSION_NAME = "OWNER";
-
-    public SharingRegistryServerHandler(SharingRegistryDBInitConfig sharingRegistryDBInitConfig)  throws ApplicationSettingsException, TException {
-        DBInitializer.initializeDB(sharingRegistryDBInitConfig);
-    }
-
-    @Override
-    public String getAPIVersion() throws TException {
-        return sharing_cpiConstants.SHARING_CPI_VERSION;
-    }
-
-    /**
-     * * Domain Operations
-     * *
-     */
-    @Override
-    public String createDomain(Domain domain) throws SharingRegistryException, DuplicateEntryException, TException {
-        try{
-            domain.setDomainId(domain.getName());
-            if((new DomainRepository()).get(domain.getDomainId()) != null)
-                throw new DuplicateEntryException("There exist domain with given domain id");
-
-            domain.setCreatedTime(System.currentTimeMillis());
-            domain.setUpdatedTime(System.currentTimeMillis());
-            (new DomainRepository()).create(domain);
-
-            //create the global permission for the domain
-            PermissionType permissionType = new PermissionType();
-            permissionType.setPermissionTypeId(domain.getDomainId() + ":" + OWNER_PERMISSION_NAME);
-            permissionType.setDomainId(domain.getDomainId());
-            permissionType.setName(OWNER_PERMISSION_NAME);
-            permissionType.setDescription("GLOBAL permission to " + domain.getDomainId());
-            permissionType.setCreatedTime(System.currentTimeMillis());
-            permissionType.setUpdatedTime(System.currentTimeMillis());
-            (new PermissionTypeRepository()).create(permissionType);
-
-            return domain.getDomainId();
-        }catch (Throwable ex){
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean updateDomain(Domain domain) throws SharingRegistryException, TException {
-        try{
-            Domain oldDomain = (new DomainRepository()).get(domain.getDomainId());
-            domain.setCreatedTime(oldDomain.getCreatedTime());
-            domain.setUpdatedTime(System.currentTimeMillis());
-            domain = getUpdatedObject(oldDomain, domain);
-            (new DomainRepository()).update(domain);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * <p>API method to check Domain Exists</p>
-     *
-     * @param domainId
-     */
-    @Override
-    public boolean isDomainExists(String domainId) throws SharingRegistryException, TException {
-        try{
-            return (new DomainRepository()).isExists(domainId);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean deleteDomain(String domainId) throws SharingRegistryException, TException {
-        try{
-            (new DomainRepository()).delete(domainId);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public Domain getDomain(String domainId) throws SharingRegistryException, TException {
-        try{
-            return (new DomainRepository()).get(domainId);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<Domain> getDomains(int offset, int limit) throws TException {
-        try{
-            return (new DomainRepository()).select(new HashMap<>(), offset, limit);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * * User Operations
-     * *
-     */
-    @Override
-    public String createUser(User user) throws SharingRegistryException, DuplicateEntryException, TException {
-        try{
-            UserPK userPK = new UserPK();
-            userPK.setUserId(user.getUserId());
-            userPK.setDomainId(user.getDomainId());
-            if((new UserRepository()).get(userPK) != null)
-                throw new DuplicateEntryException("There exist user with given user id");
-
-            user.setCreatedTime(System.currentTimeMillis());
-            user.setUpdatedTime(System.currentTimeMillis());
-            (new UserRepository()).create(user);
-
-            UserGroup userGroup = new UserGroup();
-            userGroup.setGroupId(user.getUserId());
-            userGroup.setDomainId(user.getDomainId());
-            userGroup.setName(user.getUserName());
-            userGroup.setDescription("user " + user.getUserName() + " group");
-            userGroup.setOwnerId(user.getUserId());
-            userGroup.setGroupType(GroupType.USER_LEVEL_GROUP);
-            userGroup.setGroupCardinality(GroupCardinality.SINGLE_USER);
-            (new UserGroupRepository()).create(userGroup);
-
-            return user.getUserId();
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean updatedUser(User user) throws SharingRegistryException, TException {
-        try{
-            UserPK userPK = new UserPK();
-            userPK.setUserId(user.getUserId());
-            userPK.setDomainId(user.getDomainId());
-            User oldUser = (new UserRepository()).get(userPK);
-            user.setCreatedTime(oldUser.getCreatedTime());
-            user.setUpdatedTime(System.currentTimeMillis());
-            user = getUpdatedObject(oldUser, user);
-            (new UserRepository()).update(user);
-
-            UserGroupPK userGroupPK = new UserGroupPK();
-            userGroupPK.setGroupId(user.getUserId());
-            userGroupPK.setDomainId(user.getDomainId());
-            UserGroup userGroup = (new UserGroupRepository()).get(userGroupPK);
-            userGroup.setName(user.getUserName());
-            userGroup.setDescription("user " + user.getUserName() + " group");
-            updateGroup(userGroup);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * <p>API method to check User Exists</p>
-     *
-     * @param userId
-     */
-    @Override
-    public boolean isUserExists(String domainId, String userId) throws SharingRegistryException, TException {
-        try{
-            UserPK userPK = new UserPK();
-            userPK.setDomainId(domainId);
-            userPK.setUserId(userId);
-            return (new UserRepository()).isExists(userPK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean deleteUser(String domainId, String userId) throws SharingRegistryException, TException {
-        try{
-            UserPK userPK = new UserPK();
-            userPK.setUserId(userId);
-            userPK.setDomainId(domainId);
-            (new UserRepository()).delete(userPK);
-
-            UserGroupPK userGroupPK = new UserGroupPK();
-            userGroupPK.setGroupId(userId);
-            userGroupPK.setDomainId(domainId);
-            (new UserGroupRepository()).delete(userGroupPK);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public User getUser(String domainId, String userId) throws SharingRegistryException, TException {
-        try{
-            UserPK userPK = new UserPK();
-            userPK.setUserId(userId);
-            userPK.setDomainId(domainId);
-            return (new UserRepository()).get(userPK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<User> getUsers(String domain, int offset, int limit) throws SharingRegistryException, TException {
-        try{
-            HashMap<String, String> filters = new HashMap<>();
-            filters.put(DBConstants.UserTable.DOMAIN_ID, domain);
-            return (new UserRepository()).select(filters, offset, limit);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * * Group Operations
-     * *
-     */
-    @Override
-    public String createGroup(UserGroup group) throws SharingRegistryException, TException {
-        try{
-            UserGroupPK userGroupPK = new UserGroupPK();
-            userGroupPK.setGroupId(group.getGroupId());
-            userGroupPK.setDomainId(group.getDomainId());
-            if((new UserGroupRepository()).get(userGroupPK) != null)
-                throw new SharingRegistryException("There exist group with given group id");
-            //Client created groups are always of type MULTI_USER
-            group.setGroupCardinality(GroupCardinality.MULTI_USER);
-            group.setCreatedTime(System.currentTimeMillis());
-            group.setUpdatedTime(System.currentTimeMillis());
-            //Add group admins once the group is created
-            group.unsetGroupAdmins();
-            (new UserGroupRepository()).create(group);
-
-            addUsersToGroup(group.getDomainId(), Arrays.asList(group.getOwnerId()), group.getGroupId());
-            return group.getGroupId();
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean updateGroup(UserGroup group) throws SharingRegistryException, TException {
-        try{
-            group.setUpdatedTime(System.currentTimeMillis());
-            UserGroupPK userGroupPK = new UserGroupPK();
-            userGroupPK.setGroupId(group.getGroupId());
-            userGroupPK.setDomainId(group.getDomainId());
-            UserGroup oldGroup = (new UserGroupRepository()).get(userGroupPK);
-            group.setGroupCardinality(oldGroup.getGroupCardinality());
-            group.setCreatedTime(oldGroup.getCreatedTime());
-            group = getUpdatedObject(oldGroup, group);
-
-            if(!group.getOwnerId().equals(oldGroup.getOwnerId()))
-                throw new SharingRegistryException("Group owner cannot be changed");
-
-            (new UserGroupRepository()).update(group);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * API method to check Group Exists
-     * @param domainId
-     * @param groupId
-     * @return
-     * @throws SharingRegistryException
-     * @throws TException
-     */
-    @Override
-    public boolean isGroupExists(String domainId, String groupId) throws SharingRegistryException, TException {
-        try{
-            UserGroupPK userGroupPK = new UserGroupPK();
-            userGroupPK.setDomainId(domainId);
-            userGroupPK.setGroupId(groupId);
-            return (new UserGroupRepository()).isExists(userGroupPK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean deleteGroup(String domainId, String groupId) throws SharingRegistryException, TException {
-        try{
-            UserGroupPK userGroupPK = new UserGroupPK();
-            userGroupPK.setGroupId(groupId);
-            userGroupPK.setDomainId(domainId);
-            (new UserGroupRepository()).delete(userGroupPK);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public UserGroup getGroup(String domainId, String groupId) throws SharingRegistryException, TException {
-        try{
-            UserGroupPK userGroupPK = new UserGroupPK();
-            userGroupPK.setGroupId(groupId);
-            userGroupPK.setDomainId(domainId);
-            return (new UserGroupRepository()).get(userGroupPK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<UserGroup> getGroups(String domain, int offset, int limit) throws TException {
-        try{
-            HashMap<String, String> filters = new HashMap<>();
-            filters.put(DBConstants.UserGroupTable.DOMAIN_ID, domain);
-            // Only return groups with MULTI_USER cardinality which is the only type of cardinality allowed for client created groups
-            filters.put(DBConstants.UserGroupTable.GROUP_CARDINALITY, GroupCardinality.MULTI_USER.name());
-            return (new UserGroupRepository()).select(filters, offset, limit);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean addUsersToGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException, TException {
-        try{
-            for(int i=0; i < userIds.size(); i++){
-                GroupMembership groupMembership = new GroupMembership();
-                groupMembership.setParentId(groupId);
-                groupMembership.setChildId(userIds.get(i));
-                groupMembership.setChildType(GroupChildType.USER);
-                groupMembership.setDomainId(domainId);
-                groupMembership.setCreatedTime(System.currentTimeMillis());
-                groupMembership.setUpdatedTime(System.currentTimeMillis());
-                (new GroupMembershipRepository()).create(groupMembership);
-            }
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean removeUsersFromGroup(String domainId, List<String> userIds, String groupId) throws SharingRegistryException, TException {
-        try{
-            for (String userId: userIds) {
-                if (hasOwnerAccess(domainId, groupId, userId)) {
-                    throw new SharingRegistryException("List of User Ids contains Owner Id. Cannot remove owner from the group");
-                }
-            }
-
-            for(int i=0; i < userIds.size(); i++){
-                GroupMembershipPK groupMembershipPK = new GroupMembershipPK();
-                groupMembershipPK.setParentId(groupId);
-                groupMembershipPK.setChildId(userIds.get(i));
-                groupMembershipPK.setDomainId(domainId);
-                (new GroupMembershipRepository()).delete(groupMembershipPK);
-            }
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean transferGroupOwnership(String domainId, String groupId, String newOwnerId) throws SharingRegistryException, TException {
-        try {
-            List<User> groupUser = getGroupMembersOfTypeUser(domainId, groupId, 0, -1);
-            if (!isUserBelongsToGroup(groupUser, newOwnerId)) {
-                throw new SharingRegistryException("New group owner is not part of the group");
-            }
-
-            if (hasOwnerAccess(domainId, groupId, newOwnerId)) {
-                throw new DuplicateEntryException("User already the current owner of the group");
-            }
-            // remove the new owner as Admin if present
-            if (hasAdminAccess(domainId, groupId, newOwnerId)) {
-                removeGroupAdmins(domainId, groupId, Arrays.asList(newOwnerId));
-            }
-
-            UserGroupPK userGroupPK = new UserGroupPK();
-            userGroupPK.setGroupId(groupId);
-            userGroupPK.setDomainId(domainId);
-            UserGroup userGroup = (new UserGroupRepository()).get(userGroupPK);
-            UserGroup newUserGroup = new UserGroup();
-            newUserGroup.setUpdatedTime(System.currentTimeMillis());
-            newUserGroup.setOwnerId(newOwnerId);
-            newUserGroup.setGroupCardinality(GroupCardinality.MULTI_USER);
-            newUserGroup.setCreatedTime(userGroup.getCreatedTime());
-            newUserGroup = getUpdatedObject(userGroup, newUserGroup);
-
-            (new UserGroupRepository()).update(newUserGroup);
-
-            return true;
-        }
-        catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    private boolean isUserBelongsToGroup(List<User> groupUser, String newOwnerId) {
-        for (User user: groupUser) {
-            if (user.getUserId().equals(newOwnerId)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public boolean addGroupAdmins(String domainId, String groupId, List<String> adminIds) throws SharingRegistryException, TException {
-        try{
-            List<User> groupUser = getGroupMembersOfTypeUser(domainId, groupId, 0, -1);
-
-            for (String adminId: adminIds) {
-                if (! isUserBelongsToGroup(groupUser, adminId)) {
-                    throw new SharingRegistryException("Admin not the user of the group. GroupId : "+ groupId + ", AdminId : "+ adminId);
-                }
-                GroupAdminPK groupAdminPK = new GroupAdminPK();
-                groupAdminPK.setGroupId(groupId);
-                groupAdminPK.setAdminId(adminId);
-                groupAdminPK.setDomainId(domainId);
-
-                if((new GroupAdminRepository()).get(groupAdminPK) != null)
-                    throw new DuplicateEntryException("User already an admin for the group");
-
-                GroupAdmin admin = new GroupAdmin();
-                admin.setAdminId(adminId);
-                admin.setDomainId(domainId);
-                admin.setGroupId(groupId);
-                (new GroupAdminRepository()).create(admin);
-            }
-            return true;
-        }
-        catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean removeGroupAdmins(String domainId, String groupId, List<String> adminIds) throws SharingRegistryException, TException {
-        try {
-            for (String adminId: adminIds) {
-                GroupAdminPK groupAdminPK = new GroupAdminPK();
-                groupAdminPK.setAdminId(adminId);
-                groupAdminPK.setDomainId(domainId);
-                groupAdminPK.setGroupId(groupId);
-                (new GroupAdminRepository()).delete(groupAdminPK);
-            }
-            return true;
-        }
-        catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean hasAdminAccess(String domainId, String groupId, String adminId) throws SharingRegistryException, TException {
-        try{
-            GroupAdminPK groupAdminPK = new GroupAdminPK();
-            groupAdminPK.setGroupId(groupId);
-            groupAdminPK.setAdminId(adminId);
-            groupAdminPK.setDomainId(domainId);
-
-            if((new GroupAdminRepository()).get(groupAdminPK) != null)
-                return true;
-            return false;
-        }
-        catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean hasOwnerAccess(String domainId, String groupId, String ownerId) throws SharingRegistryException, TException {
-        try {
-            UserGroupPK userGroupPK = new UserGroupPK();
-            userGroupPK.setGroupId(groupId);
-            userGroupPK.setDomainId(domainId);
-            UserGroup getGroup = (new UserGroupRepository()).get(userGroupPK);
-
-            if(getGroup.getOwnerId().equals(ownerId))
-                return true;
-            return false;
-        }
-        catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<User> getGroupMembersOfTypeUser(String domainId, String groupId, int offset, int limit) throws SharingRegistryException, TException {
-        try{
-            //TODO limit offset
-            List<User> groupMemberUsers = (new GroupMembershipRepository()).getAllChildUsers(domainId, groupId);
-            return groupMemberUsers;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<UserGroup> getGroupMembersOfTypeGroup(String domainId, String groupId, int offset, int limit) throws SharingRegistryException, TException {
-        try{
-            //TODO limit offset
-            List<UserGroup> groupMemberGroups = (new GroupMembershipRepository()).getAllChildGroups(domainId, groupId);
-            return groupMemberGroups;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean addChildGroupsToParentGroup(String domainId, List<String> childIds, String groupId) throws SharingRegistryException, TException {
-        try{
-            for(String childId : childIds) {
-                //Todo check for cyclic dependencies
-                GroupMembership groupMembership = new GroupMembership();
-                groupMembership.setParentId(groupId);
-                groupMembership.setChildId(childId);
-                groupMembership.setChildType(GroupChildType.GROUP);
-                groupMembership.setDomainId(domainId);
-                groupMembership.setCreatedTime(System.currentTimeMillis());
-                groupMembership.setUpdatedTime(System.currentTimeMillis());
-                (new GroupMembershipRepository()).create(groupMembership);
-            }
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean removeChildGroupFromParentGroup(String domainId, String childId, String groupId) throws SharingRegistryException, TException {
-        try{
-            GroupMembershipPK groupMembershipPK = new GroupMembershipPK();
-            groupMembershipPK.setParentId(groupId);
-            groupMembershipPK.setChildId(childId);
-            groupMembershipPK.setDomainId(domainId);
-            (new GroupMembershipRepository()).delete(groupMembershipPK);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<UserGroup> getAllMemberGroupsForUser(String domainId, String userId) throws SharingRegistryException, TException {
-        try{
-            GroupMembershipRepository groupMembershipRepository = new GroupMembershipRepository();
-            return groupMembershipRepository.getAllMemberGroupsForUser(domainId, userId);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * * EntityType Operations
-     * *
-     */
-    @Override
-    public String createEntityType(EntityType entityType) throws SharingRegistryException, DuplicateEntryException, TException {
-        try{
-            EntityTypePK entityTypePK = new EntityTypePK();
-            entityTypePK.setDomainId(entityType.getDomainId());
-            entityTypePK.setEntityTypeId(entityType.getEntityTypeId());
-            if((new EntityTypeRepository()).get(entityTypePK) != null)
-                throw new DuplicateEntryException("There exist EntityType with given EntityType id");
-
-            entityType.setCreatedTime(System.currentTimeMillis());
-            entityType.setUpdatedTime(System.currentTimeMillis());
-            (new EntityTypeRepository()).create(entityType);
-            return entityType.getEntityTypeId();
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean updateEntityType(EntityType entityType) throws SharingRegistryException, TException {
-        try{
-            entityType.setUpdatedTime(System.currentTimeMillis());
-            EntityTypePK entityTypePK = new EntityTypePK();
-            entityTypePK.setDomainId(entityType.getDomainId());
-            entityTypePK.setEntityTypeId(entityType.getEntityTypeId());
-            EntityType oldEntityType = (new EntityTypeRepository()).get(entityTypePK);
-            entityType.setCreatedTime(oldEntityType.getCreatedTime());
-            entityType = getUpdatedObject(oldEntityType, entityType);
-            (new EntityTypeRepository()).update(entityType);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * <p>API method to check EntityType Exists</p>
-     *
-     * @param entityTypeId
-     */
-    @Override
-    public boolean isEntityTypeExists(String domainId, String entityTypeId) throws SharingRegistryException, TException {
-        try{
-            EntityTypePK entityTypePK = new EntityTypePK();
-            entityTypePK.setDomainId(domainId);
-            entityTypePK.setEntityTypeId(entityTypeId);
-            return (new EntityTypeRepository()).isExists(entityTypePK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean deleteEntityType(String domainId, String entityTypeId) throws SharingRegistryException, TException {
-        try{
-            EntityTypePK entityTypePK = new EntityTypePK();
-            entityTypePK.setDomainId(domainId);
-            entityTypePK.setEntityTypeId(entityTypeId);
-            (new EntityTypeRepository()).delete(entityTypePK);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public EntityType getEntityType(String domainId, String entityTypeId) throws SharingRegistryException, TException {
-        try{
-            EntityTypePK entityTypePK = new EntityTypePK();
-            entityTypePK.setDomainId(domainId);
-            entityTypePK.setEntityTypeId(entityTypeId);
-            return (new EntityTypeRepository()).get(entityTypePK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<EntityType> getEntityTypes(String domain, int offset, int limit) throws TException {
-        try{
-            HashMap<String, String> filters = new HashMap<>();
-            filters.put(DBConstants.EntityTypeTable.DOMAIN_ID, domain);
-            return (new EntityTypeRepository()).select(filters, offset, limit);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * * Permission Operations
-     * *
-     */
-    @Override
-    public String createPermissionType(PermissionType permissionType) throws SharingRegistryException, DuplicateEntryException, TException {
-        try{
-            PermissionTypePK permissionTypePK =  new PermissionTypePK();
-            permissionTypePK.setDomainId(permissionType.getDomainId());
-            permissionTypePK.setPermissionTypeId(permissionType.getPermissionTypeId());
-            if((new PermissionTypeRepository()).get(permissionTypePK) != null)
-                throw new DuplicateEntryException("There exist PermissionType with given PermissionType id");
-            permissionType.setCreatedTime(System.currentTimeMillis());
-            permissionType.setUpdatedTime(System.currentTimeMillis());
-            (new PermissionTypeRepository()).create(permissionType);
-            return permissionType.getPermissionTypeId();
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean updatePermissionType(PermissionType permissionType) throws SharingRegistryException, TException {
-        try{
-            permissionType.setUpdatedTime(System.currentTimeMillis());
-            PermissionTypePK permissionTypePK =  new PermissionTypePK();
-            permissionTypePK.setDomainId(permissionType.getDomainId());
-            permissionTypePK.setPermissionTypeId(permissionType.getPermissionTypeId());
-            PermissionType oldPermissionType = (new PermissionTypeRepository()).get(permissionTypePK);
-            permissionType = getUpdatedObject(oldPermissionType, permissionType);
-            (new PermissionTypeRepository()).update(permissionType);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * <p>API method to check Permission Exists</p>
-     *
-     * @param permissionId
-     */
-    @Override
-    public boolean isPermissionExists(String domainId, String permissionId) throws SharingRegistryException, TException {
-        try{
-            PermissionTypePK permissionTypePK = new PermissionTypePK();
-            permissionTypePK.setDomainId(domainId);
-            permissionTypePK.setPermissionTypeId(permissionId);
-            return (new PermissionTypeRepository()).isExists(permissionTypePK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean deletePermissionType(String domainId, String permissionTypeId) throws SharingRegistryException, TException {
-        try{
-            PermissionTypePK permissionTypePK =  new PermissionTypePK();
-            permissionTypePK.setDomainId(domainId);
-            permissionTypePK.setPermissionTypeId(permissionTypeId);
-            (new PermissionTypeRepository()).delete(permissionTypePK);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public PermissionType getPermissionType(String domainId, String permissionTypeId) throws SharingRegistryException, TException {
-        try{
-            PermissionTypePK permissionTypePK =  new PermissionTypePK();
-            permissionTypePK.setDomainId(domainId);
-            permissionTypePK.setPermissionTypeId(permissionTypeId);
-            return (new PermissionTypeRepository()).get(permissionTypePK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<PermissionType> getPermissionTypes(String domain, int offset, int limit) throws SharingRegistryException, TException {
-        try{
-            HashMap<String, String> filters = new HashMap<>();
-            filters.put(DBConstants.PermissionTypeTable.DOMAIN_ID, domain);
-            return (new PermissionTypeRepository()).select(filters, offset, limit);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * * Entity Operations
-     * *
-     */
-    @Override
-    public String createEntity(Entity entity) throws SharingRegistryException, DuplicateEntryException, TException {
-        try{
-            EntityPK entityPK = new EntityPK();
-            entityPK.setDomainId(entity.getDomainId());
-            entityPK.setEntityId(entity.getEntityId());
-            if((new EntityRepository()).get(entityPK) != null)
-                throw new DuplicateEntryException("There exist Entity with given Entity id");
-
-            UserPK userPK = new UserPK();
-            userPK.setDomainId(entity.getDomainId());
-            userPK.setUserId(entity.getOwnerId());
-            if(!(new UserRepository()).isExists(userPK)){
-                //Todo this is for Airavata easy integration. Proper thing is to throw an exception here
-                User user = new User();
-                user.setUserId(entity.getOwnerId());
-                user.setDomainId(entity.getDomainId());
-                user.setUserName(user.getUserId().split("@")[0]);
-
-                createUser(user);
-            }
-            entity.setCreatedTime(System.currentTimeMillis());
-            entity.setUpdatedTime(System.currentTimeMillis());
-
-            if(entity.getOriginalEntityCreationTime()==0){
-                entity.setOriginalEntityCreationTime(entity.getCreatedTime());
-            }
-            (new EntityRepository()).create(entity);
-
-            //Assigning global permission for the owner
-            Sharing newSharing = new Sharing();
-            newSharing.setPermissionTypeId((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(entity.getDomainId()));
-            newSharing.setEntityId(entity.getEntityId());
-            newSharing.setGroupId(entity.getOwnerId());
-            newSharing.setSharingType(SharingType.DIRECT_CASCADING);
-            newSharing.setInheritedParentId(entity.getEntityId());
-            newSharing.setDomainId(entity.getDomainId());
-            newSharing.setCreatedTime(System.currentTimeMillis());
-            newSharing.setUpdatedTime(System.currentTimeMillis());
-
-            (new SharingRepository()).create(newSharing);
-
-            // creating records for inherited permissions
-            if (entity.getParentEntityId() != null && entity.getParentEntityId() != "") {
-                addCascadingPermissionsForEntity(entity);
-            }
-
-            return entity.getEntityId();
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            SharingRegistryException sharingRegistryException = new SharingRegistryException();
-            sharingRegistryException.setMessage(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-            throw sharingRegistryException;
-        }
-    }
-
-    private void addCascadingPermissionsForEntity(Entity entity) throws SharingRegistryException {
-        Sharing newSharing;
-        List<Sharing> sharings = (new SharingRepository()).getCascadingPermissionsForEntity(entity.getDomainId(),
-                entity.getParentEntityId());
-        for (Sharing sharing : sharings) {
-                    newSharing = new Sharing();
-                    newSharing.setPermissionTypeId(sharing.getPermissionTypeId());
-                    newSharing.setEntityId(entity.getEntityId());
-                    newSharing.setGroupId(sharing.getGroupId());
-                    newSharing.setInheritedParentId(sharing.getInheritedParentId());
-                    newSharing.setSharingType(SharingType.INDIRECT_CASCADING);
-                    newSharing.setDomainId(entity.getDomainId());
-                    newSharing.setCreatedTime(System.currentTimeMillis());
-                    newSharing.setUpdatedTime(System.currentTimeMillis());
-
-                    (new SharingRepository()).create(newSharing);
-                }
-            }
-
-    @Override
-    public boolean updateEntity(Entity entity) throws SharingRegistryException, TException {
-        try{
-            //TODO Check for permission changes
-            entity.setUpdatedTime(System.currentTimeMillis());
-            EntityPK entityPK = new EntityPK();
-            entityPK.setDomainId(entity.getDomainId());
-            entityPK.setEntityId(entity.getEntityId());
-            Entity oldEntity = (new EntityRepository()).get(entityPK);
-            entity.setCreatedTime(oldEntity.getCreatedTime());
-            // check if parent entity changed and re-add inherited permissions
-            if (!Objects.equals(oldEntity.getParentEntityId(), entity.getParentEntityId())) {
-                logger.debug("Parent entity changed for {}, updating inherited permissions", entity.getEntityId());
-                if (oldEntity.getParentEntityId() != null && oldEntity.getParentEntityId() != "") {
-                    logger.debug("Removing inherited permissions from {} that were inherited from parent {}", entity.getEntityId(), oldEntity.getParentEntityId());
-                    (new SharingRepository()).removeAllIndirectCascadingPermissionsForEntity(entity.getDomainId(), entity.getEntityId());
-                }
-                if (entity.getParentEntityId() != null && entity.getParentEntityId() != "") {
-                    // re-add INDIRECT_CASCADING permissions
-                    logger.debug("Adding inherited permissions to {} that are inherited from parent {}", entity.getEntityId(), entity.getParentEntityId());
-                    addCascadingPermissionsForEntity(entity);
-                }
-            }
-            entity = getUpdatedObject(oldEntity, entity);
-            entity.setSharedCount((new SharingRepository()).getSharedCount(entity.getDomainId(), entity.getEntityId()));
-            (new EntityRepository()).update(entity);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    /**
-     * <p>API method to check Entity Exists</p>
-     *
-     * @param entityId
-     */
-    @Override
-    public boolean isEntityExists(String domainId, String entityId) throws SharingRegistryException, TException {
-        try{
-            EntityPK entityPK = new EntityPK();
-            entityPK.setDomainId(domainId);
-            entityPK.setEntityId(entityId);
-            return (new EntityRepository()).isExists(entityPK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean deleteEntity(String domainId, String entityId) throws SharingRegistryException, TException {
-        try{
-            //TODO Check for permission changes
-            EntityPK entityPK = new EntityPK();
-            entityPK.setDomainId(domainId);
-            entityPK.setEntityId(entityId);
-            (new EntityRepository()).delete(entityPK);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public Entity getEntity(String domainId, String entityId) throws SharingRegistryException, TException {
-        try{
-            EntityPK entityPK = new EntityPK();
-            entityPK.setDomainId(domainId);
-            entityPK.setEntityId(entityId);
-            return (new EntityRepository()).get(entityPK);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<Entity> searchEntities(String domainId, String userId, List<SearchCriteria> filters,
-                                       int offset, int limit) throws SharingRegistryException, TException {
-        try{
-            List<String> groupIds = new ArrayList<>();
-            groupIds.add(userId);
-            (new GroupMembershipRepository()).getAllParentMembershipsForChild(domainId, userId).stream().forEach(gm -> groupIds.add(gm.getParentId()));
-            return (new EntityRepository()).searchEntities(domainId, groupIds, filters, offset, limit);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<User> getListOfSharedUsers(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException, TException {
-        try{
-            return (new UserRepository()).getAccessibleUsers(domainId, entityId, permissionTypeId);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<User> getListOfDirectlySharedUsers(String domainId, String entityId, String permissionTypeId)
-            throws SharingRegistryException, TException {
-        try{
-            return (new UserRepository()).getDirectlyAccessibleUsers(domainId, entityId, permissionTypeId);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            SharingRegistryException sharingRegistryException = new SharingRegistryException();
-            sharingRegistryException.setMessage(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-            throw sharingRegistryException;
-        }
-    }
-
-    @Override
-    public List<UserGroup> getListOfSharedGroups(String domainId, String entityId, String permissionTypeId) throws SharingRegistryException, TException {
-        try{
-            return (new UserGroupRepository()).getAccessibleGroups(domainId, entityId, permissionTypeId);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public List<UserGroup> getListOfDirectlySharedGroups(String domainId, String entityId, String permissionTypeId)
-            throws SharingRegistryException, TException {
-        try{
-            return (new UserGroupRepository()).getDirectlyAccessibleGroups(domainId, entityId, permissionTypeId);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            SharingRegistryException sharingRegistryException = new SharingRegistryException();
-            sharingRegistryException.setMessage(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-            throw sharingRegistryException;
-        }
-    }
-
-    /**
-     * Sharing Entity with Users and Groups
-     * @param domainId
-     * @param entityId
-     * @param userList
-     * @param permissionTypeId
-     * @param cascadePermission
-     * @return
-     * @throws SharingRegistryException
-     * @throws TException
-     */
-    @Override
-    public boolean shareEntityWithUsers(String domainId, String entityId, List<String> userList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException {
-        try{
-            return shareEntity(domainId, entityId, userList, permissionTypeId, cascadePermission);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean shareEntityWithGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId, boolean cascadePermission) throws SharingRegistryException, TException {
-        try{
-            return shareEntity(domainId, entityId, groupList, permissionTypeId, cascadePermission);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    private boolean shareEntity(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId, boolean cascadePermission)  throws SharingRegistryException, TException {
-        try{
-            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
-                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
-            }
-
-            List<Sharing> sharings = new ArrayList<>();
-
-            //Adding permission for the specified users/groups for the specified entity
-            LinkedList<Entity> temp = new LinkedList<>();
-            for(String userId : groupOrUserList){
-                Sharing sharing = new Sharing();
-                sharing.setPermissionTypeId(permissionTypeId);
-                sharing.setEntityId(entityId);
-                sharing.setGroupId(userId);
-                sharing.setInheritedParentId(entityId);
-                sharing.setDomainId(domainId);
-                if(cascadePermission) {
-                    sharing.setSharingType(SharingType.DIRECT_CASCADING);
-                }else {
-                    sharing.setSharingType(SharingType.DIRECT_NON_CASCADING);
-                }
-                sharing.setCreatedTime(System.currentTimeMillis());
-                sharing.setUpdatedTime(System.currentTimeMillis());
-
-                sharings.add(sharing);
-            }
-
-            if(cascadePermission){
-                //Adding permission for the specified users/groups for all child entities
-                (new EntityRepository()).getChildEntities(domainId, entityId).stream().forEach(e -> temp.addLast(e));
-                while(temp.size() > 0){
-                    Entity entity = temp.pop();
-                    String childEntityId = entity.getEntityId();
-                    for(String userId : groupOrUserList){
-                        Sharing sharing = new Sharing();
-                        sharing.setPermissionTypeId(permissionTypeId);
-                        sharing.setEntityId(childEntityId);
-                        sharing.setGroupId(userId);
-                        sharing.setInheritedParentId(entityId);
-                        sharing.setSharingType(SharingType.INDIRECT_CASCADING);
-                        sharing.setInheritedParentId(entityId);
-                        sharing.setDomainId(domainId);
-                        sharing.setCreatedTime(System.currentTimeMillis());
-                        sharing.setUpdatedTime(System.currentTimeMillis());
-                        sharings.add(sharing);
-                        (new EntityRepository()).getChildEntities(domainId, childEntityId).stream().forEach(e -> temp.addLast(e));
-                    }
-                }
-            }
-            (new SharingRepository()).create(sharings);
-
-            EntityPK entityPK = new EntityPK();
-            entityPK.setDomainId(domainId);
-            entityPK.setEntityId(entityId);
-            Entity entity = (new EntityRepository()).get(entityPK);
-            entity.setSharedCount((new SharingRepository()).getSharedCount(domainId, entityId));
-            (new EntityRepository()).update(entity);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean revokeEntitySharingFromUsers(String domainId, String entityId, List<String> userList, String permissionTypeId) throws SharingRegistryException, TException {
-        try{
-            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
-                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
-            }
-            return revokeEntitySharing(domainId, entityId, userList, permissionTypeId);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-
-    @Override
-    public boolean revokeEntitySharingFromGroups(String domainId, String entityId, List<String> groupList, String permissionTypeId) throws SharingRegistryException, TException {
-        try{
-            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
-                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be assigned or removed");
-            }
-            return revokeEntitySharing(domainId, entityId, groupList, permissionTypeId);
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    @Override
-    public boolean userHasAccess(String domainId, String userId, String entityId, String permissionTypeId) throws SharingRegistryException, TException {
-        try{
-            //check whether the user has permission directly or indirectly
-            List<GroupMembership> parentMemberships = (new GroupMembershipRepository()).getAllParentMembershipsForChild(domainId, userId);
-            List<String> groupIds = new ArrayList<>();
-            parentMemberships.stream().forEach(pm->groupIds.add(pm.getParentId()));
-            groupIds.add(userId);
-            return (new SharingRepository()).hasAccess(domainId, entityId, groupIds, Arrays.asList(permissionTypeId,
-                    (new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId)));
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-    }
-
-    public boolean revokeEntitySharing(String domainId, String entityId, List<String> groupOrUserList, String permissionTypeId) throws SharingRegistryException {
-        try{
-            if(permissionTypeId.equals((new PermissionTypeRepository()).getOwnerPermissionTypeIdForDomain(domainId))){
-                throw new SharingRegistryException(OWNER_PERMISSION_NAME + " permission cannot be removed");
-            }
-
-            //revoking permission for the entity
-            for(String groupId : groupOrUserList){
-                SharingPK sharingPK = new SharingPK();
-                sharingPK.setEntityId(entityId);
-                sharingPK.setGroupId(groupId);
-                sharingPK.setPermissionTypeId(permissionTypeId);
-                sharingPK.setInheritedParentId(entityId);
-                sharingPK.setDomainId(domainId);
-
-                (new SharingRepository()).delete(sharingPK);
-            }
-
-            //revoking permission from inheritance
-            List<Sharing> temp = new ArrayList<>();
-            (new SharingRepository()).getIndirectSharedChildren(domainId, entityId, permissionTypeId).stream().forEach(s -> temp.add(s));
-            for(Sharing sharing : temp){
-                String childEntityId = sharing.getEntityId();
-                for(String groupId : groupOrUserList){
-                    SharingPK sharingPK = new SharingPK();
-                    sharingPK.setEntityId(childEntityId);
-                    sharingPK.setGroupId(groupId);
-                    sharingPK.setPermissionTypeId(permissionTypeId);
-                    sharingPK.setInheritedParentId(entityId);
-                    sharingPK.setDomainId(domainId);
-
-                    (new SharingRepository()).delete(sharingPK);
-                }
-            }
-
-            EntityPK entityPK = new EntityPK();
-            entityPK.setDomainId(domainId);
-            entityPK.setEntityId(entityId);
-            Entity entity = (new EntityRepository()).get(entityPK);
-            entity.setSharedCount((new SharingRepository()).getSharedCount(domainId, entityId));
-            (new EntityRepository()).update(entity);
-            return true;
-        }catch (Throwable ex) {
-            logger.error(ex.getMessage(), ex);
-            throw new SharingRegistryException(ex.getMessage() + " Stack trace:" + ExceptionUtils.getStackTrace(ex));
-        }
-
-    }
-
-
-
-    private <T> T getUpdatedObject(T oldEntity, T newEntity) throws SharingRegistryException {
-        Field[] newEntityFields = newEntity.getClass().getDeclaredFields();
-        Hashtable newHT = fieldsToHT(newEntityFields, newEntity);
-
-        Class oldEntityClass = oldEntity.getClass();
-        Field[] oldEntityFields = oldEntityClass.getDeclaredFields();
-
-        for (Field field : oldEntityFields){
-            if (!Modifier.isFinal(field.getModifiers())) {
-                field.setAccessible(true);
-                Object o = newHT.get(field.getName());
-                if (o != null) {
-                    Field f = null;
-                    try {
-                        f = oldEntityClass.getDeclaredField(field.getName());
-                        f.setAccessible(true);
-                        logger.debug("setting " + f.getName());
-                        f.set(oldEntity, o);
-                    } catch (Exception e) {
-                        throw new SharingRegistryException(e.getMessage());
-                    }
-                }
-            }
-        }
-        return oldEntity;
-    }
-
-    private static Hashtable<String, Object> fieldsToHT(Field[] fields, Object obj){
-        Hashtable<String,Object> hashtable = new Hashtable<>();
-        for (Field field: fields){
-            field.setAccessible(true);
-            try {
-                Object retrievedObject = field.get(obj);
-                if (retrievedObject != null){
-                    logger.debug("scanning " + field.getName());
-                    hashtable.put(field.getName(), field.get(obj));
-                }
-            } catch (IllegalAccessException e) {
-                e.printStackTrace();
-            }
-        }
-        return hashtable;
-    }
-
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/META-INF/persistence.xml b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index 936b84d..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
-
-    <persistence-unit name="airavata-sharing-registry">
-        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
-        <class>org.apache.airavata.sharing.registry.db.entities.DomainEntity</class>
-        <class>org.apache.airavata.sharing.registry.db.entities.EntityEntity</class>
-        <class>org.apache.airavata.sharing.registry.db.entities.EntityTypeEntity</class>
-        <class>org.apache.airavata.sharing.registry.db.entities.GroupMembershipEntity</class>
-        <class>org.apache.airavata.sharing.registry.db.entities.PermissionTypeEntity</class>
-        <class>org.apache.airavata.sharing.registry.db.entities.SharingEntity</class>
-        <class>org.apache.airavata.sharing.registry.db.entities.UserEntity</class>
-        <class>org.apache.airavata.sharing.registry.db.entities.GroupAdminEntity</class>
-        <class>org.apache.airavata.sharing.registry.db.entities.UserGroupEntity</class>
-    </persistence-unit>
-</persistence>
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/airavata.jks b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/airavata.jks
deleted file mode 100644
index e0e46e2..0000000
Binary files a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/airavata.jks and /dev/null differ
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/client_truststore.jks b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/client_truststore.jks
deleted file mode 100644
index 4ff588f..0000000
Binary files a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/client_truststore.jks and /dev/null differ
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-derby.sql b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
deleted file mode 100644
index a7038e2..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-derby.sql
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-
-CREATE TABLE DOMAIN (
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (DOMAIN_ID)
-);
-
-CREATE TABLE SHARING_USER (
-  USER_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  USER_NAME VARCHAR(255) NOT NULL,
-  FIRST_NAME VARCHAR (255),
-  LAST_NAME VARCHAR (255),
-  EMAIL VARCHAR (255),
-  ICON BLOB,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (USER_ID, DOMAIN_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-CREATE TABLE GROUP_ADMIN (
-  ADMIN_ID VARCHAR(255) NOT NULL,
-  GROUP_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  PRIMARY KEY (ADMIN_ID, GROUP_ID, DOMAIN_ID),
-  FOREIGN KEY (ADMIN_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-CREATE TABLE USER_GROUP (
-  GROUP_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  OWNER_ID VARCHAR(255) NOT NULL,
-  GROUP_TYPE VARCHAR(255) NOT NULL,
-  GROUP_CARDINALITY VARCHAR(255) NOT NULL,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (GROUP_ID, DOMAIN_ID),
-  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-
-CREATE TABLE GROUP_MEMBERSHIP (
-  PARENT_ID VARCHAR(255) NOT NULL,
-  CHILD_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  CHILD_TYPE VARCHAR(255) NOT NULL,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (PARENT_ID, CHILD_ID, DOMAIN_ID),
-  FOREIGN KEY (PARENT_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (CHILD_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-CREATE TABLE ENTITY_TYPE (
-  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (ENTITY_TYPE_ID, DOMAIN_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-CREATE TABLE PERMISSION_TYPE (
-  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (PERMISSION_TYPE_ID, DOMAIN_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-CREATE TABLE ENTITY (
-  ENTITY_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
-  OWNER_ID VARCHAR(255) NOT NULL,
-  PARENT_ENTITY_ID VARCHAR(255),
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  BINARY_DATA BLOB,
-  FULL_TEXT VARCHAR(255),
-  SHARED_COUNT BIGINT DEFAULT 0,
-  ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (ENTITY_ID, DOMAIN_ID),
-  FOREIGN KEY (ENTITY_TYPE_ID, DOMAIN_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (PARENT_ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
--- ALTER TABLE ENTITY ADD FULLTEXT FULL_TEXT_INDEX(FULL_TEXT);
-
-CREATE TABLE SHARING (
-  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
-  ENTITY_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR (255) NOT NULL,
-  GROUP_ID VARCHAR(255) NOT NULL,
-  SHARING_TYPE VARCHAR(255) NOT NULL,
-  INHERITED_PARENT_ID VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID, DOMAIN_ID, INHERITED_PARENT_ID),
-  FOREIGN KEY (PERMISSION_TYPE_ID, DOMAIN_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (INHERITED_PARENT_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (GROUP_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-);
-
-CREATE TABLE CONFIGURATION
-(
-  CONFIG_KEY VARCHAR(255) NOT NULL,
-  CONFIG_VALUE VARCHAR(255) NOT NULL,
-  PRIMARY KEY(CONFIG_KEY, CONFIG_VALUE)
-);
-
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VALUE) VALUES('sharing_reg_version', '0.17');
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql b/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
deleted file mode 100644
index 145d926..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/main/resources/sharing-registry-mysql.sql
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-
-CREATE TABLE DOMAIN (
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (DOMAIN_ID)
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-CREATE TABLE SHARING_USER (
-  USER_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  USER_NAME VARCHAR(255) NOT NULL,
-  FIRST_NAME VARCHAR (255),
-  LAST_NAME VARCHAR (255),
-  EMAIL VARCHAR (255),
-  ICON BLOB,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (USER_ID, DOMAIN_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-CREATE TABLE USER_GROUP (
-  GROUP_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  OWNER_ID VARCHAR(255) NOT NULL,
-  GROUP_TYPE VARCHAR(255) NOT NULL,
-  GROUP_CARDINALITY VARCHAR(255) NOT NULL,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (GROUP_ID, DOMAIN_ID),
-  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-CREATE TABLE GROUP_ADMIN (
-  ADMIN_ID VARCHAR(255) NOT NULL,
-  GROUP_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  PRIMARY KEY (ADMIN_ID, GROUP_ID, DOMAIN_ID),
-  FOREIGN KEY (ADMIN_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-CREATE TABLE GROUP_MEMBERSHIP (
-  PARENT_ID VARCHAR(255) NOT NULL,
-  CHILD_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  CHILD_TYPE VARCHAR(255) NOT NULL,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (PARENT_ID, CHILD_ID, DOMAIN_ID),
-  FOREIGN KEY (PARENT_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (CHILD_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-CREATE TABLE ENTITY_TYPE (
-  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (ENTITY_TYPE_ID, DOMAIN_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-CREATE TABLE PERMISSION_TYPE (
-  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (PERMISSION_TYPE_ID, DOMAIN_ID),
-  FOREIGN KEY (DOMAIN_ID) REFERENCES DOMAIN(DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-CREATE TABLE ENTITY (
-  ENTITY_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR(255) NOT NULL,
-  ENTITY_TYPE_ID VARCHAR(255) NOT NULL,
-  OWNER_ID VARCHAR(255) NOT NULL,
-  PARENT_ENTITY_ID VARCHAR(255),
-  NAME VARCHAR(255) NOT NULL,
-  DESCRIPTION VARCHAR(255),
-  BINARY_DATA BLOB,
-  FULL_TEXT TEXT,
-  SHARED_COUNT BIGINT DEFAULT 0,
-  ORIGINAL_ENTITY_CREATION_TIME BIGINT NOT NULL,
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (ENTITY_ID, DOMAIN_ID),
-  FOREIGN KEY (ENTITY_TYPE_ID, DOMAIN_ID) REFERENCES ENTITY_TYPE(ENTITY_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (OWNER_ID, DOMAIN_ID) REFERENCES SHARING_USER(USER_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  FOREIGN KEY (PARENT_ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-ALTER TABLE ENTITY ADD FULLTEXT FULL_TEXT_INDEX(FULL_TEXT);
-
-CREATE TABLE SHARING (
-  PERMISSION_TYPE_ID VARCHAR(255) NOT NULL,
-  ENTITY_ID VARCHAR(255) NOT NULL,
-  DOMAIN_ID VARCHAR (255) NOT NULL,
-  GROUP_ID VARCHAR(255) NOT NULL,
-  SHARING_TYPE VARCHAR(255) NOT NULL,
-  INHERITED_PARENT_ID VARCHAR(255),
-  CREATED_TIME BIGINT NOT NULL,
-  UPDATED_TIME BIGINT NOT NULL,
-  PRIMARY KEY (PERMISSION_TYPE_ID, ENTITY_ID, GROUP_ID, DOMAIN_ID, INHERITED_PARENT_ID),
-  CONSTRAINT `SHARING_PERMISSION_TYPE_ID_DOMAIN_ID_FK` FOREIGN KEY (PERMISSION_TYPE_ID, DOMAIN_ID) REFERENCES PERMISSION_TYPE(PERMISSION_TYPE_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  CONSTRAINT `SHARING_ENTITY_ID_DOMAIN_ID_FK` FOREIGN KEY (ENTITY_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  CONSTRAINT `SHARING_INHERITED_PARENT_ID_DOMAIN_ID_FK` FOREIGN KEY (INHERITED_PARENT_ID, DOMAIN_ID) REFERENCES ENTITY(ENTITY_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION,
-  CONSTRAINT `SHARING_GROUP_ID_DOMAIN_ID_FK` FOREIGN KEY (GROUP_ID, DOMAIN_ID) REFERENCES USER_GROUP(GROUP_ID, DOMAIN_ID) ON DELETE CASCADE ON UPDATE NO ACTION
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-CREATE TABLE CONFIGURATION
-(
-  CONFIG_KEY VARCHAR(255) NOT NULL,
-  CONFIG_VALUE VARCHAR(255) NOT NULL,
-  PRIMARY KEY(CONFIG_KEY, CONFIG_VALUE)
-)ENGINE=InnoDB DEFAULT CHARACTER SET=latin1;
-
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VALUE) VALUES('sharing_reg_version', '0.17');
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/CipresTest.java b/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/CipresTest.java
deleted file mode 100644
index f3ccc52..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/CipresTest.java
+++ /dev/null
@@ -1,632 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry;
-
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.sharing.registry.models.*;
-import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
-import org.apache.thrift.TException;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.transport.TSSLTransportFactory;
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-public class CipresTest {
-    public static void main(String[] args) throws InterruptedException, TException, ApplicationSettingsException {
-        System.out.println("Hello World!");
-        //should use the correct host name and port here
-        String serverHost = "wb-airavata.scigap.org";
-
-        int serverPort = 7878;
-        TTransport transport = null;
-        TProtocol protocol = null;
-        try {
-
-            SharingRegistryService.Client sharingServiceClient;
-
-            //Non Secure Client
-//            transport = new TSocket(serverHost, serverPort);
-//            transport.open();
-//            protocol = new TBinaryProtocol(transport);
-//            sharingServiceClient= new SharingRegistryService.Client(protocol);
-
-            //TLS enabled client
-            TSSLTransportFactory.TSSLTransportParameters params =
-                    new TSSLTransportFactory.TSSLTransportParameters();
-            params.setKeyStore(ServerSettings.getKeyStorePath(), ServerSettings.getKeyStorePassword());
-            params.setTrustStore(ServerSettings.getTrustStorePath(), ServerSettings.getTrustStorePassword());
-            transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, 10000, params);
-            protocol = new TBinaryProtocol(transport);
-            sharingServiceClient = new SharingRegistryService.Client(protocol);
-
-
-            try {
-                sharingServiceClient.deleteDomain("test-domain");
-            } catch (SharingRegistryException sre1) {
-                System.out.println("deleteDomain failed" + sre1.getMessage() + "\n");
-            }
-            Domain domain = new Domain();
-            //has to be one word
-            domain.setName("test-domain");
-            //optional
-            domain.setDescription("test domain description");
-            //domain id will be same as domain name
-            String domainId = sharingServiceClient.createDomain(domain);
-            System.out.println("After domain creation...\n");
-
-            User user1 = new User();
-            String userName1 = "test-user-1";
-            String userId1 = "test-user-1";
-            //required
-            user1.setUserId(userId1);
-            //required
-            user1.setUserName(userName1);
-            //required
-            user1.setDomainId(domainId);
-            //required
-            user1.setFirstName("John");
-            //required
-            user1.setLastName("Doe");
-            //required
-            user1.setEmail("john.doe@abc.com");
-            //optional - this should be bytes of the users image icon
-            //byte[] icon = new byte[10];
-            //user1.setIcon(icon);
-            sharingServiceClient.createUser(user1);
-            User user2 = new User();
-            String userName2 = "test-user-2";
-            String userId2 = "test-user-2";
-            //required
-            user2.setUserId(userId2);
-            //required
-            user2.setUserName(userName2);
-            //required
-            user2.setDomainId(domainId);
-            //required
-            user2.setFirstName("John");
-            //required
-            user2.setLastName("Doe");
-            //required
-            user2.setEmail("john.doe@abc.com");
-            //optional - this should be bytes of the users image icon
-            //byte[] icon = new byte[20];
-            //user2.setIcon(icon);
-            sharingServiceClient.createUser(user2);
-            User user3 = new User();
-            String userName3 = "test-user-3";
-            String userId3 = "test-user-3";
-            //required
-            user3.setUserId(userId3);
-            //required
-            user3.setUserName(userName3);
-            //required
-            user3.setDomainId(domainId);
-            //required
-            user3.setFirstName("John");
-            //required
-            user3.setLastName("Doe");
-            //required
-            user3.setEmail("john.doe@abc.com");
-            //optional - this should be bytes of the users image icon
-            //byte[] icon = new byte[30];
-            //user3.setIcon(icon);
-            sharingServiceClient.createUser(user3);
-            System.out.println("After user creation...\n");
-
-            UserGroup userGroup1 = new UserGroup();
-            //required
-            userGroup1.setGroupId("test-group-1");
-            //required
-            userGroup1.setDomainId(domainId);
-            //required
-            userGroup1.setName("test-group-1");
-            //optional
-            //userGroup1.setDescription("test group description");
-            //required
-            userGroup1.setOwnerId("test-user-1");
-            //required
-            userGroup1.setGroupType(GroupType.USER_LEVEL_GROUP);
-            sharingServiceClient.createGroup(userGroup1);
-            //Similarly create another group "userGroup2" with the owner being "test-user-2".
-            UserGroup userGroup2 = new UserGroup();
-            //required
-            userGroup2.setGroupId("test-group-2");
-            //required
-            userGroup2.setDomainId(domainId);
-            //required
-            userGroup2.setName("test-group-2");
-            //optional
-            //userGroup2.setDescription("test group description");
-            //required
-            userGroup2.setOwnerId("test-user-2");
-            //required
-            userGroup2.setGroupType(GroupType.USER_LEVEL_GROUP);
-            sharingServiceClient.createGroup(userGroup2);
-            System.out.println("After group creation...\n");
-
-            sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("test-user-3"), "test-group-2");
-            System.out.println("After adding user to group...\n");
-
-            sharingServiceClient.addChildGroupsToParentGroup(domainId, Arrays.asList("test-group-2"), "test-group-1");
-
-
-            PermissionType permissionType1 = new PermissionType();
-            //required
-            permissionType1.setPermissionTypeId("READ");
-            //required
-            permissionType1.setDomainId(domainId);
-            //required
-            permissionType1.setName("READ");
-            //optional
-            permissionType1.setDescription("READ description");
-            sharingServiceClient.createPermissionType(permissionType1);
-            PermissionType permissionType2 = new PermissionType();
-            permissionType2.setPermissionTypeId("WRITE");
-            permissionType2.setDomainId(domainId);
-            permissionType2.setName("WRITE");
-            permissionType2.setDescription("WRITE description");
-            sharingServiceClient.createPermissionType(permissionType2);
-            PermissionType permissionType3 = new PermissionType();
-            permissionType3.setPermissionTypeId("CLONE");
-            permissionType3.setDomainId(domainId);
-            permissionType3.setName("CLONE");
-            permissionType3.setDescription("CLONE description");
-            sharingServiceClient.createPermissionType(permissionType3);
-            System.out.println("After adding groups to parent group...\n");
-
-            EntityType entityType1 = new EntityType();
-            //required
-            entityType1.setEntityTypeId("PROJECT");
-            //required
-            entityType1.setDomainId(domainId);
-            //required
-            entityType1.setName("PROJECT");
-            //optional
-            entityType1.setDescription("PROJECT entity type description");
-            sharingServiceClient.createEntityType(entityType1);
-            EntityType entityType2 = new EntityType();
-            entityType2.setEntityTypeId("EXPERIMENT");
-            entityType2.setDomainId(domainId);
-            entityType2.setName("EXPERIMENT");
-            entityType2.setDescription("EXPERIMENT entity type");
-            sharingServiceClient.createEntityType(entityType2);
-            EntityType entityType3 = new EntityType();
-            entityType3.setEntityTypeId("FILE");
-            entityType3.setDomainId(domainId);
-            entityType3.setName("FILE");
-            entityType3.setDescription("FILE entity type");
-            sharingServiceClient.createEntityType(entityType3);
-            System.out.println("After project entity creation...\n");
-
-            Entity entity1 = new Entity();
-            //required
-            entity1.setEntityId("test-project-1");
-            //required
-            entity1.setDomainId(domainId);
-            //required
-            entity1.setEntityTypeId("PROJECT");
-            //required
-            entity1.setOwnerId("test-user-1");
-            //required
-            entity1.setName("test-project-1");
-            //optional
-            entity1.setDescription("test project 1 description");
-            //optional
-            entity1.setFullText("test project 1 stampede gaussian seagrid");
-            //optional - If not set this will be default to current system time
-            entity1.setOriginalEntityCreationTime(System.currentTimeMillis());
-            sharingServiceClient.createEntity(entity1);
-            System.out.println("After currentTimeMillis()...\n");
-            Entity entity2 = new Entity();
-            entity2.setEntityId("test-experiment-1");
-            entity2.setDomainId(domainId);
-            entity2.setEntityTypeId("EXPERIMENT");
-            entity2.setOwnerId("test-user-1");
-            entity2.setName("test-experiment-1");
-            entity2.setDescription("test experiment 1 description");
-            entity2.setParentEntityId("test-project-1");
-            entity2.setFullText("test experiment 1 benzene");
-            System.out.println("Before sharingServiceClient.createEntity entity2...\n");
-            sharingServiceClient.createEntity(entity2);
-            System.out.println("After sharingServiceClient.createEntity entity2...\n");
-            Entity entity3 = new Entity();
-            entity3.setEntityId("test-experiment-2");
-            entity3.setDomainId(domainId);
-            entity3.setEntityTypeId("EXPERIMENT");
-            entity3.setOwnerId("test-user-1");
-            entity3.setName("test-experiment-2");
-            entity3.setDescription("test experiment 2 description");
-            entity3.setParentEntityId("test-project-1");
-            entity3.setFullText("test experiment 1 3-methyl 1-butanol stampede");
-            sharingServiceClient.createEntity(entity3);
-            System.out.println("After sharingServiceClient.createEntity entity3...\n");
-            Entity entity4 = new Entity();
-            entity4.setEntityId("test-file-1");
-            entity4.setDomainId(domainId);
-            entity4.setEntityTypeId("FILE");
-            entity4.setOwnerId("test-user-1");
-            entity4.setName("test-file-1");
-            entity4.setDescription("test file 1 description");
-            entity4.setParentEntityId("test-experiment-2");
-            entity4.setFullText("test input file 1 for experiment 2");
-            sharingServiceClient.createEntity(entity4);
-            System.out.println("After sharingServiceClient.createEntity entity4...\n");
-            System.out.println("After test entity creation...\n");
-
-            //shared with cascading permissions
-            //System.out.println("Before shareEntityWithUsers WRITE...\n");
-            //sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true);
-            System.out.println("Before shareEntityWithGroups READ...\n");
-            long time = System.currentTimeMillis();
-            sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "READ", true);
-            System.out.println("Time for sharing " + (System.currentTimeMillis() - time));
-            //shared with non cascading permissions
-            System.out.println("Before shareEntityWithGroups CLONE...\n");
-            time = System.currentTimeMillis();
-            sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "CLONE", false);
-            System.out.println("Time for sharing " + (System.currentTimeMillis() - time));
-
-            //test-project-1 is explicitly shared with test-user-2 with WRITE permission
-            System.out.println("Before userHasAccess 1...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-project-1", "WRITE"));
-            //test-user-2 has WRITE permission to test-experiment-1 and test-experiment-2 indirectly
-            System.out.println("Before userHasAccess 2...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "WRITE"));
-            System.out.println("Before userHasAccess 3...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "WRITE"));
-            //test-user-2 does not have READ permission to test-experiment-1 and test-experiment-2
-            System.out.println("Before userHasAccess 4...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "READ"));
-            System.out.println(domainId + " test-user-2 " + " test-experiment-2 " + " READ ");
-            System.out.println("Before userHasAccess 5...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "READ"));
-            //test-user-3 does not have READ permission to test-project-1
-            System.out.println("Before userHasAccess 6...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-project-1", "READ"));
-            //test-experiment-2 is shared with test-group-2 with READ permission. Therefore test-user-3 has READ permission
-            System.out.println("Before userHasAccess 7...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "READ"));
-            //test-user-3 does not have WRITE permission to test-experiment-2
-            System.out.println("Before userHasAccess 8...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "WRITE"));
-            //test-user-3 has CLONE permission to test-experiment-2
-            System.out.println("Before userHasAccess 9...\n");
-            System.out.println((sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "CLONE")));
-            //test-user-3 does not have CLONE permission to test-file-1
-            System.out.println("Before userHasAccess 10...\n");
-            System.out.println((sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-file-1", "CLONE")));
-            System.out.println("After cascading permissions...\n");
-
-            ArrayList<SearchCriteria> filters = new ArrayList<>();
-            //ArrayList<SearchCriteria> filters = new List<>();
-            SearchCriteria searchCriteria = new SearchCriteria();
-            searchCriteria.setSearchCondition(SearchCondition.LIKE);
-            searchCriteria.setValue("experiment stampede methyl");
-            //searchCriteria.setValue("stampede");
-            //searchCriteria.setSearchField(EntitySearchField.NAME);
-            searchCriteria.setSearchField(EntitySearchField.FULL_TEXT);
-            filters.add(searchCriteria);
-            searchCriteria = new SearchCriteria();
-            searchCriteria.setSearchCondition(SearchCondition.EQUAL);
-            searchCriteria.setValue("READ");
-            searchCriteria.setSearchField(EntitySearchField.PERMISSION_TYPE_ID);
-            filters.add(searchCriteria);
-            System.out.println(sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1).size());
-            System.out.println(sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1));
-            System.out.println("After searchEntities...\n");
-
-
-            //System.out.println("After searchEntities...\n");
-            User userA = new User();
-            String userNameA = "UserA";
-            String userIdA = "UserA";
-            //required
-            userA.setUserId(userIdA);
-            //required
-            userA.setUserName(userNameA);
-            //required
-            userA.setDomainId(domainId);
-            //required
-            userA.setFirstName("User");
-            //required
-            userA.setLastName("A");
-            //required
-            userA.setEmail("user.a@example.com");
-            //optional - this should be bytes of the users image icon
-            //byte[] icon = new byte[10];
-            //userA.setIcon(icon);
-            sharingServiceClient.createUser(userA);
-            User userB = new User();
-            String userNameB = "UserB";
-            String userIdB = "UserB";
-            //required
-            userB.setUserId(userIdB);
-            //required
-            userB.setUserName(userNameB);
-            //required
-            userB.setDomainId(domainId);
-            //required
-            userB.setFirstName("User");
-            //required
-            userB.setLastName("B");
-            //required
-            userB.setEmail("user.b@example.com");
-            //optional - this should be bytes of the users image icon
-            //byte[] icon = new byte[10];
-            //userB.setIcon(icon);
-            sharingServiceClient.createUser(userB);
-            User userC = new User();
-            String userNameC = "UserC";
-            String userIdC = "UserC";
-            //required
-            userC.setUserId(userIdC);
-            //required
-            userC.setUserName(userNameC);
-            //required
-            userC.setDomainId(domainId);
-            //required
-            userC.setFirstName("User");
-            //required
-            userC.setLastName("C");
-            //required
-            userC.setEmail("user.c@example.com");
-            //optional - this should be bytes of the users image icon
-            //byte[] icon = new byte[10];
-            //userC.setIcon(icon);
-            sharingServiceClient.createUser(userC);
-            User userD = new User();
-            String userNameD = "UserD";
-            String userIdD = "UserD";
-            //required
-            userD.setUserId(userIdD);
-            //required
-            userD.setUserName(userNameD);
-            //required
-            userD.setDomainId(domainId);
-            //required
-            userD.setFirstName("User");
-            //required
-            userD.setLastName("D");
-            //required
-            userD.setEmail("user.d@example.com");
-            //optional - this should be bytes of the users image icon
-            //byte[] icon = new byte[10];
-            //userD.setIcon(icon);
-            sharingServiceClient.createUser(userD);
-            System.out.println("After user creation...\n");
-
-            UserGroup Group1 = new UserGroup();
-            //required
-            Group1.setGroupId("Group1");
-            //required
-            Group1.setDomainId(domainId);
-            //required
-            Group1.setName("Group1");
-            //optional
-            //userGroup1.setDescription("test group description");
-            //required
-            Group1.setOwnerId("UserA");
-            //required
-            Group1.setGroupType(GroupType.USER_LEVEL_GROUP);
-            sharingServiceClient.createGroup(Group1);
-            System.out.println("After Group1 creation...\n");
-
-            sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("UserB"), "Group1");
-            sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("UserC"), "Group1");
-            sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("UserD"), "Group1");
-
-            System.out.println("After adding users to Group1 creation...\n");
-
-            EntityType entityTypeFolder = new EntityType();
-            //required
-            entityTypeFolder.setEntityTypeId("FOLDER");
-            //required
-            entityTypeFolder.setDomainId(domainId);
-            //required
-            entityTypeFolder.setName("FOLDER");
-            //optional
-            //entityTypeFolder.setDescription("PROJECT entity type description");
-            sharingServiceClient.createEntityType(entityTypeFolder);
-            System.out.println("After creating FOLDER entity type...\n");
-
-            EntityType entityTypeInputData = new EntityType();
-            //required
-            entityTypeInputData.setEntityTypeId("INPUTDATA");
-            //required
-            entityTypeInputData.setDomainId(domainId);
-            //required
-            entityTypeInputData.setName("INPUTDATA");
-            //optional
-            //entityTypeFolder.setDescription("PROJECT entity type description");
-            sharingServiceClient.createEntityType(entityTypeInputData);
-            System.out.println("After creating INPUTDATA entity type...\n");
-
-            Entity entityB1 = new Entity();
-            //required
-            entityB1.setEntityId("UserBProject1");
-            //required
-            entityB1.setDomainId(domainId);
-            //required
-            entityB1.setEntityTypeId("PROJECT");
-            //required
-            entityB1.setOwnerId("UserB");
-            //required
-            entityB1.setName("UserBProject1");
-            //optional
-            entityB1.setDescription("User B's Project 1");
-            //optional
-            entityB1.setFullText("test project 1");
-            //optional - If not set this will be default to current system time
-            entityB1.setOriginalEntityCreationTime(System.currentTimeMillis());
-            sharingServiceClient.createEntity(entityB1);
-            System.out.println("After creating UserBProject1 ...\n");
-
-            Entity entityC1 = new Entity();
-            //required
-            entityC1.setEntityId("UserCProject2");
-            //required
-            entityC1.setDomainId(domainId);
-            //required
-            entityC1.setEntityTypeId("PROJECT");
-            //required
-            entityC1.setOwnerId("UserC");
-            //required
-            entityC1.setName("UserCProject2");
-            //optional
-            entityC1.setDescription("User C's Project 2");
-            //optional
-            entityC1.setFullText("test project 2");
-            //optional - If not set this will be default to current system time
-            entityC1.setOriginalEntityCreationTime(System.currentTimeMillis());
-            sharingServiceClient.createEntity(entityC1);
-            System.out.println("After creating UserCProject2 ...\n");
-
-            Entity entityF1 = new Entity();
-            entityF1.setEntityId("Folder1");
-            entityF1.setDomainId(domainId);
-            entityF1.setEntityTypeId("FOLDER");
-            entityF1.setOwnerId("UserB");
-            entityF1.setName("UserBFolder1");
-            entityF1.setDescription("UserB's Folder 1");
-            entityF1.setParentEntityId("UserBProject1");
-            entityF1.setFullText("test experiment 1 ethidium");
-            sharingServiceClient.createEntity(entityF1);
-            System.out.println("After creating Folder1 ...\n");
-
-            Entity entityD1 = new Entity();
-            entityD1.setEntityId("Data1");
-            entityD1.setDomainId(domainId);
-            entityD1.setEntityTypeId("INPUTDATA");
-            entityD1.setOwnerId("UserB");
-            entityD1.setName("UserBData1");
-            entityD1.setDescription("UserB's Data 1");
-            entityD1.setParentEntityId("Folder1");
-            entityD1.setFullText("Data 1 for User B Folder 1");
-            sharingServiceClient.createEntity(entityD1);
-            System.out.println("After creating Data1 ...\n");
-
-            Entity entityF2 = new Entity();
-            entityF2.setEntityId("Folder2");
-            entityF2.setDomainId(domainId);
-            entityF2.setEntityTypeId("FOLDER");
-            entityF2.setOwnerId("UserC");
-            entityF2.setName("UserCFolder2");
-            entityF2.setDescription("UserC's Folder 2");
-            entityF2.setParentEntityId("UserCProject2");
-            entityF2.setFullText("test experiment 2 ethidium");
-            sharingServiceClient.createEntity(entityF2);
-            System.out.println("After creating Folder2 ...\n");
-
-            Entity entityD2 = new Entity();
-            entityD2.setEntityId("Data2");
-            entityD2.setDomainId(domainId);
-            entityD2.setEntityTypeId("INPUTDATA");
-            entityD2.setOwnerId("UserC");
-            entityD2.setName("UserCData2");
-            entityD2.setDescription("UserC's Data 2");
-            entityD2.setParentEntityId("Folder2");
-            entityD2.setFullText("Data 2 for User C Folder 1");
-            sharingServiceClient.createEntity(entityD2);
-            System.out.println("After creating Data2 ...\n");
-
-            //sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "READ", true);
-            time = System.currentTimeMillis();
-            sharingServiceClient.shareEntityWithGroups(domainId, "Folder1", Arrays.asList("Group1"), "READ", true);
-            System.out.println("Time for sharing " + (System.currentTimeMillis() - time));
-            System.out.println("After READ sharing UserBFolder1 with Group1 ...\n");
-            //sharingServiceClient.shareEntityWithGroups(domainId, "Folder2", Arrays.asList("Group1"), "READ", true);
-            //System.out.println("After READ sharing UserCFolder2 with Group1 ...\n");
-
-            Entity entityD3 = new Entity();
-            entityD3.setEntityId("Data3");
-            entityD3.setDomainId(domainId);
-            entityD3.setEntityTypeId("INPUTDATA");
-            entityD3.setOwnerId("UserC");
-            entityD3.setName("UserCData3");
-            entityD3.setDescription("UserC's Data 3");
-            entityD3.setParentEntityId("Folder2");
-            entityD3.setFullText("Data 3 for User C Folder 2");
-            sharingServiceClient.createEntity(entityD3);
-            System.out.println("After creating Data3 ...\n");
-
-            System.out.println("Does UserC have READ access to Data1 ...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "UserC", "Data1", "READ"));
-            System.out.println("Does UserC have READ access to Data2 ...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "UserC", "Data2", "READ"));
-            System.out.println("Does UserC have READ access to Data3 ...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "UserC", "Data3", "READ"));
-            System.out.println("Does UserB have READ access to Data3 ...\n");
-            System.out.println(sharingServiceClient.userHasAccess(domainId, "UserB", "Data3", "READ"));
-
-            ArrayList<SearchCriteria> sharedfilters = new ArrayList<>();
-            searchCriteria = new SearchCriteria();
-            searchCriteria.setSearchCondition(SearchCondition.EQUAL);
-            searchCriteria.setValue("READ");
-            searchCriteria.setSearchField(EntitySearchField.PERMISSION_TYPE_ID);
-            sharedfilters.add(searchCriteria);
-            System.out.println("items READable by UserC ...\n");
-            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1).size());
-            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1));
-            searchCriteria = new SearchCriteria();
-            //searchCriteria.setSearchCondition(SearchCondition.EQUAL);
-            searchCriteria.setSearchCondition(SearchCondition.NOT);
-            searchCriteria.setValue("UserC");
-            searchCriteria.setSearchField(EntitySearchField.OWNER_ID);
-            sharedfilters.add(searchCriteria);
-            System.out.println("items READable, and not owned by UserC by UserC ...\n");
-            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1).size());
-            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1));
-            System.out.println("After searchEntities 2...\n");
-
-            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1).size());
-            System.out.println(sharingServiceClient.searchEntities(domainId, "UserC", sharedfilters, 0, -1));
-            System.out.println("After searchEntities 2...\n");
-
-
-            sharingServiceClient.removeUsersFromGroup(domainId, Arrays.asList("UserD"), "Group1");
-            System.out.println("After removing UserD from Group1 ...\n");
-
-            sharingServiceClient.deleteGroup(domainId, "Group1");
-            System.out.println("After deleting Group1 ...\n");
-
-            System.out.println("End of try clause...\n");
-        } catch (TTransportException ex1) {
-            System.out.println("TTransportException...\n");
-            System.out.println(ex1);
-            System.out.println(ex1.getCause());
-            ex1.printStackTrace();
-            System.out.println(ex1.getMessage());
-        } catch (SharingRegistryException ex2) {
-            System.out.println("SharingRegistryException...\n");
-            System.out.println(ex2.getMessage());
-        } catch (TException ex3) {
-            System.out.println("TException...\n");
-            System.out.println(ex3.getMessage());
-        } finally {
-            System.out.println("In finally...\n");
-            transport.close();
-        }
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServerHandlerTest.java b/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServerHandlerTest.java
deleted file mode 100644
index 2b88167..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServerHandlerTest.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry;
-
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.sharing.registry.db.utils.SharingRegistryDBInitConfig;
-import org.apache.custos.sharing.registry.models.*;
-import org.apache.custos.sharing.registry.server.SharingRegistryServerHandler;
-import org.junit.Assert;
-import org.apache.thrift.TException;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class SharingRegistryServerHandlerTest {
-    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServerHandlerTest.class);
-
-    @Test
-    public void test() throws TException, ApplicationSettingsException {
-        SharingRegistryDBInitConfig sharingRegistryDBInitConfig = new SharingRegistryDBInitConfig();
-        sharingRegistryDBInitConfig.setDBInitScriptPrefix("sharing-registry");
-        SharingRegistryServerHandler sharingRegistryServerHandler = new SharingRegistryServerHandler(sharingRegistryDBInitConfig);
-
-        //Creating domain
-        Domain domain = new Domain();
-        String domainId = "test-domain."+System.currentTimeMillis();
-        domain.setDomainId(domainId);
-        domain.setName(domainId);
-        domain.setDescription("test domain description");
-        domain.setCreatedTime(System.currentTimeMillis());
-        domain.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createDomain(domain));
-        Assert.assertTrue(sharingRegistryServerHandler.getDomains(0, 10).size() > 0);
-
-        //Creating users
-        User user1 = new User();
-        String userName1 = "test-user-1." + System.currentTimeMillis();
-        String userId1 = domainId + ":" + userName1;
-        user1.setUserId(userId1);
-        user1.setUserName(userName1);
-        user1.setDomainId(domainId);
-        user1.setCreatedTime(System.currentTimeMillis());
-        user1.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user1));
-
-        User user2 = new User();
-        String userName2 = "test-user-2." + System.currentTimeMillis();
-        String userId2 = domainId + ":" + userName2;
-        user2.setUserId(userId2);
-        user2.setUserName(userName2);
-        user2.setDomainId(domainId);
-        user2.setCreatedTime(System.currentTimeMillis());
-        user2.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user2));
-
-        User user3 = new User();
-        String userName3 = "test-user-3." + System.currentTimeMillis();
-        String userId3 = domainId + ":" + userName3;
-        user3.setUserId(userId3);
-        user3.setUserName(userName3);
-        user3.setDomainId(domainId);
-        user3.setCreatedTime(System.currentTimeMillis());
-        user3.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user3));
-
-        User user7 = new User();
-        String userName7 = "test-user-7." + System.currentTimeMillis();
-        String userId7 = domainId + ":" + userName7;
-        user7.setUserId(userId7);
-        user7.setUserName(userName7);
-        user7.setDomainId(domainId);
-        user7.setCreatedTime(System.currentTimeMillis());
-        user7.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createUser(user7));
-
-        Assert.assertTrue(sharingRegistryServerHandler.getUsers(domainId, 0, 10).size() > 0);
-
-        // Creating user groups
-        UserGroup userGroup1 = new UserGroup();
-        String groupName1 = "test-group-1." + System.currentTimeMillis();
-        String groupId1 = domainId + ":" + groupName1;
-        userGroup1.setGroupId(groupId1);
-        userGroup1.setDomainId(domainId);
-        userGroup1.setName(groupName1);
-        userGroup1.setDescription("test group description");
-        userGroup1.setOwnerId(userId1);
-        userGroup1.setGroupType(GroupType.USER_LEVEL_GROUP);
-        userGroup1.setGroupCardinality(GroupCardinality.MULTI_USER);
-        userGroup1.setCreatedTime(System.currentTimeMillis());
-        userGroup1.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createGroup(userGroup1));
-        Assert.assertEquals(1, sharingRegistryServerHandler.getAllMemberGroupsForUser(domainId, userId1).size());
-
-        UserGroup userGroup2 = new UserGroup();
-        String groupName2 = "test-group-2." + System.currentTimeMillis();
-        String groupId2 = domainId + ":" + groupName2;
-        userGroup2.setGroupId(groupId2);
-        userGroup2.setDomainId(domainId);
-        userGroup2.setName(groupName2);
-        userGroup2.setDescription("test group description");
-        userGroup2.setOwnerId(userId2);
-        userGroup2.setGroupType(GroupType.USER_LEVEL_GROUP);
-        userGroup2.setGroupCardinality(GroupCardinality.MULTI_USER);
-        userGroup2.setCreatedTime(System.currentTimeMillis());
-        userGroup2.setUpdatedTime(System.currentTimeMillis());
-
-        Assert.assertNotNull(sharingRegistryServerHandler.createGroup(userGroup2));
-
-        sharingRegistryServerHandler.addUsersToGroup(domainId, Arrays.asList(userId1), groupId1);
-        sharingRegistryServerHandler.addUsersToGroup(domainId, Arrays.asList(userId7), groupId1);
-
-        sharingRegistryServerHandler.addUsersToGroup(domainId, Arrays.asList(userId2, userId3), groupId2);
-        Assert.assertEquals(1, sharingRegistryServerHandler.getAllMemberGroupsForUser(domainId, userId3).size());
-
-        sharingRegistryServerHandler.addChildGroupsToParentGroup(domainId, Arrays.asList(groupId2), groupId1);
-
-        Assert.assertTrue(sharingRegistryServerHandler.getGroupMembersOfTypeGroup(domainId, groupId1, 0, 10).size() == 1);
-        Assert.assertTrue(sharingRegistryServerHandler.getGroupMembersOfTypeUser(domainId, groupId2, 0, 10).size() == 2);
-
-        // Group roles tests
-
-        // user has owner access
-        Assert.assertTrue(sharingRegistryServerHandler.hasOwnerAccess(domainId, groupId1, userId1));
-
-        // user has admin access
-        Assert.assertTrue(sharingRegistryServerHandler.addGroupAdmins(domainId, groupId1, Arrays.asList(userId7)));
-        Assert.assertTrue(sharingRegistryServerHandler.hasAdminAccess(domainId, groupId1, userId7));
-        Assert.assertTrue(sharingRegistryServerHandler.removeGroupAdmins(domainId, groupId1, Arrays.asList(userId7)));
-        Assert.assertFalse(sharingRegistryServerHandler.hasAdminAccess(domainId, groupId1, userId7));
-
-        // transfer group ownership
-        sharingRegistryServerHandler.addUsersToGroup(domainId, Arrays.asList(userId2), groupId1);
-        Assert.assertTrue(sharingRegistryServerHandler.transferGroupOwnership(domainId, groupId1, userId2));
-        Assert.assertTrue(sharingRegistryServerHandler.hasOwnerAccess(domainId, groupId1, userId2));
-        Assert.assertTrue(sharingRegistryServerHandler.transferGroupOwnership(domainId, groupId1, userId1));
-        Assert.assertFalse(sharingRegistryServerHandler.hasOwnerAccess(domainId, groupId1, userId2));
-
-        //Creating permission types
-        PermissionType permissionType1 = new PermissionType();
-        String permissionName1 = "READ";
-        permissionType1.setPermissionTypeId(domainId+":"+permissionName1);
-        permissionType1.setDomainId(domainId);
-        permissionType1.setName(permissionName1);
-        permissionType1.setDescription("READ description");
-        permissionType1.setCreatedTime(System.currentTimeMillis());
-        permissionType1.setUpdatedTime(System.currentTimeMillis());
-        String permissionTypeId1 = sharingRegistryServerHandler.createPermissionType(permissionType1);
-        Assert.assertNotNull(permissionTypeId1);
-
-        PermissionType permissionType2 = new PermissionType();
-        String permissionName2 = "WRITE";
-        permissionType2.setPermissionTypeId(domainId+":"+permissionName2);
-        permissionType2.setDomainId(domainId);
-        permissionType2.setName(permissionName2);
-        permissionType2.setDescription("WRITE description");
-        permissionType2.setCreatedTime(System.currentTimeMillis());
-        permissionType2.setUpdatedTime(System.currentTimeMillis());
-        String permissionTypeId2 = sharingRegistryServerHandler.createPermissionType(permissionType2);
-        Assert.assertNotNull(permissionTypeId2);
-
-        //Creating entity types
-        EntityType entityType1 = new EntityType();
-        String entityType1Name = "Project";
-        entityType1.setEntityTypeId(domainId+":"+entityType1Name);
-        entityType1.setDomainId(domainId);
-        entityType1.setName(entityType1Name);
-        entityType1.setDescription("test entity type");
-        entityType1.setCreatedTime(System.currentTimeMillis());
-        entityType1.setUpdatedTime(System.currentTimeMillis());
-        String entityTypeId1 = sharingRegistryServerHandler.createEntityType(entityType1);
-        Assert.assertNotNull(entityTypeId1);
-
-        EntityType entityType2 = new EntityType();
-        String entityType2Name = "Experiment";
-        entityType2.setEntityTypeId(domainId+":"+entityType2Name);
-        entityType2.setDomainId(domainId);
-        entityType2.setName(entityType2Name);
-        entityType2.setDescription("test entity type");
-        entityType2.setCreatedTime(System.currentTimeMillis());
-        entityType2.setUpdatedTime(System.currentTimeMillis());
-        String entityTypeId2 = sharingRegistryServerHandler.createEntityType(entityType2);
-        Assert.assertNotNull(entityTypeId2);
-
-        EntityType entityType3 = new EntityType();
-        String entityType3Name = "FileInput";
-        entityType3.setEntityTypeId(domainId+":"+entityType3Name);
-        entityType3.setDomainId(domainId);
-        entityType3.setName(entityType3Name);
-        entityType3.setDescription("file input type");
-        entityType3.setCreatedTime(System.currentTimeMillis());
-        entityType3.setUpdatedTime(System.currentTimeMillis());
-        String entityTypeId3 = sharingRegistryServerHandler.createEntityType(entityType3);
-        Assert.assertNotNull(entityTypeId3);
-
-        EntityType entityType4 = new EntityType();
-        String entityType4Name = "Application-Deployment";
-        entityType4.setEntityTypeId(domainId+":"+entityType4Name);
-        entityType4.setDomainId(domainId);
-        entityType4.setName(entityType4Name);
-        entityType4.setDescription("test entity type");
-        entityType4.setCreatedTime(System.currentTimeMillis());
-        entityType4.setUpdatedTime(System.currentTimeMillis());
-        String entityTypeId4 = sharingRegistryServerHandler.createEntityType(entityType4);
-        Assert.assertNotNull(entityTypeId4);
-
-        //Creating Entities
-        Entity entity1 = new Entity();
-        entity1.setEntityId(domainId+":Entity1");
-        entity1.setDomainId(domainId);
-        entity1.setEntityTypeId(entityTypeId1);
-        entity1.setOwnerId(userId1);
-        entity1.setName("Project name 1");
-        entity1.setDescription("Project description");
-        entity1.setFullText("Project name project description");
-        entity1.setCreatedTime(System.currentTimeMillis());
-        entity1.setUpdatedTime(System.currentTimeMillis());
-
-        String entityId1 = sharingRegistryServerHandler.createEntity(entity1);
-        Assert.assertNotNull(entityId1);
-
-        Entity entity2 = new Entity();
-        entity2.setEntityId(domainId+":Entity2");
-        entity2.setDomainId(domainId);
-        entity2.setEntityTypeId(entityTypeId2);
-        entity2.setOwnerId(userId1);
-        entity2.setName("Experiment name");
-        entity2.setDescription("Experiment description");
-        entity2.setParentEntityId(entityId1);
-        entity2.setFullText("Project name project description");
-        entity2.setCreatedTime(System.currentTimeMillis());
-        entity2.setUpdatedTime(System.currentTimeMillis());
-
-        String entityId2 = sharingRegistryServerHandler.createEntity(entity2);
-        Assert.assertNotNull(entityId2);
-
-        Entity entity3 = new Entity();
-        entity3.setEntityId(domainId+":Entity3");
-        entity3.setDomainId(domainId);
-        entity3.setEntityTypeId(entityTypeId2);
-        entity3.setOwnerId(userId1);
-        entity3.setName("Experiment name");
-        entity3.setDescription("Experiment description");
-        entity3.setParentEntityId(entityId1);
-        entity3.setFullText("Project name project description");
-        entity3.setCreatedTime(System.currentTimeMillis());
-        entity3.setUpdatedTime(System.currentTimeMillis());
-
-        String entityId3 = sharingRegistryServerHandler.createEntity(entity3);
-        Assert.assertNotNull(entityId3);
-
-        sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId1, Arrays.asList(userId2), permissionTypeId1, true);
-        sharingRegistryServerHandler.shareEntityWithGroups(domainId, entityId3, Arrays.asList(groupId2), permissionTypeId1, true);
-
-        Entity entity4 = new Entity();
-        entity4.setEntityId(domainId+":Entity4");
-        entity4.setDomainId(domainId);
-        entity4.setEntityTypeId(entityTypeId3);
-        entity4.setOwnerId(userId3);
-        entity4.setName("Input name");
-        entity4.setDescription("Input file description");
-        entity4.setParentEntityId(entityId3);
-        entity4.setFullText("Input File");
-        entity4.setCreatedTime(System.currentTimeMillis());
-        entity4.setUpdatedTime(System.currentTimeMillis());
-
-        String entityId4 = sharingRegistryServerHandler.createEntity(entity4);
-        Assert.assertNotNull(entityId4);
-
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId4, permissionTypeId1));
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId4, permissionTypeId1));
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId1, entityId4, permissionTypeId1));
-        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId1, permissionTypeId1));
-
-        Entity entity5 = new Entity();
-        entity5.setEntityId(domainId+":Entity5");
-        entity5.setDomainId(domainId);
-        entity5.setEntityTypeId(entityTypeId4);
-        entity5.setOwnerId(userId1);
-        entity5.setName("App deployment name");
-        entity5.setDescription("App deployment description");
-        entity5.setFullText("App Deployment name app deployment description");
-        entity5.setCreatedTime(System.currentTimeMillis());
-        entity5.setUpdatedTime(System.currentTimeMillis());
-
-        String entityId5 = sharingRegistryServerHandler.createEntity(entity5);
-        Assert.assertNotNull(entityId5);
-
-        sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId5, Arrays.asList(userId2), permissionTypeId1, true);
-        sharingRegistryServerHandler.shareEntityWithGroups(domainId, entityId5, Arrays.asList(groupId2), permissionTypeId2, true);
-
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId5, permissionTypeId2));
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId5, permissionTypeId1));
-        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId5, permissionTypeId1));
-
-        ArrayList<SearchCriteria> filters = new ArrayList<>();
-        SearchCriteria searchCriteria = new SearchCriteria();
-        searchCriteria.setSearchCondition(SearchCondition.LIKE);
-        searchCriteria.setValue("Input");
-        searchCriteria.setSearchField(EntitySearchField.NAME);
-        filters.add(searchCriteria);
-
-        searchCriteria = new SearchCriteria();
-        searchCriteria.setSearchCondition(SearchCondition.EQUAL);
-        searchCriteria.setValue(entityTypeId3);
-        searchCriteria.setSearchField(EntitySearchField.ENTITY_TYPE_ID);
-        filters.add(searchCriteria);
-
-        Assert.assertTrue(sharingRegistryServerHandler.searchEntities(domainId, userId1, filters, 0, -1).size() > 0);
-
-        Assert.assertNotNull(sharingRegistryServerHandler.getListOfSharedUsers(domainId, entityId1, permissionTypeId1));
-        Assert.assertNotNull(sharingRegistryServerHandler.getListOfSharedGroups(domainId, entityId1, permissionTypeId1));
-
-        Assert.assertTrue(sharingRegistryServerHandler.getListOfSharedUsers(domainId, entityId1, domainId + ":OWNER").size()==1);
-
-        // test changing parent - old INDIRECT_CASCADING permissions removed, new is added
-        // entityId2's parent is entityId1. entityId1 is shared with userId2
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId1, permissionTypeId1));
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId2, permissionTypeId1));
-        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId2, permissionTypeId1));
-        // create a different parent entity
-        Entity entity6 = new Entity();
-        entity6.setEntityId(domainId+":Entity6");
-        entity6.setDomainId(domainId);
-        entity6.setEntityTypeId(entityTypeId1);
-        entity6.setOwnerId(userId1);
-        entity6.setName("Project name 2");
-        entity6.setDescription("Project description");
-        entity6.setFullText("Project name project description");
-        entity6.setCreatedTime(System.currentTimeMillis());
-        entity6.setUpdatedTime(System.currentTimeMillis());
-        String entityId6 = sharingRegistryServerHandler.createEntity(entity6);
-        Assert.assertNotNull(entityId6);
-
-        sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId6, Arrays.asList(userId3), permissionTypeId1, true);
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId6, permissionTypeId1));
-        // Make sure entityId2 isn't shared with userId7 and then share it directly
-        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId7, entityId2, permissionTypeId1));
-        sharingRegistryServerHandler.shareEntityWithUsers(domainId, entityId2, Arrays.asList(userId7), permissionTypeId1, true);
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId7, entityId2, permissionTypeId1));
-        entity2.setParentEntityId(entityId6);
-        logger.debug("Updating entity2");
-        Assert.assertTrue(sharingRegistryServerHandler.updateEntity(entity2));
-        Entity entity2Updated = sharingRegistryServerHandler.getEntity(domainId, entityId2);
-        Assert.assertEquals(entityId6, entity2Updated.getParentEntityId());
-        // parent changed so entityId2 should now be shared with entityId6's shared users (userId3)
-        Assert.assertFalse(sharingRegistryServerHandler.userHasAccess(domainId, userId2, entityId2, permissionTypeId1));
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId3, entityId2, permissionTypeId1));
-        // entityId2 should still be shared with userId7 since that was directly shared
-        Assert.assertTrue(sharingRegistryServerHandler.userHasAccess(domainId, userId7, entityId2, permissionTypeId1));
-
-        Assert.assertEquals(Arrays.asList(user3), sharingRegistryServerHandler.getListOfDirectlySharedUsers(domainId, entityId6, permissionTypeId1));
-        Assert.assertEquals(Arrays.asList(user7), sharingRegistryServerHandler.getListOfDirectlySharedUsers(domainId, entityId2, permissionTypeId1));
-        List<User> entityId2SharedUsers = sharingRegistryServerHandler.getListOfSharedUsers(domainId, entityId2, permissionTypeId1);
-        Assert.assertEquals(2, entityId2SharedUsers.size());
-        Assert.assertTrue("user3 and user7 in shared users", entityId2SharedUsers.contains(user3) && entityId2SharedUsers.contains(user7));
-        Assert.assertEquals(1, sharingRegistryServerHandler.getListOfDirectlySharedGroups(domainId, entityId3, permissionTypeId1).size());
-        Assert.assertEquals(groupId2, sharingRegistryServerHandler.getListOfDirectlySharedGroups(domainId, entityId3, permissionTypeId1).get(0).getGroupId());
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServiceTest.java b/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServiceTest.java
deleted file mode 100644
index c6777ff..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/test/java/org/apache/custos/sharing/registry/SharingRegistryServiceTest.java
+++ /dev/null
@@ -1,419 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry;
-
-import org.apache.custos.commons.exceptions.ApplicationSettingsException;
-import org.apache.custos.commons.utils.ServerSettings;
-import org.apache.custos.sharing.registry.models.*;
-import org.apache.custos.sharing.registry.server.SharingRegistryServer;
-import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
-import org.apache.thrift.TException;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.transport.TSSLTransportFactory;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransport;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-public class SharingRegistryServiceTest {
-    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServiceTest.class);
-
-    @BeforeClass
-    public static void setUp() throws Exception {
-        SharingRegistryServer server = new SharingRegistryServer();
-        server.setTestMode(true);
-        server.start();
-        Thread.sleep(1000 * 2);
-    }
-
-
-    @Test
-    public void test() throws TException, InterruptedException, ApplicationSettingsException {
-        String serverHost = "localhost";
-        int serverPort = 7878;
-
-        SharingRegistryService.Client sharingServiceClient;
-        if (!ServerSettings.isSharingTLSEnabled()) {
-            TTransport transport = new TSocket(serverHost, serverPort);
-            transport.open();
-            TProtocol protocol = new TBinaryProtocol(transport);
-            sharingServiceClient = new SharingRegistryService.Client(protocol);
-        }else{
-            TSSLTransportFactory.TSSLTransportParameters params =
-                    new TSSLTransportFactory.TSSLTransportParameters();
-            params.setKeyStore(ServerSettings.getKeyStorePath(), ServerSettings.getKeyStorePassword());
-            params.setTrustStore(ServerSettings.getTrustStorePath(), ServerSettings.getTrustStorePassword());
-
-            TTransport transport = TSSLTransportFactory.getClientSocket(serverHost, serverPort, 10000, params);
-            TProtocol protocol = new TBinaryProtocol(transport);
-            sharingServiceClient = new SharingRegistryService.Client(protocol);
-        }
-
-        Domain domain = new Domain();
-        //has to be one word
-        domain.setName("test-domain" + Math.random());
-        //optional
-        domain.setDescription("test domain description");
-
-        String domainId = sharingServiceClient.createDomain(domain);
-        Assert.assertTrue(sharingServiceClient.isDomainExists(domainId));
-
-        User user1 = new User();
-        //required
-        user1.setUserId("test-user-1");
-        //required
-        user1.setUserName("test-user-1");
-        //required
-        user1.setDomainId(domainId);
-        //required
-        user1.setFirstName("John");
-        //required
-        user1.setLastName("Doe");
-        //required
-        user1.setEmail("john.doe@abc.com");
-        //optional - this should be bytes of the users image icon
-        //byte[] icon1 = new byte[10];
-        //user1.setIcon(icon1);
-
-        sharingServiceClient.createUser(user1);
-        Assert.assertTrue(sharingServiceClient.isUserExists(domainId, "test-user-1"));
-
-        User user2 = new User();
-        //required
-        user2.setUserId("test-user-2");
-        //required
-        user2.setUserName("test-user-2");
-        //required
-        user2.setDomainId(domainId);
-        //required
-        user2.setFirstName("John");
-        //required
-        user2.setLastName("Doe");
-        //required
-        user2.setEmail("john.doe@abc.com");
-        //optional - this should be bytes of the users image icon
-        //byte[] icon2 = new byte[10];
-        //user2.setIcon(icon2);
-
-        sharingServiceClient.createUser(user2);
-
-        User user3 = new User();
-        //required
-        user3.setUserId("test-user-3");
-        //required
-        user3.setUserName("test-user-3");
-        //required
-        user3.setDomainId(domainId);
-        //required
-        user3.setFirstName("John");
-        //required
-        user3.setLastName("Doe");
-        //required
-        user3.setEmail("john.doe@abc.com");
-        //optional - this should be bytes of the users image icon
-        //byte[] icon3 = new byte[10];
-        //user3.setIcon(icon3);
-
-        sharingServiceClient.createUser(user3);
-
-        User user7 = new User();
-        //required
-        user7.setUserId("test-user-7");
-        //required
-        user7.setUserName("test-user-7");
-        //required
-        user7.setDomainId(domainId);
-        //required
-        user7.setFirstName("John");
-        //required
-        user7.setLastName("Doe");
-        //required
-        user7.setEmail("john.doe@abc.com");
-        //optional - this should be bytes of the users image icon
-        //byte[] icon3 = new byte[10];
-        //user3.setIcon(icon3);
-
-        sharingServiceClient.createUser(user7);
-
-        // Test updates to user and how it affects the user's SINGLE_USER group
-        UserGroup singleUserGroupUser7 = sharingServiceClient.getGroup(domainId, user7.getUserId());
-        Assert.assertEquals(GroupCardinality.SINGLE_USER, singleUserGroupUser7.getGroupCardinality());
-        user7.setFirstName("Johnny");
-        sharingServiceClient.updatedUser(user7);
-        User updatedUser7 = sharingServiceClient.getUser(domainId, user7.getUserId());
-        Assert.assertEquals("Johnny", updatedUser7.getFirstName());
-        singleUserGroupUser7 = sharingServiceClient.getGroup(domainId, user7.getUserId());
-        Assert.assertEquals(GroupCardinality.SINGLE_USER, singleUserGroupUser7.getGroupCardinality());
-
-        UserGroup userGroup1 = new UserGroup();
-        //required
-        userGroup1.setGroupId("test-group-1");
-        //required
-        userGroup1.setDomainId(domainId);
-        //required
-        userGroup1.setName("test-group-1");
-        //optional
-        userGroup1.setDescription("test group description");
-        //required
-        userGroup1.setOwnerId("test-user-1");
-        //required
-        userGroup1.setGroupType(GroupType.USER_LEVEL_GROUP);
-
-        sharingServiceClient.createGroup(userGroup1);
-        userGroup1.setDescription("updated description");
-        sharingServiceClient.updateGroup(userGroup1);
-        Assert.assertTrue(sharingServiceClient.getGroup(domainId, userGroup1.getGroupId()).getDescription().equals("updated description"));
-        Assert.assertTrue(sharingServiceClient.isGroupExists(domainId, "test-group-1"));
-
-        UserGroup userGroup2 = new UserGroup();
-        //required
-        userGroup2.setGroupId("test-group-2");
-        //required
-        userGroup2.setDomainId(domainId);
-        //required
-        userGroup2.setName("test-group-2");
-        //optional
-        userGroup2.setDescription("test group description");
-        //required
-        userGroup2.setOwnerId("test-user-2");
-        //required
-        userGroup2.setGroupType(GroupType.USER_LEVEL_GROUP);
-
-        sharingServiceClient.createGroup(userGroup2);
-
-        sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("test-user-3"), "test-group-2");
-
-        sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("test-user-7"), "test-group-1");
-
-        sharingServiceClient.addChildGroupsToParentGroup(domainId, Arrays.asList("test-group-2"), "test-group-1");
-
-        //Group roles
-        Assert.assertTrue(sharingServiceClient.hasOwnerAccess(domainId, "test-group-1", "test-user-1"));
-
-        // user has admin access
-        Assert.assertTrue(sharingServiceClient.addGroupAdmins(domainId, "test-group-1", Arrays.asList("test-user-7")));
-        Assert.assertTrue(sharingServiceClient.hasAdminAccess(domainId, "test-group-1", "test-user-7"));
-
-        UserGroup getGroup = sharingServiceClient.getGroup(domainId, "test-group-1");
-        Assert.assertTrue(getGroup.getGroupAdmins().size() == 1);
-
-        Assert.assertTrue(sharingServiceClient.removeGroupAdmins(domainId, "test-group-1", Arrays.asList("test-user-7")));
-        Assert.assertFalse(sharingServiceClient.hasAdminAccess(domainId, "test-group-1", "test-user-7"));
-
-        // transfer group ownership
-        sharingServiceClient.addUsersToGroup(domainId, Arrays.asList("test-user-2"), "test-group-1");
-        Assert.assertTrue(sharingServiceClient.transferGroupOwnership(domainId, "test-group-1", "test-user-2"));
-        Assert.assertTrue(sharingServiceClient.hasOwnerAccess(domainId, "test-group-1", "test-user-2"));
-        Assert.assertTrue(sharingServiceClient.transferGroupOwnership(domainId, "test-group-1", "test-user-1"));
-        Assert.assertFalse(sharingServiceClient.hasOwnerAccess(domainId, "test-group-1", "test-user-2"));
-
-        PermissionType permissionType1 = new PermissionType();
-        //required
-        permissionType1.setPermissionTypeId("READ");
-        //required
-        permissionType1.setDomainId(domainId);
-        //required
-        permissionType1.setName("READ");
-        //optional
-        permissionType1.setDescription("READ description");
-        sharingServiceClient.createPermissionType(permissionType1);
-        Assert.assertTrue(sharingServiceClient.isPermissionExists(domainId, "READ"));
-
-        PermissionType permissionType2 = new PermissionType();
-        permissionType2.setPermissionTypeId("WRITE");
-        permissionType2.setDomainId(domainId);
-        permissionType2.setName("WRITE");
-        permissionType2.setDescription("WRITE description");
-        sharingServiceClient.createPermissionType(permissionType2);
-
-        PermissionType permissionType3 = new PermissionType();
-        permissionType3.setPermissionTypeId("CLONE");
-        permissionType3.setDomainId(domainId);
-        permissionType3.setName("CLONE");
-        permissionType3.setDescription("CLONE description");
-        sharingServiceClient.createPermissionType(permissionType3);
-
-        EntityType entityType1 = new EntityType();
-        //required
-        entityType1.setEntityTypeId("PROJECT");
-        //required
-        entityType1.setDomainId(domainId);
-        //required
-        entityType1.setName("PROJECT");
-        //optional
-        entityType1.setDescription("PROJECT entity type description");
-        sharingServiceClient.createEntityType(entityType1);
-        Assert.assertTrue(sharingServiceClient.isEntityTypeExists(domainId, "PROJECT"));
-
-        EntityType entityType2 = new EntityType();
-        entityType2.setEntityTypeId("EXPERIMENT");
-        entityType2.setDomainId(domainId);
-        entityType2.setName("EXPERIMENT");
-        entityType2.setDescription("EXPERIMENT entity type");
-        sharingServiceClient.createEntityType(entityType2);
-
-        EntityType entityType3 = new EntityType();
-        entityType3.setEntityTypeId("FILE");
-        entityType3.setDomainId(domainId);
-        entityType3.setName("FILE");
-        entityType3.setDescription("FILE entity type");
-        sharingServiceClient.createEntityType(entityType3);
-
-
-        //Creating entities
-        Entity entity1 = new Entity();
-        //required
-        entity1.setEntityId("test-project-1");
-        //required
-        entity1.setDomainId(domainId);
-        //required
-        entity1.setEntityTypeId("PROJECT");
-        //required
-        entity1.setOwnerId("test-user-1");
-        //required
-        entity1.setName("test-project-1");
-        //optional
-        entity1.setDescription("test project 1 description");
-        //optional
-        entity1.setFullText("test project 1 stampede gaussian seagrid");
-        //optional - If not set this will be default to current system time
-        entity1.setOriginalEntityCreationTime(System.currentTimeMillis());
-        sharingServiceClient.createEntity(entity1);
-        Assert.assertTrue(sharingServiceClient.isEntityExists(domainId, "test-project-1"));
-
-        Entity entity2 = new Entity();
-        entity2.setEntityId("test-experiment-1");
-        entity2.setDomainId(domainId);
-        entity2.setEntityTypeId("EXPERIMENT");
-        entity2.setOwnerId("test-user-1");
-        entity2.setName("test-experiment-1");
-        entity2.setDescription("test experiment 1 description");
-        entity2.setParentEntityId("test-project-1");
-        entity2.setFullText("test experiment 1 benzene");
-        sharingServiceClient.createEntity(entity2);
-
-
-        Entity entity3 = new Entity();
-        entity3.setEntityId("test-experiment-2");
-        entity3.setDomainId(domainId);
-        entity3.setEntityTypeId("EXPERIMENT");
-        entity3.setOwnerId("test-user-1");
-        entity3.setName("test-experiment-2");
-        entity3.setDescription("test experiment 2 description");
-        entity3.setParentEntityId("test-project-1");
-        entity3.setFullText("test experiment 1 3-methyl 1-butanol stampede");
-        sharingServiceClient.createEntity(entity3);
-
-
-        Entity entity4 = new Entity();
-        entity4.setEntityId("test-file-1");
-        entity4.setDomainId(domainId);
-        entity4.setEntityTypeId("FILE");
-        entity4.setOwnerId("test-user-1");
-        entity4.setName("test-file-1");
-        entity4.setDescription("test file 1 description");
-        entity4.setParentEntityId("test-experiment-2");
-        entity4.setFullText("test input file 1 for experiment 2");
-        sharingServiceClient.createEntity(entity4);
-
-        Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").getSharedCount() == 0);
-        sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true);
-        Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").getSharedCount() == 1);
-        ArrayList<SearchCriteria> filters = new ArrayList<>();
-        SearchCriteria searchCriteria = new SearchCriteria();
-        searchCriteria.setSearchField(EntitySearchField.SHARED_COUNT);
-        searchCriteria.setValue("1");
-        searchCriteria.setSearchCondition(SearchCondition.GTE);
-        filters.add(searchCriteria);
-        Assert.assertEquals(1, sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1).size());
-
-
-        sharingServiceClient.revokeEntitySharingFromUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE");
-        Assert.assertTrue(sharingServiceClient.getEntity(domainId, "test-project-1").getSharedCount() == 0);
-        sharingServiceClient.shareEntityWithUsers(domainId, "test-project-1", Arrays.asList("test-user-2"), "WRITE", true);
-
-        sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "READ", true);
-        sharingServiceClient.shareEntityWithGroups(domainId, "test-experiment-2", Arrays.asList("test-group-2"), "CLONE", false);
-
-        //true
-        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-project-1", "WRITE"));
-        //true
-        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "WRITE"));
-        //true
-        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "WRITE"));
-
-        //false
-        Assert.assertFalse(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-1", "READ"));
-        //true
-        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-2", "test-experiment-2", "READ"));
-
-        //false
-        Assert.assertFalse(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-project-1", "READ"));
-        //true
-        Assert.assertTrue(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "READ"));
-        //false
-        Assert.assertFalse(sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "WRITE"));
-
-        //true
-        Assert.assertTrue((sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-experiment-2", "CLONE")));
-        //false
-        Assert.assertFalse((sharingServiceClient.userHasAccess(domainId, "test-user-3", "test-file-1", "CLONE")));
-
-        filters = new ArrayList<>();
-        searchCriteria = new SearchCriteria();
-        searchCriteria.setSearchCondition(SearchCondition.FULL_TEXT);
-        searchCriteria.setValue("experiment");
-        searchCriteria.setSearchField(EntitySearchField.FULL_TEXT);
-        filters.add(searchCriteria);
-
-        searchCriteria = new SearchCriteria();
-        searchCriteria.setSearchCondition(SearchCondition.EQUAL);
-        searchCriteria.setValue("EXPERIMENT");
-        searchCriteria.setSearchField(EntitySearchField.ENTITY_TYPE_ID);
-        filters.add(searchCriteria);
-
-        searchCriteria = new SearchCriteria();
-        searchCriteria.setSearchCondition(SearchCondition.EQUAL);
-        searchCriteria.setValue("READ");
-        searchCriteria.setSearchField(EntitySearchField.PERMISSION_TYPE_ID);
-        filters.add(searchCriteria);
-
-        Assert.assertTrue(sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1).size() == 1);
-        Entity persistedEntity = sharingServiceClient.searchEntities(
-                domainId, "test-user-2", filters, 0, -1).get(0);
-        Assert.assertEquals(entity3.getName(), persistedEntity.getName());
-        Assert.assertEquals(entity3.getDescription(), persistedEntity.getDescription());
-        Assert.assertEquals(entity3.getFullText(), persistedEntity.getFullText());
-
-        searchCriteria = new SearchCriteria();
-        searchCriteria.setSearchCondition(SearchCondition.NOT);
-        searchCriteria.setValue("test-user-1");
-        searchCriteria.setSearchField(EntitySearchField.OWNER_ID);
-        filters.add(searchCriteria);
-        Assert.assertTrue(sharingServiceClient.searchEntities(domainId, "test-user-2", filters, 0, -1).size() == 0);
-    }
-}
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/resources/airavata.jks b/custos-sharing-registry-service/sharing-registry-server/src/test/resources/airavata.jks
deleted file mode 100644
index e0e46e2..0000000
Binary files a/custos-sharing-registry-service/sharing-registry-server/src/test/resources/airavata.jks and /dev/null differ
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/resources/client_truststore.jks b/custos-sharing-registry-service/sharing-registry-server/src/test/resources/client_truststore.jks
deleted file mode 100644
index 4ff588f..0000000
Binary files a/custos-sharing-registry-service/sharing-registry-server/src/test/resources/client_truststore.jks and /dev/null differ
diff --git a/custos-sharing-registry-service/sharing-registry-server/src/test/resources/logback.xml b/custos-sharing-registry-service/sharing-registry-server/src/test/resources/logback.xml
deleted file mode 100644
index 88937d3..0000000
--- a/custos-sharing-registry-service/sharing-registry-server/src/test/resources/logback.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  ~
-  -->
-<configuration>
-    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>[%p] %m%n</pattern>
-        </encoder>
-    </appender>
-    <!-- <logger name="org.apache.airavata.sharing.registry" level="DEBUG"/> -->
-    <root level="INFO">
-        <appender-ref ref="CONSOLE"/>
-    </root>
-</configuration>
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/pom.xml b/custos-sharing-registry-service/sharing-registry-stubs/pom.xml
deleted file mode 100644
index 01364ad..0000000
--- a/custos-sharing-registry-service/sharing-registry-stubs/pom.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-
-    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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>custos-sharing-registry-service</artifactId>
-        <groupId>org.apache.custos</groupId>
-        <relativePath>../pom.xml</relativePath>
-        <version>1.0-SNAPSHOT</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>custos-sharing-registry-stubs</artifactId>
-    <packaging>jar</packaging>
-    <name>Sharing Registry Stubs</name>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.thrift</groupId>
-            <artifactId>libthrift</artifactId>
-            <version>${thrift.version}</version>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.5.1</version>
-                <configuration>
-                    <source>1.8</source>
-                    <target>1.8</target>
-                </configuration>
-            </plugin>
-            <!--<plugin>-->
-                <!--<groupId>com.google.code.maven-replacer-plugin</groupId>-->
-                <!--<artifactId>replacer</artifactId>-->
-                <!--<version>${maven.replacer.plugin.version}</version>-->
-                <!--<executions>-->
-                    <!--<execution>-->
-                        <!--<phase>generate-sources</phase>-->
-                        <!--<goals>-->
-                            <!--<goal>replace</goal>-->
-                        <!--</goals>-->
-                    <!--</execution>-->
-                <!--</executions>-->
-                <!--<configuration>-->
-                    <!--<includes>-->
-                        <!--<include>${basedir}/src/main/java/org/apache/airavata/**/*.java</include>-->
-                    <!--</includes>-->
-                    <!--<token>, date = ".*"</token>-->
-                    <!--<value> </value>-->
-                <!--</configuration>-->
-            <!--</plugin>-->
-        </plugins>
-    </build>
-</project>
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/client/SharingRegistryServiceClientFactory.java b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/client/SharingRegistryServiceClientFactory.java
deleted file mode 100644
index dbcb49a..0000000
--- a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/client/SharingRegistryServiceClientFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *
- * 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.custos.sharing.registry.client;
-
-import org.apache.custos.sharing.registry.models.SharingRegistryException;
-import org.apache.custos.sharing.registry.service.cpi.SharingRegistryService;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransportException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SharingRegistryServiceClientFactory {
-    private final static Logger logger = LoggerFactory.getLogger(SharingRegistryServiceClientFactory.class);
-
-    public static SharingRegistryService.Client createSharingRegistryClient(String serverHost, int serverPort) throws SharingRegistryException {
-        try {
-            TSocket e = new TSocket(serverHost, serverPort);
-            e.open();
-            TBinaryProtocol protocol = new TBinaryProtocol(e);
-            return new SharingRegistryService.Client(protocol);
-        } catch (TTransportException var4) {
-            logger.error("failed to create sharing registry client", var4);
-            throw new SharingRegistryException();
-        }
-    }
-}
\ No newline at end of file
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Domain.java b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Domain.java
deleted file mode 100644
index d61f613..0000000
--- a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Domain.java
+++ /dev/null
@@ -1,805 +0,0 @@
-/**
- * Autogenerated by Thrift Compiler (0.12.0)
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- *  @generated
- */
-package org.apache.custos.sharing.registry.models;
-
-@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-/**
- * <p>Domain is the entity that enables multi-tenency in this componenet. Every tenant will be
- * operating separately it's own silo which is identified by the domain id. In the current implementation domain id
- * will be same as the domain name</p>
- * <li>domainId : Will be generated by the server based on the domain name</li>
- * <li><b>name</b> : A single word name that identifies the domain e.g seagrid, ultrascan</li>
- * <li>description : A short description for the domain</li>
- * <li>createdTime : Will be set by the system</li>
- * <li>updatedTime : Will be set by the system</li>
- * 
- */
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-13")
-public class Domain implements org.apache.thrift.TBase<Domain, Domain._Fields>, java.io.Serializable, Cloneable, Comparable<Domain> {
-  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Domain");
-
-  private static final org.apache.thrift.protocol.TField DOMAIN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("domainId", org.apache.thrift.protocol.TType.STRING, (short)1);
-  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)2);
-  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)3);
-  private static final org.apache.thrift.protocol.TField CREATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createdTime", org.apache.thrift.protocol.TType.I64, (short)4);
-  private static final org.apache.thrift.protocol.TField UPDATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedTime", org.apache.thrift.protocol.TType.I64, (short)5);
-
-  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new DomainStandardSchemeFactory();
-  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new DomainTupleSchemeFactory();
-
-  public @org.apache.thrift.annotation.Nullable String domainId; // optional
-  public @org.apache.thrift.annotation.Nullable String name; // optional
-  public @org.apache.thrift.annotation.Nullable String description; // optional
-  public long createdTime; // optional
-  public long updatedTime; // optional
-
-  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
-  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
-    DOMAIN_ID((short)1, "domainId"),
-    NAME((short)2, "name"),
-    DESCRIPTION((short)3, "description"),
-    CREATED_TIME((short)4, "createdTime"),
-    UPDATED_TIME((short)5, "updatedTime");
-
-    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-    static {
-      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
-        byName.put(field.getFieldName(), field);
-      }
-    }
-
-    /**
-     * Find the _Fields constant that matches fieldId, or null if its not found.
-     */
-    @org.apache.thrift.annotation.Nullable
-    public static _Fields findByThriftId(int fieldId) {
-      switch(fieldId) {
-        case 1: // DOMAIN_ID
-          return DOMAIN_ID;
-        case 2: // NAME
-          return NAME;
-        case 3: // DESCRIPTION
-          return DESCRIPTION;
-        case 4: // CREATED_TIME
-          return CREATED_TIME;
-        case 5: // UPDATED_TIME
-          return UPDATED_TIME;
-        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.
-     */
-    @org.apache.thrift.annotation.Nullable
-    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
-  private static final int __CREATEDTIME_ISSET_ID = 0;
-  private static final int __UPDATEDTIME_ISSET_ID = 1;
-  private byte __isset_bitfield = 0;
-  private static final _Fields optionals[] = {_Fields.DOMAIN_ID,_Fields.NAME,_Fields.DESCRIPTION,_Fields.CREATED_TIME,_Fields.UPDATED_TIME};
-  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-  static {
-    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.DOMAIN_ID, new org.apache.thrift.meta_data.FieldMetaData("domainId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        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.CREATED_TIME, new org.apache.thrift.meta_data.FieldMetaData("createdTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    tmpMap.put(_Fields.UPDATED_TIME, new org.apache.thrift.meta_data.FieldMetaData("updatedTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Domain.class, metaDataMap);
-  }
-
-  public Domain() {
-    this.domainId = "DO_NOT_SET_AT_CLIENTS_ID";
-
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public Domain(Domain other) {
-    __isset_bitfield = other.__isset_bitfield;
-    if (other.isSetDomainId()) {
-      this.domainId = other.domainId;
-    }
-    if (other.isSetName()) {
-      this.name = other.name;
-    }
-    if (other.isSetDescription()) {
-      this.description = other.description;
-    }
-    this.createdTime = other.createdTime;
-    this.updatedTime = other.updatedTime;
-  }
-
-  public Domain deepCopy() {
-    return new Domain(this);
-  }
-
-  @Override
-  public void clear() {
-    this.domainId = "DO_NOT_SET_AT_CLIENTS_ID";
-
-    this.name = null;
-    this.description = null;
-    setCreatedTimeIsSet(false);
-    this.createdTime = 0;
-    setUpdatedTimeIsSet(false);
-    this.updatedTime = 0;
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getDomainId() {
-    return this.domainId;
-  }
-
-  public Domain setDomainId(@org.apache.thrift.annotation.Nullable String domainId) {
-    this.domainId = domainId;
-    return this;
-  }
-
-  public void unsetDomainId() {
-    this.domainId = null;
-  }
-
-  /** Returns true if field domainId is set (has been assigned a value) and false otherwise */
-  public boolean isSetDomainId() {
-    return this.domainId != null;
-  }
-
-  public void setDomainIdIsSet(boolean value) {
-    if (!value) {
-      this.domainId = null;
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getName() {
-    return this.name;
-  }
-
-  public Domain setName(@org.apache.thrift.annotation.Nullable String name) {
-    this.name = name;
-    return this;
-  }
-
-  public void unsetName() {
-    this.name = null;
-  }
-
-  /** Returns true if field name is set (has been assigned a value) and false otherwise */
-  public boolean isSetName() {
-    return this.name != null;
-  }
-
-  public void setNameIsSet(boolean value) {
-    if (!value) {
-      this.name = null;
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getDescription() {
-    return this.description;
-  }
-
-  public Domain setDescription(@org.apache.thrift.annotation.Nullable 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 long getCreatedTime() {
-    return this.createdTime;
-  }
-
-  public Domain setCreatedTime(long createdTime) {
-    this.createdTime = createdTime;
-    setCreatedTimeIsSet(true);
-    return this;
-  }
-
-  public void unsetCreatedTime() {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CREATEDTIME_ISSET_ID);
-  }
-
-  /** Returns true if field createdTime is set (has been assigned a value) and false otherwise */
-  public boolean isSetCreatedTime() {
-    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CREATEDTIME_ISSET_ID);
-  }
-
-  public void setCreatedTimeIsSet(boolean value) {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CREATEDTIME_ISSET_ID, value);
-  }
-
-  public long getUpdatedTime() {
-    return this.updatedTime;
-  }
-
-  public Domain setUpdatedTime(long updatedTime) {
-    this.updatedTime = updatedTime;
-    setUpdatedTimeIsSet(true);
-    return this;
-  }
-
-  public void unsetUpdatedTime() {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID);
-  }
-
-  /** Returns true if field updatedTime is set (has been assigned a value) and false otherwise */
-  public boolean isSetUpdatedTime() {
-    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID);
-  }
-
-  public void setUpdatedTimeIsSet(boolean value) {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID, value);
-  }
-
-  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
-    switch (field) {
-    case DOMAIN_ID:
-      if (value == null) {
-        unsetDomainId();
-      } else {
-        setDomainId((String)value);
-      }
-      break;
-
-    case NAME:
-      if (value == null) {
-        unsetName();
-      } else {
-        setName((String)value);
-      }
-      break;
-
-    case DESCRIPTION:
-      if (value == null) {
-        unsetDescription();
-      } else {
-        setDescription((String)value);
-      }
-      break;
-
-    case CREATED_TIME:
-      if (value == null) {
-        unsetCreatedTime();
-      } else {
-        setCreatedTime((Long)value);
-      }
-      break;
-
-    case UPDATED_TIME:
-      if (value == null) {
-        unsetUpdatedTime();
-      } else {
-        setUpdatedTime((Long)value);
-      }
-      break;
-
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public Object getFieldValue(_Fields field) {
-    switch (field) {
-    case DOMAIN_ID:
-      return getDomainId();
-
-    case NAME:
-      return getName();
-
-    case DESCRIPTION:
-      return getDescription();
-
-    case CREATED_TIME:
-      return getCreatedTime();
-
-    case UPDATED_TIME:
-      return getUpdatedTime();
-
-    }
-    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 DOMAIN_ID:
-      return isSetDomainId();
-    case NAME:
-      return isSetName();
-    case DESCRIPTION:
-      return isSetDescription();
-    case CREATED_TIME:
-      return isSetCreatedTime();
-    case UPDATED_TIME:
-      return isSetUpdatedTime();
-    }
-    throw new IllegalStateException();
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof Domain)
-      return this.equals((Domain)that);
-    return false;
-  }
-
-  public boolean equals(Domain that) {
-    if (that == null)
-      return false;
-    if (this == that)
-      return true;
-
-    boolean this_present_domainId = true && this.isSetDomainId();
-    boolean that_present_domainId = true && that.isSetDomainId();
-    if (this_present_domainId || that_present_domainId) {
-      if (!(this_present_domainId && that_present_domainId))
-        return false;
-      if (!this.domainId.equals(that.domainId))
-        return false;
-    }
-
-    boolean this_present_name = true && this.isSetName();
-    boolean that_present_name = true && that.isSetName();
-    if (this_present_name || that_present_name) {
-      if (!(this_present_name && that_present_name))
-        return false;
-      if (!this.name.equals(that.name))
-        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_createdTime = true && this.isSetCreatedTime();
-    boolean that_present_createdTime = true && that.isSetCreatedTime();
-    if (this_present_createdTime || that_present_createdTime) {
-      if (!(this_present_createdTime && that_present_createdTime))
-        return false;
-      if (this.createdTime != that.createdTime)
-        return false;
-    }
-
-    boolean this_present_updatedTime = true && this.isSetUpdatedTime();
-    boolean that_present_updatedTime = true && that.isSetUpdatedTime();
-    if (this_present_updatedTime || that_present_updatedTime) {
-      if (!(this_present_updatedTime && that_present_updatedTime))
-        return false;
-      if (this.updatedTime != that.updatedTime)
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int hashCode = 1;
-
-    hashCode = hashCode * 8191 + ((isSetDomainId()) ? 131071 : 524287);
-    if (isSetDomainId())
-      hashCode = hashCode * 8191 + domainId.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287);
-    if (isSetName())
-      hashCode = hashCode * 8191 + name.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetDescription()) ? 131071 : 524287);
-    if (isSetDescription())
-      hashCode = hashCode * 8191 + description.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetCreatedTime()) ? 131071 : 524287);
-    if (isSetCreatedTime())
-      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(createdTime);
-
-    hashCode = hashCode * 8191 + ((isSetUpdatedTime()) ? 131071 : 524287);
-    if (isSetUpdatedTime())
-      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(updatedTime);
-
-    return hashCode;
-  }
-
-  @Override
-  public int compareTo(Domain other) {
-    if (!getClass().equals(other.getClass())) {
-      return getClass().getName().compareTo(other.getClass().getName());
-    }
-
-    int lastComparison = 0;
-
-    lastComparison = Boolean.valueOf(isSetDomainId()).compareTo(other.isSetDomainId());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetDomainId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.domainId, other.domainId);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetName()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name);
-      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;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetCreatedTime()).compareTo(other.isSetCreatedTime());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetCreatedTime()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createdTime, other.createdTime);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetUpdatedTime()).compareTo(other.isSetUpdatedTime());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetUpdatedTime()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updatedTime, other.updatedTime);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    return 0;
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public _Fields fieldForId(int fieldId) {
-    return _Fields.findByThriftId(fieldId);
-  }
-
-  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
-    scheme(iprot).read(iprot, this);
-  }
-
-  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-    scheme(oprot).write(oprot, this);
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("Domain(");
-    boolean first = true;
-
-    if (isSetDomainId()) {
-      sb.append("domainId:");
-      if (this.domainId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.domainId);
-      }
-      first = false;
-    }
-    if (isSetName()) {
-      if (!first) sb.append(", ");
-      sb.append("name:");
-      if (this.name == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.name);
-      }
-      first = false;
-    }
-    if (isSetDescription()) {
-      if (!first) sb.append(", ");
-      sb.append("description:");
-      if (this.description == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.description);
-      }
-      first = false;
-    }
-    if (isSetCreatedTime()) {
-      if (!first) sb.append(", ");
-      sb.append("createdTime:");
-      sb.append(this.createdTime);
-      first = false;
-    }
-    if (isSetUpdatedTime()) {
-      if (!first) sb.append(", ");
-      sb.append("updatedTime:");
-      sb.append(this.updatedTime);
-      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 {
-      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
-      __isset_bitfield = 0;
-      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 DomainStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public DomainStandardScheme getScheme() {
-      return new DomainStandardScheme();
-    }
-  }
-
-  private static class DomainStandardScheme extends org.apache.thrift.scheme.StandardScheme<Domain> {
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot, Domain 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: // DOMAIN_ID
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.domainId = iprot.readString();
-              struct.setDomainIdIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 2: // NAME
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.name = iprot.readString();
-              struct.setNameIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 3: // 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 4: // CREATED_TIME
-            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
-              struct.createdTime = iprot.readI64();
-              struct.setCreatedTimeIsSet(true);
-            } else { 
-              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
-            }
-            break;
-          case 5: // UPDATED_TIME
-            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
-              struct.updatedTime = iprot.readI64();
-              struct.setUpdatedTimeIsSet(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, Domain struct) throws org.apache.thrift.TException {
-      struct.validate();
-
-      oprot.writeStructBegin(STRUCT_DESC);
-      if (struct.domainId != null) {
-        if (struct.isSetDomainId()) {
-          oprot.writeFieldBegin(DOMAIN_ID_FIELD_DESC);
-          oprot.writeString(struct.domainId);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.name != null) {
-        if (struct.isSetName()) {
-          oprot.writeFieldBegin(NAME_FIELD_DESC);
-          oprot.writeString(struct.name);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.description != null) {
-        if (struct.isSetDescription()) {
-          oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC);
-          oprot.writeString(struct.description);
-          oprot.writeFieldEnd();
-        }
-      }
-      if (struct.isSetCreatedTime()) {
-        oprot.writeFieldBegin(CREATED_TIME_FIELD_DESC);
-        oprot.writeI64(struct.createdTime);
-        oprot.writeFieldEnd();
-      }
-      if (struct.isSetUpdatedTime()) {
-        oprot.writeFieldBegin(UPDATED_TIME_FIELD_DESC);
-        oprot.writeI64(struct.updatedTime);
-        oprot.writeFieldEnd();
-      }
-      oprot.writeFieldStop();
-      oprot.writeStructEnd();
-    }
-
-  }
-
-  private static class DomainTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public DomainTupleScheme getScheme() {
-      return new DomainTupleScheme();
-    }
-  }
-
-  private static class DomainTupleScheme extends org.apache.thrift.scheme.TupleScheme<Domain> {
-
-    @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, Domain struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      java.util.BitSet optionals = new java.util.BitSet();
-      if (struct.isSetDomainId()) {
-        optionals.set(0);
-      }
-      if (struct.isSetName()) {
-        optionals.set(1);
-      }
-      if (struct.isSetDescription()) {
-        optionals.set(2);
-      }
-      if (struct.isSetCreatedTime()) {
-        optionals.set(3);
-      }
-      if (struct.isSetUpdatedTime()) {
-        optionals.set(4);
-      }
-      oprot.writeBitSet(optionals, 5);
-      if (struct.isSetDomainId()) {
-        oprot.writeString(struct.domainId);
-      }
-      if (struct.isSetName()) {
-        oprot.writeString(struct.name);
-      }
-      if (struct.isSetDescription()) {
-        oprot.writeString(struct.description);
-      }
-      if (struct.isSetCreatedTime()) {
-        oprot.writeI64(struct.createdTime);
-      }
-      if (struct.isSetUpdatedTime()) {
-        oprot.writeI64(struct.updatedTime);
-      }
-    }
-
-    @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, Domain struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      java.util.BitSet incoming = iprot.readBitSet(5);
-      if (incoming.get(0)) {
-        struct.domainId = iprot.readString();
-        struct.setDomainIdIsSet(true);
-      }
-      if (incoming.get(1)) {
-        struct.name = iprot.readString();
-        struct.setNameIsSet(true);
-      }
-      if (incoming.get(2)) {
-        struct.description = iprot.readString();
-        struct.setDescriptionIsSet(true);
-      }
-      if (incoming.get(3)) {
-        struct.createdTime = iprot.readI64();
-        struct.setCreatedTimeIsSet(true);
-      }
-      if (incoming.get(4)) {
-        struct.updatedTime = iprot.readI64();
-        struct.setUpdatedTimeIsSet(true);
-      }
-    }
-  }
-
-  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-  }
-}
-
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/DuplicateEntryException.java b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/DuplicateEntryException.java
deleted file mode 100644
index bcbf29a..0000000
--- a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/DuplicateEntryException.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/**
- * Autogenerated by Thrift Compiler (0.12.0)
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- *  @generated
- */
-package org.apache.custos.sharing.registry.models;
-
-@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-/**
- * This exception is thrown when you try to save a duplicate entity that already exists
- *   in the database.
- * 
- *   message: contains the associated error message
- * 
- */
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-13")
-public class DuplicateEntryException extends org.apache.thrift.TException implements org.apache.thrift.TBase<DuplicateEntryException, DuplicateEntryException._Fields>, java.io.Serializable, Cloneable, Comparable<DuplicateEntryException> {
-  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("DuplicateEntryException");
-
-  private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
-
-  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new DuplicateEntryExceptionStandardSchemeFactory();
-  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new DuplicateEntryExceptionTupleSchemeFactory();
-
-  public @org.apache.thrift.annotation.Nullable String message; // 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 {
-    MESSAGE((short)1, "message");
-
-    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-    static {
-      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
-        byName.put(field.getFieldName(), field);
-      }
-    }
-
-    /**
-     * Find the _Fields constant that matches fieldId, or null if its not found.
-     */
-    @org.apache.thrift.annotation.Nullable
-    public static _Fields findByThriftId(int fieldId) {
-      switch(fieldId) {
-        case 1: // MESSAGE
-          return MESSAGE;
-        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.
-     */
-    @org.apache.thrift.annotation.Nullable
-    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 java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-  static {
-    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.REQUIRED, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(DuplicateEntryException.class, metaDataMap);
-  }
-
-  public DuplicateEntryException() {
-  }
-
-  public DuplicateEntryException(
-    String message)
-  {
-    this();
-    this.message = message;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public DuplicateEntryException(DuplicateEntryException other) {
-    if (other.isSetMessage()) {
-      this.message = other.message;
-    }
-  }
-
-  public DuplicateEntryException deepCopy() {
-    return new DuplicateEntryException(this);
-  }
-
-  @Override
-  public void clear() {
-    this.message = null;
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getMessage() {
-    return this.message;
-  }
-
-  public DuplicateEntryException setMessage(@org.apache.thrift.annotation.Nullable String message) {
-    this.message = message;
-    return this;
-  }
-
-  public void unsetMessage() {
-    this.message = null;
-  }
-
-  /** Returns true if field message is set (has been assigned a value) and false otherwise */
-  public boolean isSetMessage() {
-    return this.message != null;
-  }
-
-  public void setMessageIsSet(boolean value) {
-    if (!value) {
-      this.message = null;
-    }
-  }
-
-  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
-    switch (field) {
-    case MESSAGE:
-      if (value == null) {
-        unsetMessage();
-      } else {
-        setMessage((String)value);
-      }
-      break;
-
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public Object getFieldValue(_Fields field) {
-    switch (field) {
-    case MESSAGE:
-      return getMessage();
-
-    }
-    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 MESSAGE:
-      return isSetMessage();
-    }
-    throw new IllegalStateException();
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof DuplicateEntryException)
-      return this.equals((DuplicateEntryException)that);
-    return false;
-  }
-
-  public boolean equals(DuplicateEntryException that) {
-    if (that == null)
-      return false;
-    if (this == that)
-      return true;
-
-    boolean this_present_message = true && this.isSetMessage();
-    boolean that_present_message = true && that.isSetMessage();
-    if (this_present_message || that_present_message) {
-      if (!(this_present_message && that_present_message))
-        return false;
-      if (!this.message.equals(that.message))
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int hashCode = 1;
-
-    hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
-    if (isSetMessage())
-      hashCode = hashCode * 8191 + message.hashCode();
-
-    return hashCode;
-  }
-
-  @Override
-  public int compareTo(DuplicateEntryException other) {
-    if (!getClass().equals(other.getClass())) {
-      return getClass().getName().compareTo(other.getClass().getName());
-    }
-
-    int lastComparison = 0;
-
-    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetMessage()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message, other.message);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    return 0;
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public _Fields fieldForId(int fieldId) {
-    return _Fields.findByThriftId(fieldId);
-  }
-
-  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
-    scheme(iprot).read(iprot, this);
-  }
-
-  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-    scheme(oprot).write(oprot, this);
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("DuplicateEntryException(");
-    boolean first = true;
-
-    sb.append("message:");
-    if (this.message == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.message);
-    }
-    first = false;
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public void validate() throws org.apache.thrift.TException {
-    // check for required fields
-    if (message == null) {
-      throw new org.apache.thrift.protocol.TProtocolException("Required field 'message' was not present! Struct: " + toString());
-    }
-    // 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 DuplicateEntryExceptionStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public DuplicateEntryExceptionStandardScheme getScheme() {
-      return new DuplicateEntryExceptionStandardScheme();
-    }
-  }
-
-  private static class DuplicateEntryExceptionStandardScheme extends org.apache.thrift.scheme.StandardScheme<DuplicateEntryException> {
-
-    public void read(org.apache.thrift.protocol.TProtocol iprot, DuplicateEntryException 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: // MESSAGE
-            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
-              struct.message = iprot.readString();
-              struct.setMessageIsSet(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, DuplicateEntryException struct) throws org.apache.thrift.TException {
-      struct.validate();
-
-      oprot.writeStructBegin(STRUCT_DESC);
-      if (struct.message != null) {
-        oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
-        oprot.writeString(struct.message);
-        oprot.writeFieldEnd();
-      }
-      oprot.writeFieldStop();
-      oprot.writeStructEnd();
-    }
-
-  }
-
-  private static class DuplicateEntryExceptionTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
-    public DuplicateEntryExceptionTupleScheme getScheme() {
-      return new DuplicateEntryExceptionTupleScheme();
-    }
-  }
-
-  private static class DuplicateEntryExceptionTupleScheme extends org.apache.thrift.scheme.TupleScheme<DuplicateEntryException> {
-
-    @Override
-    public void write(org.apache.thrift.protocol.TProtocol prot, DuplicateEntryException struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      oprot.writeString(struct.message);
-    }
-
-    @Override
-    public void read(org.apache.thrift.protocol.TProtocol prot, DuplicateEntryException struct) throws org.apache.thrift.TException {
-      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
-      struct.message = iprot.readString();
-      struct.setMessageIsSet(true);
-    }
-  }
-
-  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
-    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
-  }
-}
-
diff --git a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Entity.java b/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Entity.java
deleted file mode 100644
index 613ea5d..0000000
--- a/custos-sharing-registry-service/sharing-registry-stubs/src/main/java/org/apache/custos/sharing/registry/models/Entity.java
+++ /dev/null
@@ -1,1663 +0,0 @@
-/**
- * Autogenerated by Thrift Compiler (0.12.0)
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- *  @generated
- */
-package org.apache.custos.sharing.registry.models;
-
-@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-/**
- * <p>Entity object which is used to register an entity in the system.</p>
- * <li><b>entityId</b> : Entity id provided by the client</li>
- * <li><b>domainId</b> : Domain id</li>
- * <li><b>entityTypeId</b> : Entity type id</li>
- * <li><b>ownerId</b> : Owner id</li>
- * <li>parentEntityId : Parent entity id</li>
- * <li><b>name</b> : Name</li>
- * <li>description : Short description for the entity</li>
- * <li>binaryData : Any information stored in binary format</li>
- * <li>fullText : A string which will be considered for full text search</li>
- * <li><b>originalEntityCreationTime</b> : When registering old records what is the original entity creation time. If not
- * set will be default to current time</li>
- * <li>createdTime : Will be set by the system</li>
- * <li>updatedTime : Will be set by the system</li>
- * 
- */
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.12.0)", date = "2019-08-13")
-public class Entity implements org.apache.thrift.TBase<Entity, Entity._Fields>, java.io.Serializable, Cloneable, Comparable<Entity> {
-  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Entity");
-
-  private static final org.apache.thrift.protocol.TField ENTITY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("entityId", org.apache.thrift.protocol.TType.STRING, (short)1);
-  private static final org.apache.thrift.protocol.TField DOMAIN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("domainId", org.apache.thrift.protocol.TType.STRING, (short)2);
-  private static final org.apache.thrift.protocol.TField ENTITY_TYPE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("entityTypeId", org.apache.thrift.protocol.TType.STRING, (short)3);
-  private static final org.apache.thrift.protocol.TField OWNER_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("ownerId", org.apache.thrift.protocol.TType.STRING, (short)4);
-  private static final org.apache.thrift.protocol.TField PARENT_ENTITY_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("parentEntityId", org.apache.thrift.protocol.TType.STRING, (short)5);
-  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)6);
-  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)7);
-  private static final org.apache.thrift.protocol.TField BINARY_DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("binaryData", org.apache.thrift.protocol.TType.STRING, (short)8);
-  private static final org.apache.thrift.protocol.TField FULL_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("fullText", org.apache.thrift.protocol.TType.STRING, (short)9);
-  private static final org.apache.thrift.protocol.TField SHARED_COUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("sharedCount", org.apache.thrift.protocol.TType.I64, (short)10);
-  private static final org.apache.thrift.protocol.TField ORIGINAL_ENTITY_CREATION_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("originalEntityCreationTime", org.apache.thrift.protocol.TType.I64, (short)11);
-  private static final org.apache.thrift.protocol.TField CREATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createdTime", org.apache.thrift.protocol.TType.I64, (short)12);
-  private static final org.apache.thrift.protocol.TField UPDATED_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedTime", org.apache.thrift.protocol.TType.I64, (short)13);
-
-  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new EntityStandardSchemeFactory();
-  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new EntityTupleSchemeFactory();
-
-  public @org.apache.thrift.annotation.Nullable String entityId; // optional
-  public @org.apache.thrift.annotation.Nullable String domainId; // optional
-  public @org.apache.thrift.annotation.Nullable String entityTypeId; // optional
-  public @org.apache.thrift.annotation.Nullable String ownerId; // optional
-  public @org.apache.thrift.annotation.Nullable String parentEntityId; // optional
-  public @org.apache.thrift.annotation.Nullable String name; // optional
-  public @org.apache.thrift.annotation.Nullable String description; // optional
-  public @org.apache.thrift.annotation.Nullable java.nio.ByteBuffer binaryData; // optional
-  public @org.apache.thrift.annotation.Nullable String fullText; // optional
-  public long sharedCount; // optional
-  public long originalEntityCreationTime; // optional
-  public long createdTime; // optional
-  public long updatedTime; // optional
-
-  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
-  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
-    ENTITY_ID((short)1, "entityId"),
-    DOMAIN_ID((short)2, "domainId"),
-    ENTITY_TYPE_ID((short)3, "entityTypeId"),
-    OWNER_ID((short)4, "ownerId"),
-    PARENT_ENTITY_ID((short)5, "parentEntityId"),
-    NAME((short)6, "name"),
-    DESCRIPTION((short)7, "description"),
-    BINARY_DATA((short)8, "binaryData"),
-    FULL_TEXT((short)9, "fullText"),
-    SHARED_COUNT((short)10, "sharedCount"),
-    ORIGINAL_ENTITY_CREATION_TIME((short)11, "originalEntityCreationTime"),
-    CREATED_TIME((short)12, "createdTime"),
-    UPDATED_TIME((short)13, "updatedTime");
-
-    private static final java.util.Map<String, _Fields> byName = new java.util.HashMap<String, _Fields>();
-
-    static {
-      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
-        byName.put(field.getFieldName(), field);
-      }
-    }
-
-    /**
-     * Find the _Fields constant that matches fieldId, or null if its not found.
-     */
-    @org.apache.thrift.annotation.Nullable
-    public static _Fields findByThriftId(int fieldId) {
-      switch(fieldId) {
-        case 1: // ENTITY_ID
-          return ENTITY_ID;
-        case 2: // DOMAIN_ID
-          return DOMAIN_ID;
-        case 3: // ENTITY_TYPE_ID
-          return ENTITY_TYPE_ID;
-        case 4: // OWNER_ID
-          return OWNER_ID;
-        case 5: // PARENT_ENTITY_ID
-          return PARENT_ENTITY_ID;
-        case 6: // NAME
-          return NAME;
-        case 7: // DESCRIPTION
-          return DESCRIPTION;
-        case 8: // BINARY_DATA
-          return BINARY_DATA;
-        case 9: // FULL_TEXT
-          return FULL_TEXT;
-        case 10: // SHARED_COUNT
-          return SHARED_COUNT;
-        case 11: // ORIGINAL_ENTITY_CREATION_TIME
-          return ORIGINAL_ENTITY_CREATION_TIME;
-        case 12: // CREATED_TIME
-          return CREATED_TIME;
-        case 13: // UPDATED_TIME
-          return UPDATED_TIME;
-        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.
-     */
-    @org.apache.thrift.annotation.Nullable
-    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
-  private static final int __SHAREDCOUNT_ISSET_ID = 0;
-  private static final int __ORIGINALENTITYCREATIONTIME_ISSET_ID = 1;
-  private static final int __CREATEDTIME_ISSET_ID = 2;
-  private static final int __UPDATEDTIME_ISSET_ID = 3;
-  private byte __isset_bitfield = 0;
-  private static final _Fields optionals[] = {_Fields.ENTITY_ID,_Fields.DOMAIN_ID,_Fields.ENTITY_TYPE_ID,_Fields.OWNER_ID,_Fields.PARENT_ENTITY_ID,_Fields.NAME,_Fields.DESCRIPTION,_Fields.BINARY_DATA,_Fields.FULL_TEXT,_Fields.SHARED_COUNT,_Fields.ORIGINAL_ENTITY_CREATION_TIME,_Fields.CREATED_TIME,_Fields.UPDATED_TIME};
-  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
-  static {
-    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
-    tmpMap.put(_Fields.ENTITY_ID, new org.apache.thrift.meta_data.FieldMetaData("entityId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.DOMAIN_ID, new org.apache.thrift.meta_data.FieldMetaData("domainId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.ENTITY_TYPE_ID, new org.apache.thrift.meta_data.FieldMetaData("entityTypeId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.OWNER_ID, new org.apache.thrift.meta_data.FieldMetaData("ownerId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.PARENT_ENTITY_ID, new org.apache.thrift.meta_data.FieldMetaData("parentEntityId", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        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.BINARY_DATA, new org.apache.thrift.meta_data.FieldMetaData("binaryData", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
-    tmpMap.put(_Fields.FULL_TEXT, new org.apache.thrift.meta_data.FieldMetaData("fullText", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
-    tmpMap.put(_Fields.SHARED_COUNT, new org.apache.thrift.meta_data.FieldMetaData("sharedCount", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    tmpMap.put(_Fields.ORIGINAL_ENTITY_CREATION_TIME, new org.apache.thrift.meta_data.FieldMetaData("originalEntityCreationTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    tmpMap.put(_Fields.CREATED_TIME, new org.apache.thrift.meta_data.FieldMetaData("createdTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    tmpMap.put(_Fields.UPDATED_TIME, new org.apache.thrift.meta_data.FieldMetaData("updatedTime", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
-        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
-    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
-    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Entity.class, metaDataMap);
-  }
-
-  public Entity() {
-    this.sharedCount = 0L;
-
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public Entity(Entity other) {
-    __isset_bitfield = other.__isset_bitfield;
-    if (other.isSetEntityId()) {
-      this.entityId = other.entityId;
-    }
-    if (other.isSetDomainId()) {
-      this.domainId = other.domainId;
-    }
-    if (other.isSetEntityTypeId()) {
-      this.entityTypeId = other.entityTypeId;
-    }
-    if (other.isSetOwnerId()) {
-      this.ownerId = other.ownerId;
-    }
-    if (other.isSetParentEntityId()) {
-      this.parentEntityId = other.parentEntityId;
-    }
-    if (other.isSetName()) {
-      this.name = other.name;
-    }
-    if (other.isSetDescription()) {
-      this.description = other.description;
-    }
-    if (other.isSetBinaryData()) {
-      this.binaryData = org.apache.thrift.TBaseHelper.copyBinary(other.binaryData);
-    }
-    if (other.isSetFullText()) {
-      this.fullText = other.fullText;
-    }
-    this.sharedCount = other.sharedCount;
-    this.originalEntityCreationTime = other.originalEntityCreationTime;
-    this.createdTime = other.createdTime;
-    this.updatedTime = other.updatedTime;
-  }
-
-  public Entity deepCopy() {
-    return new Entity(this);
-  }
-
-  @Override
-  public void clear() {
-    this.entityId = null;
-    this.domainId = null;
-    this.entityTypeId = null;
-    this.ownerId = null;
-    this.parentEntityId = null;
-    this.name = null;
-    this.description = null;
-    this.binaryData = null;
-    this.fullText = null;
-    this.sharedCount = 0L;
-
-    setOriginalEntityCreationTimeIsSet(false);
-    this.originalEntityCreationTime = 0;
-    setCreatedTimeIsSet(false);
-    this.createdTime = 0;
-    setUpdatedTimeIsSet(false);
-    this.updatedTime = 0;
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getEntityId() {
-    return this.entityId;
-  }
-
-  public Entity setEntityId(@org.apache.thrift.annotation.Nullable String entityId) {
-    this.entityId = entityId;
-    return this;
-  }
-
-  public void unsetEntityId() {
-    this.entityId = null;
-  }
-
-  /** Returns true if field entityId is set (has been assigned a value) and false otherwise */
-  public boolean isSetEntityId() {
-    return this.entityId != null;
-  }
-
-  public void setEntityIdIsSet(boolean value) {
-    if (!value) {
-      this.entityId = null;
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getDomainId() {
-    return this.domainId;
-  }
-
-  public Entity setDomainId(@org.apache.thrift.annotation.Nullable String domainId) {
-    this.domainId = domainId;
-    return this;
-  }
-
-  public void unsetDomainId() {
-    this.domainId = null;
-  }
-
-  /** Returns true if field domainId is set (has been assigned a value) and false otherwise */
-  public boolean isSetDomainId() {
-    return this.domainId != null;
-  }
-
-  public void setDomainIdIsSet(boolean value) {
-    if (!value) {
-      this.domainId = null;
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getEntityTypeId() {
-    return this.entityTypeId;
-  }
-
-  public Entity setEntityTypeId(@org.apache.thrift.annotation.Nullable String entityTypeId) {
-    this.entityTypeId = entityTypeId;
-    return this;
-  }
-
-  public void unsetEntityTypeId() {
-    this.entityTypeId = null;
-  }
-
-  /** Returns true if field entityTypeId is set (has been assigned a value) and false otherwise */
-  public boolean isSetEntityTypeId() {
-    return this.entityTypeId != null;
-  }
-
-  public void setEntityTypeIdIsSet(boolean value) {
-    if (!value) {
-      this.entityTypeId = null;
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getOwnerId() {
-    return this.ownerId;
-  }
-
-  public Entity setOwnerId(@org.apache.thrift.annotation.Nullable String ownerId) {
-    this.ownerId = ownerId;
-    return this;
-  }
-
-  public void unsetOwnerId() {
-    this.ownerId = null;
-  }
-
-  /** Returns true if field ownerId is set (has been assigned a value) and false otherwise */
-  public boolean isSetOwnerId() {
-    return this.ownerId != null;
-  }
-
-  public void setOwnerIdIsSet(boolean value) {
-    if (!value) {
-      this.ownerId = null;
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getParentEntityId() {
-    return this.parentEntityId;
-  }
-
-  public Entity setParentEntityId(@org.apache.thrift.annotation.Nullable String parentEntityId) {
-    this.parentEntityId = parentEntityId;
-    return this;
-  }
-
-  public void unsetParentEntityId() {
-    this.parentEntityId = null;
-  }
-
-  /** Returns true if field parentEntityId is set (has been assigned a value) and false otherwise */
-  public boolean isSetParentEntityId() {
-    return this.parentEntityId != null;
-  }
-
-  public void setParentEntityIdIsSet(boolean value) {
-    if (!value) {
-      this.parentEntityId = null;
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getName() {
-    return this.name;
-  }
-
-  public Entity setName(@org.apache.thrift.annotation.Nullable String name) {
-    this.name = name;
-    return this;
-  }
-
-  public void unsetName() {
-    this.name = null;
-  }
-
-  /** Returns true if field name is set (has been assigned a value) and false otherwise */
-  public boolean isSetName() {
-    return this.name != null;
-  }
-
-  public void setNameIsSet(boolean value) {
-    if (!value) {
-      this.name = null;
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getDescription() {
-    return this.description;
-  }
-
-  public Entity setDescription(@org.apache.thrift.annotation.Nullable 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 byte[] getBinaryData() {
-    setBinaryData(org.apache.thrift.TBaseHelper.rightSize(binaryData));
-    return binaryData == null ? null : binaryData.array();
-  }
-
-  public java.nio.ByteBuffer bufferForBinaryData() {
-    return org.apache.thrift.TBaseHelper.copyBinary(binaryData);
-  }
-
-  public Entity setBinaryData(byte[] binaryData) {
-    this.binaryData = binaryData == null ? (java.nio.ByteBuffer)null   : java.nio.ByteBuffer.wrap(binaryData.clone());
-    return this;
-  }
-
-  public Entity setBinaryData(@org.apache.thrift.annotation.Nullable java.nio.ByteBuffer binaryData) {
-    this.binaryData = org.apache.thrift.TBaseHelper.copyBinary(binaryData);
-    return this;
-  }
-
-  public void unsetBinaryData() {
-    this.binaryData = null;
-  }
-
-  /** Returns true if field binaryData is set (has been assigned a value) and false otherwise */
-  public boolean isSetBinaryData() {
-    return this.binaryData != null;
-  }
-
-  public void setBinaryDataIsSet(boolean value) {
-    if (!value) {
-      this.binaryData = null;
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public String getFullText() {
-    return this.fullText;
-  }
-
-  public Entity setFullText(@org.apache.thrift.annotation.Nullable String fullText) {
-    this.fullText = fullText;
-    return this;
-  }
-
-  public void unsetFullText() {
-    this.fullText = null;
-  }
-
-  /** Returns true if field fullText is set (has been assigned a value) and false otherwise */
-  public boolean isSetFullText() {
-    return this.fullText != null;
-  }
-
-  public void setFullTextIsSet(boolean value) {
-    if (!value) {
-      this.fullText = null;
-    }
-  }
-
-  public long getSharedCount() {
-    return this.sharedCount;
-  }
-
-  public Entity setSharedCount(long sharedCount) {
-    this.sharedCount = sharedCount;
-    setSharedCountIsSet(true);
-    return this;
-  }
-
-  public void unsetSharedCount() {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SHAREDCOUNT_ISSET_ID);
-  }
-
-  /** Returns true if field sharedCount is set (has been assigned a value) and false otherwise */
-  public boolean isSetSharedCount() {
-    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SHAREDCOUNT_ISSET_ID);
-  }
-
-  public void setSharedCountIsSet(boolean value) {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SHAREDCOUNT_ISSET_ID, value);
-  }
-
-  public long getOriginalEntityCreationTime() {
-    return this.originalEntityCreationTime;
-  }
-
-  public Entity setOriginalEntityCreationTime(long originalEntityCreationTime) {
-    this.originalEntityCreationTime = originalEntityCreationTime;
-    setOriginalEntityCreationTimeIsSet(true);
-    return this;
-  }
-
-  public void unsetOriginalEntityCreationTime() {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ORIGINALENTITYCREATIONTIME_ISSET_ID);
-  }
-
-  /** Returns true if field originalEntityCreationTime is set (has been assigned a value) and false otherwise */
-  public boolean isSetOriginalEntityCreationTime() {
-    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ORIGINALENTITYCREATIONTIME_ISSET_ID);
-  }
-
-  public void setOriginalEntityCreationTimeIsSet(boolean value) {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ORIGINALENTITYCREATIONTIME_ISSET_ID, value);
-  }
-
-  public long getCreatedTime() {
-    return this.createdTime;
-  }
-
-  public Entity setCreatedTime(long createdTime) {
-    this.createdTime = createdTime;
-    setCreatedTimeIsSet(true);
-    return this;
-  }
-
-  public void unsetCreatedTime() {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CREATEDTIME_ISSET_ID);
-  }
-
-  /** Returns true if field createdTime is set (has been assigned a value) and false otherwise */
-  public boolean isSetCreatedTime() {
-    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CREATEDTIME_ISSET_ID);
-  }
-
-  public void setCreatedTimeIsSet(boolean value) {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CREATEDTIME_ISSET_ID, value);
-  }
-
-  public long getUpdatedTime() {
-    return this.updatedTime;
-  }
-
-  public Entity setUpdatedTime(long updatedTime) {
-    this.updatedTime = updatedTime;
-    setUpdatedTimeIsSet(true);
-    return this;
-  }
-
-  public void unsetUpdatedTime() {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID);
-  }
-
-  /** Returns true if field updatedTime is set (has been assigned a value) and false otherwise */
-  public boolean isSetUpdatedTime() {
-    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID);
-  }
-
-  public void setUpdatedTimeIsSet(boolean value) {
-    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __UPDATEDTIME_ISSET_ID, value);
-  }
-
-  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable Object value) {
-    switch (field) {
-    case ENTITY_ID:
-      if (value == null) {
-        unsetEntityId();
-      } else {
-        setEntityId((String)value);
-      }
-      break;
-
-    case DOMAIN_ID:
-      if (value == null) {
-        unsetDomainId();
-      } else {
-        setDomainId((String)value);
-      }
-      break;
-
-    case ENTITY_TYPE_ID:
-      if (value == null) {
-        unsetEntityTypeId();
-      } else {
-        setEntityTypeId((String)value);
-      }
-      break;
-
-    case OWNER_ID:
-      if (value == null) {
-        unsetOwnerId();
-      } else {
-        setOwnerId((String)value);
-      }
-      break;
-
-    case PARENT_ENTITY_ID:
-      if (value == null) {
-        unsetParentEntityId();
-      } else {
-        setParentEntityId((String)value);
-      }
-      break;
-
-    case NAME:
-      if (value == null) {
-        unsetName();
-      } else {
-        setName((String)value);
-      }
-      break;
-
-    case DESCRIPTION:
-      if (value == null) {
-        unsetDescription();
-      } else {
-        setDescription((String)value);
-      }
-      break;
-
-    case BINARY_DATA:
-      if (value == null) {
-        unsetBinaryData();
-      } else {
-        if (value instanceof byte[]) {
-          setBinaryData((byte[])value);
-        } else {
-          setBinaryData((java.nio.ByteBuffer)value);
-        }
-      }
-      break;
-
-    case FULL_TEXT:
-      if (value == null) {
-        unsetFullText();
-      } else {
-        setFullText((String)value);
-      }
-      break;
-
-    case SHARED_COUNT:
-      if (value == null) {
-        unsetSharedCount();
-      } else {
-        setSharedCount((Long)value);
-      }
-      break;
-
-    case ORIGINAL_ENTITY_CREATION_TIME:
-      if (value == null) {
-        unsetOriginalEntityCreationTime();
-      } else {
-        setOriginalEntityCreationTime((Long)value);
-      }
-      break;
-
-    case CREATED_TIME:
-      if (value == null) {
-        unsetCreatedTime();
-      } else {
-        setCreatedTime((Long)value);
-      }
-      break;
-
-    case UPDATED_TIME:
-      if (value == null) {
-        unsetUpdatedTime();
-      } else {
-        setUpdatedTime((Long)value);
-      }
-      break;
-
-    }
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public Object getFieldValue(_Fields field) {
-    switch (field) {
-    case ENTITY_ID:
-      return getEntityId();
-
-    case DOMAIN_ID:
-      return getDomainId();
-
-    case ENTITY_TYPE_ID:
-      return getEntityTypeId();
-
-    case OWNER_ID:
-      return getOwnerId();
-
-    case PARENT_ENTITY_ID:
-      return getParentEntityId();
-
-    case NAME:
-      return getName();
-
-    case DESCRIPTION:
-      return getDescription();
-
-    case BINARY_DATA:
-      return getBinaryData();
-
-    case FULL_TEXT:
-      return getFullText();
-
-    case SHARED_COUNT:
-      return getSharedCount();
-
-    case ORIGINAL_ENTITY_CREATION_TIME:
-      return getOriginalEntityCreationTime();
-
-    case CREATED_TIME:
-      return getCreatedTime();
-
-    case UPDATED_TIME:
-      return getUpdatedTime();
-
-    }
-    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 ENTITY_ID:
-      return isSetEntityId();
-    case DOMAIN_ID:
-      return isSetDomainId();
-    case ENTITY_TYPE_ID:
-      return isSetEntityTypeId();
-    case OWNER_ID:
-      return isSetOwnerId();
-    case PARENT_ENTITY_ID:
-      return isSetParentEntityId();
-    case NAME:
-      return isSetName();
-    case DESCRIPTION:
-      return isSetDescription();
-    case BINARY_DATA:
-      return isSetBinaryData();
-    case FULL_TEXT:
-      return isSetFullText();
-    case SHARED_COUNT:
-      return isSetSharedCount();
-    case ORIGINAL_ENTITY_CREATION_TIME:
-      return isSetOriginalEntityCreationTime();
-    case CREATED_TIME:
-      return isSetCreatedTime();
-    case UPDATED_TIME:
-      return isSetUpdatedTime();
-    }
-    throw new IllegalStateException();
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof Entity)
-      return this.equals((Entity)that);
-    return false;
-  }
-
-  public boolean equals(Entity that) {
-    if (that == null)
-      return false;
-    if (this == that)
-      return true;
-
-    boolean this_present_entityId = true && this.isSetEntityId();
-    boolean that_present_entityId = true && that.isSetEntityId();
-    if (this_present_entityId || that_present_entityId) {
-      if (!(this_present_entityId && that_present_entityId))
-        return false;
-      if (!this.entityId.equals(that.entityId))
-        return false;
-    }
-
-    boolean this_present_domainId = true && this.isSetDomainId();
-    boolean that_present_domainId = true && that.isSetDomainId();
-    if (this_present_domainId || that_present_domainId) {
-      if (!(this_present_domainId && that_present_domainId))
-        return false;
-      if (!this.domainId.equals(that.domainId))
-        return false;
-    }
-
-    boolean this_present_entityTypeId = true && this.isSetEntityTypeId();
-    boolean that_present_entityTypeId = true && that.isSetEntityTypeId();
-    if (this_present_entityTypeId || that_present_entityTypeId) {
-      if (!(this_present_entityTypeId && that_present_entityTypeId))
-        return false;
-      if (!this.entityTypeId.equals(that.entityTypeId))
-        return false;
-    }
-
-    boolean this_present_ownerId = true && this.isSetOwnerId();
-    boolean that_present_ownerId = true && that.isSetOwnerId();
-    if (this_present_ownerId || that_present_ownerId) {
-      if (!(this_present_ownerId && that_present_ownerId))
-        return false;
-      if (!this.ownerId.equals(that.ownerId))
-        return false;
-    }
-
-    boolean this_present_parentEntityId = true && this.isSetParentEntityId();
-    boolean that_present_parentEntityId = true && that.isSetParentEntityId();
-    if (this_present_parentEntityId || that_present_parentEntityId) {
-      if (!(this_present_parentEntityId && that_present_parentEntityId))
-        return false;
-      if (!this.parentEntityId.equals(that.parentEntityId))
-        return false;
-    }
-
-    boolean this_present_name = true && this.isSetName();
-    boolean that_present_name = true && that.isSetName();
-    if (this_present_name || that_present_name) {
-      if (!(this_present_name && that_present_name))
-        return false;
-      if (!this.name.equals(that.name))
-        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_binaryData = true && this.isSetBinaryData();
-    boolean that_present_binaryData = true && that.isSetBinaryData();
-    if (this_present_binaryData || that_present_binaryData) {
-      if (!(this_present_binaryData && that_present_binaryData))
-        return false;
-      if (!this.binaryData.equals(that.binaryData))
-        return false;
-    }
-
-    boolean this_present_fullText = true && this.isSetFullText();
-    boolean that_present_fullText = true && that.isSetFullText();
-    if (this_present_fullText || that_present_fullText) {
-      if (!(this_present_fullText && that_present_fullText))
-        return false;
-      if (!this.fullText.equals(that.fullText))
-        return false;
-    }
-
-    boolean this_present_sharedCount = true && this.isSetSharedCount();
-    boolean that_present_sharedCount = true && that.isSetSharedCount();
-    if (this_present_sharedCount || that_present_sharedCount) {
-      if (!(this_present_sharedCount && that_present_sharedCount))
-        return false;
-      if (this.sharedCount != that.sharedCount)
-        return false;
-    }
-
-    boolean this_present_originalEntityCreationTime = true && this.isSetOriginalEntityCreationTime();
-    boolean that_present_originalEntityCreationTime = true && that.isSetOriginalEntityCreationTime();
-    if (this_present_originalEntityCreationTime || that_present_originalEntityCreationTime) {
-      if (!(this_present_originalEntityCreationTime && that_present_originalEntityCreationTime))
-        return false;
-      if (this.originalEntityCreationTime != that.originalEntityCreationTime)
-        return false;
-    }
-
-    boolean this_present_createdTime = true && this.isSetCreatedTime();
-    boolean that_present_createdTime = true && that.isSetCreatedTime();
-    if (this_present_createdTime || that_present_createdTime) {
-      if (!(this_present_createdTime && that_present_createdTime))
-        return false;
-      if (this.createdTime != that.createdTime)
-        return false;
-    }
-
-    boolean this_present_updatedTime = true && this.isSetUpdatedTime();
-    boolean that_present_updatedTime = true && that.isSetUpdatedTime();
-    if (this_present_updatedTime || that_present_updatedTime) {
-      if (!(this_present_updatedTime && that_present_updatedTime))
-        return false;
-      if (this.updatedTime != that.updatedTime)
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    int hashCode = 1;
-
-    hashCode = hashCode * 8191 + ((isSetEntityId()) ? 131071 : 524287);
-    if (isSetEntityId())
-      hashCode = hashCode * 8191 + entityId.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetDomainId()) ? 131071 : 524287);
-    if (isSetDomainId())
-      hashCode = hashCode * 8191 + domainId.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetEntityTypeId()) ? 131071 : 524287);
-    if (isSetEntityTypeId())
-      hashCode = hashCode * 8191 + entityTypeId.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetOwnerId()) ? 131071 : 524287);
-    if (isSetOwnerId())
-      hashCode = hashCode * 8191 + ownerId.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetParentEntityId()) ? 131071 : 524287);
-    if (isSetParentEntityId())
-      hashCode = hashCode * 8191 + parentEntityId.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetName()) ? 131071 : 524287);
-    if (isSetName())
-      hashCode = hashCode * 8191 + name.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetDescription()) ? 131071 : 524287);
-    if (isSetDescription())
-      hashCode = hashCode * 8191 + description.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetBinaryData()) ? 131071 : 524287);
-    if (isSetBinaryData())
-      hashCode = hashCode * 8191 + binaryData.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetFullText()) ? 131071 : 524287);
-    if (isSetFullText())
-      hashCode = hashCode * 8191 + fullText.hashCode();
-
-    hashCode = hashCode * 8191 + ((isSetSharedCount()) ? 131071 : 524287);
-    if (isSetSharedCount())
-      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(sharedCount);
-
-    hashCode = hashCode * 8191 + ((isSetOriginalEntityCreationTime()) ? 131071 : 524287);
-    if (isSetOriginalEntityCreationTime())
-      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(originalEntityCreationTime);
-
-    hashCode = hashCode * 8191 + ((isSetCreatedTime()) ? 131071 : 524287);
-    if (isSetCreatedTime())
-      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(createdTime);
-
-    hashCode = hashCode * 8191 + ((isSetUpdatedTime()) ? 131071 : 524287);
-    if (isSetUpdatedTime())
-      hashCode = hashCode * 8191 + org.apache.thrift.TBaseHelper.hashCode(updatedTime);
-
-    return hashCode;
-  }
-
-  @Override
-  public int compareTo(Entity other) {
-    if (!getClass().equals(other.getClass())) {
-      return getClass().getName().compareTo(other.getClass().getName());
-    }
-
-    int lastComparison = 0;
-
-    lastComparison = Boolean.valueOf(isSetEntityId()).compareTo(other.isSetEntityId());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetEntityId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.entityId, other.entityId);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetDomainId()).compareTo(other.isSetDomainId());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetDomainId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.domainId, other.domainId);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetEntityTypeId()).compareTo(other.isSetEntityTypeId());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetEntityTypeId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.entityTypeId, other.entityTypeId);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetOwnerId()).compareTo(other.isSetOwnerId());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetOwnerId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ownerId, other.ownerId);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetParentEntityId()).compareTo(other.isSetParentEntityId());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetParentEntityId()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.parentEntityId, other.parentEntityId);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetName()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name);
-      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;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetBinaryData()).compareTo(other.isSetBinaryData());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetBinaryData()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.binaryData, other.binaryData);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetFullText()).compareTo(other.isSetFullText());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetFullText()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fullText, other.fullText);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetSharedCount()).compareTo(other.isSetSharedCount());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetSharedCount()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sharedCount, other.sharedCount);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetOriginalEntityCreationTime()).compareTo(other.isSetOriginalEntityCreationTime());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetOriginalEntityCreationTime()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.originalEntityCreationTime, other.originalEntityCreationTime);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetCreatedTime()).compareTo(other.isSetCreatedTime());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetCreatedTime()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createdTime, other.createdTime);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    lastComparison = Boolean.valueOf(isSetUpdatedTime()).compareTo(other.isSetUpdatedTime());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    if (isSetUpdatedTime()) {
-      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updatedTime, other.updatedTime);
-      if (lastComparison != 0) {
-        return lastComparison;
-      }
-    }
-    return 0;
-  }
-
-  @org.apache.thrift.annotation.Nullable
-  public _Fields fieldForId(int fieldId) {
-    return _Fields.findByThriftId(fieldId);
-  }
-
-  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
-    scheme(iprot).read(iprot, this);
-  }
-
-  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
-    scheme(oprot).write(oprot, this);
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("Entity(");
-    boolean first = true;
-
-    if (isSetEntityId()) {
-      sb.append("entityId:");
-      if (this.entityId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.entityId);
-      }
-      first = false;
-    }
-    if (isSetDomainId()) {
-      if (!first) sb.append(", ");
-      sb.append("domainId:");
-      if (this.domainId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.domainId);
-      }
-      first = false;
-    }
-    if (isSetEntityTypeId()) {
-      if (!first) sb.append(", ");
-      sb.append("entityTypeId:");
-      if (this.entityTypeId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.entityTypeId);
-      }
-      first = false;
-    }
-    if (isSetOwnerId()) {
-      if (!first) sb.append(", ");
-      sb.append("ownerId:");
-      if (this.ownerId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.ownerId);
-      }
-      first = false;
-    }
-    if (isSetParentEntityId()) {
-      if (!first) sb.append(", ");
-      sb.append("parentEntityId:");
-      if (this.parentEntityId == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.parentEntityId);
-      }
-      first = false;
-    }
-    if (isSetName()) {
-      if (!first) sb.append(", ");
-      sb.append("name:");
-      if (this.name == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.name);
-      }
-      first = false;
-    }
-    if (isSetDescription()) {
-      if (!first) sb.append(", ");
-      sb.append("description:");
-      if (this.description == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.description);
-      }
-      first = false;
-    }
-    if (isSetBinaryData()) {
-      if (!first) sb.append(", ");
-      sb.append("binaryData:");
-      if (this.binaryData == null) {
-        sb.append("null");
-      } else {
-        org.apache.thrift.TBaseHelper.toString(this.binaryData, sb);
-      }
-      first = false;
-    }
-    if (isSetFullText()) {
-      if (!first) sb.append(", ");
-      sb.append("fullText:");
-      if (this.fullText == null) {
-        sb.append("null");
-      } else {
-        sb.append(this.fullText);
-      }
-      first = false;
-    }
-    if (isSetSharedCount()) {
-      if (!first) sb.append(", ");
-      sb.append("sharedCount:");
-      sb.append(this.sharedCount);
-      first = false;
-    }
-    if (isSetOriginalEntityCreationTime()) {
-      if (!first) sb.append(", ");
-      sb.append("originalEntityCreationTime:");
-      sb.append(this.originalEntityCreationTime);
-      first = false;
-    }
-    if (isSetCreatedTime()) {
-      if (!first) sb.append(", ");
-      sb.append("createdTime:");
-      sb.append(this.createdTime);
-      first = false;
... 78275 lines suppressed ...


[airavata-custos] 06/48: added logging

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6c3fb74c159cc42d935625be7f1687aec6b6eaf9
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Jun 25 09:03:05 2019 -0400

    added logging
---
 .../src/main/resources/log4j.properties            | 41 ++++++++++++++++++++++
 pom.xml                                            | 10 ++++++
 2 files changed, 51 insertions(+)

diff --git a/custos-profile-service/profile-service-server/src/main/resources/log4j.properties b/custos-profile-service/profile-service-server/src/main/resources/log4j.properties
new file mode 100644
index 0000000..27a4f03
--- /dev/null
+++ b/custos-profile-service/profile-service-server/src/main/resources/log4j.properties
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+# Set root category priority to INFO and its only appender to CONSOLE.
+log4j.rootCategory=INFO, CONSOLE,LOGFILE
+log4j.rootLogger=INFO, CONSOLE, LOGFILE
+
+# Set the enterprise logger priority to FATAL
+log4j.logger.org.apache.axis2.enterprise=FATAL
+log4j.logger.de.hunsicker.jalopy.io=FATAL
+log4j.logger.httpclient.wire.header=FATAL
+log4j.logger.org.apache.commons.httpclient=FATAL
+log4j.logger.org.apache.zookeeper=FATAL
+         
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n
+
+# LOGFILE is set to be a File appender using a PatternLayout.
+log4j.appender.LOGFILE=org.apache.log4j.FileAppender
+log4j.appender.LOGFILE.File=../../bin/custos-profile-service.log
+log4j.appender.LOGFILE.Append=true
+log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
diff --git a/pom.xml b/pom.xml
index d42d29e..7bcdf03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,5 +51,15 @@
             <artifactId>mariadb-java-client</artifactId>
             <version>2.0.2</version>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>${org.slf4j.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
     </dependencies>
 </project>
\ No newline at end of file


[airavata-custos] 07/48: Merge branch 'custos-dev-abisht' of https://github.com/aarushiibisht/airavata-custos into custos-dev-abisht

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 55853a8978e62776e9c9be0b1bb41d7626f652f2
Merge: 6c3fb74 8f67c2d
Author: Aarushi <aa...@gmail.com>
AuthorDate: Tue Jun 25 09:06:25 2019 -0400

    Merge branch 'custos-dev-abisht' of https://github.com/aarushiibisht/airavata-custos into custos-dev-abisht



[airavata-custos] 16/48: removed hard coded version from the pom.xml files which now uses project version

Posted by sm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 07dbb7563a3ff09a3f2bffeab353275185bba9d0
Author: Aarushi <aa...@gmail.com>
AuthorDate: Sat Aug 10 18:46:04 2019 -0400

    removed hard coded version from the pom.xml files which now uses project version
---
 custos-authentication/pom.xml                          |  8 +++-----
 custos-client/pom.xml                                  | 12 ++++--------
 custos-commons/pom.xml                                 |  5 ++---
 custos-connectors/pom.xml                              |  4 ++--
 custos-profile-service/iam-admin-services/pom.xml      |  4 ++--
 custos-profile-service/profile-service-commons/pom.xml |  5 ++---
 custos-profile-service/profile-service-server/pom.xml  |  9 +++------
 custos-profile-service/tenant-profile-service/pom.xml  | 10 +++-------
 custos-profile-service/user-profile-service/pom.xml    |  9 +++------
 ide-integration/pom.xml                                |  6 ++----
 10 files changed, 26 insertions(+), 46 deletions(-)

diff --git a/custos-authentication/pom.xml b/custos-authentication/pom.xml
index c8f8cf3..fc2a34f 100644
--- a/custos-authentication/pom.xml
+++ b/custos-authentication/pom.xml
@@ -10,20 +10,18 @@
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>custos-authentication</artifactId>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-connectors</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
 
-
 </project>
\ No newline at end of file
diff --git a/custos-client/pom.xml b/custos-client/pom.xml
index 2c2ee4c..7c241a8 100644
--- a/custos-client/pom.xml
+++ b/custos-client/pom.xml
@@ -13,26 +13,22 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-authentication</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>user-profile-service</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>iam-admin-services</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>tenant-profile-service</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
     <properties>
diff --git a/custos-commons/pom.xml b/custos-commons/pom.xml
index 85b8584..5a78df1 100644
--- a/custos-commons/pom.xml
+++ b/custos-commons/pom.xml
@@ -7,15 +7,14 @@
         <artifactId>custos</artifactId>
         <groupId>org.apache.custos</groupId>
         <version>1.0-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
     </parent>
     <properties>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
     </properties>
-    <groupId>org.apache.custos</groupId>
+
     <artifactId>custos-commons</artifactId>
-    <version>${parent.version}</version>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.thrift</groupId>
diff --git a/custos-connectors/pom.xml b/custos-connectors/pom.xml
index f3ab17d..aa5f07c 100644
--- a/custos-connectors/pom.xml
+++ b/custos-connectors/pom.xml
@@ -18,12 +18,12 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>profile-service-model</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>com.google.inject</groupId>
diff --git a/custos-profile-service/iam-admin-services/pom.xml b/custos-profile-service/iam-admin-services/pom.xml
index e5136ae..d67b676 100644
--- a/custos-profile-service/iam-admin-services/pom.xml
+++ b/custos-profile-service/iam-admin-services/pom.xml
@@ -14,12 +14,12 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>profile-service-model</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-authentication</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
     <properties>
diff --git a/custos-profile-service/profile-service-commons/pom.xml b/custos-profile-service/profile-service-commons/pom.xml
index 2688339..949246a 100644
--- a/custos-profile-service/profile-service-commons/pom.xml
+++ b/custos-profile-service/profile-service-commons/pom.xml
@@ -13,7 +13,6 @@
         <artifactId>custos-profile-service</artifactId>
         <groupId>org.apache.custos</groupId>
         <version>1.0-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
     </parent>
 
     <modelVersion>4.0.0</modelVersion>
@@ -67,12 +66,12 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>profile-service-model</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
 
diff --git a/custos-profile-service/profile-service-server/pom.xml b/custos-profile-service/profile-service-server/pom.xml
index 53b8128..b021ff5 100644
--- a/custos-profile-service/profile-service-server/pom.xml
+++ b/custos-profile-service/profile-service-server/pom.xml
@@ -14,20 +14,17 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>user-profile-service</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>tenant-profile-service</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
 
diff --git a/custos-profile-service/tenant-profile-service/pom.xml b/custos-profile-service/tenant-profile-service/pom.xml
index f151c8b..d672cfa 100644
--- a/custos-profile-service/tenant-profile-service/pom.xml
+++ b/custos-profile-service/tenant-profile-service/pom.xml
@@ -14,22 +14,18 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>profile-service-model</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>profile-service-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
 
-
 </project>
\ No newline at end of file
diff --git a/custos-profile-service/user-profile-service/pom.xml b/custos-profile-service/user-profile-service/pom.xml
index 1854131..4afd95c 100644
--- a/custos-profile-service/user-profile-service/pom.xml
+++ b/custos-profile-service/user-profile-service/pom.xml
@@ -22,20 +22,17 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>profile-service-commons</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-connectors</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>iam-admin-services</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>
 
diff --git a/ide-integration/pom.xml b/ide-integration/pom.xml
index 00adb60..ee1a01d 100644
--- a/ide-integration/pom.xml
+++ b/ide-integration/pom.xml
@@ -24,14 +24,12 @@
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>profile-service-server</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
             <artifactId>custos-authentication</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <scope>compile</scope>
+            <version>${project.version}</version>
         </dependency>
     </dependencies>