BDXRClientReadOnly extends AbstractGenericSMPClient <BDXRClientReadOnly> implements
                                IBDXRServiceGroupProvider,
                                IBDXRServiceMetadataProvider { @Nonnull public SignedServiceMetadataType getServiceMetadata (@Nonnull final IParticipantIdentifier aServiceGroupID, @Nonnull final IDocumentTypeIdentifier aDocumentTypeID) throws SMPClientException { ValueEnforcer.notNull (aServiceGroupID, "ServiceGroupID"); ValueEnforcer.notNull (aDocumentTypeID, "DocumentTypeID"); final String sURI = getSMPHostURI () + aServiceGroupID.getURIPercentEncoded () + "/" + URL_PART_SERVICES + "/" + aDocumentTypeID.getURIPercentEncoded (); if (LOGGER.isDebugEnabled ()) LOGGER.debug ("BDXRClient getServiceRegistration@" + sURI); final boolean bXSDValidation = isXMLSchemaValidation (); final boolean bVerifySignature = isVerifySignature (); final KeyStore aTrustStore = getTrustStore (); HttpGet aRequest = new HttpGet (sURI); SignedServiceMetadataType aMetadata = executeGenericRequest (aRequest, new SMPHttpResponseHandlerSigned <> (new BDXR1MarshallerSignedServiceMetadataType (bXSDValidation), aTrustStore).setVerifySignature (bVerifySignature)); if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Received response: " + aMetadata); if (isFollowSMPRedirects ()) { if (aMetadata.getServiceMetadata () != null && aMetadata.getServiceMetadata ().getRedirect () != null) { final RedirectType aRedirect = aMetadata.getServiceMetadata ().getRedirect (); if (LOGGER.isInfoEnabled ()) LOGGER.info ("Following a redirect from '" + sURI + "' to '" + aRedirect.getHref () + "'"); aRequest = new HttpGet (aRedirect.getHref ()); aMetadata = executeGenericRequest (aRequest, new SMPHttpResponseHandlerSigned <> (new BDXR1MarshallerSignedServiceMetadataType (bXSDValidation), aTrustStore).setVerifySignature (bVerifySignature)); boolean bCertificateSubjectFound = false; outer: for (final Object aObj : aMetadata.getSignature ().getKeyInfo ().getContent ()) { final Object aInfoValue = ((JAXBElement <?>) aObj).getValue (); if (aInfoValue instanceof X509DataType) { final X509DataType aX509Data = (X509DataType) aInfoValue; for (final Object aX509Obj : aX509Data.getX509IssuerSerialOrX509SKIOrX509SubjectName ()) { final JAXBElement <?> aX509element = (JAXBElement <?>) aX509Obj; if (aX509element.getValue () instanceof String) { final String sSubject = (String) aX509element.getValue (); if (!aRedirect.getCertificateUID ().equals (sSubject)) { throw new SMPClientException ("The certificate UID of the redirect did not match the certificate subject. Subject is '" + sSubject + "'. Required certificate UID is '" + aRedirect.getCertificateUID () + "'"); } bCertificateSubjectFound = true; break outer; } } } } if (!bCertificateSubjectFound) throw new SMPClientException ("The X509 certificate did not contain a certificate subject."); } } else { if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Following SMP redirects is disabled"); } return aMetadata; } BDXRClientReadOnly(@Nonnull final ISMPURLProvider aURLProvider,
                             @Nonnull final IParticipantIdentifier aParticipantIdentifier,
                             @Nonnull final ISMLInfo aSMLInfo);  BDXRClientReadOnly(@Nonnull final ISMPURLProvider aURLProvider,
                             @Nonnull final IParticipantIdentifier aParticipantIdentifier,
                             @Nonnull @Nonempty final String sSMLZoneName);  BDXRClientReadOnly(@Nonnull final URI aSMPHost); @Nonnull ServiceGroupType getServiceGroup(@Nonnull final IParticipantIdentifier aServiceGroupID); @Nullable ServiceGroupType getServiceGroupOrNull(@Nonnull final IParticipantIdentifier aServiceGroupID); @Nonnull static ICommonsList <IDocumentTypeIdentifier> getAllDocumentTypes(@Nullable final ServiceGroupType aSG,
                                                                            @Nonnull final IIdentifierFactory aIdentifierFactory,
                                                                            @Nullable final Consumer <String> aUnhandledHrefHandler); @Nonnull SignedServiceMetadataType getServiceMetadata(@Nonnull final IParticipantIdentifier aServiceGroupID,
                                                       @Nonnull final IDocumentTypeIdentifier aDocumentTypeID); @Nullable SignedServiceMetadataType getServiceMetadataOrNull(@Nonnull final IParticipantIdentifier aServiceGroupID,
                                                             @Nonnull final IDocumentTypeIdentifier aDocumentTypeID); @Nullable static EndpointType getEndpoint(@Nonnull final SignedServiceMetadataType aSignedServiceMetadata,
                                          @Nonnull final IProcessIdentifier aProcessID,
                                          @Nonnull final ISMPTransportProfile aTransportProfile); @Nullable static String getEndpointAddress(@Nullable final EndpointType aEndpoint); @Nullable static byte [] getEndpointCertificateBytes(@Nullable final EndpointType aEndpoint); @Nullable static X509Certificate getEndpointCertificate(@Nullable final EndpointType aEndpoint); @Nullable static X509Certificate getEndpointCertificateOrNull(@Nullable final EndpointType aEndpoint); @Nonnull static ServiceGroupType getServiceGroupByDNS(@Nonnull final ISMPURLProvider aURLProvider,
                                                       @Nonnull final ISMLInfo aSMLInfo,
                                                       @Nonnull final IParticipantIdentifier aServiceGroupID); @Nonnull static SignedServiceMetadataType getServiceRegistrationByDNS(@Nonnull final ISMPURLProvider aURLProvider,
                                                                       @Nonnull final ISMLInfo aSMLInfo,
                                                                       @Nonnull final IParticipantIdentifier aServiceGroupID,
                                                                       @Nonnull final IDocumentTypeIdentifier aDocumentTypeID); static final String URL_PART_SERVICES; }
@Test @Ignore @IgnoredNaptrTest public void testRead () throws SMPDNSResolutionException, SMPClientException { final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme ("9930:167064991"); final IDocumentTypeIdentifier aDocTypeID = SimpleIdentifierFactory.INSTANCE.createDocumentTypeIdentifier ("toop-doctypeid-qns", "urn:eu:toop:ns:dataexchange-1p40::Response##urn:eu.toop.response.registeredorganization::1.40"); final ISMLInfo aSMLInfo = new SMLInfo ("toop", "SMK", "toop.acc.edelivery.tech.ec.europa.eu.", "https: true); final BDXRClientReadOnly aBDXRClient = new BDXRClientReadOnly (BDXLURLProvider.INSTANCE, aPI, aSMLInfo); aBDXRClient.setVerifySignature (false); assertEquals ("http: if (false) { final SignedServiceMetadataType aMetadata = aBDXRClient.getServiceMetadata (aPI, aDocTypeID); assertNotNull (aMetadata); } }