Search in sources :

Example 16 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller in project peppol-commons by phax.

the class SMLFuncTest method testManageBusinessIdentifier.

@Test
public void testManageBusinessIdentifier() throws Exception {
    final ManageParticipantIdentifierServiceCaller aPIClient = new ManageParticipantIdentifierServiceCaller(SML_INFO);
    aPIClient.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
    final IParticipantIdentifier aBusinessIdentifierCreate = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(TEST_BUSINESS_IDENTIFIER1);
    final ServiceMetadataPublisherServiceForParticipantType saSrviceMetadataPublisherServiceForBusiness = new ServiceMetadataPublisherServiceForParticipantType();
    // Explicit constructor call needed for type conversion
    saSrviceMetadataPublisherServiceForBusiness.setParticipantIdentifier(new SimpleParticipantIdentifier(aBusinessIdentifierCreate));
    saSrviceMetadataPublisherServiceForBusiness.setServiceMetadataPublisherID(m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
    aPIClient.create(saSrviceMetadataPublisherServiceForBusiness);
    final ParticipantIdentifierPageType aResult = aPIClient.list("", m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
    assertNotNull(aResult);
    final List<ParticipantIdentifierType> aBusinessIdentifiers = aResult.getParticipantIdentifier();
    assertEquals(1, aBusinessIdentifiers.size());
    final ParticipantIdentifierType aBusinessIdentifierRead = aBusinessIdentifiers.get(0);
    assertEquals(aBusinessIdentifierCreate.getScheme(), aBusinessIdentifierRead.getScheme());
    assertEquals(aBusinessIdentifierCreate.getValue(), aBusinessIdentifierRead.getValue());
    aPIClient.deleteList(aBusinessIdentifiers);
    m_aSMClient.delete(m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
}
Also used : ParticipantIdentifierPageType(com.helger.peppol.smlclient.participant.ParticipantIdentifierPageType) ServiceMetadataPublisherServiceForParticipantType(com.helger.peppol.smlclient.participant.ServiceMetadataPublisherServiceForParticipantType) ParticipantIdentifierType(com.helger.xsds.peppol.id1.ParticipantIdentifierType) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 17 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller 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)

Example 18 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller in project peppol-commons by phax.

the class MainSetupSMLForSMPTests method main.

public static void main(final String[] args) throws Exception {
    final ManageServiceMetadataServiceCaller aSMClient = new ManageServiceMetadataServiceCaller(SML_INFO);
    aSMClient.setSSLSocketFactory(AbstractSMLClientTestCase.createConfiguredSSLSocketFactory(SML_INFO, false));
    final ManageParticipantIdentifierServiceCaller aParticipantClient = new ManageParticipantIdentifierServiceCaller(SML_INFO);
    aParticipantClient.setSSLSocketFactory(AbstractSMLClientTestCase.createConfiguredSSLSocketFactory(SML_INFO, false));
    try {
        aSMClient.create(SMP_ID1, "127.0.0.1", "http://localhost");
    } catch (final Exception e) {
        // ignore
        LOGGER.info(e.getMessage());
    }
    try {
        final IParticipantIdentifier serviceGroupId = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("0088:5798000000001");
        aParticipantClient.create(SMP_ID1, serviceGroupId);
    } catch (final Exception e) {
        // ignore
        LOGGER.info(e.getMessage());
    }
}
Also used : ManageServiceMetadataServiceCaller(com.helger.peppol.smlclient.ManageServiceMetadataServiceCaller) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 19 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller in project peppol-commons by phax.

the class SMKFuncTest method testCreateAndDeletePublisher.

@Test
public void testCreateAndDeletePublisher() throws Exception {
    WSHelper.enableSoapLogging(true);
    try {
        // Create client
        final ManageServiceMetadataServiceCaller aSMPClient = new ManageServiceMetadataServiceCaller(SML_INFO);
        aSMPClient.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
        final ManageParticipantIdentifierServiceCaller aPIClient = new ManageParticipantIdentifierServiceCaller(SML_INFO);
        aPIClient.setSSLSocketFactory(aSMPClient.getSSLSocketFactory());
        // Create SMP - with network logging
        LOGGER.info("CREATE SMP");
        _createSMPData(aSMPClient, SMP_ID);
        try {
            LOGGER.info("CREATE PARTICIPANT");
            aPIClient.create(SMP_ID, PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:philip"));
            try {
            } finally {
                LOGGER.info("DELETE PARTICIPANT");
                // The version with SMP_ID is required for SMK 3.0
                aPIClient.delete(SMP_ID, PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:philip"));
            }
        } finally {
            // Delete SMP
            LOGGER.info("DELETE SMP");
            aSMPClient.delete(SMP_ID);
        }
    } finally {
        WSHelper.enableSoapLogging(false);
    }
}
Also used : ManageServiceMetadataServiceCaller(com.helger.peppol.smlclient.ManageServiceMetadataServiceCaller) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) Test(org.junit.Test)

Example 20 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller in project peppol-commons by phax.

the class SMLFuncTest method testManageServiceMetadataWithManyIdentifier.

@Test
public void testManageServiceMetadataWithManyIdentifier() throws Exception {
    final ManageParticipantIdentifierServiceCaller aPIClient = new ManageParticipantIdentifierServiceCaller(SML_INFO);
    aPIClient.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
    final long nStartIdentifier = 5798000999999l;
    final int nLastIdentifier = 150;
    for (int i = 0; i <= nLastIdentifier; i++) {
        LOGGER.info("Creating number: " + i);
        final long nIdentifier = nStartIdentifier + i;
        aPIClient.create(m_aServiceMetadataPublisher.getServiceMetadataPublisherID(), PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("0088:" + nIdentifier));
    }
    m_aSMClient.delete(m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
    final ServiceMetadataPublisherServiceType aServiceMetadataCreateNew = _createSMPData(m_aSMClient, SMP_ID);
    // Delete one that was on a second page
    final long nIdentifier = nStartIdentifier + nLastIdentifier;
    aPIClient.create(aServiceMetadataCreateNew.getServiceMetadataPublisherID(), PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("0088:" + nIdentifier));
}
Also used : ServiceMetadataPublisherServiceType(com.helger.peppol.smlclient.smp.ServiceMetadataPublisherServiceType) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) Test(org.junit.Test)

Aggregations

ManageParticipantIdentifierServiceCaller (com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller)23 Test (org.junit.Test)16 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)13 UnauthorizedFault (com.helger.peppol.smlclient.participant.UnauthorizedFault)6 PeppolParticipantIdentifier (com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier)6 ParticipantIdentifierPageType (com.helger.peppol.smlclient.participant.ParticipantIdentifierPageType)5 ParticipantIdentifierType (com.helger.xsds.peppol.id1.ParticipantIdentifierType)5 ISMLInfo (com.helger.peppol.sml.ISMLInfo)4 ManageServiceMetadataServiceCaller (com.helger.peppol.smlclient.ManageServiceMetadataServiceCaller)4 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)4 ISMPParticipantMigrationManager (com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager)4 ISMPSettings (com.helger.phoss.smp.settings.ISMPSettings)4 BadRequestFault (com.helger.peppol.smlclient.participant.BadRequestFault)3 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)3 IMicroDocument (com.helger.xml.microdom.IMicroDocument)3 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)2 PDTToString (com.helger.commons.datetime.PDTToString)2 CMimeType (com.helger.commons.mime.CMimeType)2 MimeType (com.helger.commons.mime.MimeType)2 BasicAuthClientCredentials (com.helger.http.basicauth.BasicAuthClientCredentials)2