From: Scott Cantor Date: Thu, 4 May 2006 02:56:38 +0000 (+0000) Subject: Starting SAML 1.x implementation. X-Git-Tag: 2.0-alpha1~266 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=commitdiff_plain;h=01832f09c095512baad6210854ad3a3c6a8d9622 Starting SAML 1.x implementation. --- diff --git a/.cdtproject b/.cdtproject index d549fa9..e1951af 100644 --- a/.cdtproject +++ b/.cdtproject @@ -55,10 +55,15 @@ - + + + + + + diff --git a/.gitignore b/.gitignore index f786faa..d259f48 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,7 @@ /.*.swp /.DS_store # Simulated Subversion default ignores end here +# The contents of the svn:ignore property on the branch root. +/*.ncb +/*.suo +/debug diff --git a/saml/.gitignore b/saml/.gitignore new file mode 100644 index 0000000..994c81d --- /dev/null +++ b/saml/.gitignore @@ -0,0 +1,2 @@ +/Debug +/*.user diff --git a/saml/Makefile.am b/saml/Makefile.am index 145f099..a4afeb5 100644 --- a/saml/Makefile.am +++ b/saml/Makefile.am @@ -4,10 +4,10 @@ lib_LTLIBRARIES = libsaml.la libsamlincludedir = $(includedir)/saml -sigincludedir = $(includedir)/saml/signature - utilincludedir = $(includedir)/saml/util +saml1coreincludedir = $(includedir)/saml/saml1/core + libsamlinclude_HEADERS = \ base.h \ exceptions.h \ @@ -17,11 +17,15 @@ libsamlinclude_HEADERS = \ utilinclude_HEADERS = \ util/XMLConstants.h +saml1coreinclude_HEADERS = \ + saml1/core/Assertions.h + noinst_HEADERS = \ internal.h libsaml_la_SOURCES = \ SAMLConfig.cpp \ + saml1/core/impl/AssertionsImpl.cpp \ util/XMLConstants.cpp # this is different from the project version diff --git a/saml/SAMLConfig.cpp b/saml/SAMLConfig.cpp new file mode 100644 index 0000000..b36e9b0 --- /dev/null +++ b/saml/SAMLConfig.cpp @@ -0,0 +1,94 @@ +/* + * 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. + */ + +/** + * SAMLConfig.cpp + * + * Library configuration + */ + +#define SAML_DECLARE_VALIDATORS + +#include "internal.h" +#include "exceptions.h" +#include "SAMLConfig.h" +#include "saml1/core/Assertions.h" +#include "util/XMLConstants.h" + +#include +#include +#include + +using namespace opensaml::saml1; +using namespace opensaml; +using namespace xmltooling; +using namespace log4cpp; + +#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()) + + +//DECL_EXCEPTION_FACTORY(XMLParserException,xmltooling); + +namespace opensaml { + SAMLInternalConfig g_config; +} + +SAMLConfig& SAMLConfig::getConfig() +{ + return g_config; +} + +SAMLInternalConfig& SAMLInternalConfig::getInternalConfig() +{ + return g_config; +} + +bool SAMLInternalConfig::init() +{ +#ifdef _DEBUG + xmltooling::NDC ndc("init"); +#endif + Category& log=Category::getInstance(SAML_LOGCAT".SAMLConfig"); + log.debug("library initialization started"); + + XMLToolingConfig::getConfig().init(); + log.debug("XMLTooling library initialized"); + + QName q; + REGISTER_ELEMENT(XMLConstants::SAML1_NS,AssertionIDReference); + REGISTER_ELEMENT(XMLConstants::SAML1_NS,Audience); + REGISTER_ELEMENT(XMLConstants::SAML1_NS,ConfirmationMethod); + + log.info("library initialization complete"); + return true; +} + +void SAMLInternalConfig::term() +{ +#ifdef _DEBUG + xmltooling::NDC ndc("term"); +#endif + XMLToolingConfig::getConfig().term(); + Category::getInstance(SAML_LOGCAT".SAMLConfig").info("library shutdown complete"); +} diff --git a/saml/SAMLConfig.h b/saml/SAMLConfig.h index c8a00d6..ec74921 100644 --- a/saml/SAMLConfig.h +++ b/saml/SAMLConfig.h @@ -25,6 +25,10 @@ #include +/** + * @namespace opensaml + * Common classes for OpenSAML library + */ namespace opensaml { /** diff --git a/saml/exceptions.h b/saml/exceptions.h index 4aea899..2259d1a 100644 --- a/saml/exceptions.h +++ b/saml/exceptions.h @@ -23,6 +23,7 @@ #ifndef __saml_exceptions_h__ #define __saml_exceptions_h__ +#include #include namespace opensaml { diff --git a/saml/saml.vcproj b/saml/saml.vcproj index 0a3a162..39ccad3 100644 --- a/saml/saml.vcproj +++ b/saml/saml.vcproj @@ -62,7 +62,7 @@ /> + + @@ -189,6 +193,22 @@ > + + + + + + + + + + + + + + +#include +#include +#include +#include +#include + +#define DECL_SAML1OBJECTBUILDER(cname) \ + DECL_XMLOBJECTBUILDER(SAML_API,cname,opensaml::XMLConstants::SAML1_NS,opensaml::XMLConstants::SAML1_PREFIX) + +namespace opensaml { + + /** + * @namespace saml1 + * SAML 1.x class namespace + */ + namespace saml1 { + DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionIDReference,Reference,SAML 1.x AssertionIDReference element); + DECL_XMLOBJECT_SIMPLE(SAML_API,Audience,Uri,SAML 1.x Audience element); + DECL_XMLOBJECT_SIMPLE(SAML_API,ConfirmationMethod,Method,SAML 1.x ConfirmationMethod element); + + DECL_SAML1OBJECTBUILDER(AssertionIDReference); + DECL_SAML1OBJECTBUILDER(Audience); + DECL_SAML1OBJECTBUILDER(ConfirmationMethod); + +#ifdef SAML_DECLARE_VALIDATORS + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,AssertionIDReference); + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,Audience); + XMLOBJECTVALIDATOR_SIMPLE(SAML_DLLLOCAL,ConfirmationMethod); +#endif + }; +}; + +#endif /* __saml_assertions_h__ */ diff --git a/saml/saml1/core/impl/AssertionsImpl.cpp b/saml/saml1/core/impl/AssertionsImpl.cpp new file mode 100644 index 0000000..63e1b7d --- /dev/null +++ b/saml/saml1/core/impl/AssertionsImpl.cpp @@ -0,0 +1,74 @@ +/* +* 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. + */ + +/** + * AssertionsImpl.cpp + * + * Implementation classes for SAML 1.x Assertions schema + */ + +#include "internal.h" +#include "exceptions.h" +#include "saml1/core/Assertions.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace opensaml::saml1; +using namespace opensaml; +using namespace xmltooling; +using namespace std; + +#if defined (_MSC_VER) + #pragma warning( push ) + #pragma warning( disable : 4250 4251 ) +#endif + +namespace opensaml { + namespace saml1 { + + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,AssertionIDReference); + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,Audience); + DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,ConfirmationMethod); + + }; +}; + +#if defined (_MSC_VER) + #pragma warning( pop ) +#endif + +// Builder Implementations + +IMPL_XMLOBJECTBUILDER(AssertionIDReference); +IMPL_XMLOBJECTBUILDER(Audience); +IMPL_XMLOBJECTBUILDER(ConfirmationMethod); + +// Unicode literals +const XMLCh AssertionIDReference::LOCAL_NAME[] = UNICODE_LITERAL_20(A,s,s,e,r,t,i,o,n,I,D,R,e,f,e,r,e,n,c,e); +const XMLCh Audience::LOCAL_NAME[] = UNICODE_LITERAL_8(A,u,d,i,e,n,c,e); +const XMLCh ConfirmationMethod::LOCAL_NAME[] = UNICODE_LITERAL_18(C,o,n,f,i,r,m,a,t,i,o,n,M,e,t,h,o,d); + +#define XCH(ch) chLatin_##ch +#define XNUM(d) chDigit_##d