- java.lang.Object
-
- org.snmp4j.AbstractTarget<A>
-
- org.snmp4j.SecureTarget<A>
-
- org.snmp4j.UserTarget<A>
-
- org.snmp4j.DirectUserTarget<A>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Target<A>
public class DirectUserTarget<A extends Address> extends UserTarget<A>
User based target for SNMPv3 User Based Security ModelUSM
or later that includes any necessary authentication and privacy information, i.e. protocol references and localized keys. In contrast to the base classUserTarget
, theDirectUserTarget
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
- Author:
- Frank Fock
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.snmp4j.UserTarget
authoritativeEngineID
-
Fields inherited from class org.snmp4j.AbstractTarget
securityLevel, securityModel, securityName
-
-
Constructor Summary
Constructors Constructor Description DirectUserTarget()
Creates 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 a 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Target<A>
duplicate()
Creates a new copy of this target with the same address type.boolean
equals(java.lang.Object o)
OctetString
getAuthenticationKey()
Gets the authentication key associated directly with this user target (withoutUSM
user table lookup).AuthenticationProtocol
getAuthenticationProtocol()
Get theAuthenticationProtocol
associated with this target ornull
if there is no direct user information provided but referenced by theAbstractTarget.securityName
from theUSM
or if there is no authentication.OctetString
getPrivacyKey()
Gets the privacy key associated directly with this user target (withoutUSM
user table lookup).PrivacyProtocol
getPrivacyProtocol()
Get thePrivacyProtocol
associated with this target ornull
if there is no direct user information provided but referenced by theAbstractTarget.securityName
from theUSM
or there is no privacy.int
hashCode()
void
setAuthenticationKey(OctetString authenticationKey)
Sets the authentication key (localized for theUserTarget.authoritativeEngineID
) to be used for this target directly.void
setAuthenticationProtocol(AuthenticationProtocol authenticationProtocol)
Set theAuthenticationProtocol
associated with this target ornull
if there is no direct user information provided but referenced by theAbstractTarget.securityName
from theUSM
or if there is no authentication.void
setPrivacyKey(OctetString privacyKey)
Sets the privacy key (localized for theUserTarget.authoritativeEngineID
) to be used for this target directly.void
setPrivacyProtocol(PrivacyProtocol privacyProtocol)
/** Set thePrivacyProtocol
associated with this target ornull
if there is no direct user information provided but referenced by theAbstractTarget.securityName
from theUSM
or if there is no privacy.java.lang.String
toString()
-
Methods inherited from class org.snmp4j.UserTarget
getAuthoritativeEngineID, setAuthoritativeEngineID
-
Methods 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 Detail
-
DirectUserTarget
public DirectUserTarget()
Creates a target for a user based security model target.
-
DirectUserTarget
public DirectUserTarget(UserTarget<A> userTarget)
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 a SNMPv3 USM target with the supplied security level, one second time-out without retries. The security level is deducted from the keys given (authenticationKey
andprivacyKey
). If both arenull
or have zero length,SecurityLevel.noAuthNoPriv
is used; ifauthenticationKey
is given butprivacyKey
not, thenSecurityLevel.authNoPriv
, andSecurityLevel.authPriv
otherwise.- Parameters:
address
- the transportAddress
of 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 (ornull
forSecurityLevel.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 (ornull
forSecurityLevel.noAuthNoPriv
orSecurityLevel.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
-
-
Method Detail
-
getAuthenticationKey
public OctetString getAuthenticationKey()
Gets the authentication key associated directly with this user target (withoutUSM
user table lookup). Ifnull
is returned and theAbstractTarget.securityLevel
is notSecurityLevel.noAuthNoPriv
, then the authentication must be looked up from aUSM
instance, when sending a SNMPv3 message to a target,- Returns:
- the localized authentication key directly associated with this target.
- Since:
- 3.4.0
-
setAuthenticationKey
public void setAuthenticationKey(OctetString authenticationKey)
Sets the authentication key (localized for theUserTarget.authoritativeEngineID
) to be used for this target directly. Note: This has no effect unlessAbstractTarget.securityLevel
isSecurityLevel.authNoPriv
orSecurityLevel.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 theUSM
by theAbstractTarget.securityName
.- Since:
- 3.4.0
-
getPrivacyKey
public OctetString getPrivacyKey()
Gets the privacy key associated directly with this user target (withoutUSM
user table lookup). Ifnull
is returned and theAbstractTarget.securityLevel
isSecurityLevel.authPriv
then the privacy key must be looked up from aUSM
instance, when sending a SNMPv3 message to a target.- Returns:
- the localized privacy key directly associated with this target.
- Since:
- 3.4.0
-
setPrivacyKey
public void setPrivacyKey(OctetString privacyKey)
Sets the privacy key (localized for theUserTarget.authoritativeEngineID
) to be used for this target directly. Note: This has no effect unlessauthenticationKey
is also set andAbstractTarget.securityLevel
isSecurityLevel.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 theUSM
by theAbstractTarget.securityName
.- Since:
- 3.4.0
-
getAuthenticationProtocol
public AuthenticationProtocol getAuthenticationProtocol()
Get theAuthenticationProtocol
associated with this target ornull
if there is no direct user information provided but referenced by theAbstractTarget.securityName
from theUSM
or 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
public void setAuthenticationProtocol(AuthenticationProtocol authenticationProtocol)
Set theAuthenticationProtocol
associated with this target ornull
if there is no direct user information provided but referenced by theAbstractTarget.securityName
from theUSM
or 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
public PrivacyProtocol getPrivacyProtocol()
Get thePrivacyProtocol
associated with this target ornull
if there is no direct user information provided but referenced by theAbstractTarget.securityName
from theUSM
or 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
public void setPrivacyProtocol(PrivacyProtocol privacyProtocol)
/** Set thePrivacyProtocol
associated with this target ornull
if there is no direct user information provided but referenced by theAbstractTarget.securityName
from theUSM
or 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
public java.lang.String toString()
- Overrides:
toString
in classUserTarget<A extends Address>
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classUserTarget<A extends Address>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classUserTarget<A extends Address>
-
-