[
https://issues.apache.org/jira/browse/GEODE-4066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16288324#comment-16288324
]
ASF GitHub Bot commented on GEODE-4066:
---------------------------------------
dgkimura closed pull request #167: GEODE-4066: Add security manager integration
test
URL: https://github.com/apache/geode-native/pull/167
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/cppcache/include/geode/DataInput.hpp
b/cppcache/include/geode/DataInput.hpp
index e0f67c9a..3b28cf9e 100644
--- a/cppcache/include/geode/DataInput.hpp
+++ b/cppcache/include/geode/DataInput.hpp
@@ -46,6 +46,7 @@ namespace client {
class SerializationRegistry;
class DataInputInternal;
+class CacheImpl;
/**
* Provide operations for reading primitive data values, byte arrays,
@@ -918,7 +919,7 @@ class CPPCACHE_EXPORT DataInput {
protected:
/** constructor given a pre-allocated byte array with size */
- DataInput(const uint8_t* m_buffer, int32_t len, const Cache* cache)
+ DataInput(const uint8_t* m_buffer, int32_t len, const CacheImpl* cache)
: m_buf(m_buffer),
m_bufHead(m_buffer),
m_bufLength(len),
@@ -932,7 +933,7 @@ class CPPCACHE_EXPORT DataInput {
const uint8_t* m_bufHead;
int32_t m_bufLength;
std::reference_wrapper<const std::string> m_poolName;
- const Cache* m_cache;
+ const CacheImpl* m_cache;
std::shared_ptr<Serializable> readObjectInternal(int8_t typeId = -1);
@@ -1062,6 +1063,7 @@ class CPPCACHE_EXPORT DataInput {
DataInput& operator=(const DataInput&) = delete;
friend Cache;
+ friend CacheImpl;
friend DataInputInternal;
};
} // namespace client
diff --git a/cppcache/include/geode/DataOutput.hpp
b/cppcache/include/geode/DataOutput.hpp
index 80eaed47..0aa07ced 100644
--- a/cppcache/include/geode/DataOutput.hpp
+++ b/cppcache/include/geode/DataOutput.hpp
@@ -40,6 +40,7 @@ namespace geode {
namespace client {
class SerializationRegistry;
class DataOutputInternal;
+class CacheImpl;
/**
* Provide operations for writing primitive data values, byte arrays,
@@ -687,7 +688,7 @@ class CPPCACHE_EXPORT DataOutput {
/**
* Construct a new DataOutput.
*/
- DataOutput(const Cache* cache);
+ DataOutput(const CacheImpl* cache);
DataOutput() : DataOutput(nullptr) {}
@@ -710,7 +711,7 @@ class CPPCACHE_EXPORT DataOutput {
static uint32_t m_highWaterMark;
// flag to indicate we have a big buffer
volatile bool m_haveBigBuffer;
- const Cache* m_cache;
+ const CacheImpl* m_cache;
std::reference_wrapper<const std::string> m_poolName;
inline void writeAscii(const std::string& value) {
@@ -860,6 +861,7 @@ class CPPCACHE_EXPORT DataOutput {
DataOutput& operator=(const DataOutput&);
friend Cache;
+ friend CacheImpl;
friend DataOutputInternal;
friend CacheableString;
};
diff --git a/cppcache/integration-test/CacheHelper.cpp
b/cppcache/integration-test/CacheHelper.cpp
index da6abd92..d4401ecf 100644
--- a/cppcache/integration-test/CacheHelper.cpp
+++ b/cppcache/integration-test/CacheHelper.cpp
@@ -1187,7 +1187,7 @@ void CacheHelper::cleanupServerInstances() {
void CacheHelper::initServer(int instance, const char* xml,
const char* locHostport, const char* authParam,
bool ssl, bool enableDelta, bool multiDS,
- bool testServerGC, bool untrustedCert) {
+ bool testServerGC, bool untrustedCert, bool
useSecurityManager) {
if (!isServerCleanupCallbackRegistered &&
gClientCleanup.registerCallback(&CacheHelper::cleanupServerInstances)) {
isServerCleanupCallbackRegistered = true;
@@ -1341,17 +1341,18 @@ void CacheHelper::initServer(int instance, const char*
xml,
if (locHostport != nullptr) { // check number of locator host port.
std::string geodeProperties =
- generateGeodeProperties(currDir, ssl, -1, 0, untrustedCert);
+ generateGeodeProperties(currDir, ssl, -1, 0, untrustedCert,
useSecurityManager);
sprintf(
cmd,
"%s/bin/%s start server --classpath=%s --name=%s "
- "--cache-xml-file=%s --dir=%s --server-port=%d --log-level=%s "
+ "--cache-xml-file=%s %s --dir=%s --server-port=%d --log-level=%s "
"--properties-file=%s %s %s "
"--J=-Dgemfire.tombstone-timeout=%ld "
"--J=-Dgemfire.tombstone-gc-hreshold=%ld "
"--J=-Dgemfire.security-log-level=%s --J=-Xmx1024m --J=-Xms128m 2>&1",
gfjavaenv, GFSH, classpath, sname.c_str(), xmlFile.c_str(),
+ useSecurityManager ? "--user=root --password=root-password" : "",
currDir.c_str(), portNum, gfLogLevel, geodeProperties.c_str(),
authParam, deltaProperty.c_str(),
testServerGC ? userTombstone_timeout : defaultTombstone_timeout,
@@ -1362,11 +1363,12 @@ void CacheHelper::initServer(int instance, const char*
xml,
sprintf(
cmd,
"%s/bin/%s start server --classpath=%s --name=%s "
- "--cache-xml-file=%s --dir=%s --server-port=%d --log-level=%s %s %s "
+ "--cache-xml-file=%s %s --dir=%s --server-port=%d --log-level=%s %s %s
"
"--J=-Dgemfire.tombstone-timeout=%ld "
"--J=-Dgemfire.tombstone-gc-hreshold=%ld "
"--J=-Dgemfire.security-log-level=%s --J=-Xmx1024m --J=-Xms128m 2>&1",
gfjavaenv, GFSH, classpath, sname.c_str(), xmlFile.c_str(),
+ useSecurityManager ? "--user=root --password=root-password" : "",
currDir.c_str(), portNum, gfLogLevel, authParam, deltaProperty.c_str(),
testServerGC ? userTombstone_timeout : defaultTombstone_timeout,
testServerGC ? userTombstone_gc_threshold
@@ -1694,7 +1696,7 @@ void CacheHelper::cleanupLocatorInstances() {
// starting locator
void CacheHelper::initLocator(int instance, bool ssl, bool multiDS, int dsId,
- int remoteLocator, bool untrustedCert) {
+ int remoteLocator, bool untrustedCert, bool
useSecurityManager) {
if (!isLocatorCleanupCallbackRegistered &&
gClientCleanup.registerCallback(&CacheHelper::cleanupLocatorInstances)) {
isLocatorCleanupCallbackRegistered = true;
@@ -1749,7 +1751,7 @@ void CacheHelper::initLocator(int instance, bool ssl,
bool multiDS, int dsId,
ACE_OS::mkdir(locDirname.c_str());
std::string geodeFile =
- generateGeodeProperties(currDir, ssl, dsId, remoteLocator,
untrustedCert);
+ generateGeodeProperties(currDir, ssl, dsId, remoteLocator,
untrustedCert, useSecurityManager);
sprintf(cmd, "%s/bin/%s stop locator --dir=%s --properties-file=%s ",
gfjavaenv, GFSH, currDir.c_str(), geodeFile.c_str());
@@ -1757,11 +1759,15 @@ void CacheHelper::initLocator(int instance, bool ssl,
bool multiDS, int dsId,
LOG(cmd);
ACE_OS::system(cmd);
+ static char* classpath = ACE_OS::getenv("GF_CLASSPATH");
+ std::string propertiesFile = useSecurityManager ?
+ std::string("--security-properties-file=") + geodeFile :
+ std::string("--properties-file=") + geodeFile;
sprintf(cmd,
"%s/bin/%s start locator --name=%s --port=%d --dir=%s "
- "--properties-file=%s --http-service-port=0",
+ "%s --http-service-port=0 --classpath=%s",
gfjavaenv, GFSH, locDirname.c_str(), portnum, currDir.c_str(),
- geodeFile.c_str());
+ propertiesFile.c_str(), classpath);
LOG(cmd);
ACE_OS::system(cmd);
@@ -1872,7 +1878,8 @@ int CacheHelper::getNumLocatorListUpdates(const char* s) {
std::string CacheHelper::generateGeodeProperties(const std::string& path,
const bool ssl, const int
dsId,
const int remoteLocator,
- const bool untrustedCert) {
+ const bool untrustedCert,
+ const bool
useSecurityManager) {
char cmd[2048];
std::string keystore = std::string(ACE_OS::getenv("TESTSRC")) + "/keystore";
@@ -1894,6 +1901,9 @@ std::string CacheHelper::generateGeodeProperties(const
std::string& path,
msg += "log-level=config\n";
msg += "mcast-port=0\n";
msg += "enable-network-partition-detection=false\n";
+ if (useSecurityManager) {
+ msg += "security-manager=javaobject.SimpleSecurityManager\n";
+ }
std::string serverKeystore;
std::string serverTruststore;
diff --git a/cppcache/integration-test/CacheHelper.hpp
b/cppcache/integration-test/CacheHelper.hpp
index b6570927..0362262f 100644
--- a/cppcache/integration-test/CacheHelper.hpp
+++ b/cppcache/integration-test/CacheHelper.hpp
@@ -309,7 +309,8 @@ class CacheHelper {
const char* locHostport = nullptr,
const char* authParam = nullptr, bool ssl = false,
bool enableDelta = true, bool multiDS = false,
- bool testServerGC = false, bool untrustedCert =
false);
+ bool testServerGC = false, bool untrustedCert = false,
+ bool useSecurityManager = false);
static void createDuplicateXMLFile(std::string& originalFile, int hostport1,
int hostport2, int locport1, int
locport2);
@@ -348,7 +349,7 @@ class CacheHelper {
// starting locator
static void initLocator(int instance, bool ssl = false, bool multiDS = false,
int dsId = -1, int remoteLocator = 0,
- bool untrustedCert = false);
+ bool untrustedCert = false, bool useSecurityManager
= false);
static void clearSecProp();
@@ -371,7 +372,8 @@ class CacheHelper {
const bool ssl = false,
const int dsId = -1,
const int remoteLocator = 0,
- const bool untrustedCert = false);
+ const bool untrustedCert = false,
+ const bool useSecurityManager =
false);
};
#ifndef test_cppcache_utils_static
diff --git a/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
b/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
index 5ea09bc2..ea75333d 100644
--- a/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
+++ b/cppcache/integration-test/testThinClientSecurityMultiUserTest.cpp
@@ -14,456 +14,89 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "fw_dunit.hpp"
-#include <string>
-#include <cstdlib>
-#include <geode/FunctionService.hpp>
-#include <geode/Execution.hpp>
-
-#define ROOT_NAME "testThinClientSecurityMultiUserTest"
-#define ROOT_SCOPE DISTRIBUTED_ACK
-#include "CacheHelper.hpp"
-#include "ThinClientHelper.hpp"
-#include "ace/Process.h"
+#include <geode/AuthInitialize.hpp>
+#include "fw_dunit.hpp"
#include "ThinClientSecurity.hpp"
+#include "ThinClientHelper.hpp"
-using namespace apache::geode::client::testframework::security;
using namespace apache::geode::client;
-const char* locHostPort =
- CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
-std::shared_ptr<CredentialGenerator> credentialGeneratorHandler;
-
-std::string getXmlPath() {
- char xmlPath[1000] = {'\0'};
- const char* path = ACE_OS::getenv("TESTSRC");
- printf(" getXMLPATH = %s \n", path);
- 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() {
- static int loopNum = 1;
-
- switch (loopNum) {
- case 1: {
- credentialGeneratorHandler = CredentialGenerator::create("DUMMY2");
- break;
- }
- case 2: {
- credentialGeneratorHandler = CredentialGenerator::create("LDAP");
- break;
- }
- default:
- case 3: {
- credentialGeneratorHandler = CredentialGenerator::create("PKCS");
- break;
- }
- }
-
- if (credentialGeneratorHandler == nullptr) {
- FAIL("credentialGeneratorHandler is nullptr");
- }
-
- loopNum++;
- if (loopNum > 1) loopNum = 1;
-}
-#define HANDLE_NO_NOT_AUTHORIZED_EXCEPTION \
- catch (const apache::geode::client::NotAuthorizedException&) { \
- LOG("NotAuthorizedException Caught"); \
- FAIL("should not have caught NotAuthorizedException"); \
- } \
- catch (const apache::geode::client::Exception& other) { \
- LOG("Got apache::geode::client::Exception& other "); \
- LOG(other.getStackTrace().c_str()); \
- FAIL(other.what()); \
- }
-
-#define HANDLE_NOT_AUTHORIZED_EXCEPTION \
- catch (const apache::geode::client::NotAuthorizedException&) { \
- LOG("NotAuthorizedException Caught"); \
- LOG("Success"); \
- } \
- catch (const apache::geode::client::Exception& other) { \
- LOG(other.getStackTrace().c_str()); \
- FAIL(other.what()); \
- }
-
-#define CLIENT_1 s1p1
-#define WRITER_CLIENT s1p2
-#define READER_CLIENT s2p1
-//#define USER_CLIENT s2p2
-
-const char* regionNamesAuth[] = {"DistRegionAck"};
- std::shared_ptr<Properties> userCreds;
- void initClientAuth() {
- userCreds = Properties::create();
- auto config = Properties::create();
- credentialGeneratorHandler->getAuthInit(config);
-
- credentialGeneratorHandler->getValidCredentials(userCreds);
-
- try {
- initClient(true, config);
- } catch (...) {
- throw;
- }
- }
-
- typedef enum { OP_GET = 0, OP_PUT = 1 } UserOpCode;
-
- class UserThread : public ACE_Task_Base {
- int m_numberOfOps;
- int m_numberOfUsers;
- std::shared_ptr<RegionService> m_userCache;
- std::shared_ptr<Region> m_userRegion;
- int m_userId;
- bool m_failed;
- bool getValidOps;
- int m_totalOpsPassed;
-
- int getNextOp() { return (rand() % 17) % 2; }
-
- int getNextKeyIdx() {
- if (getValidOps) {
- getValidOps = false;
- return m_userId;
- } else {
- getValidOps = true;
- }
- int nextNumber = (rand() % 541) % (m_numberOfUsers + 1);
- if (nextNumber == m_userId)
- return (nextNumber + 1) % (m_numberOfUsers + 1);
- return nextNumber;
- }
-
- void getOp() {
- LOG("Get ops");
- bool isPassed = false;
- char key[10] = {'\0'};
- try {
- int nextKey = getNextKeyIdx();
-
- sprintf(key, "key%d", nextKey);
- char tmp[256] = {'\0'};
- sprintf(tmp, "User is doing get. user id = %d, key = %s", m_userId,
key);
- LOG(tmp);
- isPassed = ifUserIdInKey(key);
- m_userRegion->get(key);
- LOG("op got passed");
- m_totalOpsPassed++;
- } catch (const apache::geode::client::NotAuthorizedException&) {
- LOG("NotAuthorizedException Caught");
- if (isPassed) {
- char tmp[256] = {'\0'};
- sprintf(tmp,
- "Get ops should have passed for user id = %d for key = %s",
- m_userId, key);
- LOG(tmp);
- m_failed = true;
- }
- } catch (const apache::geode::client::Exception& other) {
- LOG(other.getStackTrace().c_str());
- m_failed = true;
- char tmp[256] = {'\0'};
- sprintf(tmp, "Some other geode exception got for user id = %d",
- m_userId);
- LOG(tmp);
- LOG(other.what());
- m_failed = true;
- } catch (...) {
- m_failed = true;
- char tmp[256] = {'\0'};
- sprintf(tmp, "Some other exception got for user id = %d", m_userId);
- LOG(tmp);
- }
- }
-
- void putOp() {
- LOG("Put ops");
- bool isPassed = false;
- char key[10] = {'\0'};
- try {
- int nextKey = getNextKeyIdx();
-
- sprintf(key, "key%d", nextKey);
- char tmp[256] = {'\0'};
- sprintf(tmp, "User is doing put. user id = %d, key = %s", m_userId,
key);
- LOG(tmp);
- isPassed = ifUserIdInKey(key);
- m_userRegion->put(key, "val");
- LOG("op got passed");
- m_totalOpsPassed++;
- } catch (const apache::geode::client::NotAuthorizedException&) {
- LOG("NotAuthorizedException Caught");
- if (isPassed) {
- char tmp[256] = {'\0'};
- sprintf(tmp,
- "Put ops should have passed for user id = %d for key = %s",
- m_userId, key);
- LOG(tmp);
- m_failed = true;
- }
- } catch (const apache::geode::client::Exception& other) {
- LOG(other.getStackTrace().c_str());
- m_failed = true;
- char tmp[256] = {'\0'};
- sprintf(tmp, "Some other geode exception got for user id = %d",
- m_userId);
- LOG(tmp);
- LOG(other.what());
- m_failed = true;
- } catch (...) {
- m_failed = true;
- char tmp[256] = {'\0'};
- sprintf(tmp, "Some other exception got for user id = %d", m_userId);
- LOG(tmp);
- }
- }
-
- bool ifUserIdInKey(const char* key) {
- std::string s1(key);
- char tmp[10];
- sprintf(tmp, "%d", m_userId);
- std::string userId(tmp);
-
- size_t found = s1.rfind(userId);
- if (found != std::string::npos) return true;
- return false;
- }
-
- public:
- UserThread() {
- getValidOps = true;
- m_totalOpsPassed = 0;
- }
- void setParameters(int numberOfOps, int userId, std::shared_ptr<Pool> pool,
- int numberOfUsers) {
- printf(
- "userthread constructor nOo = %d, userid = %d, numberOfUsers = %d\n",
- numberOfOps, userId, numberOfUsers);
- m_userId = userId;
- m_failed = false;
- auto creds = Properties::create();
- char tmp[25] = {'\0'};
- sprintf(tmp, "user%d", userId);
-
- creds->insert("security-username", tmp);
- creds->insert("security-password", tmp);
+#define CLIENT1 s1p1
+#define LOCATORSERVER s2p2
- m_numberOfOps = numberOfOps;
- m_userCache = getVirtualCache(creds, pool);
- m_userRegion = m_userCache->getRegion(regionNamesAuth[0]);
- m_numberOfUsers = numberOfUsers;
- }
-
- void start() { activate(THR_NEW_LWP | THR_JOINABLE); }
-
- void stop() {
- /*if (m_run) {
- m_run = false;
- wait();
- }*/
- }
-
- int svc(void) {
- int nOps = 0;
- char key[10] = {'\0'};
- char val[10] = {'\0'};
- printf("User thread first put started\n");
- // users data
- sprintf(key, "key%d", m_userId);
- sprintf(val, "val%d", m_userId);
- printf("User thread first put started key = %s val =%s\n", key, val);
- m_userRegion->put(key, val);
- printf("User thread first put completed\n");
- while (nOps++ < m_numberOfOps && !m_failed) {
- int nextOp = getNextOp();
- switch (nextOp) {
- case 0:
- getOp();
- break;
- case 1:
- putOp();
- break;
- default:
- LOG("Something is worng.");
- break;
- }
- }
- m_userCache->close();
- return 0;
- }
-
- bool isUserOpsFailed() {
- if (m_failed) {
- char tmp[256] = {'\0'};
- sprintf(tmp, "User ops failed for this user id = %d", m_userId);
- LOG(tmp);
- }
- return m_failed;
- }
-
- int getTotalOpsPassed() { return m_totalOpsPassed; }
-};
-
-DUNIT_TASK_DEFINITION(CLIENT_1, StartServer1)
+DUNIT_TASK_DEFINITION(LOCATORSERVER, CreateLocator)
{
- initCredentialGenerator();
- std::string cmdServerAuthenticator;
-
- if (isLocalServer) {
- cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
- "authenticator:authorizer:authorizerPP", getXmlPath());
- printf("string %s", cmdServerAuthenticator.c_str());
- CacheHelper::initServer(
- 1, "cacheserver_notify_subscription.xml", locHostPort,
- const_cast<char*>(cmdServerAuthenticator.c_str()));
- LOG("Server1 started");
- }
+ CacheHelper::initLocator(1, false, false, -1, 0, false, true);
+ LOG("Locator started");
}
END_TASK_DEFINITION
-DUNIT_TASK_DEFINITION(CLIENT_1, StartServer2)
+DUNIT_TASK_DEFINITION(LOCATORSERVER, CreateServer)
{
- std::string cmdServerAuthenticator;
-
- if (isLocalServer) {
- cmdServerAuthenticator = credentialGeneratorHandler->getServerCmdParams(
- "authenticator:authorizer:authorizerPP", getXmlPath());
- printf("string %s", cmdServerAuthenticator.c_str());
- CacheHelper::initServer(
- 2, "cacheserver_notify_subscription2.xml", locHostPort,
- const_cast<char*>(cmdServerAuthenticator.c_str()));
- LOG("Server2 started");
- }
- }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(CLIENT_1, StartLocator)
- {
- if (isLocator) {
- CacheHelper::initLocator(1);
- LOG("Locator1 started");
- }
+ CacheHelper::initServer(
+ 1, "cacheserver_notify_subscription2.xml",
+ CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1),
+ "--J=-Dsecurity-manager=javaobject.SimpleSecurityManager",
+ false, true, false, false, false, true);
+ LOG("Server started");
}
END_TASK_DEFINITION
-DUNIT_TASK_DEFINITION(CLIENT_1, StepOne)
+DUNIT_TASK_DEFINITION(CLIENT1, PerformSecureOperationsWithUserCredentials)
{
- initClientAuth();
- try {
- LOG("Tying Region creation");
- createRegionForSecurity(regionNamesAuth[0], USE_ACK, false, nullptr,
- false, -1, true, 0);
- LOG("Region created successfully");
- auto pool = getPool(regionNamesAuth[0]);
- int m_numberOfUsers = 3;
- int m_numberOfOps = 10;
- UserThread* uthreads = new UserThread[m_numberOfUsers];
+ auto cache = CacheFactory::createCacheFactory()->create();
+ auto poolFactory = cache.getPoolManager().createFactory();
+ poolFactory->setMultiuserAuthentication(true);
+ poolFactory->addLocator("localhost", CacheHelper::staticLocatorHostPort1);
+ poolFactory->create("mypool");
- for (int i = 0; i < m_numberOfUsers; i++) {
- uthreads[i].setParameters(m_numberOfOps, i + 1, pool, m_numberOfUsers);
- }
+ auto regionFactory = cache.createRegionFactory(PROXY);
+ regionFactory.setPoolName("mypool");
+ regionFactory.create("DistRegionAck");
- LOG("USer created successfully");
- for (int i = 0; i < m_numberOfUsers; i++) {
- uthreads[i].start();
- }
- LOG("USer Threads started");
- for (int i = 0; i < m_numberOfUsers; i++) {
- uthreads[i].wait();
- }
- LOG("USer Thread Completed");
- bool fail = false;
- int totalOpsPassed = 0;
- for (int i = 0; i < m_numberOfUsers; i++) {
- if (uthreads[i].isUserOpsFailed()) {
- fail = true;
- } else {
- totalOpsPassed += uthreads[i].getTotalOpsPassed();
- }
- }
+ auto config1 = Properties::create();
+ config1->insert("security-username", "root");
+ config1->insert("security-password", "root-password");
- char tmp[256] = {'\0'};
- sprintf(tmp, "Total ops passed = %d , expected = %d", totalOpsPassed,
- (m_numberOfOps * m_numberOfUsers) / 2);
- printf("%s\n", tmp);
- ASSERT(totalOpsPassed == (m_numberOfOps * m_numberOfUsers) / 2, tmp);
- if (fail) {
- FAIL("User ops failed");
- } else {
- LOG("ALl User ops succed");
- }
- } catch (...) {
- FAIL("Something is worng.");
- }
+ cache.createAuthenticatedView(config1,
"mypool")->getRegion("DistRegionAck")
+ ->put("akey", "avalue");
- LOG("StepOne complete.");
- }
-END_TASK_DEFINITION
+ auto config2 = Properties::create();
+ config2->insert("security-username", "reader");
+ config2->insert("security-password", "reader-password");
-DUNIT_TASK_DEFINITION(CLIENT_1, CloseServer1)
- {
- SLEEP(9000);
- if (isLocalServer) {
- CacheHelper::closeServer(1);
- LOG("SERVER1 stopped");
+ try {
+ cache.createAuthenticatedView(config2,
"mypool")->getRegion("DistRegionAck")
+ ->put("akey", "avalue");
+ FAIL("Didn't throw expected AuthenticationFailedException.");
+ } catch (const apache::geode::client::NotAuthorizedException& other) {
+ LOG("Caught expected AuthenticationFailedException.");
}
}
END_TASK_DEFINITION
-DUNIT_TASK_DEFINITION(CLIENT_1, CloseServer2)
+DUNIT_TASK_DEFINITION(LOCATORSERVER, CloseServer)
{
- if (isLocalServer) {
- CacheHelper::closeServer(2);
- LOG("SERVER2 stopped");
- }
+ CacheHelper::closeServer(1);
+ LOG("SERVER1 stopped");
}
END_TASK_DEFINITION
-DUNIT_TASK_DEFINITION(CLIENT_1, CloseLocator)
+DUNIT_TASK_DEFINITION(LOCATORSERVER, CloseLocator)
{
- if (isLocator) {
- CacheHelper::closeLocator(1);
- LOG("Locator1 stopped");
- }
+ CacheHelper::closeLocator(1);
+ LOG("Locator1 stopped");
}
END_TASK_DEFINITION
-DUNIT_TASK_DEFINITION(CLIENT_1, CloseCacheAdmin)
- { cleanProc(); }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(WRITER_CLIENT, CloseCacheWriter)
- { cleanProc(); }
-END_TASK_DEFINITION
-
-DUNIT_TASK_DEFINITION(READER_CLIENT, CloseCacheReader)
- { cleanProc(); }
-END_TASK_DEFINITION
-
-void doThinClientSecurityAuthorization() {
- CALL_TASK(StartLocator);
- CALL_TASK(StartServer1);
- CALL_TASK(StepOne);
- CALL_TASK(CloseCacheAdmin);
- // CALL_TASK(StepTwo);
- // CALL_TASK(StartServer2);
- CALL_TASK(CloseServer1);
- // CALL_TASK(StepThree);
- // CALL_TASK(CloseCacheReader);
- // CALL_TASK(CloseCacheWriter);
- // CALL_TASK(CloseCacheAdmin);
- // CALL_TASK(CloseServer2);
- CALL_TASK(CloseLocator);
-}
-
DUNIT_MAIN
- { doThinClientSecurityAuthorization(); }
+ {
+ CALL_TASK(CreateLocator);
+ CALL_TASK(CreateServer);
+ CALL_TASK(PerformSecureOperationsWithUserCredentials);
+ CALL_TASK(CloseServer);
+ CALL_TASK(CloseLocator);
+ }
END_MAIN
diff --git a/cppcache/src/Cache.cpp b/cppcache/src/Cache.cpp
index 6eca8a07..1ce4391f 100644
--- a/cppcache/src/Cache.cpp
+++ b/cppcache/src/Cache.cpp
@@ -240,11 +240,12 @@ PoolManager& Cache::getPoolManager() const {
std::unique_ptr<DataInput> Cache::createDataInput(const uint8_t* m_buffer,
int32_t len) const {
- return std::unique_ptr<DataInput>(new DataInput(m_buffer, len, this));
+ return std::unique_ptr<DataInput>(new DataInput(m_buffer, len,
+ m_cacheImpl.get()));
}
std::unique_ptr<DataOutput> Cache::createDataOutput() const {
- return std::unique_ptr<DataOutput>(new DataOutput(this));
+ return std::unique_ptr<DataOutput>(new DataOutput(m_cacheImpl.get()));
}
} // namespace client
diff --git a/cppcache/src/CacheImpl.hpp b/cppcache/src/CacheImpl.hpp
index 38e88b52..65fa0d40 100644
--- a/cppcache/src/CacheImpl.hpp
+++ b/cppcache/src/CacheImpl.hpp
@@ -285,6 +285,15 @@ class CPPCACHE_EXPORT CacheImpl : private NonCopyable,
private NonAssignable {
return m_authInitialize;
}
+ virtual std::unique_ptr<DataOutput> createDataOutput() const {
+ return std::unique_ptr<DataOutput>(new DataOutput(this));
+ }
+
+ virtual std::unique_ptr<DataInput> createDataInput(const uint8_t* buffer,
+ int32_t len) const {
+ return std::unique_ptr<DataInput>(new DataInput(buffer, len, this));
+ }
+
private:
std::atomic<bool> m_networkhop;
std::atomic<int> m_blacklistBucketTimeout;
diff --git a/cppcache/src/CqQueryImpl.hpp b/cppcache/src/CqQueryImpl.hpp
index 700ee4d8..5506310a 100644
--- a/cppcache/src/CqQueryImpl.hpp
+++ b/cppcache/src/CqQueryImpl.hpp
@@ -272,7 +272,7 @@ class CqQueryImpl : public CqQuery,
mutable ACE_Recursive_Thread_Mutex m_mutex;
void sendStopOrClose(TcrMessage::MsgType requestType);
ThinClientBaseDM* m_tccdm;
- std::shared_ptr<ProxyCache> m_proxyCache;
+ ProxyCache* m_proxyCache;
FRIEND_STD_SHARED_PTR(CqQueryImpl)
};
diff --git a/cppcache/src/DataInput.cpp b/cppcache/src/DataInput.cpp
index 2405f41c..30a06bfe 100644
--- a/cppcache/src/DataInput.cpp
+++ b/cppcache/src/DataInput.cpp
@@ -31,10 +31,10 @@ std::shared_ptr<Serializable>
DataInput::readObjectInternal(int8_t typeId) {
}
const SerializationRegistry& DataInput::getSerializationRegistry() const {
- return *CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry();
+ return *m_cache->getSerializationRegistry();
}
-const Cache* DataInput::getCache() { return m_cache; }
+const Cache* DataInput::getCache() { return m_cache->getCache(); }
void DataInput::readJavaModifiedUtf8(std::string& value) {
// OPTIMIZE transcode Java Modified UTF-8/CESU-8 to standard UTF-8
@@ -104,7 +104,6 @@ void DataInput::readUtf16Huge(std::string& value) {
readUtf16Huge(utf16);
value = to_utf8(utf16);
}
-
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/DataInputInternal.hpp
b/cppcache/src/DataInputInternal.hpp
index 9794bf39..e1ab6e46 100644
--- a/cppcache/src/DataInputInternal.hpp
+++ b/cppcache/src/DataInputInternal.hpp
@@ -31,7 +31,7 @@ class DataInputInternal : public DataInput {
DataInputInternal(const uint8_t* buffer, int32_t len)
: DataInput(buffer, len, nullptr) {}
- DataInputInternal(const uint8_t* buffer, int32_t len, const Cache* cache)
+ DataInputInternal(const uint8_t* buffer, int32_t len, const CacheImpl* cache)
: DataInput(buffer, len, cache) {}
virtual const Cache* getCache() override {
diff --git a/cppcache/src/DataOutput.cpp b/cppcache/src/DataOutput.cpp
index 86f3b5b9..5f0a8f54 100644
--- a/cppcache/src/DataOutput.cpp
+++ b/cppcache/src/DataOutput.cpp
@@ -110,7 +110,7 @@ TSSDataOutput::~TSSDataOutput() {
ACE_TSS<TSSDataOutput> TSSDataOutput::s_tssDataOutput;
-DataOutput::DataOutput(const Cache* cache)
+DataOutput::DataOutput(const CacheImpl* cache)
: m_cache(cache),
m_poolName(EMPTY_STRING),
m_size(0),
@@ -135,10 +135,10 @@ void DataOutput::acquireLock() {
g_bigBufferLock.acquire(); }
void DataOutput::releaseLock() { g_bigBufferLock.release(); }
const SerializationRegistry& DataOutput::getSerializationRegistry() const {
- return *CacheRegionHelper::getCacheImpl(m_cache)->getSerializationRegistry();
+ return *m_cache->getSerializationRegistry();
}
-const Cache* DataOutput::getCache() { return m_cache; }
+const Cache* DataOutput::getCache() { return m_cache->getCache(); }
void DataOutput::writeUtf16Huge(const std::string& value) {
writeUtf16Huge(to_utf16(value));
@@ -173,7 +173,6 @@ void DataOutput::writeJavaModifiedUtf8(const
std::u16string& value) {
if (m_buf > end) m_buf = end;
}
}
-
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/DataOutputInternal.hpp
b/cppcache/src/DataOutputInternal.hpp
index 9452ca84..21c0bc4d 100644
--- a/cppcache/src/DataOutputInternal.hpp
+++ b/cppcache/src/DataOutputInternal.hpp
@@ -26,11 +26,13 @@ namespace apache {
namespace geode {
namespace client {
+class CacheImpl;
+
class DataOutputInternal : public DataOutput {
public:
DataOutputInternal() : DataOutput() {}
- DataOutputInternal(Cache* cache) : DataOutput(cache) {}
+ DataOutputInternal(CacheImpl* cache) : DataOutput(cache) {}
virtual const Cache* getCache() override {
throw FatalInternalException("DataOutputInternal does not have a Cache");
diff --git a/cppcache/src/ExecutionImpl.cpp b/cppcache/src/ExecutionImpl.cpp
index b833dc3d..983c8c89 100644
--- a/cppcache/src/ExecutionImpl.cpp
+++ b/cppcache/src/ExecutionImpl.cpp
@@ -95,7 +95,7 @@ std::shared_ptr<ResultCollector> ExecutionImpl::execute(
GuardUserAttribures gua;
if (m_proxyCache != nullptr) {
LOGDEBUG("ExecutionImpl::execute function on proxy cache");
- gua.setProxyCache(m_proxyCache);
+ gua.setProxyCache(m_proxyCache.get());
}
bool serverHasResult = false;
bool serverIsHA = false;
@@ -370,7 +370,6 @@ GfErrType ExecutionImpl::getFuncAttributes(const
std::string& func,
LOGDEBUG("Tcrmessage request GET_FUNCTION_ATTRIBUTES ");
TcrMessageGetFunctionAttributes request(tcrdm->getConnectionManager()
.getCacheImpl()
- ->getCache()
->createDataOutput(),
func, tcrdm);
TcrMessageReply reply(true, tcrdm);
diff --git a/cppcache/src/ProxyCache.cpp b/cppcache/src/ProxyCache.cpp
index 0b1b2ea3..21ac11f4 100644
--- a/cppcache/src/ProxyCache.cpp
+++ b/cppcache/src/ProxyCache.cpp
@@ -63,7 +63,7 @@ void ProxyCache::close() {
prqs->closeCqs(false);
}
- GuardUserAttribures gua(shared_from_this());
+ GuardUserAttribures gua(this);
m_isProxyCacheClosed = true;
m_userAttributes->unSetCredentials();
// send message to server
diff --git a/cppcache/src/ProxyRegion.hpp b/cppcache/src/ProxyRegion.hpp
index 14365c96..decfe987 100644
--- a/cppcache/src/ProxyRegion.hpp
+++ b/cppcache/src/ProxyRegion.hpp
@@ -91,13 +91,13 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
virtual void destroyRegion(const std::shared_ptr<Serializable>&
aCallbackArgument = nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
m_realRegion->destroyRegion(aCallbackArgument);
}
virtual void clear(const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
m_realRegion->clear(aCallbackArgument);
}
@@ -163,7 +163,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->get(key, aCallbackArgument);
}
@@ -179,7 +179,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->put(key, value, aCallbackArgument);
}
@@ -210,7 +210,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
std::chrono::milliseconds timeout = DEFAULT_RESPONSE_TIMEOUT,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->putAll(map, timeout, aCallbackArgument);
}
@@ -248,7 +248,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
m_realRegion->create(key, value, aCallbackArgument);
}
@@ -308,7 +308,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
virtual void invalidate(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>&
aCallbackArgument = nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
m_realRegion->invalidate(key, aCallbackArgument);
}
@@ -335,7 +335,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
virtual void destroy(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
m_realRegion->destroy(key, aCallbackArgument);
}
@@ -363,7 +363,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
const std::shared_ptr<Cacheable>& value,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->remove(key, value, aCallbackArgument);
}
@@ -393,7 +393,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
virtual bool removeEx(const std::shared_ptr<CacheableKey>& key,
const std::shared_ptr<Serializable>& aCallbackArgument
=
nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->removeEx(key, aCallbackArgument);
}
@@ -459,7 +459,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
}
virtual std::vector<std::shared_ptr<CacheableKey>> serverKeys() override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->serverKeys();
}
@@ -473,7 +473,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
}
virtual std::shared_ptr<RegionService> getRegionService() const override {
- return std::shared_ptr<RegionService>(m_proxyCache);
+ return std::shared_ptr<RegionService>(m_proxyCache.get());
}
virtual bool isDestroyed() const override {
@@ -505,7 +505,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
virtual bool containsKeyOnServer(
const std::shared_ptr<CacheableKey>& keyPtr) const override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->containsKeyOnServer(keyPtr);
}
@@ -566,7 +566,7 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
const std::vector<std::shared_ptr<CacheableKey>>& keys,
const std::shared_ptr<Serializable>& aCallbackArgument =
nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->getAll_internal(keys, aCallbackArgument, false);
}
@@ -574,14 +574,14 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
const std::string& predicate,
std::chrono::milliseconds timeout =
DEFAULT_QUERY_RESPONSE_TIMEOUT) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->query(predicate, timeout);
}
virtual bool existsValue(const std::string& predicate,
std::chrono::milliseconds timeout =
DEFAULT_QUERY_RESPONSE_TIMEOUT) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->existsValue(predicate, timeout);
}
@@ -589,14 +589,14 @@ class CPPCACHE_EXPORT ProxyRegion : public Region {
const std::string& predicate,
std::chrono::milliseconds timeout =
DEFAULT_QUERY_RESPONSE_TIMEOUT) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
return m_realRegion->selectValue(predicate, timeout);
}
virtual void removeAll(const std::vector<std::shared_ptr<CacheableKey>>&
keys,
const std::shared_ptr<Serializable>&
aCallbackArgument = nullptr) override {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
m_realRegion->removeAll(keys, aCallbackArgument);
}
diff --git a/cppcache/src/ProxyRemoteQueryService.cpp
b/cppcache/src/ProxyRemoteQueryService.cpp
index 859686b6..12cfa05c 100644
--- a/cppcache/src/ProxyRemoteQueryService.cpp
+++ b/cppcache/src/ProxyRemoteQueryService.cpp
@@ -36,7 +36,7 @@ std::shared_ptr<Query> ProxyRemoteQueryService::newQuery(
userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
if (!poolDM->isDestroyed()) {
return poolDM->getQueryServiceWithoutCheck()->newQuery(querystring);
@@ -63,7 +63,7 @@ std::shared_ptr<CqQuery> ProxyRemoteQueryService::newCq(
userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
auto pooDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
if (!pooDM->isDestroyed()) {
auto cqQuery = pooDM->getQueryServiceWithoutCheck()->newCq(
@@ -92,7 +92,7 @@ std::shared_ptr<CqQuery> ProxyRemoteQueryService::newCq(
userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
if (!poolDM->isDestroyed()) {
auto cqQuery = poolDM->getQueryServiceWithoutCheck()->newCq(
@@ -143,7 +143,7 @@ std::shared_ptr<CqQuery> ProxyRemoteQueryService::getCq(
userAttachedPool->getName());
if (pool != nullptr && pool.get() == userAttachedPool.get() &&
!pool->isDestroyed()) {
- GuardUserAttribures gua(m_proxyCache);
+ GuardUserAttribures gua(m_proxyCache.get());
auto poolDM = std::static_pointer_cast<ThinClientPoolDM>(pool);
if (!poolDM->isDestroyed()) {
return poolDM->getQueryServiceWithoutCheck()->getCq(name);
diff --git a/cppcache/src/RemoteQuery.cpp b/cppcache/src/RemoteQuery.cpp
index bc5316a0..a48b99ae 100644
--- a/cppcache/src/RemoteQuery.cpp
+++ b/cppcache/src/RemoteQuery.cpp
@@ -36,7 +36,7 @@ namespace client {
RemoteQuery::RemoteQuery(
std::string querystr,
const std::shared_ptr<RemoteQueryService>& queryService,
- ThinClientBaseDM* tccdmptr, std::shared_ptr<ProxyCache> proxyCache)
+ ThinClientBaseDM* tccdmptr, ProxyCache* proxyCache)
: m_queryString(querystr),
m_queryService(queryService),
m_tccdm(tccdmptr),
diff --git a/cppcache/src/RemoteQuery.hpp b/cppcache/src/RemoteQuery.hpp
index 1e656b54..ce6e03af 100644
--- a/cppcache/src/RemoteQuery.hpp
+++ b/cppcache/src/RemoteQuery.hpp
@@ -47,13 +47,13 @@ class CPPCACHE_EXPORT RemoteQuery : public Query {
std::shared_ptr<RemoteQueryService> m_queryService;
ThinClientBaseDM* m_tccdm;
- std::shared_ptr<ProxyCache> m_proxyCache;
+ ProxyCache* m_proxyCache;
public:
RemoteQuery(std::string querystr,
const std::shared_ptr<RemoteQueryService>& queryService,
ThinClientBaseDM* tccdmptr,
- std::shared_ptr<ProxyCache> proxyCache = nullptr);
+ ProxyCache* proxyCache = nullptr);
std::shared_ptr<SelectResults> execute(
std::chrono::milliseconds timeout =
diff --git a/cppcache/src/TcrConnection.cpp b/cppcache/src/TcrConnection.cpp
index c423b787..950a9195 100644
--- a/cppcache/src/TcrConnection.cpp
+++ b/cppcache/src/TcrConnection.cpp
@@ -100,7 +100,7 @@ bool TcrConnection::InitTcrConnection(
GF_DEV_ASSERT(m_conn != nullptr);
- auto handShakeMsg = cacheImpl->getCache()->createDataOutput();
+ auto handShakeMsg = cacheImpl->createDataOutput();
bool isNotificationChannel = false;
// Send byte Acceptor.CLIENT_TO_SERVER = (byte) 100;
// Send byte Acceptor.SERVER_TO_CLIENT = (byte) 101;
@@ -352,7 +352,7 @@ bool TcrConnection::InitTcrConnection(
LOGDEBUG("Handshake: Got challengeSize %d", challengeBytes->length());
// encrypt the credentials and challenge bytes
- auto cleartext = cacheImpl->getCache()->createDataOutput();
+ auto cleartext = cacheImpl->createDataOutput();
if (isClientNotification) { //:only for backward connection
credentials->toData(*cleartext);
}
@@ -360,7 +360,7 @@ bool TcrConnection::InitTcrConnection(
auto ciphertext =
m_dh->encrypt(cleartext->getBuffer(), cleartext->getBufferLength());
- auto sendCreds = cacheImpl->getCache()->createDataOutput();
+ auto sendCreds = cacheImpl->createDataOutput();
ciphertext->toData(*sendCreds);
uint32_t credLen;
char* credData = (char*)sendCreds->getBuffer(&credLen);
@@ -400,7 +400,7 @@ bool TcrConnection::InitTcrConnection(
m_hasServerQueue = NON_REDUNDANT_SERVER;
}
auto queueSizeMsg = readHandshakeData(4, connectTimeout);
- auto dI = cacheImpl->getCache()->createDataInput(queueSizeMsg->value(),
+ auto dI = cacheImpl->createDataInput(queueSizeMsg->value(),
queueSizeMsg->length());
int32_t queueSize = 0;
queueSize = dI->readInt32();
@@ -432,13 +432,13 @@ bool TcrConnection::InitTcrConnection(
if (static_cast<int8_t>((*arrayLenHeader)[0]) == -2) {
auto recvMsgLenBytes = readHandshakeData(2, connectTimeout);
auto dI2 =
- m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ m_connectionManager->getCacheImpl()->createDataInput(
recvMsgLenBytes->value(), recvMsgLenBytes->length());
recvMsgLen = dI2->readInt16();
} else if (static_cast<int8_t>((*arrayLenHeader)[0]) == -3) {
auto recvMsgLenBytes = readHandshakeData(4, connectTimeout);
auto dI2 =
- m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ m_connectionManager->getCacheImpl()->createDataInput(
recvMsgLenBytes->value(), recvMsgLenBytes->length());
recvMsgLen = dI2->readInt32();
}
@@ -446,7 +446,7 @@ bool TcrConnection::InitTcrConnection(
// If the distributed member has not been set yet, set it.
if (getEndpointObject()->getDistributedMemberID() == 0) {
LOGDEBUG("Deserializing distributed member Id");
- auto diForClient = cacheImpl->getCache()->createDataInput(
+ auto diForClient = cacheImpl->createDataInput(
recvMessage->value(), recvMessage->length());
std::shared_ptr<ClientProxyMembershipID> member;
member = diForClient->readObject<ClientProxyMembershipID>();
@@ -457,7 +457,7 @@ bool TcrConnection::InitTcrConnection(
}
auto recvMsgLenBytes = readHandshakeData(2, connectTimeout);
- auto dI3 =
m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ auto dI3 = m_connectionManager->getCacheImpl()->createDataInput(
recvMsgLenBytes->value(), recvMsgLenBytes->length());
uint16_t recvMsgLen2 = dI3->readInt16();
auto recvMessage = readHandshakeData(recvMsgLen2, connectTimeout);
@@ -465,7 +465,7 @@ bool TcrConnection::InitTcrConnection(
if (!isClientNotification) {
auto deltaEnabledMsg = readHandshakeData(1, connectTimeout);
auto di =
- m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ m_connectionManager->getCacheImpl()->createDataInput(
deltaEnabledMsg->value(), 1);
ThinClientBaseDM::setDeltaEnabledOnServer(di->readBoolean());
}
@@ -883,7 +883,7 @@ char* TcrConnection::readMessage(size_t* recvLen,
m_endpoint,
Utils::convertBytesToString(msg_header, HEADER_LENGTH).c_str());
- auto input =
m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ auto input = m_connectionManager->getCacheImpl()->createDataInput(
reinterpret_cast<uint8_t*>(msg_header), HEADER_LENGTH);
msgType = input->readInt32();
msgLen = input->readInt32();
@@ -992,7 +992,7 @@ void TcrConnection::readMessageChunked(
"endpoint %s; bytes: %s",
m_endpoint, Utils::convertBytesToString(msg_header, HDR_LEN_12).c_str());
- auto input =
m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ auto input = m_connectionManager->getCacheImpl()->createDataInput(
msg_header, HDR_LEN_12);
int32_t msgType = input->readInt32();
reply.setMessageType(msgType);
@@ -1058,7 +1058,7 @@ void TcrConnection::readMessageChunked(
.c_str());
auto input =
- m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ m_connectionManager->getCacheImpl()->createDataInput(
msg_header + HDR_LEN_12, HDR_LEN);
int32_t chunkLen;
chunkLen = input->readInt32();
@@ -1207,7 +1207,7 @@ uint32_t TcrConnection::readHandshakeArraySize(
std::chrono::microseconds connectTimeout) {
auto codeBytes = readHandshakeData(1, connectTimeout);
auto codeDI =
- m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ m_connectionManager->getCacheImpl()->createDataInput(
codeBytes->value(), codeBytes->length());
uint8_t code = codeDI->read();
uint32_t arraySize = 0;
@@ -1219,14 +1219,14 @@ uint32_t TcrConnection::readHandshakeArraySize(
if (code == 0xFE) {
auto lenBytes = readHandshakeData(2, connectTimeout);
auto lenDI =
- m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ m_connectionManager->getCacheImpl()->createDataInput(
lenBytes->value(), lenBytes->length());
uint16_t val = lenDI->readInt16();
tempLen = val;
} else if (code == 0xFD) {
auto lenBytes = readHandshakeData(4, connectTimeout);
auto lenDI =
- m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ m_connectionManager->getCacheImpl()->createDataInput(
lenBytes->value(), lenBytes->length());
uint32_t val = lenDI->readInt32();
tempLen = val;
@@ -1319,7 +1319,7 @@ int32_t TcrConnection::readHandShakeInt(
}
}
- auto di = m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ auto di = m_connectionManager->getCacheImpl()->createDataInput(
recvMessage, 4);
int32_t val = di->readInt32();
@@ -1359,7 +1359,7 @@ std::shared_ptr<CacheableString>
TcrConnection::readHandshakeString(
case GeodeTypeIds::CacheableASCIIString: {
auto lenBytes = readHandshakeData(2, connectTimeout);
auto lenDI =
- m_connectionManager->getCacheImpl()->getCache()->createDataInput(
+ m_connectionManager->getCacheImpl()->createDataInput(
lenBytes->value(), lenBytes->length());
length = lenDI->readInt16();
diff --git a/cppcache/src/TcrMessage.cpp b/cppcache/src/TcrMessage.cpp
index e8172322..68664f61 100644
--- a/cppcache/src/TcrMessage.cpp
+++ b/cppcache/src/TcrMessage.cpp
@@ -330,7 +330,6 @@ int64_t TcrMessage::getConnectionId(TcrConnection* conn) {
auto tmp = conn->decryptBytes(m_connectionIDBytes);
auto di = m_tcdm->getConnectionManager()
.getCacheImpl()
- ->getCache()
->createDataInput(tmp->value(), tmp->length());
return di->readInt64();
} else {
@@ -345,7 +344,7 @@ int64_t TcrMessage::getUniqueId(TcrConnection* conn) {
auto tmp = conn->decryptBytes(encryptBytes);
- auto di =
m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ auto di = m_tcdm->getConnectionManager().getCacheImpl()->createDataInput(
tmp->value(), tmp->length());
return di->readInt64();
}
@@ -883,7 +882,7 @@ void TcrMessage::processChunk(const uint8_t* bytes, int32_t
len,
case TcrMessage::EXCEPTION: {
if (bytes != nullptr) {
DeleteArray<const uint8_t> delChunk(bytes);
- auto input =
m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ auto input =
m_tcdm->getConnectionManager().getCacheImpl()->createDataInput(
bytes, len);
readExceptionPart(*input, isLastChunkAndisSecurityHeader);
readSecureObjectPart(*input, false, true,
@@ -940,7 +939,7 @@ void TcrMessage::chunkSecurityHeader(int skipPart, const
uint8_t* bytes,
uint8_t isLastChunkAndSecurityHeader) {
LOGDEBUG("TcrMessage::chunkSecurityHeader:: skipParts = %d", skipPart);
if ((isLastChunkAndSecurityHeader & 0x3) == 0x3) {
- auto di =
m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ auto di = m_tcdm->getConnectionManager().getCacheImpl()->createDataInput(
bytes, len);
skipParts(*di, skipPart);
readSecureObjectPart(*di, false, true, isLastChunkAndSecurityHeader);
@@ -951,7 +950,7 @@ void TcrMessage::handleByteArrayResponse(
const char* bytearray, int32_t len, uint16_t endpointMemId,
const SerializationRegistry& serializationRegistry,
MemberListForVersionStamp& memberListForVersionStamp) {
- auto input =
m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ auto input = m_tcdm->getConnectionManager().getCacheImpl()->createDataInput(
(uint8_t*)bytearray, len);
// TODO:: this need to make sure that pool is there
// if(m_tcdm == nullptr)
@@ -1205,7 +1204,7 @@ void TcrMessage::handleByteArrayResponse(
input->advanceCursor(1); // ignore byte
m_deltaBytes = new uint8_t[m_deltaBytesLen];
input->readBytesOnly(m_deltaBytes, m_deltaBytesLen);
- m_delta =
m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ m_delta =
m_tcdm->getConnectionManager().getCacheImpl()->createDataInput(
m_deltaBytes, m_deltaBytesLen);
} else {
readObjectPart(*input);
@@ -2590,7 +2589,7 @@ void
TcrMessage::createUserCredentialMessage(TcrConnection* conn) {
m_isSecurityHeaderAdded = false;
writeHeader(m_msgType, 1);
- auto dOut =
m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ auto dOut =
m_tcdm->getConnectionManager().getCacheImpl()->createDataOutput();
if (m_creds != nullptr) m_creds->toData(*dOut);
@@ -2618,7 +2617,7 @@ void TcrMessage::addSecurityPart(int64_t connectionId,
int64_t unique_id,
}
m_isSecurityHeaderAdded = true;
LOGDEBUG("addSecurityPart( , ) ");
- auto dOutput =
m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ auto dOutput =
m_tcdm->getConnectionManager().getCacheImpl()->createDataOutput();
dOutput->writeInt(connectionId);
dOutput->writeInt(unique_id);
@@ -2648,7 +2647,7 @@ void TcrMessage::addSecurityPart(int64_t connectionId,
TcrConnection* conn) {
}
m_isSecurityHeaderAdded = true;
LOGDEBUG("TcrMessage::addSecurityPart only connid");
- auto dOutput =
m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ auto dOutput =
m_tcdm->getConnectionManager().getCacheImpl()->createDataOutput();
dOutput->writeInt(connectionId);
@@ -2819,7 +2818,7 @@ void TcrMessage::setData(const char* bytearray, int32_t
len, uint16_t memId,
const SerializationRegistry& serializationRegistry,
MemberListForVersionStamp& memberListForVersionStamp)
{
if (m_request == nullptr) {
- m_request =
m_tcdm->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ m_request =
m_tcdm->getConnectionManager().getCacheImpl()->createDataOutput();
}
if (bytearray) {
DeleteArray<const char> delByteArr(bytearray);
diff --git a/cppcache/src/ThinClientLocatorHelper.cpp
b/cppcache/src/ThinClientLocatorHelper.cpp
index 07a5c260..104abe7f 100644
--- a/cppcache/src/ThinClientLocatorHelper.cpp
+++ b/cppcache/src/ThinClientLocatorHelper.cpp
@@ -102,7 +102,7 @@ GfErrType ThinClientLocatorHelper::getAllServers(
createConnection(conn, loc.getServerName().c_str(), loc.getPort(),
sysProps.connectTimeout(), buffSize);
GetAllServersRequest request(serverGrp);
- auto data =
m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ auto data =
m_poolDM->getConnectionManager().getCacheImpl()->createDataOutput();
data->writeInt((int32_t)1001); // GOSSIPVERSION
data->writeObject(&request);
int sentLength = conn->send(
@@ -122,7 +122,7 @@ GfErrType ThinClientLocatorHelper::getAllServers(
continue;
}
- auto di =
m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ auto di =
m_poolDM->getConnectionManager().getCacheImpl()->createDataInput(
reinterpret_cast<uint8_t*>(buff), receivedLength);
std::shared_ptr<GetAllServersResponse> response(nullptr);
@@ -194,7 +194,7 @@ GfErrType
ThinClientLocatorHelper::getEndpointForNewCallBackConn(
sysProps.connectTimeout(), buffSize);
QueueConnectionRequest request(memId, exclEndPts, redundancy, false,
serverGrp);
- auto data =
m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataOutput();
+ auto data =
m_poolDM->getConnectionManager().getCacheImpl()->createDataOutput();
data->writeInt((int32_t)1001); // GOSSIPVERSION
data->writeObject(&request);
int sentLength = conn->send(
@@ -213,7 +213,7 @@ GfErrType
ThinClientLocatorHelper::getEndpointForNewCallBackConn(
if (receivedLength <= 0) {
continue;
}
- auto di =
m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ auto di =
m_poolDM->getConnectionManager().getCacheImpl()->createDataInput(
reinterpret_cast<uint8_t*>(buff), receivedLength);
std::shared_ptr<QueueConnectionResponse> response(nullptr);
@@ -284,7 +284,6 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
sysProps.connectTimeout(), buffSize);
auto data = m_poolDM->getConnectionManager()
.getCacheImpl()
- ->getCache()
->createDataOutput();
data->writeInt(1001); // GOSSIPVERSION
if (currentServer == nullptr) {
@@ -315,7 +314,7 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
if (receivedLength <= 0) {
continue; // return GF_EUNDEF;
}
- auto di =
m_poolDM->getConnectionManager().getCacheImpl()->getCache()->createDataInput(
+ auto di =
m_poolDM->getConnectionManager().getCacheImpl()->createDataInput(
reinterpret_cast<uint8_t*>(buff), receivedLength);
std::shared_ptr<ClientConnectionResponse> response;
@@ -383,7 +382,6 @@ GfErrType ThinClientLocatorHelper::updateLocators(
LocatorListRequest request(serverGrp);
auto data = m_poolDM->getConnectionManager()
.getCacheImpl()
- ->getCache()
->createDataOutput();
data->writeInt((int32_t)1001); // GOSSIPVERSION
data->writeObject(&request);
@@ -407,7 +405,6 @@ GfErrType ThinClientLocatorHelper::updateLocators(
}
auto di = m_poolDM->getConnectionManager()
.getCacheImpl()
- ->getCache()
->createDataInput(reinterpret_cast<uint8_t*>(buff),
receivedLength);
auto response = std::make_shared<LocatorListResponse>();
diff --git a/cppcache/src/ThinClientRedundancyManager.cpp
b/cppcache/src/ThinClientRedundancyManager.cpp
index 338ace9f..d7852b3c 100644
--- a/cppcache/src/ThinClientRedundancyManager.cpp
+++ b/cppcache/src/ThinClientRedundancyManager.cpp
@@ -866,7 +866,7 @@ GfErrType ThinClientRedundancyManager::sendSyncRequestCq(
? 5
: attempts; // at least 5 attempts if ep lists are small.
- std::shared_ptr<ProxyCache> proxyCache = nullptr;
+ ProxyCache* proxyCache = nullptr;
while (attempts--) {
if (err != GF_NOERR || m_redundantEndpoints.empty()) {
diff --git a/cppcache/src/UserAttributes.cpp b/cppcache/src/UserAttributes.cpp
index 620ed8a2..c9deada6 100644
--- a/cppcache/src/UserAttributes.cpp
+++ b/cppcache/src/UserAttributes.cpp
@@ -25,8 +25,7 @@ UserAttributes::UserAttributes(std::shared_ptr<Properties>
credentials,
: m_isUserAuthenticated(false), m_pool(pool) {
m_credentials = credentials;
- std::shared_ptr<ProxyCache> pcp(proxyCache);
- m_proxyCache = pcp;
+ m_proxyCache = proxyCache;
}
bool UserAttributes::isCacheClosed() { return m_proxyCache->isClosed(); }
@@ -124,18 +123,18 @@ std::shared_ptr<Properties>
UserAttributes::getCredentials() {
}
return m_credentials;
}
- std::shared_ptr<ProxyCache> UserAttributes::getProxyCache() { return
m_proxyCache; }
+ProxyCache* UserAttributes::getProxyCache() { return m_proxyCache; }
ACE_TSS<TSSUserAttributesWrapper>
TSSUserAttributesWrapper::s_geodeTSSUserAttributes;
GuardUserAttribures::GuardUserAttribures(
- std::shared_ptr<ProxyCache> proxyCache) {
+ ProxyCache* proxyCache) {
setProxyCache(proxyCache);
}
void GuardUserAttribures::setProxyCache(
- std::shared_ptr<ProxyCache> proxyCache) {
+ ProxyCache* proxyCache) {
m_proxyCache = proxyCache;
LOGDEBUG("GuardUserAttribures::GuardUserAttribures:");
if (m_proxyCache != nullptr && !proxyCache->isClosed()) {
diff --git a/cppcache/src/UserAttributes.hpp b/cppcache/src/UserAttributes.hpp
index 6f80a405..586c7215 100644
--- a/cppcache/src/UserAttributes.hpp
+++ b/cppcache/src/UserAttributes.hpp
@@ -74,11 +74,12 @@ class CPPCACHE_EXPORT UserAttributes {
public:
~UserAttributes();
UserAttributes(std::shared_ptr<Properties> credentials,
- std::shared_ptr<Pool> pool, ProxyCache* proxyCache);
+ std::shared_ptr<Pool> pool,
+ ProxyCache* proxyCache);
bool isCacheClosed();
- std::shared_ptr<ProxyCache> getProxyCache();
+ ProxyCache* getProxyCache();
std::shared_ptr<Pool> getPool();
@@ -111,7 +112,7 @@ class CPPCACHE_EXPORT UserAttributes {
// ThinClientPoolDM m_pool;
ACE_Recursive_Thread_Mutex m_listLock;
bool m_isUserAuthenticated;
- std::shared_ptr<ProxyCache> m_proxyCache;
+ ProxyCache* m_proxyCache;
std::shared_ptr<Pool> m_pool;
// Disallow copy constructor and assignment operator.
@@ -139,14 +140,14 @@ class GuardUserAttribures {
public:
GuardUserAttribures();
- GuardUserAttribures(std::shared_ptr<ProxyCache> proxyCache);
+ GuardUserAttribures(ProxyCache* proxyCache);
- void setProxyCache(std::shared_ptr<ProxyCache> proxyCache);
+ void setProxyCache(ProxyCache* proxyCache);
~GuardUserAttribures();
private:
- std::shared_ptr<ProxyCache> m_proxyCache;
+ ProxyCache* m_proxyCache;
};
} // namespace client
} // namespace geode
diff --git a/cppcache/test/CacheableStringTests.cpp
b/cppcache/test/CacheableStringTests.cpp
index 6c5182a6..13fe1d9f 100644
--- a/cppcache/test/CacheableStringTests.cpp
+++ b/cppcache/test/CacheableStringTests.cpp
@@ -43,7 +43,7 @@ class TestDataOutput : public DataOutputInternal {
}
TestDataOutput(Cache* cache)
- : DataOutputInternal(cache),
+ : DataOutputInternal(nullptr),
m_byteArray(nullptr),
m_serializationRegistry() {
// NOP
diff --git a/cppcache/test/DataOutputTest.cpp b/cppcache/test/DataOutputTest.cpp
index a0094e95..f7a39aaf 100644
--- a/cppcache/test/DataOutputTest.cpp
+++ b/cppcache/test/DataOutputTest.cpp
@@ -37,7 +37,7 @@ using namespace apache::geode::client;
class TestDataOutput : public DataOutputInternal {
public:
TestDataOutput(Cache* cache)
- : DataOutputInternal(cache),
+ : DataOutputInternal(nullptr),
m_byteArray(nullptr),
m_serializationRegistry() {
// NOP
diff --git a/cppcache/test/PdxLocalReaderTest.cpp
b/cppcache/test/PdxLocalReaderTest.cpp
deleted file mode 100644
index 5d407752..00000000
--- a/cppcache/test/PdxLocalReaderTest.cpp
+++ /dev/null
@@ -1,114 +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 <gtest/gtest.h>
-
-#include <geode/CacheFactory.hpp>
-#include <PdxType.hpp>
-#include <PdxLocalReader.hpp>
-#include <PdxLocalWriter.hpp>
-#include <PdxTypeRegistry.hpp>
-#include "CacheRegionHelper.hpp"
-#include "DataInputInternal.hpp"
-#include "DataOutputInternal.hpp"
-
-using namespace apache::geode::client;
-
-class MyPdxClass : public PdxSerializable {
- public:
- MyPdxClass();
- ~MyPdxClass();
- virtual void toData(std::shared_ptr<PdxWriter> output) const override;
- virtual void fromData(std::shared_ptr<PdxReader> input) override;
- virtual void setAString(std::string a_string);
- virtual std::string getAString();
- virtual const std::string &getClassName() const override;
-
- static PdxSerializable *CreateDeserializable();
-
- private:
- std::string _a_string;
-};
-
-MyPdxClass::MyPdxClass() { _a_string = ""; }
-
-void MyPdxClass::setAString(std::string a_string) { _a_string = a_string; }
-
-std::string MyPdxClass::getAString() { return _a_string; }
-
-MyPdxClass::~MyPdxClass() {}
-
-void MyPdxClass::toData(std::shared_ptr<PdxWriter> output) const {
- output->writeString("name", _a_string.c_str());
-}
-
-void MyPdxClass::fromData(std::shared_ptr<PdxReader> input) {
- _a_string = input->readString("name");
-}
-const std::string &MyPdxClass::getClassName() const {
- static std::string name = "MyPdxClass";
- return name;
-}
-
-PdxSerializable *MyPdxClass::CreateDeserializable() { return new MyPdxClass();
}
-
-class DISABLED_PdxLocalReaderTest : public ::testing::Test {
- public:
- void SetUp() {
- auto factory = CacheFactory::createCacheFactory();
- cache = std::make_shared<Cache>(factory->create());
- }
-
- protected:
- std::shared_ptr<Cache> cache;
-};
-
-TEST_F(DISABLED_PdxLocalReaderTest, testSerializationOfPdxType) {
- MyPdxClass expected, actual;
- DataOutputInternal stream(cache.get());
- int length = 0;
-
- expected.setAString("the_expected_string");
-
- // TODO: Refactor static singleton patterns in PdxTypeRegistry so that
- // tests will not interfere with each other.
-
- auto pdxTypeRegistry =
- CacheRegionHelper::getCacheImpl(cache.get())->getPdxTypeRegistry();
-
- // C++ Client does not require pdxDomainClassName as it is only needed
- // for reflection purposes, which we do not support in C++. We pass in
- // getClassName() for consistency reasons only.
- auto pdx_type_ptr = std::make_shared<PdxType>(pdxTypeRegistry,
- expected.getClassName(),
false);
-
- // Here we construct a serialized stream of bytes representing MyPdxClass.
- // The stream is later deserialization and validated for consistency.
- auto writer =
- std::make_shared<PdxLocalWriter>(stream, pdx_type_ptr, pdxTypeRegistry);
- expected.toData(writer);
- writer->endObjectWriting();
- uint8_t *raw_stream = writer->getPdxStream(length);
-
- DataInputInternal input(raw_stream, length, cache.get());
- auto reader = std::make_shared<PdxLocalReader>(input, pdx_type_ptr, length,
- pdxTypeRegistry);
-
- actual.fromData(reader);
-
- EXPECT_EQ(actual.getAString(), "the_expected_string");
-}
diff --git a/tests/javaobject/SimpleSecurityManager.java
b/tests/javaobject/SimpleSecurityManager.java
new file mode 100644
index 00000000..6abbadec
--- /dev/null
+++ b/tests/javaobject/SimpleSecurityManager.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.
+ */
+/*=========================================================================
+* This implementation is provided on an "AS IS" BASIS, WITHOUT WARRANTIES
+* OR CONDITIONS OF ANY KIND, either express or implied."
+*==========================================================================
+*/
+
+package javaobject;
+
+import java.util.HashMap;
+import java.util.Properties;
+
+import org.apache.geode.management.internal.security.ResourceConstants;
+import org.apache.geode.security.AuthenticationFailedException;
+import org.apache.geode.security.ResourcePermission;
+import org.apache.geode.security.SecurityManager;
+
+public class SimpleSecurityManager implements SecurityManager {
+ @Override
+ public Object authenticate(Properties credentials) throws
AuthenticationFailedException {
+ String user = credentials.getProperty(ResourceConstants.USER_NAME);
+ String password = credentials.getProperty(ResourceConstants.PASSWORD);
+
+ if (getUserCredentials().containsKey(user) &&
getUserCredentials().get(user).equals(password)) {
+ return user;
+ }
+ throw new AuthenticationFailedException("Non-authenticated user: " + user);
+ }
+
+ @Override
+ public boolean authorize(Object principal, ResourcePermission permission) {
+ String username = principal.toString();
+
+ if (permission.getOperation() == ResourcePermission.Operation.MANAGE) {
+ return username.equals("root");
+ }
+
+ if (permission.getOperation() == ResourcePermission.Operation.READ) {
+ return username.contains("read") || username.equals("root");
+ }
+
+ if (permission.getOperation() == ResourcePermission.Operation.WRITE) {
+ return username.contains("write") || username.equals("root");
+ }
+
+ return false;
+ }
+
+ private HashMap<String, String> getUserCredentials() {
+ HashMap<String, String> userCredentials = new HashMap<String, String>();
+ userCredentials.put("root", "root-password");
+ userCredentials.put("reader", "reader-password");
+ userCredentials.put("writer", "writer-password");
+ return userCredentials;
+ }
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Add test coverage using SecurityManager
> ---------------------------------------
>
> Key: GEODE-4066
> URL: https://issues.apache.org/jira/browse/GEODE-4066
> Project: Geode
> Issue Type: Test
> Components: native client
> Reporter: Ernest Burghardt
>
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)