diff options
Diffstat (limited to 'id.server/src/test/at/gv/egovernment/moa/id/proxy')
5 files changed, 724 insertions, 0 deletions
diff --git a/id.server/src/test/at/gv/egovernment/moa/id/proxy/AllTests.java b/id.server/src/test/at/gv/egovernment/moa/id/proxy/AllTests.java new file mode 100644 index 000000000..2dd6cd35e --- /dev/null +++ b/id.server/src/test/at/gv/egovernment/moa/id/proxy/AllTests.java @@ -0,0 +1,31 @@ +package test.at.gv.egovernment.moa.id.proxy; + +import test.at.gv.egovernment.moa.id.proxy.builder.SAMLRequestBuilderTest; +import test.at.gv.egovernment.moa.id.proxy.parser.SAMLResponseParserTest; +import junit.awtui.TestRunner; +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @author Paul Ivancsics + * @version $Id$ + */ +public class AllTests { + + public static Test suite() { + TestSuite suite = new TestSuite(); + + suite.addTestSuite(SAMLRequestBuilderTest.class); + suite.addTestSuite(SAMLResponseParserTest.class); + + return suite; + } + + public static void main(String[] args) { + try { + TestRunner.run(AllTests.class); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/proxy/builder/DOMTreeCompare.java b/id.server/src/test/at/gv/egovernment/moa/id/proxy/builder/DOMTreeCompare.java new file mode 100644 index 000000000..aec14ce1c --- /dev/null +++ b/id.server/src/test/at/gv/egovernment/moa/id/proxy/builder/DOMTreeCompare.java @@ -0,0 +1,462 @@ +package test.at.gv.egovernment.moa.id.proxy.builder; + +import java.io.PrintStream; +import java.util.ArrayList; + +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Text; + +import at.gv.egovernment.moa.util.Base64Utils; + +/** + * @author Administrator + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class DOMTreeCompare { + + boolean debug = true; + + private static PrintStream Log = null; + + static + { + Log = System.out; + } + + public boolean compareElements(Element root1, Element root2) + { + //Log.println("----- Compare Elements:"+root1.getNodeName()+" "+root2.getNodeName()); + filterTree(root1); + filterTree(root2); + return compareNodes(root1,root2,0,"root/",false); + } + + private boolean compareNodes(Node n1, Node n2, int level,String path,boolean attribute) + { + /*try { + Log.println(DOMUtils.serializeNode(n1)); + } + catch(Exception e) + { + e.printStackTrace(); + }*/ + boolean equal = false; + //Log.println("----- Compare Node "+level+":"+n1+" "+n2); + //Log.println("----- Compare Node "+level+":"+n1.getNodeName()+" "+n2.getNodeName()); + //Log.println("----- Checking:"+path+getPathString(n1)); + NodeList nl1 = n1.getChildNodes(); + NodeList nl2 = n2.getChildNodes(); + + int size1 = nl1.getLength(); + int size2 = nl2.getLength(); + + if(debug)display_one(n1); + if(debug)display_one(n2); + + + if(debug) + if(n1.getNodeName().equals("Base64Content") && n2.getNodeName().equals("Base64Content")) + { + try { + Log.println("CONT:"+new String(Base64Utils.decode(strip(n1.getChildNodes().item(0).getNodeValue()),false))); + Log.println("CONT:"+new String(Base64Utils.decode(strip(n2.getChildNodes().item(0).getNodeValue()),false))); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + if(size1 != size2) + { + Log.println("----- Anzahl der Kinder nicht gleich:"+path+getPathString(n1)+":"+getPathString(n2)); + return false; + } + + equal = compareNodeExact(n1,n2,level,path+getPathString(n1)+"/"); + if(!equal) + { + Log.println("----- Knoten sind nicht identisch:"+path+getPathString(n1)); + return false; + } + + if(n1.hasAttributes() || n2.hasAttributes()) + { + equal = compareNodeAttriubtes(n1,n2,level+1,path+getPathString(n1)+"/(a)"); + if(!equal) + { + Log.println("----- Attribute stimmen nicht überein:"+path+getPathString(n1)); + return false; + } + } + if(size1==0) + { + return true; + } + + for(int counter=0;counter<size1;counter++) + { + boolean found = false; + Node comp_n1 = nl1.item(counter); + + //if(comp_n1==null) return false; + + Node comp_n2 = null; + size2 = nl2.getLength(); + for(int counter2=0;counter2<size2;counter2++) + { + comp_n2 = nl2.item(counter2); + + /*equal = compareNodeExact(comp_n1,comp_n2,level+1); + if(equal) return false;*/ + //Log.println("COMP_N1:"+comp_n1); + //Log.println("COMP_N2:"+comp_n2); + equal = compareNodes(comp_n1,comp_n2,level+1,path+getPathString(comp_n1)+"/",false); + if(equal) + { + n2.removeChild(comp_n2); + counter2=size2; + nl2 = n2.getChildNodes(); + size2 = nl2.getLength(); + } + + } + + if(!equal) + { + Log.println("----- Keine Übereinstimmung gefunden:"+path+getPathString(comp_n1)); + return false; + } + } + return true; + } + + private boolean compareNodeExact(Node n1,Node n2,int level,String path) + { + if(n1.getNodeType() == Node.TEXT_NODE) + { + Text textnode = (Text)n1; + /*Log.println("----- *****"+textnode.getNodeName()); + Log.println("----- *****"+textnode.getParentNode().getNodeName()); + Log.println("----- *****"+textnode.getNodeValue());*/ + } + + //Log.println("----- Checking:"+path); + String n1_name = n1.getNodeName(); + String n2_name = n2.getNodeName(); + /*Log.println("----- !!!!!"+n1.getNodeName()); + Log.println("----- !!!!!"+n1.getNodeValue()); + Log.println("----- !!!!!"+n1.getLocalName()); + Log.println("----- !!!!!"+n1.getPrefix()); + Log.println("----- !!!!!"+n1.getNextSibling()); + Log.println("----- !!!!!"+n1.getPreviousSibling());*/ + + //Log.println("----- Compare Node "+level+":"+n1_name+" "+n2_name); + if(!((n1_name==null && n2_name==null) || + (n1_name!=null && n2_name!=null && n1_name.equals(n2_name)))) + { + Log.println("----- Name stimmt nicht überein:"+path); + return false; + } + + //Log.println("----- Compare Node "+level+":"+n1.getNodeType()+" "+n2.getNodeType()); + if(n1.getNodeType() != n2.getNodeType()) + { + Log.println("----- Knotentyp stimmt nicht überein:"+path); + return false; + } + + String n1_ns = n1.getPrefix(); + String n2_ns = n2.getPrefix(); + //Log.println("----- Compare Node "+level+":"+n1_ns+" "+n2_ns); + if(!((n1_ns==null && n2_ns==null) || + (n1_ns!=null && n2_ns!=null && n1_ns.equals(n2_ns)))) + { + Log.println("----- NameSpace stimmt nicht überein:"+path); + return false; + } + + String n1_value = n1.getNodeValue(); + String n2_value = n2.getNodeValue(); + + boolean special = false; + special = specialValues(n1_value,n2_value,path); + if(special) return true; + + //Log.println("----- Compare Node "+level+":"+n1_value+" "+n2_value); + if(!((n1_value==null && n2_value==null) || + (n1_value!=null && n2_value!=null && n1_value.equals(n2_value)))) + { + Log.println("----- Wert stimmt nicht überein:"+path); + Log.println("----- Value1:\n"+n1_value); + Log.println("----- Value2:\n"+n2_value); + return false; + } + + + return true; + } + + private boolean compareNodeAttriubtesWithoutSize(Node n1, Node n2, int level,String path) + { + return true; + } + + private boolean compareNodeAttriubtes(Node n1, Node n2, int level,String path) + { + //Log.println("----- Compare NodeAttributes "+level+":"+n1.getNodeName()+" "+n2.getNodeName()); + Element n1elem = (Element)n1; + Element n2elem = (Element)n2; + + NamedNodeMap nnm1 = n1.getAttributes(); + NamedNodeMap nnm2 = n2.getAttributes(); + + int size1 = 0; + int size2 = 0; + + boolean specialattrs = specialAttributesSize(path); + + if(!specialattrs) + { + + if(nnm1==null && nnm2==null) return true; + if(nnm1==null || nnm2==null) + { + Log.println("----- Anzahl der Attribute nicht gleich:"+path+":"+getPathString(n1)); + return false; + } + size1 = nnm1.getLength(); + size2 = nnm2.getLength(); + + if(size1 != size2) + { + Log.println("----- Anzahl der Attribute nicht gleich:"+path+":"+getPathString(n1)); + return false; + } + + } + else + { + return compareNodeAttriubtesWithoutSize(n1,n2,level,path); + } + + for(int counter=0;counter<size1;counter++) + { + Node attribute_node1 = nnm1.item(counter); + Node attribute_node2 = nnm2.item(counter); + + String attr1_name = attribute_node1.getNodeName(); + String attr2_name = attribute_node2.getNodeName(); + + String value1 = n1elem.getAttribute(attr1_name); + String value2 = n2elem.getAttribute(attr2_name); + + boolean special = false; + + special = specialAttributes(path,attr1_name,value1,attr2_name,value2); + if(special) + { + return special; + } + + if(!value1.equals(value2)) + { + Log.println("----- Keine Übereinstimmung gefunden:"+path+getPathString(n1)); + return false; + } + } + + return true; + } + + private boolean checkNode(Node base,String name) + { + if(base.getNodeName().equals(name)) + { + return true; + } + + NodeList children = base.getChildNodes(); + int size = children.getLength(); + for(int counter=0;counter<size;counter++) + { + boolean found = checkNode(children.item(counter),name); + if(found) return true; + } + return false; + } + + private void display_one(Node base) + { + int att_size=0; + if(base.getAttributes()!=null) + { + att_size=base.getAttributes().getLength(); + } + if(base.getNodeName().equals("#text")) + Log.println(base.getNodeName()+base.getChildNodes().getLength()+":"+att_size+" ("+base.getNodeValue()+")"); + else + Log.println(base.getNodeName()+base.getChildNodes().getLength()+":"+att_size); + } + + private void display(Node base) + { + display(base,1); + } + + private void display(Node base,int level) + { + String spacer = ""; + for(int counter=0;counter<level;counter++) + { + spacer+=" "; + } + + int att_size=0; + if(base.getAttributes()!=null) + { + att_size=base.getAttributes().getLength(); + } + if(base.getNodeName().equals("#text")) + Log.println(spacer+base.getNodeName()+base.getChildNodes().getLength()+":"+att_size+" ("+base.getNodeValue()+")"); + else + Log.println(spacer+base.getNodeName()+base.getChildNodes().getLength()+":"+att_size); + + NodeList children = base.getChildNodes(); + int size = children.getLength(); + for(int counter=0;counter<size;counter++) + { + display(children.item(counter),level+1); + } + } + + private void filterTree(Node base) + { + ArrayList removeList = new ArrayList(); + + NodeList children = base.getChildNodes(); + int size = children.getLength(); + for(int counter=0;counter<size;counter++) + { + Node child1 = children.item(counter); + if(child1.getNodeType() == Node.TEXT_NODE && child1.getNodeValue().trim().equals("")) + { + removeList.add(child1); + } + } + + size = removeList.size(); + for(int counter=0;counter<size;counter++) + { + base.removeChild((Node)removeList.get(counter)); + } + + children = base.getChildNodes(); + size = children.getLength(); + for(int counter=0;counter<size;counter++) + { + filterTree(children.item(counter)); + } + + } + + private String getPathString(Node n) + { + if(n.getNodeType()==Node.TEXT_NODE) + { + return n.getParentNode().getNodeName()+"(text)"; + } + else + { + return n.getNodeName(); + } + + } + + public boolean specialAttributes(String path,String attr1_name,String value1,String attr2_name,String value2) + { + //if(value1.startsWith("reference-") && value2.startsWith("reference-")) return true; + //if(value1.startsWith("signature-") && value2.startsWith("signature-")) return true; + + return false; + } + + public boolean specialAttributesSize(String path) + { + //if(path.endsWith("/xsl:template/(a)")) return true; + return false; + } + + public boolean specialValues(String value1,String value2,String path) + { + + //Log.println(path); + /*if(ignoreSignatureValue) + { + if(path.endsWith("/dsig:SignatureValue(text)/")) + { + return true; + } + } + else + { + if(path.endsWith("/dsig:SignatureValue(text)/")) + { + String stripped_1 = strip(value1); + String stripped_2 = strip(value2); + return stripped_1.equals(stripped_2); + } + }*/ + + return false; + } + + private String strip(String input) + { + String output = replaceStringAll(input," ",""); + output = replaceStringAll(output,"\n",""); + output = replaceStringAll(output,"\r",""); + return output; + } + + private static String replaceStringAll( + String input, + String oldPart, + String newPart) + { + + String erg = null; + + int pos = input.indexOf(oldPart); + if(pos==-1) return input; + + while(true) + { + + //First Part + pos = input.indexOf(oldPart); + if(pos==-1) break; + erg = input.substring(0, pos); + + //Insert new Part + erg += newPart; + + //insert REST + erg + += input.substring( + input.indexOf(oldPart) + oldPart.length(), + input.length()); + + input = erg; + } + return erg; + } + +} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/proxy/builder/SAMLRequestBuilderTest.java b/id.server/src/test/at/gv/egovernment/moa/id/proxy/builder/SAMLRequestBuilderTest.java new file mode 100644 index 000000000..b6eda3c39 --- /dev/null +++ b/id.server/src/test/at/gv/egovernment/moa/id/proxy/builder/SAMLRequestBuilderTest.java @@ -0,0 +1,32 @@ +package test.at.gv.egovernment.moa.id.proxy.builder; + +import org.w3c.dom.Element; + +import test.at.gv.egovernment.moa.id.UnitTestCase; +import at.gv.egovernment.moa.id.auth.builder.SAMLArtifactBuilder; +import at.gv.egovernment.moa.id.proxy.builder.SAMLRequestBuilder; +import at.gv.egovernment.moa.util.DOMUtils; + +/* + * @author Paul Ivancsics + * @version $Id$ + */ +public class SAMLRequestBuilderTest extends UnitTestCase { + + public SAMLRequestBuilderTest(String arg0) { + super(arg0); + } + + public void testBuild() throws Exception { + String requestID = "123"; + String samlArtifact = new SAMLArtifactBuilder().build("https://moa.gv.at/auth/", "12345678901234567890"); + String REQUEST_SHOULD = "<samlp:Request xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" RequestID=\"" + + requestID + "\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"IGNORE\">" + + "<samlp:AssertionArtifact>" + samlArtifact + "</samlp:AssertionArtifact>" + + "</samlp:Request>"; + Element request = new SAMLRequestBuilder().build(requestID, samlArtifact); + Element requestShould = DOMUtils.parseDocument(REQUEST_SHOULD, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); + assertTrue(new SAMLRequestCompare().compareElements(requestShould, request)); + } + +} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/proxy/builder/SAMLRequestCompare.java b/id.server/src/test/at/gv/egovernment/moa/id/proxy/builder/SAMLRequestCompare.java new file mode 100644 index 000000000..5685129a1 --- /dev/null +++ b/id.server/src/test/at/gv/egovernment/moa/id/proxy/builder/SAMLRequestCompare.java @@ -0,0 +1,19 @@ +package test.at.gv.egovernment.moa.id.proxy.builder; + +/* + * @author Paul Ivancsics + * @version $Id$ + */ +public class SAMLRequestCompare extends test.at.gv.egovernment.moa.id.proxy.builder.DOMTreeCompare { + + + /* + * @see at.gv.egovernment.moa.util.SAMLRequestCompare#specialAttributes(java.lang.String, java.lang.String) + */ + public boolean specialAttributes(String path,String attr1_name,String value1,String attr2_name,String value2) { + if(attr1_name.equals("IssueInstant")) + return true; + return false; + } + +} diff --git a/id.server/src/test/at/gv/egovernment/moa/id/proxy/parser/SAMLResponseParserTest.java b/id.server/src/test/at/gv/egovernment/moa/id/proxy/parser/SAMLResponseParserTest.java new file mode 100644 index 000000000..39e7240d1 --- /dev/null +++ b/id.server/src/test/at/gv/egovernment/moa/id/proxy/parser/SAMLResponseParserTest.java @@ -0,0 +1,180 @@ +package test.at.gv.egovernment.moa.id.proxy.parser; + +import org.w3c.dom.Element; + +import test.at.gv.egovernment.moa.id.UnitTestCase; + +import at.gv.egovernment.moa.id.data.AuthenticationData; +import at.gv.egovernment.moa.id.data.SAMLStatus; +import at.gv.egovernment.moa.id.proxy.parser.SAMLResponseParser; +import at.gv.egovernment.moa.util.Constants; +import at.gv.egovernment.moa.util.DOMUtils; + +/* + * @author Paul Ivancsics + * @version $Id$ + */ +public class SAMLResponseParserTest extends UnitTestCase { + + public SAMLResponseParserTest(String arg0) { + super(arg0); + } + + public void testParse() throws Exception { + String samlResponse = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<samlp:Response xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\"" + + " ResponseID=\"\" MajorVersion=\"1\" MinorVersion=\"0\" IssueInstant=\"2003-03-29T06:00:00+02:00\">" + + "<samlp:Status>" + + "<samlp:StatusCode Value=\"samlp:Success\"><samlp:StatusCode Value=\"samlp:Success\"></samlp:StatusCode></samlp:StatusCode>" + + "<samlp:StatusMessage>Ollas leiwand</samlp:StatusMessage>" + + "</samlp:Status>" + +"<saml:Assertion xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:pr=\"http://reference.e-government.gv.at/namespace/persondata/20020228#\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" MajorVersion=\"1\" MinorVersion=\"0\" AssertionID=\"-4633313027464114584\" Issuer=\"http://localhost:8080/moa-id-auth/\" IssueInstant=\"2003-04-02T14:55:42+02:00\">" + + "<saml:AttributeStatement>" + + "<saml:Subject>" + + "<saml:NameIdentifier NameQualifier=\"http://reference.e-government.gv.at/names/vpk/20020221#\">MTk2OC0xMC0yMmdi</saml:NameIdentifier>" + + "<saml:SubjectConfirmation>" + + "<saml:ConfirmationMethod>http://reference.e-government.gv.at/namespace/moa/20020822#cm</saml:ConfirmationMethod>" + + "<saml:SubjectConfirmationData>" + + "<saml:Assertion xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" MajorVersion=\"1\" MinorVersion=\"0\" AssertionID=\"any\" Issuer=\"Hermann Muster\" IssueInstant=\"2003-04-02T14:55:27+02:00\">" + + "<saml:AttributeStatement>" + + "<saml:Subject>" + + "<saml:NameIdentifier>http://localhost:8080/moa-id-auth/</saml:NameIdentifier>" + + "</saml:Subject>" + + "<saml:Attribute AttributeName=\"Geschäftsbereich\" AttributeNamespace=\"http://reference.e-government.gv.at/namespace/moa/20020822#\">" + + "<saml:AttributeValue>gb</saml:AttributeValue>" + + "</saml:Attribute>" + + "<saml:Attribute AttributeName=\"OA\" AttributeNamespace=\"http://reference.e-government.gv.at/namespace/moa/20020822#\">" + + "<saml:AttributeValue>https://localhost:9443/</saml:AttributeValue>" + + "</saml:Attribute>" + + "</saml:AttributeStatement>" + + "</saml:Assertion>" + + "<saml:Assertion AssertionID=\"zmr.bmi.gv.at-AssertionID-2003-02-12T20:28:34.474\" IssueInstant=\"2003-02-12T20:28:34.474\" Issuer=\"http://zmr.bmi.gv.at/zmra/names#Issuer\" MajorVersion=\"1\" MinorVersion=\"0\" xmlns:pr=\"http://reference.e-government.gv.at/namespace/persondata/20020228#\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + + "<saml:AttributeStatement>" + + "<saml:Subject>" + + "<saml:SubjectConfirmation>" + + "<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:sender-vouches</saml:ConfirmationMethod>" + + "<saml:SubjectConfirmationData>" + + "<pr:Person xsi:type=\"pr:PhysicalPersonType\">" + + "<pr:Identification>" + + "<pr:Value>123456789012</pr:Value>" + + "<pr:Type>http://reference.e-government.gv.at/names/persondata/20020228#zmr-zahl</pr:Type>" + + "</pr:Identification>" + + "<pr:Name>" + + "<pr:GivenName>Hermann</pr:GivenName>" + + "<pr:FamilyName primary=\"undefined\">Muster</pr:FamilyName>" + + "</pr:Name>" + + "<pr:DateOfBirth>1968-10-22</pr:DateOfBirth>" + + "</pr:Person>" + + "</saml:SubjectConfirmationData>" + + "</saml:SubjectConfirmation>" + + "</saml:Subject>" + + "<saml:Attribute AttributeName=\"CitizenPublicKey\" AttributeNamespace=\"http://www.buergerkarte.at/namespaces/personenbindung/20020506#\">" + + "<saml:AttributeValue>" + + "<dsig:RSAKeyValue xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">" + + "<dsig:Modulus>0v1Ftf7WXgoexx0Jo/GrlExHOHnQIEQ5FFSjptLRd5BN1mZYRg2S9KfOMbHSCsiPm8AwjAEwE5EM A6P18Z/YyTIuP7fNGzckbB5PYIgNMHL8/TYJhHA8CjamsBrEfYDXivE8iAvALg5I9RMLZADmzL7a f2daYYuO8dycQw3xg6U=</dsig:Modulus>" + + "<dsig:Exponent>AQAB</dsig:Exponent>" + + "</dsig:RSAKeyValue>" + + "</saml:AttributeValue>" + + "</saml:Attribute>" + + "<saml:Attribute AttributeName=\"CitizenPublicKey\" AttributeNamespace=\"http://www.buergerkarte.at/namespaces/personenbindung/20020506#\">" + + "<saml:AttributeValue>" + + "<dsig:RSAKeyValue xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">" + + "<dsig:Modulus>i2qa56X4fpYeXqFLXAcQljGU3+DWnVgNrAxI9gn2bMeFWtLXE2SFa6qvl9EymUl0noBlFn0q9DWp AsyeLnRhzCAXJeSxiwsUEloOvcQCV0DfW2UVq0Y9bVlJ8KifJ2AS+5BxZ21mkc/VYx5Qz6EYjPrn pIpdAwR9sw5xnIvTySc=</dsig:Modulus>" + + "<dsig:Exponent>AQAB</dsig:Exponent>" + + "</dsig:RSAKeyValue>" + + "</saml:AttributeValue>" + + "</saml:Attribute>" + + "</saml:AttributeStatement>" + + "<dsig:Signature xmlns:dsig=\"http://www.w3.org/2000/09/xmldsig#\">" + + "<dsig:SignedInfo>" + + "<dsig:CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>" + + "<dsig:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>" + + "<dsig:Reference URI=\"\">" + + "<dsig:Transforms>" + + "<dsig:Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xpath-19991116\">" + + "<dsig:XPath>not(ancestor-or-self::pr:Identification)</dsig:XPath>" + + "</dsig:Transform>" + + "<dsig:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/>" + + "</dsig:Transforms>" + + "<dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>" + + "<dsig:DigestValue>s7TfoZrYo36OMdlxGxuIfAw/wr8=</dsig:DigestValue>" + + "</dsig:Reference>" + + "<dsig:Reference Type=\"http://www.w3.org/2000/09/xmldsig#Manifest\" URI=\"\">" + + "<dsig:Transforms>" + + "<dsig:Transform Algorithm=\"http://www.w3.org/TR/1999/REC-xpath-19991116\">" + + "<dsig:XPath>ancestor-or-self::dsig:Manifest</dsig:XPath>" + + "</dsig:Transform>" + + "</dsig:Transforms>" + + "<dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>" + + "<dsig:DigestValue>dO+RSn4xLHT3cuq8uopFtZyUBqo=</dsig:DigestValue>" + + "</dsig:Reference>" + + "</dsig:SignedInfo>" + + "<dsig:SignatureValue>MFbZ5wA5cq0UezYFDXted5uqXubWFxxRwZawGh73XEAGxAbJsT/IEQmrTQThPRHNWW5RPGxVlPDz 5BmjberdaWlgJlbyKf3b/WpNNJYptQ7ijrXlsQoCzjfiQy37NEfvHEcxHQOA6sa42C+dFKsKIvmP 3mZkRYWJDxxsVzI7E+Y=</dsig:SignatureValue>" + + "<dsig:KeyInfo>" + + "<dsig:X509Data>" + + "<dsig:X509Certificate>MIIDaDCCAtWgAwIBAgIBADAJBgUrDgMCHQUAMIGOMQswCQYDVQQGEwJBVDE9MDsG A1UEChQ0QnVuZGVzbWluaXN0ZXJpdW0gZvxyIPZmZmVudGxpY2hlIExlaXN0dW5n IHVuZCBTcG9ydDEjMCEGA1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R0OBBYEFIpEyv43H3EtiGr4I7Z34bWj v2z6MBYGByooAAoBAQEECwwJQk1PTFMtSUtUMB8GA1UdIwQYMBaAFJ5Fa9R/ESMp lJ/EiYmv9+kEO0yZMAkGBSsOAwIdBQADgYEAfMBJRy/kp8HQa0lGIBfFrWNpxVPv RsIu+N4IiFrswrsoQoMAh6IqNyzSdq7rJC08xsDkXe5HOwkb+2zGKYoC3aQ/J/zr BGkg6ec4tOaS/VSdEQeTL1L30r2faTffWLUV3GrzL7pM7jN470hB1w8F6Hc3LCI7 kFfp23o/juVtJNw=</dsig:X509Certificate>" + + "</dsig:X509Data>" + + "</dsig:KeyInfo>" + + "<dsig:Object>" + + "<dsig:Manifest>" + + "<dsig:Reference URI=\"\">" + + "<dsig:Transforms>" + + "<dsig:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/>" + + "</dsig:Transforms>" + + "<dsig:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>" + + "<dsig:DigestValue>BqzfCB7dNg4G3u4YaxpD1tALdKI=</dsig:DigestValue>" + + "</dsig:Reference>" + + "</dsig:Manifest>" + + "</dsig:Object>" + + "</dsig:Signature>" + + "</saml:Assertion>" + + "</saml:SubjectConfirmationData>" + + "</saml:SubjectConfirmation>" + + "</saml:Subject>" + + "<saml:Attribute AttributeName=\"PersonData\" AttributeNamespace=\"http://reference.e-government.gv.at/namespace/persondata/20020228#\">" + + "<saml:AttributeValue>" + + "<pr:Person xsi:type=\"pr:PhysicalPersonType\">" + + "<pr:Identification>" + + "<pr:Value>123456789012</pr:Value>" + + "<pr:Type>http://reference.e-government.gv.at/names/persondata/20020228#zmr-zahl</pr:Type>" + + "</pr:Identification>" + + "<pr:Name>" + + "<pr:GivenName>Hermann</pr:GivenName>" + + "<pr:FamilyName primary=\"undefined\">Muster</pr:FamilyName>" + + "</pr:Name>" + + "<pr:DateOfBirth>1968-10-22</pr:DateOfBirth>" + + "</pr:Person>" + + "</saml:AttributeValue>" + + "</saml:Attribute>" + + "<saml:Attribute AttributeName=\"isQualifiedCertificate\" AttributeNamespace=\"http://reference.e-government.gv.at/namespace/moa/20020822#\">" + + "<saml:AttributeValue>true</saml:AttributeValue>" + + "</saml:Attribute>" + + "</saml:AttributeStatement>" + +"</saml:Assertion>" + + "</samlp:Response>"; + + Element samlResponseElem = + DOMUtils.parseDocument(samlResponse, true, Constants.ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); + SAMLResponseParser parser = new SAMLResponseParser(samlResponseElem); + SAMLStatus status = parser.parseStatusCode(); + assertEquals("samlp:Success", status.getStatusCode()); + assertEquals("samlp:Success", status.getSubStatusCode()); + assertEquals("Ollas leiwand", status.getStatusMessage()); + AuthenticationData authData = parser.parseAuthenticationData(); + assertEquals(1, authData.getMajorVersion()); + assertEquals(0, authData.getMinorVersion()); + assertEquals("-4633313027464114584", authData.getAssertionID()); + assertEquals("http://localhost:8080/moa-id-auth/", authData.getIssuer()); + assertEquals("2003-04-02T14:55:42+02:00", authData.getIssueInstant()); + assertEquals("123456789012", authData.getIdentificationValue()); + assertEquals("MTk2OC0xMC0yMmdi", authData.getVPK()); + assertEquals("Hermann", authData.getGivenName()); + assertEquals("Muster", authData.getFamilyName()); + assertEquals("1968-10-22", authData.getDateOfBirth()); + assertTrue(authData.isQualifiedCertificate()); + assertFalse(authData.isPublicAuthority()); + } +} |