Search in sources :

Example 6 with BooleanField

use of org.codice.ddf.admin.common.fields.base.scalar.BooleanField in project admin-console-beta by connexta.

the class InstallEmbeddedLdap method performFunction.

@Override
@SuppressWarnings("squid:SwitchLastCaseIsDefaultCheck")
public BooleanField performFunction() {
    Configurator configurator = configuratorFactory.getConfigurator();
    configurator.add(featureActions.start(EMBEDDED_LDAP_FEATURE));
    switch(useCase.getValue()) {
        case AUTHENTICATION:
            configurator.add(featureActions.start(LDAP_LOGIN_FEATURE));
            configurator.add(featureActions.start(DEFAULT_EMBEDDED_LDAP_LOGIN_CONFIG_FEATURE));
            break;
        case ATTRIBUTE_STORE:
            configurator.add(featureActions.start(LDAP_CLAIMS_HANDLER_FEATURE));
            configurator.add(featureActions.start(DEFAULT_EMBEDDED_LDAP_CLAIMS_HANDLER_CONFIG_FEATURE));
            break;
        case AUTHENTICATION_AND_ATTRIBUTE_STORE:
            configurator.add(featureActions.start(LDAP_LOGIN_FEATURE));
            configurator.add(featureActions.start(LDAP_CLAIMS_HANDLER_FEATURE));
            configurator.add(featureActions.start(ALL_DEFAULT_EMBEDDED_LDAP_CONFIG_FEATURE));
            break;
    }
    OperationReport report = configurator.commit("Installed Embedded LDAP");
    if (report.containsFailedResults()) {
        addErrorMessage(failedPersistError());
    }
    return new BooleanField(!containsErrorMsgs());
}
Also used : BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) Configurator(org.codice.ddf.admin.configurator.Configurator) OperationReport(org.codice.ddf.admin.configurator.OperationReport)

Example 7 with BooleanField

use of org.codice.ddf.admin.common.fields.base.scalar.BooleanField in project admin-console-beta by connexta.

the class CreateLdapConfiguration method performFunction.

@Override
public BooleanField performFunction() {
    Configurator configurator = configuratorSuite.getConfiguratorFactory().getConfigurator();
    String authType = config.settingsField().useCase();
    if (authType.equalsIgnoreCase(AUTHENTICATION) || authType.equalsIgnoreCase(AUTHENTICATION_AND_ATTRIBUTE_STORE)) {
        Map<String, Object> ldapLoginServiceProps = ldapServiceCommons.ldapConfigurationToLdapLoginService(config);
        configurator.add(configuratorSuite.getFeatureActions().start(LdapLoginServiceProperties.LDAP_LOGIN_FEATURE));
        configurator.add(configuratorSuite.getManagedServiceActions().create(LdapLoginServiceProperties.LDAP_LOGIN_MANAGED_SERVICE_FACTORY_PID, ldapLoginServiceProps));
    }
    if (authType.equalsIgnoreCase(ATTRIBUTE_STORE) || authType.equalsIgnoreCase(AUTHENTICATION_AND_ATTRIBUTE_STORE)) {
        Path newAttributeMappingPath = Paths.get(System.getProperty("ddf.home"), "etc", "ws-security", "ldapAttributeMap-" + UUID.randomUUID().toString() + ".props");
        Map<String, Object> ldapClaimsServiceProps = ldapServiceCommons.ldapConfigToLdapClaimsHandlerService(config, newAttributeMappingPath.toString());
        configurator.add(configuratorSuite.getPropertyActions().create(newAttributeMappingPath, config.claimsMapping()));
        configurator.add(configuratorSuite.getFeatureActions().start(LdapClaimsHandlerServiceProperties.LDAP_CLAIMS_HANDLER_FEATURE));
        configurator.add(configuratorSuite.getManagedServiceActions().create(LdapClaimsHandlerServiceProperties.LDAP_CLAIMS_HANDLER_MANAGED_SERVICE_FACTORY_PID, ldapClaimsServiceProps));
    }
    OperationReport report = AccessController.doPrivileged((PrivilegedAction<OperationReport>) () -> configurator.commit("Creating LDAP configuration."));
    if (report.containsFailedResults()) {
        addErrorMessage(failedPersistError());
    }
    return new BooleanField(!containsErrorMsgs());
}
Also used : Path(java.nio.file.Path) BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) Configurator(org.codice.ddf.admin.configurator.Configurator) OperationReport(org.codice.ddf.admin.configurator.OperationReport)

Aggregations

BooleanField (org.codice.ddf.admin.common.fields.base.scalar.BooleanField)7 LdapConnectionAttempt (org.codice.ddf.admin.ldap.commons.LdapConnectionAttempt)5 Connection (org.forgerock.opendj.ldap.Connection)3 IOException (java.io.IOException)2 Configurator (org.codice.ddf.admin.configurator.Configurator)2 OperationReport (org.codice.ddf.admin.configurator.OperationReport)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Path (java.nio.file.Path)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Field (org.codice.ddf.admin.api.Field)1 FunctionField (org.codice.ddf.admin.api.fields.FunctionField)1 TestFunctionField (org.codice.ddf.admin.common.fields.base.function.TestFunctionField)1 StringField (org.codice.ddf.admin.common.fields.base.scalar.StringField)1 DefaultMessages (org.codice.ddf.admin.common.report.message.DefaultMessages)1 LdapMessages (org.codice.ddf.admin.ldap.commons.LdapMessages)1 LdapMessages.userAttributeNotFoundError (org.codice.ddf.admin.ldap.commons.LdapMessages.userAttributeNotFoundError)1 LdapTestingUtils (org.codice.ddf.admin.ldap.commons.LdapTestingUtils)1