Search in sources :

Example 26 with ISMLInfo

use of com.helger.peppol.sml.ISMLInfo in project phoss-smp by phax.

the class PageSecureSMPSettings method showObject.

@Override
protected void showObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ISMPSettings aObject) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final String sDirectoryName = SMPWebAppConfiguration.getDirectoryName();
    {
        final BootstrapCard aCard = aNodeList.addAndReturnChild(new BootstrapCard());
        aCard.createAndAddHeader().addChild("REST API");
        final BootstrapCardBody aCardBody = aCard.createAndAddBody();
        final BootstrapViewForm aTable = aCardBody.addAndReturnChild(new BootstrapViewForm());
        aTable.setLeft(4);
        aTable.addFormGroup(new BootstrapFormGroup().setLabel("REST writable API disabled?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isRESTWritableAPIDisabled(), aDisplayLocale)));
    }
    {
        final BootstrapCard aCard = aNodeList.addAndReturnChild(new BootstrapCard());
        aCard.createAndAddHeader().addChild("SMK/SML");
        final BootstrapCardBody aCardBody = aCard.createAndAddBody();
        final BootstrapViewForm aTable = aCardBody.addAndReturnChild(new BootstrapViewForm());
        aTable.setLeft(4);
        aTable.addFormGroup(new BootstrapFormGroup().setLabel("SML connection required?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isSMLRequired(), aDisplayLocale)));
        aTable.addFormGroup(new BootstrapFormGroup().setLabel("SML connection enabled?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isSMLEnabled(), aDisplayLocale)));
        final ISMLInfo aSMLInfo = aObject.getSMLInfo();
        aTable.addFormGroup(new BootstrapFormGroup().setLabel("SML to be used").setCtrl(aSMLInfo == null ? em("none") : HCSMLSelect.getDisplayNameNode(aSMLInfo)));
    }
    {
        final BootstrapCard aCard = aNodeList.addAndReturnChild(new BootstrapCard());
        aCard.createAndAddHeader().addChild(sDirectoryName);
        final BootstrapCardBody aCardBody = aCard.createAndAddBody();
        final BootstrapViewForm aTable = aCardBody.addAndReturnChild(new BootstrapViewForm());
        aTable.setLeft(4);
        aTable.addFormGroup(new BootstrapFormGroup().setLabel(sDirectoryName + " integration required?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isDirectoryIntegrationRequired(), aDisplayLocale)));
        aTable.addFormGroup(new BootstrapFormGroup().setLabel(sDirectoryName + " integration enabled?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isDirectoryIntegrationEnabled(), aDisplayLocale)));
        aTable.addFormGroup(new BootstrapFormGroup().setLabel(sDirectoryName + " integration automatic update?").setCtrl(EPhotonCoreText.getYesOrNo(aObject.isDirectoryIntegrationAutoUpdate(), aDisplayLocale)));
        aTable.addFormGroup(new BootstrapFormGroup().setLabel(sDirectoryName + " hostname").setCtrl(HCA.createLinkedWebsite(aObject.getDirectoryHostName())));
    }
}
Also used : Locale(java.util.Locale) BootstrapCard(com.helger.photon.bootstrap4.card.BootstrapCard) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMLInfo(com.helger.peppol.sml.ISMLInfo) BootstrapCardBody(com.helger.photon.bootstrap4.card.BootstrapCardBody) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup)

Example 27 with ISMLInfo

use of com.helger.peppol.sml.ISMLInfo in project peppol-commons by phax.

the class BDXRClientReadOnlyTest method testReadTOOP.

@Test
@Ignore("Because it may take long to execute")
@IgnoredNaptrTest
public void testReadTOOP() throws SMPDNSResolutionException, SMPClientException {
    final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9930:167064991");
    final IDocumentTypeIdentifier aDocTypeID = SimpleIdentifierFactory.INSTANCE.createDocumentTypeIdentifier("toop-doctypeid-qns", "urn:eu:toop:ns:dataexchange-1p40::Response##urn:eu.toop.response.registeredorganization::1.40");
    // TOOP SML
    final ISMLInfo aSMLInfo = new SMLInfo("toop", "SMK", "toop.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);
    aBDXRClient.setVerifySignature(false);
    assertEquals("http://smp.toop.egov.iwvi.uni-koblenz.de/", aBDXRClient.getSMPHostURI());
    if (false) {
        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 28 with ISMLInfo

use of com.helger.peppol.sml.ISMLInfo in project peppol-commons by phax.

the class BDXRClientReadOnlyTest method testReadDE4A.

@Test
@Ignore("Because it may take long to execute")
@IgnoredNaptrTest
public void testReadDE4A() throws Exception {
    final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:at000000271");
    final IDocumentTypeIdentifier aDocTypeID = SimpleIdentifierFactory.INSTANCE.createDocumentTypeIdentifier("urn:de4a-eu:CanonicalEvidenceType", "CompanyRegistration");
    final KeyStore aTS = KeyStoreHelper.loadKeyStoreDirect(EKeyStoreType.JKS, "truststores/de4a-truststore-test-smp-pw-de4a.jks", "de4a");
    assertNotNull(aTS);
    // TOOP SML
    final ISMLInfo aSMLInfo = new SMLInfo("dea4", "SMK", "de4a.acc.edelivery.tech.ec.europa.eu.", "https://acc.edelivery.tech.ec.europa.eu/edelivery-sml", true);
    // BDXL URL provider
    final BDXRClientReadOnly aBDXRClient = new BDXRClientReadOnly(BDXLURLProvider.INSTANCE, aPI, aSMLInfo);
    // Custom truststore is needed atm
    aBDXRClient.setTrustStore(aTS);
    assertEquals("https://de4a-smp.egovlab.eu/", 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) KeyStore(java.security.KeyStore) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Ignore(org.junit.Ignore) IgnoredNaptrTest(com.helger.smpclient.IgnoredNaptrTest) IgnoredNaptrTest(com.helger.smpclient.IgnoredNaptrTest) Test(org.junit.Test)

Example 29 with ISMLInfo

use of com.helger.peppol.sml.ISMLInfo in project peppol-commons by phax.

the class MainForArunFromBasware method main.

public static void main(final String[] args) throws Exception {
    // START MODIFY BELOW
    // Your SMP ID
    final String SMP_ID = "TEST-SMP";
    // Use SMK or SML?
    final ISMLInfo aSMLInfo = ESML.DIGIT_TEST;
    // Keystore path and password
    final EKeyStoreType eKeyStoreType = EKeyStoreType.JKS;
    final String sKeystorePath = "keystore/smp.pilot.jks";
    final String sKeystorePassword = "peppol";
    // Participant to be created
    final String sServiceGroupID = "0088:5798000000001";
    // Create (true) or delete (false) participant?
    final boolean bCreate = false;
    // Proxy server settings
    final String sProxyHostname = null;
    final int nProxyPort = 0;
    WSHelper.setMetroDebugSystemProperties(true);
    // Set proxy as system properties
    if (nProxyPort > 0 && StringHelper.hasText(sProxyHostname)) {
        SystemProperties.setPropertyValue("http.proxyHost", sProxyHostname);
        SystemProperties.setPropertyValue("http.proxyPort", nProxyPort);
        SystemProperties.setPropertyValue("https.proxyHost", sProxyHostname);
        SystemProperties.setPropertyValue("https.proxyPort", nProxyPort);
    }
    final ManageParticipantIdentifierServiceCaller aParticipantClient = new ManageParticipantIdentifierServiceCaller(aSMLInfo);
    if (aSMLInfo.isClientCertificateRequired()) {
        // Main key storage
        final KeyStore aKeyStore = KeyStoreHelper.loadKeyStoreDirect(eKeyStoreType, sKeystorePath, sKeystorePassword);
        // Key manager
        final KeyManagerFactory aKeyManagerFactory = KeyManagerFactory.getInstance("SunX509");
        aKeyManagerFactory.init(aKeyStore, sKeystorePassword.toCharArray());
        // Assign key manager and empty trust manager to SSL context
        final SSLContext aSSLCtx = SSLContext.getInstance("TLS");
        aSSLCtx.init(aKeyManagerFactory.getKeyManagers(), new TrustManager[] { new TrustManagerTrustAll(false) }, null);
        aParticipantClient.setSSLSocketFactory(aSSLCtx.getSocketFactory());
    }
    // Main WS call
    final IParticipantIdentifier aServiceGroupID = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(sServiceGroupID);
    if (bCreate) {
        // Create
        aParticipantClient.create(SMP_ID, aServiceGroupID);
        LOGGER.info("Successfully created participant " + aServiceGroupID.getURIEncoded());
    } else {
        // Delete
        aParticipantClient.delete(SMP_ID, aServiceGroupID);
        LOGGER.info("Successfully deleted participant " + aServiceGroupID.getURIEncoded());
    }
}
Also used : ISMLInfo(com.helger.peppol.sml.ISMLInfo) EKeyStoreType(com.helger.security.keystore.EKeyStoreType) SSLContext(javax.net.ssl.SSLContext) KeyStore(java.security.KeyStore) TrustManagerTrustAll(com.helger.commons.ws.TrustManagerTrustAll) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) KeyManagerFactory(javax.net.ssl.KeyManagerFactory) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

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