Class AdhocOverrides
java.lang.Object
org.snmp4j.mcp.tool.snmp.AdhocOverrides
Builds an effective
SnmpMcpServer.ServerConfiguration.SnmpTargetConfig by applying a map of per-call parameter
overrides onto a configured base target.
Overrides are only honoured when the base target has
SnmpMcpServer.ServerConfiguration.SnmpTargetConfig.allowAdhocParameterOverwrite() set to true. The
address (which embeds the transport type and port) and the targetName can
never be overridden — the destination endpoint always remains the one declared in the
server configuration. This lets an MCP client run security-negative and robustness tests
(wrong community, wrong SNMPv3 credentials, mismatched security level, altered retries/timeout)
against a fixed, operator-approved agent endpoint.
The override map mirrors the structure of a single SNMP[] entry in the
configuration JSON. Recognised keys:
- top-level:
community,version,retries,timeout,maxSizeResponsePdu SNMPv3: a nested object with any subset of theSnmpMcpServer.ServerConfiguration.SnmpV3ConfigfieldsTLS: a nested object with any subset of theSnmpMcpServer.ServerConfiguration.TlsConfigfields
address, targetName or
allowAdhocParameterOverwrite — is rejected.- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionapply(SnmpMcpServer.ServerConfiguration.SnmpTargetConfig base, Map<String, Object> overrides) Returns a target configuration with the given overrides applied.
-
Method Details
-
apply
public static SnmpMcpServer.ServerConfiguration.SnmpTargetConfig apply(SnmpMcpServer.ServerConfiguration.SnmpTargetConfig base, Map<String, Object> overrides) Returns a target configuration with the given overrides applied.- Parameters:
base- the configured base targetoverrides- the override map (typically parsed from aparameterOverridesJSON object); may benullor empty- Returns:
baseunchanged whenoverridesis null/empty, otherwise a newSnmpMcpServer.ServerConfiguration.SnmpTargetConfigwith the merged values- Throws:
IllegalArgumentException- if overrides are supplied for a target that does not permit them, or if an override targets a forbidden key (e.g.address)
-