Search in sources :

Example 1 with HCStrong

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

the class SecureHTMLProvider method _getNavbar.

@Nonnull
private static IHCNode _getNavbar(@Nonnull final SimpleWebExecutionContext aSWEC) {
    final Locale aDisplayLocale = aSWEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aSWEC.getRequestScope();
    final ISimpleURL aLinkToStartPage = aSWEC.getLinkToMenuItem(aSWEC.getMenuTree().getDefaultMenuItemID());
    final BootstrapNavbar aNavbar = new BootstrapNavbar();
    aNavbar.addBrand(new HCNodeList().addChild(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO1).addChild(CPDPublisher.getApplicationTitle())).addChild(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO2).addChild(" Administration")), aLinkToStartPage);
    final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
    {
        final IUser aUser = LoggedInUserManager.getInstance().getCurrentUser();
        aToggleable.addAndReturnText().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2).addChild("Welcome ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MX_2).addChild("Goto public area").setOnClick(LinkHelper.getURLWithContext(AbstractPublicApplicationServlet.SERVLET_DEFAULT_PATH + "/")));
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MX_2).setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)));
    }
    return aNavbar;
}
Also used : Locale(java.util.Locale) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCSpan(com.helger.html.hc.html.textlevel.HCSpan) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapNavbar(com.helger.photon.bootstrap4.navbar.BootstrapNavbar) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapNavbarToggleable(com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable) IUser(com.helger.photon.security.user.IUser) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) Nonnull(javax.annotation.Nonnull)

Example 2 with HCStrong

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

the class SMPRendererPublic method _addNavbarLoginLogout.

private static void _addNavbarLoginLogout(@Nonnull final ILayoutExecutionContext aLEC, @Nonnull final BootstrapNavbar aNavbar) {
    if (!SMPWebAppConfiguration.isPublicLoginEnabled())
        return;
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final IUser aUser = aLEC.getLoggedInUser();
    final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
    if (aUser != null) {
        final Locale aDisplayLocale = aLEC.getDisplayLocale();
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MR_2).addChild("Goto manager").setOnClick(LinkHelper.getURLWithContext(AbstractSecureApplicationServlet.SERVLET_DEFAULT_PATH + "/")));
        aToggleable.addAndReturnText().addClass(CBootstrapCSS.MX_2).addChild("Logged in as ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MX_2).setOnClick(LinkHelper.getURLWithContext(aRequestScope, SMPLogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)));
    } else {
        final BootstrapNavbarNav aNav = aToggleable.addAndReturnNav();
        final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
        {
            final HCDiv aDiv = new HCDiv().addClass(CBootstrapCSS.P_2).addStyle(CCSSProperties.MIN_WIDTH.newValue("400px"));
            aDiv.addChild(SMPCommonUI.createViewLoginForm(aLEC, null));
            aDropDown.addChild(aDiv);
        }
        aNav.addItem().addNavDropDown("Login", aDropDown);
    }
}
Also used : Locale(java.util.Locale) HCDiv(com.helger.html.hc.html.grouping.HCDiv) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) BootstrapNavbarNav(com.helger.photon.bootstrap4.navbar.BootstrapNavbarNav) BootstrapDropdownMenu(com.helger.photon.bootstrap4.dropdown.BootstrapDropdownMenu) IUser(com.helger.photon.security.user.IUser) BootstrapNavbarToggleable(com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton)

Example 3 with HCStrong

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

the class SMPRendererSecure method _getNavbar.

@Nonnull
private static IHCNode _getNavbar(@Nonnull final ILayoutExecutionContext aLEC) {
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final ISimpleURL aLinkToStartPage = aLEC.getLinkToMenuItem(aLEC.getMenuTree().getDefaultMenuItemID());
    final BootstrapNavbar aNavbar = new BootstrapNavbar();
    aNavbar.addBrand(SMPRendererPublic.createLogo(aLEC), aLinkToStartPage);
    aNavbar.addBrand(new HCSpan().addChild(CSMP.getApplicationSuffix() + " Administration"), aLinkToStartPage);
    aNavbar.addAndReturnText().addChild(" [" + SMPServerConfiguration.getSMLSMPID() + "]");
    final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
    {
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MR_2).setOnClick(LinkHelper.getURLWithContext(AbstractPublicApplicationServlet.SERVLET_DEFAULT_PATH + "/")).addChild("Goto public view"));
        final IUser aUser = aLEC.getLoggedInUser();
        aToggleable.addAndReturnText().addClass(CBootstrapCSS.MX_2).addChild("Logged in as ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MX_2).setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)));
    }
    return aNavbar;
}
Also used : Locale(java.util.Locale) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCSpan(com.helger.html.hc.html.textlevel.HCSpan) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) BootstrapNavbar(com.helger.photon.bootstrap4.navbar.BootstrapNavbar) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapNavbarToggleable(com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable) IUser(com.helger.photon.security.user.IUser) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) Nonnull(javax.annotation.Nonnull)

