Skip to content

Package: WSITUtil

WSITUtil

nameinstructionbranchcomplexitylinemethod
updateWsitClient(File, String, String)
M: 89 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 19 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package com.sun.xml.ws.test.util;
12:
13: import java.io.File;
14: import java.io.FileOutputStream;
15: import java.io.OutputStream;
16: import org.w3c.dom.Attr;
17: import org.w3c.dom.Document;
18: import org.w3c.dom.Element;
19:
20: /**
21: *
22: * @author lukas
23: */
24: public final class WSITUtil {
25:
26: private WSITUtil() {
27: }
28:
29: public static void updateWsitClient(File wsitClientFile, String endpointUri, String wsdlLocation) throws Exception {
30: Document document = XMLUtil.readXML(wsitClientFile, null);
31: Element root = document.getDocumentElement();
32: Element sts = XMLUtil.getElements(root, "//*[local-name()='Policy']/*[local-name()='ExactlyOne']/*[local-name()='All']/*[local-name()='PreconfiguredSTS']").get(0);
33:
34: Attr endpoint = sts.getAttributeNode("endpoint");
35: endpoint.setValue(endpointUri);
36:
37: Attr wsdlLoc = sts.getAttributeNode("wsdlLocation");
38: wsdlLoc.setValue(wsdlLocation);
39:
40:• for (Element keystore : XMLUtil.getElements(root, "//*[local-name()='KeyStore']")) {
41: Attr loc = keystore.getAttributeNode("location");
42: loc.setValue(loc.getValue().replaceAll("\\$WSIT_HOME", System.getProperty("WSIT_HOME")));
43: }
44:
45:• for (Element truststore : XMLUtil.getElements(root, "//*[local-name()='TrustStore']")) {
46: Attr loc = truststore.getAttributeNode("location");
47: loc.setValue(loc.getValue().replaceAll("\\$WSIT_HOME", System.getProperty("WSIT_HOME")));
48: }
49:
50: try (OutputStream os = new FileOutputStream(wsitClientFile)) {
51: XMLUtil.writeXML(document, os);
52: os.flush();
53: }
54: }
55: }