C# Класс SnmpSharpNet.SecureAgentParameters

Secure SNMPv3 agent parameters
SNMP Agent specific values. This class stores values to access SNMP version 3 agents. Pass this class with your request data (Pdu) to the request method of the target class to make a request. Based on the information in this class, an appropriate request will be made by the request class. Following request types are generated: * if EngineBoots and EngineTime are integer value 0 or if EngineId value is length 0, Discovery request is made and passed instance of the SecureAgentParameters is updated with returned values. * in all other cases, SNMP request is made to the agent
Наследование: IAgentParameters
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
_authenticationKey byte[]
_authenticationProtocol AuthenticationDigests
_authenticationSecret MutableByte
_contextEngineId OctetString
_contextName OctetString
_engineBoots Integer32
_engineId OctetString
_engineTime Integer32
_engineTimeStamp System.DateTime
_maxMessageSize Integer32
_privacyKey byte[]
_privacyProtocol PrivacyProtocols
_privacySecret MutableByte
_reportable bool
_securityName OctetString

Открытые методы

Метод Описание
BuildCachedSecurityKeys ( ) : void

Build cached authentication and privacy encryption keys if they are appropriate for the selected security mode.

This method should be called after discovery process has been completed and all security related values have been set. For noAuthNoPriv, none of the keys are generated. authNoPriv will result in authentication key cached. authPriv will generate authentication and privacy keys. For successful key caching you need to set both relevant protocols and secret values.

Clone ( ) : object

Clone current object

GetCurrentEngineTime ( ) : int

Calculates and returns current agents engine time. ValidateEngineTime is called prior to calculation to make sure current engine time is timely enough to use. EngineTime is calculated as last received engine time + difference in seconds between the time stamp saved when last time value was received and current time (using the internal GMT clock).

InitializePacket ( SnmpPacket packet ) : void

InitializePacket SNMP packet with values from this class. Works only on SNMP version 3 packets.

Reset ( ) : void

Reset the class. Initialize all member values to class defaults.

ResetKeys ( ) : void

Reset privacy and authentication keys to null.

SecureAgentParameters ( ) : System

Constructor

SecureAgentParameters ( SecureAgentParameters second ) : System

Copy constructor. Initialize the class with the values of the parameter class values.

UpdateDiscoveryValues ( SnmpPacket packet ) : void

Update class values with SNMP version 3 discovery values from the supplied SnmpV3Packet class. Values updated are EngineId, EngineTime and EngineBoots.

UpdateTimeStamp ( ) : void

Updates engine time timestamp. This value is used to determine if agents engine time stored in this class is valid. Timestamp is saved as DateTime class by default initialized to DateTime.MinValue. Timestamp value is stored in GMT to make it portable (if it is saved on one computer and loaded on another that uses a different time zone).

UpdateValues ( SnmpPacket packet ) : void

Copy all relevant values from the SnmpV3Packet class. Do not use this class for updating the SNMP version 3 discovery process results because secret name, authentication and privacy values are updated as well which discovery process doesn't use.

Valid ( ) : bool

Checks validity of the class.

ValidateEngineTime ( ) : bool

Validate agents engine time. Valid engine time value is time that has been initialized to a value other then default (DateTime.MinValue is default set in the constructor) and that has been updated in the last 10 times the SNMP v3 timely window (150 seconds). In other words, valid time is any time value in the last 1500 seconds (or 25 minutes).

ValidateIncomingPacket ( SnmpV3Packet packet ) : bool

Validate that incoming packet has arrived from the correct engine id and is using a correct combination of privacy and authentication values.

authNoPriv ( String securityName, AuthenticationDigests authDigest, String authSecret ) : void

Prepare class for authNoPriv operations. Set privacy protocol to none

authPriv ( String securityName, AuthenticationDigests authDigest, String authSecret, PrivacyProtocols privProtocol, String privSecret ) : void

Prepare class for authPriv operations.

noAuthNoPriv ( String securityName ) : void

Prepare class for noAuthNoPriv operations. Set authentication and privacy protocols to none.

Приватные методы

