From b6d6d65334689f60d41a4eba1a1660c12e90d580 Mon Sep 17 00:00:00 2001 From: kstranacher Date: Wed, 14 Jul 2010 15:17:36 +0000 Subject: git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@1173 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../auth/validator/parep/client/szrgw/SZRGWClient.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/SZRGWClient.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/SZRGWClient.java index 2080118d0..9cb7c7ab4 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/SZRGWClient.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/SZRGWClient.java @@ -18,6 +18,7 @@ package at.gv.egovernment.moa.id.auth.validator.parep.client.szrgw; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.File; import javax.net.ssl.SSLSocketFactory; import javax.xml.parsers.DocumentBuilder; @@ -27,6 +28,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.protocol.Protocol; +import org.apache.xpath.XPathAPI; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -34,6 +36,7 @@ import org.w3c.dom.NodeList; import org.w3c.dom.Text; import at.gv.egovernment.moa.id.auth.validator.parep.ParepUtils; +import at.gv.egovernment.moa.util.Constants; import at.gv.egovernment.moa.util.DOMUtils; @@ -196,7 +199,19 @@ public class SZRGWClient { } else { // set assertion - response.setAssertion(doc.getDocumentElement()); + DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document newdoc = builder.newDocument(); + + Element nameSpaceNode = newdoc.createElement("NameSpaceNode"); + nameSpaceNode.setAttribute("xmlns:" + Constants.DSIG_PREFIX, Constants.DSIG_NS_URI); + nameSpaceNode.setAttribute("xmlns:" + Constants.SAML_PREFIX, Constants.SAML_NS_URI); + + Element samlAssertion = (Element)XPathAPI.selectSingleNode(doc, "//saml:Assertion[1]", nameSpaceNode); + + if (samlAssertion == null) + throw new SZRGWClientException("Could not found a saml:Assertion element in response."); + else + response.setAssertion(samlAssertion); } return response; -- cgit v1.2.3