Search in sources :

Example 1 with SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier 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 SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier in project phoss-smp by phax.

the class SMPServiceInformationManagerJDBC method getAllSMPServiceInformationOfServiceGroup.

@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPServiceInformation> getAllSMPServiceInformationOfServiceGroup(@Nullable final ISMPServiceGroup aServiceGroup) {
    final ICommonsList<ISMPServiceInformation> ret = new CommonsArrayList<>();
    if (aServiceGroup != null) {
        final IParticipantIdentifier aPID = aServiceGroup.getParticipantIdentifier();
        final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT sm.documentIdentifierScheme, sm.documentIdentifier, sm.extension," + "   sp.processIdentifierType, sp.processIdentifier, sp.extension," + "   se.transportProfile, se.endpointReference, se.requireBusinessLevelSignature, se.minimumAuthenticationLevel," + "     se.serviceActivationDate, se.serviceExpirationDate, se.certificate, se.serviceDescription," + "     se.technicalContactUrl, se.technicalInformationUrl, se.extension" + " FROM smp_service_metadata AS sm" + " INNER JOIN smp_process AS sp" + "   ON sm.businessIdentifierScheme=sp.businessIdentifierScheme AND sm.businessIdentifier=sp.businessIdentifier" + "   AND sm.documentIdentifierScheme=sp.documentIdentifierScheme AND sm.documentIdentifier=sp.documentIdentifier" + " INNER JOIN smp_endpoint AS se" + "   ON sp.businessIdentifierScheme=se.businessIdentifierScheme AND sp.businessIdentifier=se.businessIdentifier" + "   AND sp.documentIdentifierScheme=se.documentIdentifierScheme AND sp.documentIdentifier=se.documentIdentifier" + "   AND sp.processIdentifierType=se.processIdentifierType AND sp.processIdentifier=se.processIdentifier" + " WHERE sm.businessIdentifierScheme=? AND sm.businessIdentifier=?", new ConstantPreparedStatementDataProvider(aPID.getScheme(), aPID.getValue()));
        if (aDBResult != null) {
            final ICommonsMap<DocTypeAndExtension, ICommonsMap<SMPProcess, ICommonsList<SMPEndpoint>>> aGrouping = new CommonsHashMap<>();
            for (final DBResultRow aDBRow : aDBResult) {
                // Document type ID and extension
                final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(aDBRow.getAsString(0), aDBRow.getAsString(1));
                final String sServiceInformationExtension = aDBRow.getAsString(2);
                // Process without endpoints
                final SMPProcess aProcess = new SMPProcess(new SimpleProcessIdentifier(aDBRow.getAsString(3), aDBRow.getAsString(4)), null, aDBRow.getAsString(5));
                // Don't add endpoint to process, because that impacts
                // SMPProcess.equals/hashcode
                final SMPEndpoint aEndpoint = new SMPEndpoint(aDBRow.getAsString(6), aDBRow.getAsString(7), aDBRow.getAsBoolean(8, SMPEndpoint.DEFAULT_REQUIRES_BUSINESS_LEVEL_SIGNATURE), aDBRow.getAsString(9), aDBRow.getAsXMLOffsetDateTime(10), aDBRow.getAsXMLOffsetDateTime(11), aDBRow.getAsString(12), aDBRow.getAsString(13), aDBRow.getAsString(14), aDBRow.getAsString(15), aDBRow.getAsString(16));
                aGrouping.computeIfAbsent(new DocTypeAndExtension(aDocTypeID, sServiceInformationExtension), k -> new CommonsHashMap<>()).computeIfAbsent(aProcess, k -> new CommonsArrayList<>()).add(aEndpoint);
            }
            for (final Map.Entry<DocTypeAndExtension, ICommonsMap<SMPProcess, ICommonsList<SMPEndpoint>>> aEntry : aGrouping.entrySet()) {
                // Flatten list
                final ICommonsList<SMPProcess> aProcesses = new CommonsArrayList<>();
                for (final Map.Entry<SMPProcess, ICommonsList<SMPEndpoint>> aEntry2 : aEntry.getValue().entrySet()) {
                    final SMPProcess aProcess = aEntry2.getKey();
                    aProcess.addEndpoints(aEntry2.getValue());
                    aProcesses.add(aProcess);
                }
                final DocTypeAndExtension aDE = aEntry.getKey();
                ret.add(new SMPServiceInformation(aServiceGroup, aDE.m_aDocTypeID, aProcesses, aDE.m_sExt));
            }
        }
    }
    return ret;
}
Also used : ESuccess(com.helger.commons.state.ESuccess) Nonnegative(javax.annotation.Nonnegative) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SimpleProcessIdentifier(com.helger.peppolid.simple.process.SimpleProcessIdentifier) MustImplementEqualsAndHashcode(com.helger.commons.annotation.MustImplementEqualsAndHashcode) EChange(com.helger.commons.state.EChange) SMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.SMPServiceInformation) Supplier(java.util.function.Supplier) CallbackList(com.helger.commons.callback.CallbackList) DBValueHelper(com.helger.db.api.helper.DBValueHelper) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) AbstractJDBCEnabledManager(com.helger.db.jdbc.mgr.AbstractJDBCEnabledManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) MutableBoolean(com.helger.commons.mutable.MutableBoolean) SMPProcess(com.helger.phoss.smp.domain.serviceinfo.SMPProcess) Map(java.util.Map) DBExecutor(com.helger.db.jdbc.executor.DBExecutor) ISMPServiceInformationCallback(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationCallback) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) HashCodeGenerator(com.helger.commons.hashcode.HashCodeGenerator) SMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) StringHelper(com.helger.commons.string.StringHelper) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) EqualsHelper(com.helger.commons.equals.EqualsHelper) ValueEnforcer(com.helger.commons.ValueEnforcer) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) AuditHelper(com.helger.photon.audit.AuditHelper) ISMPServiceInformationManager(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager) ICommonsList(com.helger.commons.collection.impl.ICommonsList) Wrapper(com.helger.commons.wrapper.Wrapper) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) ReturnsMutableObject(com.helger.commons.annotation.ReturnsMutableObject) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) ISMPTransportProfile(com.helger.peppol.smp.ISMPTransportProfile) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) ICommonsList(com.helger.commons.collection.impl.ICommonsList) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) SMPProcess(com.helger.phoss.smp.domain.serviceinfo.SMPProcess) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) SimpleProcessIdentifier(com.helger.peppolid.simple.process.SimpleProcessIdentifier) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) SMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.SMPServiceInformation) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) SMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) Map(java.util.Map) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 3 with SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier in project phoss-smp by phax.

