Search in sources :

Example 1 with BooleanField

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

the class LdapTestConnection method performFunction.

// Possible message types: CANNOT_CONFIGURE, CANNOT_CONNECT
@Override
public BooleanField performFunction() {
    LdapConnectionAttempt connectionAttempt = utils.getLdapConnection(connection);
    addResultMessages(connectionAttempt.messages());
    return new BooleanField(connectionAttempt.connection().isPresent());
}
Also used : BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) LdapConnectionAttempt(org.codice.ddf.admin.ldap.commons.LdapConnectionAttempt)

Example 2 with BooleanField

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

the class LdapTestDirectorySettings method performFunction.

@Override
public BooleanField performFunction() {
    try (LdapConnectionAttempt connectionAttempt = utils.bindUserToLdapConnection(conn, bindInfo)) {
        addErrorMessages(connectionAttempt);
        if (containsErrorMsgs()) {
            return new BooleanField(false);
        }
        Connection ldapConnection = connectionAttempt.getResult();
        addErrorMessages(utils.checkDirExists(settings.baseGroupDnField(), ldapConnection));
        addErrorMessages(utils.checkDirExists(settings.baseUserDnField(), ldapConnection));
        // Short-circuit return here, if either the user or group directory does not exist
        if (containsErrorMsgs()) {
            return new BooleanField(false);
        }
        checkUsersInDir(ldapConnection);
        // Short-circuit return here, if there are no users in base dir
        if (containsErrorMsgs()) {
            return new BooleanField(false);
        }
        if (settings.useCaseField().isAttributeStore()) {
            // Check if group objectClass is on at least one entry in the directory
            checkGroupObjectClass(ldapConnection);
            // Don't check the group if there is no entry with the correct objectClass
            if (containsErrorMsgs()) {
                return new BooleanField(false);
            }
            // Then, check that there is a group entry (of the correct objectClass) that has
            // any member references
            checkGroup(ldapConnection);
        }
    } catch (IOException e) {
        LOGGER.warn("Error closing LDAP connection", e);
    }
    return new BooleanField(!containsErrorMsgs());
}
Also used : BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) Connection(org.forgerock.opendj.ldap.Connection) IOException(java.io.IOException) LdapConnectionAttempt(org.codice.ddf.admin.ldap.commons.LdapConnectionAttempt)

Example 3 with BooleanField

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

the class LdapTestBind method performFunction.

// Possible message types: CANNOT_CONFIGURE, CANNOT_CONNECT, CANNOT_BIND
@Override
public BooleanField performFunction() {
    LdapConnectionAttempt connectionAttempt = utils.bindUserToLdapConnection(conn, creds);
    addResultMessages(connectionAttempt.messages());
    return new BooleanField(connectionAttempt.connection().isPresent());
}
Also used : BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) LdapConnectionAttempt(org.codice.ddf.admin.ldap.commons.LdapConnectionAttempt)

Example 4 with BooleanField

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

the class LdapTestSettings method performFunction.

@Override
public BooleanField performFunction() {
    LdapConnectionAttempt connectionAttempt = utils.bindUserToLdapConnection(conn, bindInfo);
    addResultMessages(connectionAttempt.messages());
    if (!connectionAttempt.connection().isPresent()) {
        return new BooleanField(false);
    }
    Connection ldapConnection = connectionAttempt.connection().get();
    if (!checkDirExists(settings.baseUserDn(), ldapConnection)) {
        addArgumentMessage(BASE_USER_DN_NOT_FOUND.setPath(settings.path()));
    } else {
        addArgumentMessages(checkUsersInDir(settings, ldapConnection));
    }
    if (!checkDirExists(settings.baseGroupDn(), ldapConnection)) {
        addArgumentMessage(BASE_GROUP_DN_NOT_FOUND.setPath(settings.path()));
    } else {
        // First check the group objectClass is on at least one entry in the directory
        addArgumentMessages(checkGroupObjectClass(settings, ldapConnection));
        // Then, check that there is a group entry (of the correct objectClass) that has
        // any member references
        addArgumentMessages(checkGroup(settings, ldapConnection));
    }
    return new BooleanField(!containsErrorMsgs());
}
Also used : BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) Connection(org.forgerock.opendj.ldap.Connection) LdapConnectionAttempt(org.codice.ddf.admin.ldap.commons.LdapConnectionAttempt)

