Refactor extraction of certificate details.
[shibboleth/xmltooling.git] / xmltooling / encryption / impl / Decrypter.cpp
index 89a274b..a87fa89 100644 (file)
  */
 
 #include "internal.h"
+#include "logging.h"
 #include "encryption/Decrypter.h"
 #include "encryption/EncryptedKeyResolver.h"
 #include "security/Credential.h"
 #include "security/CredentialCriteria.h"
 #include "security/CredentialResolver.h"
 
-#include <log4cpp/Category.hh>
 #include <xsec/enc/XSECCryptoException.hpp>
 #include <xsec/framework/XSECException.hpp>
 #include <xsec/framework/XSECAlgorithmMapper.hpp>
@@ -87,12 +87,9 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
 
     // Resolve a decryption key directly.
     vector<const Credential*> creds;
-    int types =
-        CredentialCriteria::KEYINFO_EXTRACTION_KEY |
-        CredentialCriteria::KEYINFO_EXTRACTION_KEYNAMES |
-        CredentialCriteria::KEYINFO_EXTRACTION_IMPLICIT_KEYNAMES;
+    int types = CredentialCriteria::KEYINFO_EXTRACTION_KEY | CredentialCriteria::KEYINFO_EXTRACTION_KEYNAMES;
     if (m_criteria) {
-        m_criteria->setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        m_criteria->setUsage(Credential::ENCRYPTION_CREDENTIAL);
         m_criteria->setKeyInfo(encryptedData.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedData.getEncryptionMethod();
         if (meth)
@@ -101,7 +98,7 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
     }
     else {
         CredentialCriteria criteria;
-        criteria.setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        criteria.setUsage(Credential::ENCRYPTION_CREDENTIAL);
         criteria.setKeyInfo(encryptedData.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedData.getEncryptionMethod();
         if (meth)
@@ -119,7 +116,7 @@ DOMDocumentFragment* Decrypter::decryptData(const EncryptedData& encryptedData,
             return decryptData(encryptedData, key);
         }
         catch(DecryptionException& ex) {
-            log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
+            logging::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
         }
     }
 
@@ -187,12 +184,9 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, co
 
     // Resolve a decryption key directly.
     vector<const Credential*> creds;
-    int types =
-        CredentialCriteria::KEYINFO_EXTRACTION_KEY |
-        CredentialCriteria::KEYINFO_EXTRACTION_KEYNAMES |
-        CredentialCriteria::KEYINFO_EXTRACTION_IMPLICIT_KEYNAMES;
+    int types = CredentialCriteria::KEYINFO_EXTRACTION_KEY | CredentialCriteria::KEYINFO_EXTRACTION_KEYNAMES;
     if (m_criteria) {
-        m_criteria->setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        m_criteria->setUsage(Credential::ENCRYPTION_CREDENTIAL);
         m_criteria->setKeyInfo(encryptedData.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedData.getEncryptionMethod();
         if (meth)
@@ -201,7 +195,7 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, co
     }
     else {
         CredentialCriteria criteria;
-        criteria.setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        criteria.setUsage(Credential::ENCRYPTION_CREDENTIAL);
         criteria.setKeyInfo(encryptedData.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedData.getEncryptionMethod();
         if (meth)
@@ -219,7 +213,7 @@ void Decrypter::decryptData(ostream& out, const EncryptedData& encryptedData, co
             return decryptData(out, encryptedData, key);
         }
         catch(DecryptionException& ex) {
-            log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
+            logging::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
         }
     }
 
@@ -270,13 +264,10 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
         m_cipher=XMLToolingInternalConfig::getInternalConfig().m_xsecProvider->newCipher(encryptedKey.getDOM()->getOwnerDocument());
     
     // Resolve key decryption keys.
-    int types =
-        CredentialCriteria::KEYINFO_EXTRACTION_KEY |
-        CredentialCriteria::KEYINFO_EXTRACTION_KEYNAMES |
-        CredentialCriteria::KEYINFO_EXTRACTION_IMPLICIT_KEYNAMES;
+    int types = CredentialCriteria::KEYINFO_EXTRACTION_KEY | CredentialCriteria::KEYINFO_EXTRACTION_KEYNAMES;
     vector<const Credential*> creds;
     if (m_criteria) {
-        m_criteria->setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        m_criteria->setUsage(Credential::ENCRYPTION_CREDENTIAL);
         m_criteria->setKeyInfo(encryptedKey.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedKey.getEncryptionMethod();
         if (meth)
@@ -285,7 +276,7 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
     }
     else {
         CredentialCriteria criteria;
-        criteria.setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL);
+        criteria.setUsage(Credential::ENCRYPTION_CREDENTIAL);
         criteria.setKeyInfo(encryptedKey.getKeyInfo(), types);
         const EncryptionMethod* meth = encryptedKey.getEncryptionMethod();
         if (meth)
@@ -320,7 +311,7 @@ XSECCryptoKey* Decrypter::decryptKey(const EncryptedKey& encryptedKey, const XML
             }
         }
         catch(DecryptionException& ex) {
-            log4cpp::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
+            logging::Category::getInstance(XMLTOOLING_LOGCAT".Decrypter").warn(ex.what());
         }
     }