<pathentry kind="mac" name="WIN32" path="" value=""/>\r
<pathentry kind="out" path=""/>\r
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>\r
-<pathentry excluding="util/|io/|impl/|validation/|signature/|signature/impl/" kind="src" path="xmltooling"/>\r
+<pathentry excluding="util/|io/|impl/|validation/|signature/|signature/impl/|encryption/|encryption/impl/" kind="src" path="xmltooling"/>\r
<pathentry kind="src" path="xmltooling/util"/>\r
<pathentry kind="src" path="xmltooling/io"/>\r
<pathentry kind="src" path="xmltooling/impl"/>\r
<pathentry kind="src" path="xmltooling/validation"/>\r
<pathentry excluding="impl/" kind="src" path="xmltooling/signature"/>\r
<pathentry kind="src" path="xmltooling/signature/impl"/>\r
+<pathentry excluding="impl/" kind="src" path="xmltooling/encryption"/>\r
+<pathentry kind="src" path="xmltooling/encryption/impl"/>\r
</item>\r
</data>\r
</cdtproject>\r
libxmltoolingincludedir = $(includedir)/xmltooling
+encincludedir = $(includedir)/xmltooling/encryption
+
implincludedir = $(includedir)/xmltooling/impl
ioincludedir = $(includedir)/xmltooling/io
XMLObjectBuilder.h \
XMLToolingConfig.h
+encinclude_HEADERS = \
+ encryption/Encryption.h
+
implinclude_HEADERS = \
impl/AnyElement.h \
impl/UnknownElement.h
unicode.cpp \
XMLObjectBuilder.cpp \
XMLToolingConfig.cpp \
+ encryption/impl/EncryptionImpl.cpp \
+ encryption/impl/EncryptionSchemaValidators.cpp \
impl/AnyElement.cpp \
impl/UnknownElement.cpp \
io/AbstractXMLObjectMarshaller.cpp \
#include "internal.h"
#include "exceptions.h"
#include "XMLToolingConfig.h"
+#include "encryption/Encryption.h"
#include "impl/UnknownElement.h"
#include "signature/KeyInfo.h"
#include "signature/Signature.h"
#include <stdexcept>
+using namespace xmlencryption;
using namespace xmlsignature;
using namespace xmltooling;
using namespace log4cpp;
XMLObjectBuilder::registerDefaultBuilder(new UnknownElementBuilder());
registerKeyInfoClasses();
+ registerEncryptionClasses();
REGISTER_EXCEPTION_FACTORY(XMLParserException,xmltooling);
REGISTER_EXCEPTION_FACTORY(XMLObjectException,xmltooling);
static const XMLCh LOCAL_NAME[]
/**
+ * Begins the declaration of an XMLObject specialization with two base classes.
+ * Basic boilerplate includes a protected constructor, empty virtual destructor,
+ * and Unicode constants for the default associated element's name and prefix.
+ *
+ * @param linkage linkage specifier for the class
+ * @param cname the name of the class to declare
+ * @param base the first base class to derive from using public virtual inheritance
+ * @param base2 the second base class to derive from using public virtual inheritance
+ * @param desc documentation comment for class
+ */
+#define BEGIN_XMLOBJECT2(linkage,cname,base,base2,desc) \
+ XMLTOOLING_DOXYGEN(desc) \
+ class linkage cname : public virtual base, public virtual base2, public virtual xmltooling::ValidatingXMLObject { \
+ protected: \
+ cname() {} \
+ public: \
+ virtual ~cname() {} \
+ XMLTOOLING_DOXYGEN(Type-specific clone method.) \
+ virtual cname* clone##cname() const=0; \
+ XMLTOOLING_DOXYGEN(Element local name) \
+ static const XMLCh LOCAL_NAME[]
+
+/**
* Ends the declaration of an XMLObject specialization.
*/
#define END_XMLOBJECT }
virtual void set##proper(int proper)=0
/**
+ * Declares abstract get/set methods for a boolean XML attribute.
+ *
+ * @param proper the proper name of the attribute
+ * @param upcased the upcased name of the attribute
+ */
+#define DECL_BOOLEAN_ATTRIB(proper,upcased) \
+ public: \
+ XMLTOOLING_DOXYGEN(proper attribute name) \
+ static const XMLCh upcased##_ATTRIB_NAME[]; \
+ XMLTOOLING_DOXYGEN(Returns the proper attribute.) \
+ virtual bool proper() const=0; \
+ XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
+ virtual void proper(bool value)=0
+
+/**
* Implements get/set methods and a private member for a typed XML attribute.
*
* @param proper the proper name of the attribute
}
/**
+ * Implements get/set methods and a private member for a boolean XML attribute.
+ *
+ * @param proper the proper name of the attribute
+ */
+#define IMPL_BOOLEAN_ATTRIB(proper) \
+ protected: \
+ bool m_##proper; \
+ public: \
+ bool proper() const { \
+ return m_##proper; \
+ } \
+ void proper(bool value) { \
+ if (m_##proper != value) { \
+ releaseThisandParentDOM(); \
+ m_##proper = value; \
+ } \
+ }
+
+/**
* Declares abstract get/set methods for a typed XML child object in a foreign namespace.
*
* @param proper the proper name of the child type
virtual const std::vector<proper*>& get##proper##s() const=0
/**
+ * Declares abstract get/set methods for a typed XML child collection in a foreign namespace.
+ *
+ * @param proper the proper name of the child type
+ * @param ns the C++ namespace for the type
+ */
+#define DECL_TYPED_FOREIGN_CHILDREN(proper,ns) \
+ public: \
+ XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
+ virtual VectorOf(ns::proper) get##proper##s()=0; \
+ XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
+ virtual const std::vector<ns::proper*>& get##proper##s() const=0
+
+/**
* Declares abstract get/set methods for a generic XML child collection.
*
* @param proper the proper name of the child
domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, wide##proper.get())
/**
+ * Implements marshalling for a boolean attribute
+ *
+ * @param proper the proper name of the attribute
+ * @param ucase the upcased name of the attribute
+ * @param namespaceURI the XML namespace of the attribute
+ */
+#define MARSHALL_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
+ XMLCh flag##proper[2]; \
+ flag##proper[0]=m_##proper ? chDigit_1 : chDigit_0; \
+ flag##proper[1]=chNull; \
+ domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, flag##proper)
+
+/**
* Implements marshalling for a QName attribute
*
* @param proper the proper name of the attribute
return; \
}
+/**
+ * Implements unmarshalling process branch for a boolean attribute
+ *
+ * @param proper the proper name of the attribute
+ * @param ucase the upcased name of the attribute
+ * @param namespaceURI the XML namespace of the attribute
+ */
+#define PROC_BOOLEAN_ATTRIB(proper,ucase,namespaceURI) \
+ if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
+ const XMLCh* value=attribute->getValue(); \
+ if (value) { \
+ if (*value==chLatin_t || *value==chDigit_1) \
+ m_##proper=true; \
+ else if (*value==chLatin_f || *value==chDigit_0) \
+ m_##proper=false; \
+ } \
+ return; \
+ }
/**
* Implements unmarshalling process branch for typed child collection element
}
/**
+ * Declares aliased get/set methods for named integer XML element content.
+ *
+ * @param proper the proper name to label the element's content
+ */
+#define DECL_INTEGER_CONTENT(proper) \
+ XMLTOOLING_DOXYGEN(Returns proper.) \
+ int get##proper() const { \
+ return XMLString::parseInt(getTextContent()); \
+ } \
+ XMLTOOLING_DOXYGEN(Sets or clears proper.) \
+ void set##proper(int proper) { \
+ char buf[64]; \
+ sprintf(buf,"%d",proper); \
+ xmltooling::auto_ptr_XMLCh widebuf(buf); \
+ setTextContent(widebuf.get()); \
+ }
+
+/**
* Implements marshalling/unmarshalling for element content.
*/
#define IMPL_XMLOBJECT_CONTENT \
--- /dev/null
+/*
+ * Copyright 2001-2006 Internet2
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file Encryption.h
+ *
+ * XMLObjects representing XML Encryption content
+ */
+
+#ifndef __xmltooling_encrypt_h__
+#define __xmltooling_encrypt_h__
+
+#include <xmltooling/ElementProxy.h>
+#include <xmltooling/SimpleElement.h>
+#include <xmltooling/XMLObjectBuilder.h>
+#include <xmltooling/util/XMLConstants.h>
+#include <xmltooling/validation/ValidatingXMLObject.h>
+
+#define DECL_XMLENCOBJECTBUILDER(cname) \
+ DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmltooling::XMLConstants::XMLENC_NS,xmltooling::XMLConstants::XMLENC_PREFIX)
+
+/**
+ * @namespace xmlencryption
+ * Namespace for XML Encryption schema objects
+ */
+namespace xmlencryption {
+
+ DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,OAEPparams,Name,XML Encryption OAEPparams element);
+
+ BEGIN_XMLOBJECT(XMLTOOL_API,KeySize,xmltooling::SimpleElement,XML Encryption KeySize element);
+ DECL_INTEGER_CONTENT(Size);
+ END_XMLOBJECT;
+
+ BEGIN_XMLOBJECT(XMLTOOL_API,EncryptionMethod,xmltooling::XMLObject,XML Encryption EncryptionMethod element);
+ DECL_STRING_ATTRIB(Algorithm,ALGORITHM);
+ DECL_TYPED_CHILD(KeySize);
+ DECL_TYPED_CHILD(OAEPparams);
+ DECL_XMLOBJECT_CHILDREN(OtherParameter);
+ /** EncryptionMethodType local name */
+ static const XMLCh TYPE_NAME[];
+ END_XMLOBJECT;
+
+ DECL_XMLENCOBJECTBUILDER(OAEPparams);
+ DECL_XMLENCOBJECTBUILDER(KeySize);
+ DECL_XMLENCOBJECTBUILDER(EncryptionMethod);
+
+ /**
+ * Registers builders and validators for XML Encryption classes into the runtime.
+ */
+ void XMLTOOL_API registerEncryptionClasses();
+};
+
+#endif /* __xmltooling_encrypt_h__ */
--- /dev/null
+/*
+ * Copyright 2001-2006 Internet2
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * EncryptionImpl.cpp
+ *
+ * Implementation classes for XML Encryption schema
+ */
+
+#include "internal.h"
+#include "AbstractChildlessElement.h"
+#include "AbstractComplexElement.h"
+#include "AbstractSimpleElement.h"
+#include "exceptions.h"
+#include "encryption/Encryption.h"
+#include "io/AbstractXMLObjectMarshaller.h"
+#include "io/AbstractXMLObjectUnmarshaller.h"
+#include "util/XMLHelper.h"
+#include "validation/AbstractValidatingXMLObject.h"
+
+#include <xercesc/util/XMLUniDefs.hpp>
+
+using namespace xmlencryption;
+using namespace xmltooling;
+using namespace std;
+
+#if defined (_MSC_VER)
+ #pragma warning( push )
+ #pragma warning( disable : 4250 4251 )
+#endif
+
+namespace xmlencryption {
+
+ DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,KeySize);
+ DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,OAEPparams);
+
+ class XMLTOOL_DLLLOCAL EncryptionMethodImpl : public virtual EncryptionMethod,
+ public AbstractComplexElement,
+ public AbstractDOMCachingXMLObject,
+ public AbstractValidatingXMLObject,
+ public AbstractXMLObjectMarshaller,
+ public AbstractXMLObjectUnmarshaller
+ {
+ void init() {
+ m_Algorithm=NULL;
+ m_KeySize=NULL;
+ m_OAEPparams=NULL;
+ m_children.push_back(NULL);
+ m_children.push_back(NULL);
+ m_pos_KeySize=m_children.begin();
+ m_pos_OAEPparams=m_pos_KeySize;
+ ++m_pos_OAEPparams;
+ }
+ public:
+ virtual ~EncryptionMethodImpl() {
+ XMLString::release(&m_Algorithm);
+ }
+
+ EncryptionMethodImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
+ : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
+ init();
+ }
+
+ EncryptionMethodImpl(const EncryptionMethodImpl& src)
+ : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) {
+ init();
+ setAlgorithm(src.getAlgorithm());
+ if (src.getKeySize())
+ setKeySize(src.getKeySize()->cloneKeySize());
+ if (src.getOAEPparams())
+ setOAEPparams(src.getOAEPparams()->cloneOAEPparams());
+ VectorOf(XMLObject) v=getOtherParameters();
+ for (vector<XMLObject*>::const_iterator i=src.m_OtherParameters.begin(); i!=src.m_OtherParameters.end(); i++) {
+ if (*i) {
+ v.push_back((*i)->clone());
+ }
+ }
+ }
+
+ IMPL_XMLOBJECT_CLONE(EncryptionMethod);
+ IMPL_STRING_ATTRIB(Algorithm);
+ IMPL_TYPED_CHILD(KeySize);
+ IMPL_TYPED_CHILD(OAEPparams);
+ IMPL_XMLOBJECT_CHILDREN(OtherParameter,m_children.end());
+
+ protected:
+ void marshallAttributes(DOMElement* domElement) const {
+ MARSHALL_STRING_ATTRIB(Algorithm,ALGORITHM,NULL);
+ }
+
+ void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
+ PROC_TYPED_CHILD(KeySize,XMLConstants::XMLENC_NS,false);
+ PROC_TYPED_CHILD(OAEPparams,XMLConstants::XMLENC_NS,false);
+
+ // Unknown child.
+ const XMLCh* nsURI=root->getNamespaceURI();
+ if (!XMLString::equals(nsURI,XMLConstants::XMLENC_NS) && nsURI && *nsURI)
+ getOtherParameters().push_back(childXMLObject);
+
+ AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
+ }
+
+ void processAttribute(const DOMAttr* attribute) {
+ PROC_STRING_ATTRIB(Algorithm,ALGORITHM,NULL);
+ }
+ };
+
+};
+
+#if defined (_MSC_VER)
+ #pragma warning( pop )
+#endif
+
+// Builder Implementations
+
+IMPL_XMLOBJECTBUILDER(KeySize);
+IMPL_XMLOBJECTBUILDER(OAEPparams);
+IMPL_XMLOBJECTBUILDER(EncryptionMethod);
+
+// Unicode literals
+
+const XMLCh KeySize::LOCAL_NAME[] = UNICODE_LITERAL_7(K,e,y,S,i,z,e);
+const XMLCh OAEPparams::LOCAL_NAME[] = UNICODE_LITERAL_10(O,A,E,P,p,a,r,a,m,s);
+const XMLCh EncryptionMethod::LOCAL_NAME[] = UNICODE_LITERAL_16(E,n,c,r,y,p,t,i,o,n,M,e,t,h,o,d);
+const XMLCh EncryptionMethod::TYPE_NAME[] = UNICODE_LITERAL_20(E,n,c,r,y,p,t,i,o,n,M,e,t,h,o,d,T,y,p,e);
+const XMLCh EncryptionMethod::ALGORITHM_ATTRIB_NAME[] = UNICODE_LITERAL_9(A,l,g,o,r,i,t,h,m);
--- /dev/null
+/*
+* Copyright 2001-2006 Internet2
+ *
+* Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * EncryptionSchemaValidators.cpp
+ *
+ * Schema validators for XML Encryption schema
+ */
+
+#include "internal.h"
+#include "exceptions.h"
+#include "encryption/Encryption.h"
+
+using namespace xmlencryption;
+using namespace xmltooling;
+using namespace std;
+
+namespace xmlencryption {
+
+ XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,KeySize);
+ XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,OAEPparams);
+
+ BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,EncryptionMethod);
+ XMLOBJECTVALIDATOR_REQUIRE(EncryptionMethod,Algorithm);
+ END_XMLOBJECTVALIDATOR;
+
+};
+
+#define REGISTER_ELEMENT(namespaceURI,cname) \
+ q=QName(namespaceURI,cname::LOCAL_NAME); \
+ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
+ Validator::registerValidator(q,new cname##SchemaValidator())
+
+#define REGISTER_TYPE(namespaceURI,cname) \
+ q=QName(namespaceURI,cname::TYPE_NAME); \
+ XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
+ Validator::registerValidator(q,new cname##SchemaValidator())
+
+void xmlencryption::registerEncryptionClasses()
+{
+ QName q;
+ REGISTER_ELEMENT(XMLConstants::XMLENC_NS,KeySize);
+ REGISTER_ELEMENT(XMLConstants::XMLENC_NS,OAEPparams);
+ REGISTER_ELEMENT(XMLConstants::XMLENC_NS,EncryptionMethod);
+ REGISTER_TYPE(XMLConstants::XMLENC_NS,EncryptionMethod);
+}
#define __xmltooling_keyinfo_h__
#include <xmltooling/ElementProxy.h>
-#include <xmltooling/exceptions.h>
#include <xmltooling/SimpleElement.h>
#include <xmltooling/XMLObjectBuilder.h>
#include <xmltooling/util/XMLConstants.h>
</File>\r
</Filter>\r
</Filter>\r
+ <Filter\r
+ Name="encryption"\r
+ >\r
+ <Filter\r
+ Name="impl"\r
+ >\r
+ <File\r
+ RelativePath=".\encryption\impl\EncryptionImpl.cpp"\r
+ >\r
+ </File>\r
+ <File\r
+ RelativePath=".\encryption\impl\EncryptionSchemaValidators.cpp"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ </Filter>\r
</Filter>\r
<Filter\r
Name="Header Files"\r
>\r
</File>\r
</Filter>\r
+ <Filter\r
+ Name="encryption"\r
+ >\r
+ <File\r
+ RelativePath=".\encryption\Encryption.h"\r
+ >\r
+ </File>\r
+ </Filter>\r
</Filter>\r
<Filter\r
Name="Resource Files"\r