Пример #1
0
EppCredsOptions * EppCredsOptions::fromXML( const DOMNode& root )
{
	DOMString version;
	DOMString lang;

	DOMNodeList* list = root.getChildNodes();
	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( name.equals("version") )
		{
			version = EppUtil::getText(*node);
		}
		else if( name.equals("lang") )
		{
			lang = EppUtil::getText(*node);
		}
	}

	if( (version.isNotNull()) && (lang.isNotNull()) )
	{
		return new EppCredsOptions(version, lang);
	}

	return null;
}
Пример #2
0
EppAuthInfo * EppAuthInfo::fromXML( const DOMNode& root )
{
	DOMNodeList* list = root.getChildNodes();
	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
//		if( name.equals("pw") )
		if( name.equals("pw") || name.equals("contact:pw") || name.equals("domain:pw") || name.equals("svcsub:pw")
			|| name.equals("xriAU:pw") || name.equals("xriINU:pw") || name.equals("xriINA:pw") || name.equals("xriISV:pw") /* Uncomment for CodeString || name.equals("xriCS:pw")*/ )
		{
			DOMElement * elm = (DOMElement *) node;
			DOMString roid = elm->getAttribute(XS("roid"));
			DOMString value = EppUtil::getText(*node);
			return new EppAuthInfo(XS(TYPE_PW), value, roid);
		}
//		else if( name.equals("ext") )
		else if( name.equals("ext") || name.equals("contact:ext") || name.equals("domain:ext") || name.equals("svcsub:ext")
			|| name.equals("xriAU:ext") || name.equals("xriINU:ext") || name.equals("xriINA:ext") || name.equals("xriISV:ext") )
		{
			return new EppAuthInfo(XS(TYPE_EXT), NULLXS);
		}
	}
	return null;
}
Пример #3
0
// remove the name using index
// avoid calling findNamePoint again if the index is already known
DOMNode * DOMAttrMapImpl::removeNamedItemAt(XMLSize_t index)
{
    DOMNode* removed = DOMNamedNodeMapImpl::removeNamedItemAt(index);

    // Replace it if it had a default value
    // (DOM spec level 1 - Element Interface)
    if (hasDefaults() && (removed != 0))
    {
        DOMAttrMapImpl* defAttrs = ((DOMElementImpl*)fOwnerNode)->getDefaultAttributes();

        const XMLCh* localName = removed->getLocalName();
        DOMAttr* attr = 0;
        if (localName)
            attr = (DOMAttr*)(defAttrs->getNamedItemNS(removed->getNamespaceURI(), localName));
        else
            attr = (DOMAttr*)(defAttrs->getNamedItem(((DOMAttr*)removed)->getName()));

        if (attr != 0)
        {
            DOMAttr* newAttr = (DOMAttr*)attr->cloneNode(true);
            setNamedItem(newAttr);
        }
    }

    return removed;
}
Пример #4
0
int DOMAttrMapImpl::findNamePoint(const XMLCh *namespaceURI,
	const XMLCh *localName) const
{
    if (fNodes == 0)
	return -1;
    // This is a linear search through the same fNodes Vector.
    // The Vector is sorted on the DOM Level 1 nodename.
    // The DOM Level 2 NS keys are namespaceURI and Localname,
    // so we must linear search thru it.
    // In addition, to get this to work with fNodes without any namespace
    // (namespaceURI and localNames are both 0) we then use the nodeName
    // as a secondary key.
    int i, len = fNodes -> size();
    for (i = 0; i < len; ++i) {
        DOMNode *node = fNodes -> elementAt(i);
        const XMLCh * nNamespaceURI = node->getNamespaceURI();
        const XMLCh * nLocalName = node->getLocalName();
        if (!XMLString::equals(nNamespaceURI, namespaceURI))    //URI not match
            continue;
        else {
            if (XMLString::equals(localName, nLocalName)
                ||
                (nLocalName == 0 && XMLString::equals(localName, node->getNodeName())))
                return i;
        }
    }
    return -1;	//not found
}
void browseTree(DOMNode* root)
{
	static int indent = 1;
	indent++;

	DOMNodeList* list = root->getChildNodes();
	for( int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if ( name.equals("#text") )
			continue;
		printDash(indent);
		cout<<name<<endl;
		browseTree(node);
	}
	indent--;
}
Пример #6
0
void DeltaApplyEngine::ApplyDeltaElement(DOMNode* incDeltaElement) {
	vddprintf(("Apply delta element\n"));
	deltaElement = incDeltaElement;
	
	/* ---- Do All DELETE Operations ( including 'from' part of move ) ---- */
	
	vddprintf(("Apply Delete operations\n"));
	DOMNode* firstOp = deltaElement->getFirstChild() ;
	vddprintf(("    first sort delete operations...\n"));
	SortDeleteOperationsEngine deleteOps(xiddoc, firstOp);
	vddprintf(("    then apply all of them 1 by 1...\n"));
	while(!deleteOps.isListEmpty()) {
		DOMNode* op=deleteOps.getNextDeleteOperation();
		ApplyOperation(op);
		}

	vddprintf(("Ok, there are no more delete operations.\n"));
	
	/* ---- Do All INSERT Operations ( including 'to' part of move ) ---- */
	
	firstOp = deltaElement->getFirstChild() ;
	SortInsertOperationsEngine insertOps(xiddoc, firstOp);
	while(!insertOps.isListEmpty()) {
		DOMNode* op=insertOps.getNextInsertOperation();
		ApplyOperation(op);
		}
	
	/* ---- Do all  UPDATE  &  ATTRIBUTE  Operations ---- */

	DOMNode* child = deltaElement->getFirstChild() ;
	XMLCh iStr[100];
	XMLString::transcode("i", iStr, 99);
	XMLCh dStr[100];
	XMLString::transcode("d", dStr, 99);
	while (child != NULL) {
		if ( (!XMLString::equals(child->getLocalName(),iStr))
		
		   &&(!XMLString::equals(child->getLocalName(), dStr)) ) ApplyOperation(child);
	  child = child->getNextSibling() ;
		}
		
	/* ---- Small consistency checks ---- */

	if (moveDocument->getDocumentElement()->hasChildNodes()) THROW_AWAY(("temporary document used to move node is not empty!"));

	vddprintf(("xiddoc=%s\n",xiddoc->getXidMap().String().c_str() ));
}
Пример #7
0
EppMarkMark* EppMarkMark::fromXML( const DOMNode& root, const char* ns)
{
	EppMarkMark *_ret    = new EppMarkMark(ns);
	DOMNodeList* list    = root.getChildNodes();

	int nsLen      = strlen(ns);

	if( list == 0 )
	{
		delete _ret;
		return NULL;
	}

	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();

		if( name.isNull() )
		{
			name = node->getNodeName();
		}

		if( name.isNull() )
		{
			continue;
		}
		if( name.substringData(0, nsLen + 1).equals((_ret->getNameSpace() + ":").c_str()) )
		{
			name = name.substringData(nsLen + 1, name.length() - ( nsLen + 1 ));
		}
		if( name.equals("trademark") )
		{
			EppTrademarkData *_tmd = EppTrademarkData::fromXML(*node, ns);
			if( NULL != _tmd )
			{
				_ret->_marks.addElement(_tmd);
			}
		}
		else if ( name.equals("court") )
		{
			EppCourtData *_cd = EppCourtData::fromXML(*node, ns);
			if( NULL != _cd )
			{
				_ret->_marks.addElement(_cd);
			}
		}
		else if ( name.equals("treatyOrStatute") )
		{
			EppTreatyOrStatuteData *_tsd = EppTreatyOrStatuteData::fromXML(*node, ns);
			if( NULL != _tsd )
			{
				_ret->_marks.addElement(_tsd );
			}
		}

	}
	return _ret;
}
EppCommandInfoLaunchRegistration* EppCommandInfoLaunchRegistration::fromXML( const DOMNode& root )
{
	EppCommandInfoLaunchRegistration* cmd  = new EppCommandInfoLaunchRegistration();
	if( cmd == null )
	{
		return null;
	}
	DOMNodeList* list      = root.getChildNodes();
	DOMNamedNodeMap* attrs = root.getAttributes();

	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node  = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( (name.length() > 7) && name.substringData(0, 7).equals("launch:") )
		{
			name = name.substringData(7, name.length() - 7);
		}
		if( name.equals("phase") )
		{
			EppLaunchPhase *_pptr = EppLaunchPhase::fromXML(*node);
			if( null != _pptr )
			{
				cmd->_phase = *_pptr;
				delete _pptr;
			}
			_pptr = null;
		}
		else if ( name.equals("applicationID") )
		{
			cmd->_appId = EppUtil::getText(*node);
		}
	}
	for( unsigned int i = 0;i<attrs->getLength();i++ )
	{
		DOMNode* attr = attrs->item(i);
		if( XS(attr->getNodeName()).equals("includeMark") )
		{
			DOMString _v = attr->getNodeValue();
			if( _v.length() > 0 )
			{
				if( _v.equals("true") )
				{
					cmd->includeMark(true);
				}
			}
			break;
		}
	}
	return cmd;
}
EppCommandCreateSecDns* EppCommandCreateSecDns::fromXML( const DOMNode &root )
{
	EppCommandCreateSecDns * cmd  = new EppCommandCreateSecDns();
	if( cmd == null )
	{
		return null;
	}

	DOMNodeList* list  = root.getChildNodes();
	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();

		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( name.substringData(0, 7).equals("secDNS:") )
		{
			name = name.substringData(7, name.length() - 7);
		}
		if( name.equals("dsData") )
		{
			EppSecDnsDsData * ds = EppSecDnsDsData::fromXML(*node);
			if( ds != null )
			{
				cmd->add(*ds);
				delete ds;
			}
		}
		else if( name.equals("maxSigLife") )
		{
			DOMString value = EppUtil::getText(*node);
			char *p = value.transcode();
			if( p != null )
			{
				cmd->maxSigLife = ::atoi(p);
				XercesString::Delete(p);
			}
		}
		else if( name.equals("keyData") )
		{
			// FIXME(zhang) not supported
			cmd->keyDataPresent = true;
			EppSecDnsKeyData *kd = EppSecDnsKeyData::fromXML(*node);
			if( kd != null )
			{
				cmd->add(*kd);
				delete kd;
			}
		}
	}
	return cmd;
}
Пример #10
0
EppCreds * EppCreds::fromXML( const DOMNode& root )
{
	DOMString clID;
	DOMString pw;
	DOMString newPW;
	EppCredsOptions * opt = null;
	EppCreds * creds = null;

	DOMNodeList* list = root.getChildNodes();
	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( name.equals("clID") )
		{
			clID = EppUtil::getText(*node);
		}
		else if( name.equals("pw") )
		{
			pw = EppUtil::getText(*node);
		}
		else if( name.equals("newPW") )
		{
			newPW = EppUtil::getText(*node);
		}
		else if( name.equals("options") )
		{
			if( opt != null )
			{
				delete opt;
			}
			opt = EppCredsOptions::fromXML(*node);
		}
	}

	if( (clID.isNotNull()) && (pw.isNotNull()) )
	{
		creds = new EppCreds(clID, pw, newPW);
		if( opt != null )
		{
			creds->setOptions(*opt);
		}
	}

	if( opt != null )
	{
		delete opt;
	}

	return creds;
}
void EppResponseInfoFeeType::fromXMLCommon( const DOMNode& root, EppResponseInfoFeeType* data )
{
	if( NULL == data )
	{
		return;
	}

	EppCommandInfoFeeType::fromXMLCommon(root, data);

	DOMNodeList* list = root.getChildNodes();

	if( NULL == list )
	{
		return;
	}

	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);

		if( NULL == node )
		{
			continue;
		}

		DOMString name = node->getLocalName();

		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}

		if( name.equals("fee") || name.equals("fee:fee") )
		{
			EppFeeFee* f = EppFeeFee::fromXML(*node);
			if( NULL != f )
			{
				data->addFee(f);
			}
			continue;
		}
		if( name.equals("class") || name.equals("fee:class") )
		{
			data->setFeeClass(EppUtil::getText(*node));
			continue;
		}

	}
}
Пример #12
0
static DOMElement *getExpectedChildElement(DOMNode *parent, string childName) {
    for(DOMNode *child = parent->getFirstChild(); child; child = child->getNextSibling()) {
        if(child->getNodeType() == DOMNode::ELEMENT_NODE && child->getLocalName() && XercesString(child->getLocalName()) == childName) {
            DOMElement *childElement = dynamic_cast<DOMElement*>(child);
            CHECK(childElement);

            return childElement;
        }
    }

    throw runtime_error((string)XercesString(parent->getLocalName()) + " missing expected child element " + childName);
}
Пример #13
0
const XMLCh* DOMNodeImpl::lookupNamespacePrefix(const XMLCh* const namespaceURI, bool useDefault, DOMElement *el) const {
    DOMNode *thisNode = castToNode(this);

    const XMLCh* ns = thisNode->getNamespaceURI();
    // REVISIT: if no prefix is available is it null or empty string, or
    //          could be both?
    const XMLCh* prefix = thisNode->getPrefix();

    if (ns != 0 && XMLString::equals(ns,namespaceURI)) {
        if (useDefault || prefix != 0) {
            const XMLCh* foundNamespace =  el->lookupNamespaceURI(prefix);
            if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
                return prefix;
            }
        }
    }
    if (thisNode->hasAttributes()) {
        DOMNamedNodeMap *nodeMap = thisNode->getAttributes();

        if(nodeMap != 0) {
            int length = nodeMap->getLength();

            for (int i = 0;i < length;i++) {
                DOMNode *attr = nodeMap->item(i);
                const XMLCh* attrPrefix = attr->getPrefix();
                const XMLCh* value = attr->getNodeValue();

                ns = attr->getNamespaceURI();

                if (ns != 0 && XMLString::equals(ns, XMLUni::fgXMLNSURIName)) {
                    // DOM Level 2 nodes
                    if ((useDefault && XMLString::equals(attr->getNodeName(), XMLUni::fgXMLNSString)) ||
                        (attrPrefix != 0 && XMLString::equals(attrPrefix, XMLUni::fgXMLNSString)) &&
                        XMLString::equals(value, namespaceURI)) {
                        const XMLCh* localname= attr->getLocalName();
                        const XMLCh* foundNamespace = el->lookupNamespaceURI(localname);
                        if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
                            return localname;
                        }
                    }
                }
            }
        }
    }
    DOMNode *ancestor = getElementAncestor(thisNode);
    if (ancestor != 0) {
        return castToNodeImpl(ancestor)->lookupNamespacePrefix(namespaceURI, useDefault, el);
    }
    return 0;
}
EppCommandTransferContact * EppCommandTransferContact::fromXML( const DOMNode& root )
{
	EppCommandTransferContact * cmd = null;
	EppAuthInfo * authInfo = null;
	DOMNodeList* list = root.getChildNodes();

	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();

		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		//if( name.equals("id") )
		if( name.equals("id") || name.equals("contact:id") )
		{
			DOMString id = EppUtil::getText(*node);
			if( cmd == null )
			{
				cmd = new EppCommandTransferContact(id);
			}
		}
		//else if( name.equals("authInfo") )
		else if( name.equals("authInfo") || name.equals("contact:authInfo") )
		{
			if( authInfo == null )
			{
				authInfo = EppAuthInfo::fromXML(*node);
			}
		}
	}
	if( cmd != null )
	{
		cmd->authInfo = authInfo;
	}
	else if( authInfo != null )
	{
		delete authInfo;
	}

	return cmd;
}
Пример #15
0
DOMNode* DeltaApplyEngine::getDeltaElement(XID_DOMDocument *IncDeltaDoc) {

	if (IncDeltaDoc  == NULL) THROW_AWAY(("delta document is null"));

	DOMNode* dRoot = IncDeltaDoc->getElementsByTagNameNS(XYDIFF_XYDELTA_NS, XMLString::transcode("unit_delta"))->item(0);
	if ( (dRoot==NULL)
	   ||(!XMLString::equals(dRoot->getLocalName(), XMLString::transcode("unit_delta")))) THROW_AWAY(("no <unit_delta> root found on document"));

//	const XMLCh * firstChildNodeName = dRoot->getFirstChild()->getNodeName();
//	char * firstChildNodeChar = XMLString::transcode(firstChildNodeName);
	DOMNodeList * tElementNodes = IncDeltaDoc->getElementsByTagNameNS(XYDIFF_XYDELTA_NS, XMLString::transcode("t"));
	if (tElementNodes->getLength() == 0) THROW_AWAY(("no delta element <t> found"));
//	   ||(!XMLString::equals(dRoot->getFirstChild()->getNodeName(), tempStr))) THROW_AWAY(("no delta element <t> found"));
	
//	DOMNode* deltaElement = dRoot->getFirstChild() ;
	DOMNode* deltaElement = tElementNodes->item(0);
	return deltaElement ;
	}
