Search in sources :

Example 1 with ISMLInfo

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;
}
Also used : BDXR2ClientReadOnly(com.helger.smpclient.bdxr2.BDXR2ClientReadOnly) SMPClientReadOnly(com.helger.smpclient.peppol.SMPClientReadOnly) ISMLInfo(com.helger.peppol.sml.ISMLInfo) HttpClientSettings(com.helger.httpclient.HttpClientSettings) SMPDNSResolutionException(com.helger.smpclient.url.SMPDNSResolutionException) BDXRClientReadOnly(com.helger.smpclient.bdxr1.BDXRClientReadOnly) Nullable(javax.annotation.Nullable)

Example 2 with ISMLInfo

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;
}
Also used : SMLInfo(com.helger.peppol.sml.SMLInfo) ISMLInfo(com.helger.peppol.sml.ISMLInfo) Nonnull(javax.annotation.Nonnull)

Example 3 with ISMLInfo

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);
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMLInfo(com.helger.peppol.sml.ISMLInfo) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) HCTable(com.helger.html.hc.html.tabular.HCTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) ISMLInfoManager(com.helger.pd.publisher.app.ISMLInfoManager) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) HCTextNode(com.helger.html.hc.impl.HCTextNode) DataTables(com.helger.photon.uictrls.datatables.DataTables) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)

Example 4 with ISMLInfo

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);
}
Also used : ISMLInfo(com.helger.peppol.sml.ISMLInfo) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SignedServiceMetadataType(com.helger.xsds.bdxr.smp1.SignedServiceMetadataType) SMLInfo(com.helger.peppol.sml.SMLInfo) ISMLInfo(com.helger.peppol.sml.ISMLInfo) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Ignore(org.junit.Ignore) IgnoredNaptrTest(com.helger.smpclient.IgnoredNaptrTest) IgnoredNaptrTest(com.helger.smpclient.IgnoredNaptrTest) Test(org.junit.Test)

Example 5 with ISMLInfo

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());
    }
}
Also used : ISMLInfo(com.helger.peppol.sml.ISMLInfo) ESML(com.helger.peppol.sml.ESML) Test(org.junit.Test)

Aggregations

ISMLInfo (com.helger.peppol.sml.ISMLInfo)29 HCNodeList (com.helger.html.hc.impl.HCNodeList)11 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)9 SMLInfo (com.helger.peppol.sml.SMLInfo)7 Locale (java.util.Locale)7 Nonnull (javax.annotation.Nonnull)6 Test (org.junit.Test)6 ISMPSettings (com.helger.phoss.smp.settings.ISMPSettings)5 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)5 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)5 UnknownHostException (java.net.UnknownHostException)5 ManageParticipantIdentifierServiceCaller (com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller)4 PDTToString (com.helger.commons.datetime.PDTToString)3 HCA (com.helger.html.hc.html.textlevel.HCA)3 ManageServiceMetadataServiceCaller (com.helger.peppol.smlclient.ManageServiceMetadataServiceCaller)3 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)3 BootstrapForm (com.helger.photon.bootstrap4.form.BootstrapForm)3 FormErrorList (com.helger.photon.core.form.FormErrorList)3 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)3 CMimeType (com.helger.commons.mime.CMimeType)2