summaryrefslogtreecommitdiffstats
path: root/pki/base/tps/src/selftests/TPSPresence.cpp
diff options
context:
space:
mode:
authorawnuk <awnuk@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2010-08-17 23:41:50 +0000
committerawnuk <awnuk@c9f7a03b-bd48-0410-a16d-cbbf54688b0b>2010-08-17 23:41:50 +0000
commit16b60483367f27632405ca18f8808e121f8e4f0c (patch)
tree7fb0e9aedfb4521831117d96fc3a255b19bbd1b1 /pki/base/tps/src/selftests/TPSPresence.cpp
parentebb6205c768581ec0ba29a3a75ac7918c9427bc6 (diff)
downloadpki-16b60483367f27632405ca18f8808e121f8e4f0c.tar.gz
pki-16b60483367f27632405ca18f8808e121f8e4f0c.tar.xz
pki-16b60483367f27632405ca18f8808e121f8e4f0c.zip
Fixed bugzilla bug #624847.
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@1207 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/base/tps/src/selftests/TPSPresence.cpp')
-rw-r--r--pki/base/tps/src/selftests/TPSPresence.cpp63
1 files changed, 40 insertions, 23 deletions
diff --git a/pki/base/tps/src/selftests/TPSPresence.cpp b/pki/base/tps/src/selftests/TPSPresence.cpp
index 6e2e562c9..7f37fd0fb 100644
--- a/pki/base/tps/src/selftests/TPSPresence.cpp
+++ b/pki/base/tps/src/selftests/TPSPresence.cpp
@@ -57,6 +57,7 @@ bool TPSPresence::onDemandEnabled = false;
bool TPSPresence::startupCritical = false;
bool TPSPresence::onDemandCritical = false;
char *TPSPresence::nickname = 0;
+const char *TPSPresence::UNINITIALIZED_NICKNAME = "[HSM_LABEL][NICKNAME]";
const char *TPSPresence::NICKNAME_NAME = "selftests.plugin.TPSPresence.nickname";
const char *TPSPresence::CRITICAL_TEST_NAME = "TPSPresence:critical";
const char *TPSPresence::TEST_NAME = "TPSPresence";
@@ -94,9 +95,17 @@ void TPSPresence::Initialize (ConfigStore *cfg)
}
char* n = (char*)(cfg->GetConfigAsString(TPSPresence::NICKNAME_NAME));
if (n != 0 && PL_strlen(n) > 0) {
+ if (PL_strstr (n, TPSPresence::UNINITIALIZED_NICKNAME) != NULL) {
+ TPSPresence::initialized = 0;
+ } else {
+ TPSPresence::nickname = n;
+ }
+
TPSPresence::nickname = n;
}
- TPSPresence::initialized = 2;
+ if (TPSPresence::initialized == 1) {
+ TPSPresence::initialized = 2;
+ }
}
RA::SelfTestLog("TPSPresence::Initialize", "%s", ((initialized==2)?"successfully completed":"failed"));
}
@@ -112,11 +121,15 @@ void TPSPresence::Initialize (ConfigStore *cfg)
int TPSPresence::runSelfTest ()
{
int rc = 0;
- if (TPSPresence::nickname != 0 && PL_strlen(TPSPresence::nickname) > 0) {
- rc = TPSPresence::runSelfTest (TPSPresence::nickname);
- } else {
- rc = -3;
+
+ if (TPSPresence::initialized == 2) {
+ if (TPSPresence::nickname != 0 && PL_strlen(TPSPresence::nickname) > 0) {
+ rc = TPSPresence::runSelfTest (TPSPresence::nickname);
+ } else {
+ rc = -3;
+ }
}
+
return rc;
}
@@ -126,21 +139,23 @@ int TPSPresence::runSelfTest (const char *nick_name)
CERTCertDBHandle *handle = 0;
CERTCertificate *cert = 0;
- if (nick_name != 0 && PL_strlen(nick_name) > 0) {
- handle = CERT_GetDefaultCertDB();
- if (handle != 0) {
- cert = CERT_FindCertByNickname( handle, (char *) nick_name);
- if (cert != 0) {
- CERT_DestroyCertificate (cert);
- cert = 0;
+ if (TPSPresence::initialized == 2) {
+ if (nick_name != 0 && PL_strlen(nick_name) > 0) {
+ handle = CERT_GetDefaultCertDB();
+ if (handle != 0) {
+ cert = CERT_FindCertByNickname( handle, (char *) nick_name);
+ if (cert != 0) {
+ CERT_DestroyCertificate (cert);
+ cert = 0;
+ } else {
+ rc = 2;
+ }
} else {
- rc = 2;
+ rc = -1;
}
} else {
- rc = -1;
+ rc = TPSPresence::runSelfTest ();
}
- } else {
- rc = TPSPresence::runSelfTest ();
}
return rc;
@@ -151,14 +166,16 @@ int TPSPresence::runSelfTest (const char *nick_name, CERTCertificate **cert)
int rc = 0;
CERTCertDBHandle *handle = 0;
- handle = CERT_GetDefaultCertDB();
- if (handle != 0) {
- *cert = CERT_FindCertByNickname( handle, (char *) nick_name);
- if (*cert == NULL) {
- rc = 2;
+ if (TPSPresence::initialized == 2) {
+ handle = CERT_GetDefaultCertDB();
+ if (handle != 0) {
+ *cert = CERT_FindCertByNickname( handle, (char *) nick_name);
+ if (*cert == NULL) {
+ rc = 2;
+ }
+ } else {
+ rc = 1;
}
- } else {
- rc = 1;
}
return rc;