Search in sources :

Example 1 with HCTextArea

use of com.helger.html.hc.html.forms.HCTextArea in project phoss-smp by phax.

the class AbstractPageSecureEndpoint method showInputForm.

@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPServiceInformation aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
    final boolean bEdit = eFormAction.isEdit();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final ISMPProcess aSelectedProcess = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_PROCESS);
    final ISMPEndpoint aSelectedEndpoint = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_ENDPOINT);
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    aForm.addChild(getUIHandler().createActionHeader(bEdit ? "Edit endpoint" : "Create new endpoint"));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service group").setCtrl(new HCServiceGroupSelect(new RequestField(FIELD_SERVICE_GROUP_ID, aSelectedObject != null ? aSelectedObject.getServiceGroupID() : null), aDisplayLocale).setReadOnly(bEdit)).setErrorList(aFormErrors.getListOfField(FIELD_SERVICE_GROUP_ID)));
    {
        final BootstrapRow aRow = new BootstrapRow();
        aRow.createColumn(GS_IDENTIFIER_SCHEME).addChild(new HCEdit(new RequestField(FIELD_DOCTYPE_ID_SCHEME, aSelectedObject != null ? aSelectedObject.getDocumentTypeIdentifier().getScheme() : aIdentifierFactory.getDefaultDocumentTypeIdentifierScheme())).setPlaceholder("Identifier scheme").setReadOnly(bEdit));
        aRow.createColumn(GS_IDENTIFIER_VALUE).addChild(new HCEdit(new RequestField(FIELD_DOCTYPE_ID_VALUE, aSelectedObject != null ? aSelectedObject.getDocumentTypeIdentifier().getValue() : null)).setPlaceholder("Identifier value").setReadOnly(bEdit));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Document type ID").setCtrl(aRow).setErrorList(aFormErrors.getListOfFields(FIELD_DOCTYPE_ID_SCHEME, FIELD_DOCTYPE_ID_VALUE)));
    }
    {
        final BootstrapRow aRow = new BootstrapRow();
        aRow.createColumn(GS_IDENTIFIER_SCHEME).addChild(new HCEdit(new RequestField(FIELD_PROCESS_ID_SCHEME, aSelectedProcess != null ? aSelectedProcess.getProcessIdentifier().getScheme() : aIdentifierFactory.getDefaultProcessIdentifierScheme())).setPlaceholder("Identifier scheme").setReadOnly(bEdit));
        aRow.createColumn(GS_IDENTIFIER_VALUE).addChild(new HCEdit(new RequestField(FIELD_PROCESS_ID_VALUE, aSelectedProcess != null ? aSelectedProcess.getProcessIdentifier().getValue() : null)).setPlaceholder("Identifier value").setReadOnly(bEdit));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Process ID").setCtrl(aRow).setErrorList(aFormErrors.getListOfFields(FIELD_PROCESS_ID_SCHEME, FIELD_PROCESS_ID_VALUE)));
    }
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Transport Profile").setCtrl(new HCSMPTransportProfileSelect(new RequestField(FIELD_TRANSPORT_PROFILE, aSelectedEndpoint != null ? aSelectedEndpoint.getTransportProfile() : ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID())).setReadOnly(bEdit)).setErrorList(aFormErrors.getListOfField(FIELD_TRANSPORT_PROFILE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Endpoint Reference").setCtrl(new HCEdit(new RequestField(FIELD_ENDPOINT_REFERENCE, aSelectedEndpoint != null ? aSelectedEndpoint.getEndpointReference() : null))).setHelpText("The URL where messsages of this type should be targeted to.").setErrorList(aFormErrors.getListOfField(FIELD_ENDPOINT_REFERENCE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Requires Business Level Signature").setCtrl(new HCCheckBox(new RequestFieldBoolean(FIELD_REQUIRES_BUSINESS_LEVEL_SIGNATURE, aSelectedEndpoint != null ? aSelectedEndpoint.isRequireBusinessLevelSignature() : SMPEndpoint.DEFAULT_REQUIRES_BUSINESS_LEVEL_SIGNATURE))).setHelpText("Check the box if the recipient requires business-level signatures for " + "the message, meaning a signature applied to the business message " + "before the message is put on the transport. This is independent of " + "the transport-level signatures that a specific transport profile, such " + "as the START profile, might mandate. This flag does not indicate " + "which type of business-level signature might be required. Setting or " + "consuming business-level signatures would typically be the " + "responsibility of the final senders and receivers of messages, rather " + "than a set of APs.").setErrorList(aFormErrors.getListOfField(FIELD_REQUIRES_BUSINESS_LEVEL_SIGNATURE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Minimum Authentication Level").setCtrl(new HCEdit(new RequestField(FIELD_MINIMUM_AUTHENTICATION_LEVEL, aSelectedEndpoint != null ? aSelectedEndpoint.getMinimumAuthenticationLevel() : null))).setHelpText("Indicates the minimum authentication level that recipient requires. " + "The specific semantics of this field is defined in a specific instance " + "of the BUSDOX infrastructure. It could for example reflect the " + "value of the \"urn:eu:busdox:attribute:assurance-level\" SAML " + "attribute defined in the START specification.").setErrorList(aFormErrors.getListOfField(FIELD_MINIMUM_AUTHENTICATION_LEVEL)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not before").setCtrl(BootstrapDateTimePicker.create(FIELD_NOT_BEFORE, aSelectedEndpoint != null ? aSelectedEndpoint.getServiceActivationDate() : null, aDisplayLocale)).setHelpText("Activation date of the service. Senders should ignore services that " + "are not yet activated.").setErrorList(aFormErrors.getListOfField(FIELD_NOT_BEFORE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not after").setCtrl(BootstrapDateTimePicker.create(FIELD_NOT_AFTER, aSelectedEndpoint != null ? aSelectedEndpoint.getServiceExpirationDate() : null, aDisplayLocale)).setHelpText("Expiration date of the service. Senders should ignore services that " + "are expired.").setErrorList(aFormErrors.getListOfField(FIELD_NOT_AFTER)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Certificate").setCtrl(new HCTextArea(new RequestField(FIELD_CERTIFICATE, aSelectedEndpoint != null ? aSelectedEndpoint.getCertificate() : null))).setHelpText("Holds the complete signing certificate of the recipient AP, as a " + "PEM base 64 encoded X509 DER formatted value.").setErrorList(aFormErrors.getListOfField(FIELD_CERTIFICATE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service Description").setCtrl(new HCEdit(new RequestField(FIELD_SERVICE_DESCRIPTION, aSelectedEndpoint != null ? aSelectedEndpoint.getServiceDescription() : null))).setHelpText("A human readable description of the service.").setErrorList(aFormErrors.getListOfField(FIELD_SERVICE_DESCRIPTION)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Technical Contact").setCtrl(new HCEdit(new RequestField(FIELD_TECHNICAL_CONTACT, aSelectedEndpoint != null ? aSelectedEndpoint.getTechnicalContactUrl() : null))).setHelpText("Represents a link to human readable contact information. This " + "might also be an email address.").setErrorList(aFormErrors.getListOfField(FIELD_TECHNICAL_CONTACT)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Technical Information").setCtrl(new HCEdit(new RequestField(FIELD_TECHNICAL_INFORMATION, aSelectedEndpoint != null ? aSelectedEndpoint.getTechnicalInformationUrl() : null))).setHelpText("A URL to human readable documentation of the service format. " + "This could for example be a web site containing links to XML " + "Schemas, WSDLs, Schematrons and other relevant resources.").setErrorList(aFormErrors.getListOfField(FIELD_TECHNICAL_INFORMATION)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Extension").setCtrl(new HCTextArea(new RequestField(FIELD_EXTENSION, aSelectedEndpoint != null ? aSelectedEndpoint.getFirstExtensionXML() : null))).setHelpText("Optional extension to the endpoint. If present it must be valid XML content!").setErrorList(aFormErrors.getListOfField(FIELD_EXTENSION)));
}
Also used : Locale(java.util.Locale) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) RequestFieldBoolean(com.helger.photon.core.form.RequestFieldBoolean) HCEdit(com.helger.html.hc.html.forms.HCEdit) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) HCSMPTransportProfileSelect(com.helger.phoss.smp.ui.secure.hc.HCSMPTransportProfileSelect) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) BootstrapRow(com.helger.photon.bootstrap4.grid.BootstrapRow) HCCheckBox(com.helger.html.hc.html.forms.HCCheckBox) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) RequestField(com.helger.photon.core.form.RequestField)

