Search in sources :

Example 41 with SimpleParticipantIdentifier

use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.

the class SMPRedirectTest method testBasic.

@Test
public void testBasic() {
    final IParticipantIdentifier aPI = new SimpleParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:dummy");
    final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "testdoctype");
    final SMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
    // Create new one
    final ISMPRedirect aRedirect = new SMPRedirect(aSG, aDocTypeID, "target", "suid", null, "<extredirect/>");
    assertSame(aSG, aRedirect.getServiceGroup());
    assertEquals(aDocTypeID, aRedirect.getDocumentTypeIdentifier());
    assertEquals("target", aRedirect.getTargetHref());
    assertEquals("suid", aRedirect.getSubjectUniqueIdentifier());
    assertNull(aRedirect.getCertificate());
    assertFalse(aRedirect.hasCertificate());
    assertEquals("[{\"Any\":\"<extredirect />\"}]", aRedirect.getExtensionsAsString());
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 42 with SimpleParticipantIdentifier

use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.

the class SMPServiceInformationTest method testMinimal.

@Test
public void testMinimal() {
    final IParticipantIdentifier aPI = new SimpleParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:dummy");
    final ISMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
    final SMPEndpoint aEP = new SMPEndpoint("tp", "http://localhost/as2", false, (String) null, (XMLOffsetDateTime) null, (XMLOffsetDateTime) null, "cert", "sd", "tc", (String) null, (String) null);
    assertEquals("tp", aEP.getTransportProfile());
    assertEquals("http://localhost/as2", aEP.getEndpointReference());
    assertFalse(aEP.isRequireBusinessLevelSignature());
    assertNull(aEP.getMinimumAuthenticationLevel());
    assertNull(aEP.getServiceActivationDateTime());
    assertNull(aEP.getServiceExpirationDateTime());
    assertEquals("cert", aEP.getCertificate());
    assertEquals("sd", aEP.getServiceDescription());
    assertEquals("tc", aEP.getTechnicalContactUrl());
    assertNull(aEP.getTechnicalInformationUrl());
    assertNull(aEP.getExtensionsAsString());
    final IProcessIdentifier aProcessID = new SimpleProcessIdentifier(PeppolIdentifierHelper.DEFAULT_PROCESS_SCHEME, "testproc");
    final SMPProcess aProcess = new SMPProcess(aProcessID, CollectionHelper.newList(aEP), (String) null);
    assertEquals(aProcessID, aProcess.getProcessIdentifier());
    assertEquals(1, aProcess.getAllEndpoints().size());
    assertNull(aProcess.getExtensionsAsString());
    final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "testdoctype");
    final SMPServiceInformation aSI = new SMPServiceInformation(aSG, aDocTypeID, CollectionHelper.newList(aProcess), (String) null);
    assertSame(aSG, aSI.getServiceGroup());
    assertEquals(aDocTypeID, aSI.getDocumentTypeIdentifier());
    assertEquals(1, aSI.getAllProcesses().size());
    assertNull(aSI.getExtensionsAsString());
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) SimpleProcessIdentifier(com.helger.peppolid.simple.process.SimpleProcessIdentifier) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 43 with SimpleParticipantIdentifier

use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.

the class SMPBusinessCardTest method testBasic.

@Test
public void testBasic() {
    final IParticipantIdentifier aPI = new SimpleParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:dummy");
    final SMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
    // Test empty
    {
        final SMPBusinessCard aBC = new SMPBusinessCard(aPI, new CommonsArrayList<>());
        assertEquals(aPI, aBC.getParticipantIdentifier());
        assertEquals(aSG.getID(), aBC.getID());
        assertNotNull(aBC.getAllEntities());
        assertTrue(aBC.getAllEntities().isEmpty());
        _testXMLConversion(aBC);
    }
    // with entities
    {
        final SMPBusinessCardEntity aEntity1 = new SMPBusinessCardEntity();
        aEntity1.names().add(new SMPBusinessCardName("Name 1", "de"));
        aEntity1.names().add(new SMPBusinessCardName("Name 2", null));
        aEntity1.setCountryCode("AT");
        aEntity1.setGeographicalInformation("here\nthere\r\neverywhere");
        aEntity1.identifiers().add(new SMPBusinessCardIdentifier("scheme1", "value1"));
        aEntity1.identifiers().add(new SMPBusinessCardIdentifier("scheme 2", "value 2"));
        aEntity1.websiteURIs().add("http://www.helger.com");
        aEntity1.websiteURIs().add("https://github.com/phax/phoss-smp");
        aEntity1.contacts().add(new SMPBusinessCardContact("type 1", "Whoever", "with a phone", "and@an.email.org"));
        aEntity1.contacts().add(new SMPBusinessCardContact("type 2", "Whoever else", "without a phone", "but@an.email.org"));
        aEntity1.setAdditionalInformation("this is line1\nfollowed by line 2\r\nand now eoai");
        aEntity1.setRegistrationDate(PDTFactory.getCurrentLocalDate());
        final SMPBusinessCardEntity aEntity2 = new SMPBusinessCardEntity();
        aEntity2.names().add(new SMPBusinessCardName("Name 1", "de"));
        aEntity2.names().add(new SMPBusinessCardName("Name 2", null));
        aEntity2.setCountryCode("UK");
        aEntity2.setGeographicalInformation("here\nthere\r\neverywhere");
        aEntity2.identifiers().add(new SMPBusinessCardIdentifier("scheme1", "value1"));
        aEntity2.identifiers().add(new SMPBusinessCardIdentifier("scheme 2", "value 2"));
        aEntity2.websiteURIs().add("http://www.helger.com");
        aEntity2.websiteURIs().add("https://github.com/phax/phoss-smp");
        aEntity2.contacts().add(new SMPBusinessCardContact("type 1", "Whoever", "with a phone", "and@an.email.org"));
        aEntity2.contacts().add(new SMPBusinessCardContact("type 2", "Whoever else", "without a phone", "but@an.email.org"));
        aEntity2.setAdditionalInformation("this is line1\nfollowed by line 2\r\nand now eoai");
        aEntity2.setRegistrationDate(PDTFactory.getCurrentLocalDate());
        final SMPBusinessCardEntity aEntity3 = new SMPBusinessCardEntity();
        aEntity3.names().add(new SMPBusinessCardName("Shorty", null));
        aEntity3.setCountryCode("US");
        final SMPBusinessCard aBC = new SMPBusinessCard(aPI, new CommonsArrayList<>(aEntity1, aEntity2, aEntity3));
        assertEquals(aPI, aBC.getParticipantIdentifier());
        assertEquals(aSG.getID(), aBC.getID());
        assertNotNull(aBC.getAllEntities());
        assertEquals(3, aBC.getAllEntities().size());
        _testXMLConversion(aBC);
    }
}
Also used : SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 44 with SimpleParticipantIdentifier

