- All Known Implementing Classes:
SNMPv3SecurityModel
,TSM
,USM
public interface SecurityModel
The
SecurityModel
interface as described in RFC3411 section 4.4
and RFC 5590 section 5.- Version:
- 3.4.0
- Author:
- Frank Fock
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionint
generateRequestMessage
(int messageProcessingModel, byte[] globalData, int maxMessageSize, int securityModel, byte[] securityEngineID, byte[] securityName, int securityLevel, BERInputStream scopedPDU, SecurityParameters securityParameters, BEROutputStream wholeMsg, TransportStateReference tmStateReference, SecurityStateReference securityStateReference) Generate a request message.int
generateResponseMessage
(int messageProcessingModel, byte[] globalData, int maxMessageSize, int securityModel, byte[] securityEngineID, byte[] securityName, int securityLevel, BERInputStream scopedPDU, SecurityStateReference securityStateReference, SecurityParameters securityParameters, BEROutputStream wholeMsg) Generates a response message.int
getID()
Gets the ID of the security model.boolean
Checks whether thisSecurityModel
has an authoritative engine ID.Creates a newSecurityParameters
instance that corresponds to this security model.Creates a newSecurityStateReference
instance that corresponds to this security model.int
processIncomingMsg
(int messageProcessingModel, int maxMessageSize, SecurityParameters securityParameters, SecurityModel securityModel, int securityLevel, BERInputStream wholeMsg, TransportStateReference tmStateReference, OctetString securityEngineID, OctetString securityName, BEROutputStream scopedPDU, Integer32 maxSizeResponseScopedPDU, SecurityStateReference securityStateReference, StatusInformation statusInfo) Processes an incoming message and returns its plaintext payload.boolean
Checks whether thisSecurityModel
supports authoritative engine ID discovery.
-
Field Details
-
SECURITY_MODEL_ANY
static final int SECURITY_MODEL_ANY- See Also:
-
SECURITY_MODEL_SNMPv1
static final int SECURITY_MODEL_SNMPv1- See Also:
-
SECURITY_MODEL_SNMPv2c
static final int SECURITY_MODEL_SNMPv2c- See Also:
-
SECURITY_MODEL_USM
static final int SECURITY_MODEL_USM- See Also:
-
SECURITY_MODEL_TSM
static final int SECURITY_MODEL_TSM- See Also:
-
-
Method Details
-
getID
int getID()Gets the ID of the security model.- Returns:
- one of the integer constants defined in the
SecurityModel
interface. - See Also:
-
newSecurityParametersInstance
SecurityParameters newSecurityParametersInstance()Creates a newSecurityParameters
instance that corresponds to this security model.- Returns:
- a new
SecurityParameters
instance.
-
newSecurityStateReference
SecurityStateReference newSecurityStateReference()Creates a newSecurityStateReference
instance that corresponds to this security model.- Returns:
- a new
SecurityStateReference
instance.
-
generateRequestMessage
int generateRequestMessage(int messageProcessingModel, byte[] globalData, int maxMessageSize, int securityModel, byte[] securityEngineID, byte[] securityName, int securityLevel, BERInputStream scopedPDU, SecurityParameters securityParameters, BEROutputStream wholeMsg, TransportStateReference tmStateReference, SecurityStateReference securityStateReference) throws IOException Generate a request message.- Parameters:
messageProcessingModel
- the ID of the message processing model (SNMP version) to use.globalData
- the message header and admin data.maxMessageSize
- the maximum message size of the sending (this) SNMP entity for the selected transport mapping (determined by the message processing model).securityModel
- the security model for the outgoing message.securityEngineID
- the authoritative SNMP entity.securityName
- the principal on behalf of this message is generated.securityLevel
- the requestedSecurityLevel
.scopedPDU
- a BERInputStream containing the message (plain text) payload.securityParameters
- returns theSecurityParameters
filled by the security model.wholeMsg
- returns the complete generated message in aBEROutputStream
. The buffer ofwholeMsg
is set tonull
by the caller and must be set by the implementation of this method.tmStateReference
- the transport model state reference as defined by RFC 5590.securityStateReference
- aSecurityStateReference
instance collecting information for response processing, i.e. should benull
if no response is expected. This security state reference will be stored in the message processing model cache for response processing.- Returns:
- the error status of the message generation. On success
SnmpConstants.SNMPv3_USM_OK
is returned, otherwise one of the otherSnmpConstants.SNMPv3_USM_*
values is returned. - Throws:
IOException
- if generation of the message fails because of an internal or an resource error.
-
generateResponseMessage
int generateResponseMessage(int messageProcessingModel, byte[] globalData, int maxMessageSize, int securityModel, byte[] securityEngineID, byte[] securityName, int securityLevel, BERInputStream scopedPDU, SecurityStateReference securityStateReference, SecurityParameters securityParameters, BEROutputStream wholeMsg) throws IOException Generates a response message.- Parameters:
messageProcessingModel
- the ID of the message processing model (SNMP version) to use.globalData
- the message header and admin data.maxMessageSize
- the maximum message size of the sending (this) SNMP entity for the selected transport mapping (determined by the message processing model).securityModel
- the security model for the outgoing message.securityEngineID
- the authoritative SNMP entity.securityName
- the principal on behalf of this message is generated.securityLevel
- the requestedSecurityLevel
.scopedPDU
- a BERInputStream containing the message (plain text) payload.securityStateReference
- aSecurityStateReference
instance providing information from original request.securityParameters
- returns theSecurityParameters
filled by the security model.wholeMsg
- returns the complete generated message in aBEROutputStream
. The buffer ofwholeMsg
is set tonull
by the caller and must be set by the implementation of this method.- Returns:
- the error status of the message generation. On success
SnmpConstants.SNMPv3_USM_OK
is returned, otherwise one of the otherSnmpConstants.SNMPv3_USM_*
values is returned. - Throws:
IOException
- if generation of the message fails because of an internal or an resource error.
-
processIncomingMsg
int processIncomingMsg(int messageProcessingModel, int maxMessageSize, SecurityParameters securityParameters, SecurityModel securityModel, int securityLevel, BERInputStream wholeMsg, TransportStateReference tmStateReference, OctetString securityEngineID, OctetString securityName, BEROutputStream scopedPDU, Integer32 maxSizeResponseScopedPDU, SecurityStateReference securityStateReference, StatusInformation statusInfo) throws IOException Processes an incoming message and returns its plaintext payload.- Parameters:
messageProcessingModel
- the ID of the message processing model (SNMP version) to use.maxMessageSize
- the maximum message size of the message processing model for the transport mapping associated with this message's source address less the length of the maximum header length of the message processing model. This value is used by the security model to determine themaxSizeResponseScopedPDU
value.securityParameters
- theSecurityParameters
for the received message.securityModel
- theSecurityModel
instance for the received message.securityLevel
- theSecurityLevel
ID.wholeMsg
- theBERInputStream
containing the whole message as received on the wire.tmStateReference
- the transport model state reference as defined by RFC 5590.securityEngineID
- the authoritative SNMP entity.securityName
- the identification of the principal.scopedPDU
- returns the message (plaintext) payload into the suppliedBEROutputStream
. The buffer ofscopedPDU
is set tonull
by the caller and must be set by the implementation of this method.maxSizeResponseScopedPDU
- the determined maximum size for a response PDU.securityStateReference
- theSecurityStateReference
information needed for a response.statusInfo
- theStatusInformation
needed to generate reports if processing of the incoming message failed.- Returns:
- the error status of the message processing. On success
SnmpConstants.SNMPv3_USM_OK
is returned, otherwise one of the otherSnmpConstants.SNMPv3_USM_*
values is returned. - Throws:
IOException
- if an unexpected (internal) or an resource error occurred.
-
supportsEngineIdDiscovery
boolean supportsEngineIdDiscovery()Checks whether thisSecurityModel
supports authoritative engine ID discovery. TheUSM
for instance, returnstrue
whereasTSM
returnsfalse
. See also RFC 5343 3.2 for details.- Returns:
true
if this security model has its own authoritative engine ID discovery mechanism.
-
hasAuthoritativeEngineID
boolean hasAuthoritativeEngineID()Checks whether thisSecurityModel
has an authoritative engine ID.- Returns:
true
if an authoritative engine ID is exchanged between command sender and responder using this security model,false
otherwise.
-