+ });
+ }
+ }
+ }
+
+ private void setPolicyAdapterPolicyNameAndDesc(PolicyRestAdapter policyAdapter, PolicyType policy) {
+ policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
+ String policyNameValue =
+ policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf('_') + 1);
+ policyAdapter.setPolicyName(policyNameValue);
+ String description;
+ try {
+ description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
+ } catch (Exception e) {
+ LOGGER.error("Error while collecting the description tag in ActionPolicy " + policyNameValue, e);
+ description = policy.getDescription();
+ }
+ policyAdapter.setPolicyDescription(description);
+ }
+
+ private void setPolicyAdapterRuleAlgorithmschoices(PolicyRestAdapter policyAdapter, RuleType ruleType) {
+ if (ruleType.getCondition() != null) {
+ int index = 0;
+ ApplyType actionApply = (ApplyType) ruleType.getCondition().getExpression().getValue();
+ ruleAlgorithmTracker = new LinkedList<>();
+ // Populating Rule Algorithms starting from compound.
+ prePopulateCompoundRuleAlgorithm(index, actionApply);
+ }
+ policyAdapter.setRuleAlgorithmschoices(ruleAlgorithmList);
+ }
+
+ private void setPolicyAdapterAttributes(PolicyRestAdapter policyAdapter, List<AnyOfType> anyOfList) {
+ List<Object> attributeList = new ArrayList<>();
+ //
+ // NOTE: If using xacml3 code and doing a getAnyOf(), the anyOfList will
+ // NEVER be null as that code will create it if it is null.
+ //
+ // Remove the null check as its impossible to cover it.
+ //
+ // under target we have AnyOFType
+ for (AnyOfType anyOf : anyOfList) {
+ // Under AntOfType we have AllOfType
+ //
+ // NOTE: This will NEVER be null as the method call in the
+ // previous line getAllOf() will never return a null. It
+ // always creates it if its empty.
+ //
+ List<AllOfType> allOfList = anyOf.getAllOf();
+ // Under AllOfType we have Match.
+ for (AllOfType allOfType : allOfList) {
+ //
+ // NOTE: allOfType.getMatch() will NEVER be null as the method
+ // call getMatch will always return something. If its
+ // not there it will create it.
+ //
+ //
+ // Under the match we have attributeValue and
+ // attributeDesignator. So,finally down to the actual attribute.
+ //
+ // Component attributes are saved under Target here we are fetching them back.
+ // One row is default so we are not adding dynamic component at index 0.
+ for (MatchType match : allOfType.getMatch()) {
+ AttributeValueType attributeValue = match.getAttributeValue();
+ String value = (String) attributeValue.getContent().get(0);
+ AttributeDesignatorType designator = match.getAttributeDesignator();
+ String attributeId = designator.getAttributeId();
+ Map<String, String> attribute = new HashMap<>();
+ attribute.put("key", attributeId);
+ attribute.put("value", value);
+ attributeList.add(attribute);