use of com.helger.xsds.peppol.smp1.SignedServiceMetadataType 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.SignedServiceMetadataType in project peppol-commons by phax.
the class SMPClientWithDNSFuncTest method testGetByDNS.
@Test
public void testGetByDNS() throws Exception {
// Make sure that the dns exists.
final String sParticipantID = "0088:5798000000001";
final String sDocumentID = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::InvoiceDisputeDisputeInvoice##UBL-2.0";
final IParticipantIdentifier aServiceGroupID = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(sParticipantID);
final IDocumentTypeIdentifier aDocumentTypeID = PeppolIdentifierFactory.INSTANCE.createDocumentTypeIdentifierWithDefaultScheme(sDocumentID);
final ServiceGroupType aGroup = SMPClientReadOnly.getServiceGroupByDNS(URL_PROVIDER, SML_INFO, aServiceGroupID);
assertNotNull(aGroup);
final SignedServiceMetadataType aMetadata = SMPClientReadOnly.getServiceRegistrationByDNS(URL_PROVIDER, SML_INFO, aServiceGroupID, aDocumentTypeID);
assertNotNull(aMetadata);
}
use of com.helger.xsds.peppol.smp1.SignedServiceMetadataType in project peppol-commons by phax.
the class SMPClientWithDNSFuncTest method testGetByDNSForDocs.
@Test
public void testGetByDNSForDocs() throws Exception {
// ServiceGroup = participant identifier; GLN = 0088
final IParticipantIdentifier aServiceGroupID = EPredefinedParticipantIdentifierScheme.GLN.createParticipantIdentifier("5798000000001");
// Document type identifier from enumeration
@SuppressWarnings("deprecation") final IDocumentTypeIdentifier aDocumentTypeID = EPredefinedDocumentTypeIdentifier.INVOICE_T010_BIS4A_V20.getAsDocumentTypeIdentifier();
// Main call to the SMP client with the correct SML to use
final SignedServiceMetadataType aMetadata = SMPClientReadOnly.getServiceRegistrationByDNS(URL_PROVIDER, ESML.DIGIT_TEST, aServiceGroupID, aDocumentTypeID);
assertNotNull(aMetadata);
}
use of com.helger.xsds.peppol.smp1.SignedServiceMetadataType in project peppol-commons by phax.
the class SignedServiceMetadataTypeFuncTest method testReadValid.
@Test
public void testReadValid() throws Exception {
final SMPMarshallerSignedServiceMetadataType aMarshaller = new SMPMarshallerSignedServiceMetadataType(true);
aMarshaller.setValidationEventHandlerFactory(x -> new LoggingValidationEventHandler());
final byte[] aBytes = StreamHelper.getAllBytes(new ClassPathResource("smp/signed-service-metadata2.xml"));
assertNotNull(aBytes);
final SignedServiceMetadataType aSSM = aMarshaller.read(aBytes);
assertNotNull(aSSM);
final Document aDocument = DOMReader.readXMLDOM(aBytes);
assertNotNull(aDocument);
final TrustStoreBasedX509KeySelector aKeySelector = new TrustStoreBasedX509KeySelector(SMPClientConfiguration.loadTrustStore());
// Certificate expired 2021-03-01
aKeySelector.setValidationDateTime(PDTFactory.createLocalDateTime(2021, Month.JANUARY, 1));
final ESuccess eSuccess = SMPHttpResponseHandlerSigned.checkSignature(aDocument, aKeySelector);
assertTrue(eSuccess.isSuccess());
}
use of com.helger.xsds.peppol.smp1.SignedServiceMetadataType in project peppol-commons by phax.
the class SignedServiceMetadataTypeFuncTest method testReadC14NInclusive.
@Test
public void testReadC14NInclusive() throws Exception {
final SMPMarshallerSignedServiceMetadataType aMarshaller = new SMPMarshallerSignedServiceMetadataType(true);
aMarshaller.setValidationEventHandlerFactory(x -> new LoggingValidationEventHandler());
final byte[] aBytes = StreamHelper.getAllBytes(new ClassPathResource("smp/signed-service-metadata3-c14n-inclusive.xml"));
assertNotNull(aBytes);
final SignedServiceMetadataType aSSM = aMarshaller.read(aBytes);
assertNotNull(aSSM);
final Document aDocument = DOMReader.readXMLDOM(aBytes);
assertNotNull(aDocument);
final TrustStoreBasedX509KeySelector aKeySelector = new TrustStoreBasedX509KeySelector(SMPClientConfiguration.loadTrustStore());
// Certificate expired 2020-08-05
aKeySelector.setValidationDateTime(PDTFactory.createLocalDateTime(2020, Month.AUGUST, 1));
final ESuccess eSuccess = SMPHttpResponseHandlerSigned.checkSignature(aDocument, aKeySelector);
assertTrue(eSuccess.isSuccess());
}
Aggregations