Search in sources :

Example 96 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project peppol-commons by phax.

the class BDXRClientReadOnlyTest method testGetBDXRHostURI_Peppol_WithBDXR.

@Test
public void testGetBDXRHostURI_Peppol_WithBDXR() throws SMPClientException, SMPDNSResolutionException {
    // This instance has a BOM inside
    final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9917:5504033150");
    final BDXRClientReadOnly aBDXRClient = new BDXRClientReadOnly(PeppolURLProvider.INSTANCE, aPI, ESML.DIGIT_PRODUCTION);
    assertEquals("http://B-2f67a0710cbc13c11ac8c0d64186ac5e.iso6523-actorid-upis.edelivery.tech.ec.europa.eu/", aBDXRClient.getSMPHostURI());
    // not OASIS!
    try {
        aBDXRClient.getServiceGroupOrNull(aPI);
        fail();
    } catch (final SMPClientBadResponseException ex) {
    // Expected "Malformed XML document returned from SMP server"
    }
}
Also used : SMPClientBadResponseException(com.helger.smpclient.exception.SMPClientBadResponseException) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) IgnoredNaptrTest(com.helger.smpclient.IgnoredNaptrTest) Test(org.junit.Test)

Example 97 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project peppol-commons by phax.

the class SMPClientReadOnlyTest method testGetSMPHostURI_BDXR.

@Test
@Ignore("Because it may take some time to resolve it")
@IgnoredNaptrTest
public void testGetSMPHostURI_BDXR() throws SMPClientException, SMPDNSResolutionException {
    final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:test");
    // CEF URL provider
    final SMPClientReadOnly aSMPClient = new SMPClientReadOnly(BDXLURLProvider.INSTANCE, aPI, ESML.DIGIT_TEST);
    assertEquals("http://test-infra.peppol.at/", aSMPClient.getSMPHostURI());
    assertNotNull(aSMPClient.getServiceGroupOrNull(aPI));
}
Also used : IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Ignore(org.junit.Ignore) IgnoredNaptrTest(com.helger.smpclient.IgnoredNaptrTest) IgnoredNaptrTest(com.helger.smpclient.IgnoredNaptrTest) Test(org.junit.Test)

Example 98 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project peppol-commons by phax.

the class SMPClientReadOnlyTest method testInvalidTrustStore.

@Test
public void testInvalidTrustStore() throws SMPDNSResolutionException, SMPClientException, GeneralSecurityException, IOException {
    final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:test");
    final SMPClientReadOnly aSMPClient = new SMPClientReadOnly(PeppolURLProvider.INSTANCE, aPI, ESML.DIGIT_TEST);
    // Set old trust store
    {
        final KeyStore aTS = KeyStoreHelper.loadKeyStoreDirect(EKeyStoreType.JKS, "truststore-outdated.jks", "peppol");
        assertNotNull(aTS);
        aSMPClient.setTrustStore(aTS);
    }
    try {
        // Signature validation MUST fail
        aSMPClient.getServiceMetadataOrNull(aPI, EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30);
        fail();
    } catch (final SMPClientBadResponseException ex) {
        assertNotNull(ex.getCause());
        assertTrue(ex.getCause() instanceof XMLSignatureException);
    }
}
Also used : KeyStore(java.security.KeyStore) SMPClientBadResponseException(com.helger.smpclient.exception.SMPClientBadResponseException) XMLSignatureException(javax.xml.crypto.dsig.XMLSignatureException) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) IgnoredNaptrTest(com.helger.smpclient.IgnoredNaptrTest) Test(org.junit.Test)

Example 99 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier 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 100 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier 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)

Aggregations

IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)218 Test (org.junit.Test)70 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)58 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)57 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)51 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)47 File (java.io.File)46 Nonnull (javax.annotation.Nonnull)43 ESimpleUserMessageSendResult (com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult)42 Element (org.w3c.dom.Element)41 SMPClientReadOnly (com.helger.smpclient.peppol.SMPClientReadOnly)40 AS4RawResponseConsumerWriteToFile (com.helger.phase4.dump.AS4RawResponseConsumerWriteToFile)38 AS4IncomingDumperFileBased (com.helger.phase4.dump.AS4IncomingDumperFileBased)35 AS4OutgoingDumperFileBased (com.helger.phase4.dump.AS4OutgoingDumperFileBased)35 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)30 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)24 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)24 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)24 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)19 ICommonsList (com.helger.commons.collection.impl.ICommonsList)18