|
|||||||||
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 FormField Summary | |
static int |
CBC_DES
Constant for SNMPV3 usmUser CBC_DES PrivProtocol. |
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. |
static int |
SHA_AUTH
Constant for SNMPV3 usmUser SHA AuthProtocol. |
static byte |
USM_SECURITY_MODEL
Constant for the User Based Security Model. |
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 | |
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. |
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. |
SnmpEngineEntry |
getEngineEntry()
Gets the corresponding SnmpEngineEntry reference. |
byte[] |
getEngineID()
Retrieves the Engine identifier associated with the SNMP engine. |
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. |
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 |
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 |
processEncodedMsg(Snmp3Message msg,
ASN1Parser asnParser)
This method is called after encoding the message version. |
int |
sendTimeSync(SnmpSession session)
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 |
setEngineEntry(SnmpEngineEntry entry)
Sets the SnmpEngineEntry reference. |
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 |
setStorageType(int storageType)
Sets the USM StorageType associated with this USMUserEntry. |
void |
setUserCloneFrom(int[] oid)
Sets the USM UserCloneFrom OID for this USMUserEntry. |
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)
Achieves time sync with the remote host. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
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
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()
getEngineID
in class SecurityModelEntry
public byte[] getUserName()
public byte[] getSecurityName()
getSecurityName
in class SecurityModelEntry
public byte[] getSecurityName(byte[] securityID)
getSecurityName
in class SecurityModelEntry
public byte[] getSecurityID(byte[] securityName)
getSecurityID
in class SecurityModelEntry
public void setSecurityName(byte[] name)
setSecurityName
in class SecurityModelEntry
public int getSecurityModel()
getSecurityModel
in class SecurityModelEntry
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()
getSecurityLevel
in class SecurityModelEntry
public void setSecurityLevel(byte level)
setSecurityLevel
in class SecurityModelEntry
level
- The securityLevel to be used for this user entry.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()
getKey
in class SecurityModelEntry
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)
session
- The SnmpSession instance, over which the the timeSync
request is sent.public int sendTimeSync(SnmpSession session)
session
- The SnmpSession instance, over which the timeSync
request is sent.public SecurityModelEntry copy()
copy
in class SecurityModelEntry
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.public int authenticateReceivedMessage(Snmp3Message msg, SnmpSession session)
authenticateReceivedMessage
in class SecurityModelEntry
msg
- The Snmp3Message instance.session
- The SnmpSession instance incase this module requires
to reply appropriately.public void authenticateMessageToSend(Snmp3Message msg, SnmpSession session) throws SnmpException
authenticateMessageToSend
in class SecurityModelEntry
msg
- The Snmp3Message instance.session
- The SnmpSession instance.SnmpException
- If the message could not be authenticated
properly or particular entry is not available.public boolean encodeMsgSecurityParams(Snmp3Message msg, SnmpAPI API, ASN1Parser asnParser)
encodeMsgSecurityParams
in class SecurityModelEntry
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
decodeMsgSecurityParams
in class SecurityModelEntry
msg
- The Snmp3Message instance.asnParser
- The reference to ASN1Parser, which has the
data and methods to encode/decode the SnmpPDU.SnmpException
- If the security parameters could not be
decoded properly.java.lang.ArrayIndexOutOfBoundsException
- If an unrecognized
snmp message.public void processEncodedMsg(Snmp3Message msg, ASN1Parser asnParser)
processEncodedMsg
in class SecurityModelEntry
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
SecurityModelEntry
encrypt
in class SecurityModelEntry
com.adventnet.snmp.snmp2.SecurityModelEntry
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)
SecurityModelEntry
decrypt
in class SecurityModelEntry
com.adventnet.snmp.snmp2.SecurityModelEntry
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |