use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class PageSecureTasksProblems method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final OffsetDateTime aNowDT = PDTFactory.getCurrentOffsetDateTime();
final OffsetDateTime aNowPlusDT = aNowDT.plusMonths(3);
aNodeList.addChild(info("This page tries to identify upcoming tasks and potential problems in the SMP configuration. It is meant to highlight immediate and upcoming action items as well as potential misconfiguration."));
final HCOL aOL = new HCOL();
// Check for default password
if (PhotonSecurityManager.getUserMgr().areUserIDAndPasswordValid(CSecurity.USER_ADMINISTRATOR_ID, CSecurity.USER_ADMINISTRATOR_PASSWORD)) {
aOL.addItem(_createError("Please change the password of the default user " + CSecurity.USER_ADMINISTRATOR_EMAIL + "!"), div("This is a severe security risk"));
}
_checkSettings(aOL);
// check keystore configuration
_checkKeyStore(aWPEC, aOL, aNowDT, aNowPlusDT);
// Check truststore configuration
_checkTrustStore(aWPEC, aOL, aNowDT, aNowPlusDT);
// Check SML configuration
_checkSMLConfiguration(aOL);
// Check Directory configuration
_checkDirectoryConfig(aWPEC, aOL, aNowDT, aNowPlusDT);
// check service groups and redirects
{
final ICommonsList<ISMPServiceGroup> aServiceGroups = aServiceGroupMgr.getAllSMPServiceGroups();
if (aServiceGroups.isEmpty()) {
aOL.addItem(_createWarning("No service group is configured. This SMP is currently empty."));
} else {
// For all service groups
for (final ISMPServiceGroup aServiceGroup : CollectionHelper.getSorted(aServiceGroups, ISMPServiceGroup.comparator())) {
final HCUL aULPerSG = new HCUL();
final ICommonsList<ISMPServiceInformation> aServiceInfos = aServiceInfoMgr.getAllSMPServiceInformationOfServiceGroup(aServiceGroup);
if (aServiceInfos.isEmpty()) {
// This is merely a warning or an error
aULPerSG.addItem(_createInfo("No endpoint is configured for this service group."));
} else {
for (final ISMPServiceInformation aServiceInfo : aServiceInfos) {
final HCUL aULPerDocType = new HCUL();
final ICommonsList<ISMPProcess> aProcesses = aServiceInfo.getAllProcesses();
for (final ISMPProcess aProcess : aProcesses) {
final HCUL aULPerProcess = new HCUL();
final ICommonsList<ISMPEndpoint> aEndpoints = aProcess.getAllEndpoints();
for (final ISMPEndpoint aEndpoint : aEndpoints) {
final HCUL aULPerEndpoint = new HCUL();
final ESMPTransportProfile eTransportProfile = ESMPTransportProfile.getFromIDOrNull(aEndpoint.getTransportProfile());
if (eTransportProfile == null)
aULPerEndpoint.addItem(_createWarning("The endpoint uses the non-standard transport profile '" + aEndpoint.getTransportProfile() + "'."));
if (aEndpoint.getServiceActivationDateTime() != null) {
if (aEndpoint.getServiceActivationDateTime().isAfter(XMLOffsetDateTime.of(aNowDT)))
aULPerEndpoint.addItem(_createWarning("The endpoint is not yet active."), div("It will be active from " + PDTToString.getAsString(aEndpoint.getServiceActivationDateTime(), aDisplayLocale) + "."));
}
if (aEndpoint.getServiceExpirationDateTime() != null) {
if (aEndpoint.getServiceExpirationDateTime().isBefore(XMLOffsetDateTime.of(aNowDT)))
aULPerEndpoint.addItem(_createError("The endpoint is no longer active."), div("It was valid until " + PDTToString.getAsString(aEndpoint.getServiceExpirationDateTime(), aDisplayLocale) + "."));
else if (aEndpoint.getServiceExpirationDateTime().isBefore(XMLOffsetDateTime.of(aNowPlusDT)))
aULPerEndpoint.addItem(_createWarning("The endpoint will be inactive soon."), div("It is only valid until " + PDTToString.getAsString(aEndpoint.getServiceExpirationDateTime(), aDisplayLocale) + "."));
}
X509Certificate aX509Cert = null;
try {
aX509Cert = CertificateHelper.convertStringToCertficate(aEndpoint.getCertificate());
} catch (final CertificateException ex) {
// Ignore
}
if (aX509Cert == null)
aULPerEndpoint.addItem(_createError("The X.509 certificate configured at the endpoint is invalid and could not be interpreted as a certificate."));
else {
final OffsetDateTime aNotBefore = PDTFactory.createOffsetDateTime(aX509Cert.getNotBefore());
if (aNowDT.isBefore(aNotBefore))
aULPerEndpoint.addItem(_createError("The endpoint certificate is not yet active."), div("It will be valid from " + PDTToString.getAsString(aNotBefore, aDisplayLocale) + "."));
final OffsetDateTime aNotAfter = PDTFactory.createOffsetDateTime(aX509Cert.getNotAfter());
if (aNowDT.isAfter(aNotAfter))
aULPerEndpoint.addItem(_createError("The endpoint certificate is already expired."), div("It was valid until " + PDTToString.getAsString(aNotAfter, aDisplayLocale) + "."));
else if (aNowPlusDT.isAfter(aNotAfter))
aULPerEndpoint.addItem(_createWarning("The endpoint certificate will expire soon."), div("It is only valid until " + PDTToString.getAsString(aNotAfter, aDisplayLocale) + "."));
}
// Show per endpoint errors
if (aULPerEndpoint.hasChildren())
aULPerProcess.addItem(div("Transport profile ").addChild(code(aEndpoint.getTransportProfile())), aULPerEndpoint);
}
// Show per process errors
if (aULPerProcess.hasChildren())
aULPerDocType.addItem(div("Process ").addChild(code(aProcess.getProcessIdentifier().getURIEncoded()).addClass(CUICoreCSS.CSS_CLASS_NOWRAP)), aULPerProcess);
}
// Show per document type errors
if (aULPerDocType.hasChildren())
aULPerSG.addItem(div("Document type ").addChild(code(aServiceInfo.getDocumentTypeIdentifier().getURIEncoded()).addClass(CUICoreCSS.CSS_CLASS_NOWRAP)), aULPerDocType);
}
}
// Show per service group errors
if (aULPerSG.hasChildren())
aOL.addItem(div("Service group ").addChild(code(aServiceGroup.getParticipantIdentifier().getURIEncoded())), aULPerSG);
}
}
}
// Show results
if (aOL.hasChildren()) {
aNodeList.addChild(warn("The following list of tasks and problems were identified:"));
aNodeList.addChild(aOL);
} else
aNodeList.addChild(success("Great job, no tasks or problems identified!"));
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class PageSecureTransportProfiles method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPTransportProfileManager aTransportProfileMgr = SMPMetaManager.getTransportProfileMgr();
aNodeList.addChild(info("This page lets you create custom transport profiles that can be used in service information endpoints."));
final ICommonsList<ISMPTransportProfile> aList = aTransportProfileMgr.getAllSMPTransportProfiles();
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addChild(new BootstrapButton().addChild("Create new transport profile").setOnClick(createCreateURL(aWPEC)).setIcon(EDefaultIcon.NEW));
final ICommonsSet<String> aExistingIDs = new CommonsHashSet<>(aList, ISMPTransportProfile::getID);
if (!aExistingIDs.containsAll(DEFAULT_PROFILE_IDS)) {
// Show button only on demand
aToolbar.addChild(new BootstrapButton().addChild("Ensure all default transport profiles").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_ENSURE_DEFAULT)).setIcon(EDefaultIcon.PLUS));
}
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Name"), new DTCol("Deprecated?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMPTransportProfile aCurObject : aList) {
final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getID()));
aRow.addCell(aCurObject.getName());
aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isDeprecated(), 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.getID()) : createEmptyAction());
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class PageSecureTransportProfiles method showSelectedObject.
@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ISMPTransportProfile aSelectedObject) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
aNodeList.addChild(getUIHandler().createActionHeader("Show details of transport profile '" + aSelectedObject.getID() + "'"));
final BootstrapViewForm aForm = new BootstrapViewForm();
aForm.addFormGroup(new BootstrapFormGroup().setLabel("ID").setCtrl(aSelectedObject.getID()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Name").setCtrl(aSelectedObject.getName()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Deprecated?").setCtrl(EPhotonCoreText.getYesOrNo(aSelectedObject.isDeprecated(), aDisplayLocale)));
aNodeList.addChild(aForm);
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class SMPRendererSecure method getMenuContent.
@Nonnull
public static IHCNode getMenuContent(@Nonnull final ILayoutExecutionContext aLEC) {
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
final HCNodeList ret = new HCNodeList();
final ISMPSettings aSettings = SMPMetaManager.getSettings();
ret.addChild(BootstrapMenuItemRenderer.createSideBarMenu(aLEC));
final BootstrapSuccessBox aBox = new BootstrapSuccessBox().addClass(CBootstrapCSS.MT_2);
if (SMPMetaManager.getInstance().getBackendConnectionState().isFalse()) {
aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" No database connection: ").addChild(new HCA(CAjax.FUNCTION_BACKEND_CONNECTION_RESET.getInvocationURL(aRequestScope)).addChild("Retry")));
aBox.setType(EBootstrapAlertType.DANGER);
}
// Information on SML usage
if (aSettings.isSMLEnabled()) {
aBox.addChild(new HCDiv().addChild(EDefaultIcon.YES.getAsNode()).addChild(" SML connection is configured."));
if (aSettings.getSMLInfo() == null) {
aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" No SML is selected. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
aBox.setType(EBootstrapAlertType.DANGER);
}
} else {
// Warn only if SML is needed
if (aSettings.isSMLRequired()) {
aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" SML connection is NOT configured. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
aBox.setTypeIfWorse(EBootstrapAlertType.WARNING);
}
}
if (aSettings.isDirectoryIntegrationRequired()) {
if (aSettings.isDirectoryIntegrationEnabled()) {
aBox.addChild(new HCDiv().addChild(EDefaultIcon.YES.getAsNode()).addChild(" Directory support is configured."));
if (StringHelper.hasNoText(aSettings.getDirectoryHostName())) {
aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" No Directory host is provided. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
aBox.setType(EBootstrapAlertType.DANGER);
}
} else {
// Warn only if Directory is needed
aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" Directory support is NOT configured. ").addChild(new HCA(aLEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).addChild("Fix me")));
aBox.setTypeIfWorse(EBootstrapAlertType.WARNING);
}
}
// Information on certificate
if (!SMPKeyManager.isKeyStoreValid()) {
aBox.addChild(new HCDiv().addChild(EDefaultIcon.NO.getAsNode()).addChild(" Certificate configuration is invalid."));
aBox.setType(EBootstrapAlertType.DANGER);
}
ret.addChild(aBox);
return ret;
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class PageSecureSMPIdentifierMappings method _createList.
@Nonnull
private IHCNode _createList(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ICommonsOrderedMap<String, NiceNameEntry> aEntries, @Nonnull final String sSuffix) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCTable aTable = new HCTable(new DTCol("ID"), new DTCol("Name"), new DTCol("Deprecated?")).setID(getID() + sSuffix);
for (final Map.Entry<String, NiceNameEntry> aEntry : aEntries.entrySet()) {
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(aEntry.getKey());
aRow.addCell(aEntry.getValue().getName());
aRow.addCell(EPhotonCoreText.getYesOrNo(aEntry.getValue().isDeprecated(), aDisplayLocale));
}
return new HCNodeList().addChild(aTable).addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
}
Aggregations