8c10e771f30b2391140876da8a7fe166609cc313
[shibboleth/cpp-opensaml.git] / saml / signature / SignableObject.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/signature/SignableObject.h
19  * 
20  * Base class for SAML objects that can be signed. 
21  */
22
23 #ifndef __saml_signable_h__
24 #define __saml_signable_h__
25
26 #include <saml/base.h>
27 #include <saml/signature/ContentReference.h>
28 #include <xmltooling/XMLObject.h>
29
30 namespace opensaml {
31
32     /**
33      * Base class for SAML objects that can be signed.
34      */
35     class SAML_API SignableObject : public virtual xmltooling::XMLObject
36     {
37     public:
38         virtual ~SignableObject() {}
39
40         /**
41          * Gets a new ContentReference object bound to this object.
42          * It's lifetime must not outlast this object, so it should
43          * generally be set into a Signature owned by the object.
44          * 
45          * @return  a new ContentReference
46          */
47         virtual ContentReference* getContentReference() const {
48             return new ContentReference(*this);
49         }
50         
51         /**
52          * Returns the enveloped Signature from the object.
53          *
54          * @return the enveloped Signature, or NULL
55          */
56         virtual xmlsignature::Signature* getSignature() const=0;
57
58         /**
59          * Sets an enveloped Signature in the object.
60          *
61          * @param sig the enveloped Signature, or NULL
62          */
63         virtual void setSignature(xmlsignature::Signature* sig)=0;
64
65     protected:
66         SignableObject() {}
67     };
68
69 };
70
71 #endif /* __saml_signable_h__ */