Example 4 with HCStrong

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

the class PublicHTMLProvider method _addNavbarLoginLogout.

private static void _addNavbarLoginLogout(@Nonnull final LayoutExecutionContext aLEC, @Nonnull final BootstrapNavbar aNavbar) {
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    // Documentation
    {
        final BootstrapNavbarNav aNav = aNavbar.addAndReturnNav();
        final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
        aDropDown.createAndAddItem().addChild("Introduction").setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_DOCS_INTRODUCTION));
        aDropDown.createAndAddItem().addChild("How to use it").setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_DOCS_HOW_TO));
        aDropDown.createAndAddItem().addChild("REST API").setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_DOCS_REST_API));
        aDropDown.createAndAddItem().addChild("Export data").setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_DOCS_EXPORT_ALL));
        aDropDown.createAndAddItem().addChild("Specification v1.1.1 (PDF)").setHref(LinkHelper.getURLWithContext("/files/PEPPOL-EDN-Directory-1.1.1-2020-10-15.pdf"));
        aDropDown.createAndAddItem().addChild("Guide for SMP providers (PDF)").setHref(LinkHelper.getURLWithContext("/files/OpenPEPPOL Directory for SMP providers 2016-12-05.pdf"));
        aNav.addItem().addNavDropDown("Documentation", aDropDown);
    }
    // Support
    {
        final BootstrapNavbarNav aNav = aNavbar.addAndReturnNav();
        final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
        if (PDServerConfiguration.isWebAppShowContactPage()) {
            final String sTitle = PDServerConfiguration.getWebAppContactTitle("Contact us");
            final URL aExternalURL = PDServerConfiguration.getWebAppContactExternalURL();
            if (aExternalURL != null)
                aDropDown.createAndAddItem().addChild(sTitle).setHref(new SimpleURL(aExternalURL));
            else
                aDropDown.createAndAddItem().addChild(sTitle).setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_SUPPORT_CONTACT_US));
        }
        aDropDown.createAndAddItem().addChild("Issue tracker (external)").setHref(new SimpleURL("https://github.com/phax/phoss-directory/issues")).setTargetBlank();
        aNav.addItem().addNavDropDown("Support", aDropDown);
    }
    // About
    {
        final BootstrapNavbarNav aNav = aNavbar.addAndReturnNav();
        final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
        aDropDown.createAndAddItem().addChild("About " + CPDPublisher.getApplication()).setHref(aLEC.getLinkToMenuItem(CMenuPublic.MENU_ABOUT));
        aNav.addItem().addNavDropDown("About", aDropDown);
    }
    final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
    // Login etc
    {
        final IUser aUser = LoggedInUserManager.getInstance().getCurrentUser();
        if (aUser != null) {
            aToggleable.addAndReturnText().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MR_2).addChild("Welcome ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
            if (SecurityHelper.hasUserRole(aUser.getID(), AppSecurity.ROLE_CONFIG_ID)) {
                aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MR_2).addChild("Goto secure area").setOnClick(LinkHelper.getURLWithContext(AbstractSecureApplicationServlet.SERVLET_DEFAULT_PATH + "/")));
            }
            aToggleable.addChild(new BootstrapButton().setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)).addStyle(CCSSProperties.MARGIN_RIGHT.newValue("8px")));
        } else {
            final BootstrapNavbarNav aNav = aToggleable.addAndReturnNav();
            final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
            {
                final HCDiv aDiv = new HCDiv().addClass(CBootstrapCSS.P_2).addStyle(CCSSProperties.MIN_WIDTH.newValue("400px"));
                aDiv.addChild(AppCommonUI.createViewLoginForm(aLEC, null));
                aDropDown.addChild(aDiv);
            }
            aNav.addItem().addNavDropDown("Login", aDropDown);
        }
    }
}
Also used : Locale(java.util.Locale) HCDiv(com.helger.html.hc.html.grouping.HCDiv) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) BootstrapNavbarNav(com.helger.photon.bootstrap4.navbar.BootstrapNavbarNav) BootstrapDropdownMenu(com.helger.photon.bootstrap4.dropdown.BootstrapDropdownMenu) BootstrapNavbarToggleable(com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable) IUser(com.helger.photon.security.user.IUser) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) URL(java.net.URL) SimpleURL(com.helger.commons.url.SimpleURL) ISimpleURL(com.helger.commons.url.ISimpleURL) SimpleURL(com.helger.commons.url.SimpleURL) ISimpleURL(com.helger.commons.url.ISimpleURL)

