@Test public final void testGetClause_noRemoteIpPrefix() { secRuleBuilder.setDirection(DirectionIngress.class); secRuleBuilder.setEthertype(EthertypeV4.class); ClauseName expectedClauseName = SecRuleNameDecoder.getClauseName(secRuleBuilder.build()); Clause clause = SecRuleEntityDecoder.getClause(secRuleBuilder.build()); Assert.assertEquals(expectedClauseName, clause.getName()); List<SubjectName> subjectRefs = clause.getSubjectRefs(); Assert.assertNotNull(subjectRefs); Assert.assertEquals(1, subjectRefs.size()); SubjectName subjectNameFromClause = subjectRefs.get(0); SubjectName expectedSubjectName = SecRuleNameDecoder.getSubjectName(secRuleBuilder.build()); Assert.assertEquals(expectedSubjectName, subjectNameFromClause); Assert.assertNull(clause.getConsumerMatchers()); Assert.assertNull(clause.getProviderMatchers()); }
public static Clause getClause(SecurityRule secRule) { checkNotNull(secRule); SubjectName subjectName = SecRuleNameDecoder.getSubjectName(secRule); ClauseBuilder clauseBuilder = new ClauseBuilder() .setSubjectRefs(ImmutableList.of(subjectName)) .setName(SecRuleNameDecoder .getClauseName(secRule)); IpPrefix remoteIpPrefix = secRule.getRemoteIpPrefix(); if (remoteIpPrefix != null) { clauseBuilder.setConsumerMatchers(createConsumerMatchersWithEic(remoteIpPrefix)); } return clauseBuilder.build(); }
SecRuleEntityDecoder { public static Clause getClause(SecurityRule secRule) { checkNotNull(secRule); SubjectName subjectName = SecRuleNameDecoder.getSubjectName(secRule); ClauseBuilder clauseBuilder = new ClauseBuilder() .setSubjectRefs(ImmutableList.of(subjectName)) .setName(SecRuleNameDecoder .getClauseName(secRule)); IpPrefix remoteIpPrefix = secRule.getRemoteIpPrefix(); if (remoteIpPrefix != null) { clauseBuilder.setConsumerMatchers(createConsumerMatchersWithEic(remoteIpPrefix)); } return clauseBuilder.build(); } }
SecRuleEntityDecoder { public static Clause getClause(SecurityRule secRule) { checkNotNull(secRule); SubjectName subjectName = SecRuleNameDecoder.getSubjectName(secRule); ClauseBuilder clauseBuilder = new ClauseBuilder() .setSubjectRefs(ImmutableList.of(subjectName)) .setName(SecRuleNameDecoder .getClauseName(secRule)); IpPrefix remoteIpPrefix = secRule.getRemoteIpPrefix(); if (remoteIpPrefix != null) { clauseBuilder.setConsumerMatchers(createConsumerMatchersWithEic(remoteIpPrefix)); } return clauseBuilder.build(); } private  SecRuleEntityDecoder(); }
SecRuleEntityDecoder { public static Clause getClause(SecurityRule secRule) { checkNotNull(secRule); SubjectName subjectName = SecRuleNameDecoder.getSubjectName(secRule); ClauseBuilder clauseBuilder = new ClauseBuilder() .setSubjectRefs(ImmutableList.of(subjectName)) .setName(SecRuleNameDecoder .getClauseName(secRule)); IpPrefix remoteIpPrefix = secRule.getRemoteIpPrefix(); if (remoteIpPrefix != null) { clauseBuilder.setConsumerMatchers(createConsumerMatchersWithEic(remoteIpPrefix)); } return clauseBuilder.build(); } private  SecRuleEntityDecoder(); static ContractId getContractId(SecurityRule secRule); static ClassifierInstance getClassifierInstance(SecurityRule secRule); static ActionRef createActionRefFromActionChoice(ActionChoice action); static ClassifierRef getClassifierRef(SecurityRule secRule); static Direction getDirection(SecurityRule secRule); static Clause getClause(SecurityRule secRule); static boolean isEtherTypeOfOneWithinTwo(SecurityRule one, SecurityRule two); static boolean isProtocolOfOneWithinTwo(SecurityRule one, SecurityRule two); static boolean isPortsOfOneWithinTwo(SecurityRule one, SecurityRule two); static Long getEtherType(SecurityRule secRule); static Long getProtocol(SecurityRule secRule); }
SecRuleEntityDecoder { public static Clause getClause(SecurityRule secRule) { checkNotNull(secRule); SubjectName subjectName = SecRuleNameDecoder.getSubjectName(secRule); ClauseBuilder clauseBuilder = new ClauseBuilder() .setSubjectRefs(ImmutableList.of(subjectName)) .setName(SecRuleNameDecoder .getClauseName(secRule)); IpPrefix remoteIpPrefix = secRule.getRemoteIpPrefix(); if (remoteIpPrefix != null) { clauseBuilder.setConsumerMatchers(createConsumerMatchersWithEic(remoteIpPrefix)); } return clauseBuilder.build(); } private  SecRuleEntityDecoder(); static ContractId getContractId(SecurityRule secRule); static ClassifierInstance getClassifierInstance(SecurityRule secRule); static ActionRef createActionRefFromActionChoice(ActionChoice action); static ClassifierRef getClassifierRef(SecurityRule secRule); static Direction getDirection(SecurityRule secRule); static Clause getClause(SecurityRule secRule); static boolean isEtherTypeOfOneWithinTwo(SecurityRule one, SecurityRule two); static boolean isProtocolOfOneWithinTwo(SecurityRule one, SecurityRule two); static boolean isPortsOfOneWithinTwo(SecurityRule one, SecurityRule two); static Long getEtherType(SecurityRule secRule); static Long getProtocol(SecurityRule secRule);  }