public static RuleName resolveRuleNameFromFlowCacheName(String flowCacheName) { List<String> keys = Splitter.on(DELIMETER).splitToList(flowCacheName); String ruleName = keys.get(1); return new RuleName(ruleName); }
public static RuleName getRuleName(SecurityRule secRule) { ClassifierName classifierRefName = SecRuleNameDecoder.getClassifierRefName(secRule); String ruleName = new StringBuilder(MappingUtils.ACTION_ALLOW.getName().getValue()) .append(MappingUtils.NAME_DOUBLE_DELIMETER).append(classifierRefName.getValue()).toString(); return new RuleName(ruleName); }
public static String createFlowCacheName(InstanceIdentifier<Classifier> classifierIid, FlowCacheCons.Value value) { PolicyRuleGroupKey policyRuleGroup = classifierIid.firstKeyOf(PolicyRuleGroup.class); ResolvedRuleKey resolvedRule = classifierIid.firstKeyOf(ResolvedRule.class); ClassifierKey classifier = classifierIid.firstKeyOf(Classifier.class); StringBuilder sb = new StringBuilder(); sb.append(createStringFromCompositeKey(policyRuleGroup.getTenantId().getValue(), policyRuleGroup.getContractId().getValue(), policyRuleGroup.getSubjectName().getValue())) .append(DELIMETER) .append(resolvedRule.getName().getValue()) .append(DELIMETER) .append(classifier.getName().getValue()) .append(DELIMETER) .append(value.get()); return sb.toString(); }
private static Rule createRuleAllow(ClassifierName classifierName, Direction direction) { ClassifierName name = new ClassifierName(direction.name() + MappingUtils.NAME_DOUBLE_DELIMETER + classifierName.getValue()); ClassifierRef classifierRef = new ClassifierRefBuilder().setName(name) .setInstanceName(classifierName) .setDirection(direction) .build(); return new RuleBuilder().setName(new RuleName(name)) .setActionRef(ImmutableList.<ActionRef>of(MappingUtils.ACTION_REF_ALLOW)) .setClassifierRef(ImmutableList.of(classifierRef)) .build(); }
securityRules.add(new SecurityRuleBuilder().setName(new Name(rule.getName().getValue())) .setOrder(rule.getOrder()) .setRuleClassifier(pClassifiers)
private Subject getAllowSubject() { return new SubjectBuilder() .setName(new SubjectName(SUBJECT_NAME)) .setRule(ImmutableList.of(new RuleBuilder() .setKey(new RuleKey(new RuleName(SUBJECT_NAME + "_Rule"))) .setActionRef(ImmutableList.of(new ActionRefBuilder() .setName(new ActionName(ACTION_ALLOW)) .build())) .setClassifierRef(ImmutableList.of(new ClassifierRefBuilder() .setKey(new ClassifierRefKey(new ClassifierName(SUBJECT_NAME + "_Classifier"))) .setName(new ClassifierName(CLASSIFIER_NAME)) .setDirection(Direction.Bidirectional) .build())) .build())) .build(); }