Метод Описание
EngineTimeStamp ( ) : System.DateTime

Get engine time stamp value (last time engine boots and time values were retrieved from the SNMP agent).

Описание методов

BuildCachedSecurityKeys() публичный Метод

Build cached authentication and privacy encryption keys if they are appropriate for the selected security mode.
This method should be called after discovery process has been completed and all security related values have been set. For noAuthNoPriv, none of the keys are generated. authNoPriv will result in authentication key cached. authPriv will generate authentication and privacy keys. For successful key caching you need to set both relevant protocols and secret values.
public BuildCachedSecurityKeys ( ) : void
Результат void

Clone() публичный Метод

Clone current object
public Clone ( ) : object
Результат object

GetCurrentEngineTime() публичный Метод

Calculates and returns current agents engine time. ValidateEngineTime is called prior to calculation to make sure current engine time is timely enough to use. EngineTime is calculated as last received engine time + difference in seconds between the time stamp saved when last time value was received and current time (using the internal GMT clock).
public GetCurrentEngineTime ( ) : int
Результат int

InitializePacket() публичный Метод

InitializePacket SNMP packet with values from this class. Works only on SNMP version 3 packets.
Thrown when parameter packet is not SnmpV3Packet
public InitializePacket ( SnmpPacket packet ) : void
packet SnmpPacket Instance of
Результат void

Reset() публичный Метод

Reset the class. Initialize all member values to class defaults.
public Reset ( ) : void
Результат void

ResetKeys() публичный Метод

Reset privacy and authentication keys to null.
public ResetKeys ( ) : void
Результат void

SecureAgentParameters() публичный Метод

Constructor
public SecureAgentParameters ( ) : System
Результат System

SecureAgentParameters() публичный Метод

Copy constructor. Initialize the class with the values of the parameter class values.
public SecureAgentParameters ( SecureAgentParameters second ) : System
second SecureAgentParameters Parameter class.
Результат System

UpdateDiscoveryValues() публичный Метод

Update class values with SNMP version 3 discovery values from the supplied SnmpV3Packet class. Values updated are EngineId, EngineTime and EngineBoots.
Thrown when SNMP packet class other then version 3 /// is passed as parameter
public UpdateDiscoveryValues ( SnmpPacket packet ) : void
packet SnmpPacket class cast as
Результат void

UpdateTimeStamp() публичный Метод

Updates engine time timestamp. This value is used to determine if agents engine time stored in this class is valid. Timestamp is saved as DateTime class by default initialized to DateTime.MinValue. Timestamp value is stored in GMT to make it portable (if it is saved on one computer and loaded on another that uses a different time zone).
public UpdateTimeStamp ( ) : void
Результат void

UpdateValues() публичный Метод

Copy all relevant values from the SnmpV3Packet class. Do not use this class for updating the SNMP version 3 discovery process results because secret name, authentication and privacy values are updated as well which discovery process doesn't use.
Thrown when SNMP packet class other then version 3 /// is passed as parameter
public UpdateValues ( SnmpPacket packet ) : void
packet SnmpPacket cast as
Результат void

Valid() публичный Метод

Checks validity of the class.
public Valid ( ) : bool
Результат bool

ValidateEngineTime() публичный Метод

Validate agents engine time. Valid engine time value is time that has been initialized to a value other then default (DateTime.MinValue is default set in the constructor) and that has been updated in the last 10 times the SNMP v3 timely window (150 seconds). In other words, valid time is any time value in the last 1500 seconds (or 25 minutes).
public ValidateEngineTime ( ) : bool
Результат bool

ValidateIncomingPacket() публичный Метод

