Search in sources :

Example 1 with HCCode

use of com.helger.html.hc.html.textlevel.HCCode in project phoss-directory by phax.

the class PageSecureAdminSMLConfiguration method showInputForm.

@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMLInfo aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
    final boolean bEdit = eFormAction.isEdit();
    aForm.addChild(getUIHandler().createActionHeader(bEdit ? "Edit SML configuration '" + aSelectedObject.getDisplayName() + "'" : "Create new SML configuration"));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Name").setCtrl(new HCEdit(new RequestField(FIELD_DISPLAY_NAME, aSelectedObject != null ? aSelectedObject.getDisplayName() : null))).setHelpText("The name of the SML configuration. This is for informational purposes only and has no effect on the functionality.").setErrorList(aFormErrors.getListOfField(FIELD_DISPLAY_NAME)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("DNS Zone").setCtrl(new HCEdit(new RequestField(FIELD_DNS_ZONE, aSelectedObject != null ? aSelectedObject.getDNSZone() : null))).setHelpText(new HCTextNode("The name of the DNS Zone that this SML is working upon (e.g. "), new HCCode().addChild("sml.peppolcentral.org"), new HCTextNode("). The value will automatically converted to all-lowercase!")).setErrorList(aFormErrors.getListOfField(FIELD_DNS_ZONE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Management Service URL").setCtrl(new HCEdit(new RequestField(FIELD_MANAGEMENT_ADDRESS_URL, aSelectedObject != null ? aSelectedObject.getManagementServiceURL() : null))).setHelpText("The service URL where the SML management application is running on including the host name. It may not contain the '" + CSMLDefault.MANAGEMENT_SERVICE_METADATA + "' or '" + CSMLDefault.MANAGEMENT_SERVICE_PARTICIPANTIDENTIFIER + "' path elements!").setErrorList(aFormErrors.getListOfField(FIELD_MANAGEMENT_ADDRESS_URL)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Client Certificate required?").setCtrl(new HCCheckBox(new RequestFieldBoolean(FIELD_CLIENT_CERTIFICATE_REQUIRED, aSelectedObject != null ? aSelectedObject.isClientCertificateRequired() : true))).setHelpText("Check this if this SML requires a client certificate for access. Both Peppol production SML and SMK require a client certificate. Only a locally running SML software may not require a client certificate.").setErrorList(aFormErrors.getListOfField(FIELD_CLIENT_CERTIFICATE_REQUIRED)));
}
Also used : HCCode(com.helger.html.hc.html.textlevel.HCCode) RequestFieldBoolean(com.helger.photon.core.form.RequestFieldBoolean) HCEdit(com.helger.html.hc.html.forms.HCEdit) HCCheckBox(com.helger.html.hc.html.forms.HCCheckBox) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) HCTextNode(com.helger.html.hc.impl.HCTextNode) RequestField(com.helger.photon.core.form.RequestField)

Example 2 with HCCode

use of com.helger.html.hc.html.textlevel.HCCode in project phoss-smp by phax.

the class PageSecureEndpointChangeCertificate method _getCertificateDisplay.

@Nonnull
private static IHCNode _getCertificateDisplay(@Nullable final String sCert, @Nonnull final Locale aDisplayLocale) {
    X509Certificate aEndpointCert = null;
    try {
        aEndpointCert = CertificateHelper.convertStringToCertficate(sCert);
    } catch (final Exception ex) {
    // Ignore
    }
    if (aEndpointCert == null) {
        final int nDisplayLen = 20;
        final String sCertPart = (sCert.length() > nDisplayLen ? sCert.substring(0, 20) + "..." : sCert);
        final HCDiv ret = new HCDiv().addChild("Invalid certificate").addChild(sCert.length() > nDisplayLen ? " starting with: " : ": ");
        if (sCertPart.length() > 0)
            ret.addChild(new HCCode().addChild(sCertPart));
        else
            ret.addChild(new HCEM().addChild("empty"));
        return ret;
    }
    final HCNodeList ret = new HCNodeList();
    ret.addChild(new HCDiv().addChild("Issuer: " + aEndpointCert.getIssuerX500Principal().toString()));
    ret.addChild(new HCDiv().addChild("Subject: " + aEndpointCert.getSubjectX500Principal().toString()));
    final LocalDateTime aNotBefore = PDTFactory.createLocalDateTime(aEndpointCert.getNotBefore());
    ret.addChild(new HCDiv().addChild("Not before: " + PDTToString.getAsString(aNotBefore, aDisplayLocale)));
    final LocalDateTime aNotAfter = PDTFactory.createLocalDateTime(aEndpointCert.getNotAfter());
    ret.addChild(new HCDiv().addChild("Not after: " + PDTToString.getAsString(aNotAfter, aDisplayLocale)));
    return ret;
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) LocalDateTime(java.time.LocalDateTime) HCEM(com.helger.html.hc.html.textlevel.HCEM) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCCode(com.helger.html.hc.html.textlevel.HCCode) PDTToString(com.helger.commons.datetime.PDTToString) X509Certificate(java.security.cert.X509Certificate) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) SMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint) Nonnull(javax.annotation.Nonnull)

