java.lang.Object
org.snmp4j.AbstractTarget<A>
org.snmp4j.SecureTarget<A>
org.snmp4j.UserTarget<A>
org.snmp4j.DirectUserTarget<A>
- All Implemented Interfaces:
Serializable,Cloneable,Target<A>
User-based target for SNMPv3 User-Based Security Model
USM or later that includes any necessary
authentication and privacy information, i.e., protocol references and localized keys.
In contrast to the base class UserTarget, the DirectUserTarget does not refer to user
information of a USM Local Configuration Storage except for caching engine times and boot counter for the
authoritative engine ID.- Since:
- 3.4.0
- Version:
- 3.9.3
- Author:
- Frank Fock
- See Also:
-
Field Summary
Fields inherited from class org.snmp4j.UserTarget
authoritativeEngineIDFields inherited from class org.snmp4j.AbstractTarget
securityLevel, securityModel, securityName -
Constructor Summary
ConstructorsConstructorDescriptionCreates a target for a user-based security model target.DirectUserTarget(A address, OctetString securityName, byte[] authoritativeEngineID, AuthenticationProtocol authenticationProtocol, OctetString authenticationKey, PrivacyProtocol privacyProtocol, OctetString privacyKey) Creates an SNMPv3 USM target with the supplied security level, one second time-out without retries.DirectUserTarget(A address, OctetString securityName, AuthenticationProtocol authenticationProtocol, OctetString authenticationPassphrase, PrivacyProtocol privacyProtocol, OctetString privacyPassphrase) Creates an SNMPv3 USM target with the supplied security level, one second time-out without retries.DirectUserTarget(UserTarget<A> userTarget) Creates a target for a user-based security model target without referencing security information from elsewhere. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new copy of this target with the same address type.booleanGets the authentication key associated directly with this user target (withoutUSMuser table lookup).Get theAuthenticationProtocolassociated with this target ornullif there is no direct user information provided but referenced by theAbstractTarget.securityNamefrom theUSMor if there is no authentication.Gets the privacy key associated directly with this user target (withoutUSMuser table lookup).Get thePrivacyProtocolassociated with this target ornullif there is no direct user information provided but referenced by theAbstractTarget.securityNamefrom theUSMor there is no privacy.inthashCode()voidsetAuthenticationKey(OctetString authenticationKey) Sets the authentication key (localized for theUserTarget.authoritativeEngineID) to be used for this target directly.voidsetAuthenticationProtocol(AuthenticationProtocol authenticationProtocol) Set theAuthenticationProtocolassociated with this target ornullif there is no direct user information provided but referenced by theAbstractTarget.securityNamefrom theUSMor if there is no authentication.voidsetAuthoritativeEngineID(byte[] authoritativeEngineID) Sets the authoritative engine ID of this target.voidsetPrivacyKey(OctetString privacyKey) Sets the privacy key (localized for theUserTarget.authoritativeEngineID) to be used for this target directly.voidsetPrivacyProtocol(PrivacyProtocol privacyProtocol) /** Set thePrivacyProtocolassociated with this target ornullif there is no direct user information provided but referenced by theAbstractTarget.securityNamefrom theUSMor if there is no privacy.toString()Methods inherited from class org.snmp4j.UserTarget
getAuthoritativeEngineIDMethods inherited from class org.snmp4j.AbstractTarget
clone, getAddress, getMaxSizeRequestPDU, getPreferredTransports, getRetries, getSecurityLevel, getSecurityModel, getSecurityName, getTimeout, getVersion, setAddress, setMaxSizeRequestPDU, setPreferredTransports, setRetries, setSecurityLevel, setSecurityModel, setSecurityName, setTimeout, setVersion, toStringAbstractTarget
-
Constructor Details
-
DirectUserTarget
public DirectUserTarget()Creates a target for a user-based security model target. -
DirectUserTarget
Creates a target for a user-based security model target without referencing security information from elsewhere.- Parameters:
userTarget- the target based on an USM.
-
DirectUserTarget
public DirectUserTarget(A address, OctetString securityName, byte[] authoritativeEngineID, AuthenticationProtocol authenticationProtocol, OctetString authenticationKey, PrivacyProtocol privacyProtocol, OctetString privacyKey) Creates an SNMPv3 USM target with the supplied security level, one second time-out without retries. The security level is deducted from the keys given (authenticationKeyandprivacyKey). If both arenullor have zero-length,SecurityLevel.noAuthNoPrivis used; ifauthenticationKeyis given butprivacyKeynot, thenSecurityLevel.authNoPriv, andSecurityLevel.authPrivotherwise.- Parameters:
address- the transportAddressof the target.securityName- the USM security name to be used to access the target.authoritativeEngineID- the authoritative engine ID as a possibly zero-length byte array which must not benull.authenticationProtocol- the authentication protocol to be used (ornullforSecurityLevel.noAuthNoPriv.authenticationKey- the localized authentication key (localized with theauthoritativeEngineID) that will be used for this target instead of looking up the authentication key from theUSM.privacyProtocol- the privacy protocol to be used (ornullforSecurityLevel.noAuthNoPrivorSecurityLevel.authNoPriv.privacyKey- the localized privacy key (localized with theauthoritativeEngineID) that will be used for this target instead of looking up the privacy key from theUSM.- Since:
- 3.4.0
-
DirectUserTarget
public DirectUserTarget(A address, OctetString securityName, AuthenticationProtocol authenticationProtocol, OctetString authenticationPassphrase, PrivacyProtocol privacyProtocol, OctetString privacyPassphrase) Creates an SNMPv3 USM target with the supplied security level, one second time-out without retries. The security level is deducted from the passphrases given (authenticationPassphrase and privacyPassphrase). If both arenullor have zero-length,SecurityLevel.noAuthNoPrivis used; if authenticationPassphrase is given but privacyPassphrase not, thenSecurityLevel.authNoPriv, andSecurityLevel.authPrivotherwise. This constructor sets theUserTarget.authoritativeEngineIDtonew byte[0], which means that the authoritative engine ID needs to be either looked up from theUSMor discovered by the SNMPv3MPv3model before sending a request to this target by callingsetAuthenticationKey(OctetString)with a non-zero length engine ID which will then internally calllocalize(byte[])to localize the provided passphrases for that engine ID.- Parameters:
address- the transportAddressof the target.securityName- the USM security name to be used to access the target.authenticationProtocol- the authentication protocol to be used (ornullforSecurityLevel.noAuthNoPriv.authenticationPassphrase- the localized authentication key that will be localized when actually sending a request to this target instead of looking up the authentication key from theUSM.privacyProtocol- the privacy protocol to be used (ornullforSecurityLevel.noAuthNoPrivorSecurityLevel.authNoPriv.privacyPassphrase- the non-localized privacy passphrase that will be localized when actually sending a request to this target instead of looking up the privacy key from theUSM.- Since:
- 3.9.3
-
-
Method Details
-
getAuthenticationKey
Gets the authentication key associated directly with this user target (withoutUSMuser table lookup). Ifnullis returned and theAbstractTarget.securityLevelis notSecurityLevel.noAuthNoPriv, then the authentication must be looked up from aUSMinstance, when sending a SNMPv3 message to a target,- Returns:
- the localized authentication key directly associated with this target.
- Since:
- 3.4.0
-
setAuthenticationKey
Sets the authentication key (localized for theUserTarget.authoritativeEngineID) to be used for this target directly. Note: This has no effect unlessAbstractTarget.securityLevelisSecurityLevel.authNoPrivorSecurityLevel.authPriv.- Parameters:
authenticationKey- the localized authentication key (localized with theauthoritativeEngineID) that will be used for this target instead of looking up the authentication key from theUSMby theAbstractTarget.securityName.- Since:
- 3.4.0
-
getPrivacyKey
Gets the privacy key associated directly with this user target (withoutUSMuser table lookup). Ifnullis returned and theAbstractTarget.securityLevelisSecurityLevel.authPrivthen the privacy key must be looked up from aUSMinstance, when sending a SNMPv3 message to a target.- Returns:
- the localized privacy key directly associated with this target.
- Since:
- 3.4.0
-
setPrivacyKey
Sets the privacy key (localized for theUserTarget.authoritativeEngineID) to be used for this target directly. Note: This has no effect unlessauthenticationKeyis also set andAbstractTarget.securityLevelisSecurityLevel.authPriv.- Parameters:
privacyKey- the localized privacy key (localized with theauthoritativeEngineID) that will be used for this target instead of looking up the privacy key from theUSMby theAbstractTarget.securityName.- Since:
- 3.4.0
-
getAuthenticationProtocol
Get theAuthenticationProtocolassociated with this target ornullif there is no direct user information provided but referenced by theAbstractTarget.securityNamefrom theUSMor if there is no authentication.- Returns:
- the (optional) authentication protocol associated with this target by direct reference
(i.e., not via
USM). - Since:
- 3.4.0
-
setAuthenticationProtocol
Set theAuthenticationProtocolassociated with this target ornullif there is no direct user information provided but referenced by theAbstractTarget.securityNamefrom theUSMor if there is no authentication.- Parameters:
authenticationProtocol- the (optional) authentication protocol associated with this target by direct reference (i.e., not viaUSM).- Since:
- 3.4.0
-
getPrivacyProtocol
Get thePrivacyProtocolassociated with this target ornullif there is no direct user information provided but referenced by theAbstractTarget.securityNamefrom theUSMor there is no privacy.- Returns:
- the (optional) privacy protocol associated with this target by direct reference
(i.e., not via
USM). - Since:
- 3.4.0
-
setPrivacyProtocol
/** Set thePrivacyProtocolassociated with this target ornullif there is no direct user information provided but referenced by theAbstractTarget.securityNamefrom theUSMor if there is no privacy.- Parameters:
privacyProtocol- the (optional) privacy protocol associated with this target by direct reference (i.e., not viaUSM).- Since:
- 3.4.0
-
toString
- Overrides:
toStringin classUserTarget<A extends Address>
-
equals
- Overrides:
equalsin classUserTarget<A extends Address>
-
hashCode
public int hashCode()- Overrides:
hashCodein classUserTarget<A extends Address>
-
duplicate
Description copied from interface:TargetCreates a new copy of this target with the same address type. -
setAuthoritativeEngineID
public void setAuthoritativeEngineID(byte[] authoritativeEngineID) Sets the authoritative engine ID of this target. If the authoritative engine ID has currently a length of zero andgetAuthenticationKey()is notnullthenlocalize(byte[])is being called with the provided authoritative engine ID to localize the provisioned auth and priv passphrases with the discovered authoritative engine ID.- Overrides:
setAuthoritativeEngineIDin classUserTarget<A extends Address>- Parameters:
authoritativeEngineID- a possibly zero-length byte array (must not benull).- Since:
- 3.9.3
-