Search in sources :

Example 16 with ISMPSettings

use of com.helger.phoss.smp.settings.ISMPSettings in project phoss-smp by phax.

the class SMPWebAppListener method initManagers.

@Override
protected void initManagers() {
    {
        LOGGER.info("Init of ConfigurationFileManager");
        final ConfigurationFileManager aCFM = ConfigurationFileManager.getInstance();
        aCFM.registerConfigurationFile(new ConfigurationFile(new ClassPathResource("log4j2.xml")).setDescription("Log4J2 configuration").setSyntaxHighlightLanguage(EConfigurationFileSyntax.XML));
        aCFM.registerConfigurationFile(new ConfigurationFile(SMPWebAppConfiguration.getSettingsResource()).setDescription("SMP web application configuration").setSyntaxHighlightLanguage(EConfigurationFileSyntax.PROPERTIES));
        final IReadableResource aConfigRes = SMPServerConfiguration.getConfigFile().getReadResource();
        if (aConfigRes != null) {
            aCFM.registerConfigurationFile(new ConfigurationFile(aConfigRes).setDescription("SMP server configuration").setSyntaxHighlightLanguage(EConfigurationFileSyntax.PROPERTIES));
        }
        aCFM.registerAll(PDClientConfiguration.getConfig());
    }
    {
        LOGGER.info("Init of Directory client stuff");
        // If the SMP settings change, the PD client must be re-created
        SMPMetaManager.getSettingsMgr().callbacks().add(x -> PDClientProvider.getInstance().resetPDClient());
        // Callback on BusinessCard manager - if something happens, notify PD
        // server
        final ISMPBusinessCardManager aBusinessCardMgr = SMPMetaManager.getBusinessCardMgr();
        if (aBusinessCardMgr != null) {
            aBusinessCardMgr.bcCallbacks().add(new ISMPBusinessCardCallback() {

                public void onSMPBusinessCardCreatedOrUpdated(@Nonnull final ISMPBusinessCard aBusinessCard) {
                    final ISMPSettings aSettings = SMPMetaManager.getSettings();
                    if (aSettings.isDirectoryIntegrationEnabled() && aSettings.isDirectoryIntegrationAutoUpdate()) {
                        // Notify PD server: add
                        PDClientProvider.getInstance().getPDClient().addServiceGroupToIndex(aBusinessCard.getParticipantIdentifier());
                    }
                }

                public void onSMPBusinessCardDeleted(@Nonnull final ISMPBusinessCard aBusinessCard) {
                    final ISMPSettings aSettings = SMPMetaManager.getSettings();
                    if (aSettings.isDirectoryIntegrationEnabled() && aSettings.isDirectoryIntegrationAutoUpdate()) {
                        // Notify PD server: delete
                        PDClientProvider.getInstance().getPDClient().deleteServiceGroupFromIndex(aBusinessCard.getParticipantIdentifier());
                    }
                }
            });
            // If a service information is create, updated or deleted, also update
            // Business Card at PD
            SMPMetaManager.getServiceInformationMgr().serviceInformationCallbacks().add(new ISMPServiceInformationCallback() {

                @Override
                public void onSMPServiceInformationCreated(@Nonnull final ISMPServiceInformation aServiceInformation) {
                    final ISMPSettings aSettings = SMPMetaManager.getSettings();
                    if (aSettings.isDirectoryIntegrationEnabled() && aSettings.isDirectoryIntegrationAutoUpdate()) {
                        // Only if a business card is present
                        if (aBusinessCardMgr.containsSMPBusinessCardOfServiceGroup(aServiceInformation.getServiceGroup())) {
                            // Notify PD server: update
                            PDClientProvider.getInstance().getPDClient().addServiceGroupToIndex(aServiceInformation.getServiceGroup().getParticipantIdentifier());
                        }
                    }
                }

                @Override
                public void onSMPServiceInformationUpdated(@Nonnull final ISMPServiceInformation aServiceInformation) {
                    onSMPServiceInformationCreated(aServiceInformation);
                }

                @Override
                public void onSMPServiceInformationDeleted(@Nonnull final ISMPServiceInformation aServiceInformation) {
                    onSMPServiceInformationCreated(aServiceInformation);
                }
            });
        }
    }
    {
        LOGGER.info("Init of HTTP and Proxy settings");
        // Register global proxy servers
        ProxySelectorProxySettingsManager.setAsDefault(true);
        final IProxySettings aProxyHttp = SMPServerConfiguration.getAsHttpProxySettings();
        if (aProxyHttp != null) {
            // Register a handler that returns the "http" proxy, if an "http" URL is
            // requested
            ProxySettingsManager.registerProvider((sProtocol, sHost, nPort) -> "http".equals(sProtocol) ? new CommonsArrayList<>(aProxyHttp) : null);
        }
        final IProxySettings aProxyHttps = SMPServerConfiguration.getAsHttpsProxySettings();
        if (aProxyHttps != null) {
            // Register a handler that returns the "https" proxy, if an "https" URL
            // is
            // requested
            ProxySettingsManager.registerProvider((sProtocol, sHost, nPort) -> "https".equals(sProtocol) ? new CommonsArrayList<>(aProxyHttps) : null);
        }
    }
    // Special http client config
    BasePageUtilsHttpClient.HttpClientConfigRegistry.register(new HttpClientConfig("directoryclient", "Directory client settings", PDHttpClientSettings::new));
    LOGGER.info("Finished init of managers");
}
Also used : CSMPServer(com.helger.phoss.smp.CSMPServer) PDClientProvider(com.helger.phoss.smp.app.PDClientProvider) PDTConfig(com.helger.commons.datetime.PDTConfig) ILocaleManager(com.helger.photon.core.locale.ILocaleManager) ProxySelectorProxySettingsManager(com.helger.network.proxy.ProxySelectorProxySettingsManager) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) LoggerFactory(org.slf4j.LoggerFactory) PDClientConfiguration(com.helger.pd.client.PDClientConfiguration) SLF4JBridgeHandler(org.slf4j.bridge.SLF4JBridgeHandler) CApplicationID(com.helger.photon.core.appid.CApplicationID) PDTFactory(com.helger.commons.datetime.PDTFactory) SMPCommonUI(com.helger.phoss.smp.ui.SMPCommonUI) UnifiedResponseDefaultSettings(com.helger.servlet.response.UnifiedResponseDefaultSettings) TimeZone(java.util.TimeZone) ConfigurationFile(com.helger.photon.core.configfile.ConfigurationFile) IReadableResource(com.helger.commons.io.resource.IReadableResource) OffsetDateTime(java.time.OffsetDateTime) IProxySettings(com.helger.network.proxy.settings.IProxySettings) InitializationException(com.helger.commons.exception.InitializationException) IAjaxRegistry(com.helger.photon.ajax.IAjaxRegistry) RegExHelper(com.helger.commons.regex.RegExHelper) RequestTrackerSettings(com.helger.xservlet.requesttrack.RequestTrackerSettings) SMPWebAppConfiguration(com.helger.phoss.smp.app.SMPWebAppConfiguration) WSHelper(com.helger.wsclient.WSHelper) ProxySettingsManager(com.helger.network.proxy.settings.ProxySettingsManager) ServletContextPathHolder(com.helger.servlet.ServletContextPathHolder) ISMPBusinessCard(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard) ISMPBusinessCardManager(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager) MenuPublic(com.helger.phoss.smp.ui.pub.MenuPublic) PhotonGlobalState(com.helger.photon.core.appid.PhotonGlobalState) SMPSecurity(com.helger.phoss.smp.app.SMPSecurity) RequestParameterManager(com.helger.photon.core.requestparam.RequestParameterManager) WebAppListenerBootstrap(com.helger.photon.bootstrap4.servlet.WebAppListenerBootstrap) IPrivilegedAction(com.helger.commons.lang.priviledged.IPrivilegedAction) ISMPServiceInformationCallback(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationCallback) GlobalDebug(com.helger.commons.debug.GlobalDebug) Nonnull(javax.annotation.Nonnull) ConfigurationFileManager(com.helger.photon.core.configfile.ConfigurationFileManager) Nullable(javax.annotation.Nullable) ArrayHelper(com.helger.commons.collection.ArrayHelper) Logger(org.slf4j.Logger) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) BasePageUtilsHttpClient(com.helger.photon.bootstrap4.pages.utils.BasePageUtilsHttpClient) StringHelper(com.helger.commons.string.StringHelper) SMPMetaManager(com.helger.phoss.smp.domain.SMPMetaManager) MenuSecure(com.helger.phoss.smp.ui.secure.MenuSecure) RequestParameterHandlerURLPathNamed(com.helger.photon.core.requestparam.RequestParameterHandlerURLPathNamed) CAjax(com.helger.phoss.smp.ui.ajax.CAjax) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) PDHttpClientSettings(com.helger.pd.client.PDHttpClientSettings) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) SMPServerConfiguration(com.helger.phoss.smp.SMPServerConfiguration) ISMPBusinessCardCallback(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardCallback) HttpClientConfig(com.helger.photon.bootstrap4.pages.utils.BasePageUtilsHttpClient.HttpClientConfig) ServletContext(javax.servlet.ServletContext) EConfigurationFileSyntax(com.helger.photon.core.configfile.EConfigurationFileSyntax) MenuTree(com.helger.photon.core.menu.MenuTree) ISMPBusinessCardCallback(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardCallback) HttpClientConfig(com.helger.photon.bootstrap4.pages.utils.BasePageUtilsHttpClient.HttpClientConfig) ConfigurationFileManager(com.helger.photon.core.configfile.ConfigurationFileManager) Nonnull(javax.annotation.Nonnull) IReadableResource(com.helger.commons.io.resource.IReadableResource) ISMPServiceInformationCallback(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationCallback) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) ISMPBusinessCard(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard) IProxySettings(com.helger.network.proxy.settings.IProxySettings) ISMPBusinessCardManager(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) ConfigurationFile(com.helger.photon.core.configfile.ConfigurationFile)

