use of com.helger.peppol.sml.ISMLInfo in project phoss-smp by phax.
the class PageSecureSMLRegistration method _deleteSMPfromSML.
private void _deleteSMPfromSML(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final FormErrorList aFormErrors) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final String sSMLID = aWPEC.params().getAsString(FIELD_SML_ID);
final ISMLInfo aSMLInfo = SMPMetaManager.getSMLInfoMgr().getSMLInfoOfID(sSMLID);
if (aSMLInfo == null)
aFormErrors.addFieldError(FIELD_SML_ID, "A valid SML must be selected!");
if (aFormErrors.isEmpty()) {
final String sSMPID = SMPServerConfiguration.getSMLSMPID();
try {
final SSLSocketFactory aSocketFactory = SMPKeyManager.getInstance().createSSLContext().getSocketFactory();
final ManageServiceMetadataServiceCaller aCaller = _create(aSMLInfo, aSocketFactory);
aCaller.delete(sSMPID);
final String sMsg = "Successfully deleted SMP '" + sSMPID + "' from the SML '" + aSMLInfo.getManagementServiceURL() + "'.";
LOGGER.info(sMsg);
aNodeList.addChild(success(sMsg));
AuditHelper.onAuditExecuteSuccess("smp-sml-delete", sSMPID, aSMLInfo.getManagementServiceURL());
} catch (final Exception ex) {
final String sMsg = "Error deleting SMP '" + sSMPID + "' from the SML '" + aSMLInfo.getManagementServiceURL() + "'.";
aNodeList.addChild(error(sMsg).addChild(SMPCommonUI.getTechnicalDetailsUI(ex)));
AuditHelper.onAuditExecuteFailure("smp-sml-delete", sSMPID, aSMLInfo.getManagementServiceURL(), ex.getClass(), ex.getMessage());
}
} else
aNodeList.addChild(BootstrapWebPageUIHandler.INSTANCE.createIncorrectInputBox(aWPEC));
}
use of com.helger.peppol.sml.ISMLInfo in project phoss-smp by phax.
the class PageSecureTasksProblems method _checkSMLConfiguration.
private void _checkSMLConfiguration(@Nonnull final HCOL aOL) {
final ISMPSettings aSMPSettings = SMPMetaManager.getSettings();
final String sSMPID = SMPServerConfiguration.getSMLSMPID();
if (aSMPSettings.isSMLEnabled()) {
final ISMLInfo aSMLInfo = aSMPSettings.getSMLInfo();
if (aSMLInfo == null) {
aOL.addItem(_createError("No SML is selected in the SMP settings."), div("All creations and deletions of service groups needs to be repeated when the SML connection is active!"));
} else {
// Check if this SMP is already registered
final String sPublisherDNSName = sSMPID + "." + aSMLInfo.getPublisherDNSZone();
try {
InetAddress.getByName(sPublisherDNSName);
// On success, ignore
} catch (final UnknownHostException ex) {
// continue
aOL.addItem(_createWarning("It seems like this SMP was not yet registered to the SML."), div("This is a one-time action that should be performed once. It requires a valid SMP certificate to work."), div("The registration check was performed with the URL ").addChild(new HCA().setHref(new SimpleURL("http://" + sPublisherDNSName)).setTargetBlank().addChild(code(sPublisherDNSName))));
}
}
} else {
if (aSMPSettings.isSMLRequired())
aOL.addItem(_createError("The connection to the SML is not enabled."), div("All creations and deletions of service groups needs to be repeated when the SML connection is active!"));
}
}
use of com.helger.peppol.sml.ISMLInfo in project phoss-smp by phax.
the class RegistrationHookWriteToSML method _createSMLCaller.
@Nonnull
private static ManageParticipantIdentifierServiceCaller _createSMLCaller() {
// SML endpoint (incl. the service name)
final ISMLInfo aSMLInfo = SMPMetaManager.getSettings().getSMLInfo();
if (aSMLInfo == null)
throw new IllegalStateException("Failed to get SML manage participant endpoint URL");
final URL aSMLEndpointURL = aSMLInfo.getManageParticipantIdentifierEndpointAddress();
final String sEndpointURL = aSMLEndpointURL.toExternalForm();
final String sLowerURL = sEndpointURL.toLowerCase(Locale.US);
if (LOGGER.isInfoEnabled())
LOGGER.info("Performing SML query to '" + sEndpointURL + "'");
// SSL socket factory
final SSLSocketFactory aSocketFactory;
if (sLowerURL.startsWith("https://")) {
// https connection
if (!SMPKeyManager.isKeyStoreValid())
throw new InitializationException("Cannot init registration hook to SML, because private key/certificate setup has errors: " + SMPKeyManager.getInitializationError());
try {
aSocketFactory = SMPKeyManager.getInstance().createSSLContext().getSocketFactory();
} catch (final Exception ex) {
throw new IllegalStateException("Failed to init SSLContext for SML access", ex);
}
} else {
// Local, http only access - no socket factory
aSocketFactory = null;
}
// Hostname verifier
final HostnameVerifier aHostnameVerifier;
if (sLowerURL.contains("//localhost") || sLowerURL.contains("//127.0.0.1")) {
// Accept all hostnames
aHostnameVerifier = new HostnameVerifierVerifyAll(false);
} else
aHostnameVerifier = null;
// Build WS client
final ManageParticipantIdentifierServiceCaller ret = new ManageParticipantIdentifierServiceCaller(aSMLEndpointURL);
ret.setSSLSocketFactory(aSocketFactory);
ret.setHostnameVerifier(aHostnameVerifier);
final Integer aConnectionTimeoutMS = SMPServerConfiguration.getSMLConnectionTimeoutMS();
if (aConnectionTimeoutMS != null)
ret.setConnectionTimeoutMS(aConnectionTimeoutMS.intValue());
final int nRequestTimeoutMS = SMPServerConfiguration.getSMLRequestTimeoutMS();
if (nRequestTimeoutMS >= 0)
ret.setRequestTimeoutMS(nRequestTimeoutMS);
return ret;
}
use of com.helger.peppol.sml.ISMLInfo in project phoss-smp by phax.
the class SMPSettings method initFromSettings.
@Nonnull
EChange initFromSettings(@Nonnull final ISettings aSettings) {
ValueEnforcer.notNull(aSettings, "settings");
final EChange ret = m_aSettings.setAll(aSettings);
// Soft migration 5.0.7
if (!m_aSettings.containsKey(KEY_SML_INFO_ID)) {
// Get old String (includes "/manageparticipantidentifier")
final String sOldSMLURL = m_aSettings.getAsString("sml.url");
if (StringHelper.hasText(sOldSMLURL)) {
// Check if any SML item matches
final ISMLInfo aSMLInfo = SMPMetaManager.getSMLInfoMgr().findFirstWithManageParticipantIdentifierEndpointAddress(sOldSMLURL);
if (aSMLInfo != null)
m_aSettings.put(KEY_SML_INFO_ID, aSMLInfo.getID());
}
}
return ret;
}
use of com.helger.peppol.sml.ISMLInfo in project phoss-directory by phax.
the class PageSecureIndexManually method fillContent.
@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
final FormErrorList aFormErrors = new FormErrorList();
{
final IPDBusinessCardProvider aBCProv = PDMetaManager.getBusinessCardProvider();
if (aBCProv instanceof SMPBusinessCardProvider) {
final SMPBusinessCardProvider aSMPBCProv = (SMPBusinessCardProvider) aBCProv;
if (aSMPBCProv.isFixedSMP()) {
aNodeList.addChild(info("Fixed SMP URI " + aSMPBCProv.getFixedSMPURI() + " is used."));
} else {
aNodeList.addChild(info("The following SMLs are crawled for entries: " + StringHelper.getImplodedMapped(", ", aSMPBCProv.getAllSMLsToUse(), ISMLInfo::getDisplayName)));
}
}
}
if (aWPEC.hasAction(CPageParam.ACTION_PERFORM)) {
final String sParticipantID = aWPEC.params().getAsString(FIELD_PARTICIPANT_ID);
final IParticipantIdentifier aParticipantID = aIdentifierFactory.parseParticipantIdentifier(sParticipantID);
if (StringHelper.hasNoText(sParticipantID))
aFormErrors.addFieldError(FIELD_PARTICIPANT_ID, "A participant ID must be provided.");
else if (aParticipantID == null)
aFormErrors.addFieldError(FIELD_PARTICIPANT_ID, "The provided participant ID is syntactically invalid.");
if (aFormErrors.isEmpty()) {
if (PDMetaManager.getIndexerMgr().queueWorkItem(aParticipantID, EIndexerWorkItemType.CREATE_UPDATE, "manually-triggered", PDIndexerManager.HOST_LOCALHOST).isChanged()) {
aWPEC.postRedirectGetInternal(success("The indexing of participant ID '" + sParticipantID + "' was successfully triggered!"));
} else {
aWPEC.postRedirectGetInternal(warn("Participant ID '" + sParticipantID + "' is already in the indexing queue!"));
}
}
}
final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormSelf(aWPEC));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Participant ID").setCtrl(new HCEdit(new RequestField(FIELD_PARTICIPANT_ID, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME + CIdentifier.URL_SCHEME_VALUE_SEPARATOR))).setHelpText(span().addChild("Enter the fully qualified Peppol participant ID (including the scheme) you want to index.\nExample identifier layout: ").addChild(code(aIdentifierFactory.createParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "9999:test").getURIEncoded()))).setErrorList(aFormErrors.getListOfField(FIELD_PARTICIPANT_ID)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
aToolbar.addSubmitButton("Add to queue", EDefaultIcon.YES);
}
Aggregations