7e4eefcfbe03d22558b50fb3a685d4e27a60003c
[shibboleth/cpp-opensaml.git] / saml / saml1 / profile / AssertionValidator.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file saml/saml1/profile/AssertionValidator.h
19  * 
20  * SAML 1.x basic assertion validator
21  */
22
23 #ifndef __saml1_assval_h__
24 #define __saml1_assval_h__
25
26 #include <saml/base.h>
27 #include <xmltooling/validation/Validator.h>
28
29 namespace opensaml {
30     namespace saml1 {
31         
32         class SAML_API Assertion;
33         class SAML_API Condition;
34         
35         /**
36          * SAML 1.x basic assertion validator provides time and audience condition checking.
37          */
38         class SAML_API AssertionValidator : public virtual xmltooling::Validator
39         {
40         public:
41             /**
42              * Constructor
43              * 
44              * @param recipient name of assertion recipient (implicit audience)
45              * @param audiences additional audience values
46              * @param ts        timestamp to evaluate assertion conditions, or 0 to bypass check
47              */
48             AssertionValidator(const XMLCh* recipient, const std::vector<const XMLCh*>* audiences=NULL, time_t ts=0)
49                 : m_recipient(recipient), m_audiences(audiences), m_ts(ts) {
50             }
51
52             virtual ~AssertionValidator() {}
53     
54             void validate(const xmltooling::XMLObject* xmlObject) const;
55
56             /**
57              * Type-safe validation method.
58              * 
59              * @param assertion assertion to validate
60              */
61             virtual void validateAssertion(const Assertion& assertion) const;
62
63             /**
64              * Condition validation.
65              *
66              * <p>The base class version only understands AudienceRestrictionConditions.
67              * All other condition types will be rejected and require subclassing to
68              * prevent validation failure.
69              * 
70              * @param condition condition to validate
71              */
72             virtual void validateCondition(const Condition* condition) const;
73
74         protected:
75             /** Name of recipient (implicit audience). */
76             const XMLCh* m_recipient;
77             
78             /** Additional audience values. */
79             const std::vector<const XMLCh*>* m_audiences;
80
81             /** Timestamp to evaluate assertion conditions. */
82             time_t m_ts;
83         };
84         
85     };
86 };
87
88 #endif /* __saml1_assval_h__ */