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())));
}
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;
}
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;
}
Aggregations