You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2004/08/06 13:41:13 UTC

cvs commit: xml-security/c/src/xkms/impl XKMSResponseMechanismImpl.cpp XKMSResponseMechanismImpl.hpp XKMSLocateRequestImpl.hpp XKMSMessageAbstractTypeImpl.cpp XKMSMessageAbstractTypeImpl.hpp XKMSMessageFactoryImpl.cpp XKMSMessageFactoryImpl.hpp XKMSRequestAbstractTypeImpl.cpp XKMSRequestAbstractTypeImpl.hpp XKMSValidateRequestImpl.hpp

blautenb    2004/08/06 04:41:13

  Modified:    c/Projects/VC6.0/xsec/xsec_lib xsec_lib.dsp
               c/src/tools/xklient xklient.cpp
               c/src/xkms XKMSConstants.cpp XKMSConstants.hpp
                        XKMSMessageAbstractType.hpp
                        XKMSRequestAbstractType.hpp
               c/src/xkms/impl XKMSLocateRequestImpl.hpp
                        XKMSMessageAbstractTypeImpl.cpp
                        XKMSMessageAbstractTypeImpl.hpp
                        XKMSMessageFactoryImpl.cpp
                        XKMSMessageFactoryImpl.hpp
                        XKMSRequestAbstractTypeImpl.cpp
                        XKMSRequestAbstractTypeImpl.hpp
                        XKMSValidateRequestImpl.hpp
  Added:       c/src/xkms XKMSResponseMechanism.hpp
               c/src/xkms/impl XKMSResponseMechanismImpl.cpp
                        XKMSResponseMechanismImpl.hpp
  Log:
  Implement ResponseMechanism
  
  Revision  Changes    Path
  1.35      +12 -0     xml-security/c/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp
  
  Index: xsec_lib.dsp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/Projects/VC6.0/xsec/xsec_lib/xsec_lib.dsp,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- xsec_lib.dsp	11 Jul 2004 12:08:12 -0000	1.34
  +++ xsec_lib.dsp	6 Aug 2004 11:41:12 -0000	1.35
  @@ -1253,6 +1253,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\..\..\..\src\xkms\XKMSResponseMechanism.hpp
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\..\..\..\src\xkms\XKMSResult.hpp
   # End Source File
   # Begin Source File
  @@ -1280,5 +1284,13 @@
   SOURCE=..\..\..\..\src\xkms\XKMSValidateResult.hpp
   # End Source File
   # End Group
  +# Begin Source File
  +
  +SOURCE=..\..\..\..\src\xkms\impl\XKMSResponseMechanismImpl.cpp
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=..\..\..\..\src\xkms\impl\XKMSResponseMechanismImpl.hpp
  +# End Source File
   # End Target
   # End Project
  
  
  
  1.13      +46 -4     xml-security/c/src/tools/xklient/xklient.cpp
  
  Index: xklient.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/tools/xklient/xklient.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- xklient.cpp	2 Aug 2004 11:09:05 -0000	1.12
  +++ xklient.cpp	6 Aug 2004 11:41:12 -0000	1.13
  @@ -354,7 +354,8 @@
   	cerr << "\nUsage LocateRequest [--help|-h] <service URI> [options]\n";
   	cerr << "   --help/-h                : print this screen and exit\n\n";
   	cerr << "   --add-cert/-a <filename> : add cert in filename as a KeyInfo\n";
  -	cerr << "   --add-name/-n <name>     : Add name as a KeyInfoName\n\n";
  +	cerr << "   --add-name/-n <name>     : Add name as a KeyInfoName\n";
  +	cerr << "   --add-opaque/-o <data>   : Add an opaque data string\n";
   	cerr << "   --add-usage-sig/-us      : Add Signature Key Usage\n";
   	cerr << "   --add-usage-exc/-ux      : Add Excange Key Usage\n";
   	cerr << "   --add-usage-enc/-ue      : Add Encryption Key Usage\n";
  @@ -362,6 +363,8 @@
   	cerr << "                            : Add a UseKeyWith element\n";
   	cerr << "   --add-respondwith/-r <Identifier>\n";
   	cerr << "                            : Add a RespondWith element\n";
  +	cerr << "   --add-responsemechanism/-m <Identifier>\n";
  +	cerr << "                            : Add a ResponseMechanism element\n";
   	cerr << "   --sign-dsa/-sd <filename> <passphrase>\n";
   	cerr << "           : Sign using the DSA key in file protected by passphrase\n\n";
   
  @@ -425,6 +428,15 @@
   			qkb->appendKeyName(MAKE_UNICODE_STRING(argv[paramCount]));
   			paramCount++;
   		}
  +		else if (stricmp(argv[paramCount], "--add-opaque") == 0 || stricmp(argv[paramCount], "-o") == 0) {
  +			if (++paramCount >= argc) {
  +				printLocateRequestUsage();
  +				delete lr;
  +				return NULL;
  +			}
  +			lr->appendOpaqueClientDataItem(MAKE_UNICODE_STRING(argv[paramCount]));
  +			paramCount++;
  +		}
   		else if (stricmp(argv[paramCount], "--add-usage-sig") == 0 || stricmp(argv[paramCount], "-us") == 0) {
   			XKMSQueryKeyBinding * qkb = lr->getQueryKeyBinding();
   			if (qkb == NULL)
  @@ -468,6 +480,15 @@
   			lr->appendRespondWithItem(MAKE_UNICODE_STRING(argv[paramCount]));
   			paramCount++;
   		}
  +		else if (stricmp(argv[paramCount], "--add-responsemechanism") == 0 || stricmp(argv[paramCount], "-m") == 0) {
  +			if (++paramCount >= argc) {
  +				printLocateRequestUsage();
  +				delete lr;
  +				return NULL;
  +			}
  +			lr->appendResponseMechanismItem(MAKE_UNICODE_STRING(argv[paramCount]));
  +			paramCount++;
  +		}
   #if defined (HAVE_OPENSSL)
   		else if (stricmp(argv[paramCount], "--sign-dsa") == 0 || stricmp(argv[paramCount], "-sd") == 0 ||
   				stricmp(argv[paramCount], "--sign-rsa") == 0 || stricmp(argv[paramCount], "-sr") == 0) {
  @@ -585,6 +606,7 @@
   	cerr << "   --help/-h                : print this screen and exit\n\n";
   	cerr << "   --add-cert/-a <filename> : add cert in filename as a KeyInfo\n";
   	cerr << "   --add-name/-n <name>     : Add name as a KeyInfoName\n";
  +	cerr << "   --add-opaque/-o <data>   : Add an opaque data string\n";
   	cerr << "   --add-usage-sig/-us      : Add Signature Key Usage\n";
   	cerr << "   --add-usage-exc/-ux      : Add Excange Key Usage\n";
   	cerr << "   --add-usage-enc/-ue      : Add Encryption Key Usage\n";
  @@ -592,6 +614,8 @@
   	cerr << "                            : Add a UseKeyWith element\n";
   	cerr << "   --add-respondwith/-r <Identifier>\n";
   	cerr << "                            : Add a RespondWith element\n";
  +	cerr << "   --add-responsemechanism/-m <Identifier>\n";
  +	cerr << "                            : Add a ResponseMechanism element\n";
   	cerr << "   --sign-dsa/-sd <filename> <passphrase>\n";
   	cerr << "           : Sign using the DSA key in file protected by passphrase\n\n";
   
  @@ -656,6 +680,15 @@
   			qkb->appendKeyName(MAKE_UNICODE_STRING(argv[paramCount]));
   			paramCount++;
   		}
  +		else if (stricmp(argv[paramCount], "--add-opaque") == 0 || stricmp(argv[paramCount], "-o") == 0) {
  +			if (++paramCount >= argc) {
  +				printValidateRequestUsage();
  +				delete vr;
  +				return NULL;
  +			}
  +			vr->appendOpaqueClientDataItem(MAKE_UNICODE_STRING(argv[paramCount]));
  +			paramCount++;
  +		}
   		else if (stricmp(argv[paramCount], "--add-respondwith") == 0 || stricmp(argv[paramCount], "-r") == 0) {
   			if (++paramCount >= argc) {
   				printValidateRequestUsage();
  @@ -665,6 +698,15 @@
   			vr->appendRespondWithItem(MAKE_UNICODE_STRING(argv[paramCount]));
   			paramCount++;
   		}
  +		else if (stricmp(argv[paramCount], "--add-responsemechanism") == 0 || stricmp(argv[paramCount], "-m") == 0) {
  +			if (++paramCount >= argc) {
  +				printLocateRequestUsage();
  +				delete vr;
  +				return NULL;
  +			}
  +			vr->appendResponseMechanismItem(MAKE_UNICODE_STRING(argv[paramCount]));
  +			paramCount++;
  +		}
   		else if (stricmp(argv[paramCount], "--add-usage-sig") == 0 || stricmp(argv[paramCount], "-us") == 0) {
   			XKMSQueryKeyBinding * qkb = vr->getQueryKeyBinding();
   			if (qkb == NULL)
  @@ -1366,7 +1408,7 @@
   			}
   
   			if (twoPhase)
  -				r->appendRespondWithItem(XKMSConstants::s_tagRepresent);
  +				r->appendResponseMechanismItem(XKMSConstants::s_tagRepresent);
   
   			msg = r;
   			parmsDone = true;
  @@ -1382,7 +1424,7 @@
   				return -1;
   			}
   			if (twoPhase)
  -				r->appendRespondWithItem(XKMSConstants::s_tagRepresent);
  +				r->appendResponseMechanismItem(XKMSConstants::s_tagRepresent);
   
   			msg = r;
   			parmsDone = true;
  
  
  
  1.7       +64 -1     xml-security/c/src/xkms/XKMSConstants.cpp
  
  Index: XKMSConstants.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/XKMSConstants.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XKMSConstants.cpp	24 Jul 2004 12:23:00 -0000	1.6
  +++ XKMSConstants.cpp	6 Aug 2004 11:41:12 -0000	1.7
  @@ -245,6 +245,42 @@
   	chNull
   };
   
  +const XMLCh XKMSConstants::s_tagOpaqueClientData[] = {
  +
  +	chLatin_O,
  +	chLatin_p,
  +	chLatin_a,
  +	chLatin_q,
  +	chLatin_u,
  +	chLatin_e,
  +	chLatin_C,
  +	chLatin_l,
  +	chLatin_i,
  +	chLatin_e,
  +	chLatin_n,
  +	chLatin_t,
  +	chLatin_D,
  +	chLatin_a,
  +	chLatin_t,
  +	chLatin_a,
  +	chNull
  +};
  +
  +const XMLCh XKMSConstants::s_tagOpaqueData[] = {
  +
  +	chLatin_O,
  +	chLatin_p,
  +	chLatin_a,
  +	chLatin_q,
  +	chLatin_u,
  +	chLatin_e,
  +	chLatin_D,
  +	chLatin_a,
  +	chLatin_t,
  +	chLatin_a,
  +	chNull
  +};
  +
   const XMLCh XKMSConstants::s_tagOriginalRequestId[] = {
   
   	chLatin_O,
  @@ -540,6 +576,33 @@
   	chLatin_a,
   	chLatin_s,
   	chLatin_o,
  +	chLatin_n,
  +	chNull
  +};
  +
  +const XMLCh XKMSConstants::s_tagX509Cert[] = {
  +
  +	chLatin_X,
  +	chDigit_5,
  +	chDigit_0,
  +	chDigit_9,
  +	chLatin_C,
  +	chLatin_e,
  +	chLatin_r,
  +	chLatin_t,
  +	chNull
  +};
  +
  +const XMLCh XKMSConstants::s_tagX509Chain[] = {
  +
  +	chLatin_X,
  +	chDigit_5,
  +	chDigit_0,
  +	chDigit_9,
  +	chLatin_C,
  +	chLatin_h,
  +	chLatin_a,
  +	chLatin_i,
   	chLatin_n,
   	chNull
   };
  
  
  
  1.9       +5 -1      xml-security/c/src/xkms/XKMSConstants.hpp
  
  Index: XKMSConstants.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/XKMSConstants.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XKMSConstants.hpp	2 Aug 2004 11:05:11 -0000	1.8
  +++ XKMSConstants.hpp	6 Aug 2004 11:41:12 -0000	1.9
  @@ -65,6 +65,8 @@
   	static const XMLCh s_tagLocateRequest[];
   	static const XMLCh s_tagLocateResult[];
   	static const XMLCh s_tagNonce[];
  +	static const XMLCh s_tagOpaqueClientData[];
  +	static const XMLCh s_tagOpaqueData[];
   	static const XMLCh s_tagOriginalRequestId[];
   	static const XMLCh s_tagQueryKeyBinding[];
   	static const XMLCh s_tagRepresent[];
  @@ -83,6 +85,8 @@
   	static const XMLCh s_tagValidateRequest[];
   	static const XMLCh s_tagValidateResult[];
   	static const XMLCh s_tagValidReason[];
  +	static const XMLCh s_tagX509Cert[];
  +	static const XMLCh s_tagX509Chain[];
   
   	// ResultMajor codes
   
  
  
  
  1.5       +37 -1     xml-security/c/src/xkms/XKMSMessageAbstractType.hpp
  
  Index: XKMSMessageAbstractType.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/XKMSMessageAbstractType.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XKMSMessageAbstractType.hpp	3 Jul 2004 12:44:59 -0000	1.4
  +++ XKMSMessageAbstractType.hpp	6 Aug 2004 11:41:12 -0000	1.5
  @@ -239,6 +239,42 @@
   
   	//@}
   
  +	/** @name Opaque client data handling */
  +	//@{
  +
  +	/**
  +	 * \brief Find the number of \<OpaqueData\> elements
  +	 *
  +	 * The \<OpaqueClientData\> element can have multiple
  +	 * \<OpaqueData\> children.  This method allows an application
  +	 * to determine how many such children exist
  +	 *
  +	 * @return Number of \<OpaqueData\> elements
  +	 */
  +
  +	virtual int getOpaqueClientDataSize(void) = 0;
  +
  +	/*
  +	 * \brief Get the nth item in the OpaqueClientData list
  +	 *
  +	 * @param item The item to return
  +	 * @returns the string of the nth item in the OpaqueClientData list.
  +	 *
  +	 */
  +
  +	virtual const XMLCh * getOpaqueClientDataItemStr(int item) = 0;
  +
  +	/*
  +	 * \brief Append an item to the OpaqueClientData list
  +	 *
  +	 * @param item Base64 string to append to the list.  Will be
  +	 * wrapped in a OpaqueData element.
  +	 */
  +
  +	virtual void appendOpaqueClientDataItem(const XMLCh * item) = 0;
  +
  +	//@}
  +
   private:
   
   	// Unimplemented
  
  
  
  1.2       +54 -1     xml-security/c/src/xkms/XKMSRequestAbstractType.hpp
  
  Index: XKMSRequestAbstractType.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/XKMSRequestAbstractType.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XKMSRequestAbstractType.hpp	16 Apr 2004 12:07:24 -0000	1.1
  +++ XKMSRequestAbstractType.hpp	6 Aug 2004 11:41:12 -0000	1.2
  @@ -32,6 +32,7 @@
   #include <xsec/xkms/XKMSMessageAbstractType.hpp>
   
   class XKMSRespondWith;
  +class XKMSResponseMechanism;
   
   /**
    * @ingroup xkms
  @@ -166,6 +167,58 @@
   	 */
   
   	virtual void appendRespondWithItem(const XMLCh * item) = 0;
  +
  +	//@}
  +
  +	/** @name \<ResponseMechanism\> handling */
  +	//@{
  +
  +	/* \brief Number of ResponseMechanism elements in this Request
  +	 *
  +	 * Returns the number of ResponseMechanism elements held within this request
  +	 *
  +	 * @returns Number of ResponseMechanism elements
  +	 */
  +
  +	virtual int getResponseMechanismSize(void) = 0;
  +
  +	/*
  +	 * \brief Get the nth item in the ResponseMechanism list
  +	 *
  +	 * @param item The item to return
  +	 * @returns the nth item in the ResponseMechanism list.
  +	 *
  +	 */
  +
  +	virtual XKMSResponseMechanism * getResponseMechanismItem(int item) = 0;
  +
  +	/*
  +	 * \brief Get the string of the nth item in the ResponseMechanism list
  +	 *
  +	 * @param item The item whose string is to be returned
  +	 * @returns the string of the nth item in the RespondWith list.
  +	 *
  +	 */
  +
  +	virtual const XMLCh * getResponseMechanismItemStr(int item) = 0;
  +
  +	/*
  +	 * \brief Append an item to the ResponseMechanism list
  +	 *
  +	 * @param item XKMSResponseMechanism object to append to the list.
  +	 * @note Once passed in, this item will be owned by the library.
  +	 */
  +
  +	virtual void appendResponseMechanismItem(XKMSResponseMechanism * item) = 0;
  +
  +	/*
  +	 * \brief Shortcut for appending an item to the ResponseMechanism list
  +	 *
  +	 * @param item String to create a ResponseMechanism element around and 
  +	 * append to the list.
  +	 */
  +
  +	virtual void appendResponseMechanismItem(const XMLCh * item) = 0;
   
   	//@}
   
  
  
  
  1.1                  xml-security/c/src/xkms/XKMSResponseMechanism.hpp
  
  Index: XKMSResponseMechanism.hpp
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * 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
   * imitations under the License.
   */
  
  /*
   * XSEC
   *
   * XKMSResponseMechanism:= Interface for ResponseMechanism elements
   *
   * $Id: XKMSResponseMechanism.hpp,v 1.1 2004/08/06 11:41:12 blautenb Exp $
   *
   */
  
  #ifndef XKMSRESPONSEMECHANISM_INCLUDE
  #define XKMSRESPONSEMECHANISM_INCLUDE
  
  // XSEC Includes
  
  #include <xsec/framework/XSECDefs.hpp>
  #include <xsec/xkms/XKMSMessageAbstractType.hpp>
  
  /**
   * @ingroup xkms
   * @{
   */
  
  /**
   * @brief Interface definition for the ResponseMechanism element
   *
   * The \<ResponseMechanism\> is a very simple element structure that
   * allows a requestor to pass extended protocol information
   *
   * The schema definition for ResponseMechanism is as follows :
   *
   * \verbatim
     <!-- ResponseMechanism -->
     <element name="ResponseMechanism" type="QName"/>
     <!-- /ResponseMechanism -->
  \endverbatim
   */
  
  
  class XKMSResponseMechanism {
  
  	/** @name Constructors and Destructors */
  	//@{
  
  protected:
  
  	XKMSResponseMechanism() {};
  
  public:
  
  	virtual ~XKMSResponseMechanism() {};
  
  	/** @name Getter Interface Methods */
  	//@{
  
  	/*
  	 * \brief Obtain the element at the head of this structure
  	 *
  	 * @returns the owning Element for this structure
  	 */
  
  	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) const = 0;
  
  	/**
  	 * \brief Get the ResponseMechanism string for this element
  	 *
  	 * Each ResponseMechanism element has a text node that defines the Key type to
  	 * be returned.
  	 *
  	 * @returns a pointer to the ResponseMechanism string for this element - note that the
  	 * xkms namespace part of the QName (if any) is stripped away.
  	 */
  
  	virtual const XMLCh * getResponseMechanismString(void) const = 0;
  
  	//@}
  
  	/** @name Setter interface methods */
  	//@{
  
  	/**
  	 * \brief Set the String within the ResponseMechanism element
  	 *
  	 * Allows a calling application to set a new ResponseMechanism string
  	 * 
  	 * @param str The string to set (overwriting any previous value).  Do not add
  	 * any local name part - this will be added by the library.
  	 * @note The library does not check that the string is a valid ResponseMechanism string.
  	 */
  
  	virtual void setResponseMechanismString(const XMLCh * str) = 0;
  
  	//@}
  
  
  private:
  
  	// Unimplemented
  	XKMSResponseMechanism(const XKMSResponseMechanism &);
  	XKMSResponseMechanism & operator = (const XKMSResponseMechanism &);
  
  };
  
  #endif /* XKMSRESPONSEMECHANISM_INCLUDE */
  
  
  
  1.4       +2 -15     xml-security/c/src/xkms/impl/XKMSLocateRequestImpl.hpp
  
  Index: XKMSLocateRequestImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSLocateRequestImpl.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XKMSLocateRequestImpl.hpp	9 Jun 2004 04:04:18 -0000	1.3
  +++ XKMSLocateRequestImpl.hpp	6 Aug 2004 11:41:12 -0000	1.4
  @@ -75,20 +75,7 @@
   	XKMS_MESSAGEABSTRACTYPE_IMPL_METHODS
   
   	/* Forced inheritance from RequestAbstractType */
  -	virtual const XMLCh * getOriginalRequestId(void) const
  -		{return XKMSRequestAbstractTypeImpl::getOriginalRequestId();}
  -	virtual void setOriginalRequestId(const XMLCh * id)
  -		{XKMSRequestAbstractTypeImpl::setOriginalRequestId(id);}
  -	virtual int getRespondWithSize(void)
  -		{return XKMSRequestAbstractTypeImpl::getRespondWithSize();}	
  -	virtual XKMSRespondWith * getRespondWithItem(int item)
  -		{return XKMSRequestAbstractTypeImpl::getRespondWithItem(item);}	
  -	virtual const XMLCh * getRespondWithItemStr(int item)
  -		{return XKMSRequestAbstractTypeImpl::getRespondWithItemStr(item);}	
  -	virtual void appendRespondWithItem(XKMSRespondWith * item)
  -		{XKMSRequestAbstractTypeImpl::appendRespondWithItem(item);}
  -	virtual void appendRespondWithItem(const XMLCh * item)
  -		{XKMSRequestAbstractTypeImpl::appendRespondWithItem(item);}
  +	XKMS_REQUESTABSTRACTYPE_IMPL_METHODS
   
   private:
   
  
  
  
  1.6       +102 -4    xml-security/c/src/xkms/impl/XKMSMessageAbstractTypeImpl.cpp
  
  Index: XKMSMessageAbstractTypeImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSMessageAbstractTypeImpl.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XKMSMessageAbstractTypeImpl.cpp	24 Jul 2004 12:23:01 -0000	1.5
  +++ XKMSMessageAbstractTypeImpl.cpp	6 Aug 2004 11:41:12 -0000	1.6
  @@ -52,8 +52,10 @@
   mp_serviceAttr(NULL),
   mp_nonceAttr(NULL),
   mp_signatureElement(NULL),
  -mp_signature(NULL) {
  +mp_signature(NULL),
  +mp_opaqueClientDataElement(NULL) {
   
  +	m_opaqueClientDataSize = 0;
   }
   
   XKMSMessageAbstractTypeImpl::XKMSMessageAbstractTypeImpl(
  @@ -66,8 +68,10 @@
   mp_serviceAttr(NULL),
   mp_nonceAttr(NULL),
   mp_signatureElement(NULL),
  -mp_signature(NULL) {
  +mp_signature(NULL),
  +mp_opaqueClientDataElement(NULL) {
   
  +	m_opaqueClientDataSize = 0;
   }
   
   XKMSMessageAbstractTypeImpl::~XKMSMessageAbstractTypeImpl() {
  @@ -115,7 +119,7 @@
   	}
   
   	// Check for <Signature> node
  -	DOMElement *mp_signatureElement = (DOMElement *) findFirstChildOfType(mp_messageAbstractTypeElement, DOMNode::ELEMENT_NODE);
  +	mp_signatureElement = (DOMElement *) findFirstChildOfType(mp_messageAbstractTypeElement, DOMNode::ELEMENT_NODE);
   
   	while (mp_signatureElement != NULL && 
   		!strEquals(getDSIGLocalName(mp_signatureElement), XKMSConstants::s_tagSignature)) {
  @@ -134,6 +138,37 @@
   
   	}
   
  +	// Cheque for OpaqueClientData
  +	mp_opaqueClientDataElement = (DOMElement *) findFirstChildOfType(mp_messageAbstractTypeElement, DOMNode::ELEMENT_NODE);
  +	while (mp_opaqueClientDataElement != NULL && 
  +		!strEquals(getXKMSLocalName(mp_opaqueClientDataElement), XKMSConstants::s_tagOpaqueClientData)) {
  +
  +		mp_opaqueClientDataElement = findNextElementChild(mp_opaqueClientDataElement);
  +
  +	}
  +
  +	if (mp_opaqueClientDataElement != NULL) {
  +
  +		DOMElement * c = findFirstElementChild(mp_opaqueClientDataElement);
  +		while (c != NULL) {
  +
  +			if (!strEquals(getXKMSLocalName(c), XKMSConstants::s_tagOpaqueData)) {
  +				throw XSECException(XSECException::ExpectedXKMSChildNotFound,
  +					"XKMSMessageAbstractType::load - Only <OpaqueData> children allowed for <OpaqueClientData>");
  +			}
  +
  +			if (findFirstChildOfType(c, DOMNode::TEXT_NODE) == NULL) {
  +				throw XSECException(XSECException::ExpectedXKMSChildNotFound,
  +					"XKMSMessageAbstractType::load - OpaqueData elements require a text child containing Base64 data");
  +			}
  +
  +			++m_opaqueClientDataSize;
  +
  +			c = findNextElementChild(c);
  +
  +		}
  +
  +	}
   }
   
   // --------------------------------------------------------------------------------
  @@ -329,3 +364,66 @@
   	return ret;
   }
   
  +// --------------------------------------------------------------------------------
  +//           Opaque Client Data interface
  +// --------------------------------------------------------------------------------
  +
  +int XKMSMessageAbstractTypeImpl::getOpaqueClientDataSize(void) {
  +
  +	return m_opaqueClientDataSize;
  +
  +}
  +const XMLCh * XKMSMessageAbstractTypeImpl::getOpaqueClientDataItemStr(int item) {
  +
  +	if (item < 0 || item > m_opaqueClientDataSize) {
  +
  +		throw XSECException(XSECException::MessageAbstractTypeError,
  +			"XKMSMessageAbstractType::getOpaqueClientDataItemStr - index out of range");
  +	}
  +
  +	DOMElement * c = findFirstElementChild(mp_opaqueClientDataElement);
  +	int i = 0;
  +
  +	while (i < item) {
  +
  +		c = findNextElementChild(c);
  +		if (c == NULL) {
  +			throw XSECException(XSECException::MessageAbstractTypeError,
  +				"XKMSMessageAbstractType::getOpaqueClientDataItemStr - index unexpectedly out of range");
  +		}
  +		++i;
  +	}
  +
  +	return findFirstChildOfType(c, DOMNode::TEXT_NODE)->getNodeValue();
  +
  +}
  +
  +void XKMSMessageAbstractTypeImpl::appendOpaqueClientDataItem(const XMLCh * item) {
  +
  +	safeBuffer str;
  +	DOMDocument *doc = mp_env->getParentDocument();
  +	const XMLCh * prefix = mp_env->getXKMSNSPrefix();
  +
  +	if (mp_opaqueClientDataElement == NULL) {
  +
  +		makeQName(str, prefix, XKMSConstants::s_tagOpaqueClientData);
  +
  +		mp_opaqueClientDataElement = doc->createElementNS(XKMSConstants::s_unicodeStrURIXKMS, 
  +												str.rawXMLChBuffer());
  +		mp_env->doPrettyPrint(mp_opaqueClientDataElement);
  +
  +		mp_messageAbstractTypeElement->appendChild(mp_opaqueClientDataElement);
  +		mp_env->doPrettyPrint(mp_messageAbstractTypeElement);
  +
  +	}
  +
  +	makeQName(str, prefix, XKMSConstants::s_tagOpaqueData);
  +	DOMElement * e = doc->createElementNS(XKMSConstants::s_unicodeStrURIXKMS,
  +									str.rawXMLChBuffer());
  +	e->appendChild(doc->createTextNode(item));
  +	mp_opaqueClientDataElement->appendChild(e);
  +	mp_env->doPrettyPrint(mp_opaqueClientDataElement);
  +
  +	m_opaqueClientDataSize++;
  +
  +}
  
  
  
  1.5       +17 -2     xml-security/c/src/xkms/impl/XKMSMessageAbstractTypeImpl.hpp
  
  Index: XKMSMessageAbstractTypeImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSMessageAbstractTypeImpl.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XKMSMessageAbstractTypeImpl.hpp	3 Jul 2004 08:49:51 -0000	1.4
  +++ XKMSMessageAbstractTypeImpl.hpp	6 Aug 2004 11:41:12 -0000	1.5
  @@ -88,6 +88,11 @@
   		signatureMethod	sm = SIGNATURE_DSA,
   		hashMethod hm = HASH_SHA1);
   
  +	/* Opaque Client Data interface */
  +	virtual int getOpaqueClientDataSize(void);
  +	virtual const XMLCh * getOpaqueClientDataItemStr(int item);
  +	virtual void appendOpaqueClientDataItem(const XMLCh * item);
  +
   protected:
   
   	const XSECEnv		* mp_env;		// NOTE: Owned by the base message class
  @@ -105,10 +110,14 @@
   						* mp_nonceAttr;
   	XERCES_CPP_NAMESPACE_QUALIFIER  DOMElement
   						* mp_signatureElement;
  +	XERCES_CPP_NAMESPACE_QUALIFIER  DOMElement
  +						* mp_opaqueClientDataElement;
   
   	XSECProvider		m_prov;
   	DSIGSignature		* mp_signature;
   
  +	int					m_opaqueClientDataSize;
  +
   	// Unimplemented
   	XKMSMessageAbstractTypeImpl(void);
   	XKMSMessageAbstractTypeImpl(const XKMSMessageAbstractTypeImpl &);
  @@ -140,6 +149,12 @@
   		canonicalizationMethod cm = CANON_C14N_NOC, \
   		signatureMethod	sm = SIGNATURE_DSA, \
   		hashMethod hm = HASH_SHA1) \
  -		{return XKMSMessageAbstractTypeImpl::addSignature(cm,sm,hm);}
  +		{return XKMSMessageAbstractTypeImpl::addSignature(cm,sm,hm);} \
  +	virtual int getOpaqueClientDataSize(void) \
  +		{return XKMSMessageAbstractTypeImpl::getOpaqueClientDataSize();} \
  +	virtual const XMLCh * getOpaqueClientDataItemStr(int item) \
  +		{return XKMSMessageAbstractTypeImpl::getOpaqueClientDataItemStr(item);} \
  +	virtual void appendOpaqueClientDataItem(const XMLCh * item) \
  +		{XKMSMessageAbstractTypeImpl::appendOpaqueClientDataItem(item);}
   
   #endif /* XKMSMESSAGEABSTRACTTYPEIMPL_INCLUDE */
  
  
  
  1.6       +27 -1     xml-security/c/src/xkms/impl/XKMSMessageFactoryImpl.cpp
  
  Index: XKMSMessageFactoryImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSMessageFactoryImpl.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XKMSMessageFactoryImpl.cpp	24 Jul 2004 12:23:01 -0000	1.5
  +++ XKMSMessageFactoryImpl.cpp	6 Aug 2004 11:41:13 -0000	1.6
  @@ -61,6 +61,22 @@
   };
   
   // --------------------------------------------------------------------------------
  +//			Internal methods
  +// --------------------------------------------------------------------------------
  +
  +void XKMSMessageFactoryImpl::copyRequestToResult(XKMSRequestAbstractType * req, 
  +												 XKMSResultType * res) {
  +
  +	/* Copy any Opaque Data */
  +
  +	int sz = req->getOpaqueClientDataSize();
  +	for (int i = 0; i < sz; ++i) {
  +		res->appendOpaqueClientDataItem(req->getOpaqueClientDataItemStr(i));
  +	}
  +
  +}
  +
  +// --------------------------------------------------------------------------------
   //			Set/get the namespace prefix to be used when creating nodes
   // --------------------------------------------------------------------------------
   
  @@ -263,6 +279,10 @@
   	return vri;
   }
   
  +// --------------------------------------------------------------------------------
  +//           Create a result based on a request
  +// --------------------------------------------------------------------------------
  +
   XKMSLocateResult * XKMSMessageFactoryImpl::createLocateResult(
   		XKMSLocateRequest * request,
   		XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc,
  @@ -279,6 +299,8 @@
   	XSECnew(lri, XKMSLocateResultImpl(tenv));
   	lri->createBlankLocateResult(request->getService(), id, rmaj, rmin);
   
  +	copyRequestToResult(request, (XKMSResultTypeImpl*) lri);
  +
   	return lri;
   
   }
  @@ -321,6 +343,8 @@
   	XSECnew(ri, XKMSResultImpl(tenv));
   	ri->createBlankResult(request->getService(), id, rmaj, rmin);
   
  +	copyRequestToResult(request, (XKMSResultTypeImpl*) ri);
  +
   	return ri;
   
   }
  @@ -362,6 +386,8 @@
   
   	XSECnew(vri, XKMSValidateResultImpl(tenv));
   	vri->createBlankValidateResult(request->getService(), id, rmaj, rmin);
  +
  +	copyRequestToResult(request, (XKMSResultTypeImpl*) vri);
   
   	return vri;
   
  
  
  
  1.7       +3 -1      xml-security/c/src/xkms/impl/XKMSMessageFactoryImpl.hpp
  
  Index: XKMSMessageFactoryImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSMessageFactoryImpl.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XKMSMessageFactoryImpl.hpp	24 Jul 2004 12:23:01 -0000	1.6
  +++ XKMSMessageFactoryImpl.hpp	6 Aug 2004 11:41:13 -0000	1.7
  @@ -119,6 +119,8 @@
   
   private:
   
  +	// Internal methods
  +	void copyRequestToResult(XKMSRequestAbstractType * req, XKMSResultType * res);
   	// Environment
   	XSECEnv					* mp_env;
   
  
  
  
  1.5       +100 -1    xml-security/c/src/xkms/impl/XKMSRequestAbstractTypeImpl.cpp
  
  Index: XKMSRequestAbstractTypeImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSRequestAbstractTypeImpl.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XKMSRequestAbstractTypeImpl.cpp	24 Jul 2004 12:23:01 -0000	1.4
  +++ XKMSRequestAbstractTypeImpl.cpp	6 Aug 2004 11:41:13 -0000	1.5
  @@ -35,6 +35,7 @@
   
   #include "XKMSRequestAbstractTypeImpl.hpp"
   #include "XKMSRespondWithImpl.hpp"
  +#include "XKMSResponseMechanismImpl.hpp"
   
   XERCES_CPP_NAMESPACE_USE
   
  @@ -65,6 +66,11 @@
   		delete (*i);
   	}
   
  +	ResponseMechanismVectorType::iterator j;
  +
  +	for (j = m_responseMechanismList.begin(); j < m_responseMechanismList.end(); ++j) {
  +		delete (*j);
  +	}
   };
   
   // --------------------------------------------------------------------------------
  @@ -99,6 +105,24 @@
   
   	}
   
  +	// Get any ResponseMechanism elements
  +	nl = mp_messageAbstractTypeElement->getElementsByTagNameNS(
  +		XKMSConstants::s_unicodeStrURIXKMS,
  +		XKMSConstants::s_tagResponseMechanism);
  +
  +	if (nl != NULL) {
  +
  +		XKMSResponseMechanismImpl * rm;
  +		for (int i = 0; i < nl->getLength() ; ++ i) {
  +
  +			XSECnew(rm, XKMSResponseMechanismImpl(mp_env, (DOMElement *) nl->item(i)));
  +			rm->load();
  +			m_responseMechanismList.push_back(rm);
  +
  +		}
  +
  +	}
  +
   	mp_originalRequestIdAttr = 
   		mp_messageAbstractTypeElement->getAttributeNodeNS(NULL, XKMSConstants::s_tagOriginalRequestId);
   
  @@ -218,6 +242,81 @@
   
   	// Add to the list
   	m_respondWithList.push_back(rw);
  +
  +}
  +
  +
  +// --------------------------------------------------------------------------------
  +//           ResponseMechanism handling
  +// --------------------------------------------------------------------------------
  +
  +int XKMSRequestAbstractTypeImpl::getResponseMechanismSize(void) {
  +
  +	return m_responseMechanismList.size();
  +
  +}
  +
  +XKMSResponseMechanism * XKMSRequestAbstractTypeImpl::getResponseMechanismItem(int item) {
  +
  +	if (item < 0 || item >= m_responseMechanismList.size()) {
  +
  +		throw XSECException(XSECException::RequestAbstractTypeError,
  +			"XKMSRequestAbstractTypeImpl::getResponseMechanismItem - item out of range");
  +
  +	}
  +
  +	return m_responseMechanismList[item];
  +
  +}
  +
  +const XMLCh * XKMSRequestAbstractTypeImpl::getResponseMechanismItemStr(int item) {
  +
  +	if (item < 0 || item >= m_responseMechanismList.size()) {
  +
  +		throw XSECException(XSECException::RequestAbstractTypeError,
  +			"XKMSRequestAbstractTypeImpl::getResponseMechanismItem - item out of range");
  +
  +	}
  +
  +	return m_responseMechanismList[item]->getResponseMechanismString();
  +
  +}
  +
  +void XKMSRequestAbstractTypeImpl::appendResponseMechanismItem(XKMSResponseMechanism * item) {
  +
  +}
  +
  +void XKMSRequestAbstractTypeImpl::appendResponseMechanismItem(const XMLCh * item) {
  +
  +	XKMSResponseMechanismImpl * rw;
  +	XSECnew(rw, XKMSResponseMechanismImpl(mp_env));
  +
  +	// Create the ResponseMechanism object
  +	DOMElement * elt = rw->createBlankResponseMechanism(item);
  +
  +	// Add to the item
  +	DOMElement * c = findFirstElementChild(mp_messageAbstractTypeElement);
  +	while (c != NULL) {
  +
  +		if (!strEquals(getXKMSLocalName(c), XKMSConstants::s_tagResponseMechanism))
  +			break;
  +
  +	}
  +
  +	if (c != NULL) {
  +		mp_messageAbstractTypeElement->insertBefore(elt, c);
  +		if (mp_env->getPrettyPrintFlag()) {
  +			mp_messageAbstractTypeElement->insertBefore(
  +				mp_env->getParentDocument()->createTextNode(DSIGConstants::s_unicodeStrNL), c);
  +		}
  +	}
  +	else {
  +		mp_messageAbstractTypeElement->appendChild(elt);
  +		mp_env->doPrettyPrint(mp_messageAbstractTypeElement);
  +	}
  +
  +	// Add to the list
  +	m_responseMechanismList.push_back(rw);
   
   }
   
  
  
  
  1.5       +43 -1     xml-security/c/src/xkms/impl/XKMSRequestAbstractTypeImpl.hpp
  
  Index: XKMSRequestAbstractTypeImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSRequestAbstractTypeImpl.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XKMSRequestAbstractTypeImpl.hpp	24 Jul 2004 12:23:01 -0000	1.4
  +++ XKMSRequestAbstractTypeImpl.hpp	6 Aug 2004 11:41:13 -0000	1.5
  @@ -36,6 +36,7 @@
   #include <vector>
   
   class XKMSRespondWithImpl;
  +class XKMSResponseMechanismImpl;
   
   class XKMSRequestAbstractTypeImpl : virtual public XKMSRequestAbstractType, public XKMSMessageAbstractTypeImpl {
   
  @@ -74,6 +75,14 @@
   	virtual void appendRespondWithItem(XKMSRespondWith * item);
   	virtual void appendRespondWithItem(const XMLCh * item);
   
  +	/* ResponseMechanism handling */
  +	virtual int getResponseMechanismSize(void);
  +	virtual XKMSResponseMechanism * getResponseMechanismItem(int item);
  +	virtual const XMLCh * getResponseMechanismItemStr(int item);
  +	virtual void appendResponseMechanismItem(XKMSResponseMechanism * item);
  +	virtual void appendResponseMechanismItem(const XMLCh * item);
  +
  +
   	/* Inherited from XKMSMessageType */
   	virtual messageType getMessageType(void) = 0;
   
  @@ -109,7 +118,14 @@
   	typedef std::vector<XKMSRespondWithImpl *>	RespondWithVectorType;
   #endif
   
  +#if defined(XSEC_NO_NAMESPACES)
  +	typedef vector<XKMSResponseMechanismImpl *>		ResponseMechanismVectorType;
  +#else
  +	typedef std::vector<XKMSResponseMechanismImpl *>	ResponseMechanismVectorType;
  +#endif
  +
   	RespondWithVectorType		m_respondWithList;		// List of m_respondWith elements
  +	ResponseMechanismVectorType	m_responseMechanismList;// List of responseMechanism elements
   
   	XERCES_CPP_NAMESPACE_QUALIFIER  DOMAttr
   						* mp_originalRequestIdAttr;
  @@ -120,5 +136,31 @@
   	XKMSRequestAbstractTypeImpl & operator = (const XKMSRequestAbstractTypeImpl &);
   
   };
  +
  +#define	XKMS_REQUESTABSTRACTYPE_IMPL_METHODS \
  +	virtual const XMLCh * getOriginalRequestId(void) const \
  +		{return XKMSRequestAbstractTypeImpl::getOriginalRequestId();} \
  +	virtual void setOriginalRequestId(const XMLCh * id) \
  +		{XKMSRequestAbstractTypeImpl::setOriginalRequestId(id);} \
  +	virtual int getRespondWithSize(void) \
  +		{return XKMSRequestAbstractTypeImpl::getRespondWithSize();}	\
  +	virtual XKMSRespondWith * getRespondWithItem(int item) \
  +		{return XKMSRequestAbstractTypeImpl::getRespondWithItem(item);}	\
  +	virtual const XMLCh * getRespondWithItemStr(int item) \
  +		{return XKMSRequestAbstractTypeImpl::getRespondWithItemStr(item);}	\
  +	virtual void appendRespondWithItem(XKMSRespondWith * item) \
  +		{XKMSRequestAbstractTypeImpl::appendRespondWithItem(item);} \
  +	virtual void appendRespondWithItem(const XMLCh * item) \
  +		{XKMSRequestAbstractTypeImpl::appendRespondWithItem(item);} \
  +	virtual int getResponseMechanismSize(void) \
  +		{return XKMSRequestAbstractTypeImpl::getResponseMechanismSize();}	\
  +	virtual XKMSResponseMechanism * getResponseMechanismItem(int item) \
  +		{return XKMSRequestAbstractTypeImpl::getResponseMechanismItem(item);}	\
  +	virtual const XMLCh * getResponseMechanismItemStr(int item) \
  +		{return XKMSRequestAbstractTypeImpl::getResponseMechanismItemStr(item);}	\
  +	virtual void appendResponseMechanismItem(XKMSResponseMechanism * item) \
  +		{XKMSRequestAbstractTypeImpl::appendResponseMechanismItem(item);} \
  +	virtual void appendResponseMechanismItem(const XMLCh * item) \
  +		{XKMSRequestAbstractTypeImpl::appendResponseMechanismItem(item);}
   
   #endif /* XKMSREQUESTABSTRACTTYPEIMPL_INCLUDE */
  
  
  
  1.2       +2 -15     xml-security/c/src/xkms/impl/XKMSValidateRequestImpl.hpp
  
  Index: XKMSValidateRequestImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSValidateRequestImpl.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XKMSValidateRequestImpl.hpp	3 Jul 2004 12:44:59 -0000	1.1
  +++ XKMSValidateRequestImpl.hpp	6 Aug 2004 11:41:13 -0000	1.2
  @@ -75,20 +75,7 @@
   	XKMS_MESSAGEABSTRACTYPE_IMPL_METHODS
   
   	/* Forced inheritance from RequestAbstractType */
  -	virtual const XMLCh * getOriginalRequestId(void) const
  -		{return XKMSRequestAbstractTypeImpl::getOriginalRequestId();}
  -	virtual void setOriginalRequestId(const XMLCh * id)
  -		{XKMSRequestAbstractTypeImpl::setOriginalRequestId(id);}
  -	virtual int getRespondWithSize(void)
  -		{return XKMSRequestAbstractTypeImpl::getRespondWithSize();}	
  -	virtual XKMSRespondWith * getRespondWithItem(int item)
  -		{return XKMSRequestAbstractTypeImpl::getRespondWithItem(item);}	
  -	virtual const XMLCh * getRespondWithItemStr(int item)
  -		{return XKMSRequestAbstractTypeImpl::getRespondWithItemStr(item);}	
  -	virtual void appendRespondWithItem(XKMSRespondWith * item)
  -		{XKMSRequestAbstractTypeImpl::appendRespondWithItem(item);}
  -	virtual void appendRespondWithItem(const XMLCh * item)
  -		{XKMSRequestAbstractTypeImpl::appendRespondWithItem(item);}
  +	XKMS_REQUESTABSTRACTYPE_IMPL_METHODS
   
   private:
   
  
  
  
  1.1                  xml-security/c/src/xkms/impl/XKMSResponseMechanismImpl.cpp
  
  Index: XKMSResponseMechanismImpl.cpp
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * 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
   * imitations under the License.
   */
  
  /*
   * XSEC
   *
   * XKMSResponseMechanismImpl := Implementation of XKMSResponseMechanism
   *
   * $Id: XKMSResponseMechanismImpl.cpp,v 1.1 2004/08/06 11:41:13 blautenb Exp $
   *
   */
  
  // XSEC Includes
  
  #include <xsec/framework/XSECDefs.hpp>
  #include <xsec/framework/XSECEnv.hpp>
  #include <xsec/framework/XSECError.hpp>
  #include <xsec/utils/XSECDOMUtils.hpp>
  #include <xsec/xkms/XKMSConstants.hpp>
  
  #include <xercesc/util/XMLUniDefs.hpp>
  
  #include "XKMSResponseMechanismImpl.hpp"
  
  #include <xercesc/dom/DOM.hpp>
  
  XERCES_CPP_NAMESPACE_USE
  
  
  // --------------------------------------------------------------------------------
  //           Construct/Destruct
  // --------------------------------------------------------------------------------
  
  
  XKMSResponseMechanismImpl::XKMSResponseMechanismImpl(const XSECEnv * env) :
  mp_env(env),
  mp_responseMechanismTextNode(NULL)
  {}
  
  XKMSResponseMechanismImpl::XKMSResponseMechanismImpl(		
  		const XSECEnv * env, 
  		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node) :
  mp_env(env),
  mp_responseMechanismElement(node),
  mp_responseMechanismTextNode(NULL) {
  
  }
  
  XKMSResponseMechanismImpl::~XKMSResponseMechanismImpl() {}
  
  // --------------------------------------------------------------------------------
  //           Load
  // --------------------------------------------------------------------------------
  
  void XKMSResponseMechanismImpl::load(void) {
  
  	if (mp_responseMechanismElement == NULL) {
  
  		// Attempt to load an empty element
  		throw XSECException(XSECException::XKMSError,
  			"XKMSResponseMechanism::load - called on empty DOM");
  
  	}
  
  	mp_responseMechanismTextNode = findFirstChildOfType(mp_responseMechanismElement, DOMNode::TEXT_NODE);
  
  	if (mp_responseMechanismTextNode == NULL) {
  
  		throw XSECException(XSECException::ExpectedXKMSChildNotFound,
  			"XKMSResponseMechanism::load - Expected TEXT node beneath <ResponseMechanism> element");
  
  	}
  
  }
  // --------------------------------------------------------------------------------
  //           Create
  // --------------------------------------------------------------------------------
  
  DOMElement * XKMSResponseMechanismImpl::createBlankResponseMechanism(const XMLCh * item) {
  
  	// Get some setup values
  	safeBuffer str;
  	DOMDocument *doc = mp_env->getParentDocument();
  	const XMLCh * prefix = mp_env->getXKMSNSPrefix();
  
  	makeQName(str, prefix, XKMSConstants::s_tagResponseMechanism);
  
  	mp_responseMechanismElement = doc->createElementNS(XKMSConstants::s_unicodeStrURIXKMS, 
  												str.rawXMLChBuffer());
  
  	// Create the ResponseMechanism item
  	makeQName(str, prefix, item);
  	mp_responseMechanismTextNode = doc->createTextNode(str.rawXMLChBuffer());
  	mp_responseMechanismElement->appendChild(mp_responseMechanismTextNode);
  
  	return mp_responseMechanismElement;
  }
  
  // --------------------------------------------------------------------------------
  //           Get interface
  // --------------------------------------------------------------------------------
  
  const XMLCh * XKMSResponseMechanismImpl::getResponseMechanismString(void) const {
  
  	if (mp_responseMechanismTextNode == NULL) {
  
  		throw XSECException(XSECException::XKMSError,
  			"XKMSResponseMechanism::getResponseMechanismString - Attempt to get prior to initialisation");
  	}
  	const XMLCh * r = mp_responseMechanismTextNode->getNodeValue();
  
  	int index = XMLString::indexOf(r, chColon);
  	if (index == -1)
  		return r;
  
  	return &r[index+1];
  
  }
  
  // --------------------------------------------------------------------------------
  //           Set interface
  // --------------------------------------------------------------------------------
  
  void XKMSResponseMechanismImpl::setResponseMechanismString(const XMLCh * str) {
  
  	if (mp_responseMechanismTextNode == NULL) {
  
  		throw XSECException(XSECException::XKMSError,
  			"XKMSResponseMechanism::setResponseMechanismString - Attempt to set prior to initialisation");
  	}
  
  	safeBuffer sb;
  	sb.sbXMLChIn(DSIGConstants::s_unicodeStrEmpty);
  
  	if (mp_env->getXKMSNSPrefix() != NULL) {
  		sb.sbXMLChCat(mp_env->getXKMSNSPrefix());
  		sb.sbXMLChAppendCh(chColon);
  	}
  
  	sb.sbXMLChCat(str);
  
  	mp_responseMechanismTextNode->setNodeValue(sb.rawXMLChBuffer());
  
  }
  
  
  
  
  1.1                  xml-security/c/src/xkms/impl/XKMSResponseMechanismImpl.hpp
  
  Index: XKMSResponseMechanismImpl.hpp
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   *
   * 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
   * imitations under the License.
   */
  
  /*
   * XSEC
   *
   * XKMSResponseMechanismImpl := Implementation of XKMSResponseMechanism
   *
   * $Id: XKMSResponseMechanismImpl.hpp,v 1.1 2004/08/06 11:41:13 blautenb Exp $
   *
   */
  
  #ifndef XKMSRESPONSEMECHANISMIMPL_INCLUDE
  #define XKMSRESPONSEMECHANISMIMPL_INCLUDE
  
  // XSEC Includes
  
  #include <xsec/framework/XSECDefs.hpp>
  #include <xsec/xkms/XKMSResponseMechanism.hpp>
  
  class XSECEnv;
  
  class XKMSResponseMechanismImpl : public XKMSResponseMechanism {
  
  public:
  
  	XKMSResponseMechanismImpl(const XSECEnv * env);
  	XKMSResponseMechanismImpl(		
  		const XSECEnv * env, 
  		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node
  	);
  
  	virtual ~XKMSResponseMechanismImpl();
  
  	// load
  	void load(void);
  
  	XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * 
  		createBlankResponseMechanism(
  		const XMLCh * item);
  
  	/* Getter Interface Methods */
  
  	virtual XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * getElement(void) const {
  		return mp_responseMechanismElement;
  	}
  
  	virtual const XMLCh * getResponseMechanismString(void) const;
  
  	/* Setter interface methods */
  
  	virtual void setResponseMechanismString(const XMLCh * str);
  
  	//@}
  
  
  private:
  
  	const XSECEnv			* mp_env;
  	XERCES_CPP_NAMESPACE_QUALIFIER DOMElement 
  							* mp_responseMechanismElement;
  	XERCES_CPP_NAMESPACE_QUALIFIER DOMNode
  							* mp_responseMechanismTextNode;
  
  	// Unimplemented
  	XKMSResponseMechanismImpl(const XKMSResponseMechanismImpl &);
  	XKMSResponseMechanismImpl & operator = (const XKMSResponseMechanismImpl &);
  
  };
  
  #endif /* XKMSRESPONSEMECHANISMIMPL_INCLUDE */