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"
}
}
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));
}
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);
}
}
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);
}
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);
}
Aggregations