Exemplo n.º 1
0
func XMLSecTmplSignatureAddReference(signode types.Node, digestMethod TransformID, id, uri, nodeType string) (types.Node, error) {
	nptr, err := validNodePtr(signode)
	if err != nil {
		return nil, err
	}

	var idxml, urixml, typexml *C.xmlChar
	if id != "" {
		idxml = stringToXMLChar(id)
		defer C.free(unsafe.Pointer(idxml))
	}
	if uri != "" {
		urixml = stringToXMLChar(uri)
		defer C.free(unsafe.Pointer(urixml))
	}
	if nodeType != "" {
		typexml = stringToXMLChar(nodeType)
		defer C.free(unsafe.Pointer(typexml))
	}

	ptr := C.xmlSecTmplSignatureAddReference(
		nptr,
		digestMethod.ptr,
		idxml,
		urixml,
		typexml,
	)
	if ptr == nil {
		return nil, errors.New("failed to add reference")
	}

	return dom.WrapNode(uintptr(unsafe.Pointer(ptr)))
}
Exemplo n.º 2
0
func XMLSecTmplSignatureCreateNsPref(doc types.Document, c14nMethod TransformID, signMethod TransformID, id string, prefix string) (types.Node, error) {
	docptr := (*C.xmlDoc)(unsafe.Pointer(doc.Pointer()))
	if docptr == nil {
		return nil, clib.ErrInvalidDocument
	}

	var xcid *C.xmlChar
	if id != "" {
		xcid = stringToXMLChar(id)
		defer C.free(unsafe.Pointer(xcid))
	}

	var xcprefix *C.xmlChar
	if prefix != "" {
		xcprefix = stringToXMLChar(prefix)
		defer C.free(unsafe.Pointer(xcprefix))
	}

	ptr := C.xmlSecTmplSignatureCreateNsPref(
		docptr,
		c14nMethod.ptr,
		signMethod.ptr,
		xcid,
		xcprefix,
	)
	if ptr == nil {
		return nil, errors.New("failed to create signature template")
	}

	return dom.WrapNode(uintptr(unsafe.Pointer(ptr)))
}
Exemplo n.º 3
0
func FindSignatureNode(n PtrSource) (types.Node, error) {
	nptr, err := validNodePtr(n)
	if err != nil {
		return nil, err
	}
	signode := findSignatureNode(nptr)
	if signode == nil {
		return nil, errors.New("faild to find signature node")
	}
	return dom.WrapNode(uintptr(unsafe.Pointer(signode)))
}
Exemplo n.º 4
0
func XMLSecTmplKeyInfoAddX509Data(n types.Node) (types.Node, error) {
	nptr, err := validNodePtr(n)
	if err != nil {
		return nil, err
	}

	ret := C.xmlSecTmplKeyInfoAddX509Data(nptr)
	if ret == nil {
		return nil, errors.New("failed to add X509Data node")
	}

	return dom.WrapNode(uintptr(unsafe.Pointer(ret)))
}
Exemplo n.º 5
0
func XMLSecTmplReferenceAddTransform(n types.Node, transformID TransformID) (types.Node, error) {
	nptr, err := validNodePtr(n)
	if err != nil {
		return nil, err
	}

	ptr := C.xmlSecTmplReferenceAddTransform(
		nptr,
		transformID.ptr,
	)
	if ptr == nil {
		return nil, errors.New("failed to add transform")
	}

	return dom.WrapNode(uintptr(unsafe.Pointer(ptr)))
}
Exemplo n.º 6
0
func XMLSecTmplSignatureEnsureKeyInfo(n types.Node, id string) (types.Node, error) {
	nptr, err := validNodePtr(n)
	if err != nil {
		return nil, err
	}
	var idc *C.xmlChar
	if id != "" {
		idc = stringToXMLChar(id)
		defer C.free(unsafe.Pointer(idc))
	}

	ret := C.xmlSecTmplSignatureEnsureKeyInfo(nptr, idc)
	if ret == nil {
		return nil, errors.New("failed to add KeyInfo node")
	}

	return dom.WrapNode(uintptr(unsafe.Pointer(ret)))
}