[389-commits] esc/src/lib/coolkey CoolKey.cpp, 1.9, 1.10 CoolKey.h, 1.7, 1.8 NSSManager.cpp, 1.5, 1.6 NSSManager.h, 1.4, 1.5

Jack Magne jmagne at fedoraproject.org
Sat Jun 13 23:44:54 UTC 2009


Author: jmagne

Update of /cvs/dirsec/esc/src/lib/coolkey
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv18349/lib/coolkey

Modified Files:
	CoolKey.cpp CoolKey.h NSSManager.cpp NSSManager.h 
Log Message:
Bugzilla #491019 Security Officer: Format Card operation to format a user card also formats a security officer card.


Index: CoolKey.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/coolkey/CoolKey.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- CoolKey.cpp	29 Mar 2009 00:23:54 -0000	1.9
+++ CoolKey.cpp	13 Jun 2009 23:44:52 -0000	1.10
@@ -997,6 +997,16 @@
   
     return NSSManager::GetKeyPolicy(aKey, aBuf, aBufLen);
 }
+
+HRESULT
+CoolKeyGetUID(const CoolKey *aKey, char *aBuf, int aBufLength)
+{
+    if (!aKey || !aKey->mKeyID || !aBuf || aBufLength < 1)
+        return E_FAIL;
+
+    return NSSManager::GetKeyUID(aKey,aBuf,aBufLength);
+}
+
 HRESULT
 CoolKeyGetIssuedTo(const CoolKey *aKey, char *aBuf, int aBufLength)
 {


Index: CoolKey.h
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/coolkey/CoolKey.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CoolKey.h	25 Jul 2007 20:43:22 -0000	1.7
+++ CoolKey.h	13 Jun 2009 23:44:52 -0000	1.8
@@ -133,6 +133,8 @@
 
 COOLKEY_API HRESULT CoolKeyGetCertInfo(const CoolKey *aKey, char *aCertNickname, std::string & aCertInfo);
 
+COOLKEY_API HRESULT CoolKeyGetUID(const CoolKey *aKey, char *aBuf, int aBufLength);
+
 COOLKEY_API HRESULT CoolKeyGetIssuedTo(const CoolKey *aKey, char *aBuf, int aBufLength);
 COOLKEY_API HRESULT CoolKeyGetIssuer(const CoolKey *aKey, char *aBuf, int aBufLength);
 


Index: NSSManager.cpp
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/coolkey/NSSManager.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NSSManager.cpp	25 Jul 2007 20:43:22 -0000	1.5
+++ NSSManager.cpp	13 Jun 2009 23:44:52 -0000	1.6
@@ -369,7 +369,7 @@
 
     aBuf[0]=0;
 
-    PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuedTo \n",GetTStamp(tBuff,56)));
+    PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuer \n",GetTStamp(tBuff,56)));
 
     if(!aKey )
         return E_FAIL;
@@ -409,7 +409,7 @@
                         continue;
                     }
                     orgID    = CERT_GetOrgName(&cert->subject);
-                    PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuedTo ourSlot %p curSlot  %p org %s \n",GetTStamp(tBuff,56),slot,cert->slot,orgID));
+                    PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuer ourSlot %p curSlot  %p org %s \n",GetTStamp(tBuff,56),slot,cert->slot,orgID));
 
                 }
 
@@ -437,6 +437,85 @@
     return S_OK;
 }
 
+HRESULT NSSManager::GetKeyUID(const CoolKey *aKey, char *aBuf, int aBufLength)
+{
+    char tBuff[56];
+    if(!aBuf)
+        return E_FAIL;
+
+    aBuf[0]=0;
+
+    PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyUID \n",GetTStamp(tBuff,56)));
+
+    if(!aKey )
+        return E_FAIL;
+
+    PK11SlotInfo *slot = GetSlotForKeyID(aKey);
+
+    if (!slot)
+        return E_FAIL;
+
+    CERTCertList *certs = PK11_ListCerts(PK11CertListAll,NULL);
+
+    if (!certs)
+    {
+        PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%sNSSManager::GetKeyUID no certs found! \n",GetTStamp(tBuff,56)));
+        PK11_FreeSlot(slot);
+        return E_FAIL;
+    }
+
+    CERTCertListNode *node= NULL;
+
+    char *certID = NULL;
+
+    for( node = CERT_LIST_HEAD(certs);
+             ! CERT_LIST_END(node, certs);
+             node = CERT_LIST_NEXT(node))     
+    {     
+        if(node->cert) 
+        {
+            CERTCertificate *cert = node->cert;
+
+            if(cert)
+            {
+                if(cert->slot == slot)
+                {
+                    if(IsCACert(cert))
+                    {
+                        continue;
+                    }
+
+                    certID = CERT_GetCertUid(&cert->subject);
+
+                    PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyUID ourSlot %p curSlot  %p certID %s  \n",GetTStamp(tBuff,56),slot,cert->slot,certID));
+           
+                }
+
+                if(certID)
+                    break;
+            }
+        }
+
+    }
+
+    if(certID && ((int)strlen(certID)  <  aBufLength))
+    {
+        strcpy(aBuf,certID);
+    }
+
+    if(certs)
+      CERT_DestroyCertList(certs);
+
+    if(slot)
+      PK11_FreeSlot(slot);
+
+    if(certID)
+        PORT_Free(certID);
+
+    return S_OK;
+}
+
+
 HRESULT NSSManager::GetKeyIssuedTo(const CoolKey *aKey, char *aBuf, int aBufLength)
 {
     char tBuff[56];
@@ -487,6 +566,10 @@
 
                     certID = CERT_GetCommonName(&cert->subject);
 
+                    if(!certID) {
+                        certID = CERT_GetCertUid(&cert->subject);
+                    }
+
                     PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuedTo ourSlot %p curSlot  %p certID %s  \n",GetTStamp(tBuff,56),slot,cert->slot,certID));
 
                 }


Index: NSSManager.h
===================================================================
RCS file: /cvs/dirsec/esc/src/lib/coolkey/NSSManager.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- NSSManager.h	25 Jul 2007 20:43:22 -0000	1.4
+++ NSSManager.h	13 Jun 2009 23:44:52 -0000	1.5
@@ -70,6 +70,8 @@
 
   static HRESULT  GetKeyCertNicknames( const CoolKey *aKey,  vector<string> & aStrings  ); 
 
+  static HRESULT GetKeyUID(const CoolKey *aKey, char *aBuf, int aBufLength);
+
   static HRESULT GetKeyIssuedTo(const CoolKey *aKey, char *aBuf, int aBufLength);
 
   static HRESULT GetKeyIssuer(const CoolKey *aKey, char *aBuf, int aBufLength);




More information about the Fedora-directory-commits mailing list