func XMLSecDSigCtxSignDocument(ctx PtrSource, doc types.Document) error { ctxptr, err := validDSigCtxPtr(ctx) if err != nil { return err } root, err := doc.DocumentElement() if err != nil { return err } rootptr, err := validNodePtr(root) if err != nil { return err } cname := stringToXMLChar(SignatureNode) cns := stringToXMLChar(DSigNs) defer C.free(unsafe.Pointer(cname)) defer C.free(unsafe.Pointer(cns)) nodeptr := C.xmlSecFindNode(rootptr, cname, cns) if nodeptr == nil { return errors.New("failed to find start node") } return xmlSecDSigCtxSignRaw(ctxptr, nodeptr) }
func constructAuthnRequest(doc types.Document) (*AuthnRequest, error) { root, err := doc.DocumentElement() if err != nil { return nil, errors.New("failed to fetch document element: " + err.Error()) } ar := &AuthnRequest{} if err := ar.PopulateFromXML(root); err != nil { return nil, errors.New("failed to populate from xml: " + err.Error()) } return ar, nil }
func XMLSecDSigCtxVerifyDocument(ctx PtrSource, doc types.Document) error { ctxptr, err := validDSigCtxPtr(ctx) if err != nil { return err } root, err := doc.DocumentElement() if err != nil { return err } rootptr, err := validNodePtr(root) if err != nil { return err } nodeptr := findSignatureNode(rootptr) if nodeptr == nil { return errors.New("failed to find start node") } return XMLSecDSigCtxVerifyRaw(ctxptr, nodeptr) }