HOME

com.ireasoning.protocol.snmp
Class UsmUser

java.lang.Object
  extended bycom.ireasoning.protocol.snmp.UsmUser
All Implemented Interfaces:
Serializable

public class UsmUser
extends Object
implements Serializable

This class represents user information (in SNMPV3)

See Also:
Serialized Form

Field Summary
static byte AUTH_NO_PRIV
          securityLevel: Auth No Privacy
static byte AUTH_PRIV
          securityLevel: Auth and Privacy
static byte NO_AUTH_NO_PRIV
          securityLevel: No Auth No Privacy
 
Constructor Summary
UsmUser(String userName, String authProtocol, byte[] authKey, byte[] privKey, byte[] engineID)
          Constructs UsmUser object.
UsmUser(String userName, String authProtocol, int privProtocol, byte[] authKey, byte[] privKey, byte[] engineID)
          Constructs UsmUser object.
UsmUser(String userName, String authProtocol, int privProtocol, byte securityLevel, String authPassword, String privPassword, byte[] engineID, boolean keyExpansionWithEngineID)
          Constructs UsmUser object.
UsmUser(String userName, String authProtocol, String authPassword, int privProtocol, String privPassword, byte[] engineID)
          Constructs UsmUser object.
UsmUser(String userName, String authProtocol, String authPassword, int privProtocol, String privPassword, byte[] engineID, boolean keyExpansionWithEngineID)
          Constructs UsmUser object.
UsmUser(String userName, String authProtocol, String authPassword, String privPassword, byte[] engineID)
          Constructs UsmUser object.
 
Method Summary
static byte[] generateKey(String algorithm, String password, byte[] engineID)
          Creates localized key
static byte[] generateKey(String authProtocol, String password, byte[] engineID, int privProtocol, boolean keyExpansionWithEngineID)
          Generates privacy key for different privacy protocols
 byte[] getAuthKey()
          Returns localized auth key
 int getAuthLength()
          Returns the digest length of the auth protocol
 String getAuthPassword()
          Returns auth password
 String getAuthProtocol()
          Returns auth protocol
 byte[] getEngineID()
          Returns engine ID
 boolean getKeyExpansionWithEngineID()
           
static int getPriv(String priv)
           
 byte[] getPrivKey()
          Returns localized privacy key
 String getPrivPassword()
          Returns privacy password
 int getPrivProtocol()
          Returns privacy protocol
 byte getSecurityLevel()
          Returns security level
 String getUserName()
          Returns USM user name
static void main(String[] args)
           
 void setAuthKey(byte[] key)
          Sets a new localized auth key
 void setAuthPassword(String authPassword)
          Sets a new auth password
 void setAuthProtocol(String authProtocol)
          Sets a new auth protocol
 void setEngineID(byte[] engineID)
          Sets a new engineID.
 void setKeyExpansionWithEngineID(boolean b)
           
 void setPrivKey(byte[] key)
          Sets a new localized privacy key
 void setPrivPassword(String privPassword)
          Sets a new privacy password
 void setPrivProtocol(int priv)
          Sets a new privacy protocol
 void setSecurityLevel(byte level)
          Sets a new security level
 void setUserName(String name)
          Sets a new USM user name
 String toString()
           
 void updateKeys()
          Calculates localized keys
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_AUTH_NO_PRIV

public static final byte NO_AUTH_NO_PRIV
securityLevel: No Auth No Privacy

See Also:
Constant Field Values

AUTH_NO_PRIV

public static final byte AUTH_NO_PRIV
securityLevel: Auth No Privacy

See Also:
Constant Field Values

AUTH_PRIV

public static final byte AUTH_PRIV
securityLevel: Auth and Privacy

See Also:
Constant Field Values
Constructor Detail

UsmUser

public UsmUser(String userName,
               String authProtocol,
               String authPassword,
               String privPassword,
               byte[] engineID)
Constructs UsmUser object.

Parameters:
userName - user name
authProtocol - authentication protocol, one of {SnmpConst2.MD5, SnmpConst2.SHA}
authPassword - authentication password
privPassword - privacy protocol password

UsmUser

public UsmUser(String userName,
               String authProtocol,
               String authPassword,
               int privProtocol,
               String privPassword,
               byte[] engineID,
               boolean keyExpansionWithEngineID)
Constructs UsmUser object.

Parameters:
keyExpansionWithEngineID - For AES 192 and 256, localized key will be expanded with the value of engineID.
userName - user name
authProtocol - authentication protocol, one of {SnmpConst.MD5, SnmpConst.SHA, SnmpConst.SHA224, SnmpConst.SHA256, SnmpConst.SHA384, SnmpConst.SHA512}
privProtocol - privacy protocol. One of {SnmpConst.DES, SnmpConst.AES, SnmpConst.AES192, SnmpConst.AES256}
authPassword - authentication password
privPassword - privacy protocol password

UsmUser

public UsmUser(String userName,
               String authProtocol,
               String authPassword,
               int privProtocol,
               String privPassword,
               byte[] engineID)