Example 2 with HCTextArea

use of com.helger.html.hc.html.forms.HCTextArea in project phoss-smp by phax.

the class PageSecureBusinessCard method _createEntityInputForm.

@Nonnull
private static IHCNode _createEntityInputForm(@Nonnull final LayoutExecutionContext aLEC, @Nullable final SMPBusinessCardEntity aExistingEntity, @Nullable final String sExistingID, @Nonnull final FormErrorList aFormErrors, final boolean bFormSubmitted) {
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final String sEntityID = StringHelper.hasText(sExistingID) ? sExistingID : TMP_ID_PREFIX + Integer.toString(GlobalIDFactory.getNewIntID());
    final BootstrapCard aPanel = new BootstrapCard().setID(sEntityID);
    aPanel.createAndAddHeader().addChild("Business Entity");
    final BootstrapCardBody aBody = aPanel.createAndAddBody();
    final BootstrapViewForm aForm = aBody.addAndReturnChild(new BootstrapViewForm());
    final String sFieldName = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_NAME);
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Name").setCtrl(new HCEdit(new RequestField(sFieldName, aExistingEntity == null ? null : aExistingEntity.names().getFirst().getName()))).setErrorList(aFormErrors.getListOfField(sFieldName)));
    final String sFieldCountryCode = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_COUNTRY_CODE);
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Country").setCtrl(new HCCountrySelect(new RequestField(sFieldCountryCode, aExistingEntity == null ? null : aExistingEntity.getCountryCode()), aDisplayLocale, HCCountrySelect.getAllCountries(EWithDeprecated.DEFAULT), (aLocale, aContentLocale) -> aLocale.getDisplayCountry(aContentLocale) + " (" + aLocale.getCountry() + ")")).setErrorList(aFormErrors.getListOfField(sFieldCountryCode)));
    final String sFieldGeoInfo = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_GEO_INFO);
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Geographical Information").setCtrl(new HCTextArea(new RequestField(sFieldGeoInfo, aExistingEntity == null ? null : aExistingEntity.getGeographicalInformation()))).setErrorList(aFormErrors.getListOfField(sFieldGeoInfo)));
    // Identifiers
    {
        final String sBodyID = sEntityID + PREFIX_IDENTIFIER;
        final HCNodeList aNL = new HCNodeList();
        final BootstrapTable aTable = aNL.addAndReturnChild(new BootstrapTable(HCCol.star(), HCCol.star(), HCCol.star()));
        aTable.addHeaderRow().addCells("Scheme", "Value", "");
        aTable.setBodyID(sBodyID);
        final IRequestParamMap aIdentifiers = aLEC.getRequestParamMap().getMap(PREFIX_ENTITY, sEntityID, PREFIX_IDENTIFIER);
        if (bFormSubmitted) {
            // Re-show of form
            if (aIdentifiers != null)
                for (final String sIdentifierRowID : aIdentifiers.keySet()) aTable.addBodyRow(_createIdentifierInputForm(aLEC, sEntityID, null, sIdentifierRowID, aFormErrors));
        } else {
            if (aExistingEntity != null) {
                // add all existing stored entities
                for (final SMPBusinessCardIdentifier aIdentifier : aExistingEntity.identifiers()) aTable.addBodyRow(_createIdentifierInputForm(aLEC, sEntityID, aIdentifier, (String) null, aFormErrors));
            }
        }
        {
            final JSAnonymousFunction aJSAppend = new JSAnonymousFunction();
            final JSVar aJSAppendData = aJSAppend.param("data");
            aJSAppend.body().add(JQuery.idRef(sBodyID).append(aJSAppendData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
            final JSPackage aOnAdd = new JSPackage();
            aOnAdd.add(new JQueryAjaxBuilder().url(AJAX_CREATE_IDENTIFIER.getInvocationURL(aRequestScope).add(PARAM_ENTITY_ID, sEntityID)).data(new JSAssocArray()).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aJSAppend, null)).build());
            aNL.addChild(new BootstrapButton().setIcon(EDefaultIcon.PLUS).addChild("Add Identifier").setOnClick(aOnAdd));
        }
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Identifiers").setCtrl(aNL));
    }
    // Website URIs
    final String sFieldWebsiteURIs = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_WEBSITE_URIS);
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Website URIs").setCtrl(new HCTextArea(new RequestField(sFieldWebsiteURIs, aExistingEntity == null ? null : StringHelper.getImploded('\n', aExistingEntity.websiteURIs())))).setHelpText("Put each Website URI in a separate line").setErrorList(aFormErrors.getListOfField(sFieldWebsiteURIs)));
    // Contacts
    {
        final String sBodyID = sEntityID + PREFIX_CONTACT;
        final HCNodeList aNL = new HCNodeList();
        final BootstrapTable aTable = aNL.addAndReturnChild(new BootstrapTable(HCCol.star(), HCCol.star(), HCCol.star(), HCCol.star(), HCCol.star()));
        aTable.addHeaderRow().addCells("Type", "Name", "Phone number", "Email address", "");
        aTable.setBodyID(sBodyID);
        final IRequestParamMap aContacts = aLEC.getRequestParamMap().getMap(PREFIX_ENTITY, sEntityID, PREFIX_CONTACT);
        if (bFormSubmitted) {
            // Re-show of form
            if (aContacts != null)
                for (final String sIdentifierRowID : aContacts.keySet()) aTable.addBodyRow(_createContactInputForm(aLEC, sEntityID, null, sIdentifierRowID, aFormErrors));
        } else {
            if (aExistingEntity != null) {
                // add all existing stored entities
                for (final SMPBusinessCardContact aContact : aExistingEntity.contacts()) aTable.addBodyRow(_createContactInputForm(aLEC, sEntityID, aContact, (String) null, aFormErrors));
            }
        }
        {
            final JSAnonymousFunction aJSAppend = new JSAnonymousFunction();
            final JSVar aJSAppendData = aJSAppend.param("data");
            aJSAppend.body().add(JQuery.idRef(sBodyID).append(aJSAppendData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
            final JSPackage aOnAdd = new JSPackage();
            aOnAdd.add(new JQueryAjaxBuilder().url(AJAX_CREATE_CONTACT.getInvocationURL(aRequestScope).add(PARAM_ENTITY_ID, sEntityID)).data(new JSAssocArray()).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aJSAppend, null)).build());
            aNL.addChild(new BootstrapButton().setIcon(EDefaultIcon.PLUS).addChild("Add Contact").setOnClick(aOnAdd));
        }
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Contacts").setCtrl(aNL));
    }
    final String sFieldAdditionalInfo = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_ADDITIONAL_INFO);
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Additional Information").setCtrl(new HCTextArea(new RequestField(sFieldAdditionalInfo, aExistingEntity == null ? null : aExistingEntity.getAdditionalInformation()))).setErrorList(aFormErrors.getListOfField(sFieldAdditionalInfo)));
    final String sFieldRegDate = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_REG_DATE);
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Registration Date").setCtrl(BootstrapDateTimePicker.create(sFieldRegDate, aExistingEntity == null ? null : aExistingEntity.getRegistrationDate(), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(sFieldRegDate)));
    final BootstrapButtonToolbar aToolbar = aBody.addAndReturnChild(new BootstrapButtonToolbar(aLEC));
    aToolbar.addButton("Delete this Entity", JQuery.idRef(aPanel).remove(), EDefaultIcon.DELETE);
    return aPanel;
}
Also used : Locale(java.util.Locale) GlobalIDFactory(com.helger.commons.id.factory.GlobalIDFactory) ILayoutExecutionContext(com.helger.photon.core.execcontext.ILayoutExecutionContext) PDClientProvider(com.helger.phoss.smp.app.PDClientProvider) EWithDeprecated(com.helger.photon.uicore.html.select.HCCountrySelect.EWithDeprecated) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) FormErrorList(com.helger.photon.core.form.FormErrorList) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) Nonempty(com.helger.commons.annotation.Nonempty) SMPBusinessCardIdentifier(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardIdentifier) HCA(com.helger.html.hc.html.textlevel.HCA) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) CPageParam(com.helger.photon.uicore.css.CPageParam) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) IHCCell(com.helger.html.hc.html.tabular.IHCCell) HCDiv(com.helger.html.hc.html.grouping.HCDiv) HCTextNode(com.helger.html.hc.impl.HCTextNode) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) ICommonsList(com.helger.commons.collection.impl.ICommonsList) HCExtHelper(com.helger.html.hc.ext.HCExtHelper) RegExHelper(com.helger.commons.regex.RegExHelper) IValidityIndicator(com.helger.commons.state.IValidityIndicator) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) RequestParamMap(com.helger.servlet.request.RequestParamMap) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) BootstrapCardBody(com.helger.photon.bootstrap4.card.BootstrapCardBody) JSJQueryHelper(com.helger.photon.uicore.js.JSJQueryHelper) ISMPBusinessCardManager(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager) DataTables(com.helger.photon.uictrls.datatables.DataTables) IRequestParamMap(com.helger.servlet.request.IRequestParamMap) LinkHelper(com.helger.photon.app.url.LinkHelper) JSAssocArray(com.helger.html.jscode.JSAssocArray) BootstrapDateTimePicker(com.helger.photon.bootstrap4.uictrls.datetimepicker.BootstrapDateTimePicker) PDTFromString(com.helger.commons.datetime.PDTFromString) HCEdit(com.helger.html.hc.html.forms.HCEdit) IHCNode(com.helger.html.hc.IHCNode) JQuery(com.helger.html.jquery.JQuery) SMPBusinessCardEntity(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardEntity) Nullable(javax.annotation.Nullable) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) StringHelper(com.helger.commons.string.StringHelper) WorkInProgress(com.helger.commons.annotation.WorkInProgress) SMPMetaManager(com.helger.phoss.smp.domain.SMPMetaManager) BootstrapFormHelper(com.helger.photon.bootstrap4.form.BootstrapFormHelper) CAjax(com.helger.phoss.smp.ui.ajax.CAjax) HCA_MailTo(com.helger.html.hc.ext.HCA_MailTo) HCCol(com.helger.html.hc.html.tabular.HCCol) RequestField(com.helger.photon.core.form.RequestField) AbstractBootstrapWebPageActionHandler(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandler) ESortOrder(com.helger.commons.compare.ESortOrder) JSAnonymousFunction(com.helger.html.jscode.JSAnonymousFunction) LayoutExecutionContext(com.helger.photon.core.execcontext.LayoutExecutionContext) JSVar(com.helger.html.jscode.JSVar) WebPageExecutionContext(com.helger.photon.uicore.page.WebPageExecutionContext) EDefaultIcon(com.helger.photon.uicore.icon.EDefaultIcon) BootstrapSuccessBox(com.helger.photon.bootstrap4.alert.BootstrapSuccessBox) AbstractBootstrapWebPageActionHandlerDelete(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandlerDelete) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) Locale(java.util.Locale) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) EmailAddressValidator(com.helger.smtp.util.EmailAddressValidator) SMPCommonUI(com.helger.phoss.smp.ui.SMPCommonUI) BootstrapErrorBox(com.helger.photon.bootstrap4.alert.BootstrapErrorBox) HCCountrySelect(com.helger.photon.uicore.html.select.HCCountrySelect) EWebPageFormAction(com.helger.photon.uicore.page.EWebPageFormAction) BootstrapCard(com.helger.photon.bootstrap4.card.BootstrapCard) IAjaxFunctionDeclaration(com.helger.photon.ajax.decl.IAjaxFunctionDeclaration) PDClient(com.helger.pd.client.PDClient) CountryCache(com.helger.commons.locale.country.CountryCache) EFamFamIcon(com.helger.photon.uictrls.famfam.EFamFamIcon) LocalDate(java.time.LocalDate) SMPWebAppConfiguration(com.helger.phoss.smp.app.SMPWebAppConfiguration) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ESuccess(com.helger.commons.state.ESuccess) ISMPBusinessCard(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard) HCRow(com.helger.html.hc.html.tabular.HCRow) EValidity(com.helger.commons.state.EValidity) PhotonUnifiedResponse(com.helger.photon.app.PhotonUnifiedResponse) AbstractSMPWebPageForm(com.helger.phoss.smp.ui.AbstractSMPWebPageForm) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) CompareHelper(com.helger.commons.compare.CompareHelper) URLValidator(com.helger.commons.url.URLValidator) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) ISimpleURL(com.helger.commons.url.ISimpleURL) HCNodeList(com.helger.html.hc.impl.HCNodeList) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) CBootstrapCSS(com.helger.photon.bootstrap4.CBootstrapCSS) HCTable(com.helger.html.hc.html.tabular.HCTable) JQueryAjaxBuilder(com.helger.html.jquery.JQueryAjaxBuilder) SMPBusinessCardName(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardName) EBootstrapButtonSize(com.helger.photon.bootstrap4.button.EBootstrapButtonSize) EShowList(com.helger.photon.uicore.page.EShowList) EFamFamFlagIcon(com.helger.photon.uictrls.famfam.EFamFamFlagIcon) SMPBusinessCardContact(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardContact) JSPackage(com.helger.html.jscode.JSPackage) BootstrapCard(com.helger.photon.bootstrap4.card.BootstrapCard) JSAnonymousFunction(com.helger.html.jscode.JSAnonymousFunction) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) JSVar(com.helger.html.jscode.JSVar) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) HCEdit(com.helger.html.hc.html.forms.HCEdit) PDTToString(com.helger.commons.datetime.PDTToString) PDTFromString(com.helger.commons.datetime.PDTFromString) SMPBusinessCardIdentifier(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardIdentifier) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) SMPBusinessCardContact(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardContact) HCCountrySelect(com.helger.photon.uicore.html.select.HCCountrySelect) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) JQueryAjaxBuilder(com.helger.html.jquery.JQueryAjaxBuilder) BootstrapCardBody(com.helger.photon.bootstrap4.card.BootstrapCardBody) JSPackage(com.helger.html.jscode.JSPackage) JSAssocArray(com.helger.html.jscode.JSAssocArray) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) IRequestParamMap(com.helger.servlet.request.IRequestParamMap) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) RequestField(com.helger.photon.core.form.RequestField) Nonnull(javax.annotation.Nonnull)

