Ejemplo n.º 1
0
func getReferencedXML(reference *etree.Element, inputDoc *etree.Document) (outputDoc *etree.Document, err error) {
	uri := reference.SelectAttrValue("URI", "")
	uri = strings.Replace(uri, "#", "", 1)
	// populate doc with the referenced xml from the Reference URI
	if uri == "" {
		outputDoc = inputDoc
	} else {
		path := fmt.Sprintf(".//[@ID='%s']", uri)
		e := inputDoc.FindElement(path)
		if e != nil {
			outputDoc = etree.NewDocument()
			outputDoc.SetRoot(e.Copy())
		} else {
			// SAML v1.1 Assertions use AssertionID
			path := fmt.Sprintf(".//[@AssertionID='%s']", uri)
			e := inputDoc.FindElement(path)
			if e != nil {
				outputDoc = etree.NewDocument()
				outputDoc.SetRoot(e.Copy())
			}
		}
	}

	if outputDoc == nil {
		return nil, errors.New("signedxml: unable to find refereced xml")
	}

	return outputDoc, nil
}
Ejemplo n.º 2
0
func updateJobConfigXml(doc *etree.Document, cfg map[string]string) {
	eDesc := doc.FindElement(Root + Description)
	eDesc.SetText(cfg["desc"])

	eRepoURL := doc.FindElement(Root + Scm + UsrRemoteConfigs + HudsonPluginsGitUserRemoteConfig + Url)
	eRepoURL.SetText(cfg["repositryurl"])

	eCredentialsid := doc.FindElement(Root + Scm + UsrRemoteConfigs + HudsonPluginsGitUserRemoteConfig + CredentialsId)
	eCredentialsid.SetText(cfg["credentialsid"])

	eBranchesToBuild := doc.FindElement(Root + Scm + Branches + HudsonPluginsGitBranchSpec + Name)
	eBranchesToBuild.SetText(cfg["branchestobuild"])

	eRepoName := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + RepoName)
	eRepoName.SetText(cfg["repositryname"])

	eTag := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + RepoTag)
	eTag.SetText(cfg["tag"])

	eDockerHostUri := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + Server + Uri)
	eDockerHostUri.SetText(cfg["dockerhosturi"])

	eDockerRegistryUrl := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + Registry + Url)
	eDockerRegistryUrl.SetText(cfg["dockerregistryurl"])

	eSkipPush := doc.FindElement(Root + Builders + ComCloudbeesDockerpublishDockerBuilder + SkipPush)
	eSkipPush.SetText(cfg["skippush"])

	eCmd := doc.FindElement(Root + Builders + HudsonTasksShell + Command)
	eCmd.SetText(cfg["command"])

}