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