Search in sources :

Example 1 with BasicAuthClientCredentials

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) {
    }
}
Also used : BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) SMPClientUnauthorizedException(com.helger.smpclient.exception.SMPClientUnauthorizedException) Test(org.junit.Test)

Example 2 with BasicAuthClientCredentials

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) {
    }
}
Also used : BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) SMPClientUnauthorizedException(com.helger.smpclient.exception.SMPClientUnauthorizedException) Test(org.junit.Test)

Example 3 with BasicAuthClientCredentials

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!");
}
Also used : BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) SMPClient(com.helger.smpclient.peppol.SMPClient) URI(java.net.URI) ServiceGroupType(com.helger.xsds.peppol.smp1.ServiceGroupType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 4 with BasicAuthClientCredentials

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");
}
Also used : BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) SMPClient(com.helger.smpclient.peppol.SMPClient) URI(java.net.URI) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 5 with BasicAuthClientCredentials

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");
}
Also used : BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) SMPClient(com.helger.smpclient.peppol.SMPClient) ServiceGroupReferenceListType(com.helger.xsds.peppol.smp1.ServiceGroupReferenceListType) ServiceGroupReferenceType(com.helger.xsds.peppol.smp1.ServiceGroupReferenceType) URI(java.net.URI)

Aggregations

BasicAuthClientCredentials (com.helger.http.basicauth.BasicAuthClientCredentials)26 ISMPServerAPIDataProvider (com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider)15 SMPPreconditionFailedException (com.helger.phoss.smp.exception.SMPPreconditionFailedException)12 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)10 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)8 SMPBadRequestException (com.helger.phoss.smp.exception.SMPBadRequestException)8 CMimeType (com.helger.commons.mime.CMimeType)7 MimeType (com.helger.commons.mime.MimeType)7 IMicroDocument (com.helger.xml.microdom.IMicroDocument)7 XMLWriterSettings (com.helger.xml.serialize.write.XMLWriterSettings)7 BDXR1ServerAPI (com.helger.phoss.smp.restapi.BDXR1ServerAPI)6 SMPServerAPI (com.helger.phoss.smp.restapi.SMPServerAPI)6 SMPClient (com.helger.smpclient.peppol.SMPClient)6 URI (java.net.URI)6 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)5 ISMPParticipantMigration (com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration)5 ISMPParticipantMigrationManager (com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager)5 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)5 ISMPSettingsManager (com.helger.phoss.smp.settings.ISMPSettingsManager)4 IXMLWriterSettings (com.helger.xml.serialize.write.IXMLWriterSettings)4