SAML 2 SSO validator.
[shibboleth/cpp-opensaml.git] / saml / saml2 / profile / BrowserSSOProfileValidator.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/saml2/profile/BrowserSSOProfileValidator.h
19  * 
20  * SAML 2.0 Browser SSO Profile Assertion Validator 
21  */
22
23 #ifndef __saml2_ssoval_h__
24 #define __saml2_ssoval_h__
25
26 #include <saml/saml2/profile/AssertionValidator.h>
27
28 namespace opensaml {
29     
30     namespace saml2 {
31         
32         /**
33          * SAML 2.0 Browser SSO Profile Assertion Validator
34          *
35          * <p>In addition to standard core requirements for validity, SSO assertions
36          * <strong>MUST</strong> have NotBefore/NotOnOrAfter attributes and each subject statement
37          * <strong>MUST</strong> be confirmable via bearer method.
38          */
39         class SAML_API BrowserSSOProfileValidator : public AssertionValidator
40         {
41         public:
42             /**
43              * Constructor
44              * 
45              * @param audiences     set of audience values representing recipient
46              * @param ts            timestamp to evaluate assertion conditions, or 0 to bypass check
47              * @param destination   server location to which assertion was delivered, or 0 to bypass check
48              * @param requestID     ID of request that resulted in assertion, or NULL if unsolicited
49              */
50             BrowserSSOProfileValidator(
51                 const std::vector<const XMLCh*>& audiences,
52                 time_t ts=0,
53                 const XMLCh* destination=NULL,
54                 const XMLCh* requestID=NULL
55                 ) : AssertionValidator(audiences, ts), m_destination(destination), m_requestID(requestID) {
56             }
57             virtual ~BrowserSSOProfileValidator() {}
58     
59             void validateAssertion(const Assertion& assertion) const;
60
61             /**
62              * Return address information from the confirmed bearer SubjectConfirmation, if any.
63              *
64              * @return  address information
65              */
66             const char* getAddress() const {
67                 return m_address.c_str();
68             }
69         
70         protected:
71             /** Server location to which assertion was delivered. */
72             const XMLCh* m_destination;
73
74             /** ID of request that resulted in assertions. */
75             const XMLCh* m_requestID;
76
77         private:
78             /** Address in confirmed bearer SubjectConfirmationData. */
79             mutable std::string m_address;
80         };
81         
82     };
83 };
84
85 #endif /* __saml2_ssoval_h__ */