use of com.helger.peppol.ui.select.SMLConfigurationSelect in project peppol-practical by phax.
the class PagePublicToolsParticipantInformation method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMLConfigurationManager aSMLConfigurationMgr = PPMetaManager.getSMLConfigurationMgr();
final FormErrorList aFormErrors = new FormErrorList();
final boolean bShowInput = true;
String sParticipantIDScheme = DEFAULT_ID_SCHEME;
String sParticipantIDValue = null;
if (aWPEC.hasAction(CPageParam.ACTION_PERFORM)) {
// Validate fields
sParticipantIDScheme = StringHelper.trim(aWPEC.params().getAsString(FIELD_ID_SCHEME));
sParticipantIDValue = StringHelper.trim(aWPEC.params().getAsString(FIELD_ID_VALUE));
final String sSMLID = StringHelper.trim(aWPEC.params().getAsString(FIELD_SML));
final ISMLConfiguration aSMLConfiguration = aSMLConfigurationMgr.getSMLInfoOfID(sSMLID);
final boolean bSMLAutoDetect = ISMLConfigurationManager.ID_AUTO_DETECT.equals(sSMLID);
final boolean bQueryBusinessCard = aWPEC.params().isCheckBoxChecked(PARAM_QUERY_BUSINESS_CARD, DEFAULT_QUERY_BUSINESS_CARD);
final boolean bShowTime = aWPEC.params().isCheckBoxChecked(PARAM_SHOW_TIME, DEFAULT_SHOW_TIME);
final boolean bXSDValidation = aWPEC.params().isCheckBoxChecked(PARAM_XSD_VALIDATION, DEFAULT_XSD_VALIDATION);
final boolean bVerifySignatures = aWPEC.params().isCheckBoxChecked(PARAM_VERIFY_SIGNATURES, DEFAULT_VERIFY_SIGNATURES);
final IIdentifierFactory aIF = aSMLConfiguration != null ? aSMLConfiguration.getSMPIdentifierType().getIdentifierFactory() : SimpleIdentifierFactory.INSTANCE;
// Legacy URL params?
if (aWPEC.params().containsKey("idscheme") && aWPEC.params().containsKey("idvalue")) {
sParticipantIDScheme = DEFAULT_ID_SCHEME;
sParticipantIDValue = StringHelper.trim(aWPEC.params().getAsString("idscheme")) + ":" + StringHelper.trim(aWPEC.params().getAsString("idvalue"));
}
if (StringHelper.hasNoText(sParticipantIDScheme))
aFormErrors.addFieldError(FIELD_ID_SCHEME, "Please provide an identifier scheme");
else if (!aIF.isParticipantIdentifierSchemeValid(sParticipantIDScheme))
aFormErrors.addFieldError(FIELD_ID_SCHEME, "The participant identifier scheme '" + sParticipantIDScheme + "' is not valid!");
if (StringHelper.hasNoText(sParticipantIDValue))
aFormErrors.addFieldError(FIELD_ID_VALUE, "Please provide an identifier value");
else if (!aIF.isParticipantIdentifierValueValid(sParticipantIDValue))
aFormErrors.addFieldError(FIELD_ID_VALUE, "The participant identifier value '" + sParticipantIDValue + "' is not valid!");
if (aSMLConfiguration == null && !bSMLAutoDetect)
aFormErrors.addFieldError(FIELD_SML, "A valid SML must be selected!");
if (aFormErrors.isEmpty()) {
_queryParticipant(aWPEC, sParticipantIDScheme, sParticipantIDValue, aSMLConfiguration, bSMLAutoDetect, bQueryBusinessCard, bShowTime, bXSDValidation, bVerifySignatures);
}
}
if (bShowInput) {
final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormSelf(aWPEC).setMethod(EHCFormMethod.GET).setLeft(3));
aForm.addChild(info().addChildren(div("Show all processes, document types and endpoints of a participant."), div("You may want to try scheme ").addChild(code(DEFAULT_ID_SCHEME)).addChild(" and value ").addChild(code("9915:test")).addChild(" on ").addChild(code("SMK")).addChild(" as an example.")));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Identifier scheme").setCtrl(new HCEdit(new RequestField(FIELD_ID_SCHEME, sParticipantIDScheme)).setPlaceholder("Identifier scheme")).setHelpText(div("The most common identifier scheme is ").addChild(code(DEFAULT_ID_SCHEME))).setErrorList(aFormErrors.getListOfField(FIELD_ID_SCHEME)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Identifier value").setCtrl(new HCEdit(new RequestField(FIELD_ID_VALUE, sParticipantIDValue)).setPlaceholder("Identifier value")).setHelpText(div("The identifier value must look like ").addChild(code("9915:test"))).setErrorList(aFormErrors.getListOfField(FIELD_ID_VALUE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SML to use").setCtrl(new SMLConfigurationSelect(new RequestField(FIELD_SML, ISMLConfigurationManager.ID_AUTO_DETECT), true)).setErrorList(aFormErrors.getListOfField(FIELD_SML)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Query Business Card?").setCtrl(new HCCheckBox(new RequestFieldBoolean(PARAM_QUERY_BUSINESS_CARD, DEFAULT_QUERY_BUSINESS_CARD))).setErrorList(aFormErrors.getListOfField(PARAM_QUERY_BUSINESS_CARD)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Show query duration?").setCtrl(new HCCheckBox(new RequestFieldBoolean(PARAM_SHOW_TIME, DEFAULT_SHOW_TIME))).setErrorList(aFormErrors.getListOfField(PARAM_SHOW_TIME)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Enable XML Schema validation of responses?").setCtrl(new HCCheckBox(new RequestFieldBoolean(PARAM_XSD_VALIDATION, DEFAULT_XSD_VALIDATION))).setErrorList(aFormErrors.getListOfField(PARAM_XSD_VALIDATION)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Verify signatures of SMP responses?").setCtrl(new HCCheckBox(new RequestFieldBoolean(PARAM_VERIFY_SIGNATURES, DEFAULT_VERIFY_SIGNATURES))).setErrorList(aFormErrors.getListOfField(PARAM_VERIFY_SIGNATURES)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
aToolbar.addSubmitButton("Show details");
}
}
use of com.helger.peppol.ui.select.SMLConfigurationSelect in project peppol-practical by phax.
the class PagePublicToolsSMPSML method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final FormErrorList aFormErrors = new FormErrorList();
final boolean bShowInput = true;
aNodeList.addChild(warn("Note: as of ").addChild(new HCA(new SimpleURL("https://github.com/phax/phoss-smp")).addChild("phoss SMP server 5.0.0 beta 1")).addChild(" this registration feature is contained directly in the SMP software! So you don't need to send your certificates over the Internet anymore!"));
if (aWPEC.hasAction(CPageParam.ACTION_PERFORM)) {
if (aWPEC.hasSubAction(SUBACTION_SMP_REGISTER))
_registerSMPtoSML(aWPEC, aFormErrors);
else if (aWPEC.hasSubAction(SUBACTION_SMP_UPDATE))
_updateSMPatSML(aWPEC, aFormErrors);
else if (aWPEC.hasSubAction(SUBACTION_SMP_DELETE))
_deleteSMPfromSML(aWPEC, aFormErrors);
else if (aWPEC.hasSubAction(SUBACTION_SMP_UPDATE_CERT))
_updateSMPCertAtSML(aWPEC, aFormErrors);
}
if (bShowInput) {
final int nLeft = 3;
final BootstrapTabBox aTabBox = new BootstrapTabBox();
// Register SMP at SML
{
final BootstrapForm aForm = getUIHandler().createFormSelf(aWPEC);
aForm.setEncTypeFileUpload().setLeft(nLeft);
aForm.addChild(info("Register a new SMP to the SML. This must only be done once per SMP!"));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SML").setCtrl(new SMLConfigurationSelect(new RequestField(FIELD_SML_ID), false)).setErrorList(aFormErrors.getListOfField(FIELD_SML_ID)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SMP ID").setCtrl(new HCEdit(new RequestField(FIELD_SMP_ID)).setPlaceholder("Your SMP ID")).setHelpText(HELPTEXT_SMP_ID).setErrorList(aFormErrors.getListOfField(FIELD_SMP_ID)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Physical address").setCtrl(new HCEdit(new RequestField(FIELD_PHYSICAL_ADDRESS)).setPlaceholder("The IPv4 address of your SMP. E.g. 1.2.3.4")).setHelpText(HELPTEXT_PHYSICAL_ADDRESS).setErrorList(aFormErrors.getListOfField(FIELD_PHYSICAL_ADDRESS)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Logical address").setCtrl(new HCEdit(new RequestField(FIELD_LOGICAL_ADDRESS)).setPlaceholder("The domain name of your SMP server. E.g. http://smp.example.org")).setHelpText(HELPTEXT_LOGICAL_ADDRESS).setErrorList(aFormErrors.getListOfField(FIELD_LOGICAL_ADDRESS)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SMP key store").setCtrl(new BootstrapFileUpload(FIELD_KEYSTORE, aDisplayLocale)).setHelpText(HELPTEXT_KEYSTORE).setErrorList(aFormErrors.getListOfField(FIELD_KEYSTORE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("SMP key store password").setCtrl(new HCEditPassword(FIELD_KEYSTORE_PW).setPlaceholder("The password for the SMP keystore. May be empty.")).setHelpText(HELPTEXT_KEYSTORE_PW).setErrorList(aFormErrors.getListOfField(FIELD_KEYSTORE_PW)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
aToolbar.addHiddenField(CPageParam.PARAM_SUBACTION, SUBACTION_SMP_REGISTER);
aToolbar.addSubmitButton("Register SMP at SML");
aTabBox.addTab("register", "Register SMP to SML", aForm, aWPEC.hasSubAction(SUBACTION_SMP_REGISTER));
}
// Update SMP at SML
{
final BootstrapForm aForm = getUIHandler().createFormSelf(aWPEC);
aForm.setEncTypeFileUpload().setLeft(nLeft);
aForm.addChild(info("Update an existing SMP at the SML. This must only be done when either the IP address or the host name of the SMP changed!"));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SML").setCtrl(new SMLConfigurationSelect(new RequestField(FIELD_SML_ID), false)).setErrorList(aFormErrors.getListOfField(FIELD_SML_ID)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SMP ID").setCtrl(new HCEdit(new RequestField(FIELD_SMP_ID)).setPlaceholder("Your SMP ID")).setHelpText(HELPTEXT_SMP_ID).setErrorList(aFormErrors.getListOfField(FIELD_SMP_ID)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Physical address").setCtrl(new HCEdit(new RequestField(FIELD_PHYSICAL_ADDRESS)).setPlaceholder("The IPv4 address of your SMP. E.g. 1.2.3.4")).setHelpText(HELPTEXT_PHYSICAL_ADDRESS).setErrorList(aFormErrors.getListOfField(FIELD_PHYSICAL_ADDRESS)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Logical address").setCtrl(new HCEdit(new RequestField(FIELD_LOGICAL_ADDRESS)).setPlaceholder("The domain name of your SMP server. E.g. http://smp.example.org")).setHelpText(HELPTEXT_LOGICAL_ADDRESS).setErrorList(aFormErrors.getListOfField(FIELD_LOGICAL_ADDRESS)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SMP key store").setCtrl(new BootstrapFileUpload(FIELD_KEYSTORE, aDisplayLocale)).setHelpText(HELPTEXT_KEYSTORE).setErrorList(aFormErrors.getListOfField(FIELD_KEYSTORE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("SMP key store password").setCtrl(new HCEditPassword(FIELD_KEYSTORE_PW).setPlaceholder("The password for the SMP keystore. May be empty.")).setHelpText(HELPTEXT_KEYSTORE_PW).setErrorList(aFormErrors.getListOfField(FIELD_KEYSTORE_PW)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
aToolbar.addHiddenField(CPageParam.PARAM_SUBACTION, SUBACTION_SMP_UPDATE);
aToolbar.addSubmitButton("Update SMP at SML");
aTabBox.addTab("update", "Update SMP at SML", aForm, aWPEC.hasSubAction(SUBACTION_SMP_UPDATE));
}
// Delete SMP from SML
{
final BootstrapForm aForm = getUIHandler().createFormFileUploadSelf(aWPEC);
aForm.setLeft(nLeft);
aForm.addChild(info("Delete an existing SMP from the SML."));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SML").setCtrl(new SMLConfigurationSelect(new RequestField(FIELD_SML_ID), false)).setErrorList(aFormErrors.getListOfField(FIELD_SML_ID)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SMP ID").setCtrl(new HCEdit(new RequestField(FIELD_SMP_ID)).setPlaceholder("Your SMP ID")).setHelpText(HELPTEXT_SMP_ID).setErrorList(aFormErrors.getListOfField(FIELD_SMP_ID)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SMP key store").setCtrl(new BootstrapFileUpload(FIELD_KEYSTORE, aDisplayLocale)).setHelpText(HELPTEXT_KEYSTORE).setErrorList(aFormErrors.getListOfField(FIELD_KEYSTORE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("SMP key store password").setCtrl(new HCEditPassword(FIELD_KEYSTORE_PW).setPlaceholder("The password for the SMP keystore. May be empty.")).setHelpText(HELPTEXT_KEYSTORE_PW).setErrorList(aFormErrors.getListOfField(FIELD_KEYSTORE_PW)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
aToolbar.addHiddenField(CPageParam.PARAM_SUBACTION, SUBACTION_SMP_DELETE);
aToolbar.addSubmitButton("Delete SMP from SML");
aTabBox.addTab("delete", "Delete SMP from SML", aForm, aWPEC.hasSubAction(SUBACTION_SMP_DELETE));
}
// Update SMP certificate in SML
{
final BootstrapForm aForm = getUIHandler().createFormFileUploadSelf(aWPEC);
aForm.setLeft(nLeft);
aForm.addChild(info().addChildren(div("Prepare the update of your Peppol SMP certificate in the future."), div("This works only if your SMP certificate is NOT expired yet." + " If your SMP certificate is already expired contact CEF-EDELIVERY-SUPPORT@ec.europa.eu with your SMP ID, the new certificate and the requested exchange date!"), div("Note: this is a custom extension that only works with the CEF SML instances!")));
aForm.addChild(warn("It is your responsibility to update the Peppol certificate in your SMP at the specified time!"));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SML").setCtrl(new SMLConfigurationSelect(new RequestField(FIELD_SML_ID), false)).setErrorList(aFormErrors.getListOfField(FIELD_SML_ID)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Existing/old SMP key store").setCtrl(new BootstrapFileUpload(FIELD_KEYSTORE, aDisplayLocale)).setHelpText(HELPTEXT_KEYSTORE).setErrorList(aFormErrors.getListOfField(FIELD_KEYSTORE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Existing/old SMP key store password").setCtrl(new HCEditPassword(FIELD_KEYSTORE_PW).setPlaceholder("The password for the existing SMP keystore. May be empty.")).setHelpText(HELPTEXT_KEYSTORE_PW).setErrorList(aFormErrors.getListOfField(FIELD_KEYSTORE_PW)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Certificate migration date").setCtrl(BootstrapDateTimePicker.create(FIELD_PM_MIGRATION_DATE, aDisplayLocale, EBootstrap4DateTimePickerMode.DATE).setMinDate(PDTFactory.getCurrentLocalDate().plusDays(1))).setHelpText("The SML will replace the certificate at this date." + " It must be in the future and within the validity period of the provided new public certificate." + " If not provided, the 'valid from' part of the certificate is used.").setErrorList(aFormErrors.getListOfField(FIELD_PM_MIGRATION_DATE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("New public certificate").setCtrl(new HCTextAreaAutosize(new RequestField(FIELD_PM_PUBLIC_CERT)).setRows(5)).setHelpText(span("Paste the public part of your new certificate here (using PEM encoding)." + " Do NOT paste your new private key here." + " Must start with ").addChild(code(CertificateHelper.BEGIN_CERTIFICATE)).addChild(" and end with ").addChild(code(CertificateHelper.END_CERTIFICATE))).setErrorList(aFormErrors.getListOfField(FIELD_PM_PUBLIC_CERT)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
aToolbar.addHiddenField(CPageParam.PARAM_SUBACTION, SUBACTION_SMP_UPDATE_CERT);
aToolbar.addSubmitButton("Prepare certificate update");
aTabBox.addTab("updatecert", "Update SMP certificate at SML", aForm, aWPEC.hasSubAction(SUBACTION_SMP_UPDATE_CERT));
}
aNodeList.addChild(aTabBox);
}
}
use of com.helger.peppol.ui.select.SMLConfigurationSelect in project peppol-practical by phax.
the class PagePublicToolsTestEndpoints method showInputForm.
@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final TestEndpoint aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final BootstrapForm aRealForm = aForm;
aRealForm.setLeft(3);
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Company name").setCtrl(new HCEdit(new RequestField(FIELD_COMPANY_NAME, aSelectedObject == null ? null : aSelectedObject.getCompanyName()))).setHelpText("The name of the company operating the test AccessPoint").setErrorList(aFormErrors.getListOfField(FIELD_COMPANY_NAME)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabel("Contact person").setCtrl(new HCEdit(new RequestField(FIELD_CONTACT_PERSON, aSelectedObject == null ? null : aSelectedObject.getContactPerson()))).setHelpText("The contact person being in charge of the test endpoint. This field is free text and may contain an optional email address.").setErrorList(aFormErrors.getListOfField(FIELD_CONTACT_PERSON)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Identifier issuing agency").setCtrl(new ParticipantIdentifierSchemeSelect(new RequestField(FIELD_PARTICIPANT_ID_ISSUER, aSelectedObject == null ? null : aSelectedObject.getParticipantIDIssuer()), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_PARTICIPANT_ID_ISSUER)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Identifier value").setCtrl(new HCEdit(new RequestField(FIELD_PARTICIPANT_ID_VALUE, aSelectedObject == null ? null : aSelectedObject.getParticipantIDValue()))).setErrorList(aFormErrors.getListOfField(FIELD_PARTICIPANT_ID_VALUE)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Transport profile").setCtrl(new SMPTransportProfileSelect(new RequestField(FIELD_TRANSPORT_PROFILE, aSelectedObject == null ? null : aSelectedObject.getTransportProfile().getID()), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_TRANSPORT_PROFILE)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SML").setCtrl(new SMLConfigurationSelect(new RequestField(FIELD_SML, aSelectedObject == null ? null : aSelectedObject.getSML().getID()), false)).setErrorList(aFormErrors.getListOfField(FIELD_SML)));
}
Aggregations