@Test public void serviceMetadata() throws Exception { ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse( getClass().getResourceAsStream("/busdox-servicemetadata-9908-991825827.xml"))).getContent(); ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0"); try { result.getEndpoint(processIdentifier, TransportProfile.START); fail("Expected exception."); } catch (EndpointNotFoundException e) { } }
@Override public PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse) throws LookupException, PeppolSecurityException { try { Document doc = DomUtils.parse(fetcherResponse.getInputStream()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<?> result = (JAXBElement) unmarshaller.unmarshal(new DOMSource(doc)); Object o = result.getValue(); X509Certificate signer = null; if (o instanceof SignedServiceMetadataType) { signer = XmldsigVerifier.verify(doc); o = ((SignedServiceMetadataType) o).getServiceMetadata(); } if (!(o instanceof ServiceMetadataType)) throw new LookupException("ServiceMetadata element not found."); ServiceInformationType serviceInformation = ((ServiceMetadataType) o).getServiceInformation(); List<ProcessMetadata<Endpoint>> processMetadatas = Lists.newArrayList(); for (ProcessType processType : serviceInformation.getProcessList().getProcess()) { List<Endpoint> endpoints = Lists.newArrayList(); for (EndpointType endpointType : processType.getServiceEndpointList().getEndpoint()) { Period period = Period.of( endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceActivationDate().toGregorianCalendar().getTime(), endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceExpirationDate().toGregorianCalendar().getTime() ); endpoints.add(Endpoint.of( TransportProfile.of(endpointType.getTransportProfile()), URI.create(endpointType.getEndpointReference().getAddress().getValue()), certificateInstance(Base64.decodeBase64(endpointType.getCertificate())), period )); } 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 LookupException(e.getMessage(), e); } }
BusdoxReader implements MetadataReader { @Override public PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse) throws LookupException, PeppolSecurityException { try { Document doc = DomUtils.parse(fetcherResponse.getInputStream()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<?> result = (JAXBElement) unmarshaller.unmarshal(new DOMSource(doc)); Object o = result.getValue(); X509Certificate signer = null; if (o instanceof SignedServiceMetadataType) { signer = XmldsigVerifier.verify(doc); o = ((SignedServiceMetadataType) o).getServiceMetadata(); } if (!(o instanceof ServiceMetadataType)) throw new LookupException("ServiceMetadata element not found."); ServiceInformationType serviceInformation = ((ServiceMetadataType) o).getServiceInformation(); List<ProcessMetadata<Endpoint>> processMetadatas = Lists.newArrayList(); for (ProcessType processType : serviceInformation.getProcessList().getProcess()) { List<Endpoint> endpoints = Lists.newArrayList(); for (EndpointType endpointType : processType.getServiceEndpointList().getEndpoint()) { Period period = Period.of( endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceActivationDate().toGregorianCalendar().getTime(), endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceExpirationDate().toGregorianCalendar().getTime() ); endpoints.add(Endpoint.of( TransportProfile.of(endpointType.getTransportProfile()), URI.create(endpointType.getEndpointReference().getAddress().getValue()), certificateInstance(Base64.decodeBase64(endpointType.getCertificate())), period )); } 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 LookupException(e.getMessage(), e); } } }
BusdoxReader implements MetadataReader { @Override public PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse) throws LookupException, PeppolSecurityException { try { Document doc = DomUtils.parse(fetcherResponse.getInputStream()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<?> result = (JAXBElement) unmarshaller.unmarshal(new DOMSource(doc)); Object o = result.getValue(); X509Certificate signer = null; if (o instanceof SignedServiceMetadataType) { signer = XmldsigVerifier.verify(doc); o = ((SignedServiceMetadataType) o).getServiceMetadata(); } if (!(o instanceof ServiceMetadataType)) throw new LookupException("ServiceMetadata element not found."); ServiceInformationType serviceInformation = ((ServiceMetadataType) o).getServiceInformation(); List<ProcessMetadata<Endpoint>> processMetadatas = Lists.newArrayList(); for (ProcessType processType : serviceInformation.getProcessList().getProcess()) { List<Endpoint> endpoints = Lists.newArrayList(); for (EndpointType endpointType : processType.getServiceEndpointList().getEndpoint()) { Period period = Period.of( endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceActivationDate().toGregorianCalendar().getTime(), endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceExpirationDate().toGregorianCalendar().getTime() ); endpoints.add(Endpoint.of( TransportProfile.of(endpointType.getTransportProfile()), URI.create(endpointType.getEndpointReference().getAddress().getValue()), certificateInstance(Base64.decodeBase64(endpointType.getCertificate())), period )); } 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 LookupException(e.getMessage(), e); } }  }
BusdoxReader implements MetadataReader { @Override public PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse) throws LookupException, PeppolSecurityException { try { Document doc = DomUtils.parse(fetcherResponse.getInputStream()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<?> result = (JAXBElement) unmarshaller.unmarshal(new DOMSource(doc)); Object o = result.getValue(); X509Certificate signer = null; if (o instanceof SignedServiceMetadataType) { signer = XmldsigVerifier.verify(doc); o = ((SignedServiceMetadataType) o).getServiceMetadata(); } if (!(o instanceof ServiceMetadataType)) throw new LookupException("ServiceMetadata element not found."); ServiceInformationType serviceInformation = ((ServiceMetadataType) o).getServiceInformation(); List<ProcessMetadata<Endpoint>> processMetadatas = Lists.newArrayList(); for (ProcessType processType : serviceInformation.getProcessList().getProcess()) { List<Endpoint> endpoints = Lists.newArrayList(); for (EndpointType endpointType : processType.getServiceEndpointList().getEndpoint()) { Period period = Period.of( endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceActivationDate().toGregorianCalendar().getTime(), endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceExpirationDate().toGregorianCalendar().getTime() ); endpoints.add(Endpoint.of( TransportProfile.of(endpointType.getTransportProfile()), URI.create(endpointType.getEndpointReference().getAddress().getValue()), certificateInstance(Base64.decodeBase64(endpointType.getCertificate())), period )); } 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 LookupException(e.getMessage(), e); } }  @SuppressWarnings("all") @Override List<ServiceReference> parseServiceGroup(FetcherResponse fetcherResponse); @Override PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse); }
BusdoxReader implements MetadataReader { @Override public PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse) throws LookupException, PeppolSecurityException { try { Document doc = DomUtils.parse(fetcherResponse.getInputStream()); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<?> result = (JAXBElement) unmarshaller.unmarshal(new DOMSource(doc)); Object o = result.getValue(); X509Certificate signer = null; if (o instanceof SignedServiceMetadataType) { signer = XmldsigVerifier.verify(doc); o = ((SignedServiceMetadataType) o).getServiceMetadata(); } if (!(o instanceof ServiceMetadataType)) throw new LookupException("ServiceMetadata element not found."); ServiceInformationType serviceInformation = ((ServiceMetadataType) o).getServiceInformation(); List<ProcessMetadata<Endpoint>> processMetadatas = Lists.newArrayList(); for (ProcessType processType : serviceInformation.getProcessList().getProcess()) { List<Endpoint> endpoints = Lists.newArrayList(); for (EndpointType endpointType : processType.getServiceEndpointList().getEndpoint()) { Period period = Period.of( endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceActivationDate().toGregorianCalendar().getTime(), endpointType.getServiceActivationDate() == null ? null : endpointType.getServiceExpirationDate().toGregorianCalendar().getTime() ); endpoints.add(Endpoint.of( TransportProfile.of(endpointType.getTransportProfile()), URI.create(endpointType.getEndpointReference().getAddress().getValue()), certificateInstance(Base64.decodeBase64(endpointType.getCertificate())), period )); } 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 LookupException(e.getMessage(), e); } }  @SuppressWarnings("all") @Override List<ServiceReference> parseServiceGroup(FetcherResponse fetcherResponse); @Override PotentiallySigned<ServiceMetadata> parseServiceMetadata(FetcherResponse fetcherResponse);  }