Example 17 with ISMPSettings

use of com.helger.phoss.smp.settings.ISMPSettings in project phoss-smp by phax.

the class PageSecureServiceGroupMigrationOutbound method validateAndSaveInputParameters.

@Override
protected void validateAndSaveInputParameters(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPParticipantMigration aSelectedObject, @Nonnull final FormErrorList aFormErrors, @Nonnull final EWebPageFormAction eFormAction) {
    final ISMPParticipantMigrationManager aParticipantMigrationMgr = SMPMetaManager.getParticipantMigrationMgr();
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    final String sParticipantID = aWPEC.params().getAsStringTrimmed(FIELD_PARTICIPANT_ID);
    final IParticipantIdentifier aParticipantID = aIdentifierFactory.parseParticipantIdentifier(sParticipantID);
    if (StringHelper.hasNoText(sParticipantID))
        aFormErrors.addFieldError(FIELD_PARTICIPANT_ID, "A Service Group must be selected.");
    else if (aParticipantID == null)
        aFormErrors.addFieldError(FIELD_PARTICIPANT_ID, "The selected Service Group does not exist.");
    else {
        if (aParticipantMigrationMgr.containsOutboundMigrationInProgress(aParticipantID))
            aFormErrors.addFieldError(FIELD_PARTICIPANT_ID, "The migration of the selected Service Group is already in progress.");
    }
    if (aFormErrors.isEmpty()) {
        LOGGER.info("Starting migration of participant ID '" + aParticipantID.getURIEncoded() + "'");
        // Lets take this to the SML
        String sMigrationKey = null;
        if (true) {
            try {
                final ManageParticipantIdentifierServiceCaller aCaller = new ManageParticipantIdentifierServiceCaller(aSettings.getSMLInfo());
                aCaller.setSSLSocketFactory(SMPKeyManager.getInstance().createSSLContext().getSocketFactory());
                // Create a random migration key,
                // Than call SML
                sMigrationKey = aCaller.prepareToMigrate(aParticipantID, SMPServerConfiguration.getSMLSMPID());
                LOGGER.info("Successfully called prepareToMigrate on SML. Created migration key is '" + sMigrationKey + "'");
            } catch (final Exception ex) {
                LOGGER.error("Error invoking prepareToMigrate on SML", ex);
                aWPEC.postRedirectGetInternal(error("Failed to prepare the migration for participant '" + aParticipantID.getURIEncoded() + "' in SML.").addChild(SMPCommonUI.getTechnicalDetailsUI(ex)));
            }
        } else {
            // Dummy for testing only
            sMigrationKey = ManageParticipantIdentifierServiceCaller.createRandomMigrationKey();
            LOGGER.warn("Created migration key '" + sMigrationKey + "' was not send to SML!");
        }
        // Remember internally
        if (aParticipantMigrationMgr.createOutboundParticipantMigration(aParticipantID, sMigrationKey) != null) {
            aWPEC.postRedirectGetInternal(success().addChild(div("The participant migration for '" + aParticipantID.getURIEncoded() + "' was successfully created.")).addChild(div("The created migration key is ").addChild(code(sMigrationKey))));
        } else {
            aWPEC.postRedirectGetInternal(error().addChild(div("Failed to store the participant migration for '" + aParticipantID.getURIEncoded() + "'.")).addChild(div("The created migration key is ").addChild(code(sMigrationKey))).addChild(". Please note it down manually!"));
        }
    }
}
Also used : ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) ISMPParticipantMigrationManager(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager) PDTToString(com.helger.commons.datetime.PDTToString) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 18 with ISMPSettings

