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