Search in sources :

Example 1 with ConfiguratorFactory

use of org.codice.ddf.admin.configurator.ConfiguratorFactory in project admin-console-beta by connexta.

the class SaveContextPolices method checkClaimsValidity.

private void checkClaimsValidity() {
    List<String> supportedClaims = stsServiceProps.getConfiguredStsClaims(configuratorFactory);
    List<StringField> claimArgs = new ArrayList<>();
    for (ContextPolicyBin bin : contextPolicies.getList()) {
        claimArgs.addAll(bin.claimsMappingField().getList().stream().map(entry -> entry.claimField()).collect(Collectors.toList()));
    }
    claimArgs.stream().filter(claimArg -> !supportedClaims.contains(claimArg.getValue())).forEach(claimArg -> addArgumentMessage(invalidClaimType(claimArg.path())));
}
Also used : POLICY_MANAGER_PID(org.codice.ddf.admin.security.common.services.PolicyManagerServiceProperties.POLICY_MANAGER_PID) BaseFunctionField(org.codice.ddf.admin.common.fields.base.BaseFunctionField) SecurityMessages.invalidClaimType(org.codice.ddf.admin.security.common.SecurityMessages.invalidClaimType) Collection(java.util.Collection) StringField(org.codice.ddf.admin.common.fields.base.scalar.StringField) StsServiceProperties(org.codice.ddf.admin.security.common.services.StsServiceProperties) PolicyManagerServiceProperties(org.codice.ddf.admin.security.common.services.PolicyManagerServiceProperties) Configurator(org.codice.ddf.admin.configurator.Configurator) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ListFieldImpl(org.codice.ddf.admin.common.fields.base.ListFieldImpl) List(java.util.List) DefaultMessages.failedPersistError(org.codice.ddf.admin.common.report.message.DefaultMessages.failedPersistError) OperationReport(org.codice.ddf.admin.configurator.OperationReport) ImmutableList(com.google.common.collect.ImmutableList) ROOT_CONTEXT_PATH(org.codice.ddf.admin.security.common.services.PolicyManagerServiceProperties.ROOT_CONTEXT_PATH) ListField(org.codice.ddf.admin.api.fields.ListField) ContextPolicyBin(org.codice.ddf.admin.security.common.fields.wcpm.ContextPolicyBin) FunctionField(org.codice.ddf.admin.api.fields.FunctionField) ConfiguratorFactory(org.codice.ddf.admin.configurator.ConfiguratorFactory) SecurityMessages.noRootContextError(org.codice.ddf.admin.security.common.SecurityMessages.noRootContextError) DataType(org.codice.ddf.admin.api.DataType) StringField(org.codice.ddf.admin.common.fields.base.scalar.StringField) ArrayList(java.util.ArrayList) ContextPolicyBin(org.codice.ddf.admin.security.common.fields.wcpm.ContextPolicyBin)

Example 2 with ConfiguratorFactory

use of org.codice.ddf.admin.configurator.ConfiguratorFactory in project admin-console-beta by connexta.

the class SourceValidationUtils method validateSourceName.

/**
     * Validates the {@code sourceName} against the existing source names in the system. An empty {@link ReportImpl} will be returned
     * if there are no existing source names with with name {@code sourceName}, or a {@link ReportImpl} with error messages.
     *
     * @param sourceName          source name to validate
     * @param configuratorFactory configurator factory for reading FederatedSource service references
     * @return a {@link ReportImpl} containing a {@link org.codice.ddf.admin.sources.commons.SourceMessages#DUPLICATE_SOURCE_NAME} error, or a Report with
     * no messages on success.
     */
public static ReportImpl validateSourceName(StringField sourceName, ConfiguratorFactory configuratorFactory) {
    List<Source> sources = getAllSourceReferences(configuratorFactory);
    boolean matchFound = sources.stream().map(source -> source.getId()).anyMatch(id -> id.equals(sourceName.getValue()));
    ReportImpl report = new ReportImpl();
    if (matchFound) {
        report.addArgumentMessage(duplicateSourceNameError(sourceName.path()));
    }
    return report;
}
Also used : Source(ddf.catalog.source.Source) List(java.util.List) StringField(org.codice.ddf.admin.common.fields.base.scalar.StringField) SourceUtilCommons.getAllSourceReferences(org.codice.ddf.admin.sources.commons.utils.SourceUtilCommons.getAllSourceReferences) ConfiguredService(ddf.catalog.service.ConfiguredService) ReportImpl(org.codice.ddf.admin.common.report.ReportImpl) ConfiguratorFactory(org.codice.ddf.admin.configurator.ConfiguratorFactory) SourceMessages.duplicateSourceNameError(org.codice.ddf.admin.sources.commons.SourceMessages.duplicateSourceNameError) Source(ddf.catalog.source.Source) ReportImpl(org.codice.ddf.admin.common.report.ReportImpl)

