X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=saml%2Fsaml2%2Fcore%2FAssertions.h;h=94f4c53c574557d8c88be0df0a672de13ab4a66f;hb=5697d9abd4e6d149bbc6153acde26c3f0a5d4859;hp=a5a7fb7b2eca0a1acb4542ccf71ccfd439b90ce8;hpb=88fd73c5c117f708f09171375ae1890cb86bab8b;p=shibboleth%2Fcpp-opensaml.git diff --git a/saml/saml2/core/Assertions.h b/saml/saml2/core/Assertions.h index a5a7fb7..94f4c53 100644 --- a/saml/saml2/core/Assertions.h +++ b/saml/saml2/core/Assertions.h @@ -1,6 +1,6 @@ /* - * Copyright 2001-2007 Internet2 - * + * Copyright 2001-2009 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 @@ -16,8 +16,8 @@ /** * @file saml/saml2/core/Assertions.h - * - * XMLObjects representing the SAML 2.0 Assertions schema + * + * XMLObjects representing the SAML 2.0 Assertions schema. */ #ifndef __saml2_assertions_h__ @@ -26,16 +26,28 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include #define DECL_SAML2OBJECTBUILDER(cname) \ DECL_XMLOBJECTBUILDER(SAML_API,cname,samlconstants::SAML20_NS,samlconstants::SAML20_PREFIX) +namespace xmltooling { + class XMLTOOL_API CredentialCriteria; + class XMLTOOL_API CredentialResolver; + class XMLTOOL_API DateTime; +}; + +namespace xmlencryption { + class XMLTOOL_API EncryptedData; + class XMLTOOL_API EncryptedKey; +}; + +namespace xmlsignature { + class XMLTOOL_API KeyInfo; + class XMLTOOL_API Signature; +}; + namespace opensaml { namespace saml2md { @@ -48,7 +60,7 @@ namespace opensaml { * SAML 2.0 assertion namespace */ namespace saml2 { - + // Forward references class SAML_API Assertion; class SAML_API EncryptedAssertion; @@ -62,7 +74,7 @@ namespace opensaml { EncryptableObject() {} virtual ~EncryptableObject() {} }; - + DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionIDRef,AssertionID,SAML 2.0 AssertionIDRef element); DECL_XMLOBJECT_SIMPLE(SAML_API,AssertionURIRef,AssertionURI,SAML 2.0 AssertionURIRef element); DECL_XMLOBJECT_SIMPLE(SAML_API,Audience,AudienceURI,SAML 2.0 Audience element); @@ -75,10 +87,10 @@ namespace opensaml { DECL_TYPED_FOREIGN_CHILDREN(EncryptedKey,xmlencryption); /** EncryptedElementType local name */ static const XMLCh TYPE_NAME[]; - + /** * Encrypts an object to a single recipient using this object as a container. - * + * * @param xmlObject object to encrypt * @param metadataProvider a locked MetadataProvider to supply encryption keys * @param criteria metadata-based CredentialCriteria to use @@ -96,7 +108,8 @@ namespace opensaml { /** * Encrypts an object to multiple recipients using this object as a container. - * + * + * @param xmlObject object to encrypt * @param recipients pairs containing a locked MetadataProvider to supply encryption keys, * and a metadata-based CredentialCriteria to use * @param compact true iff compact KeyInfo should be used @@ -115,7 +128,7 @@ namespace opensaml { * *