use of com.helger.phoss.smp.settings.ISMPSettings in project phoss-smp by phax.

the class PageSecureServiceGroupMigrationOutbound method isActionAllowed.

@Override
protected boolean isActionAllowed(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final EWebPageFormAction eFormAction, @Nullable final ISMPParticipantMigration aSelectedObject) {
    if (eFormAction.isEdit())
        return false;
    if (eFormAction.isCreating()) {
        final ISMPSettings aSettings = SMPMetaManager.getSettings();
        if (aSettings.getSMLInfo() == null)
            return false;
        if (!aSettings.isSMLEnabled())
            return false;
        final ISMPServiceGroupManager aServiceGroupManager = SMPMetaManager.getServiceGroupMgr();
        if (aServiceGroupManager.getSMPServiceGroupCount() <= 0)
            return false;
    }
    return super.isActionAllowed(aWPEC, eFormAction, aSelectedObject);
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings)

Example 19 with ISMPSettings

use of com.helger.phoss.smp.settings.ISMPSettings in project phoss-smp by phax.

the class PageSecureServiceGroupMigrationOutbound method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPParticipantMigrationManager aParticipantMigrationMgr = SMPMetaManager.getParticipantMigrationMgr();
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    final ISMPServiceGroupManager aServiceGroupManager = SMPMetaManager.getServiceGroupMgr();
    {
        final HCOL aOL = new HCOL();
        aOL.addItem("The migration is initiated on this SMP, and the SML is informed about the upcoming migration");
        aOL.addItem("The other SMP, that is taking over the Service Group, must acknowledge the migration by providing the same migration code (created by this SMP) to the SML");
        aOL.addItem("If the migration was successful, the Service Group must be deleted from this SMP, ideally a temporary redirect to the new SMP is created. If the migration was cancelled no action is needed.");
        aNodeList.addChild(info().addChild(div("The process of migrating a Service Group to another SMP consists of multiple steps:")).addChild(aOL).addChild(div("Therefore each open Migration must either be finished (deleting the Service Group) or cancelled (no action taken)." + " If a Migration is cancelled, it can be retried later.")));
    }
    EValidity eCanStartMigration = EValidity.VALID;
    if (aSettings.getSMLInfo() == null) {
        final BootstrapWarnBox aWarn = aNodeList.addAndReturnChild(warn().addChild(div("No valid SML Configuration is selected hence no participant can be migrated.")).addChild(div(new BootstrapButton().addChild("Select SML Configuration in the Settings").setOnClick(aWPEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).setIcon(EDefaultIcon.EDIT))));
        if (aSettings.isSMLEnabled() || aSettings.isSMLRequired()) {
            aWarn.addChild(div(new BootstrapButton().addChild("Create a new SML Configuration").setOnClick(createCreateURL(aWPEC, CMenuSecure.MENU_SML_CONFIGURATION)).setIcon(EDefaultIcon.YES)));
        }
        eCanStartMigration = EValidity.INVALID;
    } else if (!aSettings.isSMLEnabled()) {
        aNodeList.addChild(warn().addChild(div("SML Connection is not enabled hence no participant can be migrated.")).addChild(div(new BootstrapButton().addChild("Enable SML in the Settings").setOnClick(aWPEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).setIcon(EDefaultIcon.EDIT))));
        eCanStartMigration = EValidity.INVALID;
    } else {
        if (aServiceGroupManager.getSMPServiceGroupCount() <= 0) {
            aNodeList.addChild(warn("No Service Group is present! At least one Service Group must be present to migrate it."));
            // Note: makes no to allow to create a new Service Group here and than
            // directly migrate it away
            eCanStartMigration = EValidity.INVALID;
        }
    }
    {
        final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
        aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
        aToolbar.addChild(new BootstrapButton().addChild("Start Participant Migration").setOnClick(createCreateURL(aWPEC)).setDisabled(eCanStartMigration.isInvalid()).setIcon(EDefaultIcon.NEW));
        aNodeList.addChild(aToolbar);
    }
    final BootstrapTabBox aTabBox = aNodeList.addAndReturnChild(new BootstrapTabBox());
    final ICommonsList<ISMPParticipantMigration> aAllMigs = aParticipantMigrationMgr.getAllOutboundParticipantMigrations(null);
    for (final EParticipantMigrationState eState : EParticipantMigrationState.values()) if (eState.isOutboundState()) {
        final ICommonsList<ISMPParticipantMigration> aMatchingMigs = aAllMigs.getAll(x -> x.getState() == eState);
        aTabBox.addTab(eState.getID(), eState.getDisplayName() + " (" + aMatchingMigs.size() + ")", _createTable(aWPEC, aMatchingMigs, eState));
    }
}
Also used : HCOL(com.helger.html.hc.html.grouping.HCOL) WebPageExecutionContext(com.helger.photon.uicore.page.WebPageExecutionContext) EDefaultIcon(com.helger.photon.uicore.icon.EDefaultIcon) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) LoggerFactory(org.slf4j.LoggerFactory) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) AbstractBootstrapWebPageActionHandlerDelete(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandlerDelete) FormErrorList(com.helger.photon.core.form.FormErrorList) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ICommonsIterable(com.helger.commons.collection.impl.ICommonsIterable) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) Nonempty(com.helger.commons.annotation.Nonempty) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) Locale(java.util.Locale) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) CPageParam(com.helger.photon.uicore.css.CPageParam) ISMPParticipantMigrationManager(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager) SMPCommonUI(com.helger.phoss.smp.ui.SMPCommonUI) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) IHCCell(com.helger.html.hc.html.tabular.IHCCell) EWebPageFormAction(com.helger.photon.uicore.page.EWebPageFormAction) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) ICommonsList(com.helger.commons.collection.impl.ICommonsList) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) ICommonsSet(com.helger.commons.collection.impl.ICommonsSet) DataTables(com.helger.photon.uictrls.datatables.DataTables) HCRow(com.helger.html.hc.html.tabular.HCRow) EValidity(com.helger.commons.state.EValidity) AbstractSMPWebPageForm(com.helger.phoss.smp.ui.AbstractSMPWebPageForm) IHCNode(com.helger.html.hc.IHCNode) EParticipantMigrationState(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationState) SMPKeyManager(com.helger.phoss.smp.security.SMPKeyManager) EDTColType(com.helger.photon.uictrls.datatables.column.EDTColType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) ISimpleURL(com.helger.commons.url.ISimpleURL) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapWarnBox(com.helger.photon.bootstrap4.alert.BootstrapWarnBox) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) Logger(org.slf4j.Logger) StringHelper(com.helger.commons.string.StringHelper) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) HCTable(com.helger.html.hc.html.tabular.HCTable) SMPMetaManager(com.helger.phoss.smp.domain.SMPMetaManager) RequestField(com.helger.photon.core.form.RequestField) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) SMPServerConfiguration(com.helger.phoss.smp.SMPServerConfiguration) ESortOrder(com.helger.commons.compare.ESortOrder) AbstractBootstrapWebPageActionHandlerWithQuery(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandlerWithQuery) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) EValidity(com.helger.commons.state.EValidity) ICommonsList(com.helger.commons.collection.impl.ICommonsList) HCNodeList(com.helger.html.hc.impl.HCNodeList) EParticipantMigrationState(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationState) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) BootstrapWarnBox(com.helger.photon.bootstrap4.alert.BootstrapWarnBox) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) HCOL(com.helger.html.hc.html.grouping.HCOL) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) ISMPParticipantMigrationManager(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Example 20 with ISMPSettings

use of com.helger.phoss.smp.settings.ISMPSettings in project phoss-smp by phax.

the class PageSecureTasksProblems method _checkDirectoryConfig.

private void _checkDirectoryConfig(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final HCOL aOL, @Nonnull final OffsetDateTime aNowDT, @Nonnull final OffsetDateTime aNowPlusDT) {
    final ISMPSettings aSMPSettings = SMPMetaManager.getSettings();
    final String sDirectoryName = SMPWebAppConfiguration.getDirectoryName();
    if (aSMPSettings.isDirectoryIntegrationEnabled()) {
        if (StringHelper.hasNoText(aSMPSettings.getDirectoryHostName()))
            aOL.addItem(_createError("An empty " + sDirectoryName + " hostname is provided"), div("A connection to the " + sDirectoryName + " server cannot be establised!"));
        // Check key store
        final LoadedKeyStore aLoadedKeyStore = PDClientConfiguration.loadKeyStore();
        if (aLoadedKeyStore.isFailure()) {
            aOL.addItem(_createError("The " + sDirectoryName + " client key store configuration is invalid."), div(PeppolKeyStoreHelper.getLoadError(aLoadedKeyStore)));
        } else {
            final KeyStore aKeyStore = aLoadedKeyStore.getKeyStore();
            final LoadedKey<KeyStore.PrivateKeyEntry> aLoadedKey = PDClientConfiguration.loadPrivateKey(aKeyStore);
            if (aLoadedKey.isFailure()) {
                aOL.addItem(_createError("The " + sDirectoryName + " client key store could be read, but the private key configuration is invalid."), div(PeppolKeyStoreHelper.getLoadError(aLoadedKey)));
            } else {
                _checkPrivateKey(aWPEC, aOL, aNowDT, aNowPlusDT, aLoadedKey.getKeyEntry());
            }
        }
        // Check trust store
        final LoadedKeyStore aLoadedTrustStore = PDClientConfiguration.loadTrustStore();
        if (aLoadedTrustStore.isFailure()) {
            aOL.addItem(_createError("The " + sDirectoryName + " client trust store configuration is invalid."), div(PeppolKeyStoreHelper.getLoadError(aLoadedTrustStore)));
        } else {
            final KeyStore aTrustStore = aLoadedTrustStore.getKeyStore();
            _iterateTrustStore(aWPEC, aOL, aNowDT, aNowPlusDT, aTrustStore);
        }
    } else {
        // Warn only if Directory is required
        if (aSMPSettings.isDirectoryIntegrationRequired())
            aOL.addItem(_createError("The connection to " + sDirectoryName + " is not enabled."));
    }
}
Also used : ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) LoadedKeyStore(com.helger.security.keystore.LoadedKeyStore) PDTToString(com.helger.commons.datetime.PDTToString) LoadedKeyStore(com.helger.security.keystore.LoadedKeyStore) KeyStore(java.security.KeyStore)

Aggregations

ISMPSettings (com.helger.phoss.smp.settings.ISMPSettings)22 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)12 HCNodeList (com.helger.html.hc.impl.HCNodeList)10 Nonnull (javax.annotation.Nonnull)9 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)8 PDTToString (com.helger.commons.datetime.PDTToString)7 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)7 HCA (com.helger.html.hc.html.textlevel.HCA)6 ManageParticipantIdentifierServiceCaller (com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller)6 ISMPParticipantMigrationManager (com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager)6 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)6 ISMLInfo (com.helger.peppol.sml.ISMLInfo)5 SMPMetaManager (com.helger.phoss.smp.domain.SMPMetaManager)5 ISMPBusinessCardManager (com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager)5 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)5 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)5 Locale (java.util.Locale)5 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)4 ICommonsList (com.helger.commons.collection.impl.ICommonsList)4 ISMPBusinessCard (com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard)4