the class SMPServiceInformationManagerJDBC method getAllSMPDocumentTypesOfServiceGroup.

@Nonnull
@ReturnsMutableCopy
public ICommonsList<IDocumentTypeIdentifier> getAllSMPDocumentTypesOfServiceGroup(@Nullable final ISMPServiceGroup aServiceGroup) {
    final ICommonsList<IDocumentTypeIdentifier> ret = new CommonsArrayList<>();
    if (aServiceGroup != null) {
        final IParticipantIdentifier aPID = aServiceGroup.getParticipantIdentifier();
        final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT sm.documentIdentifierScheme, sm.documentIdentifier" + " FROM smp_service_metadata AS sm" + " WHERE sm.businessIdentifierScheme=? AND sm.businessIdentifier=?", new ConstantPreparedStatementDataProvider(aPID.getScheme(), aPID.getValue()));
        if (aDBResult != null)
            for (final DBResultRow aRow : aDBResult) ret.add(new SimpleDocumentTypeIdentifier(aRow.getAsString(0), aRow.getAsString(1)));
    }
    return ret;
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 4 with SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier in project phoss-smp by phax.

the class SMPRedirectTest method testCaseSensitivity.

@Test
public void testCaseSensitivity() {
    final IParticipantIdentifier aPI = new SimpleParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:UpperCase");
    final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "testDocType");
    final SMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
    // Create new one
    final ISMPRedirect aRedirect = new SMPRedirect(aSG, aDocTypeID, "target", "suid", null, "<extredirect/>");
    assertSame(aSG, aRedirect.getServiceGroup());
    assertEquals(aDocTypeID, aRedirect.getDocumentTypeIdentifier());
    assertEquals("target", aRedirect.getTargetHref());
    assertEquals("suid", aRedirect.getSubjectUniqueIdentifier());
    assertNull(aRedirect.getCertificate());
    assertFalse(aRedirect.hasCertificate());
    assertEquals("[{\"Any\":\"<extredirect />\"}]", aRedirect.getExtensionsAsString());
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 5 with SimpleDocumentTypeIdentifier

use of com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier in project phoss-smp by phax.

the class SMPServiceInformationTest method testBasic.

@Test
public void testBasic() {
    final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("0088:dummy");
    final ISMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
    final XMLOffsetDateTime aStartDT = PDTFactory.getCurrentXMLOffsetDateTime();
    final XMLOffsetDateTime aEndDT = aStartDT.plusYears(1);
    final SMPEndpoint aEP = new SMPEndpoint("tp", "http://localhost/as2", false, "minauth", aStartDT, aEndDT, "cert", "sd", "tc", "ti", "<extep/>");
    assertEquals("tp", aEP.getTransportProfile());
    assertEquals("http://localhost/as2", aEP.getEndpointReference());
    assertFalse(aEP.isRequireBusinessLevelSignature());
    assertEquals("minauth", aEP.getMinimumAuthenticationLevel());
    assertEquals(aStartDT, aEP.getServiceActivationDateTime());
    assertEquals(aEndDT, aEP.getServiceExpirationDateTime());
    assertEquals("cert", aEP.getCertificate());
    assertEquals("sd", aEP.getServiceDescription());
    assertEquals("tc", aEP.getTechnicalContactUrl());
    assertEquals("ti", aEP.getTechnicalInformationUrl());
    assertEquals("[{\"Any\":\"<extep />\"}]", aEP.getExtensionsAsString());
    final IProcessIdentifier aProcessID = new SimpleProcessIdentifier(PeppolIdentifierHelper.DEFAULT_PROCESS_SCHEME, "testproc");
    final SMPProcess aProcess = new SMPProcess(aProcessID, CollectionHelper.newList(aEP), "<extproc/>");
    assertEquals(aProcessID, aProcess.getProcessIdentifier());
    assertEquals(1, aProcess.getAllEndpoints().size());
    assertEquals("[{\"Any\":\"<extproc />\"}]", aProcess.getExtensionsAsString());
    final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "testdoctype");
    final SMPServiceInformation aSI = new SMPServiceInformation(aSG, aDocTypeID, CollectionHelper.newList(aProcess), "<extsi/>");
    assertSame(aSG, aSI.getServiceGroup());
    assertEquals(aDocTypeID, aSI.getDocumentTypeIdentifier());
    assertEquals(1, aSI.getAllProcesses().size());
    assertEquals("[{\"Any\":\"<extsi />\"}]", aSI.getExtensionsAsString());
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) SimpleProcessIdentifier(com.helger.peppolid.simple.process.SimpleProcessIdentifier) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) XMLOffsetDateTime(com.helger.commons.datetime.XMLOffsetDateTime) SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Aggregations

SimpleDocumentTypeIdentifier (com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier)15 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)10 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)10 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)9 Nonnull (javax.annotation.Nonnull)8 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)7 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)6 IProcessIdentifier (com.helger.peppolid.IProcessIdentifier)6 SimpleProcessIdentifier (com.helger.peppolid.simple.process.SimpleProcessIdentifier)6 ReturnsMutableCopy (com.helger.commons.annotation.ReturnsMutableCopy)5 DBResultRow (com.helger.db.jdbc.executor.DBResultRow)5 Test (org.junit.Test)5 ConstantPreparedStatementDataProvider (com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider)4 SMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup)4 X509Certificate (java.security.cert.X509Certificate)3 ValueEnforcer (com.helger.commons.ValueEnforcer)2 MustImplementEqualsAndHashcode (com.helger.commons.annotation.MustImplementEqualsAndHashcode)2 ReturnsMutableObject (com.helger.commons.annotation.ReturnsMutableObject)2 CallbackList (com.helger.commons.callback.CallbackList)2 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)2