The object returned will be unmarshalled around the decrypted DOM element in a * new Document owned by the object. - * + * * @param credResolver locked resolver supplying decryption keys * @param recipient identifier naming the recipient (the entity performing the decryption) * @param criteria optional external criteria to use with resolver @@ -168,7 +181,7 @@ namespace opensaml { BEGIN_XMLOBJECT(SAML_API,Condition,xmltooling::XMLObject,SAML 2.0 Condition element); END_XMLOBJECT; - + BEGIN_XMLOBJECT(SAML_API,AudienceRestriction,Condition,SAML 2.0 AudienceRestriction element); DECL_TYPED_CHILDREN(Audience); /** AudienceRestrictionType local name */ @@ -187,6 +200,22 @@ namespace opensaml { static const XMLCh TYPE_NAME[]; END_XMLOBJECT; + BEGIN_XMLOBJECT(SAML_API,Delegate,xmltooling::XMLObject,SAML 2.0 Delegation Restriction Condition Delegate element); + DECL_STRING_ATTRIB(ConfirmationMethod,CONFIRMATIONMETHOD); + DECL_DATETIME_ATTRIB(DelegationInstant,DELEGATIONINSTANT); + DECL_TYPED_CHILD(BaseID); + DECL_TYPED_CHILD(NameID); + DECL_TYPED_CHILD(EncryptedID); + /** DelegateType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(SAML_API,DelegationRestrictionType,Condition,SAML 2.0 Delegation Restriction Condition type); + DECL_TYPED_CHILDREN(Delegate); + /** DelegationRestrictionType local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + BEGIN_XMLOBJECT(SAML_API,Conditions,xmltooling::XMLObject,SAML 2.0 Conditions element); DECL_DATETIME_ATTRIB(NotBefore,NOTBEFORE); DECL_DATETIME_ATTRIB(NotOnOrAfter,NOTONORAFTER); @@ -215,7 +244,7 @@ namespace opensaml { /** KeyInfoConfirmationDataType local name */ static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - + BEGIN_XMLOBJECT(SAML_API,SubjectConfirmation,xmltooling::XMLObject,SAML 2.0 SubjectConfirmation element); DECL_STRING_ATTRIB(Method,METHOD); DECL_TYPED_CHILD(BaseID); @@ -361,10 +390,10 @@ namespace opensaml { RootObject() {} public: virtual ~RootObject() {} - + /** Gets the Version attribute. */ virtual const XMLCh* getVersion() const=0; - + /** Gets the Issuer. */ virtual Issuer* getIssuer() const=0; }; @@ -415,10 +444,12 @@ namespace opensaml { DECL_SAML2OBJECTBUILDER(SubjectConfirmation); DECL_SAML2OBJECTBUILDER(SubjectConfirmationData); DECL_SAML2OBJECTBUILDER(SubjectLocality); - + + DECL_XMLOBJECTBUILDER(SAML_API,Delegate,samlconstants::SAML20_DELEGATION_CONDITION_NS,samlconstants::SAML20_DELEGATION_CONDITION_PREFIX); + /** * Builder for NameIDType objects. - * + * * This is customized to force the element name to be specified. */ class SAML_API NameIDTypeBuilder : public xmltooling::XMLObjectBuilder { @@ -432,7 +463,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static NameIDType* buildNameIDType(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL) { const NameIDTypeBuilder* b = dynamic_cast( @@ -451,12 +482,95 @@ namespace opensaml { }; /** + * Builder for Condition extension objects. + * + * This is customized to force the schema type to be specified. + */ + class SAML_API ConditionBuilder : public xmltooling::XMLObjectBuilder { + public: + virtual ~ConditionBuilder() {} + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual Condition* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + ) const; + + /** Singleton builder. */ + static Condition* buildCondition(const xmltooling::QName& schemaType) { + const ConditionBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20_NS,Condition::LOCAL_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(samlconstants::SAML20_NS, Condition::LOCAL_NAME, samlconstants::SAML20_PREFIX, &schemaType); +#else + return dynamic_cast(b->buildObject(samlconstants::SAML20_NS, Condition::LOCAL_NAME, samlconstants::SAML20_PREFIX, &schemaType)); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for Condition."); + } + }; + + /** + * Builder for DelegationRestrictionType objects. + * + * This is customized to return a Condition element with an xsi:type of DelegationRestrictionType. + */ + class SAML_API DelegationRestrictionTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder { + public: + virtual ~DelegationRestrictionTypeBuilder() {} + /** Default builder. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual DelegationRestrictionType* buildObject() const { +#else + virtual xmltooling::XMLObject* buildObject() const { +#endif + xmltooling::QName schemaType( + samlconstants::SAML20_DELEGATION_CONDITION_NS, + DelegationRestrictionType::TYPE_NAME, + samlconstants::SAML20_DELEGATION_CONDITION_PREFIX + ); + return buildObject( + samlconstants::SAML20_DELEGATION_CONDITION_NS, + DelegationRestrictionType::LOCAL_NAME, + samlconstants::SAML20_DELEGATION_CONDITION_PREFIX, + &schemaType + ); + } + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual DelegationRestrictionType* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + ) const; + + /** Singleton builder. */ + static DelegationRestrictionType* buildDelegationRestrictionType() { + const DelegationRestrictionTypeBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20_DELEGATION_CONDITION_NS,DelegationRestrictionType::TYPE_NAME)) + ); + if (b) +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(); +#else + return dynamic_cast(b->buildObject()); +#endif + throw xmltooling::XMLObjectException("Unable to obtain typed builder for DelegationRestrictionType."); + } + }; + + /** * Builder for KeyInfoConfirmationDataType objects. - * + * * This is customized to return a SubjectConfirmationData element with an * xsi:type of KeyInfoConfirmationDataType. */ - class SAML_API KeyInfoConfirmationDataTypeBuilder : public xmltooling::XMLObjectBuilder { + class SAML_API KeyInfoConfirmationDataTypeBuilder : public xmltooling::ConcreteXMLObjectBuilder { public: virtual ~KeyInfoConfirmationDataTypeBuilder() {} /** Default builder. */ @@ -480,7 +594,7 @@ namespace opensaml { #endif const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL ) const; - + /** Singleton builder. */ static KeyInfoConfirmationDataType* buildKeyInfoConfirmationDataType() { const KeyInfoConfirmationDataTypeBuilder* b = dynamic_cast( @@ -497,6 +611,39 @@ namespace opensaml { }; /** + * Builder for Statement extension objects. + * + * This is customized to force the schema type to be specified. + */ + class SAML_API StatementBuilder : public xmltooling::XMLObjectBuilder { + public: + virtual ~StatementBuilder() {} + /** Builder that allows element/type override. */ +#ifdef HAVE_COVARIANT_RETURNS + virtual Statement* buildObject( +#else + virtual xmltooling::XMLObject* buildObject( +#endif + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL + ) const; + + /** Singleton builder. */ + static Statement* buildStatement(const xmltooling::QName& schemaType) { + const StatementBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(xmltooling::QName(samlconstants::SAML20_NS,Statement::LOCAL_NAME)) + ); + if (b) { +#ifdef HAVE_COVARIANT_RETURNS + return b->buildObject(samlconstants::SAML20_NS, Statement::LOCAL_NAME, samlconstants::SAML20_PREFIX, &schemaType); +#else + return dynamic_cast(b->buildObject(samlconstants::SAML20_NS, Statement::LOCAL_NAME, samlconstants::SAML20_PREFIX, &schemaType)); +#endif + } + throw xmltooling::XMLObjectException("Unable to obtain typed builder for Statement."); + } + }; + + /** * Registers builders and validators for SAML 2.0 Assertion classes into the runtime. */ void SAML_API registerAssertionClasses();