Add XMLEnc 1.1 constants and MGF supporting code
[shibboleth/cpp-xmltooling.git] / xmltooling / encryption / Encryption.h
index e5eda15..33c5e12 100644 (file)
@@ -1,33 +1,59 @@
-/*
- *  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
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
+ *
+ * UCAID licenses this file to you 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
+ * 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.
+ * 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
+ * @file xmltooling/encryption/Encryption.h
  * 
  * XMLObjects representing XML Encryption content
  */
 
-#ifndef __xmltooling_encryption_h__
+#if !defined(__xmltooling_encryption_h__) && !defined(XMLTOOLING_NO_XMLSEC)
 #define __xmltooling_encryption_h__
 
-#include <xmltooling/AttributeExtensibleXMLObject.h>
-#include <xmltooling/signature/KeyInfo.h>
+#include <xmltooling/ConcreteXMLObjectBuilder.h>
+#include <xmltooling/ElementProxy.h>
+#include <xmltooling/util/XMLConstants.h>
+
+#include <cstdio>
+#include <boost/lexical_cast.hpp>
+
+namespace xmlsignature {
+    class XMLTOOL_API KeyInfo;
+    class XMLTOOL_API Transform;
+};
 
+/**
+ * Macro for declaring encryption builders.
+ * 
+ * @param cname name of class being built
+ */
 #define DECL_XMLENCOBJECTBUILDER(cname) \
-    DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmltooling::XMLConstants::XMLENC_NS,xmltooling::XMLConstants::XMLENC_PREFIX)
+    DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmlconstants::XMLENC_NS,xmlconstants::XMLENC_PREFIX)
+
+/**
+ * Macro for declaring encryption 1.1 builders.
+ * 
+ * @param cname name of class being built
+ */
+#define DECL_XMLENC11OBJECTBUILDER(cname) \
+    DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmlconstants::XMLENC11_NS,xmlconstants::XMLENC11_PREFIX)
 
 /**
  * @namespace xmlencryption
@@ -39,15 +65,14 @@ namespace xmlencryption {
     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,CipherValue,Value,XML Encryption CipherValue element);
     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,OAEPparams,Name,XML Encryption OAEPparams element);
 
-    BEGIN_XMLOBJECT(XMLTOOL_API,KeySize,xmltooling::SimpleElement,XML Encryption KeySize element);
+    BEGIN_XMLOBJECT(XMLTOOL_API,KeySize,xmltooling::XMLObject,XML Encryption KeySize element);
         DECL_INTEGER_CONTENT(Size);
     END_XMLOBJECT;
 
-    BEGIN_XMLOBJECT(XMLTOOL_API,EncryptionMethod,xmltooling::XMLObject,XML Encryption EncryptionMethod element);
+    BEGIN_XMLOBJECT(XMLTOOL_API,EncryptionMethod,xmltooling::ElementExtensibleXMLObject,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;
@@ -72,7 +97,7 @@ namespace xmlencryption {
         static const XMLCh TYPE_NAME[];
     END_XMLOBJECT;
 
-    BEGIN_XMLOBJECT2(XMLTOOL_API,EncryptionProperty,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,XML Encryption EncryptionProperty element);
+    BEGIN_XMLOBJECT(XMLTOOL_API,EncryptionProperty,xmltooling::ElementProxy,XML Encryption EncryptionProperty element);
         DECL_STRING_ATTRIB(Target,TARGET);
         DECL_STRING_ATTRIB(Id,ID);
         /** EncryptionPropertyType local name */
@@ -86,7 +111,7 @@ namespace xmlencryption {
         static const XMLCh TYPE_NAME[];
     END_XMLOBJECT;
 
-    BEGIN_XMLOBJECT(XMLTOOL_API,ReferenceType,xmltooling::ElementProxy,XML Encryption ReferenceType type);
+    BEGIN_XMLOBJECT(XMLTOOL_API,ReferenceType,xmltooling::ElementExtensibleXMLObject,XML Encryption ReferenceType type);
         DECL_STRING_ATTRIB(URI,URI);
         /** ReferenceType local name */
         static const XMLCh TYPE_NAME[];
@@ -129,6 +154,12 @@ namespace xmlencryption {
         static const XMLCh TYPE_NAME[];
     END_XMLOBJECT;
 
+    BEGIN_XMLOBJECT(XMLTOOL_API,MGF,xmltooling::XMLObject,XML Encryption 1.1 MGF element);
+        DECL_STRING_ATTRIB(Algorithm,ALGORITHM);
+        /** MGFType local name */
+        static const XMLCh TYPE_NAME[];
+    END_XMLOBJECT;
+
     DECL_XMLENCOBJECTBUILDER(CarriedKeyName);
     DECL_XMLENCOBJECTBUILDER(CipherData);
     DECL_XMLENCOBJECTBUILDER(CipherReference);
@@ -145,15 +176,12 @@ namespace xmlencryption {
     DECL_XMLENCOBJECTBUILDER(ReferenceList);
     DECL_XMLENCOBJECTBUILDER(Transforms);
 
+    DECL_XMLENC11OBJECTBUILDER(MGF);
+
     /**
      * Registers builders and validators for XML Encryption classes into the runtime.
      */
     void XMLTOOL_API registerEncryptionClasses();
-
-    /**
-     * Validator suite for XML Encryption schema validation.
-     */
-    extern XMLTOOL_API xmltooling::ValidatorSuite EncryptionSchemaValidators;
 };
 
 #endif /* __xmltooling_encryption_h__ */