private static Map<String, BindingPolicy> selectIntegratedPoliciesWithExpression(Document xmlDocument, XPath xPath, String xpathExpression) throws XPathExpressionException { Map<String, BindingPolicy> policies = new HashMap<String, BindingPolicy>(); NodeList nodeList = (NodeList) xPath.compile(xpathExpression).evaluate(xmlDocument, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { // get back to //wsdl:definitions/wsp:Policy String policy = checkPolicyIntegrated(xPath, nodeList.item(i).getParentNode().getParentNode().getParentNode()); policies.put("#" + policy, new BindingPolicy("#" + policy)); } return policies; }
private static BindingPolicy selectSingleMatchingPolicy( Map<String, BindingPolicy> policies) { BindingPolicy wstrust13 = null, wstrust2005 = null; // Select wstrust13 first if wstrust13 available Iterator<Entry<String, BindingPolicy>> it = policies.entrySet() .iterator(); while (it.hasNext()) { Map.Entry<String, BindingPolicy> pair = it.next(); if (pair.getValue().getUrl() != null) { if (pair.getValue().getVersion() == WSTrustVersion.WSTRUST13) { wstrust13 = pair.getValue(); } else if (pair.getValue().getVersion() == WSTrustVersion.WSTRUST2005) { wstrust2005 = pair.getValue(); } } } if (wstrust13 == null && wstrust2005 == null) { log.warn("No policies found with the url"); return null; } return wstrust13 != null ? wstrust13 : wstrust2005; }
if (trustPolicy != null) { BindingPolicy bindingPolicy = policies.get(trustPolicy .getUrl()); if (bindingPolicy != null && StringHelper.isBlank(bindingPolicy.getUrl())) { bindingPolicy.setVersion(trustPolicy.getVersion()); NodeList addressNodes = (NodeList) xPath.compile( ADDRESS_XPATH).evaluate(portNode, && address.toLowerCase().startsWith( "https://")) { bindingPolicy.setUrl(address.trim());
private static Map<String, BindingPolicy> getMatchingBindings( Document xmlDocument, XPath xPath, Map<String, BindingPolicy> policies, boolean logPii) throws XPathExpressionException { Map<String, BindingPolicy> bindings = new HashMap<String, BindingPolicy>(); NodeList nodeList = (NodeList) xPath.compile( "//wsdl:definitions/wsdl:binding/wsp:PolicyReference") .evaluate(xmlDocument, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); String uri = node.getAttributes().getNamedItem("URI") .getNodeValue(); if (policies.containsKey(uri)) { Node bindingNode = node.getParentNode(); String bindingName = bindingNode.getAttributes() .getNamedItem("name").getNodeValue(); WSTrustVersion version = checkSoapActionAndTransport(xPath, bindingNode, logPii); if (version != WSTrustVersion.UNDEFINED) { BindingPolicy policy = new BindingPolicy(""); policy.setUrl(uri); policy.setVersion(version); bindings.put(bindingName, policy); } } } return bindings; }
.get(bindingId)); if (bindingPolicy != null && StringHelper.isBlank(bindingPolicy.getUrl())) { NodeList addressNodes = (NodeList) xPath.compile( ADDRESS_XPATH).evaluate(portNode, if (address != null && address.toLowerCase().startsWith("https://")) { bindingPolicy.setUrl(address); } else { log.warn("skipping insecure endpoint: " + address);
private static String selectSingleMatchingPolicy( Map<String, BindingPolicy> policies) { for (String key : policies.keySet()) { if (policies.get(key).getUrl() == null) { policies.remove(key); } } if (policies.size() == 0) { log.warn("no policies found with an url"); return null; } return policies.values().iterator().next().getUrl(); }
if (trustPolicy != null) { BindingPolicy bindingPolicy = policies.get(trustPolicy .getUrl()); if (bindingPolicy != null && StringHelper.isBlank(bindingPolicy.getUrl())) { bindingPolicy.setVersion(trustPolicy.getVersion()); NodeList addressNodes = (NodeList) xPath.compile( ADDRESS_XPATH).evaluate(portNode, && address.toLowerCase().startsWith( "https://")) { bindingPolicy.setUrl(address.trim());
private static Map<String, BindingPolicy> getMatchingBindings( Document xmlDocument, XPath xPath, Map<String, BindingPolicy> policies, boolean logPii) throws XPathExpressionException { Map<String, BindingPolicy> bindings = new HashMap<String, BindingPolicy>(); NodeList nodeList = (NodeList) xPath.compile( "//wsdl:definitions/wsdl:binding/wsp:PolicyReference") .evaluate(xmlDocument, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); String uri = node.getAttributes().getNamedItem("URI") .getNodeValue(); if (policies.containsKey(uri)) { Node bindingNode = node.getParentNode(); String bindingName = bindingNode.getAttributes() .getNamedItem("name").getNodeValue(); WSTrustVersion version = checkSoapActionAndTransport(xPath, bindingNode, logPii); if (version != WSTrustVersion.UNDEFINED) { BindingPolicy policy = new BindingPolicy(""); policy.setUrl(uri); policy.setVersion(version); bindings.put(bindingName, policy); } } } return bindings; }
private static BindingPolicy selectSingleMatchingPolicy( Map<String, BindingPolicy> policies) { BindingPolicy wstrust13 = null, wstrust2005 = null; // Select wstrust13 first if wstrust13 available Iterator<Entry<String, BindingPolicy>> it = policies.entrySet() .iterator(); while (it.hasNext()) { Map.Entry<String, BindingPolicy> pair = it.next(); if (pair.getValue().getUrl() != null) { if (pair.getValue().getVersion() == WSTrustVersion.WSTRUST13) { wstrust13 = pair.getValue(); } else if (pair.getValue().getVersion() == WSTrustVersion.WSTRUST2005) { wstrust2005 = pair.getValue(); } } } if (wstrust13 == null && wstrust2005 == null) { log.warn("No policies found with the url"); return null; } return wstrust13 != null ? wstrust13 : wstrust2005; }
private static Map<String, BindingPolicy> selectIntegratedPoliciesWithExpression(Document xmlDocument, XPath xPath, String xpathExpression) throws XPathExpressionException { Map<String, BindingPolicy> policies = new HashMap<String, BindingPolicy>(); NodeList nodeList = (NodeList) xPath.compile(xpathExpression).evaluate(xmlDocument, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { // get back to //wsdl:definitions/wsp:Policy String policy = checkPolicyIntegrated(xPath, nodeList.item(i).getParentNode().getParentNode().getParentNode()); policies.put("#" + policy, new BindingPolicy("#" + policy)); } return policies; }
static WSTrustResponse execute(String username, String password, String cloudAudienceUrn, BindingPolicy policy, Proxy proxy, SSLSocketFactory sslSocketFactory) throws Exception { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/soap+xml; charset=utf-8"); headers.put("return-client-request-id", "true"); // default value (WSTrust 1.3) String soapAction = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue"; // only change it if version is wsTrust2005, otherwise default to wsTrust13 if (policy.getVersion() == WSTrustVersion.WSTRUST2005) { // wsTrust2005 soap value soapAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue"; } headers.put("SOAPAction", soapAction); String body = buildMessage(policy.getUrl(), username, password, policy.getVersion(), cloudAudienceUrn).toString(); String response = HttpHelper.executeHttpPost(log, policy.getUrl(), body, headers, proxy, sslSocketFactory); return WSTrustResponse.parse(response, policy.getVersion()); }
private static Map<String, BindingPolicy> selectUsernamePasswordPolicies( Document xmlDocument, XPath xPath) throws XPathExpressionException { String xpathExpression = "//wsdl:definitions/wsp:Policy/wsp:ExactlyOne/wsp:All/" + "sp:SignedEncryptedSupportingTokens/wsp:Policy/sp:UsernameToken/" + "wsp:Policy/sp:WssUsernameToken10"; Map<String, BindingPolicy> policies = new HashMap<String, BindingPolicy>(); NodeList nodeList = (NodeList) xPath.compile(xpathExpression).evaluate( xmlDocument, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { String policy = checkPolicy(xPath, nodeList.item(i).getParentNode() .getParentNode().getParentNode().getParentNode() .getParentNode().getParentNode().getParentNode()); policies.put("#" + policy, new BindingPolicy("#" + policy)); } return policies; }
static WSTrustResponse execute(String username, String password, String cloudAudienceUrn, BindingPolicy policy, Proxy proxy, SSLSocketFactory sslSocketFactory) throws Exception { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/soap+xml; charset=utf-8"); headers.put("return-client-request-id", "true"); // default value (WSTrust 1.3) String soapAction = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue"; // only change it if version is wsTrust2005, otherwise default to wsTrust13 if (policy.getVersion() == WSTrustVersion.WSTRUST2005) { // wsTrust2005 soap value soapAction = "http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue"; } headers.put("SOAPAction", soapAction); String body = buildMessage(policy.getUrl(), username, password, policy.getVersion(), cloudAudienceUrn).toString(); String response = HttpHelper.executeHttpPost(log, policy.getUrl(), body, headers, proxy, sslSocketFactory); return WSTrustResponse.parse(response, policy.getVersion()); }
private static Map<String, BindingPolicy> selectUsernamePasswordPoliciesWithExpression( Document xmlDocument, XPath xPath, String xpathExpression, boolean logPii) throws XPathExpressionException { Map<String, BindingPolicy> policies = new HashMap<String, BindingPolicy>(); NodeList nodeList = (NodeList) xPath.compile(xpathExpression).evaluate( xmlDocument, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { // Nodes // sp:WssUsernameToken10 // wsp:Policy // sp:UsernameToken // wsp:Policy // sp:SignedEncryptedSupportingTokens // wsp:All // wsp:ExactlyOne // wsp:Policy String policy = checkPolicy(xPath, nodeList.item(i).getParentNode() .getParentNode().getParentNode().getParentNode() .getParentNode().getParentNode().getParentNode(), logPii); policies.put("#" + policy, new BindingPolicy("#" + policy)); } return policies; }
private static Map<String, BindingPolicy> selectUsernamePasswordPoliciesWithExpression( Document xmlDocument, XPath xPath, String xpathExpression, boolean logPii) throws XPathExpressionException { Map<String, BindingPolicy> policies = new HashMap<String, BindingPolicy>(); NodeList nodeList = (NodeList) xPath.compile(xpathExpression).evaluate( xmlDocument, XPathConstants.NODESET); for (int i = 0; i < nodeList.getLength(); i++) { // Nodes // sp:WssUsernameToken10 // wsp:Policy // sp:UsernameToken // wsp:Policy // sp:SignedEncryptedSupportingTokens // wsp:All // wsp:ExactlyOne // wsp:Policy String policy = checkPolicy(xPath, nodeList.item(i).getParentNode() .getParentNode().getParentNode().getParentNode() .getParentNode().getParentNode().getParentNode(), logPii); policies.put("#" + policy, new BindingPolicy("#" + policy)); } return policies; }