use of org.codice.ddf.admin.security.common.fields.wcpm.ContextPolicyBin in project admin-console-beta by connexta.
the class PolicyManagerServiceProperties method contextPoliciesToPolicyManagerProps.
public Map<String, Object> contextPoliciesToPolicyManagerProps(List<ContextPolicyBin> contextPolicies) {
List<String> realmsProps = new ArrayList<>();
List<String> authTypesProps = new ArrayList<>();
List<String> reqAttrisProps = new ArrayList<>();
for (ContextPolicyBin bin : contextPolicies) {
bin.contexts().forEach(context -> {
realmsProps.add(context + "=" + bin.realm());
authTypesProps.add(context + "=" + String.join("|", bin.authTypes()));
if (bin.claimsMapping().isEmpty()) {
reqAttrisProps.add(context + "=");
} else {
reqAttrisProps.add(context + "={" + String.join(";", bin.claimsMapping().entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.toList())) + "}");
}
});
}
return ImmutableMap.of(AUTH_TYPES, authTypesProps.toArray(new String[0]), REALMS, realmsProps.toArray(new String[0]), REQUIRED_ATTRIBUTES, reqAttrisProps.toArray(new String[0]));
}
use of org.codice.ddf.admin.security.common.fields.wcpm.ContextPolicyBin 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.security.common.fields.wcpm.ContextPolicyBin 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