Search in sources :

Example 96 with HCNodeList

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!"));
}
Also used : Locale(java.util.Locale) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ICommonsList(com.helger.commons.collection.impl.ICommonsList) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMPServiceInformationManager(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) ESMPTransportProfile(com.helger.peppol.smp.ESMPTransportProfile) CertificateException(java.security.cert.CertificateException) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) X509Certificate(java.security.cert.X509Certificate) HCUL(com.helger.html.hc.html.grouping.HCUL) XMLOffsetDateTime(com.helger.commons.datetime.XMLOffsetDateTime) OffsetDateTime(java.time.OffsetDateTime) HCOL(com.helger.html.hc.html.grouping.HCOL) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess)

Example 97 with HCNodeList

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);
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) HCTable(com.helger.html.hc.html.tabular.HCTable) ISMPTransportProfileManager(com.helger.phoss.smp.domain.transportprofile.ISMPTransportProfileManager) ISMPTransportProfile(com.helger.peppol.smp.ISMPTransportProfile) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) HCTextNode(com.helger.html.hc.impl.HCTextNode) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) DataTables(com.helger.photon.uictrls.datatables.DataTables) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)

Example 98 with HCNodeList

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);
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup)

Example 99 with HCNodeList

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;
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapSuccessBox(com.helger.photon.bootstrap4.alert.BootstrapSuccessBox) Nonnull(javax.annotation.Nonnull)

Example 100 with HCNodeList

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));
}
Also used : Locale(java.util.Locale) HCTable(com.helger.html.hc.html.tabular.HCTable) HCNodeList(com.helger.html.hc.impl.HCNodeList) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) HCRow(com.helger.html.hc.html.tabular.HCRow) NiceNameEntry(com.helger.phoss.smp.nicename.NiceNameEntry) ICommonsOrderedMap(com.helger.commons.collection.impl.ICommonsOrderedMap) Map(java.util.Map) Nonnull(javax.annotation.Nonnull)

Aggregations

HCNodeList (com.helger.html.hc.impl.HCNodeList)123 Locale (java.util.Locale)74 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)42 Nonnull (javax.annotation.Nonnull)41 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)40 HCA (com.helger.html.hc.html.textlevel.HCA)35 PDTToString (com.helger.commons.datetime.PDTToString)28 ISimpleURL (com.helger.commons.url.ISimpleURL)27 HCRow (com.helger.html.hc.html.tabular.HCRow)26 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)24 RequestField (com.helger.photon.core.form.RequestField)24 DTCol (com.helger.photon.uictrls.datatables.column.DTCol)24 HCTable (com.helger.html.hc.html.tabular.HCTable)23 BootstrapViewForm (com.helger.photon.bootstrap4.form.BootstrapViewForm)23 BootstrapForm (com.helger.photon.bootstrap4.form.BootstrapForm)21 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)21 FormErrorList (com.helger.photon.core.form.FormErrorList)21 BootstrapDataTables (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)20 HCTextNode (com.helger.html.hc.impl.HCTextNode)19 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)19