use of com.helger.xsds.peppol.smp1.ServiceEndpointList in project peppol-commons by phax.
the class SMPClientTest method testCRUDServiceRegistration.
@Test
public void testCRUDServiceRegistration() throws Exception {
final SMPClient aSMPClient = new SMPClient(SMP_URI);
aSMPClient.saveServiceGroup(MockSMPClientConfig.getParticipantID(), SMP_CREDENTIALS);
final IParticipantIdentifier aServiceGroupID = MockSMPClientConfig.getParticipantID();
final IDocumentTypeIdentifier aDocumentID = MockSMPClientConfig.getDocumentTypeID();
final IProcessIdentifier aProcessID = MockSMPClientConfig.getProcessTypeID();
final ServiceInformationType aServiceInformation = new ServiceInformationType();
{
final ProcessListType aProcessList = new ProcessListType();
{
final ProcessType aProcess = new ProcessType();
{
final ServiceEndpointList aServiceEndpointList = new ServiceEndpointList();
{
final EndpointType aEndpoint = new EndpointType();
final W3CEndpointReference aEndpointReferenceType = new W3CEndpointReferenceBuilder().address("http://peppol.eu/sampleService/").build();
aEndpoint.setEndpointReference(aEndpointReferenceType);
aEndpoint.setTransportProfile(ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID());
// Certificate: Base64.encodeBytes (certificate.getEncoded ());
aEndpoint.setCertificate("1234567890");
aEndpoint.setServiceActivationDate(PDTFactory.getCurrentXMLOffsetDateTime());
aEndpoint.setServiceDescription("TEST DESCRIPTION");
aEndpoint.setServiceExpirationDate(PDTFactory.getCurrentXMLOffsetDateTime().plusYears(1));
aEndpoint.setTechnicalContactUrl("mailto:smpclient.unittest@helger.com");
aEndpoint.setMinimumAuthenticationLevel("2");
aEndpoint.setRequireBusinessLevelSignature(false);
aServiceEndpointList.getEndpoint().add(aEndpoint);
}
aProcess.setProcessIdentifier(new SimpleProcessIdentifier(aProcessID));
aProcess.setServiceEndpointList(aServiceEndpointList);
}
aProcessList.getProcess().add(aProcess);
}
aServiceInformation.setDocumentIdentifier(new SimpleDocumentTypeIdentifier(aDocumentID));
aServiceInformation.setParticipantIdentifier(new SimpleParticipantIdentifier(aServiceGroupID));
aServiceInformation.setProcessList(aProcessList);
}
aSMPClient.saveServiceInformation(aServiceInformation, SMP_CREDENTIALS);
final SignedServiceMetadataType aSignedServiceMetadata = aSMPClient.getServiceMetadata(aServiceGroupID, aDocumentID);
LOGGER.info("Service aMetadata ID:" + aSignedServiceMetadata.getServiceMetadata().getServiceInformation().getParticipantIdentifier().getValue());
aSMPClient.deleteServiceRegistration(aServiceGroupID, aDocumentID, SMP_CREDENTIALS);
aSMPClient.deleteServiceGroup(MockSMPClientConfig.getParticipantID(), SMP_CREDENTIALS);
}
use of com.helger.xsds.peppol.smp1.ServiceEndpointList in project peppol-commons by phax.
the class SMPMarshallerServiceMetadataTypeTest method testIssue121.
@Test
public void testIssue121() {
final String s = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + "<ServiceMetadata xmlns=\"http://busdox.org/serviceMetadata/publishing/1.0/\" xmlns:id=\"http://busdox.org/transport/identifiers/1.0/\">\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>";
final ServiceMetadataType aObj = new SMPMarshallerServiceMetadataType(true).read(s);
assertNotNull(aObj);
}
use of com.helger.xsds.peppol.smp1.ServiceEndpointList 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.peppol.smp1.ServiceEndpointList in project phoss-smp by phax.
the class ServiceMetadataInterfaceTest method testCreateAndDeleteServiceInformationSMPClient.
@Test
public void testCreateAndDeleteServiceInformationSMPClient() throws SMPClientException {
// Lower case
final IParticipantIdentifier aPI_LC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:xxx");
// Upper case
final IParticipantIdentifier aPI_UC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:XXX");
final PeppolDocumentTypeIdentifier aDT = EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30.getAsDocumentTypeIdentifier();
final PeppolProcessIdentifier aProcID = EPredefinedProcessIdentifier.BIS3_BILLING.getAsProcessIdentifier();
final ServiceGroupType aSG = new ServiceGroupType();
aSG.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
aSG.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
final ServiceInformationType aSI = new ServiceInformationType();
aSI.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
aSI.setDocumentIdentifier(aDT);
{
final ProcessListType aPL = new ProcessListType();
final ProcessType aProcess = new ProcessType();
aProcess.setProcessIdentifier(aProcID);
final ServiceEndpointList aSEL = new ServiceEndpointList();
final EndpointType aEndpoint = new EndpointType();
aEndpoint.setEndpointReference(W3CEndpointReferenceHelper.createEndpointReference("http://test.smpserver/as2"));
aEndpoint.setRequireBusinessLevelSignature(false);
aEndpoint.setCertificate("blacert");
aEndpoint.setServiceDescription("Unit test service");
aEndpoint.setTechnicalContactUrl("https://github.com/phax/phoss-smp");
aEndpoint.setTransportProfile(ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID());
aSEL.addEndpoint(aEndpoint);
aProcess.setServiceEndpointList(aSEL);
aPL.addProcess(aProcess);
aSI.setProcessList(aPL);
}
final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
final ISMPServiceInformationManager aSIMgr = SMPMetaManager.getServiceInformationMgr();
final SMPClient aSMPClient = new MockSMPClient();
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
try {
// PUT ServiceGroup
aSMPClient.saveServiceGroup(aSG, CREDENTIALS);
// Read both
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
final ISMPServiceGroup aServiceGroup = aSGMgr.getSMPServiceGroupOfID(aPI_LC);
assertNotNull(aServiceGroup);
final ISMPServiceGroup aServiceGroup_UC = aSGMgr.getSMPServiceGroupOfID(aPI_UC);
assertEquals(aServiceGroup, aServiceGroup_UC);
try {
// PUT 1 ServiceInformation
aSMPClient.saveServiceInformation(aSI, CREDENTIALS);
assertNotNull(aSIMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDT));
// PUT 2 ServiceInformation
aSMPClient.saveServiceInformation(aSI, CREDENTIALS);
assertNotNull(aSIMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDT));
// DELETE 1 ServiceInformation
aSMPClient.deleteServiceRegistration(aPI_LC, aDT, CREDENTIALS);
assertNull(aSIMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDT));
} finally {
// DELETE 2 ServiceInformation
try {
aSMPClient.deleteServiceRegistration(aPI_LC, aDT, CREDENTIALS);
} catch (final SMPClientNotFoundException ex) {
// Expected
}
assertNull(aSIMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDT));
}
assertNotNull(aSMPClient.getServiceGroup(aPI_LC));
} finally {
// DELETE ServiceGroup
try {
aSMPClient.deleteServiceGroup(aPI_LC, CREDENTIALS);
} catch (final SMPClientNotFoundException ex) {
// Expected
}
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
}
}
use of com.helger.xsds.peppol.smp1.ServiceEndpointList in project phoss-smp by phax.
the class SMPProcess method getAsJAXBObjectPeppol.
@Nullable
public com.helger.xsds.peppol.smp1.ProcessType getAsJAXBObjectPeppol() {
if (m_aEndpoints.isEmpty()) {
// Empty ServiceEndpointList is not allowed
return null;
}
final com.helger.xsds.peppol.smp1.ProcessType ret = new com.helger.xsds.peppol.smp1.ProcessType();
// Explicit constructor call is needed here!
ret.setProcessIdentifier(new SimpleProcessIdentifier(m_aProcessIdentifier));
final com.helger.xsds.peppol.smp1.ServiceEndpointList aEndpointList = new com.helger.xsds.peppol.smp1.ServiceEndpointList();
for (final ISMPEndpoint aEndpoint : m_aEndpoints.values()) aEndpointList.addEndpoint(aEndpoint.getAsJAXBObjectPeppol());
ret.setServiceEndpointList(aEndpointList);
ret.setExtension(getAsPeppolExtension());
return ret;
}
Aggregations