Replace license header, remove stale pkg files.
[shibboleth/cpp-xmltooling.git] / xmltooling / security / impl / ChainingTrustEngine.cpp
index a609cc5..461f022 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  Copyright 2001-2011 Internet2
- * 
- * 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
+/**
+ * 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.
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * 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
  *
- * 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.
+ * 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.
  */
 
 /**
@@ -117,11 +121,14 @@ TrustEngine* ChainingTrustEngine::removeTrustEngine(TrustEngine* oldEngine)
 
 bool ChainingTrustEngine::validate(Signature& sig, const CredentialResolver& credResolver, CredentialCriteria* criteria) const
 {
+    unsigned int usage = criteria ? criteria->getUsage() : 0;
     for (vector<SignatureTrustEngine*>::const_iterator i=m_sigEngines.begin(); i!=m_sigEngines.end(); ++i) {
         if ((*i)->validate(sig,credResolver,criteria))
             return true;
-        if (criteria)
+        if (criteria) {
             criteria->reset();
+            criteria->setUsage(usage);
+        }
     }
     return false;
 }
@@ -136,11 +143,14 @@ bool ChainingTrustEngine::validate(
     CredentialCriteria* criteria
     ) const
 {
+    unsigned int usage = criteria ? criteria->getUsage() : 0;
     for (vector<SignatureTrustEngine*>::const_iterator i=m_sigEngines.begin(); i!=m_sigEngines.end(); ++i) {
         if ((*i)->validate(sigAlgorithm, sig, keyInfo, in, in_len, credResolver, criteria))
             return true;
-        if (criteria)
+        if (criteria) {
             criteria->reset();
+            criteria->setUsage(usage);
+        }
     }
     return false;
 }
@@ -152,11 +162,14 @@ bool ChainingTrustEngine::validate(
     CredentialCriteria* criteria
     ) const
 {
+    unsigned int usage = criteria ? criteria->getUsage() : 0;
     for (vector<X509TrustEngine*>::const_iterator i=m_x509Engines.begin(); i!=m_x509Engines.end(); ++i) {
         if ((*i)->validate(certEE,certChain,credResolver,criteria))
             return true;
-        if (criteria)
+        if (criteria) {
             criteria->reset();
+            criteria->setUsage(usage);
+        }
     }
     return false;
 }
@@ -168,11 +181,14 @@ bool ChainingTrustEngine::validate(
     CredentialCriteria* criteria
     ) const
 {
+    unsigned int usage = criteria ? criteria->getUsage() : 0;
     for (vector<OpenSSLTrustEngine*>::const_iterator i=m_osslEngines.begin(); i!=m_osslEngines.end(); ++i) {
         if ((*i)->validate(certEE,certChain,credResolver,criteria))
             return true;
-        if (criteria)
+        if (criteria) {
             criteria->reset();
+            criteria->setUsage(usage);
+        }
     }
     return false;
 }