use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.
the class SMPRedirectTest method testCaseSensitivity.
@Test
public void testCaseSensitivity() {
final IParticipantIdentifier aPI = new SimpleParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:UpperCase");
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());
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phase4 by phax.
the class MainPhase4CEFSenderToop method main.
public static void main(final String[] args) {
WebScopeManager.onGlobalBegin(MockServletContext.create());
// Dump (for debugging purpose only)
AS4DumpManager.setIncomingDumper(new AS4IncomingDumperFileBased());
AS4DumpManager.setOutgoingDumper(new AS4OutgoingDumperFileBased());
try (final WebScoped w = new WebScoped()) {
final byte[] aPayloadBytes = SimpleFileIO.getAllFileBytes(new File("src/test/resources/examples/base-example.xml"));
if (aPayloadBytes == null)
throw new IllegalStateException();
// Start configuring here
final IParticipantIdentifier aReceiverID = Phase4CEFSender.IF.createParticipantIdentifier("iso6523-actorid-upis", "9915:tooptest");
final IAS4ClientBuildMessageCallback aBuildMessageCallback = new IAS4ClientBuildMessageCallback() {
public void onAS4Message(final AbstractAS4Message<?> aMsg) {
final AS4UserMessage aUserMsg = (AS4UserMessage) aMsg;
LOGGER.info("Sending out AS4 message with message ID '" + aUserMsg.getEbms3UserMessage().getMessageInfo().getMessageId() + "'");
LOGGER.info("Sending out AS4 message with conversation ID '" + aUserMsg.getEbms3UserMessage().getCollaborationInfo().getConversationId() + "'");
}
};
if (Phase4CEFSender.builder().documentTypeID(Phase4CEFSender.IF.createDocumentTypeIdentifier("toop-doctypeid-qns", "urn:eu:toop:ns:dataexchange-1p40::Response##urn:eu.toop.response.registeredorganization::1.40")).processID(Phase4CEFSender.IF.createProcessIdentifier("toop-procid-agreement", "urn:eu.toop.process.datarequestresponse")).senderParticipantID(Phase4CEFSender.IF.createParticipantIdentifier("iso6523-actorid-upis", "9914:phase4-test-sender")).receiverParticipantID(aReceiverID).fromPartyID(new SimpleParticipantIdentifier("type", "POP000306")).fromRole("http://www.toop.eu/edelivery/gateway").toPartyID(new SimpleParticipantIdentifier("type", "POP000306")).toRole("http://www.toop.eu/edelivery/gateway").payload(Phase4OutgoingAttachment.builder().data(aPayloadBytes).mimeTypeXML()).smpClient(new BDXRClientReadOnly(Phase4CEFSender.URL_PROVIDER, aReceiverID, SML_TOOP)).rawResponseConsumer(new AS4RawResponseConsumerWriteToFile()).buildMessageCallback(aBuildMessageCallback).sendMessage().isSuccess()) {
LOGGER.info("Successfully sent CEF message via AS4");
} else {
LOGGER.error("Failed to send CEF message via AS4");
}
} catch (final Exception ex) {
LOGGER.error("Error sending CEF message via AS4", ex);
} finally {
WebScopeManager.onGlobalEnd();
}
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-directory by phax.
the class PDStorageManager method deleteEntry.
@CheckForSigned
public int deleteEntry(@Nonnull final IParticipantIdentifier aParticipantID, @Nullable final PDStoredMetaData aMetaData, final boolean bVerifyOwner) throws IOException {
ValueEnforcer.notNull(aParticipantID, "ParticipantID");
LOGGER.info("Trying to delete entry with participant ID '" + aParticipantID.getURIEncoded() + "'" + (bVerifyOwner && aMetaData != null ? " with owner ID '" + aMetaData.getOwnerID() + "'" : ""));
Query aParticipantQuery = new TermQuery(PDField.PARTICIPANT_ID.getExactMatchTerm(aParticipantID));
if (getCount(aParticipantQuery) == 0) {
// Hack e.g. for 9925:everbinding
final String sOrigValue = aParticipantID.getValue();
final String sUpperCaseValue = sOrigValue.toUpperCase(Locale.ROOT);
if (!sUpperCaseValue.equals(sOrigValue)) {
// Something changed - try again
// Force case sensitivity
final IParticipantIdentifier aNewPID = new SimpleParticipantIdentifier(aParticipantID.getScheme(), sUpperCaseValue);
final Query aOtherQuery = new TermQuery(PDField.PARTICIPANT_ID.getExactMatchTerm(aNewPID));
if (getCount(aOtherQuery) > 0) {
LOGGER.info("Found something with '" + sUpperCaseValue + "' instead of '" + sOrigValue + "'");
aParticipantQuery = aOtherQuery;
}
}
}
final Query aDeleteQuery;
if (bVerifyOwner && aMetaData != null) {
// Special handling for predefined owners
final BooleanQuery.Builder aBuilderOr = new BooleanQuery.Builder();
aBuilderOr.add(new TermQuery(PDField.METADATA_OWNERID.getExactMatchTerm(aMetaData.getOwnerID())), Occur.SHOULD);
aBuilderOr.add(new TermQuery(PDField.METADATA_OWNERID.getExactMatchTerm(CPDStorage.OWNER_DUPLICATE_ELIMINATION)), Occur.SHOULD);
aBuilderOr.add(new TermQuery(PDField.METADATA_OWNERID.getExactMatchTerm(CPDStorage.OWNER_IMPORT_TRIGGERED)), Occur.SHOULD);
aBuilderOr.add(new TermQuery(PDField.METADATA_OWNERID.getExactMatchTerm(CPDStorage.OWNER_MANUALLY_TRIGGERED)), Occur.SHOULD);
aBuilderOr.add(new TermQuery(PDField.METADATA_OWNERID.getExactMatchTerm(CPDStorage.OWNER_SYNC_JOB)), Occur.SHOULD);
aDeleteQuery = new BooleanQuery.Builder().add(aParticipantQuery, Occur.MUST).add(aBuilderOr.build(), Occur.MUST).build();
} else
aDeleteQuery = aParticipantQuery;
final int nCount = getCount(aDeleteQuery);
if (m_aLucene.writeLockedAtomic(() -> {
// Delete
m_aLucene.deleteDocuments(aDeleteQuery);
}).isFailure()) {
LOGGER.error("Failed to delete docs from the index using the query '" + aDeleteQuery + "'");
return -1;
}
LOGGER.info("Deleted " + nCount + " docs from the index using the query '" + aDeleteQuery + "'");
AuditHelper.onAuditExecuteSuccess("pd-indexer-delete", aParticipantID.getURIEncoded(), Integer.valueOf(nCount), aMetaData, Boolean.toString(bVerifyOwner));
return nCount;
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-directory by phax.
the class PDStorageManager method getAllDocumentsOfParticipant.
@Nonnull
public ICommonsList<PDStoredBusinessEntity> getAllDocumentsOfParticipant(@Nonnull final IParticipantIdentifier aParticipantID) {
ValueEnforcer.notNull(aParticipantID, "ParticipantID");
ICommonsList<PDStoredBusinessEntity> ret = getAllDocuments(new TermQuery(PDField.PARTICIPANT_ID.getExactMatchTerm(aParticipantID)), -1);
if (ret.isEmpty()) {
// Hack e.g. for 9925:everbinding
final String sOrigValue = aParticipantID.getValue();
final String sUpperCaseValue = sOrigValue.toUpperCase(Locale.ROOT);
if (!sUpperCaseValue.equals(sOrigValue)) {
// Something changed - try again
// Force case sensitivity
final IParticipantIdentifier aNewPID = new SimpleParticipantIdentifier(aParticipantID.getScheme(), sUpperCaseValue);
ret = getAllDocuments(new TermQuery(PDField.PARTICIPANT_ID.getExactMatchTerm(aNewPID)), -1);
if (ret.isNotEmpty()) {
LOGGER.info("Found something with '" + sUpperCaseValue + "' instead of '" + sOrigValue + "'");
}
}
}
return ret;
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project peppol-commons by phax.
the class MainSMPServiceRegistrationCreate 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();
final IDocumentTypeIdentifier DOCUMENT_ID = MockSMPClientConfig.getDocumentTypeID();
final IProcessIdentifier PROCESS_ID = MockSMPClientConfig.getProcessTypeID();
final W3CEndpointReference START_AP_ENDPOINTREF = MockSMPClientConfig.getAPEndpointRef();
final String AP_CERT_STRING = MockSMPClientConfig.getAPCert();
final String AP_SERVICE_DESCRIPTION = MockSMPClientConfig.getAPServiceDescription();
final String AP_CONTACT_URL = MockSMPClientConfig.getAPContact();
final String AP_INFO_URL = MockSMPClientConfig.getAPInfo();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Create the service registration
final ServiceInformationType aServiceInformation = new ServiceInformationType();
{
final ProcessListType aProcessList = new ProcessListType();
{
final ProcessType aProcess = new ProcessType();
{
final ServiceEndpointList aServiceEndpointList = new ServiceEndpointList();
{
final EndpointType aEndpoint = new EndpointType();
aEndpoint.setEndpointReference(START_AP_ENDPOINTREF);
aEndpoint.setTransportProfile(ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID());
aEndpoint.setCertificate(AP_CERT_STRING);
aEndpoint.setServiceActivationDate(PDTFactory.createXMLOffsetDateTime(2011, Month.JANUARY, 1));
aEndpoint.setServiceExpirationDate(PDTFactory.createXMLOffsetDateTime(2020, Month.DECEMBER, 31));
aEndpoint.setServiceDescription(AP_SERVICE_DESCRIPTION);
aEndpoint.setTechnicalContactUrl(AP_CONTACT_URL);
aEndpoint.setTechnicalInformationUrl(AP_INFO_URL);
aEndpoint.setMinimumAuthenticationLevel("1");
aEndpoint.setRequireBusinessLevelSignature(false);
aServiceEndpointList.getEndpoint().add(aEndpoint);
}
aProcess.setProcessIdentifier(new SimpleProcessIdentifier(PROCESS_ID));
aProcess.setServiceEndpointList(aServiceEndpointList);
}
aProcessList.getProcess().add(aProcess);
}
aServiceInformation.setDocumentIdentifier(new SimpleDocumentTypeIdentifier(DOCUMENT_ID));
aServiceInformation.setParticipantIdentifier(new SimpleParticipantIdentifier(PARTICIPANT_ID));
aServiceInformation.setProcessList(aProcessList);
}
aClient.saveServiceInformation(aServiceInformation, SMP_CREDENTIALS);
LOGGER.info("Done");
}
Aggregations