Package org.snmp4j.security
Class UsmUser
java.lang.Object
org.snmp4j.security.UsmUser
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable
,User
The
UsmUser
class represents USM user providing information
to secure SNMPv3 message exchange. A user is characterized by its security
name and optionally by a authentication protocol and passphrase as well as
a privacy protocol and passphrase.
There are no setters for the attributes of this class, to prevent inconsistent states in the USM, when a user is changed from outside.
- Version:
- 2.4.3
- Author:
- Frank Fock
- See Also:
-
Constructor Summary
ConstructorDescriptionUsmUser
(OctetString securityName, OID authenticationProtocol, OctetString authenticationPassphrase, OID privacyProtocol, OctetString privacyPassphrase) Creates a USM user.UsmUser
(OctetString securityName, OID authenticationProtocol, OctetString authenticationPassphrase, OID privacyProtocol, OctetString privacyPassphrase, OctetString localizationEngineID) Creates a localized USM user. -
Method Summary
Modifier and TypeMethodDescriptionclone()
int
Compares two USM users by their security names.boolean
Gets the authentication passphrase.Gets the authentication protocol ID.Returns the localization engine ID for which this USM user has been already localized.Gets the privacy passphrase.Gets the privacy protocol ID.int
Gets the security model ID of the USM.Gets the user's security name.int
hashCode()
boolean
Indicates whether the passphrases of this USM user need to be localized or not (true
is returned in that case).toString()
-
Constructor Details
-
UsmUser
public UsmUser(OctetString securityName, OID authenticationProtocol, OctetString authenticationPassphrase, OID privacyProtocol, OctetString privacyPassphrase) Creates a USM user.- Parameters:
securityName
- the security name of the user (typically the user name).authenticationProtocol
- the authentication protcol ID to be associated with this user. If set tonull
, this user only supports unauthenticated messages.authenticationPassphrase
- the authentication passphrase. If notnull
,authenticationProtocol
must also be notnull
. RFC3414 §11.2 requires passphrases to have a minimum length of 8 bytes. If the length ofauthenticationPassphrase
is less than 8 bytes anIllegalArgumentException
is thrown.privacyProtocol
- the privacy protcol ID to be associated with this user. If set tonull
, this user only supports unencrypted messages.privacyPassphrase
- the privacy passphrase. If notnull
,privacyProtocol
must also be notnull
. RFC3414 §11.2 requires passphrases to have a minimum length of 8 bytes. If the length ofauthenticationPassphrase
is less than 8 bytes anIllegalArgumentException
is thrown.
-
UsmUser
public UsmUser(OctetString securityName, OID authenticationProtocol, OctetString authenticationPassphrase, OID privacyProtocol, OctetString privacyPassphrase, OctetString localizationEngineID) Creates a localized USM user.- Parameters:
securityName
- the security name of the user (typically the user name).authenticationProtocol
- the authentication protcol ID to be associated with this user. If set tonull
, this user only supports unauthenticated messages.authenticationPassphrase
- the authentication passphrase. If notnull
,authenticationProtocol
must also be notnull
. RFC3414 §11.2 requires passphrases to have a minimum length of 8 bytes. If the length ofauthenticationPassphrase
is less than 8 bytes anIllegalArgumentException
is thrown.privacyProtocol
- the privacy protcol ID to be associated with this user. If set tonull
, this user only supports unencrypted messages.privacyPassphrase
- the privacy passphrase. If notnull
,privacyProtocol
must also be notnull
. RFC3414 §11.2 requires passphrases to have a minimum length of 8 bytes. If the length ofauthenticationPassphrase
is less than 8 bytes anIllegalArgumentException
is thrown.localizationEngineID
- if notnull
, the localizationEngineID specifies the engine ID for which the supplied passphrases are already localized. Such an USM user can only be used with the target whose engine ID equals localizationEngineID.
-
-
Method Details
-
getSecurityName
Gets the user's security name.- Returns:
- a clone of the user's security name.
-
getAuthenticationProtocol
Gets the authentication protocol ID.- Returns:
- a clone of the authentication protocol ID or
null
.
-
getPrivacyProtocol
Gets the privacy protocol ID.- Returns:
- a clone of the privacy protocol ID or
null
.
-
getAuthenticationPassphrase
Gets the authentication passphrase.- Returns:
- a clone of the authentication passphrase or
null
.
-
getPrivacyPassphrase
Gets the privacy passphrase.- Returns:
- a clone of the privacy passphrase or
null
.
-
getLocalizationEngineID
Returns the localization engine ID for which this USM user has been already localized.- Returns:
null
if this USM user is not localized or the SNMP engine ID of the target for which this user has been localized.- Since:
- 1.6
-
isLocalized
public boolean isLocalized()Indicates whether the passphrases of this USM user need to be localized or not (true
is returned in that case).- Returns:
true
if the passphrases of this USM user represent localized keys.- Since:
- 1.6
-
getSecurityModel
public int getSecurityModel()Gets the security model ID of the USM.- Returns:
USM.getID()
-
compareTo
Compares two USM users by their security names.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- anotherUsmUser
instance.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
clone
-
equals
-
hashCode
public int hashCode() -
toString
-