Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,23 @@ public UsmUser deserialize(JsonParser jp, DeserializationContext ctxt) throws IO
"authentication protocol is specified.");
}

OctetString localizationEngineID = null;
final JsonNode localizationEngineIDNode = node.get("localizationEngineID");
if (localizationEngineIDNode != null) {
if (localizationEngineIDNode.asText().contains(":")) {
localizationEngineID = OctetString.fromHexString(localizationEngineIDNode.asText());
} else {
localizationEngineID = OctetString.fromHexStringPairs(localizationEngineIDNode.asText());
}
}

return new UsmUser(
new OctetString(securityName),
authProtocol,
authPassphrase,
privProtocol,
privPassphrase
privPassphrase,
localizationEngineID
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The ListenTrapSNMP processor listens for incoming SNMP traps and generates a Flo

When configured to use SNMPv3, SNMPv1 and SNMPv2c are automatically disabled. As a result, traps using SNMPv1 or SNMPv2c message models will not be received or processed. This is done to enforce a higher level of security, as SNMPv1 and SNMPv2c transmit community strings in plaintext, making them vulnerable to interception and unauthorized access.

For SNMPv3, security is based on a User-Based Security Model (USM). The 'USM Users Input Method' property allows users to configure the USM user database in different ways. Below is an example JSON file defining two users as "Json Content":
For SNMPv3, security is based on a User-Based Security Model (USM). The 'USM Users Input Method' property allows users to configure the USM user database in different ways. Below is an example JSON file defining three users as "Json Content":

```json
[
Expand All @@ -37,8 +37,18 @@ For SNMPv3, security is based on a User-Based Security Model (USM). The 'USM Use
"authProtocol": "HMAC192SHA256",
"authPassphrase": "authPassphrase2",
"privProtocol": "AES256",
"privPassphrase": "privPassphrase2"
"privPassphrase": "privPassphrase2",
"localizationEngineID":"00:0A:95:9D:68:16"
},
{
"securityName":"user3",
"authProtocol":"HMAC384SHA512",
"authPassphrase":"authPassphrase3",
"privProtocol":"AES256",
"privPassphrase":"privPassphrase3",
"localizationEngineID":"08A69E"
}
]

```
```
**NOTE:** `localizationEngineID` is not required, but if specified it must be a hex string either with or without colon delimiters.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void testAddUsmUsers() {
trapReceiverHandler.setSnmpManager(mockSnmpManager);
trapReceiverHandler.createTrapReceiver(null, null);

verify(mockSnmpManager.getUSM(), times(2)).addUser(usmUserCaptor.capture());
verify(mockSnmpManager.getUSM(), times(3)).addUser(usmUserCaptor.capture());
verify(mockSnmpManager).addCommandResponder(any(SNMPTrapReceiver.class));

assertTrue(trapReceiverHandler.isStarted());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ void testReadInvalidJsonThrowsException() {
}

static String readFile(String path) throws IOException {
byte[] encoded = Files.readAllBytes(Paths.get(path));
return new String(encoded, StandardCharsets.UTF_8);
return Files.readString(Paths.get(path), StandardCharsets.UTF_8);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class JsonUsmReaderTestBase {
public static final String LEGACY_USERS_JSON_PATH = "src/test/resources/invalid_usm_user_legacy_protocol.json";

static final List<UsmUser> expectedUsmUsers;
private static final OctetString EMPTY_LOCALIZATION_ENGINE_ID = null;

static {
expectedUsmUsers = new ArrayList<>();
Expand All @@ -39,15 +40,25 @@ public class JsonUsmReaderTestBase {
new OID("1.3.6.1.6.3.10.1.1.7"),
new OctetString("abc12345"),
new OID("1.3.6.1.4.1.4976.2.2.1.1.1"),
new OctetString("abc12345")
new OctetString("abc12345"),
EMPTY_LOCALIZATION_ENGINE_ID

));
expectedUsmUsers.add(new UsmUser(
new OctetString("user2"),
new OID("1.3.6.1.6.3.10.1.1.5"),
new OctetString("abc12345"),
new OID("1.3.6.1.4.1.4976.2.2.1.1.2"),
new OctetString("abc12345")
new OctetString("abc12345"),
OctetString.fromHexString("00:0A:95:9D:68:16")
));
expectedUsmUsers.add(new UsmUser(
new OctetString("user3"),
new OID("1.3.6.1.6.3.10.1.1.7"),
new OctetString("abc12345"),
new OID("1.3.6.1.4.1.4976.2.2.1.1.2"),
new OctetString("abc12345"),
OctetString.fromHexStringPairs("08A69E")
));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"authProtocol":"HMAC192SHA256",
"authPassphrase":"abc12345",
"privProtocol":"AES256",
"privPassphrase":"abc12345"
"privPassphrase":"abc12345",
"localizationEngineID":"00:0A:95:9D:68:16"
},
{
"securityName":"user3",
"authProtocol":"HMAC384SHA512",
"authPassphrase":"abc12345",
"privProtocol":"AES256",
"privPassphrase":"abc12345",
"localizationEngineID":"08A69E"
}
]
Loading