You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2017/10/11 12:20:16 UTC

[geode-native] branch develop updated: GEODE-3424: Pass instance of AuthInitailize into CacheFactory.

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

jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new 2aa801a  GEODE-3424: Pass instance of AuthInitailize into CacheFactory.
2aa801a is described below

commit 2aa801a3e4dbb9091b221ca7131df24c94e44f33
Author: Mark Hanson <mh...@pivotal.io>
AuthorDate: Wed Sep 27 09:49:25 2017 -0700

    GEODE-3424: Pass instance of AuthInitailize into CacheFactory.
    
    - Remove old properties based library and factory loading.
    - Removes old test.
---
 clicache/integration-test/CacheHelperN.cs          |  12 +-
 ...ThinClientSecurityAuthSetAuthInitializeTests.cs | 148 +++++
 clicache/integration-test/UnitTests.csproj.in      |   1 +
 clicache/src/CacheFactory.cpp                      |  26 +-
 clicache/src/CacheFactory.hpp                      |  13 +
 clicache/src/DistributedSystem.cpp                 |  11 -
 clicache/src/SystemProperties.cpp                  |   5 -
 clicache/src/SystemProperties.hpp                  |   9 -
 clicache/src/impl/ManagedAuthInitialize.cpp        | 136 -----
 cppcache/include/geode/Cache.hpp                   |   3 +-
 cppcache/include/geode/CacheFactory.hpp            |   9 +
 cppcache/include/geode/SystemProperties.hpp        |  42 +-
 cppcache/integration-test/CacheHelper.cpp          |  35 +-
 cppcache/integration-test/CacheHelper.hpp          |   3 +
 ...ientSecurityAuthenticationSetAuthInitialize.cpp | 183 +++++++
 .../testThinClientSecurityCQAuthorization.cpp      | 596 ---------------------
 cppcache/src/Cache.cpp                             |  22 +-
 cppcache/src/CacheFactory.cpp                      |   8 +-
 cppcache/src/CacheImpl.cpp                         |   6 +-
 cppcache/src/CacheImpl.hpp                         |   9 +-
 cppcache/src/DistributedSystemImpl.cpp             |   5 -
 cppcache/src/DistributedSystemImpl.hpp             |   8 -
 cppcache/src/SystemProperties.cpp                  |  43 --
 cppcache/src/TcrConnection.cpp                     |  95 ++--
 cppcache/src/TcrEndpoint.cpp                       |  12 +-
 cppcache/src/ThinClientBaseDM.cpp                  |   5 +-
 cppcache/src/ThinClientDistributionManager.cpp     |  14 +-
 cppcache/src/ThinClientPoolDM.cpp                  |  43 +-
 28 files changed, 531 insertions(+), 971 deletions(-)

diff --git a/clicache/integration-test/CacheHelperN.cs b/clicache/integration-test/CacheHelperN.cs
index 5824fd7..5270e58 100644
--- a/clicache/integration-test/CacheHelperN.cs
+++ b/clicache/integration-test/CacheHelperN.cs
@@ -485,7 +485,12 @@ namespace Apache.Geode.Client.UnitTests
       InitConfig(null, null);
     }
 
-    public static void InitConfig(Properties<string, string> config)
+		public static void InitConfig(Properties<string, string> config, IAuthInitialize authInitialize)
+		{
+			InitConfig(config, null, authInitialize);
+		}
+
+		public static void InitConfig(Properties<string, string> config)
     {
       InitConfig(config, null);
     }
@@ -562,10 +567,10 @@ namespace Apache.Geode.Client.UnitTests
 
     public static void InitConfig(string cacheXml)
     {
-      InitConfig(null, cacheXml);
+      InitConfig(null, cacheXml, null);
     }
 
-    public static void InitConfig(Properties<string, string> config, string cacheXml)
+    public static void InitConfig(Properties<string, string> config, string cacheXml, IAuthInitialize authIntialize)
     {
       //Console.WriteLine(" in InitConfig1 " + System.AppDomain.CurrentDomain.Id);
       if (cacheXml != null)
@@ -608,6 +613,7 @@ namespace Apache.Geode.Client.UnitTests
           m_cache = cf
               .SetPdxIgnoreUnreadFields(PdxIgnoreUnreadFields)
               .SetPdxReadSerialized(PdxReadSerialized)
+							.SetAuthInitialize(authIntialize)
               .Create();
 
           PdxIgnoreUnreadFields = false; //reset so next test will have default value
diff --git a/clicache/integration-test/ThinClientSecurityAuthSetAuthInitializeTests.cs b/clicache/integration-test/ThinClientSecurityAuthSetAuthInitializeTests.cs
new file mode 100644
index 0000000..662c860
--- /dev/null
+++ b/clicache/integration-test/ThinClientSecurityAuthSetAuthInitializeTests.cs
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+
+namespace Apache.Geode.Client.UnitTests
+{
+	using NUnit.Framework;
+	using Apache.Geode.Client.Tests;
+	using Apache.Geode.DUnitFramework;
+	using Apache.Geode.Client;
+
+	[TestFixture]
+	[Category("group1")]
+	[Category("unicast_only")]
+	[Category("generics")]
+	public class ThinClientSecurityAuthSetAuthInitializeTests : ThinClientRegionSteps
+	{
+		#region Private members
+
+		private UnitProcess m_client1;
+		private const string CacheXml1 = "cacheserver_notify_subscription.xml";
+
+		private UsernamePasswordAuthInitialize authInitialize = new UsernamePasswordAuthInitialize();
+
+		#endregion
+
+		protected override ClientBase[] GetClients()
+		{
+			m_client1 = new UnitProcess();
+			return new ClientBase[] { m_client1 };
+		}
+
+		[TearDown]
+		public override void EndTest()
+		{
+			try {
+				m_client1.Call(CacheHelper.Close);
+				CacheHelper.ClearEndpoints();
+				CacheHelper.ClearLocators();
+			} finally {
+				CacheHelper.StopJavaServers();
+			}
+			base.EndTest();
+		}
+
+
+		public void CreateClient(string regionName, string locators)
+		{
+			CacheHelper.Close();
+			Properties<string, string> sysProps = new Properties<string, string>();
+			sysProps.Insert("security-username", "root");
+			sysProps.Insert("security-password", "root");
+
+			CacheHelper.InitConfig(sysProps, authInitialize);
+
+			Assert.IsFalse(authInitialize.called);
+
+			CacheHelper.CreatePool<object, object>("__TESTPOOL1_", locators, (string)null,
+				0, true, -1, false);
+
+			CacheHelper.CreateTCRegion_Pool<object, object>(regionName, true, true,
+				null, locators, "__TESTPOOL1_", true);
+		}
+
+		public void AssertAuthInitializeCalled(bool called)
+		{
+			Assert.AreEqual(called, authInitialize.called);
+		}
+
+		void runValidCredentials()
+		{
+			var dataDir = Util.GetEnvironmentVariable("TESTSRC");
+			Properties<string, string> javaProps = new Properties<string, string>();
+			javaProps.Insert("gemfire.security-authz-xml-uri", dataDir + "\\..\\..\\templates\\security\\authz-dummy.xml");
+			string authenticator = "javaobject.DummyAuthenticator.create";
+
+			// Start the server
+			CacheHelper.SetupJavaServers(true, CacheXml1);
+			CacheHelper.StartJavaLocator(1, "GFELOC");
+			Util.Log("Locator started");
+			CacheHelper.StartJavaServerWithLocators(1, "GFECS1", 1, SecurityTestUtil.GetServerArgs(
+				authenticator, null, javaProps));
+			Util.Log("Cacheserver 1 started.");
+
+
+			m_client1.Call(CreateClient, RegionName, CacheHelper.Locators);
+
+			// Perform some put operations from client1
+			//m_client1.Call(AssertAuthInitializeCalled, false);
+			m_client1.Call(DoPuts, 4);
+			m_client1.Call(AssertAuthInitializeCalled, true);
+
+			// Verify that the puts succeeded
+			m_client1.Call(DoGets, 4);
+
+			m_client1.Call(Close);
+
+			CacheHelper.StopJavaServer(1);
+
+			CacheHelper.StopJavaLocator(1);
+
+			CacheHelper.ClearEndpoints();
+			CacheHelper.ClearLocators();
+
+		}
+
+		[Test]
+		public void ValidCredentials()
+		{
+			runValidCredentials();
+		}
+
+	}
+
+
+	public class UsernamePasswordAuthInitialize : IAuthInitialize
+	{
+		public bool called = false;
+
+		public void Close() { }
+
+		public Properties<string, object> GetCredentials(Properties<string, string> props, string server)
+		{
+			called = true;
+			var credentials = new Properties<string, object>();
+			credentials.Insert("security-username", props.Find("security-username"));
+			credentials.Insert("security-password", props.Find("security-password"));
+			return credentials;
+		}
+	}
+}
\ No newline at end of file
diff --git a/clicache/integration-test/UnitTests.csproj.in b/clicache/integration-test/UnitTests.csproj.in
index df6c975..c929137 100644
--- a/clicache/integration-test/UnitTests.csproj.in
+++ b/clicache/integration-test/UnitTests.csproj.in
@@ -160,6 +160,7 @@
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\ThinClientPdxTests.cs">
       <Link>ThinClientPdxTests.cs</Link>
     </Compile>
+    <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\ThinClientSecurityAuthSetAuthInitializeTests.cs" />
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\AttributesFactoryTestsN.cs" />
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\AttributesMutatorTestsN.cs" />
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\CacheHelperN.cs" />
diff --git a/clicache/src/CacheFactory.cpp b/clicache/src/CacheFactory.cpp
index e418d0c..c95e6a7 100644
--- a/clicache/src/CacheFactory.cpp
+++ b/clicache/src/CacheFactory.cpp
@@ -24,6 +24,7 @@
 #include "impl/PdxTypeRegistry.hpp"
 #include "impl/AppDomainContext.hpp"
 #include "impl/CacheResolver.hpp"
+#include "impl/ManagedAuthInitialize.hpp"
 
 using namespace System;
 
@@ -177,8 +178,31 @@ namespace Apache
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
+      }
+
+      CacheFactory^ CacheFactory::SetAuthInitialize(IAuthInitialize^ authInitialize)
+      {
+        	_GF_MG_EXCEPTION_TRY2
+
+          try
+          {
+            std::shared_ptr<ManagedAuthInitializeGeneric> nativeAuthInitialize;
+            if (authInitialize != nullptr)
+            {
+              nativeAuthInitialize.reset(new ManagedAuthInitializeGeneric(authInitialize));
+            }
+            m_nativeptr->get()->setAuthInitialize( nativeAuthInitialize);
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
+          return this;
+
+			  _GF_MG_EXCEPTION_CATCH_ALL2
+      }
+
     }  // namespace Client
   }  // namespace Geode
 }  // namespace Apache
 
-}
diff --git a/clicache/src/CacheFactory.hpp b/clicache/src/CacheFactory.hpp
index fb9f8ba..5c18828 100644
--- a/clicache/src/CacheFactory.hpp
+++ b/clicache/src/CacheFactory.hpp
@@ -24,6 +24,7 @@
 
 #include "native_shared_ptr.hpp"
 #include "Properties.hpp"
+#include "IAuthInitialize.hpp"
 
 using namespace System::Collections::Generic;
 
@@ -150,6 +151,18 @@ namespace Apache
         /// </returns>
         CacheFactory^ Set(String^ name, String^ value);
 
