Lehel44 commented on code in PR #6034: URL: https://github.com/apache/nifi/pull/6034#discussion_r879718273
########## nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/main/java/org/apache/nifi/snmp/processors/ListenTrapSNMP.java: ########## @@ -100,21 +129,66 @@ public class ListenTrapSNMP extends AbstractSessionFactoryProcessor { private volatile SNMPTrapReceiverHandler snmpTrapReceiverHandler; + @Override + public Collection<ValidationResult> customValidate(final ValidationContext validationContext) { + final List<ValidationResult> results = new ArrayList<>(super.customValidate(validationContext)); + + final boolean snmpUsersJsonFileIsSet = validationContext.getProperty(SNMP_USM_USERS_JSON_FILE).isSet(); + final boolean snmpUsersJsonIsSet = validationContext.getProperty(SNMP_USM_USERS_JSON).isSet(); + final boolean snmpUsersSecurityNames = validationContext.getProperty(SNMP_USM_SECURITY_NAMES).isSet(); + + final boolean isOnlyOneIsSetFromThree = Stream.of(snmpUsersJsonFileIsSet, snmpUsersJsonIsSet, snmpUsersSecurityNames).filter(a -> a).count() == 1; + final boolean isBothSetOrNotSetFromTwo = snmpUsersJsonFileIsSet && snmpUsersJsonIsSet || !snmpUsersJsonFileIsSet && !snmpUsersJsonIsSet; + final boolean isSnmpv3 = validationContext.getProperty(BasicProperties.SNMP_VERSION).getValue().equals(BasicProperties.SNMP_V3.getValue()); + final boolean isNoAuthNoPriv = validationContext.getProperty(V3SecurityProperties.SNMP_SECURITY_LEVEL).getValue().equals(V3SecurityProperties.NO_AUTH_NO_PRIV.getValue()); + + if (isSnmpv3 && isNoAuthNoPriv && isOnlyOneIsSetFromThree) { + results.add(new ValidationResult.Builder() + .subject("Provide snmpv3 USM Users JSON.") + .valid(false) + .explanation("Only one of '" + SNMP_USM_USERS_JSON_FILE.getDisplayName() + "' or '" + Review Comment: That is a great idea. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org