https://issues.shibboleth.net/jira/browse/CPPXT-94
[shibboleth/cpp-xmltooling.git] / xmltooling / security / impl / FilesystemCredentialResolver.cpp
index 26d3dc3..480ef3b 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  Copyright 2001-2011 Internet2
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
  *
- * Licensed 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
+ * UCAID 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
+ * 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.
+ * 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.
  */
 
 /**
@@ -389,7 +393,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
             m_key.backing = XMLHelper::getAttrString(e, nullptr, backingFilePath);
             if (m_key.backing.empty())
                 throw XMLSecurityException("FilesystemCredentialResolver can't access key, backingFilePath missing from URL element.");
-            XMLToolingConfig::getConfig().getPathResolver()->resolve(m_key.backing, PathResolver::XMLTOOLING_RUN_FILE);
+            XMLToolingConfig::getConfig().getPathResolver()->resolve(m_key.backing, PathResolver::XMLTOOLING_CACHE_FILE);
             m_key.reloadInterval = XMLHelper::getAttrInt(e, 0, _reloadInterval);
         }
         else {
@@ -441,7 +445,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
                 crl.backing = XMLHelper::getAttrString(e, nullptr, backingFilePath);
                 if (crl.backing.empty())
                     throw XMLSecurityException("FilesystemCredentialResolver can't access CRL, backingFilePath missing from URL element.");
-                XMLToolingConfig::getConfig().getPathResolver()->resolve(crl.backing, PathResolver::XMLTOOLING_RUN_FILE);
+                XMLToolingConfig::getConfig().getPathResolver()->resolve(crl.backing, PathResolver::XMLTOOLING_CACHE_FILE);
                 crl.reloadInterval = XMLHelper::getAttrInt(e, 0, _reloadInterval);
             }
             e = XMLHelper::getNextSiblingElement(e, _URL);
@@ -483,7 +487,7 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
                 cert.backing = XMLHelper::getAttrString(e, nullptr, backingFilePath);
                 if (cert.backing.empty())
                     throw XMLSecurityException("FilesystemCredentialResolver can't access certificate, backingFilePath missing from URL element.");
-                XMLToolingConfig::getConfig().getPathResolver()->resolve(cert.backing, PathResolver::XMLTOOLING_RUN_FILE);
+                XMLToolingConfig::getConfig().getPathResolver()->resolve(cert.backing, PathResolver::XMLTOOLING_CACHE_FILE);
                 cert.reloadInterval = XMLHelper::getAttrInt(e, 0, _reloadInterval);
             }
             e = XMLHelper::getNextSiblingElement(e);
@@ -512,6 +516,9 @@ FilesystemCredentialResolver::FilesystemCredentialResolver(const DOMElement* e)
     auto_ptr<Credential> credential(getCredential());
     m_lock = RWLock::create();
     m_credential = credential.release();
+    if (m_credential->getPrivateKey() == nullptr) {
+        log.info("no private key resolved, usable for verification/trust only");
+    }
 }
 
 FilesystemCredentialResolver::~FilesystemCredentialResolver()