public static SubjectName resolveSubjectNameFromFlowCacheName(String flowCacheName) { List<String> keys = Splitter.on(DELIMETER).splitToList(flowCacheName); String policyRuleGroupKey = keys.get(0); String subjectName = Splitter.on(KEY_DELIMETER).splitToList(policyRuleGroupKey).get(2); return new SubjectName(subjectName); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ResolvedRuleGroup other = (ResolvedRuleGroup) obj; if (order == null) { if (other.order != null) return false; } else if (!order.equals(other.order)) return false; if (rules == null) { if (other.rules != null) return false; } else if (!rules.equals(other.rules)) return false; if (relatedSubject == null) { if (other.relatedSubject != null) return false; } else if (!relatedSubject.equals(other.relatedSubject)) return false; return true; }
LOG.trace("Start Parsing Subject Ref {} in Contract {}", subjectRef, contract.getId().getValue()); for (Subject sub : contract.getSubject()) { if (subjectRef.equals(sub.getName())) { SecurityRuleGroupBuilder securityRuleGroupBuilder = new SecurityRuleGroupBuilder(); securityRuleGroupBuilder.setName(new Name(subjectRef.getValue())); List<Rule> subRules = sub.getRule(); if (subRules == null) { LOG.warn("Subject {} in Contract {} doesn't have rules", subjectRef.getValue(), contract.getId().getValue()); } else { List<SecurityRule> securityRules = getSecurityRules(contract, subjectRef, subRules); LOG.debug("Subject {} in Contract {} has {} rules", subjectRef.getValue(), contract.getId() .getValue(), securityRules.size()); securityRuleGroupBuilder.setSecurityRule(securityRules); .getValue(), subjectRef.getValue(), contract.getId().getValue()); securityRuleGroups.add(securityRuleGroupBuilder.build());
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((order == null) ? 0 : order.hashCode()); result = prime * result + ((rules == null) ? 0 : rules.hashCode()); result = prime * result + ((relatedSubject == null) ? 0 : relatedSubject.hashCode()); return result; }
public static SubjectName getSubjectName(SecurityRule secRule) { RuleName ruleName = SecRuleNameDecoder.getRuleName(secRule); return new SubjectName(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 Subject getBlockSubject() { return new SubjectBuilder() .setName(new SubjectName(SUBJECT_NAME)) .build(); }
public static ClauseName getClauseName(SecurityRule secRule) { IpPrefix remoteIpPrefix = secRule.getRemoteIpPrefix(); SubjectName subjectName = getSubjectName(secRule); if (remoteIpPrefix == null) { return new ClauseName(subjectName); } return new ClauseName(subjectName.getValue() + MappingUtils.NAME_DOUBLE_DELIMETER + Utils.getStringIpPrefix(remoteIpPrefix).replace('/', '_')); }
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(); }
private static ProviderNamedSelector createProviderSelector(Contract contract) { SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue()); return new ProviderNamedSelectorBuilder().setName(selectorName) .setContract(ImmutableList.of(contract.getId())) .build(); }
private static ConsumerNamedSelector createConsumerSelector(Contract contract) { SelectorName selectorName = new SelectorName(contract.getSubject().get(0).getName().getValue()); return new ConsumerNamedSelectorBuilder().setName(selectorName) .setContract(ImmutableList.of(contract.getId())) .build(); }
ProviderMatchers providerMatchers = null; StringBuilder clauseName = new StringBuilder(); clauseName.append(subjectName.getValue()); if (ipPrefix != null) { clauseName.append(MappingUtils.NAME_DOUBLE_DELIMETER).append(Utils.getStringIpPrefix(ipPrefix));