LegalAddressAttribute extends CurrentAddressAttribute { @Override public String generate() { String value = super.getLatinScript(); return TemplateLoader.getTemplateByName("legalpersonaddress").replace("$base64Value", Utils.toBase64(value)); } LegalAddressAttribute(String locatorDesignator,
                               String thoroughfare,
                               String postName,
                               String postCode,
                               String pOBOX,
                               String locatorName,
                               String cvaddressArea,
                               String adminunitFirstline,
                               String adminunitSecondline);  LegalAddressAttribute(String xmlString);  LegalAddressAttribute(); @Override String generate(); @Override EidasAttributeType type(); @Override String toString(); @Override EidasPersonAttributes getPersonAttributeType();  }
@Test public void testGenerateLegalAddressAttribute() throws IOException { String locatorDesignator = "locatorDesignator"; String thoroughfare = "thoroughfare"; String postName = "postName"; String postCode = "postCode"; String pOBOX = "pOBOX"; String locatorName = "locatorName"; String cvaddressArea = "cvaddressArea"; String adminunitFirstline = "adminunitFirstline"; String adminunitSecondline = "adminunitSecondline"; LegalAddressAttribute attribute = new LegalAddressAttribute(locatorDesignator, thoroughfare, postName, postCode, pOBOX, locatorName, cvaddressArea, adminunitFirstline, adminunitSecondline); TemplateLoader.init(); String xml = attribute.generate(); Assertions.assertTrue(StringUtils.isNotEmpty(xml)); String substringBetween = StringUtils.substringBetween(xml, "<saml2:AttributeValue xsi:type=\"eidas:LegalPersonAddressType\">", "</saml2:AttributeValue>"); Assertions.assertTrue(StringUtils.isNotEmpty(substringBetween)); String base64Decoded = Utils.fromBase64(substringBetween); Assertions.assertTrue(StringUtils.isNotEmpty(base64Decoded)); Assertions.assertTrue(base64Decoded.contains("locatorDesignator")); Assertions.assertTrue(base64Decoded.contains("thoroughfare")); Assertions.assertTrue(base64Decoded.contains("postName")); Assertions.assertTrue(base64Decoded.contains("postCode")); Assertions.assertTrue(base64Decoded.contains("locatorName")); Assertions.assertTrue(base64Decoded.contains("cvaddressArea")); Assertions.assertTrue(base64Decoded.contains("adminunitFirstline")); Assertions.assertTrue(base64Decoded.contains("adminunitSecondline")); }
@Test public void testGenerateCurrentAddressAttribute() throws IOException { String locatorDesignator = "locatorDesignator"; String thoroughfare = "thoroughfare"; String postName = "postName"; String postCode = "postCode"; String pOBOX = "pOBOX"; String locatorName = "locatorName"; String cvaddressArea = "cvaddressArea"; String adminunitFirstline = "adminunitFirstline"; String adminunitSecondline = "adminunitSecondline"; CurrentAddressAttribute attribute = new CurrentAddressAttribute(locatorDesignator, thoroughfare, postName, postCode, pOBOX, locatorName, cvaddressArea, adminunitFirstline, adminunitSecondline); TemplateLoader.init(); String xml = attribute.generate(); Assertions.assertTrue(StringUtils.isNotEmpty(xml)); String substringBetween = StringUtils.substringBetween(xml, "<saml2:AttributeValue xsi:type=\"eidas:CurrentAddressType\">", "</saml2:AttributeValue>"); Assertions.assertTrue(StringUtils.isNotEmpty(substringBetween)); String base64Decoded = Utils.fromBase64(substringBetween); Assertions.assertTrue(StringUtils.isNotEmpty(base64Decoded)); Assertions.assertTrue(base64Decoded.contains("locatorDesignator")); Assertions.assertTrue(base64Decoded.contains("thoroughfare")); Assertions.assertTrue(base64Decoded.contains("postName")); Assertions.assertTrue(base64Decoded.contains("postCode")); Assertions.assertTrue(base64Decoded.contains("locatorName")); Assertions.assertTrue(base64Decoded.contains("cvaddressArea")); Assertions.assertTrue(base64Decoded.contains("adminunitFirstline")); Assertions.assertTrue(base64Decoded.contains("adminunitSecondline")); }