|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.adventnet.snmp.snmp2.SecurityModelEntry
|
+--com.adventnet.snmp.snmp2.usm.USMUserEntry
The USMUserEntry holds the configuration data specific to each user for a given SNMPv3 entity. This class represents the User Based Security Model and has the user security attrubutes like the auth and priv Passwords, protocols and their localized keys in addition to the userName. It also has authentication and the timeSynchronization routines.
A USMUserEntry is created for each user on whose behalf an SNMP request is to be made. A new instance is created with the userName and the engineID, where the engineID is got from a discovery procedure. The SnmpEngineEntry is used to create a new SnmpV3 entity and provide the methods to do discovery. For an agent side implementation, the engineID will be the agent's engineID and hence the discovery process will not be required. All the other user attributes can be added using the set methods of the respective attributes. If the auth/priv password is set, then the auth/priv key(localized key) can be generated using the password_to_key method in the USMUtils class.
This class also provides the Authentication and TimeSynchronization routines. The authentication routine, checks the message digest and updates the time values such as the engine boots, time and also the lastReceivedTime. In case of the agent side implementaion it does the timeliness check.
The USMUserEntry has a reference to the SnmpEngineEntry. So when a new USMUserEntry is created, its corresponding SnmpV3 entity reference should be set in the USMUserEntry. This class provides the methods to access the SnmpEngineEntry.
USMUserTable, Serialized Form| Field Summary | |
(package private) static int |
ACTIVE
The below are the various RowStatus constants |
(package private) byte[] |
authKey
Authorization key |
(package private) byte[] |
authParams
|
(package private) byte[] |
authPassword
Authorization Password |
(package private) int |
authPos
|
(package private) int |
authProtocol
authProtocol for this combination of securityName and snmpEngineID |
static int |
CBC_DES
Constant for SNMPV3 usmUser CBC_DES PrivProtocol. |
static int |
CFB_AES_128
Constant for SNMPV3 usmUser CFB_AES PrivProtocol. |
(package private) static int |
CREATEANDGO
|
(package private) static int |
CREATEANDWAIT
|
(package private) static SnmpOID |
DECRYPT_ERROR_OID
|
(package private) static int |
DESTROY
|
(package private) boolean |
enableAdd
If the engineId is set directly on a PDU, then the discovery need not be done. |
(package private) int |
engineBoots
|
(package private) SnmpEngineEntry |
engineEntry
|
(package private) byte[] |
engineID
Engine identifier associated with the SNMP engine |
(package private) int |
engineTime
|
(package private) long |
localTime
|
static int |
MD5_AUTH
Constant for SNMPV3 usmUser MD5 AuthProtocol. |
static int |
NO_AUTH
Constant for SNMPV3 usmNoAuthProtocol. |
static int |
NO_PRIV
Constant for SNMPV3 usmNoPrivProtocol. |
(package private) static int |
NONVOLATILE
|
(package private) static SnmpOID |
NOT_TIME_WINDOWS_OID
|
(package private) static int |
NOTINSERVICE
|
(package private) static int |
NOTREADY
|
(package private) static int |
OTHER
The below are the various StorageType constants |
(package private) boolean |
ownKeyChange
A private boolean variable to signify the Own Key change flag.This is required if a OwnKeyChange request comes to the agent in which case the agent needs to encode a proper digest.ie., the digest should be made w.r.t the auth/priv key prior to the change, otherwise a digest failure will occur in the manager. |
(package private) static int |
PERMANENT
|
(package private) byte[] |
privKey
Privacy Key |
(package private) byte[] |
privParams
|
(package private) byte[] |
privPassword
Privacy Password |
(package private) int |
privProtocol
Privacy protocol to be used |
(package private) static java.util.Random |
rand
|
(package private) static int |
READONLY
|
(package private) boolean |
respondToDiscovery
|
(package private) byte |
securityLevel
User's default security Level |
(package private) byte[] |
securityName
Model Independent SecurityName |
static int |
SHA_AUTH
Constant for SNMPV3 usmUser SHA AuthProtocol. |
(package private) int |
storageType
The StorageType variable |
(package private) USMUserEntry |
tempEntry
Used for encoding the USM message if own key change is effected, otherwise the digest will fail. |
(package private) static SnmpOID |
UKN_ENGINEID_OID
|
(package private) static SnmpOID |
UKN_USERNAMES_OID
|
(package private) static SnmpOID |
UNSUPP_SEC_LEVEL_OID
|
(package private) int[] |
userCloneFrom
The USM UserCloneFrom variable |
(package private) byte[] |
userName
User Name : Is same as SecurityName for USM |
(package private) byte[] |
userPublic
The USMUserPublic variable |
(package private) int |
userStatus
The userStatus variable |
static byte |
USM_SECURITY_MODEL
Constant for the User Based Security Model. |
(package private) java.lang.Object |
utils
|
(package private) static int |
VOLATILE
|
(package private) static SnmpOID |
WRONG_DIGEST_OID
|
| Constructor Summary | |
USMUserEntry()
Constructs a new USMUserEntry with the default userName
of initial. |
|
USMUserEntry(byte[] user,
byte[] id)
Creates a new USMUserEntry using the specified userName
and engineID. |
|
| Method Summary | |
(package private) static void |
|
int |
authenticate(Snmp3Message msg)
This performs the authentication for this user entry. |
void |
authenticateMessageToSend(Snmp3Message msg,
SnmpSession session)
Performs authentication of the received message as per the security model. |
int |
authenticateReceivedMessage(Snmp3Message msg,
SnmpSession session)
Performs authentication of the received message as per the USM security model. |
(package private) int |
checkAuthTimes(int boots,
int time,
SnmpAPI api)
|
(package private) int |
checkNonAuthTimes(int boots,
int time)
Checks the time values for a non-authoritative role packet(localEngineid!=pduEngineId) |
(package private) boolean |
compare(byte[] a,
byte[] b)
A byte array comparison routine. |
SecurityModelEntry |
copy()
Returns a copy of this USMUserEntry. |
SecurityModelEntry |
copy(byte[] engineID,
byte[] userName)
Returns a copy of this USMUserEntry with the userName and engineID, initialized to the values passed. |
void |
decodeMsgSecurityParams(Snmp3Message msg,
SnmpSession session,
ASN1Parser asnParser)
This method will decode the USM security parameters. |
byte[] |
decrypt(byte[] data,
int spaceLeft,
byte[] key,
int protocol,
byte[] privParms)
This method is called to decrypt the data. |
boolean |
encodeMsgSecurityParams(Snmp3Message msg,
SnmpAPI API,
ASN1Parser asnParser)
This method will encode the USM message security parameters. |
int |
encrypt(byte[] data,
int spaceLeft,
byte[] key,
int protocol,
byte[] privParms)
This method is called to encrypt the data. |
byte[] |
getAuthKey()
Retrieves the authentication key. |
byte[] |
getAuthParams()
Gets the auth params. |
byte[] |
getAuthPassword()
Retrieves the authentication password. |
int |
getAuthProtocol()
Returns the authentication Protocol used. |
int |
getEngineBoots()
Retrieve the engine boots value. |
SnmpEngineEntry |
getEngineEntry()
Gets the corresponding SnmpEngineEntry reference. |
byte[] |
getEngineID()
Retrieves the Engine identifier associated with the SNMP engine. |
(package private) int |
getEngineTime()
Retrieve the corresponding engineTime |
java.lang.Object |
getKey()
Retrieve the hash key for this user entry. |
static java.lang.Object |
getKey(byte[] name,
byte[] id)
Retrieve the key for this user object. |
(package private) long |
getLocalTime()
|
byte[] |
getPrivKey()
Retrieves the privacy key value. |
byte[] |
getPrivParams()
Retrieve the priv params. |
byte[] |
getPrivPassword()
Gets the privacy password. |
int |
getPrivProtocol()
Retrieves the privacy protocol value. |
byte[] |
getSecurityID(byte[] securityName)
Returns the securityID ( which depends on the security model ). |
byte |
getSecurityLevel()
Retrieves the security level value for this user entry. |
int |
getSecurityModel()
Returns the securityModel. |
byte[] |
getSecurityName()
Gets the security name, which is independent of the security model. |
byte[] |
getSecurityName(byte[] securityID)
Gets the security name ( which is independent of the security model ) using the securityID ( which depends on the security model ). |
int |
getSnmpEngineTime()
|
int |
getStorageType()
Gets the USM StorageType associated with this USMUserEntry. |
int[] |
getUserCloneFrom()
Gets the USMUserCloneFrom OID associated with this USMUserEntry. |
byte[] |
getUserName()
Gets the userName associated with this user. |
byte[] |
getUserPublic()
Gets the USM UserPublic associated with this USMUserEntry. |
int |
getUserStatus()
Gets the USM UserStatus associated with this USMUserEntry. |
void |
init(SnmpSession session,
ProtocolOptions po)
|
void |
processEncodedMsg(Snmp3Message msg,
ASN1Parser asnParser)
This method is called after encoding the message version. |
int |
sendTimeSync(SnmpSession session)
Achieves time sync with remotehost. |
int |
sendTimeSync(SnmpSession session,
ProtocolOptions po,
int reqID)
Achieves time sync with remotehost. |
void |
setAuthKey(byte[] key)
Sets the authentication key. |
void |
setAuthParams(byte[] param)
Sets the auth params value. |
void |
setAuthPassword(byte[] passwd)
Sets the authentication password. |
void |
setAuthProtocol(int protocol)
Sets the authentication Protocol to be used. |
void |
setEngineBoots(int boots)
Sets the engineBoots corresponding to this user's corresponding engine entry |
void |
setEngineEntry(SnmpEngineEntry entry)
Sets the SnmpEngineEntry reference. |
(package private) void |
setEngineTime(int time)
Sets the engineTime for this user's engine entry |
(package private) void |
setLocalTime(long l)
|
void |
setOwnKeyChange(boolean flag)
Sets the ownKeyChange flag. |
void |
setPrivKey(byte[] key)
Sets the privacy key. |
void |
setPrivParams(byte[] param)
Sets the priv params field. |
void |
setPrivPassword(byte[] passwd)
Sets the privacy password. |
void |
setPrivProtocol(int protocol)
Sets the privacy protocol to be used. |
void |
setSecurityLevel(byte level)
Sets the security level for this user entry. |
void |
setSecurityName(byte[] name)
Sets the security name by taking the byte array as argument. |
void |
setSnmpEngineTime(int et)
|
void |
setStorageType(int storageType)
Sets the USM StorageType associated with this USMUserEntry. |
void |
setUserCloneFrom(int[] oid)
Sets the USM UserCloneFrom OID for this USMUserEntry. |
(package private) void |
setUserName(byte[] name)
|
void |
setUserPublic(byte[] userPublic)
Sets the USM UserPublic associated with this USMUserEntry. |
void |
setUserStatus(int userStatus)
Sets the USM UserStatus associated with this USMUserEntry. |
void |
setUSMUtils(java.lang.Object utils)
The Utils object should be set, so that it can be used for encryption purpose. |
void |
timeSync(SnmpSession session)
Deprecated. This method does not throw any exception and hence does not inform the user, in case of any error. As of AdventNet SNMP API 4 SP2 ( Release 4.0.2 ), replaced by timeSynchronize(SnmpSession,ProtocolOptions) |
void |
timeSynchronize(SnmpSession session,
ProtocolOptions po)
Achieves time sync with the remote host. |
(package private) void |
updateTimes(int boots,
int time)
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
boolean enableAdd
public static final byte USM_SECURITY_MODEL
public static final int NO_AUTH
public static final int MD5_AUTH
public static final int SHA_AUTH
public static final int NO_PRIV
public static final int CBC_DES
public static final int CFB_AES_128
static final SnmpOID UNSUPP_SEC_LEVEL_OID
static final SnmpOID NOT_TIME_WINDOWS_OID
static final SnmpOID UKN_USERNAMES_OID
static final SnmpOID UKN_ENGINEID_OID
static final SnmpOID WRONG_DIGEST_OID
static final SnmpOID DECRYPT_ERROR_OID
byte[] engineID
byte[] userName
byte[] securityName
int authProtocol
byte[] authPassword
byte[] authKey
int privProtocol
byte[] privKey
byte[] privPassword
byte securityLevel
int engineBoots
int engineTime
long localTime
byte[] authParams
int authPos
byte[] privParams
SnmpEngineEntry engineEntry
int[] userCloneFrom
byte[] userPublic
static final int OTHER
static final int VOLATILE
static final int NONVOLATILE
static final int PERMANENT
static final int READONLY
int storageType
static final int ACTIVE
static final int NOTINSERVICE
static final int NOTREADY
static final int CREATEANDGO
static final int CREATEANDWAIT
static final int DESTROY
int userStatus
USMUserEntry tempEntry
boolean ownKeyChange
java.lang.Object utils
static java.util.Random rand
boolean respondToDiscovery
| Constructor Detail |
public USMUserEntry()
USMUserEntry with the default userName
of initial. This is used by the Snmp3Message class
constructor. The API user should not use this constructor.
public USMUserEntry(byte[] user,
byte[] id)
USMUserEntry using the specified userName
and engineID. The engineID can be learned from the discovery, for
which a new SnmpV3 entity has to be created using the SnmpEngineEntry.
For an agent side implementation, its own engineID is used.user - The userName, on whose behalf SNMP requests are to be madeid - The engineID of the SnmpV3 entity. In the context of the
SnmpV3 entity as a manager, the engineID is that of the peer agent
and can be learned from the discovery procedure. In case of the SnmpV3
entity as an agent, the engineID is the agent's engineID.SnmpEngineEntry.| Method Detail |
public byte[] getEngineID()
public byte[] getUserName()
void setUserName(byte[] name)
public byte[] getSecurityName()
public byte[] getSecurityName(byte[] securityID)
public byte[] getSecurityID(byte[] securityName)
public void setSecurityName(byte[] name)
public int getSecurityModel()
public int getAuthProtocol()
public void setAuthProtocol(int protocol)
protocol - The authentication Protocol to be used.public byte[] getAuthPassword()
public void setAuthPassword(byte[] passwd)
passwd - The authPassword to be used.public byte[] getAuthKey()
public void setAuthKey(byte[] key)
key - The localized authentication keypublic int getPrivProtocol()
public void setPrivProtocol(int protocol)
protocol - The privProtocol to be used.public byte[] getPrivKey()
public void setPrivKey(byte[] key)
key - The localized secret privacy key.public byte[] getPrivPassword()
public void setPrivPassword(byte[] passwd)
passwd - The privacy password.public byte getSecurityLevel()
public void setSecurityLevel(byte level)
level - The securityLevel to be used for this user entry.public void setEngineBoots(int boots)
public int getEngineBoots()
void setEngineTime(int time)
int getEngineTime()
long getLocalTime()
void setLocalTime(long l)
public int getSnmpEngineTime()
public void setSnmpEngineTime(int et)
public void setAuthParams(byte[] param)
param - The msgAuthentication parameters.public byte[] getAuthParams()
public void setPrivParams(byte[] param)
param - The msgPrivacyParameters.public byte[] getPrivParams()
public void setEngineEntry(SnmpEngineEntry entry)
entry - The SnmpEngineEntry to be set.public SnmpEngineEntry getEngineEntry()
public int[] getUserCloneFrom()
public void setUserCloneFrom(int[] oid)
oid - The clone from OID to set.public byte[] getUserPublic()
public void setUserPublic(byte[] userPublic)
userPublic - The usmUserPublic value to be used to set on
this entry.public int getStorageType()
public void setStorageType(int storageType)
public int getUserStatus()
public void setUserStatus(int userStatus)
userStatus - The row status value to be set on this entry.public void setOwnKeyChange(boolean flag)
flag - the flag value shlould be true if an ownKeyChange
is to be performed. The default value is false.public void setUSMUtils(java.lang.Object utils)
public java.lang.Object getKey()
String Object.
public static java.lang.Object getKey(byte[] name,
byte[] id)
String Object.public int authenticate(Snmp3Message msg)
msg - The Snmp3Message instance.public void timeSync(SnmpSession session)
timeSynchronize(SnmpSession,ProtocolOptions)
session - The SnmpSession instance, over which the the timeSync
request is sent.
public void timeSynchronize(SnmpSession session,
ProtocolOptions po)
throws SnmpException
session - The SnmpSession instance, over which the the timeSync
request is sent.po - The ProtocolOptions instancepublic int sendTimeSync(SnmpSession session)
session - The SnmpSession instance, over which the timeSync
request is sent.
public int sendTimeSync(SnmpSession session,
ProtocolOptions po,
int reqID)
throws SnmpException
session - The SnmpSession instance, over which the timeSync
request is sent.po - The ProtocolOptions instance
int checkNonAuthTimes(int boots,
int time)
int checkAuthTimes(int boots,
int time,
SnmpAPI api)
void updateTimes(int boots,
int time)
boolean compare(byte[] a,
byte[] b)
public SecurityModelEntry copy()
public SecurityModelEntry copy(byte[] engineID,
byte[] userName)
engineID - The engineID to be set in the cloned entry.userName - The userName to be set in the cloned entry.static void()
public int authenticateReceivedMessage(Snmp3Message msg,
SnmpSession session)
msg - The Snmp3Message instance.session - The SnmpSession instance incase this module requires
to reply appropriately.
public void authenticateMessageToSend(Snmp3Message msg,
SnmpSession session)
throws SnmpException
msg - The Snmp3Message instance.session - The SnmpSession instance.
public boolean encodeMsgSecurityParams(Snmp3Message msg,
SnmpAPI API,
ASN1Parser asnParser)
msg - The Snmp3Message instance.API - The SnmpAPI Instance.asnParser - The reference to ASN1Parser which has the
methods to encode the SnmpPDU.
public void decodeMsgSecurityParams(Snmp3Message msg,
SnmpSession session,
ASN1Parser asnParser)
throws SnmpException,
java.lang.ArrayIndexOutOfBoundsException
msg - The Snmp3Message instance.asnParser - The reference to ASN1Parser, which has the
data and methods to encode/decode the SnmpPDU.
public void processEncodedMsg(Snmp3Message msg,
ASN1Parser asnParser)
msg - Snmp3Messgage instance.asnParser - The reference to ASN1Parser which has the
encoded data and methods to encode SnmpPDU.
public int encrypt(byte[] data,
int spaceLeft,
byte[] key,
int protocol,
byte[] privParms)
throws SnmpException
data - The data to be encrypt.spaceleft - The space left in the buffer while encoding.key - The key value used in encryption.protocol - The protocol used for encryption.privParams - The privacy params used in encryption.
public byte[] decrypt(byte[] data,
int spaceLeft,
byte[] key,
int protocol,
byte[] privParms)
data - The data to be decrypt.offset - The offset value to be used in decrypt.key - The key value to be used in decryption.protocol - The protocol used for decryption.privParams - The privacy params used in decryption.
public void init(SnmpSession session,
ProtocolOptions po)
throws SnmpException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||