Constructs UsmUser object.

Parameters:
userName - user name
authProtocol - authentication protocol, one of {SnmpConst.MD5, SnmpConst.SHA, SnmpConst.SHA224, SnmpConst.SHA256, SnmpConst.SHA384, SnmpConst.SHA512}
privProtocol - privacy protocol. One of {SnmpConst.DES, SnmpConst.AES, SnmpConst.AES192, SnmpConst.AES256}
authPassword - authentication password
privPassword - privacy protocol password

UsmUser

public UsmUser(String userName,
               String authProtocol,
               int privProtocol,
               byte securityLevel,
               String authPassword,
               String privPassword,
               byte[] engineID,
               boolean keyExpansionWithEngineID)
Constructs UsmUser object.

Parameters:
userName - user name
authProtocol - authentication protocol, one of {SnmpConst.MD5, SnmpConst.SHA, SnmpConst.SHA224, SnmpConst.SHA256, SnmpConst.SHA384, SnmpConst.SHA512}
privProtocol - privacy protocol. One of {SnmpConst.DES, SnmpConst.AES, SnmpConst.AES192, SnmpConst.AES256}
authPassword - authentication password
privPassword - privacy protocol pass

UsmUser

public UsmUser(String userName,
               String authProtocol,
               byte[] authKey,
               byte[] privKey,
               byte[] engineID)
Constructs UsmUser object.

Parameters:
userName - user name
authProtocol - authentication protocol, one of {SnmpConst2.MD5, SnmpConst2.SHA}
authKey - localized auth key
privKey - localized priv key

UsmUser

public UsmUser(String userName,
               String authProtocol,
               int privProtocol,
               byte[] authKey,
               byte[] privKey,
               byte[] engineID)
Constructs UsmUser object.

Parameters:
userName - user name
authProtocol - authentication protocol, one of {SnmpConst2.MD5, SnmpConst2.SHA}
authKey - localized authentication password
privKey - localized privacy protocol pass
Method Detail

main

public static void main(String[] args)

getAuthKey

public byte[] getAuthKey()
Returns localized auth key


setAuthKey

public void setAuthKey(byte[] key)
Sets a new localized auth key

Parameters:
key - localized auth key

getAuthPassword

public String getAuthPassword()
Returns auth password


getAuthProtocol

public String getAuthProtocol()
Returns auth protocol


getAuthLength

public int getAuthLength()
Returns the digest length of the auth protocol


getPrivProtocol

public int getPrivProtocol()
Returns privacy protocol


setPrivProtocol

public void setPrivProtocol(int priv)
Sets a new privacy protocol


getPrivKey

public byte[] getPrivKey()
Returns localized privacy key


setPrivKey

public void setPrivKey(byte[] key)
Sets a new localized privacy key

Parameters:
key - localized priv key

getPrivPassword

public String getPrivPassword()
Returns privacy password


getSecurityLevel

public byte getSecurityLevel()
Returns security level


getUserName

public String getUserName()
Returns USM user name


setUserName

public void setUserName(String name)
Sets a new USM user name


getEngineID

public byte[] getEngineID()
Returns engine ID


setSecurityLevel

public void setSecurityLevel(byte level)
Sets a new security level


setAuthProtocol

public void setAuthProtocol(String authProtocol)
Sets a new auth protocol


setAuthPassword

public void setAuthPassword(String authPassword)
Sets a new auth password


setPrivPassword

public void setPrivPassword(String privPassword)
Sets a new privacy password


setEngineID

public void setEngineID(byte[] engineID)
Sets a new engineID. And privacy key and auth key will be localized again


toString

public String toString()

setKeyExpansionWithEngineID

public void setKeyExpansionWithEngineID(boolean b)

getKeyExpansionWithEngineID

public boolean getKeyExpansionWithEngineID()

updateKeys

public void updateKeys()
Calculates localized keys


generateKey

public static byte[] generateKey(String authProtocol,
                                 String password,
                                 byte[] engineID,
                                 int privProtocol,
                                 boolean keyExpansionWithEngineID)
                          throws NoSuchAlgorithmException
Generates privacy key for different privacy protocols

Parameters:
privProtocol - one of {SnmpConst.DES", SnmpConst.AES, SnmpConst.AES192, SnmpConst.AES256 }
Throws:
NoSuchAlgorithmException

generateKey

public static byte[] generateKey(String algorithm,
                                 String password,
                                 byte[] engineID)
                          throws NoSuchAlgorithmException
Creates localized key

Parameters:
algorithm - algorithm for creating digest, either SnmpConst1.MD5 or SnmpConst2.SHA.
password - auth or priv passwords
engineID - SNMPv3 engine ID
Throws:
NoSuchAlgorithmException

getPriv

public static int getPriv(String priv)
Parameters:
priv - privacy protocol. If priv is null, SnmpConst.DES is returned. Valid values are: DES, AES, AES192, AES256

HOME

Copyright © 2002 iReasoning Inc. All Rights Reserved.