Add accessors for new KeyInfo extensions, and fix builder namespaces.
[shibboleth/cpp-xmltooling.git] / xmltooling / signature / KeyInfo.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 xmltooling/signature/KeyInfo.h
19  * 
20  * XMLObjects representing XML Digital Signature, version 20020212, KeyInfo element
21  * and related content.
22  */
23
24 #if !defined(__xmltooling_keyinfo_h__) && !defined(XMLTOOLING_NO_XMLSEC)
25 #define __xmltooling_keyinfo_h__
26
27 #include <xmltooling/ConcreteXMLObjectBuilder.h>
28 #include <xmltooling/ElementProxy.h>
29 #include <xmltooling/util/XMLConstants.h>
30
31 /**
32  * Macro for declaring signature builders.
33  * 
34  * @param cname name of class being built
35  */
36 #define DECL_XMLSIGOBJECTBUILDER(cname) \
37     DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmlconstants::XMLSIG_NS,xmlconstants::XMLSIG_PREFIX)
38
39 /**
40  * Macro for declaring signature builders.
41  * 
42  * @param cname name of class being built
43  */
44 #define DECL_XMLSIG11OBJECTBUILDER(cname) \
45     DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmlconstants::XMLSIG11_NS,xmlconstants::XMLSIG11_PREFIX)
46
47 namespace xmlsignature {
48
49     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,KeyName,Name,XML Digital Signature version 20020212 KeyName element);
50     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,MgmtData,Data,XML Digital Signature version 20020212 MgmtData element);
51     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Modulus,Value,XML Digital Signature version 20020212 Modulus element);
52     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Exponent,Value,XML Digital Signature version 20020212 Exponent element);
53     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Seed,Value,XML Digital Signature version 20020212 Seed element);
54     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,PgenCounter,Value,XML Digital Signature version 20020212 PgenCounter element);
55     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,P,Value,XML Digital Signature version 20020212 P element);
56     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Q,Value,XML Digital Signature version 20020212 Q element);
57     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,G,Value,XML Digital Signature version 20020212 G element);
58     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Y,Value,XML Digital Signature version 20020212 Y element);
59     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,J,Value,XML Digital Signature version 20020212 J element);
60     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,XPath,Expression,XML Digital Signature version 20020212 XPath element);
61     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509IssuerName,Name,XML Digital Signature version 20020212 X509IssuerName element);
62     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509SerialNumber,SerialNumber,XML Digital Signature version 20020212 X509SerialNumber element);
63     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509SKI,Value,XML Digital Signature version 20020212 X509SKI element);
64     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509SubjectName,Name,XML Digital Signature version 20020212 X509SubjectName element);
65     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509Certificate,Value,XML Digital Signature version 20020212 X509Certificate element);
66     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509CRL,Value,XML Digital Signature version 20020212 X509CRL element);
67     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,OCSPResponse,Response,XML Digital Signature version 1.1 OCSPResponse element);
68     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,SPKISexp,Value,XML Digital Signature version 20020212 SPKISexp element);
69     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,PGPKeyID,ID,XML Digital Signature version 20020212 PGPKeyID element);
70     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,PGPKeyPacket,Packet,XML Digital Signature version 20020212 PGPKeyPacket element);
71
72     BEGIN_XMLOBJECT(XMLTOOL_API,DSAKeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 DSAKeyValue element);
73         DECL_TYPED_CHILD(P);
74         DECL_TYPED_CHILD(Q);
75         DECL_TYPED_CHILD(G);
76         DECL_TYPED_CHILD(Y);
77         DECL_TYPED_CHILD(J);
78         DECL_TYPED_CHILD(Seed);
79         DECL_TYPED_CHILD(PgenCounter);
80         /** DSAKeyValueType local name */
81         static const XMLCh TYPE_NAME[];
82     END_XMLOBJECT;
83
84     BEGIN_XMLOBJECT(XMLTOOL_API,RSAKeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 RSAKeyValue element);
85         DECL_TYPED_CHILD(Modulus);
86         DECL_TYPED_CHILD(Exponent);
87         /** RSAKeyValueType local name */
88         static const XMLCh TYPE_NAME[];
89     END_XMLOBJECT;
90
91     BEGIN_XMLOBJECT(XMLTOOL_API,KeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 KeyValue element);
92         DECL_TYPED_CHILD(DSAKeyValue);
93         DECL_TYPED_CHILD(RSAKeyValue);
94         DECL_XMLOBJECT_CHILD(UnknownXMLObject);
95         /** KeyValueType local name */
96         static const XMLCh TYPE_NAME[];
97     END_XMLOBJECT;
98
99     BEGIN_XMLOBJECT(XMLTOOL_API,DEREncodedKeyValue,xmltooling::XMLObject,XML Digital Signature version 1.1 DEREncodedKeyValue element);
100         DECL_STRING_ATTRIB(Id,ID);
101         DECL_SIMPLE_CONTENT(Value);
102         /** DEREncodedKeyValueType local name */
103         static const XMLCh TYPE_NAME[];
104     END_XMLOBJECT;
105
106     BEGIN_XMLOBJECT(XMLTOOL_API,Transform,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 Transform element);
107         DECL_STRING_ATTRIB(Algorithm,ALGORITHM);
108         DECL_TYPED_CHILDREN(XPath);
109         /** TransformType local name */
110         static const XMLCh TYPE_NAME[];
111     END_XMLOBJECT;
112
113     BEGIN_XMLOBJECT(XMLTOOL_API,Transforms,xmltooling::XMLObject,XML Digital Signature version 20020212 Transforms element);
114         DECL_TYPED_CHILDREN(Transform);
115         /** TransformsType local name */
116         static const XMLCh TYPE_NAME[];
117     END_XMLOBJECT;
118
119     BEGIN_XMLOBJECT(XMLTOOL_API,RetrievalMethod,xmltooling::XMLObject,XML Digital Signature version 20020212 RetrievalMethod element);
120         DECL_STRING_ATTRIB(URI,URI);
121         DECL_STRING_ATTRIB(Type,TYPE);
122         DECL_TYPED_CHILD(Transforms);
123         /** RetrievalMethodType local name */
124         static const XMLCh TYPE_NAME[];
125         /** DSAKeyValue RetrievalMethod Type */
126         static const XMLCh TYPE_DSAKEYVALUE[];
127         /** RSAKeyValue RetrievalMethod Type */
128         static const XMLCh TYPE_RSAKEYVALUE[];
129         /** X509Data RetrievalMethod Type */
130         static const XMLCh TYPE_X509DATA[];
131     END_XMLOBJECT;
132
133     BEGIN_XMLOBJECT(XMLTOOL_API,X509IssuerSerial,xmltooling::XMLObject,XML Digital Signature version 20020212 X509IssuerSerial element);
134         DECL_TYPED_CHILD(X509IssuerName);
135         DECL_TYPED_CHILD(X509SerialNumber);
136         /** X509IssuerSerialType local name */
137         static const XMLCh TYPE_NAME[];
138     END_XMLOBJECT;
139
140     BEGIN_XMLOBJECT(XMLTOOL_API,X509Data,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 X509Data element);
141         DECL_TYPED_CHILDREN(X509IssuerSerial);
142         DECL_TYPED_CHILDREN(X509SKI);
143         DECL_TYPED_CHILDREN(X509SubjectName);
144         DECL_TYPED_CHILDREN(X509Certificate);
145         DECL_TYPED_CHILDREN(X509CRL);
146         DECL_TYPED_CHILDREN(OCSPResponse);
147         /** X509DataType local name */
148         static const XMLCh TYPE_NAME[];
149     END_XMLOBJECT;
150
151     BEGIN_XMLOBJECT(XMLTOOL_API,SPKIData,xmltooling::XMLObject,XML Digital Signature version 20020212 SPKIData element);
152         /** SPKIDataType local name */
153         static const XMLCh TYPE_NAME[];
154         
155         /** Returns modifiable collection of SPKIsexp/XMLObject pairs. */
156         virtual VectorOfPairs(SPKISexp,xmltooling::XMLObject) getSPKISexps()=0;
157         
158         /** Returns reference to immutable collection of SPKIsexp/XMLObject pairs. */
159         virtual const std::vector< std::pair<SPKISexp*,xmltooling::XMLObject*> >& getSPKISexps() const=0;
160     END_XMLOBJECT;
161
162     BEGIN_XMLOBJECT(XMLTOOL_API,PGPData,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 PGPData element);
163         DECL_TYPED_CHILD(PGPKeyID);
164         DECL_TYPED_CHILD(PGPKeyPacket);
165         /** PGPDataType local name */
166         static const XMLCh TYPE_NAME[];
167     END_XMLOBJECT;
168
169     BEGIN_XMLOBJECT(XMLTOOL_API,KeyInfoReference,xmltooling::XMLObject,XML Digital Signature version 1.1 KeyInfoReference element);
170         DECL_STRING_ATTRIB(Id,ID);
171         DECL_STRING_ATTRIB(URI,URI);
172         /** KeyInfoReferenceType local name */
173         static const XMLCh TYPE_NAME[];
174     END_XMLOBJECT;
175
176     BEGIN_XMLOBJECT(XMLTOOL_API,KeyInfo,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 KeyInfo element);
177         DECL_STRING_ATTRIB(Id,ID);
178         DECL_TYPED_CHILDREN(X509Data);
179         DECL_TYPED_CHILDREN(KeyName);
180         DECL_TYPED_CHILDREN(KeyValue);
181         DECL_TYPED_CHILDREN(DEREncodedKeyValue);
182         DECL_TYPED_CHILDREN(RetrievalMethod);
183         DECL_TYPED_CHILDREN(MgmtData);
184         DECL_TYPED_CHILDREN(PGPData);
185         DECL_TYPED_CHILDREN(SPKIData);
186         DECL_TYPED_CHILDREN(KeyInfoReference);
187         /** KeyInfoType local name */
188         static const XMLCh TYPE_NAME[];
189     END_XMLOBJECT;
190
191     DECL_XMLSIGOBJECTBUILDER(PGPData);
192     DECL_XMLSIGOBJECTBUILDER(PGPKeyID);
193     DECL_XMLSIGOBJECTBUILDER(PGPKeyPacket);
194     DECL_XMLSIGOBJECTBUILDER(SPKIData);
195     DECL_XMLSIGOBJECTBUILDER(SPKISexp);
196     DECL_XMLSIGOBJECTBUILDER(X509IssuerSerial);
197     DECL_XMLSIGOBJECTBUILDER(X509IssuerName);
198     DECL_XMLSIGOBJECTBUILDER(X509SerialNumber);
199     DECL_XMLSIGOBJECTBUILDER(X509SKI);
200     DECL_XMLSIGOBJECTBUILDER(X509SubjectName);
201     DECL_XMLSIGOBJECTBUILDER(X509Certificate);
202     DECL_XMLSIGOBJECTBUILDER(X509CRL);
203     DECL_XMLSIGOBJECTBUILDER(X509Data);
204     DECL_XMLSIGOBJECTBUILDER(XPath);
205     DECL_XMLSIGOBJECTBUILDER(Transform);
206     DECL_XMLSIGOBJECTBUILDER(Transforms);
207     DECL_XMLSIGOBJECTBUILDER(RetrievalMethod);
208     DECL_XMLSIGOBJECTBUILDER(KeyName);
209     DECL_XMLSIGOBJECTBUILDER(MgmtData);
210     DECL_XMLSIGOBJECTBUILDER(Modulus);
211     DECL_XMLSIGOBJECTBUILDER(Exponent);
212     DECL_XMLSIGOBJECTBUILDER(Seed);
213     DECL_XMLSIGOBJECTBUILDER(PgenCounter);
214     DECL_XMLSIGOBJECTBUILDER(P);
215     DECL_XMLSIGOBJECTBUILDER(Q);
216     DECL_XMLSIGOBJECTBUILDER(G);
217     DECL_XMLSIGOBJECTBUILDER(Y);
218     DECL_XMLSIGOBJECTBUILDER(J);
219     DECL_XMLSIGOBJECTBUILDER(DSAKeyValue);
220     DECL_XMLSIGOBJECTBUILDER(RSAKeyValue);
221     DECL_XMLSIGOBJECTBUILDER(KeyValue);
222     DECL_XMLSIGOBJECTBUILDER(KeyInfo);
223
224     DECL_XMLSIG11OBJECTBUILDER(DEREncodedKeyValue);
225     DECL_XMLSIG11OBJECTBUILDER(KeyInfoReference);
226     DECL_XMLSIG11OBJECTBUILDER(OCSPResponse);
227
228     /**
229      * Registers builders and validators for KeyInfo classes into the runtime.
230      */
231     void XMLTOOL_API registerKeyInfoClasses();
232
233 };
234
235 #endif /* __xmltooling_keyinfo_h__ */