Example 3 with HCTextArea

use of com.helger.html.hc.html.forms.HCTextArea in project phoss-smp by phax.

the class PageSecureServiceGroupMigrationInbound method showInputForm.

@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPParticipantMigration aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bIsFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Migration Key").setCtrl(new HCEdit(new RequestField(FIELD_MIGRATION_KEY))).setHelpText("The migration key received from the other SMP that was acknowledged by the SMK/SML.").setErrorList(aFormErrors.getListOfField(FIELD_MIGRATION_KEY)));
    {
        final String sDefaultScheme = aIdentifierFactory.getDefaultParticipantIdentifierScheme();
        final BootstrapRow aRow = new BootstrapRow();
        aRow.createColumn(GS_IDENTIFIER_SCHEME).addChild(new HCEdit(new RequestField(FIELD_PARTICIPANT_ID_SCHEME, aSelectedObject != null ? aSelectedObject.getParticipantIdentifier().getScheme() : sDefaultScheme)).setPlaceholder("Identifier scheme"));
        aRow.createColumn(GS_IDENTIFIER_VALUE).addChild(new HCEdit(new RequestField(FIELD_PARTICIPANT_ID_VALUE, aSelectedObject != null ? aSelectedObject.getParticipantIdentifier().getValue() : null)).setPlaceholder("Identifier value"));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Participant ID").setCtrl(aRow).setHelpText("The participant identifier for which the service group should be created. The left part is the identifier scheme" + (sDefaultScheme == null ? "" : " (default: " + sDefaultScheme + ")") + ", the right part is the identifier value (e.g. 9915:test)").setErrorList(aFormErrors.getListOfFields(FIELD_PARTICIPANT_ID_SCHEME, FIELD_PARTICIPANT_ID_VALUE)));
    }
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Owning User").setCtrl(new HCUserSelect(new RequestField(FIELD_OWNING_USER_ID, LoggedInUserManager.getInstance().getCurrentUserID()), aDisplayLocale)).setHelpText("The user who owns this entry. Only this user can make changes via the REST API.").setErrorList(aFormErrors.getListOfField(FIELD_OWNING_USER_ID)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Extension").setCtrl(new HCTextArea(new RequestField(FIELD_EXTENSION))).setHelpText("Optional extension to the service group. If present it must be valid XML content!").setErrorList(aFormErrors.getListOfField(FIELD_EXTENSION)));
}
Also used : Locale(java.util.Locale) HCUserSelect(com.helger.phoss.smp.ui.secure.hc.HCUserSelect) BootstrapRow(com.helger.photon.bootstrap4.grid.BootstrapRow) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) HCEdit(com.helger.html.hc.html.forms.HCEdit) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) RequestField(com.helger.photon.core.form.RequestField)

