Class CertifiedTarget<A extends Address>
java.lang.Object
org.snmp4j.AbstractTarget<A>
org.snmp4j.SecureTarget<A>
org.snmp4j.CertifiedTarget<A>
- All Implemented Interfaces:
Serializable, Cloneable, CertifiedIdentity, Target<A>
- Direct Known Subclasses:
TlsX509CertifiedTarget
public class CertifiedTarget<A extends Address>
extends SecureTarget<A>
implements CertifiedIdentity, Serializable
The
CertifiedTarget class implements a SecureTarget for usage with SecurityModels that support secured connections using client and server certificates.
Such a target holds two independent names, following the split RFC 6353 makes between the
snmpTargetParamsTable and the snmpTlstmAddrTable:
- The security name (
AbstractTarget.getSecurityName()) is thetmSecurityNamethatTSMcopies intomsgSecurityName, i.e. the principal used for access control. It corresponds tosnmpTargetParamsSecurityName. - The identity (
getIdentity()) is the identity the peer is expected to prove with its certificate. It is matched against thedNSNameandiPAddresssubject alternative names of the server certificate as required by RFC 6353 §5.3.1 and corresponds tosnmpTlstmAddrServerIdentity.
- Since:
- 2.0
- Version:
- 3.13.0
- Author:
- Frank Fock
- See Also:
-
Field Summary
Fields inherited from class AbstractTarget
securityLevel, securityModel, securityName -
Constructor Summary
ConstructorsConstructorDescriptionCertifiedTarget(A address, OctetString securityName, OctetString serverFingerprint, OctetString clientFingerprint) Creates aCertifiedTargetwith the given address, security name, and certificate fingerprints.CertifiedTarget(OctetString securityName) Creates aCertifiedTargetwith an unspecifiedTlsAddressand the given security name. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new copy of this target with the same address type.Gets the client certificate fingerprint.Gets the identity that has been set explicitly withsetIdentity(OctetString), without falling back to the security name of this target.Gets the identity the peer is expected to prove with its certificate.Gets the server certificate fingerprint.voidsetIdentity(OctetString identity) Sets the identity the peer is expected to prove with its certificate, independently from the security name of this target.toString()Methods inherited from class AbstractTarget
clone, equals, getAddress, getMaxSizeRequestPDU, getPreferredTransports, getRetries, getSecurityLevel, getSecurityModel, getSecurityName, getTimeout, getVersion, hashCode, setAddress, setMaxSizeRequestPDU, setPreferredTransports, setRetries, setSecurityLevel, setSecurityModel, setSecurityName, setTimeout, setVersion, toStringAbstractTarget
-
Constructor Details
-
CertifiedTarget
Creates aCertifiedTargetwith an unspecifiedTlsAddressand the given security name.- Parameters:
securityName- thetmSecurityNameof the target. It is used as expected peer identity too, unlesssetIdentity(OctetString)is called.
-
CertifiedTarget
public CertifiedTarget(A address, OctetString securityName, OctetString serverFingerprint, OctetString clientFingerprint) Creates aCertifiedTargetwith the given address, security name, and certificate fingerprints.- Parameters:
address- the transport address of the target.securityName- thetmSecurityNameof the target. It is used as expected peer identity too, unlesssetIdentity(OctetString)is called.serverFingerprint- the fingerprint of the server certificate to pin, ornull/empty if the server certificate is to be validated by its certification path instead.clientFingerprint- the fingerprint of the client certificate to pin, ornull/empty if the client certificate is to be validated by its certification path instead.
-
-
Method Details
-
getServerFingerprint
Description copied from interface:CertifiedIdentityGets the server certificate fingerprint.- Specified by:
getServerFingerprintin interfaceCertifiedIdentity- Returns:
- the server certificate fingerprint or
nullif no fingerprint has been configured.
-
getClientFingerprint
Description copied from interface:CertifiedIdentityGets the client certificate fingerprint.- Specified by:
getClientFingerprintin interfaceCertifiedIdentity- Returns:
- the client certificate fingerprint or
nullif no fingerprint has been configured.
-
getIdentity
Gets the identity the peer is expected to prove with its certificate. If no identity has been set withsetIdentity(OctetString), the security name of this target is returned, as it was the case before version 3.13.0.Note that the RFC 6353 §5.3.1 verification of a server certificate uses
getConfiguredIdentity()instead, so that a security name which is not a host name or IP address does not fail that verification.- Specified by:
getIdentityin interfaceCertifiedIdentity- Returns:
- the expected peer identity, which may be
nullor empty if neither an identity nor a security name has been set. Then no identity comparison is performed.
-
setIdentity
Sets the identity the peer is expected to prove with its certificate, independently from the security name of this target. The identity is matched against thedNSNameandiPAddresssubject alternative names of the peer certificate, where the left-most label of adNSNamemay be a wildcard (RFC 6353snmpTlstmAddrServerIdentity).- Parameters:
identity- the expected peer identity, ornullto fall back to the security name of this target.- Since:
- 3.13.0
-
getConfiguredIdentity
Gets the identity that has been set explicitly withsetIdentity(OctetString), without falling back to the security name of this target. The RFC 6353 §5.3.1 verification of a server certificate is based on this value, thus it is only performed if an identity has been set on purpose.- Specified by:
getConfiguredIdentityin interfaceCertifiedIdentity- Returns:
- the explicitly configured expected peer identity or
nullif none has been configured. - Since:
- 3.13.0
-
toString
- Overrides:
toStringin classSecureTarget<A extends Address>
-
duplicate
-