Example 5 with BooleanField

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

the class LdapTestClaimMappings method performFunction.

@Override
public BooleanField performFunction() {
    try (LdapConnectionAttempt connectionAttempt = utils.bindUserToLdapConnection(conn, bindInfo)) {
        addErrorMessages(connectionAttempt);
        if (containsErrorMsgs()) {
            return new BooleanField(false);
        }
        Connection ldapConnection = connectionAttempt.getResult();
        addErrorMessages(utils.checkDirExists(baseUserDn, ldapConnection));
        // Short-circuit return here, if either the user or group directory does not exist
        if (containsErrorMsgs()) {
            return new BooleanField(false);
        }
        claimMappings.getList().stream().map(ClaimsMapEntry::claimValueField).filter(claim -> !mappingAttributeFound(ldapConnection, claim.getValue())).forEach(claim -> addErrorMessage(userAttributeNotFoundError(claim.getPath())));
    } catch (IOException e) {
        LOGGER.warn("Error closing LDAP connection", e);
    }
    return new BooleanField(!containsErrorMsgs());
}
Also used : Connection(org.forgerock.opendj.ldap.Connection) LdapBindUserInfo(org.codice.ddf.admin.ldap.fields.connection.LdapBindUserInfo) Filter(org.forgerock.opendj.ldap.Filter) LoggerFactory(org.slf4j.LoggerFactory) SearchScope(org.forgerock.opendj.ldap.SearchScope) TestFunctionField(org.codice.ddf.admin.common.fields.base.function.TestFunctionField) LdapConnectionAttempt(org.codice.ddf.admin.ldap.commons.LdapConnectionAttempt) ImmutableList(com.google.common.collect.ImmutableList) BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) LdapDistinguishedName(org.codice.ddf.admin.ldap.fields.LdapDistinguishedName) LdapTestingUtils(org.codice.ddf.admin.ldap.commons.LdapTestingUtils) FunctionField(org.codice.ddf.admin.api.fields.FunctionField) LdapConnectionField(org.codice.ddf.admin.ldap.fields.connection.LdapConnectionField) Field(org.codice.ddf.admin.api.Field) ImmutableSet(com.google.common.collect.ImmutableSet) ClaimsMapEntry(org.codice.ddf.admin.security.common.fields.wcpm.ClaimsMapEntry) Logger(org.slf4j.Logger) LdapAttributeName(org.codice.ddf.admin.ldap.fields.LdapAttributeName) Set(java.util.Set) StringField(org.codice.ddf.admin.common.fields.base.scalar.StringField) StsServiceProperties(org.codice.ddf.admin.security.common.services.StsServiceProperties) IOException(java.io.IOException) ConfiguratorSuite(org.codice.ddf.internal.admin.configurator.actions.ConfiguratorSuite) LdapMessages(org.codice.ddf.admin.ldap.commons.LdapMessages) Collectors(java.util.stream.Collectors) SecurityMessages(org.codice.ddf.admin.security.common.SecurityMessages) List(java.util.List) LdapMessages.userAttributeNotFoundError(org.codice.ddf.admin.ldap.commons.LdapMessages.userAttributeNotFoundError) DefaultMessages(org.codice.ddf.admin.common.report.message.DefaultMessages) SecurityValidation(org.codice.ddf.admin.security.common.SecurityValidation) BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) ClaimsMapEntry(org.codice.ddf.admin.security.common.fields.wcpm.ClaimsMapEntry) Connection(org.forgerock.opendj.ldap.Connection) IOException(java.io.IOException) LdapConnectionAttempt(org.codice.ddf.admin.ldap.commons.LdapConnectionAttempt)

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