Search in sources :

Example 1 with SignedServiceMetadataType

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);
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SignedServiceMetadataType(com.helger.xsds.peppol.smp1.SignedServiceMetadataType) ServiceInformationType(com.helger.xsds.peppol.smp1.ServiceInformationType) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) ProcessType(com.helger.xsds.peppol.smp1.ProcessType) W3CEndpointReferenceBuilder(javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder) SimpleProcessIdentifier(com.helger.peppolid.simple.process.SimpleProcessIdentifier) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) EndpointType(com.helger.xsds.peppol.smp1.EndpointType) ProcessListType(com.helger.xsds.peppol.smp1.ProcessListType) ServiceEndpointList(com.helger.xsds.peppol.smp1.ServiceEndpointList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 2 with SignedServiceMetadataType

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);
}
Also used : IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SignedServiceMetadataType(com.helger.xsds.peppol.smp1.SignedServiceMetadataType) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 3 with SignedServiceMetadataType

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);
}
Also used : IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SignedServiceMetadataType(com.helger.xsds.peppol.smp1.SignedServiceMetadataType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 4 with SignedServiceMetadataType

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());
}
Also used : ESuccess(com.helger.commons.state.ESuccess) SMPMarshallerSignedServiceMetadataType(com.helger.smpclient.peppol.marshal.SMPMarshallerSignedServiceMetadataType) SignedServiceMetadataType(com.helger.xsds.peppol.smp1.SignedServiceMetadataType) TrustStoreBasedX509KeySelector(com.helger.smpclient.security.TrustStoreBasedX509KeySelector) LoggingValidationEventHandler(com.helger.jaxb.validation.LoggingValidationEventHandler) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) SMPMarshallerSignedServiceMetadataType(com.helger.smpclient.peppol.marshal.SMPMarshallerSignedServiceMetadataType) Test(org.junit.Test)

Example 5 with SignedServiceMetadataType

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());
}
Also used : ESuccess(com.helger.commons.state.ESuccess) SMPMarshallerSignedServiceMetadataType(com.helger.smpclient.peppol.marshal.SMPMarshallerSignedServiceMetadataType) SignedServiceMetadataType(com.helger.xsds.peppol.smp1.SignedServiceMetadataType) TrustStoreBasedX509KeySelector(com.helger.smpclient.security.TrustStoreBasedX509KeySelector) LoggingValidationEventHandler(com.helger.jaxb.validation.LoggingValidationEventHandler) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) SMPMarshallerSignedServiceMetadataType(com.helger.smpclient.peppol.marshal.SMPMarshallerSignedServiceMetadataType) Test(org.junit.Test)

Aggregations

SignedServiceMetadataType (com.helger.xsds.peppol.smp1.SignedServiceMetadataType)13 Test (org.junit.Test)13 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)11 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)10 SignedServiceMetadataType (com.helger.xsds.bdxr.smp1.SignedServiceMetadataType)7 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)4 IgnoredNaptrTest (com.helger.smpclient.IgnoredNaptrTest)4 SMPMarshallerSignedServiceMetadataType (com.helger.smpclient.peppol.marshal.SMPMarshallerSignedServiceMetadataType)4 Nonnull (javax.annotation.Nonnull)4 Ignore (org.junit.Ignore)4 ESuccess (com.helger.commons.state.ESuccess)3 LoggingValidationEventHandler (com.helger.jaxb.validation.LoggingValidationEventHandler)3 ISMLInfo (com.helger.peppol.sml.ISMLInfo)3 SMLInfo (com.helger.peppol.sml.SMLInfo)3 TrustStoreBasedX509KeySelector (com.helger.smpclient.security.TrustStoreBasedX509KeySelector)3 KeyStore (java.security.KeyStore)3 Document (org.w3c.dom.Document)3 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)2 ISMPRedirect (com.helger.phoss.smp.domain.redirect.ISMPRedirect)2 ISMPRedirectManager (com.helger.phoss.smp.domain.redirect.ISMPRedirectManager)2