use of com.helger.xsds.bdxr.smp1.SignedServiceMetadataType in project peppol-commons by phax.
the class SMPMarshallerSignedServiceMetadataTypeTest method testIssue121.
@Test
public void testIssue121() {
final String s = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + "<SignedServiceMetadata\r\n" + " xmlns=\"http://busdox.org/serviceMetadata/publishing/1.0/\"\r\n" + " xmlns:id=\"http://busdox.org/transport/identifiers/1.0/\"\r\n " + " xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\r\n" + " <ServiceMetadata>\r\n" + " <ServiceInformation>\r\n" + " <id:ParticipantIdentifier scheme=\"iso6523-actorid-upis\">0106:{KvK}</id:ParticipantIdentifier>\r\n" + " <id:DocumentIdentifier scheme=\"busdox-docid-qns\">urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:www.cenbii.eu:transaction:biicoretrdm010:ver1.0:extended:urn:www.peppol.eu:bis:peppol4a:ver1.0::2.0</id:DocumentIdentifier>\r\n" + " <ProcessList>\r\n" + " <Process>\r\n" + " <id:ProcessIdentifier scheme=\"cenbii-procid-ubl\">urn:www.cenbii.eu:profile:bii04:ver1.0</id:ProcessIdentifier>\r\n" + " <ServiceEndpointList>\r\n" + " <Endpoint transportProfile=\"busdox-transport-as2-ver1p0\">\r\n" + " <EndpointReference xmlns=\"http://www.w3.org/2005/08/addressing\"><Address>https://example.org/as2</Address></EndpointReference>\r\n" + " <RequireBusinessLevelSignature>true</RequireBusinessLevelSignature>\r\n" + " <ServiceActivationDate>\r\n" + " 2019-01-16T01:00:00.000+01:00\r\n" + " </ServiceActivationDate>\r\n" + " <ServiceExpirationDate>\r\n" + " 2026-03-15T01:00:00.000+01:00\r\n" + " </ServiceExpirationDate>\r\n" + " <Certificate>{Certificate}</Certificate>\r\n" + " <ServiceDescription>test</ServiceDescription>\r\n" + " <TechnicalContactUrl>https://sitename.com</TechnicalContactUrl>\r\n" + " <TechnicalInformationUrl>https://sitename.com</TechnicalInformationUrl>\r\n" + " </Endpoint>\r\n" + " </ServiceEndpointList>\r\n" + " </Process>\r\n" + " </ProcessList>\r\n" + " </ServiceInformation>\r\n" + " </ServiceMetadata>\r\n" + // Parsing would fail in Signature
" <ds:Signature/>\r\n" + "</SignedServiceMetadata>";
SignedServiceMetadataType aObj = new SMPMarshallerSignedServiceMetadataType(false).read(s);
assertNotNull(aObj);
for (final String sFilename : new String[] { "signed-service-metadata1.xml", "signed-service-metadata2.xml", "signed-service-metadata3-c14n-inclusive.xml" }) {
final IReadableResource aRes = new ClassPathResource("smp/" + sFilename);
assertTrue(aRes.exists());
aObj = new SMPMarshallerSignedServiceMetadataType(true).read(aRes);
assertNotNull("Error in " + sFilename, aObj);
}
}
use of com.helger.xsds.bdxr.smp1.SignedServiceMetadataType in project peppol-commons by phax.
the class BDXRClientReadOnlyTest method testReadConnectivityTest.
@Test
@Ignore("Because it may take long to execute")
@IgnoredNaptrTest
public void testReadConnectivityTest() throws SMPDNSResolutionException, SMPClientException {
final IParticipantIdentifier aPI = SimpleIdentifierFactory.INSTANCE.createParticipantIdentifier("connectivity-partid-qns", "dynceftest1party59gw");
final IDocumentTypeIdentifier aDocTypeID = SimpleIdentifierFactory.INSTANCE.createDocumentTypeIdentifier("connectivity-docid-qns", "doc_id1");
// TOOP SML
final ISMLInfo aSMLInfo = new SMLInfo("cef-connectivity", "CEF ConnectivityTest", "connectivitytest.acc.edelivery.tech.ec.europa.eu.", "https://acc.edelivery.tech.ec.europa.eu/edelivery-sml", true);
// PEPPOL URL provider
final BDXRClientReadOnly aBDXRClient = new BDXRClientReadOnly(BDXLURLProvider.INSTANCE, aPI, aSMLInfo);
// We don't have the truststore at hand - ignore it
aBDXRClient.setVerifySignature(false);
assertEquals("https://gateway-edelivery.westeurope.cloudapp.azure.com:444/", aBDXRClient.getSMPHostURI());
final SignedServiceMetadataType aMetadata = aBDXRClient.getServiceMetadata(aPI, aDocTypeID);
assertNotNull(aMetadata);
}
use of com.helger.xsds.bdxr.smp1.SignedServiceMetadataType in project phoss-smp by phax.
the class BDXR1ServerAPI method getServiceRegistration.
@Nonnull
public SignedServiceMetadataType getServiceRegistration(@Nonnull final String sPathServiceGroupID, @Nonnull final String sPathDocTypeID) throws SMPServerException {
final String sLog = LOG_PREFIX + "GET /" + sPathServiceGroupID + "/services/" + sPathDocTypeID;
final String sAction = "getServiceRegistration";
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog);
STATS_COUNTER_INVOCATION.increment(sAction);
try {
final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
final IParticipantIdentifier aPathServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sPathServiceGroupID);
if (aPathServiceGroupID == null) {
// Invalid identifier
throw SMPBadRequestException.failedToParseSG(sPathServiceGroupID, m_aAPIDataProvider.getCurrentURI());
}
final ISMPServiceGroup aPathServiceGroup = SMPMetaManager.getServiceGroupMgr().getSMPServiceGroupOfID(aPathServiceGroupID);
if (aPathServiceGroup == null) {
throw new SMPNotFoundException("No such Service Group '" + sPathServiceGroupID + "'", m_aAPIDataProvider.getCurrentURI());
}
final IDocumentTypeIdentifier aPathDocTypeID = aIdentifierFactory.parseDocumentTypeIdentifier(sPathDocTypeID);
if (aPathDocTypeID == null) {
throw SMPBadRequestException.failedToParseDocType(sPathDocTypeID, m_aAPIDataProvider.getCurrentURI());
}
// First check for redirection, then for actual service
final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
final ISMPRedirect aRedirect = aRedirectMgr.getSMPRedirectOfServiceGroupAndDocumentType(aPathServiceGroup, aPathDocTypeID);
final SignedServiceMetadataType aSignedServiceMetadata = new SignedServiceMetadataType();
if (aRedirect != null) {
aSignedServiceMetadata.setServiceMetadata(aRedirect.getAsJAXBObjectBDXR1());
} else {
// Get as regular service information
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final ISMPServiceInformation aServiceInfo = aServiceInfoMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aPathServiceGroup, aPathDocTypeID);
final ServiceMetadataType aSM = aServiceInfo == null ? null : aServiceInfo.getAsJAXBObjectBDXR1();
if (aSM != null) {
aSignedServiceMetadata.setServiceMetadata(aSM);
} else {
// Neither nor is present, or no endpoint is available
throw new SMPNotFoundException("service(" + sPathServiceGroupID + "," + sPathDocTypeID + ")", m_aAPIDataProvider.getCurrentURI());
}
}
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog + " SUCCESS");
STATS_COUNTER_SUCCESS.increment(sAction);
return aSignedServiceMetadata;
} catch (final SMPServerException ex) {
if (LOGGER.isWarnEnabled())
LOGGER.warn(sLog + " ERROR - " + ex.getMessage());
STATS_COUNTER_ERROR.increment(sAction);
throw ex;
}
}
use of com.helger.xsds.bdxr.smp1.SignedServiceMetadataType in project phoss-smp by phax.
the class SMPServerAPI method getServiceRegistration.
@Nonnull
public SignedServiceMetadataType getServiceRegistration(@Nonnull final String sPathServiceGroupID, @Nonnull final String sPathDocTypeID) throws SMPServerException {
final String sLog = LOG_PREFIX + "GET /" + sPathServiceGroupID + "/services/" + sPathDocTypeID;
final String sAction = "getServiceRegistration";
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog);
STATS_COUNTER_INVOCATION.increment(sAction);
try {
final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
final IParticipantIdentifier aPathServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sPathServiceGroupID);
if (aPathServiceGroupID == null) {
// Invalid identifier
throw SMPBadRequestException.failedToParseSG(sPathServiceGroupID, m_aAPIDataProvider.getCurrentURI());
}
final ISMPServiceGroup aPathServiceGroup = SMPMetaManager.getServiceGroupMgr().getSMPServiceGroupOfID(aPathServiceGroupID);
if (aPathServiceGroup == null) {
throw new SMPNotFoundException("No such Service Group '" + sPathServiceGroupID + "'", m_aAPIDataProvider.getCurrentURI());
}
final IDocumentTypeIdentifier aPathDocTypeID = aIdentifierFactory.parseDocumentTypeIdentifier(sPathDocTypeID);
if (aPathDocTypeID == null) {
throw SMPBadRequestException.failedToParseDocType(sPathDocTypeID, m_aAPIDataProvider.getCurrentURI());
}
// First check for redirection, then for actual service
final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
final ISMPRedirect aRedirect = aRedirectMgr.getSMPRedirectOfServiceGroupAndDocumentType(aPathServiceGroup, aPathDocTypeID);
final SignedServiceMetadataType aSignedServiceMetadata = new SignedServiceMetadataType();
if (aRedirect != null) {
aSignedServiceMetadata.setServiceMetadata(aRedirect.getAsJAXBObjectPeppol());
} else {
// Get as regular service information
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final ISMPServiceInformation aServiceInfo = aServiceInfoMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aPathServiceGroup, aPathDocTypeID);
final ServiceMetadataType aSM = aServiceInfo == null ? null : aServiceInfo.getAsJAXBObjectPeppol();
if (aSM != null) {
aSignedServiceMetadata.setServiceMetadata(aSM);
} else {
// Neither nor is present, or no endpoint is available
throw new SMPNotFoundException("service(" + sPathServiceGroupID + "," + sPathDocTypeID + ")", m_aAPIDataProvider.getCurrentURI());
}
}
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog + " SUCCESS");
STATS_COUNTER_SUCCESS.increment(sAction);
return aSignedServiceMetadata;
} catch (final SMPServerException ex) {
if (LOGGER.isWarnEnabled())
LOGGER.warn(sLog + " ERROR - " + ex.getMessage());
STATS_COUNTER_ERROR.increment(sAction);
throw ex;
}
}
use of com.helger.xsds.bdxr.smp1.SignedServiceMetadataType in project peppol-commons by phax.
the class ISMPServiceMetadataProvider method getEndpoint.
/**
* Retrieve the service metadata from the provided service group ID and
* document type ID. Than find the matching endpoint from the process ID and
* transport profile.<br>
* This is a specification compliant method.
*
* @param aServiceGroupID
* The service group id of the service metadata to get. May not be
* <code>null</code>.
* @param aDocumentTypeID
* The document type of the service metadata to get. May not be
* <code>null</code>.
* @param aProcessID
* The process ID of the service metadata to get. May not be
* <code>null</code>.
* @param aTransportProfile
* The transport profile of the service metadata to get. May not be
* <code>null</code>.
* @return The endpoint from the signed service metadata object or
* <code>null</code> if no such registration is present.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* A HTTP Forbidden was received, should not happen.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #getServiceMetadataOrNull(IParticipantIdentifier,IDocumentTypeIdentifier)
*/
@Nullable
default EndpointType getEndpoint(@Nonnull final IParticipantIdentifier aServiceGroupID, @Nonnull final IDocumentTypeIdentifier aDocumentTypeID, @Nonnull final IProcessIdentifier aProcessID, @Nonnull final ISMPTransportProfile aTransportProfile) throws SMPClientException {
ValueEnforcer.notNull(aServiceGroupID, "ServiceGroupID");
ValueEnforcer.notNull(aDocumentTypeID, "DocumentTypeID");
ValueEnforcer.notNull(aProcessID, "ProcessID");
ValueEnforcer.notNull(aTransportProfile, "TransportProfile");
// Get meta data for participant/documentType
final SignedServiceMetadataType aSignedServiceMetadata = getServiceMetadataOrNull(aServiceGroupID, aDocumentTypeID);
return aSignedServiceMetadata == null ? null : SMPClientReadOnly.getEndpoint(aSignedServiceMetadata, aProcessID, aTransportProfile);
}
Aggregations