HttpRoutingAssertionBuilder implements PolicyAssertionBuilder { @Override public void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext) { final Bundle bundle = policyBuilderContext.getBundle(); final Element trustedCertNameElement = getSingleChildElement(assertionElement, TLS_TRUSTED_CERT_NAMES, true); if (trustedCertNameElement != null && trustedCertNameElement.getChildNodes().getLength() > 0) { Element trustedCertGoidElement = createElementWithAttribute( policyBuilderContext.getPolicyDocument(), TLS_TRUSTED_CERT_IDS, GOID_ARRAY_VALUE, "included" ); assertionElement.insertBefore(trustedCertGoidElement, trustedCertNameElement); final NodeList trustedCertNamesList = trustedCertNameElement.getChildNodes(); for (int i = 0; i < trustedCertNamesList.getLength(); i++) { final String trustedCertName = trustedCertNamesList.item(i).getAttributes().getNamedItem(STRING_VALUE).getTextContent(); final TrustedCert trustedCert = bundle.getTrustedCerts().get(trustedCertName); final String trustedCertId = getIdFromAnnotableEntity(trustedCert, policyBuilderContext.getIdGenerator()); Element trustedCertGoidItem = createElementWithAttribute( policyBuilderContext.getPolicyDocument(), PolicyXMLElements.ITEM, GOID_VALUE, trustedCertId ); trustedCertGoidElement.appendChild(trustedCertGoidItem); } } }  @Override void buildAssertionElement(Element assertionElement, PolicyBuilderContext policyBuilderContext); @Override String getAssertionTagName();  }
@Test void testPrepareRoutingAssertionCertificateIds() { bundle.putAllTrustedCerts(ImmutableMap.of("fake-cert-1", createTrustedCertWithAnnotation(AnnotationType.BUNDLE_HINTS, "2cd473fe16d98cd6b9348ffb404517bc"))); bundle.putAllTrustedCerts(ImmutableMap.of("fake-cert-2", createTrustedCertWithAnnotation(AnnotationType.BUNDLE_HINTS, "28be78b936aa61bc75bd0df2089789cd"))); Element httpRoutingAssertionElement = createHttpRoutingAssertionWithCertNames(document); policyBuilderContext = new PolicyBuilderContext("path.xml", document, bundle, new IdGenerator()); policyBuilderContext.withPolicy(policy); httpRoutingAssertionBuilder.buildAssertionElement(httpRoutingAssertionElement, policyBuilderContext); final Element trustedCertIDElement = getSingleChildElement(httpRoutingAssertionElement, TLS_TRUSTED_CERT_IDS, true); assertNotNull(trustedCertIDElement); assertEquals(2, trustedCertIDElement.getChildNodes().getLength()); assertEquals("2cd473fe16d98cd6b9348ffb404517bc", trustedCertIDElement.getChildNodes().item(0).getAttributes().getNamedItem(GOID_VALUE).getTextContent()); assertEquals("28be78b936aa61bc75bd0df2089789cd", trustedCertIDElement.getChildNodes().item(1).getAttributes().getNamedItem(GOID_VALUE).getTextContent()); }