Example 4 with HCTextArea

use of com.helger.html.hc.html.forms.HCTextArea in project phoss-smp by phax.

the class PageSecureRedirect method showInputForm.

@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPRedirect aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
    final boolean bEdit = eFormAction.isEdit();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    aForm.addChild(getUIHandler().createActionHeader(bEdit ? "Edit Redirect" : "Create new Redirect"));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service Group").setCtrl(new HCServiceGroupSelect(new RequestField(FIELD_SERVICE_GROUP_ID, aSelectedObject != null ? aSelectedObject.getServiceGroupID() : null), aDisplayLocale).setReadOnly(bEdit)).setErrorList(aFormErrors.getListOfField(FIELD_SERVICE_GROUP_ID)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Document Type ID").setCtrl(new HCEdit(new RequestField(FIELD_DOCTYPE_ID, aSelectedObject != null ? aSelectedObject.getDocumentTypeIdentifier().getURIEncoded() : aIdentifierFactory.getDefaultDocumentTypeIdentifierScheme() + CIdentifier.URL_SCHEME_VALUE_SEPARATOR)).setReadOnly(bEdit)).setErrorList(aFormErrors.getListOfField(FIELD_DOCTYPE_ID)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Redirect To").setCtrl(new HCEdit(new RequestField(FIELD_REDIRECT_TO, aSelectedObject != null ? aSelectedObject.getTargetHref() : null))).setHelpText("URL to redirect to. Must include the service group and the document type in the URL!").setErrorList(aFormErrors.getListOfField(FIELD_REDIRECT_TO)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Subject Unique Identifier").setCtrl(new HCEdit(new RequestField(FIELD_SUBJECT_UNIQUE_IDENTIFIER, aSelectedObject != null ? aSelectedObject.getSubjectUniqueIdentifier() : null))).setHelpText("Holds the Subject Unique Identifier of the certificate of the " + "destination SMP. A client SHOULD validate that the Subject " + "Unique Identifier of the certificate used to sign the resource at the " + "destination SMP matches the Subject Unique Identifier published in " + "the redirecting SMP.").setErrorList(aFormErrors.getListOfField(FIELD_SUBJECT_UNIQUE_IDENTIFIER)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Extension").setCtrl(new HCTextArea(new RequestField(FIELD_EXTENSION, aSelectedObject != null ? aSelectedObject.getFirstExtensionXML() : null))).setHelpText("Optional extension to the service group. If present it must be valid XML content!").setErrorList(aFormErrors.getListOfField(FIELD_EXTENSION)));
}
Also used : Locale(java.util.Locale) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) HCEdit(com.helger.html.hc.html.forms.HCEdit) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) RequestField(com.helger.photon.core.form.RequestField)