Example 3 with HCCode

use of com.helger.html.hc.html.textlevel.HCCode in project phoss-smp by phax.

the class PageSecureServiceGroup method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
    final ISMPBusinessCardManager aBCMgr = SMPMetaManager.getBusinessCardMgr();
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    final ESMPRESTType eRESTType = SMPServerConfiguration.getRESTType();
    final boolean bShowExtensionDetails = SMPWebAppConfiguration.isServiceGroupsExtensionsShow();
    final boolean bShowBusinessCardName = CSMP.ENABLE_ISSUE_56 && aSettings.isDirectoryIntegrationEnabled();
    final ICommonsList<ISMPServiceGroup> aAllServiceGroups = aServiceGroupMgr.getAllSMPServiceGroups();
    final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
    aToolbar.addButton("Create new Service group", createCreateURL(aWPEC), EDefaultIcon.NEW);
    aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
    if (aSettings.isSMLRequired() || aSettings.isSMLEnabled()) {
        // Disable button if no SML URL is configured
        // Disable button if no service group is present
        aToolbar.addAndReturnButton("Check DNS state", aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_CHECK_DNS), EDefaultIcon.MAGNIFIER).setDisabled(aSettings.getSMLDNSZone() == null || aAllServiceGroups.isEmpty() || !aSettings.isSMLEnabled());
    }
    aNodeList.addChild(aToolbar);
    final boolean bShowDetails = aAllServiceGroups.size() <= 1000;
    final HCTable aTable = new HCTable(new DTCol("Participant ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Owner"), bShowBusinessCardName ? new DTCol("Business Card Name") : null, new DTCol(span(bShowExtensionDetails ? "Ext" : "Ext?").setTitle("Is an Extension present?")), bShowDetails ? new DTCol(span("Docs").setTitle("Number of assigned document types")).setDisplayType(EDTColType.INT, aDisplayLocale) : null, bShowDetails ? new DTCol(span("Procs").setTitle("Number of assigned processes")).setDisplayType(EDTColType.INT, aDisplayLocale) : null, bShowDetails ? new DTCol(span("EPs").setTitle("Number of assigned endpoints")).setDisplayType(EDTColType.INT, aDisplayLocale) : null, new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final ISMPServiceGroup aCurObject : aAllServiceGroups) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
        final String sDisplayName = aCurObject.getParticipantIdentifier().getURIEncoded();
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(sDisplayName));
        aRow.addCell(SMPCommonUI.getOwnerName(aCurObject.getOwnerID()));
        if (bShowBusinessCardName) {
            IHCNode aName = null;
            final ISMPBusinessCard aBC = aBCMgr.getSMPBusinessCardOfServiceGroup(aCurObject);
            if (aBC != null) {
                final SMPBusinessCardEntity aEntity = aBC.getEntityAtIndex(0);
                if (aEntity != null && aEntity.names().isNotEmpty())
                    aName = HCTextNode.createOnDemand(aEntity.names().getFirst().getName());
            }
            aRow.addCell(aName);
        }
        if (bShowExtensionDetails) {
            if (aCurObject.extensions().isNotEmpty())
                aRow.addCell(new HCCode().addChildren(HCExtHelper.nl2divList(aCurObject.getFirstExtensionXML())));
            else
                aRow.addCell();
        } else {
            aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.extensions().isNotEmpty(), aDisplayLocale));
        }
        if (bShowDetails) {
            int nProcesses = 0;
            int nEndpoints = 0;
            final ICommonsList<ISMPServiceInformation> aSIs = aServiceInfoMgr.getAllSMPServiceInformationOfServiceGroup(aCurObject);
            for (final ISMPServiceInformation aSI : aSIs) {
                nProcesses += aSI.getProcessCount();
                nEndpoints += aSI.getTotalEndpointCount();
            }
            aRow.addCell(Integer.toString(aSIs.size()));
            aRow.addCell(Integer.toString(nProcesses));
            aRow.addCell(Integer.toString(nEndpoints));
        }
        final HCNodeList aActions = new HCNodeList();
        aActions.addChildren(createEditLink(aWPEC, aCurObject, "Edit " + sDisplayName), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject, "Copy " + sDisplayName), new HCTextNode(" "), createDeleteLink(aWPEC, aCurObject, "Delete " + sDisplayName), new HCTextNode(" "), new HCA(LinkHelper.getURLWithServerAndContext(aCurObject.getParticipantIdentifier().getURIPercentEncoded())).setTitle("Perform SMP query on " + sDisplayName).setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
        if (eRESTType.isCompleteServiceGroupSupported()) {
            aActions.addChildren(new HCTextNode(" "), new HCA(LinkHelper.getURLWithServerAndContext("complete/" + aCurObject.getParticipantIdentifier().getURIPercentEncoded())).setTitle("Perform complete SMP query on " + sDisplayName).setTargetBlank().addChild(EFamFamIcon.SCRIPT_LINK.getAsNode()));
        }
        aRow.addCell(aActions);
    }
    final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
    aNodeList.addChild(aTable).addChild(aDataTables);
}
Also used : Locale(java.util.Locale) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCRow(com.helger.html.hc.html.tabular.HCRow) ISMPBusinessCard(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) DataTables(com.helger.photon.uictrls.datatables.DataTables) ISMPServiceInformationManager(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager) HCCode(com.helger.html.hc.html.textlevel.HCCode) ESMPRESTType(com.helger.phoss.smp.ESMPRESTType) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) HCA(com.helger.html.hc.html.textlevel.HCA) SMPBusinessCardEntity(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardEntity) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) ISMPBusinessCardManager(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager) HCTable(com.helger.html.hc.html.tabular.HCTable) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) HCTextNode(com.helger.html.hc.impl.HCTextNode) IHCNode(com.helger.html.hc.IHCNode)