use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.

the class SMPRedirectManagerJDBC method getAllSMPRedirects.

@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPRedirect> getAllSMPRedirects() {
    final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT businessIdentifierScheme, businessIdentifier, documentIdentifierScheme, documentIdentifier, redirectionUrl, certificateUID, certificate, extension" + " FROM smp_service_metadata_red");
    final ICommonsList<ISMPRedirect> ret = new CommonsArrayList<>();
    if (aDBResult != null)
        for (final DBResultRow aRow : aDBResult) {
            final ISMPServiceGroup aServiceGroup = m_aServiceGroupMgr.getSMPServiceGroupOfID(new SimpleParticipantIdentifier(aRow.getAsString(0), aRow.getAsString(1)));
            final X509Certificate aCertificate = CertificateHelper.convertStringToCertficateOrNull(aRow.getAsString(6));
            ret.add(new SMPRedirect(aServiceGroup, new SimpleDocumentTypeIdentifier(aRow.getAsString(2), aRow.getAsString(3)), aRow.getAsString(4), aRow.getAsString(5), aCertificate, aRow.getAsString(7)));
        }
    return ret;
}
Also used : SimpleDocumentTypeIdentifier(com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) SMPRedirect(com.helger.phoss.smp.domain.redirect.SMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) X509Certificate(java.security.cert.X509Certificate) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Example 45 with SimpleParticipantIdentifier

use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.

the class SMPServiceGroupManagerJDBC method getAllSMPServiceGroupsOfOwner.

@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPServiceGroup> getAllSMPServiceGroupsOfOwner(@Nonnull final String sOwnerID) {
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("getAllSMPServiceGroupsOfOwner(" + sOwnerID + ")");
    final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT sg.businessIdentifierScheme, sg.businessIdentifier, sg.extension" + " FROM smp_service_group sg, smp_ownership so" + " WHERE so.username=?" + " AND so.businessIdentifierScheme=sg.businessIdentifierScheme AND so.businessIdentifier=sg.businessIdentifier", new ConstantPreparedStatementDataProvider(sOwnerID));
    final ICommonsList<ISMPServiceGroup> ret = new CommonsArrayList<>();
    if (aDBResult != null)
        for (final DBResultRow aRow : aDBResult) ret.add(new SMPServiceGroup(sOwnerID, new SimpleParticipantIdentifier(aRow.getAsString(0), aRow.getAsString(1)), aRow.getAsString(2)));
    return ret;
}
Also used : DBResultRow(com.helger.db.jdbc.executor.DBResultRow) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) Nonnull(javax.annotation.Nonnull)

Aggregations

SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)48 Test (org.junit.Test)26 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)25 ServiceGroupType (com.helger.xsds.peppol.smp1.ServiceGroupType)12 ServiceMetadataReferenceCollectionType (com.helger.xsds.peppol.smp1.ServiceMetadataReferenceCollectionType)12 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)11 Nonnull (javax.annotation.Nonnull)11 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)10 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)9 Response (javax.ws.rs.core.Response)9 SimpleDocumentTypeIdentifier (com.helger.peppolid.simple.doctype.SimpleDocumentTypeIdentifier)8 EndpointType (com.helger.xsds.peppol.smp1.EndpointType)7 ProcessListType (com.helger.xsds.peppol.smp1.ProcessListType)7 ProcessType (com.helger.xsds.peppol.smp1.ProcessType)7 ServiceEndpointList (com.helger.xsds.peppol.smp1.ServiceEndpointList)7 ServiceInformationType (com.helger.xsds.peppol.smp1.ServiceInformationType)7 WebTarget (javax.ws.rs.client.WebTarget)7 SMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup)6 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)5 PeppolDocumentTypeIdentifier (com.helger.peppolid.peppol.doctype.PeppolDocumentTypeIdentifier)5