Example 3 with ConfiguratorFactory

use of org.codice.ddf.admin.configurator.ConfiguratorFactory in project admin-console-beta by connexta.

the class PolicyManagerServiceProperties method contextPolicyServiceToContextPolicyFields.

public ListField<ContextPolicyBin> contextPolicyServiceToContextPolicyFields(ConfiguratorFactory configurator) {
    ContextPolicyManager policyManager = configurator.getConfigReader().getServiceReference(ContextPolicyManager.class);
    List<ContextPolicyBin> policies = new ArrayList<>();
    Collection<ContextPolicy> allPolicies = policyManager.getAllContextPolicies();
    for (ContextPolicy policy : allPolicies) {
        boolean foundBin = false;
        Map<String, String> policyRequiredAttributes = policy.getAllowedAttributes().stream().collect(Collectors.toMap(map -> map.getAttributeName(), map -> map.getAttributeValue()));
        //Check if bin containing an identical context policy exists already, if so add the context path to it
        for (ContextPolicyBin bin : policies) {
            if (bin.realm().equals(policy.getRealm()) && ListUtils.isEqualList(bin.authTypes(), policy.getAuthenticationMethods()) && hasSameRequiredAttributes(bin, policyRequiredAttributes)) {
                bin.addContextPath(policy.getContextPath());
                foundBin = true;
            }
        }
        if (!foundBin) {
            policies.add(new ContextPolicyBin().realm(policy.getRealm()).addClaimsMap(policyRequiredAttributes).authTypes(policy.getAuthenticationMethods()).addContextPath(policy.getContextPath()));
        }
    }
    ListField<ContextPolicyBin> policiesField = new ListFieldImpl<>(ContextPolicyBin.class);
    policiesField.addAll(policies);
    return policiesField;
}
Also used : ContextPolicy(org.codice.ddf.security.policy.context.ContextPolicy) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) ListUtils(org.apache.commons.collections.ListUtils) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ListFieldImpl(org.codice.ddf.admin.common.fields.base.ListFieldImpl) ServiceCommons(org.codice.ddf.admin.common.services.ServiceCommons) ConfigReader(org.codice.ddf.admin.configurator.ConfigReader) List(java.util.List) Map(java.util.Map) ListField(org.codice.ddf.admin.api.fields.ListField) ContextPolicyBin(org.codice.ddf.admin.security.common.fields.wcpm.ContextPolicyBin) ContextPolicyManager(org.codice.ddf.security.policy.context.ContextPolicyManager) ConfiguratorFactory(org.codice.ddf.admin.configurator.ConfiguratorFactory) ContextPath(org.codice.ddf.admin.common.fields.common.ContextPath) ListFieldImpl(org.codice.ddf.admin.common.fields.base.ListFieldImpl) ArrayList(java.util.ArrayList) ContextPolicyBin(org.codice.ddf.admin.security.common.fields.wcpm.ContextPolicyBin) ContextPolicy(org.codice.ddf.security.policy.context.ContextPolicy) ContextPolicyManager(org.codice.ddf.security.policy.context.ContextPolicyManager)

Aggregations

List (java.util.List)3 ConfiguratorFactory (org.codice.ddf.admin.configurator.ConfiguratorFactory)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collectors (java.util.stream.Collectors)2 ListField (org.codice.ddf.admin.api.fields.ListField)2 ListFieldImpl (org.codice.ddf.admin.common.fields.base.ListFieldImpl)2 StringField (org.codice.ddf.admin.common.fields.base.scalar.StringField)2 ContextPolicyBin (org.codice.ddf.admin.security.common.fields.wcpm.ContextPolicyBin)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ConfiguredService (ddf.catalog.service.ConfiguredService)1 Source (ddf.catalog.source.Source)1 Map (java.util.Map)1 ListUtils (org.apache.commons.collections.ListUtils)1 DataType (org.codice.ddf.admin.api.DataType)1 FunctionField (org.codice.ddf.admin.api.fields.FunctionField)1 BaseFunctionField (org.codice.ddf.admin.common.fields.base.BaseFunctionField)1 ContextPath (org.codice.ddf.admin.common.fields.common.ContextPath)1 ReportImpl (org.codice.ddf.admin.common.report.ReportImpl)1