Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / signature / KeyInfo.h
1 /**
2  * Licensed to the University Corporation for Advanced Internet
3  * Development, Inc. (UCAID) under one or more contributor license
4  * agreements. See the NOTICE file distributed with this work for
5  * additional information regarding copyright ownership.
6  *
7  * UCAID licenses this file to you under the Apache License,
8  * Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. You may obtain a copy of the
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */
20
21 /**
22  * @file xmltooling/signature/KeyInfo.h
23  * 
24  * XMLObjects representing XML Digital Signature, version 20020212, KeyInfo element
25  * and related content.
26  */
27
28 #if !defined(__xmltooling_keyinfo_h__) && !defined(XMLTOOLING_NO_XMLSEC)
29 #define __xmltooling_keyinfo_h__
30
31 #include <xmltooling/ConcreteXMLObjectBuilder.h>
32 #include <xmltooling/ElementProxy.h>
33 #include <xmltooling/util/XMLConstants.h>
34
35 /**
36  * Macro for declaring signature builders.
37  * 
38  * @param cname name of class being built
39  */
40 #define DECL_XMLSIGOBJECTBUILDER(cname) \
41     DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmlconstants::XMLSIG_NS,xmlconstants::XMLSIG_PREFIX)
42
43 /**
44  * Macro for declaring signature builders.
45  * 
46  * @param cname name of class being built
47  */
48 #define DECL_XMLSIG11OBJECTBUILDER(cname) \
49     DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmlconstants::XMLSIG11_NS,xmlconstants::XMLSIG11_PREFIX)
50
51 namespace xmlsignature {
52
53     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,KeyName,Name,XML Digital Signature version 20020212 KeyName element);
54     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,MgmtData,Data,XML Digital Signature version 20020212 MgmtData element);
55     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Modulus,Value,XML Digital Signature version 20020212 Modulus element);
56     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Exponent,Value,XML Digital Signature version 20020212 Exponent element);
57     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Seed,Value,XML Digital Signature version 20020212 Seed element);
58     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,PgenCounter,Value,XML Digital Signature version 20020212 PgenCounter element);
59     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,P,Value,XML Digital Signature version 20020212 P element);
60     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Q,Value,XML Digital Signature version 20020212 Q element);
61     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,G,Value,XML Digital Signature version 20020212 G element);
62     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Y,Value,XML Digital Signature version 20020212 Y element);
63     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,J,Value,XML Digital Signature version 20020212 J element);
64     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,XPath,Expression,XML Digital Signature version 20020212 XPath element);
65     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509IssuerName,Name,XML Digital Signature version 20020212 X509IssuerName element);
66     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509SerialNumber,SerialNumber,XML Digital Signature version 20020212 X509SerialNumber element);
67     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509SKI,Value,XML Digital Signature version 20020212 X509SKI element);
68     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509SubjectName,Name,XML Digital Signature version 20020212 X509SubjectName element);
69     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509Certificate,Value,XML Digital Signature version 20020212 X509Certificate element);
70     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,X509CRL,Value,XML Digital Signature version 20020212 X509CRL element);
71     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,SPKISexp,Value,XML Digital Signature version 20020212 SPKISexp element);
72     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,PGPKeyID,ID,XML Digital Signature version 20020212 PGPKeyID element);
73     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,PGPKeyPacket,Packet,XML Digital Signature version 20020212 PGPKeyPacket element);
74
75     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,OCSPResponse,Response,XML Digital Signature version 1.1 OCSPResponse element);
76     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,PublicKey,Value,XML Digital Signature version 1.1 PublicKey element);
77
78     BEGIN_XMLOBJECT(XMLTOOL_API,DSAKeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 DSAKeyValue element);
79         DECL_TYPED_CHILD(P);
80         DECL_TYPED_CHILD(Q);
81         DECL_TYPED_CHILD(G);
82         DECL_TYPED_CHILD(Y);
83         DECL_TYPED_CHILD(J);
84         DECL_TYPED_CHILD(Seed);
85         DECL_TYPED_CHILD(PgenCounter);
86         /** DSAKeyValueType local name */
87         static const XMLCh TYPE_NAME[];
88     END_XMLOBJECT;
89
90     BEGIN_XMLOBJECT(XMLTOOL_API,RSAKeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 RSAKeyValue element);
91         DECL_TYPED_CHILD(Modulus);
92         DECL_TYPED_CHILD(Exponent);
93         /** RSAKeyValueType local name */
94         static const XMLCh TYPE_NAME[];
95     END_XMLOBJECT;
96
97     BEGIN_XMLOBJECT(XMLTOOL_API,NamedCurve,xmltooling::XMLObject,XML Digital Signature version 1.1 NamedCurve element);
98         DECL_STRING_ATTRIB(URI,URI);
99         /** NamedCurveType local name */
100         static const XMLCh TYPE_NAME[];
101     END_XMLOBJECT;
102
103     BEGIN_XMLOBJECT(XMLTOOL_API,ECKeyValue,xmltooling::XMLObject,XML Digital Signature version 1.1 ECKeyValue element);
104         DECL_STRING_ATTRIB(Id,ID);
105         DECL_XMLOBJECT_CHILD(ECParameters);
106         DECL_TYPED_CHILD(NamedCurve);
107         DECL_TYPED_CHILD(PublicKey);
108         /** ECKeyValueType local name */
109         static const XMLCh TYPE_NAME[];
110     END_XMLOBJECT;
111
112     BEGIN_XMLOBJECT(XMLTOOL_API,KeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 KeyValue element);
113         DECL_TYPED_CHILD(DSAKeyValue);
114         DECL_TYPED_CHILD(RSAKeyValue);
115         DECL_TYPED_CHILD(ECKeyValue);
116         DECL_XMLOBJECT_CHILD(UnknownXMLObject);
117         /** KeyValueType local name */
118         static const XMLCh TYPE_NAME[];
119     END_XMLOBJECT;
120
121     BEGIN_XMLOBJECT(XMLTOOL_API,Transform,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 Transform element);
122         DECL_STRING_ATTRIB(Algorithm,ALGORITHM);
123         DECL_TYPED_CHILDREN(XPath);
124         /** TransformType local name */
125         static const XMLCh TYPE_NAME[];
126     END_XMLOBJECT;
127
128     BEGIN_XMLOBJECT(XMLTOOL_API,Transforms,xmltooling::XMLObject,XML Digital Signature version 20020212 Transforms element);
129         DECL_TYPED_CHILDREN(Transform);
130         /** TransformsType local name */
131         static const XMLCh TYPE_NAME[];
132     END_XMLOBJECT;
133
134     BEGIN_XMLOBJECT(XMLTOOL_API,RetrievalMethod,xmltooling::XMLObject,XML Digital Signature version 20020212 RetrievalMethod element);
135         DECL_STRING_ATTRIB(URI,URI);
136         DECL_STRING_ATTRIB(Type,TYPE);
137         DECL_TYPED_CHILD(Transforms);
138         /** RetrievalMethodType local name */
139         static const XMLCh TYPE_NAME[];
140         /** DSAKeyValue RetrievalMethod Type */
141         static const XMLCh TYPE_DSAKEYVALUE[];
142         /** RSAKeyValue RetrievalMethod Type */
143         static const XMLCh TYPE_RSAKEYVALUE[];
144         /** X509Data RetrievalMethod Type */
145         static const XMLCh TYPE_X509DATA[];
146     END_XMLOBJECT;
147
148     BEGIN_XMLOBJECT(XMLTOOL_API,X509IssuerSerial,xmltooling::XMLObject,XML Digital Signature version 20020212 X509IssuerSerial element);
149         DECL_TYPED_CHILD(X509IssuerName);
150         DECL_TYPED_CHILD(X509SerialNumber);
151         /** X509IssuerSerialType local name */
152         static const XMLCh TYPE_NAME[];
153     END_XMLOBJECT;
154
155     BEGIN_XMLOBJECT(XMLTOOL_API,X509Digest,xmltooling::XMLObject,XML Digital Signature version 1.1 X509Digest element);
156         DECL_STRING_ATTRIB(Algorithm,ALGORITHM);
157         DECL_SIMPLE_CONTENT(Value);
158         /** X509DigestType local name */
159         static const XMLCh TYPE_NAME[];
160     END_XMLOBJECT;
161
162     BEGIN_XMLOBJECT(XMLTOOL_API,X509Data,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 X509Data element);
163         DECL_TYPED_CHILDREN(X509IssuerSerial);
164         DECL_TYPED_CHILDREN(X509SKI);
165         DECL_TYPED_CHILDREN(X509SubjectName);
166         DECL_TYPED_CHILDREN(X509Certificate);
167         DECL_TYPED_CHILDREN(X509CRL);
168         DECL_TYPED_CHILDREN(X509Digest);
169         DECL_TYPED_CHILDREN(OCSPResponse);
170         /** X509DataType local name */
171         static const XMLCh TYPE_NAME[];
172     END_XMLOBJECT;
173
174     BEGIN_XMLOBJECT(XMLTOOL_API,SPKIData,xmltooling::XMLObject,XML Digital Signature version 20020212 SPKIData element);
175         /** SPKIDataType local name */
176         static const XMLCh TYPE_NAME[];
177         
178         /** Returns modifiable collection of SPKIsexp/XMLObject pairs. */
179         virtual VectorOfPairs(SPKISexp,xmltooling::XMLObject) getSPKISexps()=0;
180         
181         /** Returns reference to immutable collection of SPKIsexp/XMLObject pairs. */
182         virtual const std::vector< std::pair<SPKISexp*,xmltooling::XMLObject*> >& getSPKISexps() const=0;
183     END_XMLOBJECT;
184
185     BEGIN_XMLOBJECT(XMLTOOL_API,PGPData,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 PGPData element);
186         DECL_TYPED_CHILD(PGPKeyID);
187         DECL_TYPED_CHILD(PGPKeyPacket);
188         /** PGPDataType local name */
189         static const XMLCh TYPE_NAME[];
190     END_XMLOBJECT;
191
192     BEGIN_XMLOBJECT(XMLTOOL_API,DEREncodedKeyValue,xmltooling::XMLObject,XML Digital Signature version 1.1 DEREncodedKeyValue element);
193         DECL_STRING_ATTRIB(Id,ID);
194         DECL_SIMPLE_CONTENT(Value);
195         /** DEREncodedKeyValueType local name */
196         static const XMLCh TYPE_NAME[];
197     END_XMLOBJECT;
198
199     BEGIN_XMLOBJECT(XMLTOOL_API,KeyInfoReference,xmltooling::XMLObject,XML Digital Signature version 1.1 KeyInfoReference element);
200         DECL_STRING_ATTRIB(Id,ID);
201         DECL_STRING_ATTRIB(URI,URI);
202         /** KeyInfoReferenceType local name */
203         static const XMLCh TYPE_NAME[];
204     END_XMLOBJECT;
205
206     BEGIN_XMLOBJECT(XMLTOOL_API,KeyInfo,xmltooling::ElementExtensibleXMLObject,XML Digital Signature version 20020212 KeyInfo element);
207         DECL_STRING_ATTRIB(Id,ID);
208         DECL_TYPED_CHILDREN(X509Data);
209         DECL_TYPED_CHILDREN(KeyName);
210         DECL_TYPED_CHILDREN(KeyValue);
211         DECL_TYPED_CHILDREN(DEREncodedKeyValue);
212         DECL_TYPED_CHILDREN(RetrievalMethod);
213         DECL_TYPED_CHILDREN(MgmtData);
214         DECL_TYPED_CHILDREN(PGPData);
215         DECL_TYPED_CHILDREN(SPKIData);
216         DECL_TYPED_CHILDREN(KeyInfoReference);
217         /** KeyInfoType local name */
218         static const XMLCh TYPE_NAME[];
219     END_XMLOBJECT;
220
221     DECL_XMLSIGOBJECTBUILDER(PGPData);
222     DECL_XMLSIGOBJECTBUILDER(PGPKeyID);
223     DECL_XMLSIGOBJECTBUILDER(PGPKeyPacket);
224     DECL_XMLSIGOBJECTBUILDER(SPKIData);
225     DECL_XMLSIGOBJECTBUILDER(SPKISexp);
226     DECL_XMLSIGOBJECTBUILDER(X509IssuerSerial);
227     DECL_XMLSIGOBJECTBUILDER(X509IssuerName);
228     DECL_XMLSIGOBJECTBUILDER(X509SerialNumber);
229     DECL_XMLSIGOBJECTBUILDER(X509SKI);
230     DECL_XMLSIGOBJECTBUILDER(X509SubjectName);
231     DECL_XMLSIGOBJECTBUILDER(X509Certificate);
232     DECL_XMLSIGOBJECTBUILDER(X509CRL);
233     DECL_XMLSIGOBJECTBUILDER(X509Data);
234     DECL_XMLSIGOBJECTBUILDER(XPath);
235     DECL_XMLSIGOBJECTBUILDER(Transform);
236     DECL_XMLSIGOBJECTBUILDER(Transforms);
237     DECL_XMLSIGOBJECTBUILDER(RetrievalMethod);
238     DECL_XMLSIGOBJECTBUILDER(KeyName);
239     DECL_XMLSIGOBJECTBUILDER(MgmtData);
240     DECL_XMLSIGOBJECTBUILDER(Modulus);
241     DECL_XMLSIGOBJECTBUILDER(Exponent);
242     DECL_XMLSIGOBJECTBUILDER(Seed);
243     DECL_XMLSIGOBJECTBUILDER(PgenCounter);
244     DECL_XMLSIGOBJECTBUILDER(P);
245     DECL_XMLSIGOBJECTBUILDER(Q);
246     DECL_XMLSIGOBJECTBUILDER(G);
247     DECL_XMLSIGOBJECTBUILDER(Y);
248     DECL_XMLSIGOBJECTBUILDER(J);
249     DECL_XMLSIGOBJECTBUILDER(DSAKeyValue);
250     DECL_XMLSIGOBJECTBUILDER(RSAKeyValue);
251     DECL_XMLSIGOBJECTBUILDER(KeyValue);
252     DECL_XMLSIGOBJECTBUILDER(KeyInfo);
253
254     DECL_XMLSIG11OBJECTBUILDER(DEREncodedKeyValue);
255     DECL_XMLSIG11OBJECTBUILDER(ECKeyValue);
256     DECL_XMLSIG11OBJECTBUILDER(KeyInfoReference);
257     DECL_XMLSIG11OBJECTBUILDER(NamedCurve);
258     DECL_XMLSIG11OBJECTBUILDER(OCSPResponse);
259     DECL_XMLSIG11OBJECTBUILDER(PublicKey);
260     DECL_XMLSIG11OBJECTBUILDER(X509Digest);
261
262     /**
263      * Registers builders and validators for KeyInfo classes into the runtime.
264      */
265     void XMLTOOL_API registerKeyInfoClasses();
266
267 };
268
269 #endif /* __xmltooling_keyinfo_h__ */