+        /// <summary>
+        /// Sets the AuthInitializer defined by the user.
+        /// The AuthInitializer will be used to obtain credentials for a client.
+        /// </summary>
+        /// <param>
+        /// authInitialize
+        /// </param>
+        /// <returns>
+        /// a instance of <c>CacheFactory</c> 
+        /// </returns>
+        CacheFactory^ SetAuthInitialize(IAuthInitialize^ authInitialize);
+
       private:
 
         /// <summary>
diff --git a/clicache/src/DistributedSystem.cpp b/clicache/src/DistributedSystem.cpp
index 7431933..44cf5e3 100644
--- a/clicache/src/DistributedSystem.cpp
+++ b/clicache/src/DistributedSystem.cpp
@@ -110,14 +110,6 @@ namespace apache
                                    const char* factoryFunctionName);
       };
 
-      class ManagedAuthInitializeGeneric
-        : public AuthInitialize
-      {
-      public:
-
-        static AuthInitialize* create(const char* assemblyPath,
-                                      const char* factoryFunctionName);
-      };
     }  // namespace client
   }  // namespace geode
 }  // namespace apache
@@ -303,9 +295,6 @@ namespace Apache
 
         //if (!native::DistributedSystem::isConnected())
         //{
-          // Set the Generic ManagedAuthInitialize factory function
-          native::SystemProperties::managedAuthInitializeFn =
-            native::ManagedAuthInitializeGeneric::create;
 
           // Set the Generic ManagedCacheLoader/Listener/Writer factory functions.
           native::CacheXmlParser::managedCacheLoaderFn =
diff --git a/clicache/src/SystemProperties.cpp b/clicache/src/SystemProperties.cpp
index 8683548..e90b97d 100644
--- a/clicache/src/SystemProperties.cpp
+++ b/clicache/src/SystemProperties.cpp
@@ -170,11 +170,6 @@ namespace Apache
       }
 
 
-      bool SystemProperties::IsSecurityOn::get( )
-      {
-        return m_nativeptr->isSecurityOn( );
-      }
-
       Properties<String^, String^>^ SystemProperties::GetSecurityProperties::get( )
       {
         return Properties<String^, String^>::Create(m_nativeptr->getSecurityProperties());
diff --git a/clicache/src/SystemProperties.hpp b/clicache/src/SystemProperties.hpp
index 507035b..18790d0 100644
--- a/clicache/src/SystemProperties.hpp
+++ b/clicache/src/SystemProperties.hpp
@@ -312,15 +312,6 @@ namespace Apache
         }
 
         /// <summary>
-        /// True if client needs to be authenticated
-        /// </summary>
-        /// <returns>true if enabled</returns>
-        property bool IsSecurityOn
-        {
-          bool get();
-        }
-
-        /// <summary>
         /// Returns all the security properties
         /// </summary>
         /// <returns>the security properties</returns>
