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/12/04 06:15:15 UTC

cvs commit: xml-security/c/src/xkms/impl XKMSKeyBindingAbstractTypeImpl.cpp XKMSRespondWithImpl.cpp XKMSResponseMechanismImpl.cpp XKMSResultTypeImpl.cpp XKMSStatusImpl.cpp

blautenb    2004/12/03 21:15:15

  Modified:    c/src/xkms/impl XKMSKeyBindingAbstractTypeImpl.cpp
                        XKMSRespondWithImpl.cpp
                        XKMSResponseMechanismImpl.cpp
                        XKMSResultTypeImpl.cpp XKMSStatusImpl.cpp
  Log:
  Update to support new URI based constants
  
  Revision  Changes    Path
  1.7       +10 -5     xml-security/c/src/xkms/impl/XKMSKeyBindingAbstractTypeImpl.cpp
  
  Index: XKMSKeyBindingAbstractTypeImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSKeyBindingAbstractTypeImpl.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XKMSKeyBindingAbstractTypeImpl.cpp	29 Oct 2004 23:16:02 -0000	1.6
  +++ XKMSKeyBindingAbstractTypeImpl.cpp	4 Dec 2004 05:15:15 -0000	1.7
  @@ -124,9 +124,13 @@
   		}
   
   		const XMLCh * usageStr = txt->getNodeValue();
  -		int index = XMLString::indexOf(usageStr, chColon);
  -		if (index >= 0)
  -			usageStr = &usageStr[index+1];
  +		int index = XMLString::indexOf(usageStr, chPound);
  +		if (index == -1 || XMLString::compareNString(usageStr, XKMSConstants::s_unicodeStrURIXKMS, index)) {
  +			throw XSECException(XSECException::XKMSError,
  +				"XKMSResultType::load - KeyUsage not in XKMS Name Space");
  +		}
  +
  +		usageStr = &usageStr[index+1];
   
   
   		if (strEquals(usageStr, XKMSConstants::s_tagEncryption)) {
  @@ -391,7 +395,8 @@
   	DOMElement * e = doc->createElementNS(XKMSConstants::s_unicodeStrURIXKMS, 
   		str.rawXMLChBuffer());
   
  -	makeQName(str, prefix, usage);
  +	str.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
  +	str.sbXMLChCat(usage);
   	e->appendChild(doc->createTextNode(str.rawXMLChBuffer()));
   
   	/* Now find where it goes */
  
  
  
  1.3       +11 -12    xml-security/c/src/xkms/impl/XKMSRespondWithImpl.cpp
  
  Index: XKMSRespondWithImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSRespondWithImpl.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XKMSRespondWithImpl.cpp	24 Jul 2004 12:23:01 -0000	1.2
  +++ XKMSRespondWithImpl.cpp	4 Dec 2004 05:15:15 -0000	1.3
  @@ -102,7 +102,9 @@
   												str.rawXMLChBuffer());
   
   	// Create the RespondWith item
  -	makeQName(str, prefix, item);
  +	str.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
  +	str.sbXMLChCat(item);
  +
   	mp_respondWithTextNode = doc->createTextNode(str.rawXMLChBuffer());
   	mp_respondWithElement->appendChild(mp_respondWithTextNode);
   
  @@ -122,9 +124,12 @@
   	}
   	const XMLCh * r = mp_respondWithTextNode->getNodeValue();
   
  -	int index = XMLString::indexOf(r, chColon);
  -	if (index == -1)
  -		return r;
  +	int index = XMLString::indexOf(r, chPound);
  +
  +	if (index == -1 || XMLString::compareNString(r, XKMSConstants::s_unicodeStrURIXKMS, index)) {
  +			throw XSECException(XSECException::XKMSError,
  +				"XKMSRespondWith::getRespondWithString - Item not in XKMS Name Space");
  +	}
   
   	return &r[index+1];
   
  @@ -143,13 +148,7 @@
   	}
   
   	safeBuffer sb;
  -	sb.sbXMLChIn(DSIGConstants::s_unicodeStrEmpty);
  -
  -	if (mp_env->getXKMSNSPrefix() != NULL) {
  -		sb.sbXMLChCat(mp_env->getXKMSNSPrefix());
  -		sb.sbXMLChAppendCh(chColon);
  -	}
  -
  +	sb.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
   	sb.sbXMLChCat(str);
   
   	mp_respondWithTextNode->setNodeValue(sb.rawXMLChBuffer());
  
  
  
  1.2       +9 -12     xml-security/c/src/xkms/impl/XKMSResponseMechanismImpl.cpp
  
  Index: XKMSResponseMechanismImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSResponseMechanismImpl.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XKMSResponseMechanismImpl.cpp	6 Aug 2004 11:41:13 -0000	1.1
  +++ XKMSResponseMechanismImpl.cpp	4 Dec 2004 05:15:15 -0000	1.2
  @@ -102,7 +102,8 @@
   												str.rawXMLChBuffer());
   
   	// Create the ResponseMechanism item
  -	makeQName(str, prefix, item);
  +	str.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
  +	str.sbXMLChCat(item);
   	mp_responseMechanismTextNode = doc->createTextNode(str.rawXMLChBuffer());
   	mp_responseMechanismElement->appendChild(mp_responseMechanismTextNode);
   
  @@ -122,9 +123,11 @@
   	}
   	const XMLCh * r = mp_responseMechanismTextNode->getNodeValue();
   
  -	int index = XMLString::indexOf(r, chColon);
  -	if (index == -1)
  -		return r;
  +	int index = XMLString::indexOf(r, chPound);
  +	if (index == -1 || XMLString::compareNString(r, XKMSConstants::s_unicodeStrURIXKMS, index)) {
  +			throw XSECException(XSECException::XKMSError,
  +				"XKMSResponseMechanism::getResponseMechanismString - Item not in XKMS Name Space");
  +	}
   
   	return &r[index+1];
   
  @@ -143,13 +146,7 @@
   	}
   
   	safeBuffer sb;
  -	sb.sbXMLChIn(DSIGConstants::s_unicodeStrEmpty);
  -
  -	if (mp_env->getXKMSNSPrefix() != NULL) {
  -		sb.sbXMLChCat(mp_env->getXKMSNSPrefix());
  -		sb.sbXMLChAppendCh(chColon);
  -	}
  -
  +	sb.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
   	sb.sbXMLChCat(str);
   
   	mp_responseMechanismTextNode->setNodeValue(sb.rawXMLChBuffer());
  
  
  
  1.5       +17 -43    xml-security/c/src/xkms/impl/XKMSResultTypeImpl.cpp
  
  Index: XKMSResultTypeImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSResultTypeImpl.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XKMSResultTypeImpl.cpp	21 Sep 2004 12:33:52 -0000	1.4
  +++ XKMSResultTypeImpl.cpp	4 Dec 2004 05:15:15 -0000	1.5
  @@ -96,26 +96,16 @@
   
   	const XMLCh * res = mp_resultMajorAttr->getNodeValue();
   
  -	// This is actually an QName, but we cheat and find the ':' character by hand
  -	// without actually checking the qualifier.
  -	// TODO - CHECK the qualifier.
  -
  -	int res2 = XMLString::indexOf(res, chColon);
  -	if (res2 != -1) {
  -		if (XMLString::compareNString(res, mp_messageAbstractTypeElement->getPrefix(), res2)) {
  -			throw XSECException(XSECException::ResultTypeError,
  -				"XKMSResultType::load - ResultType not in XKMS Name Space");
  -		}
  +	// Result types have now been updated, and are URIs with the XKMS namespace prepended
  +	// to the actual result value
   
  -		res = &res[res2+1];
  -	}
  -	else {
  -		if (mp_messageAbstractTypeElement->getPrefix() != NULL) {
  +	int res2 = XMLString::indexOf(res, chPound);
  +	if (res2 == -1 || XMLString::compareNString(res, XKMSConstants::s_unicodeStrURIXKMS, res2)) {
   			throw XSECException(XSECException::ResultTypeError,
   				"XKMSResultType::load - ResultType not in XKMS Name Space");
  -		}
   	}
   
  +	res = &res[res2+1];
   	for (m_resultMajor = XKMSResultType::Pending; 
   		m_resultMajor > XKMSResultType::NoneMajor; 
   		m_resultMajor = (XKMSResultType::ResultMajor) (m_resultMajor-1)) {
  @@ -128,20 +118,16 @@
   	if (mp_resultMinorAttr != NULL) {
   
   		res = mp_resultMinorAttr->getNodeValue();
  -		int res2 = XMLString::indexOf(res, chColon);
  -		if (res2 != -1) {
  -			if (XMLString::compareNString(res, mp_messageAbstractTypeElement->getPrefix(), res2)) {
  -				throw XSECException(XSECException::ResultTypeError,
  -					"XKMSResultType::load - ResultType not in XKMS Name Space");
  -			}
  -			res = &res[res2+1];
  -		}
  -		else {
  -			if (mp_messageAbstractTypeElement->getPrefix() != NULL) {
  -				throw XSECException(XSECException::ResultTypeError,
  -					"XKMSResultType::load - ResultType not in XKMS Name Space");
  -			}
  +		int res2 = XMLString::indexOf(res, chPound);
  +		if (res2 == -1 ||
  +			XMLString::compareNString(res, XKMSConstants::s_unicodeStrURIXKMS, res2)) {
  +
  +			throw XSECException(XSECException::ResultTypeError,
  +				"XKMSResultType::load - ResultType not in XKMS Name Space");
   		}
  +
  +		res = &res[res2+1];
  +
   		for (m_resultMinor = XKMSResultType::NotSynchronous; 
   			m_resultMinor > XKMSResultType::NoneMinor; 
   			m_resultMinor = (XKMSResultType::ResultMinor) (m_resultMinor-1)) {
  @@ -190,13 +176,7 @@
   
   	safeBuffer s;
   
  -	s.sbXMLChIn(DSIGConstants::s_unicodeStrEmpty);
  -
  -	if (mp_env->getXKMSNSPrefix() != NULL) {
  -		s.sbXMLChCat(mp_env->getXKMSNSPrefix());
  -		s.sbXMLChAppendCh(chColon);
  -	}
  -
  +	s.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
   	s.sbXMLChCat(XKMSConstants::s_tagResultMajorCodes[rmaj]);
   
   	ret->setAttributeNS(NULL, 
  @@ -205,13 +185,7 @@
   
   	if (rmin != XKMSResultType::NoneMinor) {
   
  -		s.sbXMLChIn(DSIGConstants::s_unicodeStrEmpty);
  -
  -		if (mp_env->getXKMSNSPrefix() != NULL) {
  -			s.sbXMLChCat(mp_env->getXKMSNSPrefix());
  -			s.sbXMLChAppendCh(chColon);
  -		}
  -
  +		s.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
   		s.sbXMLChCat(XKMSConstants::s_tagResultMinorCodes[rmin]);
   	
   		ret->setAttributeNS(NULL, 
  
  
  
  1.2       +17 -33    xml-security/c/src/xkms/impl/XKMSStatusImpl.cpp
  
  Index: XKMSStatusImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/xkms/impl/XKMSStatusImpl.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XKMSStatusImpl.cpp	11 Jul 2004 12:08:12 -0000	1.1
  +++ XKMSStatusImpl.cpp	4 Dec 2004 05:15:15 -0000	1.2
  @@ -122,21 +122,12 @@
   	// without actually checking the qualifier.
   	// TODO - CHECK the qualifier.
   
  -	int res2 = XMLString::indexOf(res, chColon);
  -	if (res2 != -1) {
  -		if (XMLString::compareNString(res, mp_statusElement->getPrefix(), res2)) {
  +	int res2 = XMLString::indexOf(res, chPound);
  +	if (res2 == -1 || XMLString::compareNString(res, XKMSConstants::s_unicodeStrURIXKMS, res2)) {
   			throw XSECException(XSECException::StatusError,
   				"XKMSStatus::load - StatusValue not in XKMS Name Space");
  -		}
  -
  -		res = &res[res2+1];
  -	}
  -	else {
  -		if (mp_statusElement->getPrefix() != NULL) {
  -			throw XSECException(XSECException::StatusError,
  -				"XKMSStatus::load - StatusValue not in XKMS Name Space");
  -		}
   	}
  +	res = &res[res2+1];
   
   	for (m_statusValue = XKMSStatus::Indeterminate; 
   		m_statusValue > XKMSStatus::StatusUndefined; 
  @@ -183,24 +174,15 @@
   				"XKMSStatus::load - Expected text node child of reason element");
   		}
   
  -		/* Strip out the qname */
  +		/* Strip out the URI prefix */
   		const XMLCh * reason = t->getNodeValue();
   
  -		int res = XMLString::indexOf(reason, chColon);
  -		if (res != -1) {
  -			if (XMLString::compareNString(reason, e->getPrefix(), res)) {
  +		int res = XMLString::indexOf(reason, chPound);
  +		if (res == -1 || XMLString::compareNString(reason, XKMSConstants::s_unicodeStrURIXKMS, res)) {
   				throw XSECException(XSECException::StatusError,
   					"XKMSStatus::load - StatusReason not in XKMS Name Space");
  -			}
  -
  -			reason = &reason[res+1];
  -		}
  -		else {
  -			if (e->getPrefix() != NULL) {
  -				throw XSECException(XSECException::StatusError,
  -					"XKMSStatus::load - StatusReason not in XKMS Name Space");
  -			}
   		}
  +		reason = &reason[res+1];
   
   		/* Found out what we are! */
   		XKMSStatus::StatusReason i;
  @@ -244,7 +226,8 @@
   
   	/* Now add the StatusValue element */
   
  -	makeQName(str, prefix, XKMSConstants::s_tagStatusValueCodes[status]);
  +	str.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
  +	str.sbXMLChCat(XKMSConstants::s_tagStatusValueCodes[status]);
   
   	mp_statusElement->setAttributeNS(NULL, 
   		XKMSConstants::s_tagStatusValue,
  @@ -329,23 +312,24 @@
   	/* Now lets create our new element and its text child */
   	safeBuffer str;
   	DOMDocument *doc = mp_env->getParentDocument();
  -	const XMLCh * prefix = mp_env->getXKMSNSPrefix();
  +	str.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
   
   	if (status == Valid) {
  -		makeQName(str, prefix, XKMSConstants::s_tagValidReason);
  +		str.sbXMLChCat(XKMSConstants::s_tagValidReason);
   	}
   	else if (status == Invalid) {
  -		makeQName(str, prefix, XKMSConstants::s_tagInvalidReason);
  +		str.sbXMLChCat(XKMSConstants::s_tagInvalidReason);
   	}
   	else {
  -		makeQName(str, prefix, XKMSConstants::s_tagIndeterminateReason);
  +		str.sbXMLChCat(XKMSConstants::s_tagIndeterminateReason);
   	}
   
   	DOMElement * e = doc->createElementNS(XKMSConstants::s_unicodeStrURIXKMS, 
   												str.rawXMLChBuffer());
   
   	/* Create the text node child */
  -	makeQName(str, prefix, XKMSConstants::s_tagStatusReasonCodes[reason]);
  +	str.sbXMLChIn(XKMSConstants::s_unicodeStrURIXKMS);
  +	str.sbXMLChCat(XKMSConstants::s_tagStatusReasonCodes[reason]);
   	e->appendChild(doc->createTextNode(str.rawXMLChBuffer()));
   
   	/* Insert at correct place */
  @@ -365,4 +349,4 @@
   
   	m_statusReasons[status-1][reason-1] = e;
   
  -}
  \ No newline at end of file
  +}