Example 5 with HCTextArea

use of com.helger.html.hc.html.forms.HCTextArea in project phoss-smp by phax.

the class PageSecureSMLCertificateUpdate 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();
    aNodeList.addChild(info().addChildren(div("Prepare the update of your SMP certificate in the future."), div("Note: this is a custom SML extension that only works with the CEF SML instances!")));
    // check for expired certificate
    boolean bShowForm = true;
    {
        final X509Certificate aEntry = SMPKeyManager.getInstance().getPrivateKeyCertificate();
        if (aEntry != null) {
            try {
                aEntry.checkValidity();
                aNodeList.addChild(info("Your SMP certificate is still valid until " + PDTToString.getAsString(PDTFactory.createLocalDateTime(aEntry.getNotAfter()), aDisplayLocale) + "."));
            } catch (final CertificateExpiredException ex) {
                aNodeList.addChild(error("Your SMP certificate is already expired." + " This functionality works only if your SMP certificate is NOT expired yet." + " Please contact CEF-EDELIVERY-SUPPORT@ec.europa.eu with your SMP ID, the new certificate and the requested exchange date!"));
                bShowForm = false;
            } catch (final CertificateNotYetValidException ex) {
                aNodeList.addChild(warn("Your SMP certificate is not valid yet." + " For this page to work you need to have your old certificate (the one that will expire soon) configured." + " Most likely the certificate change will not work."));
            }
        }
    }
    if (aWPEC.hasAction(CPageParam.ACTION_PERFORM)) {
        if (aWPEC.hasSubAction(SUBACTION_SMP_UPDATE_CERT))
            _updateSMPCertAtSML(aWPEC, aFormErrors);
    }
    // Update SMP certificate in SML
    if (bShowForm) {
        final BootstrapForm aForm = getUIHandler().createFormFileUploadSelf(aWPEC);
        aForm.setLeft(3);
        aForm.addChild(warn("It is your responsibility to actually perform the update of the certificate in this SMP at the specified time! This does NOT happen automatically."));
        final BootstrapDateTimePicker aDTP = BootstrapDateTimePicker.create(FIELD_PM_MIGRATION_DATE, (LocalDate) null, aDisplayLocale);
        aDTP.setMinDate(PDTFactory.getCurrentLocalDate().plusDays(1));
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Certificate migration date").setCtrl(aDTP).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 new certificate is used.").setErrorList(aFormErrors.getListOfField(FIELD_PM_MIGRATION_DATE)));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("New public certificate").setCtrl(new HCTextArea(new RequestField(FIELD_PM_PUBLIC_CERT)).setRows(10)).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");
        aNodeList.addChild(aForm);
    }
}
Also used : Locale(java.util.Locale) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) HCNodeList(com.helger.html.hc.impl.HCNodeList) CertificateExpiredException(java.security.cert.CertificateExpiredException) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) FormErrorList(com.helger.photon.core.form.FormErrorList) BootstrapDateTimePicker(com.helger.photon.bootstrap4.uictrls.datetimepicker.BootstrapDateTimePicker) X509Certificate(java.security.cert.X509Certificate) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) RequestField(com.helger.photon.core.form.RequestField)

