Class McpSnmpBuilder
SnmpMcpServer.ServerConfiguration.SnmpTargetConfig
into the SNMP4J fluent-API objects (Target, Snmp, PduBuilder)
used by MCP tool implementations.
Besides the connectionless udp: and the connection oriented tcp: transports, the builder
supports the secure transports tls: (RFC 6353) and dtls: (RFC 5953). Their transport mappings
and targets are configured entirely from the TLS section of the target configuration, see
SnmpMcpServer.ServerConfiguration.TlsConfig. A (D)TLS target always uses the Transport Security Model
(TSM, RFC 5591) instead of the User-based Security Model.
Transport mappings are shared between all targets of a SnmpBuilder that need the same transport
configuration, because a transport mapping owns the listen socket and the key material of a connection. Two
targets that differ in any transport level (D)TLS parameter - key store, trust store, local certificate alias,
protocol versions, revocation checking or message sizes - therefore get their own transport mapping, and every
built target is bound to its transport mapping with AbstractTarget.setPreferredTransports(List). Target level
parameters (security name, certificate fingerprints, expected server identity) do not require a separate
transport mapping: they are carried by the TlsX509CertifiedTarget and its
TlsTmSecurityCallback, which takes precedence over the callback of the transport mapping.
-
Method Summary
Modifier and TypeMethodDescriptionstatic McpSnmpBuilderbuilder(org.snmp4j.fluent.SnmpBuilder snmpBuilder) Creates a builder wrapping the givenSnmpBuilder.org.snmp4j.fluent.PduBuilderbuildPdu()Returns aPduBuilderfor constructing the PDU to be sent.org.snmp4j.SnmpbuildSnmp(org.snmp4j.Snmp existingSnmp) ReturnsexistingSnmpif non-null, otherwise builds and returns a newSnmpinstance.org.snmp4j.Target<org.snmp4j.smi.Address> Builds and returns an SNMPTargetfrom the current target configuration.withTarget(SnmpMcpServer.ServerConfiguration.SnmpTargetConfig targetConfig) Sets the target configuration to use when building the SNMP target.
-
Method Details
-
builder
Creates a builder wrapping the givenSnmpBuilder.- Parameters:
snmpBuilder- the underlying SNMP4J fluent builder- Returns:
- a new
McpSnmpBuilder
-
withTarget
Sets the target configuration to use when building the SNMP target.- Parameters:
targetConfig- the server target configuration- Returns:
- this builder
-
buildTarget
Builds and returns an SNMPTargetfrom the current target configuration. As a side effect, the transport mapping, message processing model and security model that the target requires are added to the underlyingSnmpBuilderunless an equally configured one has been added before.- Returns:
- the configured SNMP target, or
nullif no config has been set - Throws:
IOException- if transport initialization failsIllegalArgumentException- if the target address or a (D)TLS parameter is invalid
-
buildSnmp
ReturnsexistingSnmpif non-null, otherwise builds and returns a newSnmpinstance. IfbuildTarget()had to add a new transport mapping to an already open session, that transport mapping is started here.- Parameters:
existingSnmp- an already-open session to reuse, ornull- Returns:
- an open SNMP session
- Throws:
IOException- if building a new session fails
-
buildPdu
public org.snmp4j.fluent.PduBuilder buildPdu()Returns aPduBuilderfor constructing the PDU to be sent.- Returns:
- a PDU builder for the current target
-