diff --git a/clicache/src/impl/ManagedAuthInitialize.cpp b/clicache/src/impl/ManagedAuthInitialize.cpp
index 61e0683..ca071a7 100644
--- a/clicache/src/impl/ManagedAuthInitialize.cpp
+++ b/clicache/src/impl/ManagedAuthInitialize.cpp
@@ -34,142 +34,6 @@ namespace apache
     namespace client
     {
 
-      AuthInitialize* ManagedAuthInitializeGeneric::create(const char* assemblyPath,
-                                                           const char* factoryFunctionName)
-      {
-        try
-        {
-          String^ mg_assemblyPath =
-            Apache::Geode::Client::ManagedString::Get(assemblyPath);
-          String^ mg_factoryFunctionName =
-            Apache::Geode::Client::ManagedString::Get(factoryFunctionName);
-          String^ mg_typeName = nullptr;
-          System::Int32 dotIndx = -1;
-
-          if (mg_factoryFunctionName == nullptr ||
-              (dotIndx = mg_factoryFunctionName->LastIndexOf('.')) < 0)
-          {
-            std::string ex_str = "ManagedAuthInitializeGeneric: Factory function name '";
-            ex_str += factoryFunctionName;
-            ex_str += "' does not contain type name";
-            throw AuthenticationRequiredException(ex_str.c_str());
-          }
-
-          mg_typeName = mg_factoryFunctionName->Substring(0, dotIndx);
-          mg_factoryFunctionName = mg_factoryFunctionName->Substring(dotIndx + 1);
-
-          Assembly^ assmb = nullptr;
-          try
-          {
-            assmb = Assembly::Load(mg_assemblyPath);
-          }
-          catch (System::Exception^)
-          {
-            assmb = nullptr;
-          }
-          if (assmb == nullptr)
-          {
-            std::string ex_str = "ManagedAuthInitializeGeneric: Could not load assembly: ";
-            ex_str += assemblyPath;
-            throw AuthenticationRequiredException(ex_str.c_str());
-          }
-
-          Object^ typeInst = assmb->CreateInstance(mg_typeName, true);
-
-          //Type^ typeInst = assmb->GetType(mg_typeName, false, true);
-
-          if (typeInst != nullptr)
-          {
-            /*
-            array<Type^>^ types = gcnew array<Type^>(2);
-            types[0] = Type::GetType(mg_genericKey, false, true);
-            types[1] = Type::GetType(mg_genericVal, false, true);
-
-            if (types[0] == nullptr || types[1] == nullptr)
-            {
-            std::string ex_str = "ManagedAuthInitializeGeneric: Could not get both generic type argument instances";
-            throw apache::geode::client::IllegalArgumentException( ex_str.c_str( ) );
-            }
-            */
-
-            //typeInst = typeInst->GetType()->MakeGenericType(types);
-            Apache::Geode::Client::Log::Info("Loading function: [{0}]", mg_factoryFunctionName);
-
-            /*
-            MethodInfo^ mInfo = typeInst->GetMethod( mg_factoryFunctionName,
-            BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase );
-            */
-
-            MethodInfo^ mInfo = typeInst->GetType()->GetMethod(mg_factoryFunctionName,
-                                                               BindingFlags::Public | BindingFlags::Static | BindingFlags::IgnoreCase);
-
-            if (mInfo != nullptr)
-            {
-              Object^ userptr = nullptr;
-              try
-              {
-                userptr = mInfo->Invoke(typeInst, nullptr);
-              }
-              catch (System::Exception^)
-              {
-                userptr = nullptr;
-              }
-              if (userptr == nullptr)
-              {
-                std::string ex_str = "ManagedAuthInitializeGeneric: Could not create "
-                  "object on invoking factory function [";
-                ex_str += factoryFunctionName;
-                ex_str += "] in assembly: ";
-                ex_str += assemblyPath;
-                throw AuthenticationRequiredException(ex_str.c_str());
-              }
-              ManagedAuthInitializeGeneric * maig = new ManagedAuthInitializeGeneric(safe_cast<Apache::Geode::Client::IAuthInitialize^>(userptr));
-              return maig;
-            }
-            else
-            {
-              std::string ex_str = "ManagedAuthInitializeGeneric: Could not load "
-                "function with name [";
-              ex_str += factoryFunctionName;
-              ex_str += "] in assembly: ";
-              ex_str += assemblyPath;
-              throw AuthenticationRequiredException(ex_str.c_str());
-            }
-          }
-          else
-          {
-            Apache::Geode::Client::ManagedString typeName(mg_typeName);
-            std::string ex_str = "ManagedAuthInitializeGeneric: Could not load type [";
-            ex_str += typeName.CharPtr;
-            ex_str += "] in assembly: ";
-            ex_str += assemblyPath;
-            throw AuthenticationRequiredException(ex_str.c_str());
-          }
-        }
-        catch (const apache::geode::client::AuthenticationRequiredException&)
-        {
-          throw;
-        }
-        catch (const apache::geode::client::Exception& ex)
-        {
-          std::string ex_str = "ManagedAuthInitializeGeneric: Got an exception while "
-            "loading managed library: ";
-          ex_str += ex.getName();
-          ex_str += ": ";
-          ex_str += ex.getMessage();
-          throw AuthenticationRequiredException(ex_str.c_str());
-        }
-        catch (System::Exception^ ex)
-        {
-          Apache::Geode::Client::ManagedString mg_exStr(ex->ToString());
-          std::string ex_str = "ManagedAuthInitializeGeneric: Got an exception while "
-            "loading managed library: ";
-          ex_str += mg_exStr.CharPtr;
-          throw AuthenticationRequiredException(ex_str.c_str());
-        }
-        return NULL;
-      }
-
       PropertiesPtr ManagedAuthInitializeGeneric::getCredentials(const PropertiesPtr&
                                                                  securityprops, const char* server)
       {
diff --git a/cppcache/include/geode/Cache.hpp b/cppcache/include/geode/Cache.hpp
index 64d9030..523827a 100644
--- a/cppcache/include/geode/Cache.hpp
+++ b/cppcache/include/geode/Cache.hpp
@@ -246,7 +246,8 @@ class CPPCACHE_EXPORT Cache : public GeodeCache,
    * @brief constructors
    */
   Cache(const std::string& name, PropertiesPtr dsProp,
-        bool ignorePdxUnreadFields, bool readPdxSerialized);
+        bool ignorePdxUnreadFields, bool readPdxSerialized,
+        const AuthInitializePtr& authInitialize);
 
   std::unique_ptr<CacheImpl> m_cacheImpl;
   std::unique_ptr<TypeRegistry> m_typeRegistry;
diff --git a/cppcache/include/geode/CacheFactory.hpp b/cppcache/include/geode/CacheFactory.hpp
index 82dc9a9..f98ede0 100644
--- a/cppcache/include/geode/CacheFactory.hpp
+++ b/cppcache/include/geode/CacheFactory.hpp
@@ -92,6 +92,14 @@ class CPPCACHE_EXPORT CacheFactory
    */
   CacheFactoryPtr setPdxIgnoreUnreadFields(bool ignore);
 
+  /**
+   * Sets the AuthInitializer defined by the user.
+   * The AuthInitializer will be used to obtain credentials for a client.
+   * @param authInitialize
+   * @return this ClientCacheFactory
+   */
+  CacheFactoryPtr setAuthInitialize(const AuthInitializePtr& authInitialize);
+
   /** Sets the object preference to PdxInstance type.
    * When a cached object that was serialized as a PDX is read
    * from the cache a {@link PdxInstance} will be returned instead of the actual
@@ -125,6 +133,7 @@ class CPPCACHE_EXPORT CacheFactory
   PropertiesPtr dsProp;
   bool ignorePdxUnreadFields;
   bool pdxReadSerialized;
+  AuthInitializePtr authInitialize;
 
   CachePtr create(const char* name,
                   const CacheAttributesPtr& attrs = nullptr);
diff --git a/cppcache/include/geode/SystemProperties.hpp b/cppcache/include/geode/SystemProperties.hpp
index d2a2128..ff8960d 100644
--- a/cppcache/include/geode/SystemProperties.hpp
+++ b/cppcache/include/geode/SystemProperties.hpp
@@ -22,7 +22,6 @@
 
 #include "Properties.hpp"
 #include "Log.hpp"
-#include "AuthInitialize.hpp"
 
 /** @file
  */
@@ -37,10 +36,6 @@ namespace client {
  *
  */
 
-// Factory function typedefs to register the managed authInitialize
-typedef AuthInitialize* (*LibraryAuthInitializeFn)(const char* assemblyPath,
-                                                   const char* factFuncName);
-
 /**
  * A class for internal use, that encapsulates the properties that can be
  * set from DistributedSystem::connect.
@@ -297,20 +292,6 @@ class CPPCACHE_EXPORT SystemProperties {
     m_onClientDisconnectClearPdxTypeIds = set;
   }
 
-  /** Return the security auth library */
-  inline const char* authInitLibrary() const {
-    return (m_AuthIniLoaderLibrary == nullptr
-                ? ""
-                : m_AuthIniLoaderLibrary->asChar());
-  }
-
-  /** Return the security auth factory */
-  inline const char* authInitFactory() const {
-    return (m_AuthIniLoaderFactory == nullptr
-                ? ""
-                : m_AuthIniLoaderFactory->asChar());
-  }
-
   /** Return the security diffie hellman secret key algo */
   const char* securityClientDhAlgo() const {
     return (m_securityClientDhAlgo == nullptr
@@ -332,14 +313,6 @@ class CPPCACHE_EXPORT SystemProperties {
     return m_securityPropertiesPtr;
   }
 
-  /** Checks whether Security is on or off.
-   * @return  bool value.
-   */
-  inline bool isSecurityOn() const {
-    return (m_AuthIniLoaderFactory != nullptr &&
-            m_AuthIniLoaderLibrary != nullptr);
-  }
-
   /** Checks whether list of endpoint is shuffeled or not.
    * @return  bool value.
    */
@@ -352,7 +325,7 @@ class CPPCACHE_EXPORT SystemProperties {
    * @return bool flag to indicate whether DH for credentials is on.
    */
   bool isDhOn() const {
-    return isSecurityOn() && m_securityClientDhAlgo != nullptr &&
+    return m_securityClientDhAlgo != nullptr &&
            m_securityClientDhAlgo->length() > 0;
   }
 
@@ -447,11 +420,9 @@ class CPPCACHE_EXPORT SystemProperties {
   int32_t m_notifyDupCheckLife;
 
   PropertiesPtr m_securityPropertiesPtr;
-  CacheableStringPtr m_AuthIniLoaderLibrary;
-  CacheableStringPtr m_AuthIniLoaderFactory;
+
   CacheableStringPtr m_securityClientDhAlgo;
   CacheableStringPtr m_securityClientKsPath;
-  AuthInitializePtr m_authInitializer;
 
   char* m_durableClientId;
   uint32_t m_durableTimeout;
@@ -487,13 +458,6 @@ class CPPCACHE_EXPORT SystemProperties {
    */
   void processProperty(const char* property, const char* value);
 
-  /** Gets the authInitialize loader for the system.
-   * @return  a pointer that points to the system's ,
-   * <code>AuthLoader</code> , nullptr if there is no AuthLoader for this
-   * system.
-   */
-  AuthInitializePtr getAuthLoader();
-
  private:
   SystemProperties(const SystemProperties& rhs);  // never defined
   void operator=(const SystemProperties& rhs);    // never defined
@@ -501,8 +465,6 @@ class CPPCACHE_EXPORT SystemProperties {
   void throwError(const char* msg);
 
  public:
-  static LibraryAuthInitializeFn managedAuthInitializeFn;
-
   friend class DistributedSystemImpl;
 };
 }  // namespace client
diff --git a/cppcache/integration-test/CacheHelper.cpp b/cppcache/integration-test/CacheHelper.cpp
index 4b7713a..0d1733f 100644
--- a/cppcache/integration-test/CacheHelper.cpp
+++ b/cppcache/integration-test/CacheHelper.cpp
@@ -144,6 +144,27 @@ CacheHelper::CacheHelper(const PropertiesPtr& configPtr,
 }
 
 CacheHelper::CacheHelper(const bool isThinclient,
+                         const AuthInitializePtr& authInitialize,
+                         const PropertiesPtr& configPtr) {
+  PropertiesPtr pp = configPtr;
+  if (pp == nullptr) {
+    pp = Properties::create();
+  }
+  try {
+    LOG(" in cachehelper before createCacheFactory");
+    cachePtr = CacheFactory::createCacheFactory(pp)
+                   ->setAuthInitialize(authInitialize)
+                   ->create();
+    m_doDisconnect = false;
+  } catch (const Exception& excp) {
+    LOG("Geode exception while creating cache, logged in following line");
+    LOG(excp.getMessage());
+  } catch (...) {
+    LOG("Throwing exception while creating cache....");
+  }
+}
+
+CacheHelper::CacheHelper(const bool isThinclient,
                          const PropertiesPtr& configPtr,
                          const bool noRootRegion) {
   PropertiesPtr pp = configPtr;
@@ -1268,30 +1289,18 @@ void CacheHelper::initServer(int instance, const char* xml,
   currDir += sname;
 
   if (xml != nullptr) {
-    /*
-    xmlFile = path;
-    xmlFile += PATH_SEP;
-    xmlFile += xml;
-    */
     xmlFile = xml;
   }
 
   std::string xmlFile_new;
   printf(" xml file name = %s \n", xmlFile.c_str());
   CacheHelper::createDuplicateXMLFile(xmlFile_new, xmlFile);
-  // sprintf( tmp, "%d.xml", portNum );
-  // xmlFile += tmp;
+
   xmlFile = xmlFile_new;
 
   printf("  creating dir = %s \n", sname.c_str());
   ACE_OS::mkdir(sname.c_str());
 
-  //    sprintf( cmd, "/bin/cp %s/../test.geode.properties
-  //    %s/",currDir.c_str(),
-  // currDir.c_str()  );
-  // LOG( cmd );
-  // ACE_OS::system( cmd );
-
   sprintf(cmd, "%s/bin/%s stop server --dir=%s 2>&1", gfjavaenv, GFSH,
           currDir.c_str());
 
diff --git a/cppcache/integration-test/CacheHelper.hpp b/cppcache/integration-test/CacheHelper.hpp
index 910a0b3..ab024d3 100644
--- a/cppcache/integration-test/CacheHelper.hpp
+++ b/cppcache/integration-test/CacheHelper.hpp
@@ -71,6 +71,9 @@ class CacheHelper {
   CacheHelper(const bool isThinclient, const PropertiesPtr& configPtr = nullptr,
               const bool noRootRegion = false);
 
+  CacheHelper(const bool isThinclient, const AuthInitializePtr& authInitialize,
+              const PropertiesPtr& configPtr = nullptr);
+
   CacheHelper(const bool isThinclient, bool pdxIgnoreUnreadFields,
               bool pdxReadSerialized, const PropertiesPtr& configPtr = nullptr,
               const bool noRootRegion = false);
diff --git a/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp b/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp
new file mode 100644
index 0000000..e2599af
--- /dev/null
+++ b/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp
@@ -0,0 +1,183 @@
+/*
+ * 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.
+ */
+
+#include <ace/OS.h>
+#include <ace/High_Res_Timer.h>
+
+#include <geode/GeodeCppCache.hpp>
+#include <geode/AuthInitialize.hpp>
+
+#include "fw_dunit.hpp"
+#include "ThinClientHelper.hpp"
+#include "ThinClientSecurity.hpp"
+
+using namespace apache::geode::client;
+using namespace test;
+
+const char* locHostPort =
+    CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
+const char* regionNamesAuth[] = {"DistRegionAck", "DistRegionNoAck"};
+CredentialGeneratorPtr credentialGeneratorHandler;
+
+std::string getXmlPath() {
+  char xmlPath[1000] = {'\0'};
+  const char* path = ACE_OS::getenv("TESTSRC");
+  ASSERT(path != NULL,
+         "Environment variable TESTSRC for test source directory is not set.");
+  strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
+  strcat(xmlPath, "xml/Security/");
+  return std::string(xmlPath);
+}
+
+#define SECURITY_USERNAME "security-username"
+#define SECURITY_PASSWORD "security-password"
+class UserPasswordAuthInit : public AuthInitialize {
+ public:
+  UserPasswordAuthInit() {}
+
+  ~UserPasswordAuthInit() {}
+
+  PropertiesPtr getCredentials(const PropertiesPtr& securityprops,
+                               const char* server) {
+    // LOGDEBUG("UserPasswordAuthInit: inside userPassword::getCredentials");
+    CacheablePtr userName;
+    if (securityprops == nullptr ||
+        (userName = securityprops->find(SECURITY_USERNAME)) == nullptr) {
+      throw AuthenticationFailedException(
+          "UserPasswordAuthInit: user name "
+          "property [" SECURITY_USERNAME "] not set.");
+    }
+
+    auto credentials = Properties::create();
+    credentials->insert(SECURITY_USERNAME, userName->toString()->asChar());
+    CacheableStringPtr passwd = securityprops->find(SECURITY_PASSWORD);
+    // If password is not provided then use empty string as the password.
+    if (passwd == nullptr) {
+      passwd = CacheableString::create("");
+    }
+    credentials->insert(SECURITY_PASSWORD, passwd->asChar());
+    // LOGDEBUG("UserPasswordAuthInit: inserted username:password - %s:%s",
+    //    userName->toString()->asChar(), passwd->toString()->asChar());
+    return credentials;
+  }
+
+  void close() { return; }
+
+ private:
+};
+
+void initClientAuth() {
+  auto config = Properties::create();
+  config->insert("security-password", "root");
+  config->insert("security-username", "root");
+
+  auto authInitialize = std::make_shared<UserPasswordAuthInit>();
+
+  try {
+    cacheHelper = new CacheHelper(true, authInitialize, config);
+  } catch (...) {
+    throw;
+  }
+}
+
+#define CLIENT1 s1p1
+#define LOCATORSERVER s2p2
+
+DUNIT_TASK_DEFINITION(LOCATORSERVER, CreateLocator)
+  {
+    if (isLocator) CacheHelper::initLocator(1);
+    LOG("Locator1 started");
+  }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(LOCATORSERVER, CreateServer1)
+  {
+    std::string cmdServerAuthenticator;
+
+    try {
+      if (isLocalServer) {
+        cmdServerAuthenticator +=
+            " --J=-Dgemfire.security-authz-xml-uri=" + getXmlPath() +
+            "authz-dummy.xml "
+            "--J=-Dgemfire.security-client-authenticator=javaobject."
+            "DummyAuthenticator.create";
+        printf("Input to server cmd is -->  %s",
+               cmdServerAuthenticator.c_str());
+        CacheHelper::initServer(
+            1, NULL, locHostPort,
+            const_cast<char*>(cmdServerAuthenticator.c_str()));
+        LOG("Server1 started");
+      }
+    } catch (...) {
+      printf("this is some exception");
+    }
+  }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, TestAuthentication)
+  {
+    initClientAuth();
+    try {
+      createRegionForSecurity(regionNamesAuth[0], USE_ACK, true);
+      createEntry(regionNamesAuth[0], keys[0], vals[0]);
+      updateEntry(regionNamesAuth[0], keys[0], nvals[0]);
+      RegionPtr regPtr0 = getHelper()->getRegion(regionNamesAuth[0]);
+      regPtr0->containsKeyOnServer(
+          apache::geode::client::CacheableKey::create(keys[0]));
+    } catch (const apache::geode::client::Exception& other) {
+      other.printStackTrace();
+      FAIL(other.getMessage());
+    }
+    LOG("Handshake  and  Authentication successfully completed");
+    LOG("TestAuthentication Completed");
+  }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
+  { cleanProc(); }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(LOCATORSERVER, CloseServer1)
+  {
+    if (isLocalServer) {
+      CacheHelper::closeServer(1);
+      LOG("SERVER1 stopped");
+    }
+  }
+END_TASK_DEFINITION
+
+DUNIT_TASK_DEFINITION(LOCATORSERVER, CloseLocator)
+  {
+    if (isLocator) {
+      CacheHelper::closeLocator(1);
+      LOG("Locator1 stopped");
+    }
+  }
+END_TASK_DEFINITION
+
+void doThinClientSecurityAuthentication() {
+  CALL_TASK(CreateLocator);
+  CALL_TASK(CreateServer1);
+  CALL_TASK(TestAuthentication);
+  CALL_TASK(CloseCache1);
+  CALL_TASK(CloseServer1);
+  CALL_TASK(CloseLocator);
+}
+
+DUNIT_MAIN
+  { doThinClientSecurityAuthentication(); }
+END_MAIN
diff --git a/cppcache/integration-test/testThinClientSecurityCQAuthorization.cpp b/cppcache/integration-test/testThinClientSecurityCQAuthorization.cpp
deleted file mode 100644
index 0e93eb3..0000000
--- a/cppcache/integration-test/testThinClientSecurityCQAuthorization.cpp
+++ /dev/null
@@ -1,596 +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.
- */
-#include "fw_dunit.hpp"
-#include <geode/GeodeCppCache.hpp>
-#include <geode/CqAttributesFactory.hpp>
-#include <geode/CqAttributes.hpp>
-#include <geode/CqListener.hpp>
-#include <geode/CqQuery.hpp>
-#include <geode/CqServiceStatistics.hpp>
-#include <ace/OS.h>
-#include <ace/High_Res_Timer.h>
-#include <string>
-
-#define ROOT_NAME "TestThinClientCqAuthorization"
-#define ROOT_SCOPE DISTRIBUTED_ACK
-
-#include "CacheHelper.hpp"
-
-#include "QueryStrings.hpp"
-#include "QueryHelper.hpp"
-
-#include <geode/Query.hpp>
-#include <geode/QueryService.hpp>
-
-#include "ThinClientCQ.hpp"
-
-#include "SerializationRegistry.hpp"
-#include "CacheRegionHelper.hpp"
-#include "CacheImpl.hpp"
-
-using namespace test;
-using namespace testData;
-
-#define ROOT_SCOPE DISTRIBUTED_ACK
-
-#include "CacheHelper.hpp"
-#include "ThinClientHelper.hpp"
-#include "ace/Process.h"
-
-//#include "ThinClientSecurity.hpp"
-
-using namespace apache::geode::client::testframework::security;
-using namespace apache::geode::client;
-
-const char* locHostPort =
-    CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
-CredentialGeneratorPtr credentialGeneratorHandler;
-#define CLIENT1 s1p1
-#define SERVER1 s2p1
-#define CLIENT2 s1p2
-#define LOCATORSERVER s2p2
-
-#define MAX_LISTNER 8
-
-const char* cqNames[MAX_LISTNER] = {"MyCq_0", "MyCq_1", "MyCq_2", "MyCq_3",
-                                    "MyCq_4", "MyCq_5", "MyCq_6", "MyCq_7"};
-
-const char* queryStrings[MAX_LISTNER] = {
-    "select * from /Portfolios p where p.ID < 4",
-    "select * from /Portfolios p where p.ID < 2",
-    "select * from /Portfolios p where p.ID != 2",
-    "select * from /Portfolios p where p.ID != 3",
-    "select * from /Portfolios p where p.ID != 4",
-    "select * from /Portfolios p where p.ID != 5",
-    "select * from /Portfolios p where p.ID != 6",
-    "select * from /Portfolios p where p.ID != 7"};
-
-const char* regionNamesCq[] = {"Portfolios", "Positions", "Portfolios2",
-                               "Portfolios3"};
-
-class MyCqListener : public CqListener {
-  uint8_t m_id;
-  uint32_t m_numInserts;
-  uint32_t m_numUpdates;
-  uint32_t m_numDeletes;
-  uint32_t m_numEvents;
-
- public:
-  uint8_t getId() { return m_id; }
-  uint32_t getNumInserts() { return m_numInserts; }
-  uint32_t getNumUpdates() { return m_numUpdates; }
-  uint32_t getNumDeletes() { return m_numDeletes; }
-  uint32_t getNumEvents() { return m_numEvents; }
-  explicit MyCqListener(uint8_t id)
-      : m_id(id),
-        m_numInserts(0),
-        m_numUpdates(0),
-        m_numDeletes(0),
-        m_numEvents(0) {}
-  inline void updateCount(const CqEvent& cqEvent) {
-    m_numEvents++;
-    switch (cqEvent.getQueryOperation()) {
-      case CqOperation::OP_TYPE_CREATE:
-        m_numInserts++;
-        break;
-      case CqOperation::OP_TYPE_UPDATE:
-        m_numUpdates++;
-        break;
-      case CqOperation::OP_TYPE_DESTROY:
-        m_numDeletes++;
-        break;
-      default:
-        break;
-    }
-  }
-
-  void onEvent(const CqEvent& cqe) {
-    //  LOG("MyCqListener::OnEvent called");
-    updateCount(cqe);
-  }
-  void onError(const CqEvent& cqe) {
-    updateCount(cqe);
-    //   LOG("MyCqListener::OnError called");
-  }
-  void close() {
-    //   LOG("MyCqListener::close called");
-  }
-};
-
-std::string getXmlPath() {
-  char xmlPath[1000] = {'\0'};
-  const char* path = ACE_OS::getenv("TESTSRC");
-  ASSERT(path != nullptr,
-         "Environment variable TESTSRC for test source directory is not set.");
-  strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
-  strcat(xmlPath, "xml/Security/");
-  return std::string(xmlPath);
-}
-
-void initCredentialGenerator() {
-  credentialGeneratorHandler = CredentialGenerator::create("DUMMY3");
-
-  if (credentialGeneratorHandler == nullptr) {
-    FAIL("credentialGeneratorHandler is nullptr");
-  }
-}
-
-PropertiesPtr userCreds;
-void initClientCq(const bool isthinClient) {
-  userCreds = Properties::create();
-  PropertiesPtr config = Properties::create();
-  credentialGeneratorHandler->getAuthInit(config);
-  credentialGeneratorHandler->getValidCredentials(config);
-
-  if (cacheHelper == nullptr) {
-    cacheHelper = new CacheHelper(isthinClient, config);
-  }
-  ASSERT(cacheHelper, "Failed to create a CacheHelper client instance.");
-  try {
-    SerializationRegistryPtr serializationRegistry =
-        CacheRegionHelper::getCacheImpl(cacheHelper->getCache().get())
-            ->getSerializationRegistry();
-
-    serializationRegistry->addType(Position::createDeserializable);
-    serializationRegistry->addType(Portfolio::createDeserializable);
-  } catch (const IllegalStateException&) {
-    // ignore exception
-  }
-}
-
-DUNIT_TASK_DEFINITION(CLIENT1, CreateServer1_Locator)
-  {
-    initCredentialGenerator();
-    std::string cmdServerAuthenticator;
-
-    if (isLocalServer) {
-      cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
-          "authenticator:authorizer:authorizerPP", getXmlPath());
-      printf("string %s", cmdServerAuthenticator.c_str());
-      CacheHelper::initServer(
-          1, "remotequery.xml", locatorsG,
-          const_cast<char*>(cmdServerAuthenticator.c_str()));
-      LOG("Server1 started");
-    }
-  }
-END_TASK_DEFINITION
-
-void stepOne() {
-  initClientCq(true);
-  createRegionForCQ(regionNamesCq[0], USE_ACK, true);
-  RegionPtr regptr = getHelper()->getRegion(regionNamesCq[0]);
-  RegionAttributesPtr lattribPtr = regptr->getAttributes();
-  RegionPtr subregPtr = regptr->createSubregion(regionNamesCq[1], lattribPtr);
-
-  LOG("StepOne complete.");
-}
-
-void stepOne2(bool pool = false, bool locator = false) {
-  LOG("StepOne2 complete. 1");
-  initClientCq(true);
-  LOG("StepOne2 complete. 2");
-  createRegionForCQ(regionNamesCq[0], USE_ACK, true);
-  LOG("StepOne2 complete. 3");
-  RegionPtr regptr = getHelper()->getRegion(regionNamesCq[0]);
-  LOG("StepOne2 complete. 4");
-  RegionAttributesPtr lattribPtr = regptr->getAttributes();
-  LOG("StepOne2 complete. 5");
-  RegionPtr subregPtr = regptr->createSubregion(regionNamesCq[1], lattribPtr);
-
-  LOG("StepOne2 complete.");
-}
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepOne_PoolLocator)
-  { stepOne(); }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT2, StepOne2_PoolLocator)
-  {
-    initCredentialGenerator();
-    stepOne2();
-  }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepTwo)
-  {
-    RegionPtr regPtr0 = getHelper()->getRegion(regionNamesCq[0]);
-    RegionPtr subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
-
-    QueryHelper* qh = &QueryHelper::getHelper();
-
-    qh->populatePortfolioData(regPtr0, 2, 1, 1);
-    qh->populatePositionData(subregPtr0, 2, 1);
-
-    LOG("StepTwo complete.");
-  }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepThree)
-  {
-    uint8_t i = 0;
-    QueryHelper* qh ATTR_UNUSED = &QueryHelper::getHelper();
-
-    PoolPtr pool =
-        getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
-    QueryServicePtr qs;
-    if (pool != nullptr) {
-      // Using region name as pool name as in ThinClientCq.hpp
-      qs = pool->getQueryService();
-    } else {
-      qs = getHelper()->cachePtr->getQueryService();
-    }
-    CqAttributesFactory cqFac;
-    for (i = 0; i < MAX_LISTNER; i++) {
-      auto cqLstner = std::make_shared<MyCqListener>(i);
-      cqFac.addCqListener(cqLstner);
-      CqAttributesPtr cqAttr = cqFac.create();
-      CqQueryPtr qry = qs->newCq(cqNames[i], queryStrings[i], cqAttr);
-    }
-
-    try {
-      LOG("EXECUTE 1 START");
-
-      qs->executeCqs();
-
-      LOG("EXECUTE 1 STOP");
-    } catch (const Exception& excp) {
-      std::string logmsg = "";
-      logmsg += excp.getName();
-      logmsg += ": ";
-      logmsg += excp.getMessage();
-      LOG(logmsg.c_str());
-      excp.printStackTrace();
-    }
-
-    LOG("StepThree complete.");
-  }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT2, StepTwo2)
-  {
-    RegionPtr regPtr0 = getHelper()->getRegion(regionNamesCq[0]);
-    RegionPtr subregPtr0 = regPtr0->getSubregion(regionNamesCq[1]);
-
-    QueryHelper* qh = &QueryHelper::getHelper();
-
-    qh->populatePortfolioData(regPtr0, 3, 2, 1);
-    qh->populatePositionData(subregPtr0, 3, 2);
-    for (int i = 1; i < 3; i++) {
-      auto port = std::make_shared<Portfolio>(i, 2);
-
-      CacheableKeyPtr keyport = CacheableKey::create("port1-1");
-      regPtr0->put(keyport, port);
-      SLEEP(10);  // sleep a while to allow server query to complete
-    }
-
-    LOG("StepTwo2 complete. Sleeping .25 min for server query to complete...");
-    SLEEP(15000);  // sleep .25 min to allow server query to complete
-  }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
-  {
-    auto qh ATTR_UNUSED = &QueryHelper::getHelper();
-
-    auto pool =
-        getHelper()->getCache()->getPoolManager().find(regionNamesCq[0]);
-    QueryServicePtr qs;
-    if (pool != nullptr) {
-      // Using region name as pool name as in ThinClientCq.hpp
-      qs = pool->getQueryService();
-    } else {
-      qs = getHelper()->cachePtr->getQueryService();
-    }
-
-    char buf[1024];
-
-    uint8_t i = 0;
-    int j = 0;
-    uint32_t inserts[MAX_LISTNER];
-    uint32_t updates[MAX_LISTNER];
-    uint32_t deletes[MAX_LISTNER];
-    uint32_t events[MAX_LISTNER];
-    for (i = 0; i < MAX_LISTNER; i++) {
-      inserts[i] = 0;
-      updates[i] = 0;
-      deletes[i] = 0;
-      events[i] = 0;
-    }
-
-    CqAttributesFactory cqFac;
-    for (i = 0; i < MAX_LISTNER; i++) {
-      sprintf(buf, "get info for cq[%s]:", cqNames[i]);
-      LOG(buf);
-      auto cqy = qs->getCq(cqNames[i]);
-      auto cqStats = cqy->getStatistics();
-      sprintf(buf,
-              "Cq[%s]From CqStatistics: numInserts[%d], numDeletes[%d], "
-              "numUpdates[%d], numEvents[%d]",
-              cqNames[i], cqStats->numInserts(), cqStats->numDeletes(),
-              cqStats->numUpdates(), cqStats->numEvents());
-      LOG(buf);
-      for (j = 0; j <= i; j++) {
-        inserts[j] += cqStats->numInserts();
-        updates[j] += cqStats->numUpdates();
-        deletes[j] += cqStats->numDeletes();
-        events[j] += cqStats->numEvents();
-      }
-      auto cqAttr = cqy->getCqAttributes();
-      std::vector<CqListenerPtr> vl;
-      cqAttr->getCqListeners(vl);
-      sprintf(buf, "number of listeners for cq[%s] is %zd", cqNames[i],
-              vl.size());
-      LOG(buf);
-      ASSERT(vl.size() == i + 1, "incorrect number of listeners");
-      if (i == (MAX_LISTNER - 1)) {
-        MyCqListener* myLl[MAX_LISTNER];
-        for (int k = 0; k < MAX_LISTNER; k++) {
-          MyCqListener* ml = dynamic_cast<MyCqListener*>(vl[k].get());
-          myLl[ml->getId()] = ml;
-        }
-        for (j = 0; j < MAX_LISTNER; j++) {
-          auto ml = myLl[j];
-          sprintf(buf,
-                  "MyCount for Listener[%d]: numInserts[%d], numDeletes[%d], "
-                  "numUpdates[%d], numEvents[%d]",
-                  j, ml->getNumInserts(), ml->getNumDeletes(),
-                  ml->getNumUpdates(), ml->getNumEvents());
-          LOG(buf);
-          sprintf(buf,
-                  "sum of stats for Listener[%d]: numInserts[%d], "
-                  "numDeletes[%d], numUpdates[%d], numEvents[%d]",
-                  j, inserts[j], deletes[j], updates[j], events[j]);
-          LOG(buf);
-          ASSERT(ml->getNumInserts() == inserts[j],
-                 "accumulative insert count incorrect");
-          ASSERT(ml->getNumUpdates() == updates[j],
-                 "accumulative updates count incorrect");
-          ASSERT(ml->getNumDeletes() == deletes[j],
-                 "accumulative deletes count incorrect");
-          ASSERT(ml->getNumEvents() == events[j],
-                 "accumulative events count incorrect");
-        }
-        LOG("removing listener");
-        auto cqAttrMtor = cqy->getCqAttributesMutator();
-        auto ptr = vl[0];
-        cqAttrMtor->removeCqListener(ptr);
-        cqAttr->getCqListeners(vl);
-        sprintf(buf, "number of listeners for cq[%s] is %zd", cqNames[i],
-                vl.size());
-        LOG(buf);
-        ASSERT(vl.size() == i, "incorrect number of listeners");
-      }
-    }
-    try {
-      auto cqy = qs->getCq(cqNames[1]);
-      cqy->stop();
-
-      cqy = qs->getCq(cqNames[6]);
-
-      sprintf(buf, "cq[%s] should have been running!", cqNames[6]);
-      ASSERT(cqy->isRunning() == true, buf);
-      bool got_exception = false;
-      try {
-        cqy->execute();
-      } catch (IllegalStateException& excp) {
-        std::string failmsg = "";
-        failmsg += excp.getName();
-        failmsg += ": ";
-        failmsg += excp.getMessage();
-        LOG(failmsg.c_str());
-        got_exception = true;
-      }
-      sprintf(buf, "cq[%s] should gotten exception!", cqNames[6]);
-      ASSERT(got_exception == true, buf);
-
-      cqy->stop();
-
-      sprintf(buf, "cq[%s] should have been stopped!", cqNames[6]);
-      ASSERT(cqy->isStopped() == true, buf);
-
-      cqy = qs->getCq(cqNames[2]);
-      cqy->close();
-
-      sprintf(buf, "cq[%s] should have been closed!", cqNames[2]);
-      ASSERT(cqy->isClosed() == true, buf);
-
-      cqy = qs->getCq(cqNames[2]);
-      sprintf(buf, "cq[%s] should have been removed after close!", cqNames[2]);
-      ASSERT(cqy == nullptr, buf);
-    } catch (Exception& excp) {
-      std::string failmsg = "";
-      failmsg += excp.getName();
-      failmsg += ": ";
-      failmsg += excp.getMessage();
-      LOG(failmsg.c_str());
-      FAIL(failmsg.c_str());
-      excp.printStackTrace();
-    }
-    auto serviceStats = qs->getCqServiceStatistics();
-    ASSERT(serviceStats != nullptr, "serviceStats is nullptr");
-    sprintf(buf,
-            "numCqsActive=%d, numCqsCreated=%d, "
-            "numCqsClosed=%d,numCqsStopped=%d, numCqsOnClient=%d",
-            serviceStats->numCqsActive(), serviceStats->numCqsCreated(),
-            serviceStats->numCqsClosed(), serviceStats->numCqsStopped(),
-            serviceStats->numCqsOnClient());
-    LOG(buf);
-    /*
-    for(i=0; i < MAX_LISTNER; i++)
-    {
-     CqQueryPtr cqy = qs->getCq(cqNames[i]);
-     CqState::StateType state = cqy->getState();
-     CqState cqState;
-     cqState.setState(state);
-     sprintf(buf, "cq[%s] is in state[%s]", cqNames[i], cqState.toString());
-     LOG(buf);
-    }
-    */
-    ASSERT(serviceStats->numCqsActive() == 5, "active count incorrect!");
-    ASSERT(serviceStats->numCqsCreated() == 8, "created count incorrect!");
-    ASSERT(serviceStats->numCqsClosed() == 1, "closed count incorrect!");
-    ASSERT(serviceStats->numCqsStopped() == 2, "stopped count incorrect!");
-    ASSERT(serviceStats->numCqsOnClient() == 7, "cq count incorrect!");
-    try {
-      qs->stopCqs();
-    } catch (Exception& excp) {
-      std::string failmsg = "";
-      failmsg += excp.getName();
-      failmsg += ": ";
-      failmsg += excp.getMessage();
-      LOG(failmsg.c_str());
-      FAIL(failmsg.c_str());
-      excp.printStackTrace();
-    }
-    sprintf(buf,
-            "numCqsActive=%d, numCqsCreated=%d, "
-            "numCqsClosed=%d,numCqsStopped=%d, numCqsOnClient=%d",
-            serviceStats->numCqsActive(), serviceStats->numCqsCreated(),
-            serviceStats->numCqsClosed(), serviceStats->numCqsStopped(),
-            serviceStats->numCqsOnClient());
-    LOG(buf);
-    ASSERT(serviceStats->numCqsActive() == 0, "active count incorrect!");
-    ASSERT(serviceStats->numCqsCreated() == 8, "created count incorrect!");
-    ASSERT(serviceStats->numCqsClosed() == 1, "closed count incorrect!");
-    ASSERT(serviceStats->numCqsStopped() == 7, "stopped count incorrect!");
-    ASSERT(serviceStats->numCqsOnClient() == 7, "cq count incorrect!");
-    try {
-      qs->closeCqs();
-    } catch (Exception& excp) {
-      std::string failmsg = "";
-      failmsg += excp.getName();
-      failmsg += ": ";
-      failmsg += excp.getMessage();
-      LOG(failmsg.c_str());
-      FAIL(failmsg.c_str());
-      excp.printStackTrace();
-    }
-    sprintf(buf,
-            "numCqsActive=%d, numCqsCreated=%d, "
-            "numCqsClosed=%d,numCqsStopped=%d, numCqsOnClient=%d",
-            serviceStats->numCqsActive(), serviceStats->numCqsCreated(),
-            serviceStats->numCqsClosed(), serviceStats->numCqsStopped(),
-            serviceStats->numCqsOnClient());
-    LOG(buf);
-    ASSERT(serviceStats->numCqsActive() == 0, "active count incorrect!");
-    ASSERT(serviceStats->numCqsCreated() == 8, "created count incorrect!");
-    ASSERT(serviceStats->numCqsClosed() == 8, "closed count incorrect!");
-    ASSERT(serviceStats->numCqsStopped() == 0, "stopped count incorrect!");
-    ASSERT(serviceStats->numCqsOnClient() == 0, "cq count incorrect!");
-
-    i = 0;
-    auto cqLstner = std::make_shared<MyCqListener>(i);
-    cqFac.addCqListener(cqLstner);
-    CqAttributesPtr cqAttr = cqFac.create();
-    try {
-      CqQueryPtr qry = qs->newCq(cqNames[i], queryStrings[i], cqAttr);
-      qry->execute();
-      qry->stop();
-      qry->close();
-    } catch (Exception& excp) {
-      std::string failmsg = "";
-      failmsg += excp.getName();
-      failmsg += ": ";
-      failmsg += excp.getMessage();
-      LOG(failmsg.c_str());
-      FAIL(failmsg.c_str());
-      excp.printStackTrace();
-    }
-
-    LOG("StepFour complete.");
-  }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT1, CloseCache1)
-  {
-    LOG("cleanProc 1...");
-    cleanProc();
-  }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT2, CloseCache2)
-  {
-    LOG("cleanProc 2...");
-    cleanProc();
-  }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(SERVER1, CloseServer1)
-  {
-    LOG("closing Server1...");
-    if (isLocalServer) {
-      CacheHelper::closeServer(1);
-      LOG("SERVER1 stopped");
-    }
-  }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(LOCATORSERVER, CreateLocator)
-  {
-    if (isLocator) CacheHelper::initLocator(1);
-    LOG("Locator1 started");
-  }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(LOCATORSERVER, CloseLocator)
-  {
-    CacheHelper::closeLocator(1);
-    LOG("Locator1 stopped");
-  }
-END_TASK_DEFINITION
-
-void doThinClientCq() {
-  CALL_TASK(CreateLocator);
-  CALL_TASK(CreateServer1_Locator);
-
-  CALL_TASK(StepOne_PoolLocator);
-  CALL_TASK(StepOne2_PoolLocator);
-
-  CALL_TASK(StepTwo);
-  CALL_TASK(StepThree);
-  CALL_TASK(StepTwo2);
-  CALL_TASK(StepFour);
-  CALL_TASK(CloseCache1);
-  CALL_TASK(CloseCache2);
-  CALL_TASK(CloseServer1);
-
-  CALL_TASK(CloseLocator);
-}
-
-DUNIT_MAIN
-  { doThinClientCq(); }
-END_MAIN
diff --git a/cppcache/src/Cache.cpp b/cppcache/src/Cache.cpp
index bbd7c18..304a499 100644
--- a/cppcache/src/Cache.cpp
+++ b/cppcache/src/Cache.cpp
@@ -116,20 +116,6 @@ RegionPtr Cache::getRegion(const char* path) {
 
 void Cache::rootRegions(VectorOfRegion& regions) {
   m_cacheImpl->rootRegions(regions);
-  /*VectorOfRegion tmp;
-   //this can cause issue when pool attached with region in multiuserSecure mode
-   m_cacheImpl->rootRegions(tmp);
-
-   if (tmp.size() > 0)
-   {
-     for(size_t i = 0; i< tmp.size(); i++)
-     {
-       if (!isPoolInMultiuserMode(tmp.at(i)))
-       {
-         regions.push_back(tmp.at(i));
-       }
-     }
-   }*/
 }
 
 RegionFactory Cache::createRegionFactory(RegionShortcut preDefinedRegion) {
@@ -151,11 +137,13 @@ CacheTransactionManagerPtr Cache::getCacheTransactionManager() {
 TypeRegistry& Cache::getTypeRegistry() { return *(m_typeRegistry.get()); }
 
 Cache::Cache(const std::string& name, PropertiesPtr dsProp,
-             bool ignorePdxUnreadFields, bool readPdxSerialized) {
+             bool ignorePdxUnreadFields, bool readPdxSerialized,
+             const AuthInitializePtr& authInitialize) {
   auto dsPtr = DistributedSystem::create(DEFAULT_DS_NAME, this, dsProp);
   dsPtr->connect();
-  m_cacheImpl = std::unique_ptr<CacheImpl>(new CacheImpl(
-      this, name, std::move(dsPtr), ignorePdxUnreadFields, readPdxSerialized));
+  m_cacheImpl = std::unique_ptr<CacheImpl>(
+      new CacheImpl(this, name, std::move(dsPtr), ignorePdxUnreadFields,
+                    readPdxSerialized, authInitialize));
   m_typeRegistry = std::unique_ptr<TypeRegistry>(new TypeRegistry(*this));
 }
 
diff --git a/cppcache/src/CacheFactory.cpp b/cppcache/src/CacheFactory.cpp
index 06da8d3..e754f91 100644
--- a/cppcache/src/CacheFactory.cpp
+++ b/cppcache/src/CacheFactory.cpp
@@ -67,7 +67,7 @@ void CacheFactory::create_(const char* name, const char* id_data,
   }
 
   cptr = std::make_shared<Cache>(name, dsProp, ignorePdxUnreadFields,
-                                 readPdxSerialized);
+                                 readPdxSerialized, authInitialize);
 }  // namespace client
 
 const char* CacheFactory::getVersion() { return PRODUCT_VERSION; }
@@ -171,6 +171,12 @@ CacheFactoryPtr CacheFactory::set(const char* name, const char* value) {
   return shared_from_this();
 }
 
+CacheFactoryPtr CacheFactory::setAuthInitialize(
+    const AuthInitializePtr& authInitialize) {
+  this->authInitialize = authInitialize;
+  return shared_from_this();
+}
+
 CacheFactoryPtr CacheFactory::setPdxIgnoreUnreadFields(bool ignore) {
   ignorePdxUnreadFields = ignore;
   return shared_from_this();
diff --git a/cppcache/src/CacheImpl.cpp b/cppcache/src/CacheImpl.cpp
index e4acce7..a800049 100644
--- a/cppcache/src/CacheImpl.cpp
+++ b/cppcache/src/CacheImpl.cpp
@@ -48,7 +48,8 @@ using namespace apache::geode::client;
 
 CacheImpl::CacheImpl(Cache* c, const std::string& name,
                      std::unique_ptr<DistributedSystem> sys, bool iPUF,
-                     bool readPdxSerialized)
+                     bool readPdxSerialized,
+                     const AuthInitializePtr& authInitialize)
     : m_name(name),
       m_defaultPool(nullptr),
       m_ignorePdxUnreadFields(iPUF),
@@ -73,7 +74,8 @@ CacheImpl::CacheImpl(Cache* c, const std::string& name,
           std::unique_ptr<ExpiryTaskManager>(new ExpiryTaskManager())),
       m_clientProxyMembershipIDFactory(m_distributedSystem->getName()),
       m_threadPool(new ThreadPool(
-          m_distributedSystem->getSystemProperties().threadPoolSize())) {
+          m_distributedSystem->getSystemProperties().threadPoolSize())),
+      m_authInitialize(authInitialize) {
   m_cacheTXManager = InternalCacheTransactionManager2PCPtr(
       new InternalCacheTransactionManager2PCImpl(c));
 
diff --git a/cppcache/src/CacheImpl.hpp b/cppcache/src/CacheImpl.hpp
index fec3a9f..d830f7c 100644
--- a/cppcache/src/CacheImpl.hpp
+++ b/cppcache/src/CacheImpl.hpp
@@ -216,7 +216,7 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
    */
   CacheImpl(Cache* c, const std::string& name,
             std::unique_ptr<DistributedSystem> sys, bool ignorePdxUnreadFields,
-            bool readPdxSerialized);
+            bool readPdxSerialized, const AuthInitializePtr& authInitialize);
 
   void initServices();
   EvictionController* getEvictionController();
