Bdxr201605Reader implements MetadataReader { @SuppressWarnings("all") @Override public PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse) throws LookupException, PeppolSecurityException { try { Document doc = DomUtils.parse(fetcherResponse.getInputStream()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Object o = ((JAXBElement<?>) unmarshaller.unmarshal(new DOMSource(doc))).getValue(); X509Certificate signer = null; if (o instanceof SignedServiceMetadataType) { signer = XmldsigVerifier.verify(doc); o = ((SignedServiceMetadataType) o).getServiceMetadata(); } ServiceInformationType serviceInformation = ((ServiceMetadataType) o).getServiceInformation(); List<ProcessMetadata<Endpoint>> processMetadatas = new ArrayList<>(); for (ProcessType processType : serviceInformation.getProcessList().getProcess()) { List<Endpoint> endpoints = new ArrayList<>(); for (EndpointType endpointType : processType.getServiceEndpointList().getEndpoint()) { endpoints.add(Endpoint.of( TransportProfile.of(endpointType.getTransportProfile()), URI.create(endpointType.getEndpointURI()), certificateInstance(endpointType.getCertificate()) )); } processMetadatas.add(ProcessMetadata.of( ProcessIdentifier.of( processType.getProcessIdentifier().getValue(), Scheme.of(processType.getProcessIdentifier().getScheme()) ), endpoints )); } return Signed.of(ServiceMetadata.of( ParticipantIdentifier.of( serviceInformation.getParticipantIdentifier().getValue(), Scheme.of(serviceInformation.getParticipantIdentifier().getScheme()) ), DocumentTypeIdentifier.of( serviceInformation.getDocumentIdentifier().getValue(), Scheme.of(serviceInformation.getDocumentIdentifier().getScheme()) ), processMetadatas ), signer); } catch (JAXBException | CertificateException | IOException | SAXException | ParserConfigurationException e) { throw new RuntimeException(e.getMessage(), e); } }  @SuppressWarnings("all") @Override List<ServiceReference> parseServiceGroup(FetcherResponse fetcherResponse); @SuppressWarnings("all") @Override PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse);  }
@Test(enabled = false) public void serviceMetadata() throws Exception { ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse( getClass().getResourceAsStream("/bdxr201407-servicemetadata-9908-810418052.xml"))).getContent(); ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii04:ver1.0"); try { result.getEndpoint(processIdentifier, TransportProfile.START); fail("Expected exception."); } catch (EndpointNotFoundException e) { } assertNotNull(result.getEndpoint(processIdentifier, TransportProfile.AS2_1_0)); assertEquals(result.getEndpoint( processIdentifier, TransportProfile.AS2_1_0).getCertificate().getSubjectDN().toString(), "CN=APP_1000000005, O=DIFI, C=NO" ); }