Validate that incoming packet has arrived from the correct engine id and is using a correct combination of privacy and authentication values.
Thrown on following errors with ErrorCode: /// * ErrorCode = 0: SecureAgentParameters was updated after request was made but before reply was received (this is not allowed) /// * SnmpException.InvalidAuthoritativeEngineId: engine id in the reply does not match request /// * SnmpException.InvalidSecurityName: security name mismatch between request and reply packets /// * SnmpException.ReportOnNoReports: report packet received when we had reportable set to false in the request /// * SnmpException.UnsupportedNoAuthPriv: noAuthPriv is not supported /// Thrown when configured privacy passwords in this class and in the packet class do not match Thrown when configured authentication passwords in this class and in the packet class do not match
public ValidateIncomingPacket ( SnmpV3Packet packet ) : bool
packet SnmpV3Packet Received and parsed SNMP version 3 packet.
Результат bool

authNoPriv() публичный Метод

Prepare class for authNoPriv operations. Set privacy protocol to none
public authNoPriv ( String securityName, AuthenticationDigests authDigest, String authSecret ) : void
securityName String User security name
authDigest AuthenticationDigests Authentication protocol
authSecret String Authentication secret (password)
Результат void

authPriv() публичный Метод

Prepare class for authPriv operations.
public authPriv ( String securityName, AuthenticationDigests authDigest, String authSecret, PrivacyProtocols privProtocol, String privSecret ) : void
securityName String User security name
authDigest AuthenticationDigests Authentication protocol
authSecret String Authentication secret (password)
privProtocol PrivacyProtocols Privacy protocol
privSecret String Privacy secret (encryption password)
Результат void

noAuthNoPriv() публичный Метод

Prepare class for noAuthNoPriv operations. Set authentication and privacy protocols to none.
public noAuthNoPriv ( String securityName ) : void
securityName String User security name
Результат void

Описание свойств

_authenticationKey защищенное свойство

Cached authentication key
protected byte[] _authenticationKey
Результат byte[]

_authenticationProtocol защищенное свойство

Authentication digest to use in authNoPriv and authPriv security combinations. For available authentication digests, see AuthenticationDigests enumeration.
protected AuthenticationDigests _authenticationProtocol
Результат AuthenticationDigests

_authenticationSecret защищенное свойство

Authentication secret (or authentication password)
protected MutableByte _authenticationSecret
Результат MutableByte

_contextEngineId защищенное свойство

Context engine id. By default, this value is set to authoritative engine id value unless specifically set to a different value here.
protected OctetString _contextEngineId
Результат OctetString

_contextName защищенное свойство

Context name. By default this value is a 0 length string (no context name). Set this value if you require it to be defined in ScopedPdu.
protected OctetString _contextName
Результат OctetString

_engineBoots защищенное свойство

Authoritative engine boots value
protected Integer32 _engineBoots
Результат Integer32

_engineId защищенное свойство

Protocol version. Always == SnmpConstants.SNMPV3 Authoritative engine id
protected OctetString _engineId
Результат OctetString

_engineTime защищенное свойство

Authoritative engine time value
protected Integer32 _engineTime
Результат Integer32

_engineTimeStamp защищенное свойство

Time stamp when authoritative engine time value was last refreshed with data from the agent. This value is used to calculate up to date authoritative agent time value without having to repeat discovery process every 150 seconds.
protected DateTime,System _engineTimeStamp
Результат System.DateTime

_maxMessageSize защищенное свойство

Maximum message size. This value is by default set to 64KB and then updated by the maximum message size value in the response from the agent. This value should be the smallest message size supported by both the agent and manager.
protected Integer32 _maxMessageSize
Результат Integer32

_privacyKey защищенное свойство

Cached privacy key
protected byte[] _privacyKey
Результат byte[]

_privacyProtocol защищенное свойство

Privacy protocol to use. For available protocols, see PrivacyProtocols enumeration.
protected PrivacyProtocols _privacyProtocol
Результат PrivacyProtocols

_privacySecret защищенное свойство

Privacy secret (or privacy password)
protected MutableByte _privacySecret
Результат MutableByte

_reportable защищенное свойство

Reportable option flag. Set to true by default. This flag controls if reportable flag will be set in the packet. When this flag is set in the packet, agent will respond to invalid requests with Report packets. Without this flag being set, all invalid requests are silently dropped by the agent.
protected bool _reportable
Результат bool

_securityName защищенное свойство

Security name value, or user name.
protected OctetString _securityName
Результат OctetString