- java.lang.Object
-
- org.snmp4j.security.UsmSecurityParameters
-
- All Implemented Interfaces:
BERSerializable
,SecurityParameters
public class UsmSecurityParameters extends java.lang.Object implements SecurityParameters
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
authenticationKey
private OctetString
authenticationParameters
private AuthenticationProtocol
authenticationProtocol
private Integer32
authoritativeEngineBoots
private OctetString
authoritativeEngineID
private Integer32
authoritativeEngineTime
private int
authParametersPosition
private int
decodedLength
private static LogAdapter
logger
private static int
MAX_BER_LENGTH_WITHOU_SEC_PARAMS
private byte[]
privacyKey
private OctetString
privacyParameters
private PrivacyProtocol
privacyProtocol
private int
securityParametersPosition
private SecurityProtocols
securityProtocols
private int
sequencePosition
private OctetString
userName
-
Constructor Summary
Constructors Constructor Description UsmSecurityParameters()
UsmSecurityParameters(SecurityProtocols securityProtocols)
UsmSecurityParameters(OctetString authoritativeEngineID, Integer32 authoritativeEngineBoots, Integer32 authoritativeEngineTime, OctetString userName, AuthenticationProtocol authenticationProtocol, PrivacyProtocol privacyProtocol)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
decodeBER(BERInputStream inputStream)
Decodes aVariable
from anInputStream
.void
encodeBER(java.io.OutputStream outputStream)
Encodes aVariable
to anOutputStream
.byte[]
getAuthenticationKey()
OctetString
getAuthenticationParameters()
AuthenticationProtocol
getAuthenticationProtocol()
int
getAuthoritativeEngineBoots()
byte[]
getAuthoritativeEngineID()
int
getAuthoritativeEngineTime()
int
getAuthParametersPosition()
private int
getBEREncodedAuthParamsPosition()
int
getBERLength()
Returns the length of thisBERSerializable
object in bytes when encoded according to the Basic Encoding Rules (BER).int
getBERMaxLength(int securityLevel)
Gets the maximum length of the BER encoded representation of thisSecurityParameters
instance.int
getBERPayloadLength()
Returns the length of the payload of thisBERSerializable
object in bytes when encoded according to the Basic Encoding Rules (BER).int
getBERUsmPayloadLength()
getBERUsmPayloadLengthbyte[]
getPrivacyKey()
OctetString
getPrivacyParameters()
PrivacyProtocol
getPrivacyProtocol()
int
getScopedPduPosition()
getScopedPduPositionint
getSecurityParametersPosition()
Gets the byte position of the first byte (counted from zero) of the security parameters in the whole message.int
getSequencePosition()
OctetString
getUserName()
void
setAuthenticationKey(byte[] authenticationKey)
void
setAuthenticationParameters(OctetString authenticationParameters)
void
setAuthenticationProtocol(AuthenticationProtocol authenticationProtocol)
void
setAuthoritativeEngineBoots(int authoritativeEngineBoots)
void
setAuthoritativeEngineID(byte[] authoritativeEngineID)
void
setAuthoritativeEngineTime(int authoritativeEngineTime)
void
setPrivacyKey(byte[] privacyKey)
void
setPrivacyParameters(OctetString privacyParameters)
void
setPrivacyProtocol(PrivacyProtocol privacyProtocol)
void
setSecurityParametersPosition(int securityParametersPosition)
Sets the position of the first byte (counted from zero) of the security parameters in the whole SNMP message.void
setUserName(OctetString userName)
-
-
-
Field Detail
-
logger
private static final LogAdapter logger
-
MAX_BER_LENGTH_WITHOU_SEC_PARAMS
private static final int MAX_BER_LENGTH_WITHOU_SEC_PARAMS
- See Also:
- Constant Field Values
-
authoritativeEngineID
private OctetString authoritativeEngineID
-
authoritativeEngineBoots
private Integer32 authoritativeEngineBoots
-
authoritativeEngineTime
private Integer32 authoritativeEngineTime
-
userName
private OctetString userName
-
authenticationProtocol
private AuthenticationProtocol authenticationProtocol
-
privacyProtocol
private PrivacyProtocol privacyProtocol
-
authenticationKey
private byte[] authenticationKey
-
privacyKey
private byte[] privacyKey
-
privacyParameters
private OctetString privacyParameters
-
authenticationParameters
private OctetString authenticationParameters
-
securityParametersPosition
private int securityParametersPosition
-
authParametersPosition
private int authParametersPosition
-
decodedLength
private int decodedLength
-
sequencePosition
private int sequencePosition
-
securityProtocols
private SecurityProtocols securityProtocols
-
-
Constructor Detail
-
UsmSecurityParameters
public UsmSecurityParameters()
-
UsmSecurityParameters
public UsmSecurityParameters(SecurityProtocols securityProtocols)
-
UsmSecurityParameters
public UsmSecurityParameters(OctetString authoritativeEngineID, Integer32 authoritativeEngineBoots, Integer32 authoritativeEngineTime, OctetString userName, AuthenticationProtocol authenticationProtocol, PrivacyProtocol privacyProtocol)
-
-
Method Detail
-
getAuthoritativeEngineID
public byte[] getAuthoritativeEngineID()
-
setAuthoritativeEngineID
public void setAuthoritativeEngineID(byte[] authoritativeEngineID)
-
setAuthoritativeEngineBoots
public void setAuthoritativeEngineBoots(int authoritativeEngineBoots)
-
getAuthoritativeEngineBoots
public int getAuthoritativeEngineBoots()
-
setAuthoritativeEngineTime
public void setAuthoritativeEngineTime(int authoritativeEngineTime)
-
getAuthoritativeEngineTime
public int getAuthoritativeEngineTime()
-
setUserName
public void setUserName(OctetString userName)
-
getUserName
public OctetString getUserName()
-
setAuthenticationProtocol
public void setAuthenticationProtocol(AuthenticationProtocol authenticationProtocol)
-
getAuthenticationProtocol
public AuthenticationProtocol getAuthenticationProtocol()
-
setPrivacyProtocol
public void setPrivacyProtocol(PrivacyProtocol privacyProtocol)
-
getPrivacyProtocol
public PrivacyProtocol getPrivacyProtocol()
-
getBERLength
public int getBERLength()
Description copied from interface:BERSerializable
Returns the length of thisBERSerializable
object in bytes when encoded according to the Basic Encoding Rules (BER).- Specified by:
getBERLength
in interfaceBERSerializable
- Returns:
- the BER encoded length of this variable.
-
getBERPayloadLength
public int getBERPayloadLength()
Description copied from interface:BERSerializable
Returns the length of the payload of thisBERSerializable
object in bytes when encoded according to the Basic Encoding Rules (BER).- Specified by:
getBERPayloadLength
in interfaceBERSerializable
- Returns:
- the BER encoded length of this variable.
-
decodeBER
public void decodeBER(BERInputStream inputStream) throws java.io.IOException
Description copied from interface:BERSerializable
Decodes aVariable
from anInputStream
.- Specified by:
decodeBER
in interfaceBERSerializable
- Parameters:
inputStream
- anInputStream
containing a BER encoded byte stream.- Throws:
java.io.IOException
- if the stream could not be decoded by using BER rules.
-
getBEREncodedAuthParamsPosition
private int getBEREncodedAuthParamsPosition()
-
getSequencePosition
public int getSequencePosition()
-
encodeBER
public void encodeBER(java.io.OutputStream outputStream) throws java.io.IOException
Description copied from interface:BERSerializable
Encodes aVariable
to anOutputStream
.- Specified by:
encodeBER
in interfaceBERSerializable
- Parameters:
outputStream
- anOutputStream
.- Throws:
java.io.IOException
- if an error occurs while writing to the stream.
-
getBERUsmPayloadLength
public int getBERUsmPayloadLength()
getBERUsmPayloadLength- Returns:
- int
-
getBERMaxLength
public int getBERMaxLength(int securityLevel)
Description copied from interface:SecurityParameters
Gets the maximum length of the BER encoded representation of thisSecurityParameters
instance.- Specified by:
getBERMaxLength
in interfaceSecurityParameters
- Parameters:
securityLevel
- the security level to be used.- Returns:
- the maximum BER encoded length in bytes.
-
getAuthenticationKey
public byte[] getAuthenticationKey()
-
setAuthenticationKey
public void setAuthenticationKey(byte[] authenticationKey)
-
getPrivacyKey
public byte[] getPrivacyKey()
-
setPrivacyKey
public void setPrivacyKey(byte[] privacyKey)
-
getPrivacyParameters
public OctetString getPrivacyParameters()
-
setPrivacyParameters
public void setPrivacyParameters(OctetString privacyParameters)
-
getAuthenticationParameters
public OctetString getAuthenticationParameters()
-
setAuthenticationParameters
public void setAuthenticationParameters(OctetString authenticationParameters)
-
getSecurityParametersPosition
public int getSecurityParametersPosition()
Description copied from interface:SecurityParameters
Gets the byte position of the first byte (counted from zero) of the security parameters in the whole message.- Specified by:
getSecurityParametersPosition
in interfaceSecurityParameters
- Returns:
- the position of the first byte (counted from zero) of the security parameters in the whole SNMP message. -1 is returned, when the position is unknown (not set).
-
setSecurityParametersPosition
public void setSecurityParametersPosition(int securityParametersPosition)
Description copied from interface:SecurityParameters
Sets the position of the first byte (counted from zero) of the security parameters in the whole SNMP message.- Specified by:
setSecurityParametersPosition
in interfaceSecurityParameters
- Parameters:
securityParametersPosition
- an integer value greater or equal than zero.
-
getAuthParametersPosition
public int getAuthParametersPosition()
-
getScopedPduPosition
public int getScopedPduPosition()
getScopedPduPosition- Returns:
- int
-
-