Example 4 with HCCode

use of com.helger.html.hc.html.textlevel.HCCode in project phoss-directory by phax.

the class PDCommonUI method getDocumentTypeIDDetails.

@Nonnull
public static HCUL getDocumentTypeIDDetails(@Nonnull final IPeppolDocumentTypeIdentifierParts aParts) {
    final HCUL aUL = new HCUL();
    aUL.addItem().addChild("Root namespace: ").addChild(new HCCode().addChild(aParts.getRootNS()));
    aUL.addItem().addChild("Local name: ").addChild(new HCCode().addChild(aParts.getLocalName()));
    aUL.addItem().addChild("Customization ID: ").addChild(new HCCode().addChild(aParts.getCustomizationID()));
    aUL.addItem().addChild("Version: ").addChild(new HCCode().addChild(aParts.getVersion()));
    return aUL;
}
Also used : HCUL(com.helger.html.hc.html.grouping.HCUL) HCCode(com.helger.html.hc.html.textlevel.HCCode) Nonnull(javax.annotation.Nonnull)

Example 5 with HCCode

use of com.helger.html.hc.html.textlevel.HCCode in project phoss-directory by phax.

the class NiceNameUI method _createFormattedID.

@Nonnull
private static IHCNode _createFormattedID(@Nonnull final String sID, @Nullable final String sName, @Nullable final EBootstrapBadgeType eType, final boolean bIsDeprecated, final boolean bInDetails) {
    if (sName == null) {
        // No nice name present
        if (bInDetails)
            return new HCCode().addChild(sID);
        return new HCTextNode(sID);
    }
    final HCNodeList ret = new HCNodeList();
    ret.addChild(new BootstrapBadge(eType).addChild(sName));
    if (bIsDeprecated) {
        ret.addChild(" ").addChild(new BootstrapBadge(EBootstrapBadgeType.WARNING).addChild("Identifier is deprecated"));
    }
    if (bInDetails) {
        ret.addChild(new HCSmall().addChild(" (").addChild(new HCCode().addChild(sID)).addChild(")"));
    }
    return ret;
}
Also used : HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapBadge(com.helger.photon.bootstrap4.badge.BootstrapBadge) HCCode(com.helger.html.hc.html.textlevel.HCCode) HCSmall(com.helger.html.hc.html.textlevel.HCSmall) HCTextNode(com.helger.html.hc.impl.HCTextNode) Nonnull(javax.annotation.Nonnull)

Aggregations

HCCode (com.helger.html.hc.html.textlevel.HCCode)7 Nonnull (javax.annotation.Nonnull)5 HCNodeList (com.helger.html.hc.impl.HCNodeList)4 HCTextNode (com.helger.html.hc.impl.HCTextNode)4 HCUL (com.helger.html.hc.html.grouping.HCUL)2 HCSmall (com.helger.html.hc.html.textlevel.HCSmall)2 BootstrapBadge (com.helger.photon.bootstrap4.badge.BootstrapBadge)2 PDTToString (com.helger.commons.datetime.PDTToString)1 ISimpleURL (com.helger.commons.url.ISimpleURL)1 IHCNode (com.helger.html.hc.IHCNode)1 HCCheckBox (com.helger.html.hc.html.forms.HCCheckBox)1 HCEdit (com.helger.html.hc.html.forms.HCEdit)1 HCDiv (com.helger.html.hc.html.grouping.HCDiv)1 HCRow (com.helger.html.hc.html.tabular.HCRow)1 HCTable (com.helger.html.hc.html.tabular.HCTable)1 HCA (com.helger.html.hc.html.textlevel.HCA)1 HCEM (com.helger.html.hc.html.textlevel.HCEM)1 ESMPRESTType (com.helger.phoss.smp.ESMPRESTType)1 ISMPBusinessCard (com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard)1 ISMPBusinessCardManager (com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager)1