@@ -276,12 +276,16 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
   PdxTypeRegistryPtr getPdxTypeRegistry() const;
 
   SerializationRegistryPtr getSerializationRegistry() const;
-  inline CachePerfStats& getCachePerfStats() { return *m_cacheStats; };
+  inline CachePerfStats& getCachePerfStats() { return *m_cacheStats; }
 
   PoolManager& getPoolManager() { return *m_poolManager; }
 
   ThreadPool* getThreadPool();
 
+  inline const AuthInitializePtr& getAuthInitialize() {
+    return m_authInitialize;
+  }
+
  private:
   std::atomic<bool> m_networkhop;
   std::atomic<int> m_blacklistBucketTimeout;
@@ -343,6 +347,7 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable, private NonAssignable {
   SerializationRegistryPtr m_serializationRegistry;
   PdxTypeRegistryPtr m_pdxTypeRegistry;
   ThreadPool* m_threadPool;
+  const AuthInitializePtr m_authInitialize;
 
   friend class CacheFactory;
   friend class Cache;
diff --git a/cppcache/src/DistributedSystemImpl.cpp b/cppcache/src/DistributedSystemImpl.cpp
index b562629..38675ed 100644
--- a/cppcache/src/DistributedSystemImpl.cpp
+++ b/cppcache/src/DistributedSystemImpl.cpp
@@ -46,11 +46,6 @@ DistributedSystemImpl::~DistributedSystemImpl() {
   LOGFINE("Destroyed DistributedSystemImpl");
 }
 
-AuthInitializePtr DistributedSystemImpl::getAuthLoader() {
-  ACE_Guard<ACE_Recursive_Thread_Mutex> authGuard(m_authLock);
-  return m_implementee->getSystemProperties().getAuthLoader();
-}
-
 void DistributedSystemImpl::connect() {}
 
 void DistributedSystemImpl::disconnect() {
diff --git a/cppcache/src/DistributedSystemImpl.hpp b/cppcache/src/DistributedSystemImpl.hpp
index 5352263..eed215e 100644
--- a/cppcache/src/DistributedSystemImpl.hpp
+++ b/cppcache/src/DistributedSystemImpl.hpp
@@ -82,10 +82,6 @@ class CPPCACHE_EXPORT DistributedSystemImpl {
    */
   virtual ~DistributedSystemImpl();
 
-  /**
-   */
-  virtual AuthInitializePtr getAuthLoader();
-
   /** Retrieve the MemberId used to create this Cache. */
   virtual void disconnect();
   virtual void connect();
@@ -129,10 +125,6 @@ class CPPCACHE_EXPORT DistributedSystemImpl {
   static void CallCliCallBack(Cache& cache);
 
  private:
-  /**
-   * Guard for getAuthLoader()
-   */
-  ACE_Recursive_Thread_Mutex m_authLock;
   static ACE_Recursive_Thread_Mutex m_cliCallbackLock;
   static volatile bool m_isCliCallbackSet;
   static std::map<int, CliCallbackMethod> m_cliCallbackMap;
diff --git a/cppcache/src/SystemProperties.cpp b/cppcache/src/SystemProperties.cpp
index f9675f7..09065e3 100644
--- a/cppcache/src/SystemProperties.cpp
+++ b/cppcache/src/SystemProperties.cpp
@@ -160,8 +160,6 @@ const int32_t DefaultRedundancyMonitorInterval = 10;
 const int32_t DefaultNotifyAckInterval = 1;
 const int32_t DefaultNotifyDupCheckLife = 300;
 const char DefaultSecurityPrefix[] = "security-";
-const char DefaultAuthIniLoaderFactory[] = "security-client-auth-factory";
-const char DefaultAuthIniLoaderLibrary[] = "security-client-auth-library";
 const char DefaultSecurityClientDhAlgo[] ATTR_UNUSED = "";
 const char DefaultSecurityClientKsPath[] ATTR_UNUSED = "";
 const uint32_t DefaultThreadPoolSize = ACE_OS::num_processors() * 2;
@@ -173,7 +171,6 @@ const bool DefaultReadTimeoutUnitInMillis = false;
 const bool DefaultOnClientDisconnectClearPdxTypeIds = false;
 }  // namespace
 
-LibraryAuthInitializeFn SystemProperties::managedAuthInitializeFn = nullptr;
 
 SystemProperties::SystemProperties(const PropertiesPtr& propertiesPtr,
                                    const char* configFile)
@@ -202,11 +199,8 @@ SystemProperties::SystemProperties(const PropertiesPtr& propertiesPtr,
       m_redundancyMonitorInterval(DefaultRedundancyMonitorInterval),
       m_notifyAckInterval(DefaultNotifyAckInterval),
       m_notifyDupCheckLife(DefaultNotifyDupCheckLife),
-      m_AuthIniLoaderLibrary(nullptr),
-      m_AuthIniLoaderFactory(nullptr),
       m_securityClientDhAlgo(nullptr),
       m_securityClientKsPath(nullptr),
-      m_authInitializer(nullptr),
       m_durableClientId(nullptr),
       m_durableTimeout(DefaultDurableTimeout),
       m_connectTimeout(DefaultConnectTimeout),
@@ -287,16 +281,9 @@ SystemProperties::SystemProperties(const PropertiesPtr& propertiesPtr,
     propertiesPtr->foreach (processPropsVisitor);
   }
 
-  m_AuthIniLoaderLibrary =
-      m_securityPropertiesPtr->find(DefaultAuthIniLoaderLibrary);
-  m_AuthIniLoaderFactory =
-      m_securityPropertiesPtr->find(DefaultAuthIniLoaderFactory);
   m_securityClientDhAlgo = m_securityPropertiesPtr->find(SecurityClientDhAlgo);
   m_securityClientKsPath = m_securityPropertiesPtr->find(SecurityClientKsPath);
 
-  // Deleting inorder to prevent it from sending to Server.
-  m_securityPropertiesPtr->remove(DefaultAuthIniLoaderLibrary);
-  m_securityPropertiesPtr->remove(DefaultAuthIniLoaderFactory);
 }
 
 SystemProperties::~SystemProperties() {
@@ -873,12 +860,6 @@ void SystemProperties::logSettings() {
   settings += "\n  redundancy-monitor-interval = ";
   settings += buf;
 
-  settings += "\n  security-client-auth-factory = ";
-  settings += authInitFactory();
-
-  settings += "\n  security-client-auth-library = ";
-  settings += authInitLibrary();
-
   settings += "\n  security-client-dhalgo = ";
   settings += securityClientDhAlgo();
 
@@ -924,27 +905,3 @@ void SystemProperties::logSettings() {
   LOGCONFIG(settings.c_str());
 }
 
-AuthInitializePtr SystemProperties::getAuthLoader() {
-  if ((m_authInitializer == nullptr) && (m_AuthIniLoaderLibrary != nullptr &&
-                                         m_AuthIniLoaderFactory != nullptr)) {
-    if (managedAuthInitializeFn != nullptr &&
-        strchr(m_AuthIniLoaderFactory->asChar(), '.') != nullptr) {
-      // this is a managed library
-      m_authInitializer.reset((*managedAuthInitializeFn)(
-          m_AuthIniLoaderLibrary->asChar(), m_AuthIniLoaderFactory->asChar()));
-    } else {
-      AuthInitialize* (*funcptr)();
-      funcptr = reinterpret_cast<AuthInitialize* (*)()>(getFactoryFunc(
-          m_AuthIniLoaderLibrary->asChar(), m_AuthIniLoaderFactory->asChar()));
-      if (funcptr == nullptr) {
-        LOGERROR("Failed to acquire handle to AuthInitialize library");
-        return nullptr;
-      }
-      AuthInitialize* p = funcptr();
-      m_authInitializer.reset(p);
-    }
-  } else if (m_authInitializer == nullptr) {
-    LOGFINE("No AuthInitialize library or factory configured");
-  }
-  return m_authInitializer;
-}
diff --git a/cppcache/src/TcrConnection.cpp b/cppcache/src/TcrConnection.cpp
index dafaed2..91fda78 100644
--- a/cppcache/src/TcrConnection.cpp
+++ b/cppcache/src/TcrConnection.cpp
@@ -14,16 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "TcrConnection.hpp"
+#include <memory.h>
+#include <ace/INET_Addr.h>
+#include <ace/OS.h>
+
 #include <geode/DistributedSystem.hpp>
 #include <geode/SystemProperties.hpp>
+#include <geode/AuthInitialize.hpp>
+
+#include "TcrConnection.hpp"
+
 #include "Connector.hpp"
 #include "TcpSslConn.hpp"
 #include "ClientProxyMembershipID.hpp"
 #include "ThinClientPoolHADM.hpp"
-#include <memory.h>
-#include <ace/INET_Addr.h>
-#include <ace/OS.h>
 #include "TcrEndpoint.hpp"
 
 #include "GeodeTypeIdsImpl.hpp"
@@ -36,6 +40,7 @@
 #include "ThinClientRegion.hpp"
 
 using namespace apache::geode::client;
+
 const int HEADER_LENGTH = 17;
 const int MAXBUFSIZE ATTR_UNUSED = 65536;
 const int BODYLENPOS ATTR_UNUSED = 4;
@@ -62,8 +67,8 @@ bool TcrConnection::InitTcrConnection(
   m_creationTime = ACE_OS::gettimeofday();
   connectionId = INITIAL_CONNECTION_ID;
   m_lastAccessed = ACE_OS::gettimeofday();
-  const auto& distributedSystem =
-      m_poolDM->getConnectionManager().getCacheImpl()->getDistributedSystem();
+  auto cacheImpl = m_poolDM->getConnectionManager().getCacheImpl();
+  const auto& distributedSystem = cacheImpl->getDistributedSystem();
   const auto& sysProp = distributedSystem.getSystemProperties();
 
   LOGDEBUG(
@@ -94,7 +99,7 @@ bool TcrConnection::InitTcrConnection(
 
   GF_DEV_ASSERT(m_conn != nullptr);
 
-  auto handShakeMsg = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+  auto handShakeMsg = cacheImpl->getCache()->createDataOutput();
   bool isNotificationChannel = false;
   // Send byte Acceptor.CLIENT_TO_SERVER = (byte) 100;
   // Send byte Acceptor.SERVER_TO_CLIENT = (byte) 101;
@@ -166,10 +171,8 @@ bool TcrConnection::InitTcrConnection(
 
     // Write ClientProxyMembershipID serialized object.
     uint32_t memIdBufferLength;
-    const auto memId =
-        m_connectionManager->getCacheImpl()
-            ->getClientProxyMembershipIDFactory()
-            .create(hostName, hostAddr, hostPort, durableId, durableTimeOut);
+    const auto memId = cacheImpl->getClientProxyMembershipIDFactory().create(
+        hostName, hostAddr, hostPort, durableId, durableTimeOut);
     const auto memIdBuffer = memId->getDSMemberId(memIdBufferLength);
     handShakeMsg->writeBytes((int8_t*)memIdBuffer, memIdBufferLength);
   }
@@ -183,12 +186,11 @@ bool TcrConnection::InitTcrConnection(
   // Write overrides (just conflation for now)
   handShakeMsg->write(getOverrides(&sysProp));
 
-  bool tmpIsSecurityOn = sysProp.isSecurityOn();
+  bool tmpIsSecurityOn = nullptr != cacheImpl->getAuthInitialize();
   isDhOn = sysProp.isDhOn();
 
   if (m_endpointObj) {
-    tmpIsSecurityOn =
-        sysProp.isSecurityOn() || this->m_endpointObj->isMultiUserMode();
+    tmpIsSecurityOn = tmpIsSecurityOn || this->m_endpointObj->isMultiUserMode();
     CacheableStringPtr dhalgo =
         sysProp.getSecurityProperties()->find("security-client-dhalgo");
 
@@ -234,8 +236,7 @@ bool TcrConnection::InitTcrConnection(
       }
       // only for backward connection
       if (isClientNotification) {
-        if (const auto& authInitialize =
-                distributedSystem.m_impl->getAuthLoader()) {
+        if (const auto& authInitialize = cacheImpl->getAuthInitialize()) {
           LOGFINER(
               "TcrConnection: acquired handle to authLoader, "
               "invoking getCredentials");
@@ -261,7 +262,6 @@ bool TcrConnection::InitTcrConnection(
         handShakeMsg->writeASCII(sysProp.securityClientDhAlgo());
 
         // Send the client's DH public key to the server
-        // CacheableBytesPtr dhPubKey = DiffieHellman::getPublicKey();
         CacheableBytesPtr dhPubKey = m_dh->getPublicKey();
         LOGDEBUG("DH pubkey send len is %d", dhPubKey->length());
         dhPubKey->toData(*handShakeMsg);
@@ -353,7 +353,7 @@ bool TcrConnection::InitTcrConnection(
       LOGDEBUG("Handshake: Got challengeSize %d", challengeBytes->length());
 
       // encrypt the credentials and challenge bytes
-      auto cleartext = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+      auto cleartext = cacheImpl->getCache()->createDataOutput();
       if (isClientNotification) {  //:only for backward connection
         credentials->toData(*cleartext);
       }
@@ -361,7 +361,7 @@ bool TcrConnection::InitTcrConnection(
       CacheableBytesPtr ciphertext =
           m_dh->encrypt(cleartext->getBuffer(), cleartext->getBufferLength());
 
-      auto sendCreds = m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+      auto sendCreds = cacheImpl->getCache()->createDataOutput();
       ciphertext->toData(*sendCreds);
       uint32_t credLen;
       char* credData = (char*)sendCreds->getBuffer(&credLen);
@@ -401,7 +401,8 @@ bool TcrConnection::InitTcrConnection(
       m_hasServerQueue = NON_REDUNDANT_SERVER;
     }
     CacheableBytesPtr queueSizeMsg = readHandshakeData(4, connectTimeout);
-    auto dI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(queueSizeMsg->value(), queueSizeMsg->length());
+    auto dI = cacheImpl->getCache()->createDataInput(queueSizeMsg->value(),
+                                                     queueSizeMsg->length());
     int32_t queueSize = 0;
     dI->readInt(&queueSize);
     m_queueSize = queueSize > 0 ? queueSize : 0;
@@ -432,38 +433,35 @@ bool TcrConnection::InitTcrConnection(
       if (static_cast<int8_t>((*arrayLenHeader)[0]) == -2) {
         CacheableBytesPtr recvMsgLenBytes =
             readHandshakeData(2, connectTimeout);
-        auto dI2 = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
-                      recvMsgLenBytes->value(), recvMsgLenBytes->length());
+        auto dI2 = cacheImpl->getCache()->createDataInput(
+            recvMsgLenBytes->value(), recvMsgLenBytes->length());
         int16_t recvMsgLenShort = 0;
         dI2->readInt(&recvMsgLenShort);
         recvMsgLen = recvMsgLenShort;
       } else if (static_cast<int8_t>((*arrayLenHeader)[0]) == -3) {
         CacheableBytesPtr recvMsgLenBytes =
             readHandshakeData(4, connectTimeout);
-        auto dI2 = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
-                      recvMsgLenBytes->value(), recvMsgLenBytes->length());
+        auto dI2 = cacheImpl->getCache()->createDataInput(
+            recvMsgLenBytes->value(), recvMsgLenBytes->length());
         dI2->readInt(&recvMsgLen);
       }
       auto recvMessage = readHandshakeData(recvMsgLen, connectTimeout);
       // If the distributed member has not been set yet, set it.
       if (getEndpointObject()->getDistributedMemberID() == 0) {
         LOGDEBUG("Deserializing distributed member Id");
-        auto diForClient = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
-                       recvMessage->value(), recvMessage->length());
+        auto diForClient = cacheImpl->getCache()->createDataInput(
+            recvMessage->value(), recvMessage->length());
         ClientProxyMembershipIDPtr member;
         diForClient->readObject(member);
-        auto memId = m_poolDM->getConnectionManager()
-                         .getCacheImpl()
-                         ->getMemberListForVersionStamp()
-                         ->add(member);
+        auto memId = cacheImpl->getMemberListForVersionStamp()->add(member);
         getEndpointObject()->setDistributedMemberID(memId);
         LOGDEBUG("Deserialized distributed member Id %d", memId);
       }
     }
 
     CacheableBytesPtr recvMsgLenBytes = readHandshakeData(2, connectTimeout);
-    auto dI3 = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
-                  recvMsgLenBytes->value(), recvMsgLenBytes->length());
+    auto dI3 = cacheImpl->getCache()->createDataInput(
+        recvMsgLenBytes->value(), recvMsgLenBytes->length());
     uint16_t recvMsgLen2 = 0;
     dI3->readInt(&recvMsgLen2);
     CacheableBytesPtr recvMessage =
@@ -471,8 +469,8 @@ bool TcrConnection::InitTcrConnection(
 
     if (!isClientNotification) {
       CacheableBytesPtr deltaEnabledMsg = readHandshakeData(1, connectTimeout);
-      auto di = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
-                   deltaEnabledMsg->value(), 1);
+      auto di =
+          cacheImpl->getCache()->createDataInput(deltaEnabledMsg->value(), 1);
       bool isDeltaEnabledOnServer;
       di->readBoolean(&isDeltaEnabledOnServer);
       ThinClientBaseDM::setDeltaEnabledOnServer(isDeltaEnabledOnServer);
@@ -954,7 +952,7 @@ char* TcrConnection::readMessage(size_t* recvLen, uint32_t receiveTimeoutSec,
       Utils::convertBytesToString(msg_header, HEADER_LENGTH)->asChar());
 
   auto input = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
-                  reinterpret_cast<uint8_t*>(msg_header), HEADER_LENGTH);
+      reinterpret_cast<uint8_t*>(msg_header), HEADER_LENGTH);
   input->readInt(&msgType);
   input->readInt(&msgLen);
   //  check that message length is valid.
@@ -1064,7 +1062,7 @@ void TcrConnection::readMessageChunked(TcrMessageReply& reply,
       Utils::convertBytesToString(msg_header, HDR_LEN_12)->asChar());
 
   auto input = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
-                  msg_header, HDR_LEN_12);
+      msg_header, HDR_LEN_12);
   int32_t msgType;
   input->readInt(&msgType);
   reply.setMessageType(msgType);
@@ -1130,8 +1128,9 @@ void TcrConnection::readMessageChunked(TcrMessageReply& reply,
         Utils::convertBytesToString((msg_header + HDR_LEN_12), HDR_LEN)
             ->asChar());
 
-    auto input = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
-                    msg_header + HDR_LEN_12, HDR_LEN);
+    auto input =
+        m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+            msg_header + HDR_LEN_12, HDR_LEN);
     int32_t chunkLen;
     input->readInt(&chunkLen);
     //  check that chunk length is valid.
@@ -1293,8 +1292,9 @@ CacheableBytesPtr TcrConnection::readHandshakeByteArray(
 // read a byte array
 uint32_t TcrConnection::readHandshakeArraySize(uint32_t connectTimeout) {
   CacheableBytesPtr codeBytes = readHandshakeData(1, connectTimeout);
-  auto codeDI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
-                   codeBytes->value(), codeBytes->length());
+  auto codeDI =
+      m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+          codeBytes->value(), codeBytes->length());
   uint8_t code = 0;
   codeDI->read(&code);
   uint32_t arraySize = 0;
@@ -1305,13 +1305,17 @@ uint32_t TcrConnection::readHandshakeArraySize(uint32_t connectTimeout) {
     if (tempLen > 252) {  // 252 is java's ((byte)-4 && 0xFF)
       if (code == 0xFE) {
         CacheableBytesPtr lenBytes = readHandshakeData(2, connectTimeout);
-        auto lenDI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(lenBytes->value(), lenBytes->length());
+        auto lenDI =
+            m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+                lenBytes->value(), lenBytes->length());
         uint16_t val;
         lenDI->readInt(&val);
         tempLen = val;
       } else if (code == 0xFD) {
         CacheableBytesPtr lenBytes = readHandshakeData(4, connectTimeout);
-        auto lenDI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(lenBytes->value(), lenBytes->length());
+        auto lenDI =
+            m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+                lenBytes->value(), lenBytes->length());
         uint32_t val;
         lenDI->readInt(&val);
         tempLen = val;
@@ -1402,7 +1406,8 @@ int32_t TcrConnection::readHandShakeInt(uint32_t connectTimeout) {
     }
   }
 
-  auto di = m_connectionManager->getCacheImpl()->getCache()->createDataInput(recvMessage, 4);
+  auto di = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+      recvMessage, 4);
   int32_t val;
   di->readInt(&val);
 
@@ -1440,7 +1445,9 @@ CacheableStringPtr TcrConnection::readHandshakeString(uint32_t connectTimeout) {
     case GF_STRING: {
       uint16_t shortLen = 0;
       CacheableBytesPtr lenBytes = readHandshakeData(2, connectTimeout);
-      auto lenDI = m_connectionManager->getCacheImpl()->getCache()->createDataInput(lenBytes->value(), lenBytes->length());
+      auto lenDI =
+          m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+              lenBytes->value(), lenBytes->length());
       lenDI->readInt(&shortLen);
       length = shortLen;
       break;
diff --git a/cppcache/src/TcrEndpoint.cpp b/cppcache/src/TcrEndpoint.cpp
index ac480ea..6a1d05f 100644
--- a/cppcache/src/TcrEndpoint.cpp
+++ b/cppcache/src/TcrEndpoint.cpp
@@ -14,18 +14,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+#include <thread>
+#include <chrono>
 #include <ace/OS.h>
+
+#include <geode/SystemProperties.hpp>
+#include <geode/AuthInitialize.hpp>
+
 #include "TcrEndpoint.hpp"
 #include "ThinClientRegion.hpp"
 #include "ThinClientPoolHADM.hpp"
 #include "StackTrace.hpp"
-#include <geode/SystemProperties.hpp>
 #include "CacheImpl.hpp"
 #include "Utils.hpp"
 #include "DistributedSystemImpl.hpp"
 
-#include <thread>
-#include <chrono>
 
 namespace apache {
 namespace geode {
@@ -354,7 +358,7 @@ PropertiesPtr TcrEndpoint::getCredentials() {
   const auto& tmpSecurityProperties =
       distributedSystem.getSystemProperties().getSecurityProperties();
 
-  if (const auto& authInitialize = distributedSystem.m_impl->getAuthLoader()) {
+  if (const auto& authInitialize = m_cacheImpl->getAuthInitialize()) {
     LOGFINER(
         "Acquired handle to AuthInitialize plugin, "
         "getting credentials for %s",
diff --git a/cppcache/src/ThinClientBaseDM.cpp b/cppcache/src/ThinClientBaseDM.cpp
index adf882e..9c37f20 100644
--- a/cppcache/src/ThinClientBaseDM.cpp
+++ b/cppcache/src/ThinClientBaseDM.cpp
@@ -54,10 +54,7 @@ void ThinClientBaseDM::init() {
 }
 
 bool ThinClientBaseDM::isSecurityOn() {
-  return m_connManager.getCacheImpl()
-      ->getDistributedSystem()
-      .getSystemProperties()
-      .isSecurityOn();
+  return m_connManager.getCacheImpl()->getAuthInitialize() != nullptr;
 }
 
 void ThinClientBaseDM::destroy(bool keepalive) {
diff --git a/cppcache/src/ThinClientDistributionManager.cpp b/cppcache/src/ThinClientDistributionManager.cpp
index 5fd092d..7edd6f8 100644
--- a/cppcache/src/ThinClientDistributionManager.cpp
+++ b/cppcache/src/ThinClientDistributionManager.cpp
@@ -14,10 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include "ThinClientDistributionManager.hpp"
+
 #include <algorithm>
-#include "ThinClientRegion.hpp"
+
 #include <geode/SystemProperties.hpp>
+#include <geode/AuthInitialize.hpp>
+
+#include "ThinClientDistributionManager.hpp"
+#include "ThinClientRegion.hpp"
 #include "DistributedSystemImpl.hpp"
 
 using namespace apache::geode::client;
@@ -306,12 +310,12 @@ bool ThinClientDistributionManager::postFailoverAction(TcrEndpoint* endpoint) {
 }
 
 PropertiesPtr ThinClientDistributionManager::getCredentials(TcrEndpoint* ep) {
-  const auto& distributedSystem =
-      m_connManager.getCacheImpl()->getDistributedSystem();
+  auto cacheImpl = m_connManager.getCacheImpl();
+  const auto& distributedSystem = cacheImpl->getDistributedSystem();
   const auto& tmpSecurityProperties =
       distributedSystem.getSystemProperties().getSecurityProperties();
 
-  if (const auto& authInitialize = distributedSystem.m_impl->getAuthLoader()) {
+  if (const auto& authInitialize = cacheImpl->getAuthInitialize()) {
     LOGFINER(
         "ThinClientDistributionManager::getCredentials: acquired handle to "
         "authLoader, "
diff --git a/cppcache/src/ThinClientPoolDM.cpp b/cppcache/src/ThinClientPoolDM.cpp
index 8b3f249..98d520e 100644
--- a/cppcache/src/ThinClientPoolDM.cpp
+++ b/cppcache/src/ThinClientPoolDM.cpp
@@ -14,21 +14,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+#include <algorithm>
+#include <ace/INET_Addr.h>
+
+#include <geode/ResultCollector.hpp>
+#include <geode/SystemProperties.hpp>
+#include <geode/PoolManager.hpp>
+#include <geode/AuthInitialize.hpp>
+
+#include "statistics/PoolStatsSampler.hpp"
 #include "ThinClientPoolDM.hpp"
 #include "TcrEndpoint.hpp"
 #include "ThinClientRegion.hpp"
-#include <geode/ResultCollector.hpp>
 #include "ExecutionImpl.hpp"
 #include "ExpiryHandler_T.hpp"
-#include <ace/INET_Addr.h>
 #include "ExpiryTaskManager.hpp"
-#include <geode/SystemProperties.hpp>
-#include <statistics/PoolStatsSampler.hpp>
 #include "DistributedSystemImpl.hpp"
 #include "UserAttributes.hpp"
-#include <algorithm>
 #include "ThinClientStickyManager.hpp"
-#include <geode/PoolManager.hpp>
 
 #include "NonCopyable.hpp"
 
@@ -157,12 +161,12 @@ ThinClientPoolDM::ThinClientPoolDM(const char* name,
   if (firstGurd) ClientProxyMembershipID::increaseSynchCounter();
   firstGurd = true;
 
-  auto& distributedSystem =
-      m_connManager.getCacheImpl()->getDistributedSystem();
+  auto cacheImpl = m_connManager.getCacheImpl();
+  auto& distributedSystem = cacheImpl->getDistributedSystem();
 
   auto& sysProp = distributedSystem.getSystemProperties();
   // to set security flag at pool level
-  this->m_isSecurityOn = sysProp.isSecurityOn();
+  this->m_isSecurityOn = cacheImpl->getAuthInitialize() != nullptr;
 
   ACE_TCHAR hostName[256];
   ACE_OS::hostname(hostName, sizeof(hostName) - 1);
@@ -180,10 +184,8 @@ ThinClientPoolDM::ThinClientPoolDM(const char* name,
                              : "");
 
   const uint32_t durableTimeOut = sysProp.durableTimeout();
-  m_memId =
-      m_connManager.getCacheImpl()->getClientProxyMembershipIDFactory().create(
-          hostName, hostAddr, hostPort, clientDurableId.c_str(),
-          durableTimeOut);
+  m_memId = cacheImpl->getClientProxyMembershipIDFactory().create(
+      hostName, hostAddr, hostPort, clientDurableId.c_str(), durableTimeOut);
 
   if (m_attrs->m_initLocList.size() == 0 &&
       m_attrs->m_initServList.size() == 0) {
@@ -213,17 +215,16 @@ ThinClientPoolDM::ThinClientPoolDM(const char* name,
 
 void ThinClientPoolDM::init() {
   LOGDEBUG("ThinClientPoolDM::init: Starting pool initialization");
-
-  auto& sysProp = m_connManager.getCacheImpl()
-                      ->getDistributedSystem()
-                      .getSystemProperties();
+  auto cacheImpl = m_connManager.getCacheImpl();
+  auto& sysProp = cacheImpl->getDistributedSystem().getSystemProperties();
   m_isMultiUserMode = this->getMultiuserAuthentication();
+
   if (m_isMultiUserMode) {
     LOGINFO("Multiuser authentication is enabled for pool %s",
             m_poolName.c_str());
   }
   // to set security flag at pool level
-  this->m_isSecurityOn = sysProp.isSecurityOn();
+  this->m_isSecurityOn = cacheImpl->getAuthInitialize() != nullptr;
 
   LOGDEBUG("ThinClientPoolDM::init: security in on/off = %d ",
            this->m_isSecurityOn);
@@ -241,12 +242,12 @@ void ThinClientPoolDM::init() {
 }
 
 PropertiesPtr ThinClientPoolDM::getCredentials(TcrEndpoint* ep) {
-  const auto& distributedSystem =
-      m_connManager.getCacheImpl()->getDistributedSystem();
+  auto cacheImpl = m_connManager.getCacheImpl();
+  const auto& distributedSystem = cacheImpl->getDistributedSystem();
   const auto& tmpSecurityProperties =
       distributedSystem.getSystemProperties().getSecurityProperties();
 
-  if (const auto& authInitialize = distributedSystem.m_impl->getAuthLoader()) {
+  if (const auto& authInitialize = cacheImpl->getAuthInitialize()) {
     LOGFINER(
         "ThinClientPoolDM::getCredentials: acquired handle to authLoader, "
         "invoking getCredentials %s",

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].