use of com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar 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);
}
}
use of com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar in project phoss-smp by phax.
the class PageSecureSMLConfiguration method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMLInfoManager aSMLInfoMgr = SMPMetaManager.getSMLInfoMgr();
aNodeList.addChild(info("This page lets you create custom SML configurations that can be used for registration."));
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new SML configuration", createCreateURL(aWPEC), EDefaultIcon.NEW);
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("Name").setInitialSorting(ESortOrder.ASCENDING), new DTCol("DNS Zone"), new DTCol("Management Service URL"), new DTCol("Client Cert?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMLInfo aCurObject : aSMLInfoMgr.getAllSMLInfos()) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getDisplayName()));
aRow.addCell(aCurObject.getDNSZone());
aRow.addCell(aCurObject.getManagementServiceURL());
aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isClientCertificateRequired(), aDisplayLocale));
aRow.addCell(createEditLink(aWPEC, aCurObject, "Edit " + aCurObject.getID()), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject, "Copy " + aCurObject.getID()), new HCTextNode(" "), isActionAllowed(aWPEC, EWebPageFormAction.DELETE, aCurObject) ? createDeleteLink(aWPEC, aCurObject, "Delete " + aCurObject.getDisplayName()) : createEmptyAction());
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
use of com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar 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);
}
use of com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar in project phoss-directory by phax.
the class AbstractPageSecureReIndex method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
// Add toolbar
{
final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addChild(new BootstrapButton().addChild("Refresh").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref()));
aToolbar.addChild(new BootstrapButton().addChild("Delete all entries").setIcon(EDefaultIcon.DELETE).setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_DELETE_ALL)));
aToolbar.addChild(span("Current server time: " + PDTToString.getAsString(PDTFactory.getCurrentLocalTime(), aDisplayLocale)).addClass(PDCommonUI.CSS_CLASS_VERTICAL_PADDED_TEXT));
}
final HCTable aTable = new HCTable(new DTCol("Reg date").setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING), new DTCol("Participant"), new DTCol("Action"), new DTCol("Retries").setDisplayType(EDTColType.INT, aDisplayLocale), m_bDeadIndex ? null : new DTCol("Next retry").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new DTCol("Last retry").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final IReIndexWorkItem aItem : getReIndexWorkItemList().getAllItems()) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aItem);
final IIndexerWorkItem aWorkItem = aItem.getWorkItem();
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(PDTToString.getAsString(aWorkItem.getCreationDateTime(), aDisplayLocale)));
aRow.addCell(aWorkItem.getParticipantID().getURIEncoded());
aRow.addCell(aWorkItem.getType().getDisplayName());
aRow.addCell(Integer.toString(aItem.getRetryCount()));
if (!m_bDeadIndex)
aRow.addCell(PDTToString.getAsString(aItem.getNextRetryDT(), aDisplayLocale));
aRow.addCell(PDTToString.getAsString(aItem.getMaxRetryDT(), aDisplayLocale));
final IHCCell<?> aActionCell = aRow.addCell();
if (m_bDeadIndex) {
aActionCell.addChild(new HCA(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_REINDEX_NOW).add(CPageParam.PARAM_OBJECT, aItem.getID())).setTitle("Re-index the entry now").addChild(EDefaultIcon.NEXT.getAsNode()));
aActionCell.addChild(" ");
}
aActionCell.addChild(createDeleteLink(aWPEC, aItem));
}
aNodeList.addChild(aTable);
aNodeList.addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
}
use of com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar in project phoss-directory by phax.
the class PageSecureIndexImport method fillContent.
@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
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)));
}
}
}
final boolean bIsFormSubmitted = aWPEC.hasAction(CPageParam.ACTION_PERFORM);
if (bIsFormSubmitted) {
final IFileItem aFile = aWPEC.params().getAsFileItem(FIELD_FILE);
if (aFile == null || StringHelper.hasNoText(aFile.getName()))
aFormErrors.addFieldError(FIELD_FILE, "No file was selected");
if (aFormErrors.isEmpty()) {
final HCNodeList aResultNL = new HCNodeList();
final SAXReaderSettings aSettings = new SAXReaderSettings();
aSettings.setFeatureValues(EXMLParserFeature.AVOID_DOS_SETTINGS);
final CollectingSAXErrorHandler aErrorHandler = new CollectingSAXErrorHandler();
aSettings.setErrorHandler(aErrorHandler);
final ICommonsList<IParticipantIdentifier> aQueued = new CommonsArrayList<>();
final ICommonsList<IParticipantIdentifier> aNotQueued = new CommonsArrayList<>();
aSettings.setContentHandler(new DefaultHandler() {
@Override
public void startElement(final String sURI, final String sLocalName, final String sQName, final Attributes aAttributes) throws SAXException {
if (sQName.equals("participant")) {
final String sScheme = aAttributes.getValue("scheme");
final String sValue = aAttributes.getValue("value");
final IParticipantIdentifier aParticipantID = aIdentifierFactory.createParticipantIdentifier(sScheme, sValue);
if (aParticipantID != null) {
if (PDMetaManager.getIndexerMgr().queueWorkItem(aParticipantID, EIndexerWorkItemType.CREATE_UPDATE, "import-triggered", PDIndexerManager.HOST_LOCALHOST).isChanged()) {
aQueued.add(aParticipantID);
} else {
aNotQueued.add(aParticipantID);
}
} else
LOGGER.error("Failed to convert '" + sScheme + "' and '" + sValue + "' to a participant identifier");
}
}
});
LOGGER.info("Importing participant IDs from '" + aFile.getNameSecure() + "'");
final ESuccess eSuccess = SAXReader.readXMLSAX(new FileItemResource(aFile), aSettings);
LOGGER.info("Finished reading XML file. Queued " + aQueued.size() + "; not queued: " + aNotQueued.size() + "; errors: " + aErrorHandler.getErrorList().size());
// Some things may have been queued even in case of error
if (aQueued.isNotEmpty()) {
final HCUL aUL = new HCUL();
for (final IParticipantIdentifier aPI : aQueued) aUL.addItem(aPI.getURIEncoded());
aResultNL.addChild(success(div("The following identifiers were successfully queued for indexing:")).addChild(aUL));
}
if (aNotQueued.isNotEmpty()) {
final HCUL aUL = new HCUL();
for (final IParticipantIdentifier aPI : aNotQueued) aUL.addItem(aPI.getURIEncoded());
aResultNL.addChild(warn(div("The following identifiers could not be queued (because they are already in the queue):")).addChild(aUL));
}
if (eSuccess.isFailure()) {
final HCUL aUL = new HCUL();
for (final IError aError : aErrorHandler.getErrorList()) {
final String sMsg = aError.getAsString(AppCommonUI.DEFAULT_LOCALE);
LOGGER.error(" " + sMsg);
aUL.addItem(sMsg);
}
aResultNL.addChild(error(div("Error parsing provided XML:")).addChild(aUL));
}
aWPEC.postRedirectGetInternal(aResultNL);
}
}
final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormFileUploadSelf(aWPEC, bIsFormSubmitted));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Import file").setCtrl(new BootstrapFileUpload(FIELD_FILE, aDisplayLocale)).setHelpText("Select a file that was created from a full XML export to index of all them manually.").setErrorList(aFormErrors.getListOfField(FIELD_FILE)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
aToolbar.addSubmitButton("Import all", EDefaultIcon.YES);
}
Aggregations