use of com.helger.http.basicauth.BasicAuthClientCredentials in project peppol-commons by phax.
the class SMPClientTest method testUnauthorizedPassword.
@Test
public void testUnauthorizedPassword() throws SMPClientException {
final SMPClient aSMPClient = new SMPClient(SMP_URI);
final BasicAuthClientCredentials aCredentials = new BasicAuthClientCredentials(SMP_USERNAME, SMP_PASSWORD + "wrongpass");
try {
aSMPClient.saveServiceGroup(MockSMPClientConfig.getParticipantID(), aCredentials);
fail();
} catch (final SMPClientUnauthorizedException ex) {
}
}
use of com.helger.http.basicauth.BasicAuthClientCredentials in project peppol-commons by phax.
the class SMPClientTest method testUnauthorizedUser.
@Test
public void testUnauthorizedUser() throws SMPClientException {
final SMPClient aSMPClient = new SMPClient(SMP_URI);
final BasicAuthClientCredentials aCredentials = new BasicAuthClientCredentials(SMP_USERNAME + "wronguser", SMP_PASSWORD);
try {
aSMPClient.saveServiceGroup(MockSMPClientConfig.getParticipantID(), aCredentials);
fail();
} catch (final SMPClientUnauthorizedException ex) {
}
}
use of com.helger.http.basicauth.BasicAuthClientCredentials in project peppol-commons by phax.
the class MainCheckIfSMPIsWorking method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final IParticipantIdentifier PARTICIPANT_ID = MockSMPClientConfig.getParticipantID();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Ensure that the service group does not exist
LOGGER.info("Ensuring that the service group is not existing!");
if (aClient.getServiceGroupOrNull(PARTICIPANT_ID) != null) {
LOGGER.info("Deleting existing service group for init");
aClient.deleteServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
LOGGER.info("Finished deletion of service group");
}
// Create, read and delete the service group
LOGGER.info("Creating the new service group");
aClient.saveServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
LOGGER.info("Retrieving the service group");
final ServiceGroupType aSGT = aClient.getServiceGroup(PARTICIPANT_ID);
if (!SimpleParticipantIdentifier.wrap(aSGT.getParticipantIdentifier()).equals(PARTICIPANT_ID))
throw new IllegalStateException("Participant identifiers are not equal!");
LOGGER.info("Deleting the service group again");
aClient.deleteServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
LOGGER.info("Checking if the service group is really deleted");
if (aClient.getServiceGroupOrNull(PARTICIPANT_ID) != null)
throw new IllegalStateException("Deletion of the service group failed!");
LOGGER.info("Seems like the SMP is working as expected!");
}
use of com.helger.http.basicauth.BasicAuthClientCredentials in project peppol-commons by phax.
the class MainSMPServiceGroupDelete method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final IParticipantIdentifier PARTICIPANT_ID = MockSMPClientConfig.getParticipantID();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Delete the service group
aClient.deleteServiceGroup(PARTICIPANT_ID, SMP_CREDENTIALS);
LOGGER.info("Done");
}
use of com.helger.http.basicauth.BasicAuthClientCredentials in project peppol-commons by phax.
the class MainSMPServiceGroupReferenceList method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final String SMP_USERNAME = MockSMPClientConfig.getSMPUserName();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Get the service group reference list
final ServiceGroupReferenceListType aServiceGroupReferenceList = aClient.getServiceGroupReferenceListOrNull(SMP_USERNAME, SMP_CREDENTIALS);
if (aServiceGroupReferenceList == null)
LOGGER.error("Failed to get complete service group for " + SMP_USERNAME);
else {
LOGGER.info("All service groups owned by " + SMP_USERNAME + ":");
for (final ServiceGroupReferenceType aServiceGroupReference : aServiceGroupReferenceList.getServiceGroupReference()) LOGGER.info(" " + aServiceGroupReference.getHref());
}
LOGGER.info("Done");
}
Aggregations