Example 5 with HCStrong

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

the class PDCommonUI method createCertificateDetailsTable.

@Nonnull
public static BootstrapTable createCertificateDetailsTable(@Nonnull final X509Certificate aX509Cert, @Nonnull final LocalDateTime aNowLDT, @Nonnull final Locale aDisplayLocale) {
    final LocalDateTime aNotBefore = PDTFactory.createLocalDateTime(aX509Cert.getNotBefore());
    final LocalDateTime aNotAfter = PDTFactory.createLocalDateTime(aX509Cert.getNotAfter());
    final PublicKey aPublicKey = aX509Cert.getPublicKey();
    final BootstrapTable aCertDetails = new BootstrapTable(HCCol.star(), HCCol.star());
    aCertDetails.addBodyRow().addCell("Version:").addCell(Integer.toString(aX509Cert.getVersion()));
    aCertDetails.addBodyRow().addCell("Subject:").addCell(aX509Cert.getSubjectX500Principal().getName());
    aCertDetails.addBodyRow().addCell("Issuer:").addCell(aX509Cert.getIssuerX500Principal().getName());
    aCertDetails.addBodyRow().addCell("Serial number:").addCell(aX509Cert.getSerialNumber().toString(16));
    aCertDetails.addBodyRow().addCell("Valid from:").addCell(new HCTextNode(PDTToString.getAsString(aNotBefore, aDisplayLocale)), aNowLDT.isBefore(aNotBefore) ? new HCStrong().addChild(" !!!NOT YET VALID!!!") : null);
    aCertDetails.addBodyRow().addCell("Valid to:").addCell(new HCTextNode(PDTToString.getAsString(aNotAfter, aDisplayLocale)), aNowLDT.isAfter(aNotAfter) ? new HCStrong().addChild(" !!!NO LONGER VALID!!!") : new HCDiv().addChild("Valid for: " + PDTDisplayHelper.getPeriodTextEN(aNowLDT, aNotAfter)));
    if (aPublicKey instanceof RSAPublicKey) {
        // Special handling for RSA
        aCertDetails.addBodyRow().addCell("Public key:").addCell(aX509Cert.getPublicKey().getAlgorithm() + " (" + ((RSAPublicKey) aPublicKey).getModulus().bitLength() + " bits)");
    } else {
        // Usually EC or DSA key
        aCertDetails.addBodyRow().addCell("Public key:").addCell(aX509Cert.getPublicKey().getAlgorithm());
    }
    aCertDetails.addBodyRow().addCell("Signature algorithm:").addCell(aX509Cert.getSigAlgName() + " (" + aX509Cert.getSigAlgOID() + ")");
    return aCertDetails;
}
Also used : LocalDateTime(java.time.LocalDateTime) HCDiv(com.helger.html.hc.html.grouping.HCDiv) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) RSAPublicKey(java.security.interfaces.RSAPublicKey) RSAPublicKey(java.security.interfaces.RSAPublicKey) PublicKey(java.security.PublicKey) HCTextNode(com.helger.html.hc.impl.HCTextNode) Nonnull(javax.annotation.Nonnull)

Aggregations

HCStrong (com.helger.html.hc.html.textlevel.HCStrong)5 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)4 BootstrapNavbarToggleable (com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable)4 IUser (com.helger.photon.security.user.IUser)4 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)4 Locale (java.util.Locale)4 ISimpleURL (com.helger.commons.url.ISimpleURL)3 HCDiv (com.helger.html.hc.html.grouping.HCDiv)3 Nonnull (javax.annotation.Nonnull)3 HCSpan (com.helger.html.hc.html.textlevel.HCSpan)2 BootstrapDropdownMenu (com.helger.photon.bootstrap4.dropdown.BootstrapDropdownMenu)2 BootstrapNavbar (com.helger.photon.bootstrap4.navbar.BootstrapNavbar)2 BootstrapNavbarNav (com.helger.photon.bootstrap4.navbar.BootstrapNavbarNav)2 SimpleURL (com.helger.commons.url.SimpleURL)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 HCTextNode (com.helger.html.hc.impl.HCTextNode)1 BootstrapTable (com.helger.photon.bootstrap4.table.BootstrapTable)1 URL (java.net.URL)1 PublicKey (java.security.PublicKey)1 RSAPublicKey (java.security.interfaces.RSAPublicKey)1