EppResponseDataCreateLaunchRegistration* EppResponseDataCreateLaunchRegistration::fromXML( const DOMNode& root )
{
	EppResponseDataCreateLaunchRegistration *cmd  = new EppResponseDataCreateLaunchRegistration();
	if( cmd == null )
	{
		return null;
	}
	DOMNodeList* list  = root.getChildNodes();
	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node  = list->item(i);
		DOMString name = node->getLocalName();

		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( (name.length() > 7) && name.substringData(0, 7).equals("launch:") )
		{
			name = name.substringData(7, name.length() - 7);
		}
		if( name.equals("phase") )
		{
			EppLaunchPhase *_pptr = EppLaunchPhase::fromXML(*node);
			if( null != _pptr )
			{
				cmd->_phase = *_pptr;
				delete _pptr;
			}
			_pptr = null;
		}
		else if( name.equals("applicationID") )
		{
			cmd->_appId = EppUtil::getText(*node);
		}
	}
	return cmd;
}
Пример #17
0
bool DOMNodeImpl::isEqualNode(const DOMNode* arg) const
{
    if (!arg)
        return false;

    if (isSameNode(arg)) {
        return true;
    }

    DOMNode* thisNode = castToNode(this);

    if (arg->getNodeType() != thisNode->getNodeType()) {
        return false;
    }

    // the compareString will check null string as well
    if (!XMLString::equals(thisNode->getNodeName(), arg->getNodeName())) {
        return false;
    }

    if (!XMLString::equals(thisNode->getLocalName(),arg->getLocalName())) {
        return false;
    }

    if (!XMLString::equals(thisNode->getNamespaceURI(), arg->getNamespaceURI())) {
        return false;
    }

    if (!XMLString::equals(thisNode->getPrefix(), arg->getPrefix())) {
        return false;
    }

    if (!XMLString::equals(thisNode->getNodeValue(), arg->getNodeValue())) {
        return false;
    }

    if (!XMLString::equals(thisNode->getBaseURI(), arg->getBaseURI())) {
        return false;
    }

    return true;
}
EppResponseDataTransferSvcsub * EppResponseDataTransferSvcsub::fromXML( const DOMNode& root )
{
	EppResponseDataTransferSvcsub * res = null;
	DOMNodeList* list = root.getChildNodes();
	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		//if( name.equals("id") )
		if( name.equals("id") || name.equals("svcsub:id") )
		{
			if( res == null )
			{
				DOMString svcsub = EppUtil::getText(*node);
				res = new EppResponseDataTransferSvcsub(svcsub);
			}
		}
		//else if( name.equals("service") )
		else if( name.equals("service") || name.equals("svcsub:service") )
		{
			if( res != null )
			{
				DOMString service = EppUtil::getText(*node);
				res->setService(service);
			}
		}
		else if( res != null )
		{
			res->fromXMLCommon(*node, name);
		}
	}

	return res;
}
void EppCommandCheckFeeType::fromXMLCommon( const DOMNode& root, EppCommandCheckFeeType* data )
{
	if( NULL == data )
	{
		return;
	}

	EppCommandInfoFeeType::fromXMLCommon(root, data);

	DOMNodeList* list = root.getChildNodes();

	if( NULL == list )
	{
		return;
	}

	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);

		if( NULL == node )
		{
			continue;
		}

		DOMString name = node->getLocalName();

		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( name.equals("name") || name.equals("fee:name") )
		{
			data->setName(EppUtil::getText(*node));
			continue;
		}
	}
}
EppLaunchProtection* EppLaunchProtection::fromXML( const DOMNode& root, const char* ns )
{
	EppLaunchProtection *_ret = new EppLaunchProtection(ns);
	if( null == _ret )
		return null;
	DOMNodeList* list = root.getChildNodes();
	int nsLen = strlen(ns);

	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( name.substringData(0, nsLen + 1).equals((_ret->getNameSpace() + ":").c_str() ) )
		{
			name = name.substringData(nsLen + 1, name.length() - (nsLen + 1));
		}
		if( name.equals("cc") )
		{
			_ret->_cc = (EppUtil::getText(*node)).substringData(0, 2);
		}
		else if( name.equals("region") )
		{
			_ret->_region = EppUtil::getText(*node);
		}
		else if( name.equals("ruling") )
		{
			_ret->_ruling = EppUtil::getText(*node);
		}
	}
	return _ret;
}
EppResponseDataRenewDomain * EppResponseDataRenewDomain::fromXML( const DOMNode& root )
{
	DOMString roid;
	DOMString domain;
	time_t exDate = 0;

	DOMNodeList* list = root.getChildNodes();
	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();

		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		//if( name.equals("roid") )
		if( name.equals("roid") || name.equals("domain:roid") )
		{
			roid = EppUtil::getText(*node);
		}
		//else if( name.equals("name") )
		else if( name.equals("name") || name.equals("domain:name") )
		{
			domain = EppUtil::getText(*node);
		}
		//else if( name.equals("exDate") )
		else if( name.equals("exDate") || name.equals("domain:exDate") )
		{
			exDate = EppUtil::getDate(*node);
		}
	}

	return new EppResponseDataRenewDomain(domain, roid, exDate);
}
Пример #22
0
EppLaunchPhase* EppLaunchPhase::fromXML( const DOMNode& root )
{
    DOMNamedNodeMap* attrs = root.getAttributes();
    EppLaunchPhase *_ret = new EppLaunchPhase();
    if( null == _ret )
        return null;
    {
        DOMNode* node = (DOMNode*)&root;
        DOMString name = node->getLocalName();
        if( name.isNull() )
        {
            name = node->getNodeName();
        }
        if( name.isNotNull() )
        {
            if( name.substringData(0, 7).equals("launch:") )
            {
                name = name.substringData(7, name.length() - 7);
            }
            if( name.equals("phase") )
            {
                _ret->_phase = EppUtil::getText(*node);
            }
        }
    }
    for( unsigned int i = 0; i<attrs->getLength(); i++ )
    {
        DOMNode* attr = attrs->item(i);
        DOMString _v = attr->getNodeValue();
        if( XS(attr->getNodeName()).equals("name") )
        {
            _ret->_sub_phase = attr->getNodeValue();
            break;
        }
    }
    return _ret;
}
Пример #23
0
EppTransactionId * EppTransactionId::fromXML( const DOMNode& root )
{
	DOMString clTRID = NULLXS;
	DOMString svTRID = NULLXS;

	DOMNodeList* list = root.getChildNodes();
	for( unsigned int i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();

		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( name.equals("clTRID") || name.equals("epp:clTRID") )
		{
			clTRID = EppUtil::getText(*node);
		}
		else if( name.equals("svTRID") || name.equals("epp:svTRID") )
		{
			svTRID = EppUtil::getText(*node);
		}
	}

	if( svTRID.isNotNull() )
	{
		return new EppTransactionId(clTRID, svTRID);
	}

	return null;
}
Пример #24
0
// Finds and returns the first child node with the given name.
DOMElement* XUtil::getFirstChildElementNS(const DOMNode* const parent
                                          , const XMLCh** const elemNames
                                          , const XMLCh* const uriStr
                                          , unsigned int        length)
{
    // search for node
    DOMNode* child = parent->getFirstChild();
    while (child != 0)
	{
        if (child->getNodeType() == DOMNode::ELEMENT_NODE)
		{
            for (unsigned int i = 0; i < length; i++)
			{
                if (XMLString::equals(child->getNamespaceURI(), uriStr) &&
                    XMLString::equals(child->getLocalName(), elemNames[i]))
                    return (DOMElement*)child;
			}
		}
        child = child->getNextSibling();
    }

    // not found
    return 0;
}
Пример #25
0
// remove the name using index
// avoid calling findNamePoint again if the index is already known
DOMNode * DOMAttrMapImpl::removeNamedItemAt(XMLSize_t index)
{
    if (this->readOnly())
        throw DOMException(
            DOMException::NO_MODIFICATION_ALLOWED_ERR, 0, GetDOMNamedNodeMapMemoryManager);

    DOMNode *removed = item(index);
    if(!removed)
        throw DOMException(DOMException::NOT_FOUND_ERR, 0, GetDOMNamedNodeMapMemoryManager);

    fNodes->removeElementAt(index);
    castToNodeImpl(removed)->fOwnerNode = fOwnerNode->getOwnerDocument();
    castToNodeImpl(removed)->isOwned(false);

    // Replace it if it had a default value
    // (DOM spec level 1 - Element Interface)
    if (hasDefaults() && (removed != 0))
    {
        DOMAttrMapImpl* defAttrs = ((DOMElementImpl*)fOwnerNode)->getDefaultAttributes();

        const XMLCh* localName = removed->getLocalName();
        DOMAttr* attr = 0;
        if (localName)
            attr = (DOMAttr*)(defAttrs->getNamedItemNS(removed->getNamespaceURI(), localName));
        else
            attr = (DOMAttr*)(defAttrs->getNamedItem(((DOMAttr*)removed)->getName()));

        if (attr != 0)
        {
            DOMAttr* newAttr = (DOMAttr*)attr->cloneNode(true);
            setNamedItem(newAttr);
        }
    }

    return removed;
}
Пример #26
0
// Finds and returns the next sibling element node with the give name.
DOMElement* XUtil::getNextSiblingElementNS(const DOMNode* const node
                                           , const XMLCh** const elemNames
                                           , const XMLCh* const uriStr
									       , unsigned int        length)
{
    // search for node
    DOMNode* sibling = node->getNextSibling();
    while (sibling != 0)
	{
        if (sibling->getNodeType() == DOMNode::ELEMENT_NODE)
		{
            for (unsigned int i = 0; i < length; i++)
			{
                if (XMLString::equals(sibling->getNamespaceURI(), uriStr) &&
                    XMLString::equals(sibling->getLocalName(), elemNames[i]))
                    return (DOMElement*)sibling;
			}
		}
        sibling = sibling->getNextSibling();
    }

    // not found
    return 0;
}
Пример #27
0
// ---------------------------------------------------------------------------
//  GeneralAttributeCheck: Validation methods
// ---------------------------------------------------------------------------
void
GeneralAttributeCheck::checkAttributes(const DOMElement* const elem,
                                       const unsigned short elemContext,
                                       TraverseSchema* const schema,
                                       const bool isTopLevel,
                                       ValueVectorOf<DOMNode*>* const nonXSAttList)
{
    if (nonXSAttList)
        nonXSAttList->removeAllElements();

    if (elem == 0 || !fAttMap || elemContext>=E_Count)
        return;

    const XMLCh* elemName = elem->getLocalName();
    if (!XMLString::equals(SchemaSymbols::fgURI_SCHEMAFORSCHEMA, elem->getNamespaceURI())) {
        schema->reportSchemaError
        (
            elem
            , XMLUni::fgXMLErrDomain
            , XMLErrs::ELTSchemaNS
            , elemName
        );
    }

    const XMLCh*     contextStr = (isTopLevel) ? fgGlobal : fgLocal;
    DOMNamedNodeMap* eltAttrs = elem->getAttributes();
    int              attrCount = eltAttrs->getLength();
    XMLByte          attList[A_Count];

    memset(attList, 0, sizeof(attList));

    for (int i = 0; i < attrCount; i++) {

        DOMNode*     attribute = eltAttrs->item(i);
        const XMLCh* attName = attribute->getNodeName();

        // skip namespace declarations
        if (XMLString::equals(attName, XMLUni::fgXMLNSString)
            || XMLString::startsWith(attName, XMLUni::fgXMLNSColonString))
            continue;

        // Bypass attributes that start with xml
        // add this to the list of "non-schema" attributes
        if ((*attName == chLatin_X || *attName == chLatin_x)
           && (*(attName+1) == chLatin_M || *(attName+1) == chLatin_m)
           && (*(attName+2) == chLatin_L || *(attName+2) == chLatin_l)) {

           if (nonXSAttList)
                nonXSAttList->addElement(attribute);

            continue;
        }

        // for attributes with namespace prefix
        const XMLCh* attrURI = attribute->getNamespaceURI();

        if (attrURI != 0 && *attrURI) {

            // attributes with schema namespace are not allowed
            // and not allowed on "documentation" and "appInfo"
            if (XMLString::equals(attrURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) ||
                XMLString::equals(elemName, SchemaSymbols::fgELT_APPINFO) ||
                XMLString::equals(elemName, SchemaSymbols::fgELT_DOCUMENTATION)) {

                schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                    XMLErrs::AttributeDisallowed, attName, contextStr, elemName);
            }
            else if (nonXSAttList)
            {
                nonXSAttList->addElement(attribute);
            }

            continue;
        }

        int attNameId = A_Invalid;
        attName = attribute->getLocalName();

        bool bContinue=false;   // workaround for Borland bug with 'continue' in 'catch'
        try {
            attNameId= fAttMap->get(attName, fMemoryManager);
        }
        catch(const OutOfMemoryException&)
        {
            throw;
        }
        catch(...) {

            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                XMLErrs::AttributeDisallowed, attName, contextStr, elemName);
            bContinue=true;
        }
        if(bContinue)
            continue;

        if (fgElemAttTable[elemContext][attNameId] & Att_Mask) {

            attList[attNameId] = 1;
            validate
            (
                elem
                , attName
                , attribute->getNodeValue()
                , fgElemAttTable[elemContext][attNameId] & DV_Mask
                , schema
            );
        }
        else {
            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                XMLErrs::AttributeDisallowed, attName, contextStr, elemName);
        }
    }

    // ------------------------------------------------------------------
    // Check for required attributes
    // ------------------------------------------------------------------
    for (unsigned int j=0; j < A_Count; j++) {

        if ((fgElemAttTable[elemContext][j] & Att_Required) && attList[j] == 0) {
            schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::AttributeRequired,
                                      fAttNames[j], contextStr, elemName);
        }
    }
}
void
XMLSecurityTest::testSign() {
    xbemsg::header_t hdr("tests.xbe.foo.bar", "tests.xbe.foo.bar");
    xbemsg::body_t body;

    body.any().push_back(body.dom_document().createElementNS(xml::string("http://www.xenbee.net/schema/2008/02/pingpong").c_str(),
                                                             xml::string("Ping").c_str()));
    xbemsg::message_t msg(hdr,body);

    // serialize to DOMDocument
    xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > doc =
        xbemsg::message(msg, XbeLibUtils::namespace_infomap());

    ::xercesc::DOMElement *rootElem = doc->getDocumentElement();

    XSECProvider prov;
    DSIGSignature *sig;
    xercesc::DOMElement *sigNode;

    sig = prov.newSignature();
    sig->setDSIGNSPrefix(xml::string("dsig").c_str());
    //  sig->setECNSPrefix( NULL );
    //  sig->setXPFNSPrefix(NULL);
    //  sig->setPrettyPrint(false);

    // Use it to create a blank signature DOM structure from the doc

    sigNode = sig->createBlankSignature(doc.get(),
                                        CANON_C14NE_NOC,
                                        SIGNATURE_HMAC,
                                        HASH_SHA1);
  
    // Insert the signature element at the right place within the document
    // find the header DOM node
    DOMNode *hdrNode = rootElem->getFirstChild();
    CPPUNIT_ASSERT(hdrNode != 0);

    char *tmpNodeName = XMLString::transcode(hdrNode->getLocalName());
    std::string nodeName(tmpNodeName);
    XMLString::release(&tmpNodeName);

    CPPUNIT_ASSERT_EQUAL(nodeName, std::string("header"));

    hdrNode->appendChild(sigNode);
    doc->normalizeDocument();

    // Create an envelope reference for the text to be signed
    DSIGReference * ref = sig->createReference(xml::string("").c_str());
    ref->appendEnvelopedSignatureTransform();
  
    // Set the HMAC Key to be the string "secret"
    OpenSSLCryptoProvider cryptoProvider;
    XSECCryptoKeyHMAC *hmacKey = cryptoProvider.keyHMAC();
    hmacKey->setKey((unsigned char *) "secret", strlen("secret"));
    sig->setSigningKey(hmacKey);

    // Add a KeyInfo element
    sig->appendKeyName(MAKE_UNICODE_STRING("The secret key is \"secret\""));

    // Sign
    sig->sign();
  
    xbemsg::message_t signed_msg(*rootElem);
    std::ostringstream oss;
    xbemsg::message(oss, signed_msg, XbeLibUtils::namespace_infomap());

    // write to an xml file
    //   {
    //         std::ofstream ofs("sig-test-2.xml");
    //         ofs << oss.str();
    //   }
    XBE_LOG_DEBUG(oss.str());

    //   std::string expected_digest("6gEokD/uXFJHZdGdup83UEJAL7U=\n");
    //   std::string expected_sigval("t9LLbEU8GHtWrrx+qWTWWujTGEY=\n");

    //   CPPUNIT_ASSERT_EQUAL(expected_digest,
    // 		       signed_msg.header().Signature().get().SignedInfo().Reference().begin()->DigestValue().encode());
    //   CPPUNIT_ASSERT_EQUAL(expected_sigval,
    // 		       signed_msg.header().Signature().get().SignatureValue().encode());
}
Пример #29
0
const XMLCh* DOMNodeImpl::lookupNamespaceURI(const XMLCh* specifiedPrefix) const  {
    DOMNode *thisNode = castToNode(this);

    short type = thisNode->getNodeType();
    switch (type) {
    case DOMNode::ELEMENT_NODE : {
        const XMLCh* ns = thisNode->getNamespaceURI();
        const XMLCh* prefix = thisNode->getPrefix();
        if (ns != 0) {
            // REVISIT: is it possible that prefix is empty string?
            if (specifiedPrefix == 0 && prefix == specifiedPrefix) {
                // looking for default namespace
                return ns;
            } else if (prefix != 0 && XMLString::equals(prefix, specifiedPrefix)) {
                // non default namespace
                return ns;
            }
        }
        if (thisNode->hasAttributes()) {
            DOMNamedNodeMap *nodeMap = thisNode->getAttributes();
            if(nodeMap != 0) {
                int length = nodeMap->getLength();
                for (int i = 0;i < length;i++) {
                    DOMNode *attr = nodeMap->item(i);
                    const XMLCh *attrPrefix = attr->getPrefix();
                    const XMLCh *value = attr->getNodeValue();
                    ns = attr->getNamespaceURI();

                    if (ns != 0 && XMLString::equals(ns, XMLUni::fgXMLNSURIName)) {
                        // at this point we are dealing with DOM Level 2 nodes only
                        if (specifiedPrefix == 0 &&
                            XMLString::equals(attr->getNodeName(), XMLUni::fgXMLNSString)) {
                            // default namespace
                            return value;
                        } else if (attrPrefix != 0 &&
                                   XMLString::equals(attrPrefix, XMLUni::fgXMLNSString) &&
                                   XMLString::equals(attr->getLocalName(), specifiedPrefix)) {
                            // non default namespace
                            return value;
                        }
                    }
                }
            }
        }
        DOMNode *ancestor = getElementAncestor(thisNode);
        if (ancestor != 0) {
            return ancestor->lookupNamespaceURI(specifiedPrefix);
        }
        return 0;
    }
    case DOMNode::DOCUMENT_NODE : {
        return((DOMDocument*)thisNode)->getDocumentElement()->lookupNamespaceURI(specifiedPrefix);
    }
    case DOMNode::ENTITY_NODE :
    case DOMNode::NOTATION_NODE:
    case DOMNode::DOCUMENT_FRAGMENT_NODE:
    case DOMNode::DOCUMENT_TYPE_NODE:
        // type is unknown
        return 0;
    case DOMNode::ATTRIBUTE_NODE:{
        if (fOwnerNode->getNodeType() == DOMNode::ELEMENT_NODE) {
            return fOwnerNode->lookupNamespaceURI(specifiedPrefix);
        }
        return 0;
    }
    default:{
        DOMNode *ancestor = getElementAncestor(castToNode(this));
        if (ancestor != 0) {
            return ancestor->lookupNamespaceURI(specifiedPrefix);
        }
        return 0;
    }
    }
}
Пример #30
0
EppAddress * EppAddress::fromXML( const DOMNode& root )
{
	DOMString street[MAX_NUM_OF_STREETS];
	DOMString city;
	DOMString sp;
	DOMString pc;
	DOMString cc;
	unsigned int i;

	for( i = 0; i < MAX_NUM_OF_STREETS; i++ )
	{
		street[i] = NULLXS;
	}

	DOMNodeList* list = root.getChildNodes();
	for( i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( name.substringData(0, 8).equals("contact:") )
		{
			name = name.substringData(8, name.length() - 8);
		}
		if( name.substringData(0, 6).equals("xriAU:") )
		{
			name = name.substringData(6, name.length() - 6);
		}
		if( name.equals("street") )
		{
			for( int j = 0; j < MAX_NUM_OF_STREETS; j++ )
			{
				if( street[j].isNull() )
				{
					street[j] = EppUtil::getText(*node);
					break;
				}
			}
		}
		else if( name.equals("city") )
		{
			city = EppUtil::getText(*node);
		}
		else if( name.equals("sp") )
		{
			sp = EppUtil::getText(*node);
		}
		else if( name.equals("pc") )
		{
			pc = EppUtil::getText(*node);
		}
		else if( name.equals("cc") )
		{
			cc = EppUtil::getText(*node);
		}
	}

	return new EppAddress(street, city, sp, pc, cc);
}