Lehel44 commented on code in PR #6034:
URL: https://github.com/apache/nifi/pull/6034#discussion_r879889986


##########
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.")

Review Comment:
   In SNMPv3 the Security Name/User Name with noAuthNoPriv works similar to the 
community string in SNMPv1 and SNMPv2c, thus must be provided. If the user 
wants the parse the security name from a JSON file, I'd provide an option for 
it.



-- 
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

Reply via email to