Search in sources :

Example 16 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project phoss-directory by phax.

the class ExportAllManager method queryAllContainedParticipantsAsXML.

@Nonnull
public static IMicroDocument queryAllContainedParticipantsAsXML(@Nonnull final EQueryMode eQueryMode) throws IOException {
    final Query aQuery = eQueryMode.getEffectiveQuery(new MatchAllDocsQuery());
    // Query all and group by participant ID
    final ICommonsSortedSet<IParticipantIdentifier> aSet = new CommonsTreeSet<>(Comparator.comparing(IParticipantIdentifier::getURIEncoded));
    PDMetaManager.getStorageMgr().searchAll(aQuery, -1, PDField.PARTICIPANT_ID::getDocValue, aSet::add);
    // XML root
    final IMicroDocument aDoc = new MicroDocument();
    final String sNamespaceURI = "http://www.peppol.eu/schema/pd/participant-generic/201910/";
    final IMicroElement aRoot = aDoc.appendElement(sNamespaceURI, "root");
    aRoot.setAttribute("version", "1");
    aRoot.setAttribute("creationdt", PDTWebDateHelper.getAsStringXSD(PDTFactory.getCurrentZonedDateTimeUTC()));
    aRoot.setAttribute("count", aSet.size());
    // For all participants
    for (final IParticipantIdentifier aParticipantID : aSet) {
        aRoot.appendElement(sNamespaceURI, "participantID").setAttribute("scheme", aParticipantID.getScheme()).setAttribute("value", aParticipantID.getValue());
    }
    return aDoc;
}
Also used : IMicroDocument(com.helger.xml.microdom.IMicroDocument) MicroDocument(com.helger.xml.microdom.MicroDocument) Query(org.apache.lucene.search.Query) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) CommonsTreeSet(com.helger.commons.collection.impl.CommonsTreeSet) IMicroElement(com.helger.xml.microdom.IMicroElement) IMicroDocument(com.helger.xml.microdom.IMicroDocument) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull)

Example 17 with IParticipantIdentifier

use of com.helger.peppolid.IParticipantIdentifier in project phoss-directory by phax.

the class SyncAllBusinessCardsJob method syncAllBusinessCards.

@Nonnull
public static EChange syncAllBusinessCards(final boolean bForceSync) {
    final LocalDateTime aNow = PDTFactory.getCurrentLocalDateTime();
    if (!bForceSync) {
        // Only sync every 2 weeks
        if (aNow.isBefore(getLastSync().plusWeeks(2))) {
            return EChange.UNCHANGED;
        }
    }
    LOGGER.info("Start synchronizing business cards" + (bForceSync ? " (forced)" : ""));
    final PDIndexerManager aIndexerMgr = PDMetaManager.getIndexerMgr();
    // Queue a work item to re-scan all
    final Set<IParticipantIdentifier> aAll = PDMetaManager.getStorageMgr().getAllContainedParticipantIDs(EQueryMode.NON_DELETED_ONLY).keySet();
    for (final IParticipantIdentifier aParticipantID : aAll) {
        aIndexerMgr.queueWorkItem(aParticipantID, EIndexerWorkItemType.SYNC, "sync-job", PDIndexerManager.HOST_LOCALHOST);
    }
    LOGGER.info("Finished synchronizing of " + aAll.size() + " business cards");
    AuditHelper.onAuditExecuteSuccess("sync-bc-started", Integer.valueOf(aAll.size()), aNow, Boolean.valueOf(bForceSync));
    _setLastSync(aNow);
    return EChange.CHANGED;
}
Also used : LocalDateTime(java.time.LocalDateTime) PDIndexerManager(com.helger.pd.indexer.mgr.PDIndexerManager) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull)

Example 18 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 19 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 20 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)

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