use of com.helger.peppol.sml.ISMLInfo in project phoss-directory by phax.
the class SMPBusinessCardProvider method getBusinessCard.
@Nullable
public PDExtendedBusinessCard getBusinessCard(@Nonnull final IParticipantIdentifier aParticipantID) {
final HttpClientSettings aHCS = new HttpClientSettings().setProxyHost(_getHttpProxy()).setProxyCredentials(_getHttpProxyCredentials());
PDExtendedBusinessCard aBC;
if (m_aSMPURI != null) {
// Use a preselected SMP URI
switch(m_eSMPMode) {
case PEPPOL:
{
final SMPClientReadOnly aSMPClient = new SMPClientReadOnly(m_aSMPURI);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardPeppolSMP(aParticipantID, aSMPClient, aHCS);
break;
}
case OASIS_BDXR_V1:
{
final BDXRClientReadOnly aSMPClient = new BDXRClientReadOnly(m_aSMPURI);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardBDXR1(aParticipantID, aSMPClient, aHCS);
break;
}
case OASIS_BDXR_V2:
{
final BDXR2ClientReadOnly aSMPClient = new BDXR2ClientReadOnly(m_aSMPURI);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardBDXR2(aParticipantID, aSMPClient, aHCS);
break;
}
default:
throw new IllegalStateException("Unsupported SMP mode " + m_eSMPMode);
}
} else {
// SML auto detect
aBC = null;
for (final ISMLInfo aSML : m_aSMLInfoProvider.get()) {
// Create SMP client and query SMP
switch(m_eSMPMode) {
case PEPPOL:
{
try {
final SMPClientReadOnly aSMPClient = new SMPClientReadOnly(m_aURLProvider, aParticipantID, aSML);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardPeppolSMP(aParticipantID, aSMPClient, aHCS);
} catch (final SMPDNSResolutionException ex) {
// Happens if a non-existing URL is queried
}
break;
}
case OASIS_BDXR_V1:
{
try {
final BDXRClientReadOnly aSMPClient = new BDXRClientReadOnly(m_aURLProvider, aParticipantID, aSML);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardBDXR1(aParticipantID, aSMPClient, aHCS);
} catch (final SMPDNSResolutionException ex) {
// Happens if a non-existing URL is queried
}
break;
}
case OASIS_BDXR_V2:
{
try {
final BDXR2ClientReadOnly aSMPClient = new BDXR2ClientReadOnly(m_aURLProvider, aParticipantID, aSML);
_configureSMPClient(aSMPClient);
aBC = getBusinessCardBDXR2(aParticipantID, aSMPClient, aHCS);
} catch (final SMPDNSResolutionException ex) {
// Happens if a non-existing URL is queried
}
break;
}
default:
throw new IllegalStateException("Unsupported SMP mode " + m_eSMPMode);
}
// Found one?
if (aBC != null)
break;
}
}
if (aBC != null)
LOGGER.info("Found BusinessCard for '" + aParticipantID.getURIEncoded() + "' with " + aBC.getBusinessCard().businessEntities().size() + " entities and " + aBC.getDocumentTypeCount() + " document types");
return aBC;
}
use of com.helger.peppol.sml.ISMLInfo in project phoss-directory by phax.
the class SMLInfoManager method createSMLInfo.
@Nonnull
public ISMLInfo createSMLInfo(@Nonnull @Nonempty final String sDisplayName, @Nonnull @Nonempty final String sDNSZone, @Nonnull @Nonempty final String sManagementServiceURL, final boolean bClientCertificateRequired) {
final SMLInfo aSMLInfo = new SMLInfo(sDisplayName, sDNSZone, sManagementServiceURL, bClientCertificateRequired);
m_aRWLock.writeLocked(() -> {
internalCreateItem(aSMLInfo);
});
AuditHelper.onAuditCreateSuccess(SMLInfo.OT, aSMLInfo.getID(), sDisplayName, sDNSZone, sManagementServiceURL, Boolean.valueOf(bClientCertificateRequired));
return aSMLInfo;
}
use of com.helger.peppol.sml.ISMLInfo in project phoss-directory by phax.
the class PageSecureAdminSMLConfiguration method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMLInfoManager aSMLInfoMgr = PDPMetaManager.getSMLInfoMgr();
aNodeList.addChild(info("This page lets you create custom SML configurations that can be used for registration."));
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new SML configuration", createCreateURL(aWPEC), EDefaultIcon.NEW);
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("Name").setInitialSorting(ESortOrder.ASCENDING), new DTCol("DNS Zone"), new DTCol("Management Service URL"), new DTCol("Client Cert?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMLInfo aCurObject : aSMLInfoMgr.getAll()) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getDisplayName()));
aRow.addCell(aCurObject.getDNSZone());
aRow.addCell(aCurObject.getManagementServiceURL());
aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isClientCertificateRequired(), aDisplayLocale));
aRow.addCell(createEditLink(aWPEC, aCurObject, "Edit " + aCurObject.getID()), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject, "Copy " + aCurObject.getID()), new HCTextNode(" "), isActionAllowed(aWPEC, EWebPageFormAction.DELETE, aCurObject) ? createDeleteLink(aWPEC, aCurObject, "Delete " + aCurObject.getDisplayName()) : createEmptyAction());
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
use of com.helger.peppol.sml.ISMLInfo in project peppol-commons by phax.
the class BDXRClientReadOnlyTest method testReadConnectivityTest.
@Test
@Ignore("Because it may take long to execute")
@IgnoredNaptrTest
public void testReadConnectivityTest() throws SMPDNSResolutionException, SMPClientException {
final IParticipantIdentifier aPI = SimpleIdentifierFactory.INSTANCE.createParticipantIdentifier("connectivity-partid-qns", "dynceftest1party59gw");
final IDocumentTypeIdentifier aDocTypeID = SimpleIdentifierFactory.INSTANCE.createDocumentTypeIdentifier("connectivity-docid-qns", "doc_id1");
// TOOP SML
final ISMLInfo aSMLInfo = new SMLInfo("cef-connectivity", "CEF ConnectivityTest", "connectivitytest.acc.edelivery.tech.ec.europa.eu.", "https://acc.edelivery.tech.ec.europa.eu/edelivery-sml", true);
// PEPPOL URL provider
final BDXRClientReadOnly aBDXRClient = new BDXRClientReadOnly(BDXLURLProvider.INSTANCE, aPI, aSMLInfo);
// We don't have the truststore at hand - ignore it
aBDXRClient.setVerifySignature(false);
assertEquals("https://gateway-edelivery.westeurope.cloudapp.azure.com:444/", aBDXRClient.getSMPHostURI());
final SignedServiceMetadataType aMetadata = aBDXRClient.getServiceMetadata(aPI, aDocTypeID);
assertNotNull(aMetadata);
}
use of com.helger.peppol.sml.ISMLInfo in project phoss-smp by phax.
the class SMLInfoManagerMongoDBTest method testBasic.
@Test
public void testBasic() {
try (final SMLInfoManagerMongoDB aMgr = new SMLInfoManagerMongoDB()) {
assertEquals(0, aMgr.getAllSMLInfos().size());
final ICommonsList<ISMLInfo> aCreated = aMgr.getAllSMLInfos();
for (final ESML e : ESML.values()) {
final ISMLInfo aCreate = aMgr.createSMLInfo(e.getDisplayName(), e.getDNSZone(), e.getManagementServiceURL(), e.isClientCertificateRequired());
aCreated.add(aCreate);
}
final ICommonsList<ISMLInfo> aAll = aMgr.getAllSMLInfos();
assertEquals(ESML.values().length, aAll.size());
for (final ISMLInfo aCreate : aCreated) assertTrue(aAll.contains(aCreate));
for (final ISMLInfo aCreate : aCreated) assertTrue(aMgr.updateSMLInfo(aCreate.getID(), "bla " + aCreate.getDisplayName(), aCreate.getDNSZone(), aCreate.getManagementServiceURL(), aCreate.isClientCertificateRequired()).isChanged());
for (final ISMLInfo aCreate : aCreated) {
final ISMLInfo aInfo = aMgr.getSMLInfoOfID(aCreate.getID());
assertNotNull(aInfo);
assertTrue(aInfo.getDisplayName().startsWith("bla "));
}
for (final ISMLInfo aCreate : aCreated) assertTrue(aMgr.deleteSMLInfo(aCreate.getID()).isChanged());
assertEquals(0, aMgr.getAllSMLInfos().size());
}
}
Aggregations