Aggregations

HCTextArea (com.helger.html.hc.html.forms.HCTextArea)7 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)7 RequestField (com.helger.photon.core.form.RequestField)7 Locale (java.util.Locale)7 HCEdit (com.helger.html.hc.html.forms.HCEdit)5 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)5 PDTToString (com.helger.commons.datetime.PDTToString)3 HCNodeList (com.helger.html.hc.impl.HCNodeList)3 HCServiceGroupSelect (com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect)3 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)3 BootstrapForm (com.helger.photon.bootstrap4.form.BootstrapForm)3 BootstrapRow (com.helger.photon.bootstrap4.grid.BootstrapRow)3 FormErrorList (com.helger.photon.core.form.FormErrorList)3 ICommonsList (com.helger.commons.collection.impl.ICommonsList)2 ISimpleURL (com.helger.commons.url.ISimpleURL)2 HCRow (com.helger.html.hc.html.tabular.HCRow)2 HCTable (com.helger.html.hc.html.tabular.HCTable)2 BootstrapDateTimePicker (com.helger.photon.bootstrap4.uictrls.datetimepicker.BootstrapDateTimePicker)2 Nonempty (com.helger.commons.annotation.Nonempty)1 WorkInProgress (com.helger.commons.annotation.WorkInProgress)1