xmlNodePtr msOWSCommonOperationsMetadataOperation(xmlNsPtr psNsOws, xmlNsPtr psXLinkNs, char *name, int method, char *url) { xmlNodePtr psRootNode = NULL; xmlNodePtr psNode = NULL; xmlNodePtr psSubNode = NULL; xmlNodePtr psSubSubNode = NULL; if (_validateNamespace(psNsOws) == MS_FAILURE) psNsOws = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_PREFIX); psRootNode = xmlNewNode(psNsOws, BAD_CAST "Operation"); xmlNewProp(psRootNode, BAD_CAST "name", BAD_CAST name); psNode = xmlNewChild(psRootNode, psNsOws, BAD_CAST "DCP", NULL); psSubNode = xmlNewChild(psNode, psNsOws, BAD_CAST "HTTP", NULL); if (method == OWS_METHOD_GET || method == OWS_METHOD_GETPOST ) { psSubSubNode = xmlNewChild(psSubNode, psNsOws, BAD_CAST "Get", NULL); xmlNewNsProp(psSubSubNode, psXLinkNs, BAD_CAST "type", BAD_CAST "simple"); xmlNewNsProp(psSubSubNode, psXLinkNs, BAD_CAST "href", BAD_CAST url); } if (method == OWS_METHOD_POST || method == OWS_METHOD_GETPOST ) { psSubSubNode = xmlNewChild(psSubNode, psNsOws, BAD_CAST "Post", NULL); xmlNewNsProp(psSubSubNode, psXLinkNs, BAD_CAST "type", BAD_CAST "simple"); xmlNewNsProp(psSubSubNode, psXLinkNs, BAD_CAST "href", BAD_CAST url); } return psRootNode; }
static xmlNode* get_xmlNode(LassoNode *node, gboolean lasso_dump) { xmlNode *xmlnode, *t; xmlnode = parent_class->get_xmlNode(node, lasso_dump); if (LASSO_SAMLP_RESPONSE(node)->Status && has_lib_status(LASSO_SAMLP_RESPONSE(node)->Status->StatusCode)) { /* liberty QName, add liberty namespace */ xmlNewNs(xmlnode, (xmlChar*)LASSO_LIB_HREF, (xmlChar*)LASSO_LIB_PREFIX); } for (t = xmlnode->children; t && strcmp((char*)t->name, "Assertion"); t = t->next) ; if (t && strcmp((char*)t->ns->href, LASSO_LIB_HREF) == 0) { /* liberty nodes are not allowed in samlp nodes */ xmlSetNs(t, xmlNewNs(xmlnode, (xmlChar*)LASSO_SAML_ASSERTION_HREF, (xmlChar*)LASSO_SAML_ASSERTION_PREFIX)); if (xmlHasNsProp(t, (xmlChar*)"type", (xmlChar*)LASSO_XSI_HREF) == NULL) xmlNewNsProp(t, xmlNewNs(xmlnode, (xmlChar*)LASSO_XSI_HREF, (xmlChar*)LASSO_XSI_PREFIX), (xmlChar*)"type", (xmlChar*)"lib:AssertionType"); } return xmlnode; }
WsXmlAttrH xml_parser_attr_add(WsXmlNodeH node, const char *uri, const char *name, const char *value) { xmlNodePtr xmlNode = (xmlNodePtr) node; xmlNsPtr xmlNs = (xmlNsPtr) xml_parser_ns_find(node, uri, NULL, 1, 1); xmlAttrPtr xmlAttr = (xmlAttrPtr) ws_xml_find_node_attr(node, uri, name); if (xmlAttr != NULL) ws_xml_remove_node_attr((WsXmlAttrH) xmlAttr); if (xmlNs == NULL) xmlAttr = xmlNewProp(xmlNode, BAD_CAST name, BAD_CAST value); else xmlAttr = xmlNewNsProp(xmlNode, xmlNs, BAD_CAST name, BAD_CAST value); if (xmlAttr != NULL) { if (xmlNs == NULL) xmlAttr->_private = xmlGetProp(xmlNode, BAD_CAST name); else xmlAttr->_private = xmlGetNsProp(xmlNode, BAD_CAST name, xmlNs->href); } return (WsXmlAttrH) xmlAttr; }
static int processDoc(xmlDoc *doc, lpc2xml_context *ctx) { int ret = 0; xmlNs *xsi_ns; xmlNs *lpc_ns; xmlAttr *schemaLocation; xmlNode *root_node = xmlNewNode(NULL, (const xmlChar *)"config"); if(root_node == NULL) { lpc2xml_log(ctx, LPC2XML_ERROR, "Can't create \"config\" element"); return -1; } lpc_ns = xmlNewNs(root_node, (const xmlChar *)"http://www.linphone.org/xsds/lpconfig.xsd", NULL); if(lpc_ns == NULL) { lpc2xml_log(ctx, LPC2XML_WARNING, "Can't create lpc namespace"); } else { xmlSetNs(root_node, lpc_ns); } xsi_ns = xmlNewNs(root_node, (const xmlChar *)"http://www.w3.org/2001/XMLSchema-instance", (const xmlChar *)"xsi"); if(lpc_ns == NULL) { lpc2xml_log(ctx, LPC2XML_WARNING, "Can't create xsi namespace"); } schemaLocation = xmlNewNsProp(root_node, xsi_ns, (const xmlChar *)"schemaLocation", (const xmlChar *)"http://www.linphone.org/xsds/lpconfig.xsd lpconfig.xsd"); if(schemaLocation == NULL) { lpc2xml_log(ctx, LPC2XML_WARNING, "Can't create schemaLocation"); } ret = processConfig(root_node, ctx); xmlDocSetRootElement(doc, root_node); return ret; }
/** * e_soap_message_start_header_element: * @msg: the #ESoapMessage. * @name: name of the header element * @must_understand: whether the recipient must understand the header in order * to proceed with processing the message * @actor_uri: the URI which represents the destination actor for this header. * @prefix: the namespace prefix * @ns_uri: the namespace URI * * Starts a new SOAP arbitrary header element. * * Since: 2.92 */ void e_soap_message_start_header_element (ESoapMessage *msg, const gchar *name, gboolean must_understand, const gchar *actor_uri, const gchar *prefix, const gchar *ns_uri) { ESoapMessagePrivate *priv; g_return_if_fail (E_IS_SOAP_MESSAGE (msg)); priv = E_SOAP_MESSAGE_GET_PRIVATE (msg); e_soap_message_start_element (msg, name, prefix, ns_uri); if (actor_uri) xmlNewNsProp (priv->last_node, priv->soap_ns, (const xmlChar *)"actorUri", (const xmlChar *)actor_uri); if (must_understand) xmlNewNsProp (priv->last_node, priv->soap_ns, (const xmlChar *)"mustUnderstand", (const xmlChar *)"1"); }
/** * e_soap_message_set_null: * @msg: the #ESoapMessage. * * Sets the current element's XML Schema xsi:null attribute. * * Since: 2.92 */ void e_soap_message_set_null (ESoapMessage *msg) { ESoapMessagePrivate *priv; g_return_if_fail (E_IS_SOAP_MESSAGE (msg)); priv = E_SOAP_MESSAGE_GET_PRIVATE (msg); xmlNewNsProp (priv->last_node, priv->xsi_ns, (const xmlChar *)"null", (const xmlChar *)"1"); }
/** * e_soap_message_set_encoding_style: * @msg: the #ESoapMessage. * @enc_style: the new encodingStyle value * * Sets the encodingStyle attribute on the current element to the * value of @enc_style. * * Since: 2.92 */ void e_soap_message_set_encoding_style (ESoapMessage *msg, const gchar *enc_style) { ESoapMessagePrivate *priv; g_return_if_fail (E_IS_SOAP_MESSAGE (msg)); priv = E_SOAP_MESSAGE_GET_PRIVATE (msg); xmlNewNsProp (priv->last_node, priv->soap_ns, (const xmlChar *)"encodingStyle", (const xmlChar *)enc_style); }
/** * e_soap_message_set_element_type: * @msg: the #ESoapMessage. * @xsi_type: the type name for the element. * * Sets the current element's XML schema xsi:type attribute, which * specifies the element's type name. * * Since: 2.92 */ void e_soap_message_set_element_type (ESoapMessage *msg, const gchar *xsi_type) { ESoapMessagePrivate *priv; g_return_if_fail (E_IS_SOAP_MESSAGE (msg)); priv = E_SOAP_MESSAGE_GET_PRIVATE (msg); xmlNewNsProp (priv->last_node, priv->xsi_ns, (const xmlChar *)"type", (const xmlChar *)xsi_type); }
Attr * attr__new( Element *el, unsigned char *name, unsigned char *value, Namespc *ns ) { xmlAttr *attr ; if ( ns ) attr = xmlNewNsProp(( xmlNode* ) el, ( xmlNs* ) ns, name, value ) ; else attr = xmlNewProp(( xmlNode* ) el, name, value ) ; return ( Attr* ) attr ; }
xmlNodePtr msOWSCommonExceptionReport(xmlNsPtr psNsOws, int ows_version, const char *schemas_location, const char *version, const char *language, const char *exceptionCode, const char *locator, const char *ExceptionText) { char *xsi_schemaLocation = NULL; char szVersionBuf[OWS_VERSION_MAXLEN]; xmlNsPtr psNsXsi = NULL; xmlNodePtr psRootNode = NULL; xmlNodePtr psMainNode = NULL; psRootNode = xmlNewNode(psNsOws, BAD_CAST "ExceptionReport"); psNsXsi = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_PREFIX); /* add attributes to root element */ xmlNewProp(psRootNode, BAD_CAST "version", BAD_CAST version); if (ows_version == OWS_1_0_0) { xmlNewProp(psRootNode, BAD_CAST "language", BAD_CAST language); } if (ows_version == OWS_1_1_0) { xmlNewProp(psRootNode, BAD_CAST "xml:lang", BAD_CAST language); } xsi_schemaLocation = msStrdup((char *)psNsOws->href); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, " "); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, (char *)schemas_location); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, "/ows/"); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, (char *)msOWSGetVersionString(ows_version, szVersionBuf)); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, "/owsExceptionReport.xsd"); /* add namespace'd attributes to root element */ xmlNewNsProp(psRootNode, psNsXsi, BAD_CAST "schemaLocation", BAD_CAST xsi_schemaLocation); /* add child element */ psMainNode = xmlNewChild(psRootNode, NULL, BAD_CAST "Exception", NULL); /* add attributes to child */ xmlNewProp(psMainNode, BAD_CAST "exceptionCode", BAD_CAST exceptionCode); if (locator != NULL) { xmlNewProp(psMainNode, BAD_CAST "locator", BAD_CAST locator); } if (ExceptionText != NULL) { xmlNewChild(psMainNode, NULL, BAD_CAST "ExceptionText", BAD_CAST ExceptionText); } free(xsi_schemaLocation); return psRootNode; }
xmlNodePtr generation_callback(void * handle, xmlNodePtr node, void* ctxt) { printf("\noooooooooooo %s: %p\n", __FUNCTION__, handle); xmlSetTreeDoc(node, (xmlDocPtr)ctxt); if (xmlStrEqual(node->name, BAD_CAST "people")) xmlDocSetRootElement(node->doc, node); dump_doc(node->doc, node); if (xmlStrEqual(node->name, BAD_CAST "fname")) { printf("here!\n"); return (xmlNodePtr) xmlNewNsProp(node->parent, node->ns, node->name, BAD_CAST "bob"); } return node; }
int xml_node_add_attr(struct xml_node_ctx *ctx, xml_node_t *node, xml_namespace_t *ns, const char *name, const char *value) { xmlAttrPtr attr; if (ns) { attr = xmlNewNsProp((xmlNodePtr) node, (xmlNsPtr) ns, (const xmlChar *) name, (const xmlChar *) value); } else { attr = xmlNewProp((xmlNodePtr) node, (const xmlChar *) name, (const xmlChar *) value); } return attr ? 0 : -1; }
/** * e_soap_message_add_attribute: * @msg: the #ESoapMessage. * @name: name of the attribute * @value: value of the attribute * @prefix: the namespace prefix * @ns_uri: the namespace URI * * Adds an XML attribute to the current element. * * Since: 2.92 */ void e_soap_message_add_attribute (ESoapMessage *msg, const gchar *name, const gchar *value, const gchar *prefix, const gchar *ns_uri) { ESoapMessagePrivate *priv; g_return_if_fail (E_IS_SOAP_MESSAGE (msg)); priv = E_SOAP_MESSAGE_GET_PRIVATE (msg); xmlNewNsProp (priv->last_node, fetch_ns (msg, prefix, ns_uri), (const xmlChar *) name, (const xmlChar *) value); }
/* * call-seq: * attr.initialize(node, "name", "value") * * Creates a new attribute for the node. * * node: The XML::Node that will contain the attribute * name: The name of the attribute * value: The value of the attribute * * attr = XML::Attr.new(doc.root, 'name', 'libxml') */ static VALUE rxml_attr_initialize(int argc, VALUE *argv, VALUE self) { VALUE node = argv[0]; VALUE name = argv[1]; VALUE value = argv[2]; VALUE ns = (argc == 4 ? argv[3] : Qnil); xmlNodePtr xnode; xmlAttrPtr xattr; if (argc < 3 || argc > 4) rb_raise(rb_eArgError, "Wrong number of arguments (3 or 4)"); Check_Type(name, T_STRING); Check_Type(value, T_STRING); Data_Get_Struct(node, xmlNode, xnode); if (xnode->type != XML_ELEMENT_NODE) rb_raise(rb_eArgError, "Attributes can only be created on element nodes."); if (NIL_P(ns)) { xattr = xmlNewProp(xnode, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value)); } else { xmlNsPtr xns; Data_Get_Struct(ns, xmlNs, xns); xattr = xmlNewNsProp(xnode, xns, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value)); } if (!xattr) rb_raise(rb_eRuntimeError, "Could not create attribute."); xattr->_private = (void *) self; DATA_PTR( self) = xattr; return self; }
/** * xsltAttrTemplateProcess: * @ctxt: the XSLT transformation context * @target: the element where the attribute will be grafted * @attr: the attribute node of a literal result element * * Process one attribute of a Literal Result Element (in the stylesheet). * Evaluates Attribute Value Templates and copies the attribute over to * the result element. * This does *not* process attribute sets (xsl:use-attribute-set). * * * Returns the generated attribute node. */ xmlAttrPtr xsltAttrTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target, xmlAttrPtr attr) { const xmlChar *value; xmlAttrPtr ret; if ((ctxt == NULL) || (attr == NULL) || (target == NULL)) return(NULL); if (attr->type != XML_ATTRIBUTE_NODE) return(NULL); /* * Skip all XSLT attributes. */ #ifdef XSLT_REFACTORED if (attr->psvi == xsltXSLTAttrMarker) return(NULL); #else if ((attr->ns != NULL) && xmlStrEqual(attr->ns->href, XSLT_NAMESPACE)) return(NULL); #endif /* * Get the value. */ if (attr->children != NULL) { if ((attr->children->type != XML_TEXT_NODE) || (attr->children->next != NULL)) { xsltTransformError(ctxt, NULL, attr->parent, "Internal error: The children of an attribute node of a " "literal result element are not in the expected form.\n"); return(NULL); } value = attr->children->content; if (value == NULL) value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0); } else value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0); /* * Overwrite duplicates. */ ret = target->properties; while (ret != NULL) { if (((attr->ns != NULL) == (ret->ns != NULL)) && xmlStrEqual(ret->name, attr->name) && ((attr->ns == NULL) || xmlStrEqual(ret->ns->href, attr->ns->href))) { break; } ret = ret->next; } if (ret != NULL) { /* free the existing value */ xmlFreeNodeList(ret->children); ret->children = ret->last = NULL; /* * Adjust ns-prefix if needed. */ if ((ret->ns != NULL) && (! xmlStrEqual(ret->ns->prefix, attr->ns->prefix))) { ret->ns = xsltGetNamespace(ctxt, attr->parent, attr->ns, target); } } else { /* create a new attribute */ if (attr->ns != NULL) ret = xmlNewNsProp(target, xsltGetNamespace(ctxt, attr->parent, attr->ns, target), attr->name, NULL); else ret = xmlNewNsProp(target, NULL, attr->name, NULL); } /* * Set the value. */ if (ret != NULL) { xmlNodePtr text; text = xmlNewText(NULL); if (text != NULL) { ret->last = ret->children = text; text->parent = (xmlNodePtr) ret; text->doc = ret->doc; if (attr->psvi != NULL) { /* * Evaluate the Attribute Value Template. */ xmlChar *val; val = xsltEvalAVT(ctxt, attr->psvi, attr->parent); if (val == NULL) { /* * TODO: Damn, we need an easy mechanism to report * qualified names! */ if (attr->ns) { xsltTransformError(ctxt, NULL, attr->parent, "Internal error: Failed to evaluate the AVT " "of attribute '{%s}%s'.\n", attr->ns->href, attr->name); } else { xsltTransformError(ctxt, NULL, attr->parent, "Internal error: Failed to evaluate the AVT " "of attribute '%s'.\n", attr->name); } text->content = xmlStrdup(BAD_CAST ""); } else { text->content = val; } } else if ((ctxt->internalized) && (target != NULL) && (target->doc != NULL) && (target->doc->dict == ctxt->dict) && xmlDictOwns(ctxt->dict, value)) { text->content = (xmlChar *) value; } else { text->content = xmlStrdup(value); } } } else { if (attr->ns) { xsltTransformError(ctxt, NULL, attr->parent, "Internal error: Failed to create attribute '{%s}%s'.\n", attr->ns->href, attr->name); } else { xsltTransformError(ctxt, NULL, attr->parent, "Internal error: Failed to create attribute '%s'.\n", attr->name); } } return(ret); }
int msWFSGetCapabilities11(mapObj *map, wfsParamsObj *params, cgiRequestObj *req, owsRequestObj *ows_request) { xmlDocPtr psDoc = NULL; /* document pointer */ xmlNodePtr psRootNode, psMainNode, psNode, psFtNode; const char *updatesequence=NULL; xmlNsPtr psNsOws, psNsXLink, psNsOgc; char *schemalocation = NULL; char *xsi_schemaLocation = NULL; const char *user_namespace_prefix = NULL; const char *user_namespace_uri = NULL; gmlNamespaceListObj *namespaceList=NULL; /* for external application schema support */ char *script_url=NULL, *formats_list; const char *value = NULL; xmlChar *buffer = NULL; int size = 0, i; msIOContext *context = NULL; int ows_version = OWS_1_0_0; int ret; /* -------------------------------------------------------------------- */ /* Handle updatesequence */ /* -------------------------------------------------------------------- */ ret = msWFSHandleUpdateSequence(map, params, "msWFSGetCapabilities11()"); if( ret != MS_SUCCESS ) return ret; /* -------------------------------------------------------------------- */ /* Create document. */ /* -------------------------------------------------------------------- */ psDoc = xmlNewDoc(BAD_CAST "1.0"); psRootNode = xmlNewNode(NULL, BAD_CAST "WFS_Capabilities"); xmlDocSetRootElement(psDoc, psRootNode); /* -------------------------------------------------------------------- */ /* Name spaces */ /* -------------------------------------------------------------------- */ /*default name space*/ xmlNewProp(psRootNode, BAD_CAST "xmlns", BAD_CAST "http://www.opengis.net/wfs"); xmlSetNs(psRootNode, xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/gml", BAD_CAST "gml")); xmlSetNs(psRootNode, xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/wfs", BAD_CAST "wfs")); psNsOws = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_PREFIX); psNsXLink = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_W3C_XLINK_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_W3C_XLINK_NAMESPACE_PREFIX); xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_PREFIX); xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_PREFIX ); value = msOWSLookupMetadata(&(map->web.metadata), "FO", "namespace_uri"); if(value) user_namespace_uri = value; value = msOWSLookupMetadata(&(map->web.metadata), "FO", "namespace_prefix"); if(value) user_namespace_prefix = value; if(user_namespace_prefix != NULL && msIsXMLTagValid(user_namespace_prefix) == MS_FALSE) msIO_printf("<!-- WARNING: The value '%s' is not valid XML namespace. -->\n", user_namespace_prefix); else xmlNewNs(psRootNode, BAD_CAST user_namespace_uri, BAD_CAST user_namespace_prefix); /* any additional namespaces */ namespaceList = msGMLGetNamespaces(&(map->web), "G"); for(i=0; i<namespaceList->numnamespaces; i++) { if(namespaceList->namespaces[i].uri) { xmlNewNs(psRootNode, BAD_CAST namespaceList->namespaces[i].uri, BAD_CAST namespaceList->namespaces[i].prefix); } } msGMLFreeNamespaces(namespaceList); xmlNewProp(psRootNode, BAD_CAST "version", BAD_CAST params->pszVersion ); updatesequence = msOWSLookupMetadata(&(map->web.metadata), "FO", "updatesequence"); if (updatesequence) xmlNewProp(psRootNode, BAD_CAST "updateSequence", BAD_CAST updatesequence); /*schema*/ schemalocation = msEncodeHTMLEntities( msOWSGetSchemasLocation(map) ); xsi_schemaLocation = msStrdup("http://www.opengis.net/wfs"); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, " "); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, schemalocation); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, "/wfs/1.1.0/wfs.xsd"); xmlNewNsProp(psRootNode, NULL, BAD_CAST "xsi:schemaLocation", BAD_CAST xsi_schemaLocation); /* -------------------------------------------------------------------- */ /* Service metadata. */ /* -------------------------------------------------------------------- */ xmlAddChild(psRootNode, msOWSCommonServiceIdentification(psNsOws, map, "OGC WFS", params->pszVersion, "FO", NULL)); /*service provider*/ xmlAddChild(psRootNode, msOWSCommonServiceProvider( psNsOws, psNsXLink, map, "FO", NULL)); /*operation metadata */ if ((script_url=msOWSGetOnlineResource(map, "FO", "onlineresource", req)) == NULL) { msSetError(MS_WFSERR, "Server URL not found", "msWFSGetCapabilities11()"); return msWFSException11(map, "mapserv", MS_OWS_ERROR_NO_APPLICABLE_CODE, params->pszVersion); } /* -------------------------------------------------------------------- */ /* Operations metadata. */ /* -------------------------------------------------------------------- */ psMainNode= xmlAddChild(psRootNode,msOWSCommonOperationsMetadata(psNsOws)); /* -------------------------------------------------------------------- */ /* GetCapabilities */ /* -------------------------------------------------------------------- */ psNode = xmlAddChild(psMainNode, msOWSCommonOperationsMetadataOperation(psNsOws,psNsXLink,"GetCapabilities", OWS_METHOD_GETPOST, script_url)); xmlAddChild(psMainNode, psNode); xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType( ows_version, psNsOws, "Parameter", "service", "WFS")); /*accept version*/ xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "AcceptVersions", "1.0.0,1.1.0")); /*format*/ xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "AcceptFormats", "text/xml")); /* -------------------------------------------------------------------- */ /* DescribeFeatureType */ /* -------------------------------------------------------------------- */ if (msOWSRequestIsEnabled(map, NULL, "F", "DescribeFeatureType", MS_TRUE)) { psNode = xmlAddChild(psMainNode, msOWSCommonOperationsMetadataOperation(psNsOws,psNsXLink,"DescribeFeatureType", OWS_METHOD_GETPOST, script_url)); xmlAddChild(psMainNode, psNode); /*output format*/ xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "outputFormat", "XMLSCHEMA,text/xml; subtype=gml/2.1.2,text/xml; subtype=gml/3.1.1")); } /* -------------------------------------------------------------------- */ /* GetFeature */ /* -------------------------------------------------------------------- */ if (msOWSRequestIsEnabled(map, NULL, "F", "GetFeature", MS_TRUE)) { psNode = xmlAddChild(psMainNode, msOWSCommonOperationsMetadataOperation(psNsOws,psNsXLink,"GetFeature", OWS_METHOD_GETPOST, script_url)); xmlAddChild(psMainNode, psNode); xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "resultType", "results,hits")); formats_list = msWFSGetOutputFormatList( map, NULL, OWS_1_1_0 ); xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "outputFormat", formats_list)); msFree( formats_list ); value = msOWSLookupMetadata(&(map->web.metadata), "FO", "maxfeatures"); if (value) { xmlAddChild(psMainNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Constraint", "DefaultMaxFeatures", (char *)value)); } } /* -------------------------------------------------------------------- */ /* FeatureTypeList */ /* -------------------------------------------------------------------- */ psFtNode = xmlNewNode(NULL, BAD_CAST "FeatureTypeList"); xmlAddChild(psRootNode, psFtNode); psNode = xmlNewChild(psFtNode, NULL, BAD_CAST "Operations", NULL); xmlNewChild(psNode, NULL, BAD_CAST "Operation", BAD_CAST "Query"); for(i=0; i<map->numlayers; i++) { layerObj *lp; lp = GET_LAYER(map, i); if (!msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers)) continue; /* List only vector layers in which DUMP=TRUE */ if (msWFSIsLayerSupported(lp)) xmlAddChild(psFtNode, msWFSDumpLayer11(map, lp, psNsOws, OWS_1_1_0, NULL)); } /* -------------------------------------------------------------------- */ /* Filter capabilities. */ /* -------------------------------------------------------------------- */ psNsOgc = xmlNewNs(NULL, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_PREFIX); xmlAddChild(psRootNode, FLTGetCapabilities(psNsOgc, psNsOgc, MS_FALSE)); /* -------------------------------------------------------------------- */ /* Write out the document. */ /* -------------------------------------------------------------------- */ if( msIO_needBinaryStdout() == MS_FAILURE ) return MS_FAILURE; msIO_setHeader("Content-Type","text/xml; charset=UTF-8"); msIO_sendHeaders(); context = msIO_getHandler(stdout); xmlDocDumpFormatMemoryEnc(psDoc, &buffer, &size, ("UTF-8"), 1); msIO_contextWrite(context, buffer, size); xmlFree(buffer); /*free buffer and the document */ /*xmlFree(buffer);*/ xmlFreeDoc(psDoc); xmlFreeNs(psNsOgc); free(script_url); free(xsi_schemaLocation); free(schemalocation); xmlCleanupParser(); return(MS_SUCCESS); }
int EBC_Provider_XchgPubRequest_H002(AB_PROVIDER *pro, GWEN_HTTP_SESSION *sess, AB_USER *u, const char *signVersion) { EBC_PROVIDER *dp; int rv; const char *userId; const char *partnerId; GWEN_BUFFER *bufKey; GWEN_CRYPT_TOKEN *ct; const GWEN_CRYPT_TOKEN_CONTEXT *ctx; uint32_t kid; const GWEN_CRYPT_TOKEN_KEYINFO *signKeyInfo=NULL; assert(pro); dp=GWEN_INHERIT_GETDATA(AB_PROVIDER, EBC_PROVIDER, pro); assert(dp); userId=AB_User_GetUserId(u); partnerId=AB_User_GetCustomerId(u); /* get crypt token and context */ rv=EBC_Provider_MountToken(pro, u, &ct, &ctx); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); return rv; } /* get crypt key info */ kid=GWEN_Crypt_Token_Context_GetTempSignKeyId(ctx); if (kid) { signKeyInfo=GWEN_Crypt_Token_GetKeyInfo(ct, kid, GWEN_CRYPT_TOKEN_KEYFLAGS_HASMODULUS | GWEN_CRYPT_TOKEN_KEYFLAGS_HASEXPONENT | GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYVERSION | GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYNUMBER, 0); if (signKeyInfo==NULL) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Sign key info not found on crypt token"); GWEN_Gui_ProgressLog(0, GWEN_LoggerLevel_Error, I18N("Sign key info not found on crypt token")); return GWEN_ERROR_NOT_FOUND; } } if (strcasecmp(signVersion, "A004")==0) { EB_RC rc; /* encode according to "DFUE-Abkommen" */ bufKey=GWEN_Buffer_new(0, 512, 0, 1); rc=EB_Key_Info_toBin(signKeyInfo, userId, "A004", 1024, bufKey); if (rc) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error writing key (rc=%06x)", rc); GWEN_Buffer_free(bufKey); return GWEN_ERROR_GENERIC; } } else { xmlDocPtr doc; xmlNodePtr root_node = NULL; xmlNodePtr node = NULL; xmlNsPtr ns; /* create INIRequestOrderData */ doc=xmlNewDoc(BAD_CAST "1.0"); doc->encoding=xmlCharStrdup("UTF-8"); root_node=xmlNewNode(NULL, BAD_CAST "PUBRequestOrderData"); xmlDocSetRootElement(doc, root_node); ns=xmlNewNs(root_node, BAD_CAST "http://www.ebics.org/H002", NULL); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2000/09/xmldsig#", BAD_CAST "ds"); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2001/XMLSchema-instance", BAD_CAST "xsi"); xmlNewNsProp(root_node, ns, BAD_CAST "schemaLocation", /* xsi:schemaLocation */ BAD_CAST "http://www.ebics.org/H002 " "http://www.ebics.org/H002/ebics_orders.xsd"); /* create sign key tree */ node=xmlNewChild(root_node, NULL, BAD_CAST "SignaturePubKeyInfo", NULL); rv=EB_Key_Info_toXml(signKeyInfo, node); if (rv<0) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error response: (%d)", rv); xmlFreeDoc(doc); return GWEN_ERROR_INVALID; } xmlNewChild(node, NULL, BAD_CAST "SignatureVersion", BAD_CAST signVersion); /* store partner id and user id */ node=xmlNewChild(root_node, NULL, BAD_CAST "PartnerID", BAD_CAST partnerId); node=xmlNewChild(root_node, NULL, BAD_CAST "UserID", BAD_CAST userId); /* compress and base64 doc */ bufKey=GWEN_Buffer_new(0, 4096, 0, 1); rv=EB_Xml_Compress64Doc(doc, bufKey); if (rv<0) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error compressing/encoding doc (%d)", rv); xmlFreeDoc(doc); return rv; } xmlFreeDoc(doc); } rv=EBC_Provider_XchgUploadRequest(pro, sess, u, "PUB", (const uint8_t*)GWEN_Buffer_GetStart(bufKey), GWEN_Buffer_GetUsedBytes(bufKey)); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); GWEN_Buffer_free(bufKey); return rv; } GWEN_Buffer_free(bufKey); return 0; }
xmlNode *xccdf_benchmark_to_dom(struct xccdf_benchmark *benchmark, xmlDocPtr doc, xmlNode *parent, void *user_args) { xmlNodePtr root_node = xccdf_item_to_dom(XITEM(benchmark), doc, parent); if (parent == NULL) { xmlDocSetRootElement(doc, root_node); } // FIXME! //xmlNewProp(root_node, BAD_CAST "xsi:schemaLocation", BAD_CAST XCCDF_SCHEMA_LOCATION); lookup_xsi_ns(doc); /* Handle attributes */ if (xccdf_benchmark_get_resolved(benchmark)) xmlNewProp(root_node, BAD_CAST "resolved", BAD_CAST "1"); else xmlNewProp(root_node, BAD_CAST "resolved", BAD_CAST "0"); const char *xmllang = xccdf_benchmark_get_lang(benchmark); if (xmllang) { xmlNs *ns_xml = xmlSearchNsByHref(doc, root_node, OSCAP_XML_XSI); if (ns_xml == NULL) { ns_xml = xmlNewNs(root_node, OSCAP_XML_XSI, BAD_CAST "xml"); } xmlNewNsProp(root_node, ns_xml, BAD_CAST "lang", BAD_CAST xmllang); } const char *style = xccdf_benchmark_get_style(benchmark); if (style) xmlNewProp(root_node, BAD_CAST "style", BAD_CAST style); const char *style_href = xccdf_benchmark_get_style_href(benchmark); if (style_href) xmlNewProp(root_node, BAD_CAST "style-href", BAD_CAST style_href); // Export plain-text elements struct xccdf_plain_text_iterator *plain_text_it = xccdf_benchmark_get_plain_texts(benchmark); while (xccdf_plain_text_iterator_has_more(plain_text_it)) { struct xccdf_plain_text *plain_text = xccdf_plain_text_iterator_next(plain_text_it); xccdf_plain_text_to_dom(plain_text, doc, root_node, xccdf_benchmark_get_schema_version(benchmark)); } xccdf_plain_text_iterator_free(plain_text_it); /* Handle children */ if (xccdf_benchmark_get_cpe_list(benchmark)) { // CPE API can only export via xmlTextWriter, we export via DOM // this is used to bridge both methods xmlTextWriterPtr writer = xmlNewTextWriterTree(doc, root_node, 0); cpe_dict_export(xccdf_benchmark_get_cpe_list(benchmark), writer); xmlFreeTextWriter(writer); } if (xccdf_benchmark_get_cpe_lang_model(benchmark)) { // CPE API can only export via xmlTextWriter, we export via DOM // this is used to bridge both methods xmlTextWriterPtr writer = xmlNewTextWriterTree(doc, root_node, 0); cpe_lang_export(xccdf_benchmark_get_cpe_lang_model(benchmark), writer); xmlFreeTextWriter(writer); } xmlNs *ns_xccdf = lookup_xccdf_ns(doc, root_node, xccdf_benchmark_get_schema_version(benchmark)); struct oscap_string_iterator *platforms = xccdf_benchmark_get_platforms(benchmark); while (oscap_string_iterator_has_more(platforms)) { xmlNode *platform_node = xmlNewTextChild(root_node, ns_xccdf, BAD_CAST "platform", NULL); const char *idref = oscap_string_iterator_next(platforms); if (idref) xmlNewProp(platform_node, BAD_CAST "idref", BAD_CAST idref); } oscap_string_iterator_free(platforms); const char *version = xccdf_benchmark_get_version(benchmark); if (version) xmlNewTextChild(root_node, ns_xccdf, BAD_CAST "version", BAD_CAST version); struct oscap_string_iterator* metadata = xccdf_item_get_metadata(XITEM(benchmark)); while (oscap_string_iterator_has_more(metadata)) { const char* meta = oscap_string_iterator_next(metadata); xmlNode *m = oscap_xmlstr_to_dom(root_node, "metadata", meta); xmlSetNs(m, ns_xccdf); } oscap_string_iterator_free(metadata); OSCAP_FOR(xccdf_model, model, xccdf_benchmark_get_models(benchmark)) { xmlNode *model_node = xmlNewTextChild(root_node, ns_xccdf, BAD_CAST "model", NULL); xmlNewProp(model_node, BAD_CAST "system", BAD_CAST xccdf_model_get_system(model)); }
xmlNodePtr msOWSCommonServiceProvider(xmlNsPtr psNsOws, xmlNsPtr psNsXLink, mapObj *map, const char *namespaces) { const char *value = NULL; xmlNodePtr psNode = NULL; xmlNodePtr psRootNode = NULL; xmlNodePtr psSubNode = NULL; xmlNodePtr psSubSubNode = NULL; xmlNodePtr psSubSubSubNode = NULL; if (_validateNamespace(psNsOws) == MS_FAILURE) psNsOws = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_PREFIX); psRootNode = xmlNewNode(psNsOws, BAD_CAST "ServiceProvider"); /* add child elements */ value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "contactorganization"); psNode = xmlNewChild(psRootNode, psNsOws, BAD_CAST "ProviderName", BAD_CAST value); if (!value) { xmlAddSibling(psNode, xmlNewComment(BAD_CAST "WARNING: Mandatory metadata \"ows_contactorganization\" was missing for ows:ProviderName")); } psNode = xmlNewChild(psRootNode, psNsOws, BAD_CAST "ProviderSite", NULL); xmlNewNsProp(psNode, psNsXLink, BAD_CAST "type", BAD_CAST "simple"); value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "service_onlineresource"); xmlNewNsProp(psNode, psNsXLink, BAD_CAST "href", BAD_CAST value); if (!value) { xmlAddSibling(psNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_service_onlineresource\" was missing for ows:ProviderSite/@xlink:href")); } psNode = xmlNewChild(psRootNode, psNsOws, BAD_CAST "ServiceContact", NULL); value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "contactperson"); psSubNode = xmlNewChild(psNode, psNsOws, BAD_CAST "IndividualName", BAD_CAST value); if (!value) { xmlAddSibling(psSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_contactperson\" was missing for ows:IndividualName")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "contactposition"); psSubNode = xmlNewChild(psNode, psNsOws, BAD_CAST "PositionName", BAD_CAST value); if (!value) { xmlAddSibling(psSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_contactposition\" was missing for ows:PositionName")); } psSubNode = xmlNewChild(psNode, psNsOws, BAD_CAST "ContactInfo", NULL); psSubSubNode = xmlNewChild(psSubNode, psNsOws, BAD_CAST "Phone", NULL); value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "contactvoicetelephone"); psSubSubSubNode = xmlNewChild(psSubSubNode, psNsOws, BAD_CAST "Voice", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_contactvoicetelephone\" was missing for ows:Voice")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "contactfacsimiletelephone"); psSubSubSubNode = xmlNewChild(psSubSubNode, psNsOws, BAD_CAST "Facsimile", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_contactfacsimiletelephone\" was missing for ows:Facsimile")); } psSubSubNode = xmlNewChild(psSubNode, psNsOws, BAD_CAST "Address", NULL); value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "address"); psSubSubSubNode = xmlNewChild(psSubSubNode, psNsOws, BAD_CAST "DeliveryPoint", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_address\" was missing for ows:DeliveryPoint")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "city"); psSubSubSubNode = xmlNewChild(psSubSubNode, psNsOws, BAD_CAST "City", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_city\" was missing for ows:City")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "stateorprovince"); psSubSubSubNode = xmlNewChild(psSubSubNode, psNsOws, BAD_CAST "AdministrativeArea", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_stateorprovince\" was missing for ows:AdministrativeArea")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "postcode"); psSubSubSubNode = xmlNewChild(psSubSubNode, psNsOws, BAD_CAST "PostalCode", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_postcode\" was missing for ows:PostalCode")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "country"); psSubSubSubNode = xmlNewChild(psSubSubNode, psNsOws, BAD_CAST "Country", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_country\" was missing for ows:Country")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "contactelectronicmailaddress"); psSubSubSubNode = xmlNewChild(psSubSubNode, psNsOws, BAD_CAST "ElectronicMailAddress", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_contactelectronicmailaddress\" was missing for ows:ElectronicMailAddress")); } psSubSubNode = xmlNewChild(psSubNode, psNsOws, BAD_CAST "OnlineResource", NULL); xmlNewNsProp(psSubSubNode, psNsXLink, BAD_CAST "type", BAD_CAST "simple"); value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "service_onlineresource"); xmlNewNsProp(psSubSubNode, psNsXLink, BAD_CAST "href", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_service_onlineresource\" was missing for ows:OnlineResource/@xlink:href")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "hoursofservice"); psSubSubNode = xmlNewChild(psSubNode, psNsOws, BAD_CAST "HoursOfService", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_hoursofservice\" was missing for ows:HoursOfService")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "contactinstructions"); psSubSubNode = xmlNewChild(psSubNode, psNsOws, BAD_CAST "ContactInstructions", BAD_CAST value); if (!value) { xmlAddSibling(psSubSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_contactinstructions\" was missing for ows:ContactInstructions")); } value = msOWSLookupMetadata(&(map->web.metadata), namespaces, "role"); psSubNode = xmlNewChild(psNode, psNsOws, BAD_CAST "Role", BAD_CAST value); if (!value) { xmlAddSibling(psSubNode, xmlNewComment(BAD_CAST "WARNING: Optional metadata \"ows_role\" was missing for ows:Role")); } return psRootNode; }
int EBC_Provider_MkEuZipDoc_A004(AB_PROVIDER *pro, AB_USER *u, const char *requestType, const uint8_t *pMsg, uint32_t lMsg, GWEN_BUFFER *sbuf) { int rv; xmlDocPtr doc; xmlNodePtr root_node; xmlNodePtr node; xmlNsPtr ns; GWEN_BUFFER *tbuf; GWEN_BUFFER *bbuf; tbuf=GWEN_Buffer_new(0, 256, 0, 1); rv=EBC_Provider_EuSign_A004(pro, u, requestType, pMsg, lMsg, tbuf); if (rv) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); GWEN_Buffer_free(tbuf); return rv; } bbuf=GWEN_Buffer_new(0, (GWEN_Buffer_GetUsedBytes(tbuf)*3)/2, 0, 1); rv=GWEN_Base64_Encode((const uint8_t*)GWEN_Buffer_GetStart(tbuf), GWEN_Buffer_GetUsedBytes(tbuf), bbuf, 0); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); GWEN_Buffer_free(bbuf); GWEN_Buffer_free(tbuf); return rv; } GWEN_Buffer_free(tbuf); doc=xmlNewDoc(BAD_CAST "1.0"); root_node=xmlNewNode(NULL, BAD_CAST "UserSignatureData"); xmlDocSetRootElement(doc, root_node); ns=xmlNewNs(root_node, BAD_CAST "http://www.ebics.org/H002", NULL); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2001/XMLSchema-instance", BAD_CAST "xsi"); xmlNewNsProp(root_node, ns, BAD_CAST "schemaLocation", /* xsi:schemaLocation */ BAD_CAST "http://www.ebics.org/H002 " "http://www.ebics.org/H002/ebics_orders.xsd"); node=xmlNewTextChild(root_node, NULL, BAD_CAST "OrderSignature", BAD_CAST GWEN_Buffer_GetStart(bbuf)); GWEN_Buffer_free(bbuf); xmlNewProp(node, BAD_CAST "PartnerID", BAD_CAST AB_User_GetCustomerId(u)); rv=EB_Xml_CompressDoc(doc, sbuf); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); xmlFreeDoc(doc); return rv; } xmlFreeDoc(doc); return 0; }
int EBC_Provider_XchgIniRequest_H002(AB_PROVIDER *pro, GWEN_HTTP_SESSION *sess, AB_USER *u) { int rv; GWEN_CRYPT_TOKEN *ct; const GWEN_CRYPT_TOKEN_CONTEXT *ctx; uint32_t kid; const GWEN_CRYPT_TOKEN_KEYINFO *signKeyInfo=NULL; xmlNsPtr ns; EB_MSG *msg; const char *userId; EB_MSG *mRsp; EB_RC rc; xmlDocPtr doc; xmlNodePtr root_node = NULL; xmlNodePtr node = NULL; GWEN_BUFFER *tbuf; const char *signVersion; const char *s; GWEN_BUFFER *bufKey; GWEN_BUFFER *bufZip; GWEN_BUFFER *bufB64; userId=AB_User_GetUserId(u); /* get crypt token and context */ rv=EBC_Provider_MountToken(pro, u, &ct, &ctx); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); return rv; } /* get crypt key info */ kid=GWEN_Crypt_Token_Context_GetSignKeyId(ctx); if (kid) { signKeyInfo=GWEN_Crypt_Token_GetKeyInfo(ct, kid, GWEN_CRYPT_TOKEN_KEYFLAGS_HASMODULUS | GWEN_CRYPT_TOKEN_KEYFLAGS_HASEXPONENT | GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYVERSION | GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYNUMBER, 0); if (signKeyInfo==NULL) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Sign key info not found on crypt token"); GWEN_Gui_ProgressLog(0, GWEN_LoggerLevel_Error, I18N("Sign key info not found on crypt token")); return GWEN_ERROR_NOT_FOUND; } } signVersion=EBC_User_GetSignVersion(u); if (!(signVersion && *signVersion)) signVersion="A004"; if (strcasecmp(signVersion, "A004")==0) { /* encode according to "DFUE-Abkommen" */ bufKey=GWEN_Buffer_new(0, 512, 0, 1); rc=EB_Key_Info_toBin(signKeyInfo, userId, "A004", 1024, bufKey); if (rc) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error writing key (rc=%06x)", rc); GWEN_Buffer_free(bufKey); return GWEN_ERROR_GENERIC; } /* zip order */ bufZip=GWEN_Buffer_new(0, 512, 0, 1); if (EB_Zip_Deflate(GWEN_Buffer_GetStart(bufKey), GWEN_Buffer_GetUsedBytes(bufKey), bufZip)) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Unable to zip key data"); GWEN_Buffer_free(bufZip); GWEN_Buffer_free(bufKey); return GWEN_ERROR_GENERIC; } GWEN_Buffer_free(bufKey); /* base64 encode for order */ bufB64=GWEN_Buffer_new(0, 800, 0, 1); if (GWEN_Base64_Encode((const unsigned char *)GWEN_Buffer_GetStart(bufZip), GWEN_Buffer_GetUsedBytes(bufZip), bufB64, 0)) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error encoding key"); GWEN_Buffer_free(bufB64); GWEN_Buffer_free(bufZip); return GWEN_ERROR_GENERIC; } GWEN_Buffer_free(bufZip); } else { DBG_ERROR(AQEBICS_LOGDOMAIN, "Unsupported sign version [%s]", signVersion); return GWEN_ERROR_INTERNAL; } /* create request */ msg=EB_Msg_new(); doc=EB_Msg_GetDoc(msg); root_node=xmlNewNode(NULL, BAD_CAST "ebicsUnsecuredRequest"); xmlDocSetRootElement(doc, root_node); ns=xmlNewNs(root_node, BAD_CAST "http://www.ebics.org/H002", NULL); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2000/09/xmldsig#", BAD_CAST "ds"); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2001/XMLSchema-instance", BAD_CAST "xsi"); xmlNewNsProp(root_node, ns, BAD_CAST "schemaLocation", /* xsi:schemaLocation */ BAD_CAST "http://www.ebics.org/H002 " "http://www.ebics.org/H002/ebics_keymgmt_request.xsd"); xmlNewProp(root_node, BAD_CAST "Version", BAD_CAST "H002"); xmlNewProp(root_node, BAD_CAST "Revision", BAD_CAST "1"); /* header */ node=xmlNewChild(root_node, NULL, BAD_CAST "header", NULL); xmlNewProp(node, BAD_CAST "authenticate", BAD_CAST "true"); xmlNewChild(node, NULL, BAD_CAST "static", NULL); xmlNewChild(node, NULL, BAD_CAST "mutable", NULL); /* body */ node=xmlNewChild(root_node, NULL, BAD_CAST "body", NULL); /* fill */ s=EBC_User_GetPeerId(u); if (s) EB_Msg_SetCharValue(msg, "header/static/HostID", s); s=AB_User_GetCustomerId(u); if (s) EB_Msg_SetCharValue(msg, "header/static/PartnerID", s); EB_Msg_SetCharValue(msg, "header/static/UserID", AB_User_GetUserId(u)); EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderType", "INI"); tbuf=GWEN_Buffer_new(0, 16, 0, 1); rv=EBC_Provider_Generate_OrderId(pro, tbuf); if (rv<0) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error creating order id (%d)", rv); GWEN_Buffer_free(tbuf); GWEN_Buffer_free(bufB64); EB_Msg_free(msg); return rv; } EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderID", GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_free(tbuf); EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderAttribute", "DZNNN"); EB_Msg_SetCharValue(msg, "header/static/SecurityMedium", "0000"); EB_Msg_SetCharValue(msg, "body/DataTransfer/OrderData", GWEN_Buffer_GetStart(bufB64)); GWEN_Buffer_free(bufB64); /* exchange requests */ rv=EBC_Dialog_ExchangeMessages(sess, msg, &mRsp); if (rv<0 || rv>=300) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error exchanging messages (%d)", rv); EB_Msg_free(msg); return rv; } EB_Msg_free(msg); /* check response */ assert(mRsp); /* log results */ EBC_Provider_LogRequestResults(pro, mRsp, NULL); rc=EB_Msg_GetResultCode(mRsp); if ((rc & 0xff0000)==0x090000 || (rc & 0xff0000)==0x060000) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error response: (%06x)", rc); EB_Msg_free(mRsp); return AB_ERROR_SECURITY; } rc=EB_Msg_GetBodyResultCode(mRsp); if (rc) { if ((rc & 0xff0000)==0x090000 || (rc & 0xff0000)==0x060000) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error response: (%06x)", rc); EB_Msg_free(mRsp); if ((rc & 0xfff00)==0x091300 || (rc & 0xfff00)==0x091200) return AB_ERROR_SECURITY; else return GWEN_ERROR_GENERIC; } } EB_Msg_free(mRsp); /* adjust user status and flags */ DBG_NOTICE(AQEBICS_LOGDOMAIN, "Adjusting user flags"); EBC_User_AddFlags(u, EBC_USER_FLAGS_INI); if ((EBC_User_GetFlags(u) & (EBC_USER_FLAGS_INI | EBC_USER_FLAGS_HIA)) == (EBC_USER_FLAGS_INI | EBC_USER_FLAGS_HIA)) EBC_User_SetStatus(u, EBC_UserStatus_Init2); else EBC_User_SetStatus(u, EBC_UserStatus_Init1); return 0; }
xmlNode *oval_definition_model_to_dom(struct oval_definition_model *definition_model, xmlDocPtr doc, xmlNode * parent) { xmlNodePtr root_node = NULL; if (parent) { /* result file */ root_node = xmlNewTextChild(parent, NULL, BAD_CAST OVAL_ROOT_ELM_DEFINITIONS, NULL); } else { /* definitions file, we are the root */ root_node = xmlNewNode(NULL, BAD_CAST OVAL_ROOT_ELM_DEFINITIONS); xmlDocSetRootElement(doc, root_node); } xmlNewNsProp(root_node, lookup_xsi_ns(doc), BAD_CAST "schemaLocation", BAD_CAST definition_model->schema); xmlNs *ns_common = xmlNewNs(root_node, OVAL_COMMON_NAMESPACE, BAD_CAST "oval"); xmlNs *ns_unix = xmlNewNs(root_node, OVAL_DEFINITIONS_UNIX_NS, BAD_CAST "unix-def"); xmlNs *ns_ind = xmlNewNs(root_node, OVAL_DEFINITIONS_IND_NS, BAD_CAST "ind-def"); xmlNs *ns_lin = xmlNewNs(root_node, OVAL_DEFINITIONS_LIN_NS, BAD_CAST "lin-def"); xmlNs *ns_defntns = xmlNewNs(root_node, OVAL_DEFINITIONS_NAMESPACE, NULL); xmlSetNs(root_node, ns_common); xmlSetNs(root_node, ns_unix); xmlSetNs(root_node, ns_ind); xmlSetNs(root_node, ns_lin); xmlSetNs(root_node, ns_defntns); /* Always report the generator */ oval_generator_to_dom(definition_model->generator, doc, root_node); /* Report definitions */ struct oval_definition_iterator *definitions = oval_definition_model_get_definitions(definition_model); if (oval_definition_iterator_has_more(definitions)) { xmlNode *definitions_node = NULL; while(oval_definition_iterator_has_more(definitions)) { struct oval_definition *definition = oval_definition_iterator_next(definitions); if (definitions_node == NULL) { definitions_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "definitions", NULL); } oval_definition_to_dom(definition, doc, definitions_node); } } oval_definition_iterator_free(definitions); /* Report tests */ struct oval_test_iterator *tests = oval_definition_model_get_tests(definition_model); if (oval_test_iterator_has_more(tests)) { xmlNode *tests_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "tests", NULL); while (oval_test_iterator_has_more(tests)) { struct oval_test *test = oval_test_iterator_next(tests); oval_test_to_dom(test, doc, tests_node); } } oval_test_iterator_free(tests); /* Report objects */ struct oval_object_iterator *objects = oval_definition_model_get_objects(definition_model); if (oval_object_iterator_has_more(objects)) { xmlNode *objects_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "objects", NULL); while(oval_object_iterator_has_more(objects)) { struct oval_object *object = oval_object_iterator_next(objects); if (oval_object_get_base_obj(object)) /* Skip internal objects */ continue; oval_object_to_dom(object, doc, objects_node); } } oval_object_iterator_free(objects); /* Report states */ struct oval_state_iterator *states = oval_definition_model_get_states(definition_model); if (oval_state_iterator_has_more(states)) { xmlNode *states_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "states", NULL); while (oval_state_iterator_has_more(states)) { struct oval_state *state = oval_state_iterator_next(states); oval_state_to_dom(state, doc, states_node); } } oval_state_iterator_free(states); /* Report variables */ struct oval_variable_iterator *variables = oval_definition_model_get_variables(definition_model); if (oval_variable_iterator_has_more(variables)) { xmlNode *variables_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "variables", NULL); while (oval_variable_iterator_has_more(variables)) { struct oval_variable *variable = oval_variable_iterator_next(variables); oval_variable_to_dom(variable, doc, variables_node); } } oval_variable_iterator_free(variables); return root_node; }
/** * xsltAttrTemplateProcess: * @ctxt: the XSLT transformation context * @target: the result node * @cur: the attribute template node * * Process the given attribute and return the new processed copy. * * Returns the attribute replacement. */ xmlAttrPtr xsltAttrTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target, xmlAttrPtr cur) { const xmlChar *value; xmlNsPtr ns; xmlAttrPtr ret; if ((ctxt == NULL) || (cur == NULL) || (target == NULL)) return(NULL); if (cur->type != XML_ATTRIBUTE_NODE) return(NULL); if ((cur->children == NULL) || (cur->children->type != XML_TEXT_NODE) || (cur->children->next != NULL)) { xsltTransformError(ctxt, NULL, cur->parent, "attribute %s content problem\n", cur->name); return(NULL); } value = cur->children->content; if (value == NULL) value = xmlDictLookup(ctxt->dict, BAD_CAST "", 0); if ((cur->ns != NULL) && (xmlStrEqual(cur->ns->href, XSLT_NAMESPACE))) { if (xmlStrEqual(cur->name, (const xmlChar *)"use-attribute-sets")) { xsltApplyAttributeSet(ctxt, ctxt->node, NULL, value); } return(NULL); } ret = target->properties; while (ret != NULL) { if (xmlStrEqual(ret->name, cur->name)) { if (cur->ns == NULL) { if (ret->ns == NULL) break; } else { if ((ret->ns != NULL) && (xmlStrEqual(ret->ns->href, cur->ns->href))) break; } } ret = ret->next; } if (ret != NULL) { /* free the existing value */ xmlFreeNodeList(ret->children); ret->children = ret->last = NULL; } else { /* create a new attribute */ if (cur->ns != NULL) ns = xsltGetPlainNamespace(ctxt, cur->parent, cur->ns, target); else ns = NULL; ret = xmlNewNsProp(target, ns, cur->name, NULL); } if (ret != NULL) { xmlNodePtr text; text = xmlNewText(NULL); if (text != NULL) { ret->last = ret->children = text; text->parent = (xmlNodePtr) ret; text->doc = ret->doc; if (cur->psvi != NULL) { xmlChar *val; val = xsltEvalAVT(ctxt, cur->psvi, cur->parent); if (val == NULL) { text->content = xmlStrdup(BAD_CAST "runtime error"); } else { text->content = val; } } else if ((ctxt->internalized) && (target != NULL) && (target->doc != NULL) && (target->doc->dict == ctxt->dict)) { text->content = (xmlChar *) value; } else { text->content = xmlStrdup(value); } } } else { xsltTransformError(ctxt, NULL, cur->parent, "Failed to create attribute %s\n", cur->name); } return(ret); }
static int EBC_Provider_XchgHpbRequest_H003(AB_PROVIDER *pro, GWEN_HTTP_SESSION *sess, AB_USER *u) { EBC_PROVIDER *dp; int rv; GWEN_CRYPT_TOKEN *ct; const GWEN_CRYPT_TOKEN_CONTEXT *ctx; uint32_t keyId; xmlNsPtr ns; EB_MSG *msg; EB_MSG *mRsp; EB_RC rc; xmlDocPtr doc; xmlNodePtr root_node = NULL; xmlNodePtr node = NULL; xmlNodePtr sigNode = NULL; GWEN_BUFFER *tbuf; const char *s; assert(pro); dp=GWEN_INHERIT_GETDATA(AB_PROVIDER, EBC_PROVIDER, pro); assert(dp); /* get crypt token and context */ rv=EBC_Provider_MountToken(pro, u, &ct, &ctx); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); return rv; } /* create request */ msg=EB_Msg_new(); doc=EB_Msg_GetDoc(msg); root_node=xmlNewNode(NULL, BAD_CAST "ebicsNoPubKeyDigestsRequest"); xmlDocSetRootElement(doc, root_node); ns=xmlNewNs(root_node, BAD_CAST "http://www.ebics.org/H003", NULL); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2000/09/xmldsig#", BAD_CAST "ds"); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2001/XMLSchema-instance", BAD_CAST "xsi"); xmlNewNsProp(root_node, ns, BAD_CAST "schemaLocation", /* xsi:schemaLocation */ BAD_CAST "http://www.ebics.org/H003 " "http://www.ebics.org/H003/ebics_keymgmt_request.xsd"); xmlNewProp(root_node, BAD_CAST "Version", BAD_CAST "H003"); xmlNewProp(root_node, BAD_CAST "Revision", BAD_CAST "1"); /* header */ node=xmlNewChild(root_node, NULL, BAD_CAST "header", NULL); xmlNewProp(node, BAD_CAST "authenticate", BAD_CAST "true"); xmlNewChild(node, NULL, BAD_CAST "static", NULL); xmlNewChild(node, NULL, BAD_CAST "mutable", NULL); sigNode=xmlNewChild(root_node, NULL, BAD_CAST "AuthSignature", NULL); /* body */ node=xmlNewChild(root_node, NULL, BAD_CAST "body", NULL); /* fill */ s=EBC_User_GetPeerId(u); if (s) EB_Msg_SetCharValue(msg, "header/static/HostID", s); /* generate Nonce */ tbuf=GWEN_Buffer_new(0, 128, 0, 1); rv=EBC_Provider_GenerateNonce(pro, tbuf); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); GWEN_Buffer_free(tbuf); EB_Msg_free(msg); return rv; } EB_Msg_SetCharValue(msg, "header/static/Nonce", GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_Reset(tbuf); /* generate timestamp */ rv=EBC_Provider_GenerateTimeStamp(pro, u, tbuf); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); GWEN_Buffer_free(tbuf); EB_Msg_free(msg); return rv; } EB_Msg_SetCharValue(msg, "header/static/Timestamp", GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_free(tbuf); s=AB_User_GetCustomerId(u); if (s) EB_Msg_SetCharValue(msg, "header/static/PartnerID", s); EB_Msg_SetCharValue(msg, "header/static/UserID", AB_User_GetUserId(u)); EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderType", "HPB"); EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderAttribute", "DZHNN"); EB_Msg_SetCharValue(msg, "header/static/SecurityMedium", "0000"); /* sign */ rv=EBC_Provider_SignMessage(pro, msg, u, sigNode); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); EB_Msg_free(msg); return rv; } /* exchange requests */ rv=EBC_Dialog_ExchangeMessages(sess, msg, &mRsp); if (rv<0 || rv>=300) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error exchanging messages (%d)", rv); EB_Msg_free(msg); return rv; } EB_Msg_free(msg); /* check response */ assert(mRsp); /* log results */ EBC_Provider_LogRequestResults(pro, mRsp, NULL); rc=EB_Msg_GetResultCode(mRsp); if ((rc & 0xff0000)==0x090000 || (rc & 0xff0000)==0x060000) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error response: (%06x)", rc); EB_Msg_free(mRsp); return AB_ERROR_SECURITY; } rc=EB_Msg_GetBodyResultCode(mRsp); if (rc) { if ((rc & 0xff0000)==0x090000 || (rc & 0xff0000)==0x060000) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error response: (%06x)", rc); EB_Msg_free(mRsp); if ((rc & 0xfff00)==0x091300 || (rc & 0xfff00)==0x091200) return AB_ERROR_SECURITY; else return GWEN_ERROR_GENERIC; } } if (1) { xmlDocPtr orderDoc=NULL; xmlNodePtr root_node=NULL; xmlNodePtr node=NULL; GWEN_CRYPT_KEY *skey=NULL; GWEN_BUFFER *buf1; GWEN_BUFFER *buf2; const char *s; /* extract keys and store them */ node=EB_Xml_GetNode(EB_Msg_GetRootNode(mRsp), "body/DataTransfer/DataEncryptionInfo", GWEN_PATH_FLAGS_NAMEMUSTEXIST); if (node==NULL) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Bad message from server: Missing session key"); EB_Msg_free(mRsp); return GWEN_ERROR_BAD_DATA; } rv=EBC_Provider_ExtractSessionKey(pro, u, node, &skey); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); EB_Msg_free(mRsp); return rv; } s=EB_Msg_GetCharValue(mRsp, "body/DataTransfer/OrderData", NULL); if (!s) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Bad message from server: Missing OrderData"); EB_Msg_free(mRsp); return GWEN_ERROR_BAD_DATA; } buf1=GWEN_Buffer_new(0, strlen(s), 0, 1); rv=GWEN_Base64_Decode((const uint8_t*)s, 0, buf1); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "Could not decode OrderData (%d)", rv); GWEN_Buffer_free(buf1); EB_Msg_free(mRsp); return rv; } /* decode data */ buf2=GWEN_Buffer_new(0, GWEN_Buffer_GetUsedBytes(buf1), 0, 1); rv=EBC_Provider_DecryptData(pro, u, skey, (const uint8_t*)GWEN_Buffer_GetStart(buf1), GWEN_Buffer_GetUsedBytes(buf1), buf2); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "Could not decrypt OrderData (%d)", rv); GWEN_Buffer_free(buf2); GWEN_Buffer_free(buf1); return rv; } /* parse XML document */ rv=EB_Xml_DocFromBuffer(GWEN_Buffer_GetStart(buf2), GWEN_Buffer_GetUsedBytes(buf2), &orderDoc); GWEN_Buffer_free(buf2); GWEN_Buffer_free(buf1); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); EB_Msg_free(mRsp); return rv; } /* get keys */ root_node=xmlDocGetRootElement(orderDoc); /* get auth key */ node=EB_Xml_GetNode(root_node, "AuthenticationPubKeyInfo", GWEN_PATH_FLAGS_NAMEMUSTEXIST); if (node==NULL) { DBG_ERROR(AQEBICS_LOGDOMAIN, "No authentication key found"); xmlFreeDoc(orderDoc); EB_Msg_free(mRsp); return GWEN_ERROR_BAD_DATA; } else { const GWEN_CRYPT_TOKEN_KEYINFO *cki; GWEN_CRYPT_TOKEN_KEYINFO *ki; keyId=GWEN_Crypt_Token_Context_GetAuthVerifyKeyId(ctx); cki=GWEN_Crypt_Token_GetKeyInfo(ct, keyId, 0, 0); if (cki) ki=GWEN_Crypt_Token_KeyInfo_dup(cki); else ki=GWEN_Crypt_Token_KeyInfo_new(keyId, GWEN_Crypt_CryptAlgoId_Rsa, 128); GWEN_Crypt_Token_KeyInfo_SetFlags(ki, 0); rc=EB_Key_Info_ReadXml(ki, node); if (rc) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%06x)", rc); GWEN_Crypt_Token_KeyInfo_free(ki); xmlFreeDoc(orderDoc); EB_Msg_free(mRsp); return GWEN_ERROR_BAD_DATA; } rv=GWEN_Crypt_Token_SetKeyInfo(ct, keyId, ki, 0); GWEN_Crypt_Token_KeyInfo_free(ki); if (rv) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); xmlFreeDoc(orderDoc); EB_Msg_free(mRsp); return rv; } DBG_NOTICE(AQEBICS_LOGDOMAIN, "Auth key stored"); } /* get crypt key */ node=EB_Xml_GetNode(root_node, "EncryptionPubKeyInfo", GWEN_PATH_FLAGS_NAMEMUSTEXIST); if (node==NULL) { DBG_ERROR(AQEBICS_LOGDOMAIN, "No encryption key found"); xmlFreeDoc(orderDoc); EB_Msg_free(mRsp); return GWEN_ERROR_BAD_DATA; } else { const GWEN_CRYPT_TOKEN_KEYINFO *cki; GWEN_CRYPT_TOKEN_KEYINFO *ki; keyId=GWEN_Crypt_Token_Context_GetEncipherKeyId(ctx); cki=GWEN_Crypt_Token_GetKeyInfo(ct, keyId, 0, 0); if (cki) ki=GWEN_Crypt_Token_KeyInfo_dup(cki); else ki=GWEN_Crypt_Token_KeyInfo_new(keyId, GWEN_Crypt_CryptAlgoId_Rsa, 128); GWEN_Crypt_Token_KeyInfo_SetFlags(ki, 0); rc=EB_Key_Info_ReadXml(ki, node); if (rc) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%06x)", rc); GWEN_Crypt_Token_KeyInfo_free(ki); xmlFreeDoc(orderDoc); EB_Msg_free(mRsp); return GWEN_ERROR_BAD_DATA; } rv=GWEN_Crypt_Token_SetKeyInfo(ct, keyId, ki, 0); GWEN_Crypt_Token_KeyInfo_free(ki); if (rv) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); xmlFreeDoc(orderDoc); EB_Msg_free(mRsp); return rv; } DBG_NOTICE(AQEBICS_LOGDOMAIN, "Crypt key stored"); } xmlFreeDoc(orderDoc); } EB_Msg_free(mRsp); /* adjust user status and flags */ DBG_NOTICE(AQEBICS_LOGDOMAIN, "Adjusting user flags"); if ((EBC_User_GetFlags(u) & (EBC_USER_FLAGS_INI | EBC_USER_FLAGS_HIA)) == (EBC_USER_FLAGS_INI | EBC_USER_FLAGS_HIA)) EBC_User_SetStatus(u, EBC_UserStatus_Enabled); return 0; }
/*>void testWriteAsPDBML(FILE *fp, PDB *pdb) ----------------------------------------- *//** \param[in] *fp PDB file pointer to be written \param[in] *pdb PDB linked list to write Write a PDB linked list in PDBML format. This test function is based on the bioplib function blWriteAsPDBML(). The function calls blAddTagVariablesNodes() which writes additional user-defined tags for each atom. Tags are written if gPDBTagWrite is TRUE. - 25.08.14 Original. By: CTP - 28.08.14 Use gNPDBTagFunctions to control output of user-defined tags. By: CTP */ void testWriteAsPDBML(FILE *fp, PDB *pdb) { /* PDBML format supported */ PDB *p; xmlDocPtr doc = NULL; xmlNodePtr root_node = NULL, sites_node = NULL, atom_node = NULL, node = NULL; xmlNsPtr pdbx = NULL, xsi = NULL; char buffer[16], *buffer_ptr; /* Create doc */ doc = xmlNewDoc((xmlChar *) "1.0"); doc->encoding = xmlStrdup((xmlChar *) "UTF-8"); /* Root node */ root_node = xmlNewNode(NULL, (xmlChar *) "datablock"); xmlDocSetRootElement(doc, root_node); pdbx = xmlNewNs(root_node, (xmlChar *) "null", (xmlChar *) "PDBx"); xsi = xmlNewNs(root_node, (xmlChar *) "null", (xmlChar *) "xsi"); xmlSetNs(root_node,pdbx); /* Atom_sites node */ sites_node = xmlNewChild(root_node, NULL, (xmlChar *) "atom_siteCategory", NULL); /* Atom nodes */ for(p = pdb ; p ; NEXT(p)) { /* skip TER */ if(!strncmp("TER",p->resnam,3)) { continue; } /* Add atom node */ atom_node = xmlNewChild(sites_node, NULL, (xmlChar *) "atom_site", NULL); sprintf(buffer, "%d", p->atnum); xmlNewProp(atom_node, (xmlChar *) "id", (xmlChar *) buffer); /* Add atom data nodes */ /* B value */ sprintf(buffer,"%.2f", p->bval); node = xmlNewChild(atom_node, NULL, (xmlChar *) "B_iso_or_equiv", (xmlChar *) buffer); /* coordinates */ sprintf(buffer,"%.3f", p->x); node = xmlNewChild(atom_node, NULL, (xmlChar *) "Cartn_x", (xmlChar *) buffer); sprintf(buffer,"%.3f", p->y); node = xmlNewChild(atom_node, NULL, (xmlChar *) "Cartn_y", (xmlChar *) buffer); sprintf(buffer,"%.3f", p->z); node = xmlNewChild(atom_node, NULL, (xmlChar *) "Cartn_z", (xmlChar *) buffer); /* author atom site labels */ node = xmlNewChild(atom_node, NULL, (xmlChar *) "auth_asym_id", (xmlChar *) p->chain); strcpy(buffer,p->atnam); KILLTRAILSPACES(buffer); node = xmlNewChild(atom_node, NULL, (xmlChar *) "auth_atom_id", (xmlChar *) buffer); strcpy(buffer,p->resnam); KILLTRAILSPACES(buffer); KILLLEADSPACES(buffer_ptr,buffer); node = xmlNewChild(atom_node, NULL, (xmlChar *) "auth_comp_id", (xmlChar *) buffer_ptr); sprintf(buffer,"%d", p->resnum); node = xmlNewChild(atom_node, NULL, (xmlChar *) "auth_seq_id", (xmlChar *) buffer); /* record type atom/hetatm */ strcpy(buffer,p->record_type); KILLTRAILSPACES(buffer); node = xmlNewChild(atom_node, NULL, (xmlChar *) "group_PDB", (xmlChar *) buffer); /* atom site labels */ node = xmlNewChild(atom_node, NULL, (xmlChar *) "label_alt_id", NULL); if(p->altpos == ' ') { xmlNewNsProp(node, xsi, (xmlChar *) "nil", (xmlChar *) "true"); } else { buffer[0] = p->altpos; buffer[1] = '\0'; xmlNodeSetContent(node, (xmlChar *) buffer); } node = xmlNewChild(atom_node, NULL, (xmlChar *) "label_asym_id", (xmlChar *) p->chain); strcpy(buffer,p->atnam); KILLTRAILSPACES(buffer); node = xmlNewChild(atom_node, NULL, (xmlChar *) "label_atom_id", (xmlChar *) buffer); strcpy(buffer,p->resnam); KILLTRAILSPACES(buffer); KILLLEADSPACES(buffer_ptr,buffer); node = xmlNewChild(atom_node, NULL, (xmlChar *) "label_comp_id", (xmlChar *) buffer_ptr); /* Note: Entity ID is not stored in PDB data structure. Value set to 1 */ node = xmlNewChild(atom_node, NULL, (xmlChar *) "label_entity_id", (xmlChar *) "1"); sprintf(buffer,"%d", p->resnum); node = xmlNewChild(atom_node, NULL, (xmlChar *) "label_seq_id", (xmlChar *) buffer); /* occupancy */ sprintf(buffer,"%.2f", p->occ); node = xmlNewChild(atom_node, NULL, (xmlChar *) "occupancy", (xmlChar *) buffer); /* insertion code */ /* Note: Insertion code node only included for residues with insertion codes */ if(strcmp(p->insert," ")) { sprintf(buffer,"%s", p->insert); node = xmlNewChild(atom_node, NULL, (xmlChar *) "pdbx_PDB_ins_code", (xmlChar *) buffer); } /* model number */ /* Note: Model number is not stored in PDB data structure. Value set to 1 */ node = xmlNewChild(atom_node, NULL, (xmlChar *) "pdbx_PDB_model_num", (xmlChar *) "1"); /* formal charge */ /* Note: Formal charge node not included for neutral atoms */ if(p->formal_charge != 0) { sprintf(buffer,"%d", p->formal_charge); node = xmlNewChild(atom_node, NULL, (xmlChar *) "pdbx_formal_charge", (xmlChar *) buffer); } /* atom symbol */ /* Note: If the atomic symbol is not set in PDB data structure then the value set is based on columns 13-14 of pdb-formated text file. */ sprintf(buffer,"%s", p->element); KILLLEADSPACES(buffer_ptr,buffer); if(strlen(buffer_ptr)) { node = xmlNewChild(atom_node, NULL, (xmlChar *) "type_symbol", (xmlChar *) buffer_ptr); } else { blSetElementSymbolFromAtomName(buffer,p->atnam_raw); node = xmlNewChild(atom_node, NULL, (xmlChar *) "type_symbol", (xmlChar *) buffer); } /* NEW CODE */ /* user-defined tags */ if(gNPDBTagFunctions) { blAddTagVariablesNodes(p,atom_node); } } /* Write to doc file pointer */ xmlDocFormatDump(fp,doc,1); /* Free Memory */ xmlFreeDoc(doc); xmlCleanupParser(); return; }
Check_Type(value, T_STRING); Data_Get_Struct(node, xmlNode, xnode); if (xnode->type != XML_ELEMENT_NODE) rb_raise(rb_eArgError, "Attributes can only be created on element nodes."); if NIL_P(ns) { xattr = xmlNewProp(xnode, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value)); } else { xmlNsPtr xns; Data_Get_Struct(ns, xmlNs, xns); xattr = xmlNewNsProp(xnode, xns, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(value)); } if (!xattr) rb_raise(rb_eRuntimeError, "Could not create attribute."); xattr->_private = (void *)self; DATA_PTR(self) = xattr; return self; } /* * call-seq: * attr.child -> node * * Obtain this attribute's child attribute(s).
int EBC_Provider_XchgHiaRequest_H003(AB_PROVIDER *pro, GWEN_HTTP_SESSION *sess, AB_USER *u) { int rv; GWEN_CRYPT_TOKEN *ct; const GWEN_CRYPT_TOKEN_CONTEXT *ctx; uint32_t kid; const GWEN_CRYPT_TOKEN_KEYINFO *cryptKeyInfo=NULL; const GWEN_CRYPT_TOKEN_KEYINFO *authKeyInfo=NULL; xmlNsPtr ns; EB_MSG *msg; const char *userId; const char *partnerId; EB_MSG *mRsp; EB_RC rc; xmlDocPtr doc; xmlNodePtr root_node = NULL; xmlNodePtr node = NULL; /*xmlNodePtr nodeX = NULL;*/ GWEN_BUFFER *mbuf; GWEN_BUFFER *tbuf; const char *s; userId=AB_User_GetUserId(u); partnerId=AB_User_GetCustomerId(u); /* get crypt token and context */ rv=EBC_Provider_MountToken(pro, u, &ct, &ctx); if (rv<0) { DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv); return rv; } /* get crypt key info */ kid=GWEN_Crypt_Token_Context_GetDecipherKeyId(ctx); if (kid) { cryptKeyInfo=GWEN_Crypt_Token_GetKeyInfo(ct, kid, GWEN_CRYPT_TOKEN_KEYFLAGS_HASMODULUS | GWEN_CRYPT_TOKEN_KEYFLAGS_HASEXPONENT | GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYVERSION | GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYNUMBER, 0); if (cryptKeyInfo==NULL) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Crypt key info not found on crypt token"); GWEN_Gui_ProgressLog(0, GWEN_LoggerLevel_Error, I18N("Crypt key info not found on crypt token")); return GWEN_ERROR_NOT_FOUND; } } /* get auth sign key info */ kid=GWEN_Crypt_Token_Context_GetAuthSignKeyId(ctx); if (kid) { authKeyInfo=GWEN_Crypt_Token_GetKeyInfo(ct, kid, GWEN_CRYPT_TOKEN_KEYFLAGS_HASMODULUS | GWEN_CRYPT_TOKEN_KEYFLAGS_HASEXPONENT | GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYVERSION | GWEN_CRYPT_TOKEN_KEYFLAGS_HASKEYNUMBER, 0); if (authKeyInfo==NULL) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Auth key info not found on crypt token"); GWEN_Gui_ProgressLog(0, GWEN_LoggerLevel_Error, I18N("Auth key info not found on crypt token")); return GWEN_ERROR_NOT_FOUND; } } /* create HIARequestOrderData */ doc=xmlNewDoc(BAD_CAST "1.0"); doc->encoding=xmlCharStrdup("UTF-8"); root_node=xmlNewNode(NULL, BAD_CAST "HIARequestOrderData"); xmlDocSetRootElement(doc, root_node); ns=xmlNewNs(root_node, BAD_CAST "http://www.ebics.org/H003", NULL); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2000/09/xmldsig#", BAD_CAST "ds"); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2001/XMLSchema-instance", BAD_CAST "xsi"); xmlNewNsProp(root_node, ns, BAD_CAST "schemaLocation", /* xsi:schemaLocation */ BAD_CAST "http://www.ebics.org/H003 " "http://www.ebics.org/H003/ebics_orders.xsd"); /* create auth key tree */ node=xmlNewChild(root_node, NULL, BAD_CAST "AuthenticationPubKeyInfo", NULL); rv=EB_Key_Info_toXml(authKeyInfo, node); if (rv<0) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error response: (%d)", rv); xmlFreeDoc(doc); return GWEN_ERROR_INVALID; } xmlNewChild(node, NULL, BAD_CAST "AuthenticationVersion", BAD_CAST "X002"); /* create crypt key tree */ node=xmlNewChild(root_node, NULL, BAD_CAST "EncryptionPubKeyInfo", NULL); rv=EB_Key_Info_toXml(cryptKeyInfo, node); if (rv<0) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error response: (%d)", rv); xmlFreeDoc(doc); return rv; } xmlNewChild(node, NULL, BAD_CAST "EncryptionVersion", BAD_CAST "E002"); /* store partner id and user id */ node=xmlNewChild(root_node, NULL, BAD_CAST "PartnerID", BAD_CAST partnerId); node=xmlNewChild(root_node, NULL, BAD_CAST "UserID", BAD_CAST userId); /* compress and base64 doc */ mbuf=GWEN_Buffer_new(0, 512, 0, 1); rv=EB_Xml_Compress64Doc(doc, mbuf); if (rv<0) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error compressing/encoding doc (%d)", rv); xmlFreeDoc(doc); return rv; } xmlFreeDoc(doc); /* create request */ msg=EB_Msg_new(); doc=EB_Msg_GetDoc(msg); root_node=xmlNewNode(NULL, BAD_CAST "ebicsUnsecuredRequest"); xmlDocSetRootElement(doc, root_node); ns=xmlNewNs(root_node, BAD_CAST "http://www.ebics.org/H003", NULL); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2000/09/xmldsig#", BAD_CAST "ds"); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2001/XMLSchema-instance", BAD_CAST "xsi"); xmlNewNsProp(root_node, ns, BAD_CAST "schemaLocation", /* xsi:schemaLocation */ BAD_CAST "http://www.ebics.org/H003 " "http://www.ebics.org/H003/ebics_keymgmt_request.xsd"); xmlNewProp(root_node, BAD_CAST "Version", BAD_CAST "H003"); xmlNewProp(root_node, BAD_CAST "Revision", BAD_CAST "1"); /* header */ node=xmlNewChild(root_node, NULL, BAD_CAST "header", NULL); xmlNewProp(node, BAD_CAST "authenticate", BAD_CAST "true"); xmlNewChild(node, NULL, BAD_CAST "static", NULL); xmlNewChild(node, NULL, BAD_CAST "mutable", NULL); /* body */ node=xmlNewChild(root_node, NULL, BAD_CAST "body", NULL); /* fill */ s=EBC_User_GetPeerId(u); if (s) EB_Msg_SetCharValue(msg, "header/static/HostID", s); s=AB_User_GetCustomerId(u); if (s) EB_Msg_SetCharValue(msg, "header/static/PartnerID", s); EB_Msg_SetCharValue(msg, "header/static/UserID", AB_User_GetUserId(u)); EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderType", "HIA"); tbuf=GWEN_Buffer_new(0, 16, 0, 1); rv=EBC_Provider_Generate_OrderId(pro, tbuf); if (rv<0) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error exchanging messages (%d)", rv); GWEN_Buffer_free(tbuf); GWEN_Buffer_free(mbuf); EB_Msg_free(msg); return rv; } EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderID", GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_free(tbuf); EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderAttribute", "DZNNN"); EB_Msg_SetCharValue(msg, "header/static/SecurityMedium", "0200"); EB_Msg_SetCharValue(msg, "body/DataTransfer/OrderData", GWEN_Buffer_GetStart(mbuf)); GWEN_Buffer_free(mbuf); /* exchange requests */ rv=EBC_Dialog_ExchangeMessages(sess, msg, &mRsp); if (rv<0 || rv>=300) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error exchanging messages (%d)", rv); EB_Msg_free(msg); return rv; } EB_Msg_free(msg); /* check response */ assert(mRsp); /* log results */ EBC_Provider_LogRequestResults(pro, mRsp, NULL); rc=EB_Msg_GetResultCode(mRsp); if ((rc & 0xff0000)==0x090000 || (rc & 0xff0000)==0x060000) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error response: (%06x)", rc); EB_Msg_free(mRsp); return AB_ERROR_SECURITY; } rc=EB_Msg_GetBodyResultCode(mRsp); if (rc) { if ((rc & 0xff0000)==0x090000 || (rc & 0xff0000)==0x060000) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error response: (%06x)", rc); EB_Msg_free(mRsp); if ((rc & 0xfff00)==0x091300 || (rc & 0xfff00)==0x091200) return AB_ERROR_SECURITY; else return GWEN_ERROR_GENERIC; } } EB_Msg_free(mRsp); /* adjust user status and flags */ DBG_NOTICE(AQEBICS_LOGDOMAIN, "Adjusting user flags"); EBC_User_AddFlags(u, EBC_USER_FLAGS_HIA); if ((EBC_User_GetFlags(u) & (EBC_USER_FLAGS_INI | EBC_USER_FLAGS_HIA)) == (EBC_USER_FLAGS_INI | EBC_USER_FLAGS_HIA)) EBC_User_SetStatus(u, EBC_UserStatus_Init2); else EBC_User_SetStatus(u, EBC_UserStatus_Init1); return 0; }
int msWFSGetCapabilities11(mapObj *map, wfsParamsObj *params, cgiRequestObj *req, owsRequestObj *ows_request) { xmlDocPtr psDoc = NULL; /* document pointer */ xmlNodePtr psRootNode, psMainNode, psNode, psFtNode; xmlNodePtr psTmpNode; const char *updatesequence=NULL; xmlNsPtr psNsOws, psNsXLink, psNsOgc; char *schemalocation = NULL; char *xsi_schemaLocation = NULL; char *script_url=NULL, *script_url_encoded=NULL, *formats_list; const char *value = NULL; const char *encoding; xmlChar *buffer = NULL; int size = 0, i; msIOContext *context = NULL; int ows_version = OWS_1_0_0; /* -------------------------------------------------------------------- */ /* Handle updatesequence */ /* -------------------------------------------------------------------- */ updatesequence = msOWSLookupMetadata(&(map->web.metadata), "FO", "updatesequence"); encoding = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding"); if (params->pszUpdateSequence != NULL) { i = msOWSNegotiateUpdateSequence(params->pszUpdateSequence, updatesequence); if (i == 0) { /* current */ msSetError(MS_WFSERR, "UPDATESEQUENCE parameter (%s) is equal to server (%s)", "msWFSGetCapabilities11()", params->pszUpdateSequence, updatesequence); return msWFSException11(map, "updatesequence", "CurrentUpdateSequence", params->pszVersion); } if (i > 0) { /* invalid */ msSetError(MS_WFSERR, "UPDATESEQUENCE parameter (%s) is higher than server (%s)", "msWFSGetCapabilities11()", params->pszUpdateSequence, updatesequence); return msWFSException11(map, "updatesequence", "InvalidUpdateSequence", params->pszVersion); } } /* -------------------------------------------------------------------- */ /* Create document. */ /* -------------------------------------------------------------------- */ psDoc = xmlNewDoc(BAD_CAST "1.0"); psRootNode = xmlNewNode(NULL, BAD_CAST "WFS_Capabilities"); xmlDocSetRootElement(psDoc, psRootNode); /* -------------------------------------------------------------------- */ /* Name spaces */ /* -------------------------------------------------------------------- */ /*default name space*/ xmlNewProp(psRootNode, BAD_CAST "xmlns", BAD_CAST "http://www.opengis.net/wfs"); xmlSetNs(psRootNode, xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/gml", BAD_CAST "gml")); xmlSetNs(psRootNode, xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/wfs", BAD_CAST "wfs")); psNsOws = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_PREFIX); psNsXLink = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_W3C_XLINK_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_W3C_XLINK_NAMESPACE_PREFIX); xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_PREFIX); xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_PREFIX ); xmlNewProp(psRootNode, BAD_CAST "version", BAD_CAST params->pszVersion ); updatesequence = msOWSLookupMetadata(&(map->web.metadata), "FO", "updatesequence"); if (updatesequence) xmlNewProp(psRootNode, BAD_CAST "updateSequence", BAD_CAST updatesequence); /*schema*/ schemalocation = msEncodeHTMLEntities( msOWSGetSchemasLocation(map) ); xsi_schemaLocation = msStrdup("http://www.opengis.net/wfs"); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, " "); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, schemalocation); xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, "/wfs/1.1.0/wfs.xsd"); xmlNewNsProp(psRootNode, NULL, BAD_CAST "xsi:schemaLocation", BAD_CAST xsi_schemaLocation); /* -------------------------------------------------------------------- */ /* Service metadata. */ /* -------------------------------------------------------------------- */ psTmpNode = xmlAddChild(psRootNode, msOWSCommonServiceIdentification(psNsOws, map, "OGC WFS", params->pszVersion, "FO")); /*service provider*/ psTmpNode = xmlAddChild(psRootNode, msOWSCommonServiceProvider( psNsOws, psNsXLink, map, "FO")); /*operation metadata */ if ((script_url=msOWSGetOnlineResource(map, "FO", "onlineresource", req)) == NULL || (script_url_encoded = msEncodeHTMLEntities(script_url)) == NULL) { msSetError(MS_WFSERR, "Server URL not found", "msWFSGetCapabilities11()"); return msWFSException11(map, "mapserv", "NoApplicableCode", params->pszVersion); } /* -------------------------------------------------------------------- */ /* Operations metadata. */ /* -------------------------------------------------------------------- */ psMainNode= xmlAddChild(psRootNode,msOWSCommonOperationsMetadata(psNsOws)); /* -------------------------------------------------------------------- */ /* GetCapabilities */ /* -------------------------------------------------------------------- */ psNode = xmlAddChild(psMainNode, msOWSCommonOperationsMetadataOperation(psNsOws,psNsXLink,"GetCapabilities", OWS_METHOD_GETPOST, script_url_encoded)); xmlAddChild(psMainNode, psNode); xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType( ows_version, psNsOws, "Parameter", "service", "WFS")); /*accept version*/ xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "AcceptVersions", "1.0.0,1.1.0")); /*format*/ xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "AcceptFormats", "text/xml")); /* -------------------------------------------------------------------- */ /* DescribeFeatureType */ /* -------------------------------------------------------------------- */ if (msOWSRequestIsEnabled(map, NULL, "F", "DescribeFeatureType", MS_TRUE)) { psNode = xmlAddChild(psMainNode, msOWSCommonOperationsMetadataOperation(psNsOws,psNsXLink,"DescribeFeatureType", OWS_METHOD_GETPOST, script_url_encoded)); xmlAddChild(psMainNode, psNode); /*output format*/ xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "outputFormat", "XMLSCHEMA,text/xml; subtype=gml/2.1.2,text/xml; subtype=gml/3.1.1")); } /* -------------------------------------------------------------------- */ /* GetFeature */ /* -------------------------------------------------------------------- */ if (msOWSRequestIsEnabled(map, NULL, "F", "GetFeature", MS_TRUE)) { psNode = xmlAddChild(psMainNode, msOWSCommonOperationsMetadataOperation(psNsOws,psNsXLink,"GetFeature", OWS_METHOD_GETPOST, script_url_encoded)); xmlAddChild(psMainNode, psNode); xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "resultType", "results,hits")); formats_list = msWFSGetOutputFormatList( map, NULL, "1.1.0" ); xmlAddChild(psNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Parameter", "outputFormat", formats_list)); msFree( formats_list ); value = msOWSLookupMetadata(&(map->web.metadata), "FO", "maxfeatures"); if (value) { xmlAddChild(psMainNode, msOWSCommonOperationsMetadataDomainType(ows_version, psNsOws, "Constraint", "DefaultMaxFeatures", (char *)value)); } } /* -------------------------------------------------------------------- */ /* FeatureTypeList */ /* -------------------------------------------------------------------- */ psFtNode = xmlNewNode(NULL, BAD_CAST "FeatureTypeList"); xmlAddChild(psRootNode, psFtNode); psNode = xmlNewChild(psFtNode, NULL, BAD_CAST "Operations", NULL); xmlNewChild(psNode, NULL, BAD_CAST "Operation", BAD_CAST "Query"); for(i=0; i<map->numlayers; i++) { layerObj *lp; lp = GET_LAYER(map, i); if (!msIntegerInArray(lp->index, ows_request->enabled_layers, ows_request->numlayers)) continue; /* List only vector layers in which DUMP=TRUE */ if (msWFSIsLayerSupported(lp)) xmlAddChild(psFtNode, msWFSDumpLayer11(map, lp, psNsOws)); } /* -------------------------------------------------------------------- */ /* Filter capabilities. */ /* -------------------------------------------------------------------- */ psNsOgc = xmlNewNs(NULL, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_PREFIX); xmlAddChild(psRootNode, FLTGetCapabilities(psNsOgc, psNsOgc, MS_FALSE)); /* -------------------------------------------------------------------- */ /* Write out the document. */ /* -------------------------------------------------------------------- */ if( msIO_needBinaryStdout() == MS_FAILURE ) return MS_FAILURE; if (encoding) msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10); else msIO_printf("Content-type: text/xml%c%c",10,10); context = msIO_getHandler(stdout); xmlDocDumpFormatMemoryEnc(psDoc, &buffer, &size, (encoding ? encoding : "ISO-8859-1"), 1); msIO_contextWrite(context, buffer, size); xmlFree(buffer); /*free buffer and the document */ /*xmlFree(buffer);*/ xmlFreeDoc(psDoc); xmlFreeNs(psNsOgc); free(script_url); free(script_url_encoded); free(xsi_schemaLocation); free(schemalocation); xmlCleanupParser(); return(MS_SUCCESS); }
EB_MSG *EBC_Provider_MkUnsecuredRequest_H004(AB_PROVIDER *pro, AB_USER *u, const char *orderType, const char *orderAttribute, const char *orderData) { EB_MSG *msg; xmlDocPtr doc; xmlNodePtr root_node = NULL; xmlNodePtr node = NULL; xmlNsPtr ns; const char *s; GWEN_BUFFER *tbuf; int rv; /* create request */ msg=EB_Msg_new(); doc=EB_Msg_GetDoc(msg); root_node=xmlNewNode(NULL, BAD_CAST "ebicsUnsecuredRequest"); xmlDocSetRootElement(doc, root_node); ns=xmlNewNs(root_node, BAD_CAST "http://www.ebics.org/H004", NULL); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2000/09/xmldsig#", BAD_CAST "ds"); assert(ns); ns=xmlNewNs(root_node, BAD_CAST "http://www.w3.org/2001/XMLSchema-instance", BAD_CAST "xsi"); xmlNewNsProp(root_node, ns, BAD_CAST "schemaLocation", /* xsi:schemaLocation */ BAD_CAST "urn:org:ebics:H004 ebics_ keymgmt_request_H004.xsd"); xmlNewProp(root_node, BAD_CAST "Version", BAD_CAST "H004"); xmlNewProp(root_node, BAD_CAST "Revision", BAD_CAST "1"); /* header */ node=xmlNewChild(root_node, NULL, BAD_CAST "header", NULL); xmlNewProp(node, BAD_CAST "authenticate", BAD_CAST "true"); xmlNewChild(node, NULL, BAD_CAST "static", NULL); xmlNewChild(node, NULL, BAD_CAST "mutable", NULL); /* body */ node=xmlNewChild(root_node, NULL, BAD_CAST "body", NULL); /* fill */ s=EBC_User_GetPeerId(u); if (s) EB_Msg_SetCharValue(msg, "header/static/HostID", s); s=AB_User_GetCustomerId(u); if (s) EB_Msg_SetCharValue(msg, "header/static/PartnerID", s); EB_Msg_SetCharValue(msg, "header/static/UserID", AB_User_GetUserId(u)); EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderType", orderType); tbuf=GWEN_Buffer_new(0, 16, 0, 1); rv=EBC_Provider_Generate_OrderId(pro, tbuf); if (rv<0) { DBG_ERROR(AQEBICS_LOGDOMAIN, "Error exchanging messages (%d)", rv); GWEN_Buffer_free(tbuf); EB_Msg_free(msg); return NULL; } EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderID", GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_free(tbuf); EB_Msg_SetCharValue(msg, "header/static/OrderDetails/OrderAttribute", orderAttribute); EB_Msg_SetCharValue(msg, "header/static/SecurityMedium", "0200"); EB_Msg_SetCharValue(msg, "body/DataTransfer/OrderData", orderData); return msg; }