Package com.helger.smpclient.bdxr2
Class BDXR2ClientReadOnly
java.lang.Object
com.helger.smpclient.httpclient.AbstractGenericSMPClient<BDXR2ClientReadOnly>
com.helger.smpclient.bdxr2.BDXR2ClientReadOnly
- All Implemented Interfaces:
com.helger.commons.traits.IGenericImplTrait<BDXR2ClientReadOnly>,IBDXR2ServiceGroupProvider,IBDXR2ServiceMetadataProvider
- Direct Known Subclasses:
BDXR2Client
public class BDXR2ClientReadOnly
extends AbstractGenericSMPClient<BDXR2ClientReadOnly>
implements IBDXR2ServiceGroupProvider, IBDXR2ServiceMetadataProvider
This class is used for calling the OASIS BDXR SMP v2 REST interface. This
class only contains the read-only methods defined in the SMP specification
and nothing else.
Note: this class is also licensed under Apache 2 license, as it was not part of the original implementation
- Author:
- Philip Helger
-
Field Summary
FieldsFields inherited from class com.helger.smpclient.httpclient.AbstractGenericSMPClient
CONTENT_TYPE_TEXT_XML, DEFAULT_FOLLOW_REDIRECTS, DEFAULT_XML_SCHEMA_VALIDATION -
Constructor Summary
ConstructorsConstructorDescriptionBDXR2ClientReadOnly(ISMPURLProvider aURLProvider, com.helger.peppolid.IParticipantIdentifier aParticipantIdentifier, com.helger.peppol.sml.ISMLInfo aSMLInfo) Constructor with SML lookupBDXR2ClientReadOnly(ISMPURLProvider aURLProvider, com.helger.peppolid.IParticipantIdentifier aParticipantIdentifier, String sSMLZoneName) Constructor with SML lookupBDXR2ClientReadOnly(URI aSMPHost) Constructor with a direct SMP URL.
Remember: must be HTTP and using port 80 only! -
Method Summary
Modifier and TypeMethodDescriptionstatic com.helger.commons.collection.impl.ICommonsList<com.helger.peppolid.IDocumentTypeIdentifier> getAllDocumentTypes(com.helger.xsds.bdxr.smp2.ServiceGroupType aSG, com.helger.peppolid.factory.IIdentifierFactory aIdentifierFactory) Extract all document types from the passed Service group.static com.helger.xsds.bdxr.smp2.ac.EndpointTypegetEndpoint(com.helger.xsds.bdxr.smp2.ServiceMetadataType aServiceMetadata, com.helger.peppolid.IProcessIdentifier aProcessID, com.helger.peppol.smp.ISMPTransportProfile aTransportProfile) Extract the Endpoint from the ServiceMetadata that matches the passed process ID and the optional required transport profile.static StringgetEndpointAddress(com.helger.xsds.bdxr.smp2.ac.EndpointType aEndpoint) Get the endpoint address URI from the provided SMP endpoint.static X509CertificategetEndpointCertificate(com.helger.xsds.bdxr.smp2.ac.EndpointType aEndpoint) Get the certificate bytes from the specified endpoint.static byte[]getEndpointCertificateBytes(com.helger.xsds.bdxr.smp2.ac.EndpointType aEndpoint) Get the certificate bytes from the provided SMP endpoint.
Note: if the endpoint has more than one certificate, the first one is returned.com.helger.xsds.bdxr.smp2.ServiceGroupTypegetServiceGroup(com.helger.peppolid.IParticipantIdentifier aServiceGroupID) Returns a service group.static com.helger.xsds.bdxr.smp2.ServiceGroupTypegetServiceGroupByDNS(ISMPURLProvider aURLProvider, com.helger.peppol.sml.ISMLInfo aSMLInfo, com.helger.peppolid.IParticipantIdentifier aServiceGroupID) Returns a service group.com.helger.xsds.bdxr.smp2.ServiceGroupTypegetServiceGroupOrNull(com.helger.peppolid.IParticipantIdentifier aServiceGroupID) Returns a service group.com.helger.xsds.bdxr.smp2.ServiceMetadataTypegetServiceMetadata(com.helger.peppolid.IParticipantIdentifier aServiceGroupID, com.helger.peppolid.IDocumentTypeIdentifier aDocumentTypeID) Gets a signed service metadata object given by its service group id and its document type.com.helger.xsds.bdxr.smp2.ServiceMetadataTypegetServiceMetadataOrNull(com.helger.peppolid.IParticipantIdentifier aServiceGroupID, com.helger.peppolid.IDocumentTypeIdentifier aDocumentTypeID) Gets a signed service metadata object given by its service group id and its document type.
This is a specification compliant method.static com.helger.xsds.bdxr.smp2.ServiceMetadataTypegetServiceRegistrationByDNS(ISMPURLProvider aURLProvider, com.helger.peppol.sml.ISMLInfo aSMLInfo, com.helger.peppolid.IParticipantIdentifier aServiceGroupID, com.helger.peppolid.IDocumentTypeIdentifier aDocumentTypeID) Gets a signed service metadata object given by its service group id and its document type.Methods inherited from class com.helger.smpclient.httpclient.AbstractGenericSMPClient
containsRedirectSubject, createHttpContext, customizeMarshaller, executeGenericRequest, executeRequest, getConvertedException, getMarshallerCustomizer, getSMPHostURI, getTrustStore, httpClientSettings, isFollowSMPRedirects, isSecureValidation, isVerifySignature, isXMLSchemaValidation, setFollowSMPRedirects, setMarshallerCustomizer, setSecureValidation, setTrustStore, setVerifySignature, setXMLSchemaValidation, toString, withHttpClientSettingsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.smpclient.bdxr2.IBDXR2ServiceMetadataProvider
getEndpoint, getEndpointAddress, getEndpointCertificate, getEndpointCertificateBytesMethods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsT
-
Field Details
-
PATH_OASIS_BDXR_SMP_2
- See Also:
-
URL_PART_SERVICES
- See Also:
-
-
Constructor Details
-
BDXR2ClientReadOnly
public BDXR2ClientReadOnly(@Nonnull ISMPURLProvider aURLProvider, @Nonnull com.helger.peppolid.IParticipantIdentifier aParticipantIdentifier, @Nonnull com.helger.peppol.sml.ISMLInfo aSMLInfo) throws SMPDNSResolutionException Constructor with SML lookup- Parameters:
aURLProvider- The URL provider to be used. May not benull.aParticipantIdentifier- The participant identifier to be used. Required to build the SMP access URI.aSMLInfo- The SML to be used. Required to build the SMP access URI.- Throws:
SMPDNSResolutionException- If DNS resolution failed- See Also:
-
BDXR2ClientReadOnly
public BDXR2ClientReadOnly(@Nonnull ISMPURLProvider aURLProvider, @Nonnull com.helger.peppolid.IParticipantIdentifier aParticipantIdentifier, @Nonnull @Nonempty String sSMLZoneName) throws SMPDNSResolutionException Constructor with SML lookup- Parameters:
aURLProvider- The URL provider to be used. May not benull.aParticipantIdentifier- The participant identifier to be used. Required to build the SMP access URI.sSMLZoneName- The SML DNS zone name to be used. Required to build the SMP access URI. Must end with a trailing dot (".") and may neither benullnor empty to build a correct URL. May not start with "http://". Example:sml.peppolcentral.org.- Throws:
SMPDNSResolutionException- if DNS resolution failed- See Also:
-
BDXR2ClientReadOnly
Constructor with a direct SMP URL.
Remember: must be HTTP and using port 80 only!- Parameters:
aSMPHost- The address of the SMP service. Must be port 80 and basic http only (no https!). Example: http://smpcompany.company.org
-
-
Method Details
-
getServiceGroup
@Nonnull public com.helger.xsds.bdxr.smp2.ServiceGroupType getServiceGroup(@Nonnull com.helger.peppolid.IParticipantIdentifier aServiceGroupID) throws SMPClientException Returns a service group. A service group references to the service metadata. This is a specification compliant method.- Parameters:
aServiceGroupID- The service group id corresponding to the service group which one wants to get.- Returns:
- The service group. Never
null. - Throws:
SMPClientException- in case something goes wrongSMPClientUnauthorizedException- A HTTP Forbidden was received, should not happen.SMPClientParticipantNotFoundException- The service group id does not exist in the network.SMPClientNotFoundException- The service group id or document types did not exist.SMPClientBadRequestException- The request was not well formed.- See Also:
-
getServiceGroupOrNull
@Nullable public com.helger.xsds.bdxr.smp2.ServiceGroupType getServiceGroupOrNull(@Nonnull com.helger.peppolid.IParticipantIdentifier aServiceGroupID) throws SMPClientException Description copied from interface:IBDXR2ServiceGroupProviderReturns a service group. A service group references to the service metadata. This is a specification compliant method.- Specified by:
getServiceGroupOrNullin interfaceIBDXR2ServiceGroupProvider- Parameters:
aServiceGroupID- The ID of the service group to retrieve. May not benull.- Returns:
- The service group. Maybe
null. - Throws:
SMPClientException- in case something goes wrong
-
getAllDocumentTypes
@Nonnull public static com.helger.commons.collection.impl.ICommonsList<com.helger.peppolid.IDocumentTypeIdentifier> getAllDocumentTypes(@Nullable com.helger.xsds.bdxr.smp2.ServiceGroupType aSG, @Nonnull com.helger.peppolid.factory.IIdentifierFactory aIdentifierFactory) Extract all document types from the passed Service group.- Parameters:
aSG- The service group to parse. May benull.aIdentifierFactory- The identifier factory to be used. May not benull.- Returns:
- Never
nullbut a maybe empty list. - Since:
- 8.0.4
-
getServiceMetadata
@Nonnull public com.helger.xsds.bdxr.smp2.ServiceMetadataType getServiceMetadata(@Nonnull com.helger.peppolid.IParticipantIdentifier aServiceGroupID, @Nonnull com.helger.peppolid.IDocumentTypeIdentifier aDocumentTypeID) throws SMPClientException Gets a signed service metadata object given by its service group id and its document type. This is a specification compliant method.- Parameters:
aServiceGroupID- The service group id of the service metadata to get. May not benull.aDocumentTypeID- The document type of the service metadata to get. May not benull.- Returns:
- A signed service metadata object. Never
null. - Throws:
SMPClientException- in case something goes wrongSMPClientUnauthorizedException- A HTTP Forbidden was received, should not happen.SMPClientParticipantNotFoundException- The service group id does not exist in the network.SMPClientNotFoundException- The service group id or document types did not exist.SMPClientBadRequestException- The request was not well formed.- See Also:
-
getServiceMetadataOrNull
@Nullable public com.helger.xsds.bdxr.smp2.ServiceMetadataType getServiceMetadataOrNull(@Nonnull com.helger.peppolid.IParticipantIdentifier aServiceGroupID, @Nonnull com.helger.peppolid.IDocumentTypeIdentifier aDocumentTypeID) throws SMPClientException Description copied from interface:IBDXR2ServiceMetadataProviderGets a signed service metadata object given by its service group id and its document type.
This is a specification compliant method.- Specified by:
getServiceMetadataOrNullin interfaceIBDXR2ServiceMetadataProvider- Parameters:
aServiceGroupID- The ID of the service group to query. May not benull.aDocumentTypeID- The document type of the service metadata to retrieve. May not benull.- Returns:
- A service metadata object or
nullif no such registration is present. - Throws:
SMPClientException- in case something goes wrong
-
getEndpoint
@Nullable public static com.helger.xsds.bdxr.smp2.ac.EndpointType getEndpoint(@Nonnull com.helger.xsds.bdxr.smp2.ServiceMetadataType aServiceMetadata, @Nonnull com.helger.peppolid.IProcessIdentifier aProcessID, @Nonnull com.helger.peppol.smp.ISMPTransportProfile aTransportProfile) Extract the Endpoint from the ServiceMetadata that matches the passed process ID and the optional required transport profile.- Parameters:
aServiceMetadata- The service meta data object (e.g. from a call togetServiceMetadataOrNull(IParticipantIdentifier, IDocumentTypeIdentifier). May not benull.aProcessID- The process identifier to be looked up. May not benull.aTransportProfile- The required transport profile to be used. May not benull.- Returns:
nullif no matching endpoint was found
-
getEndpointAddress
@Nullable public static String getEndpointAddress(@Nullable com.helger.xsds.bdxr.smp2.ac.EndpointType aEndpoint) Get the endpoint address URI from the provided SMP endpoint.- Parameters:
aEndpoint- The endpoint to be used. May benull.- Returns:
nullif the endpoint isnullif the endpoint has no address URI.
-
getEndpointCertificateBytes
@Nullable public static byte[] getEndpointCertificateBytes(@Nullable com.helger.xsds.bdxr.smp2.ac.EndpointType aEndpoint) Get the certificate bytes from the provided SMP endpoint.
Note: if the endpoint has more than one certificate, the first one is returned.- Parameters:
aEndpoint- The endpoint to be used. May benull.- Returns:
nullif the endpoint isnullif the endpoint has no certificate.
-
getEndpointCertificate
@Nullable public static X509Certificate getEndpointCertificate(@Nullable com.helger.xsds.bdxr.smp2.ac.EndpointType aEndpoint) throws CertificateException Get the certificate bytes from the specified endpoint.- Parameters:
aEndpoint- The endpoint to be used. May benull.- Returns:
nullif no such endpoint exists, or if the endpoint has no certificate- Throws:
CertificateException- In case the conversion from byte to X509 certificate failed
-
getServiceGroupByDNS
@Nonnull public static com.helger.xsds.bdxr.smp2.ServiceGroupType getServiceGroupByDNS(@Nonnull ISMPURLProvider aURLProvider, @Nonnull com.helger.peppol.sml.ISMLInfo aSMLInfo, @Nonnull com.helger.peppolid.IParticipantIdentifier aServiceGroupID) throws SMPClientException, SMPDNSResolutionException Returns a service group. A service group references to the service metadata.- Parameters:
aURLProvider- The URL provider to be used. May not benull.aSMLInfo- The SML object to be usedaServiceGroupID- The service group id corresponding to the service group which one wants to get.- Returns:
- The service group
- Throws:
SMPClientException- in case something goes wrongSMPClientUnauthorizedException- A HTTP Forbidden was received, should not happen.SMPClientParticipantNotFoundException- The service group id does not exist in the network.SMPClientNotFoundException- The service group id or document types did not exist.SMPClientBadRequestException- The request was not well formed.SMPDNSResolutionException- if DNS resolution fails
-
getServiceRegistrationByDNS
@Nonnull public static com.helger.xsds.bdxr.smp2.ServiceMetadataType getServiceRegistrationByDNS(@Nonnull ISMPURLProvider aURLProvider, @Nonnull com.helger.peppol.sml.ISMLInfo aSMLInfo, @Nonnull com.helger.peppolid.IParticipantIdentifier aServiceGroupID, @Nonnull com.helger.peppolid.IDocumentTypeIdentifier aDocumentTypeID) throws SMPClientException, SMPDNSResolutionException Gets a signed service metadata object given by its service group id and its document type.- Parameters:
aURLProvider- The URL provider to be used. May not benull.aSMLInfo- The SML object to be usedaServiceGroupID- The service group id of the service metadata to get.aDocumentTypeID- The document type of the service metadata to get.- Returns:
- A signed service metadata object.
- Throws:
SMPClientException- in case something goes wrongSMPClientUnauthorizedException- A HTTP Forbidden was received, should not happen.SMPClientParticipantNotFoundException- The service group id does not exist in the network.SMPClientNotFoundException- The service group id or document types did not exist.SMPClientBadRequestException- The request was not well formed.SMPDNSResolutionException- if DNS resolution fails
-