|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.adventnet.snmp.snmp2.usm.USMUtils
This class provides general USM related methods. All the methods in this class are static. There is no need to instantiate this class. The methods include password to key conversion, digest authentication keyChange routines. The init_v3_params provide a simple interface to set up a user configuration for communicating with a v3 entity.
Method Summary | |
static byte[] |
getDigest(int authProtocol,
byte[] authKey,
byte[] data)
Returns the USMUserEntry.MD5_AUTH or USMUserEntry.SHA_AUTH Digest. |
static java.security.MessageDigest |
getDigestImpl(int algorithm)
Returns the MessageDigest Implementation. |
static int |
getHashLength(int protocol)
Returns the length of the hash associated with the protocol. |
static byte[] |
getKey(int authProtocol,
boolean isFixedLen,
int keyLength,
int hashLength,
byte[] keyChange,
byte[] keyOld,
byte[] random)
Gives the new key corresponding to the keyChange value provided |
static java.lang.Object |
getKey(java.lang.String name,
int port,
byte[] userName)
Retrieves the Hash key associated with the given host, port and userName. |
static byte[] |
getKeyChange(int authProtocol,
boolean isFixedLen,
int keyLength,
int hashLength,
byte[] keyNew,
byte[] keyOld,
byte[] random)
Returns the keyChange value required for a key change operation. |
static int |
getKeyLength(int protocol)
Returns the key Length associated with the protocol |
static void |
init_v3_parameters(java.lang.String userName,
int authProtocol,
java.lang.String authPassword,
java.lang.String privPassword,
java.lang.String targetHost,
int port,
SnmpSession session)
A comprehensive initialization routine that creates new SnmpV3 entities and user entries and performs discovery and time synchronization. |
static void |
init_v3_parameters(java.lang.String userName,
int authProtocol,
java.lang.String authPassword,
java.lang.String privPassword,
java.lang.String engineName,
SnmpSession session)
A comprehensive initialization routine that creates new SnmpV3 entities and user entries and performs discovery and time synchronization. |
static void |
init_v3_params(java.lang.String userName,
int authProtocol,
java.lang.String authPassword,
java.lang.String privPassword,
java.lang.String targetHost,
int port,
SnmpSession session)
A comprehensive initialization routine that creates new SnmpV3 entities and user entries and performs discovery and time synchronization. |
static void |
init_v3_params(java.lang.String userName,
int authProtocol,
java.lang.String authPassword,
java.lang.String privPassword,
java.lang.String engineName,
SnmpSession session)
A comprehensive initialization routine that creates new SnmpV3 entities and user entries and performs discovery and time synchronization. |
static byte[] |
password_to_key(int authProtocol,
byte[] password,
int passwordlen,
byte[] id)
The password to key implementation. |
static java.lang.String |
printOctets(byte[] data,
int length)
Prints the octet data in a more readable form. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static byte[] password_to_key(int authProtocol, byte[] password, int passwordlen, byte[] id)
authProtocol
- The authentication protocol. Right now only
MD5 and SHA is supported.password
- The password to be used for converting to the
localized key.passwordlen
- The length of the password.id
- The engineID to be used for converting to the localized key.public static java.security.MessageDigest getDigestImpl(int algorithm) throws java.security.NoSuchAlgorithmException
algorithm
- The protocol to be used. Right now it is only
MD5 or SHA.java.security.NoSuchAlgorithmException
- is thrown on error.public static byte[] getKeyChange(int authProtocol, boolean isFixedLen, int keyLength, int hashLength, byte[] keyNew, byte[] keyOld, byte[] random)
authProtocol
- The authentication scheme. USMUserEntry.MD5_AUTH or USMUserEntry.SHA_AUTHisFixedLen
- fixed/variable. Both MD5 & SHA have fixed secret key length.keyLength
- 16 for MD5 and 20 for SHA. This will be 16 for CBC-DES.hashLength
- 16 for MD5 and 20 for SHA.public static byte[] getKey(int authProtocol, boolean isFixedLen, int keyLength, int hashLength, byte[] keyChange, byte[] keyOld, byte[] random)
authProtocol
- the authentication protocol.isFixedLen
- indicates whether the length of the key is fixed
for the protocol. true for both MD5 and SHA.keyLength
- the length of the key associated with this protocol.hashLength
- the length of the hash associated with the protocol.keyChange
- the key change value.keyOld
- the original key value.public static java.lang.String printOctets(byte[] data, int length)
data
- the byte array representing the data to be printed.length
- the number of bytes of data to be printed in hex format.public static byte[] getDigest(int authProtocol, byte[] authKey, byte[] data)
authProtocol
- The authentication protocol. Right now only MD5
and SHA is supported.authKey
- The localized authentication key.data
- The pdu data over which the digest is to be computed.public static int getKeyLength(int protocol)
public static int getHashLength(int protocol)
public static void init_v3_params(java.lang.String userName, int authProtocol, java.lang.String authPassword, java.lang.String privPassword, java.lang.String targetHost, int port, SnmpSession session)
userName
- The string representing the SnmpV3 principal.authProtocol
- The authentication protocol. Should be one of
the constants, MD5_AUTH, SHA_AUTH or NO_AUTH. These constants are
defined in USMUserEntry.authPassword
- The authentication password, which is converted
to a localized key.privPassword
- The privacy password, which is converted into a
localized private key. The only supported protocol is CBC_DES.targetHost
- The hostName of the SNMP peer.port
- The port of the SNMP peer.session
- The SnmpSession instance. This should be in an open
state. The discovery and timeSync messages are sent over this session.public static void init_v3_parameters(java.lang.String userName, int authProtocol, java.lang.String authPassword, java.lang.String privPassword, java.lang.String targetHost, int port, SnmpSession session) throws SnmpException
userName
- The string representing the SnmpV3 principal.authProtocol
- The authentication protocol. Should be one of
the constants, MD5_AUTH, SHA_AUTH or NO_AUTH. These constants are
defined in USMUserEntry.authPassword
- The authentication password which is converted
to a localized key.privPassword
- The privacy password which is converted into a
localized private key. The only supported protocol is CBC_DES.targetHost
- The hostName of the SNMP peer.port
- The port of the SNMP peer.session
- The SnmpSession instance. This should be in an open
state. The discovery and timeSync messages are sent over this session.SnmpException
- is thrown on error.public static void init_v3_params(java.lang.String userName, int authProtocol, java.lang.String authPassword, java.lang.String privPassword, java.lang.String engineName, SnmpSession session)
userName
- The string representing the SnmpV3 principal.authProtocol
- The authentication protocol. Should be one of
the constants, MD5_AUTH, SHA_AUTH or NO_AUTH. These constants are
defined in USMUserEntry.authPassword
- The authentication password which is converted
to a localized key.privPassword
- The privacy password which is converted into a
localized private key. The only supported protocol is CBC_DES.engineName
- The string value of the engine entry.session
- The SnmpSession instance. This should be in an open
state. The discovery and timeSync messages are sent over this session.public static void init_v3_parameters(java.lang.String userName, int authProtocol, java.lang.String authPassword, java.lang.String privPassword, java.lang.String engineName, SnmpSession session) throws SnmpException
SnmpException
- is thrown on error.public static java.lang.Object getKey(java.lang.String name, int port, byte[] userName)
name
- hostName or engineName for UDP/IP or Independent Transport
Protocol respectively.port
- the remotePort. -1 in the case of Independent Transport Protocol.userName
- the UserName set in the case of v3.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |