Package org.snmp4j.security
Class TSM
java.lang.Object
org.snmp4j.security.SNMPv3SecurityModel
org.snmp4j.security.TSM
- All Implemented Interfaces:
 SecurityModel
The 
TSM (Transport Security Model) implements a
 SecurityModel which uses transport security mechanisms
 as defined in RFC 5591.- Since:
 - 2.0
 - Version:
 - 2.0
 - Author:
 - Frank Fock
 
- 
Field Summary
Fields inherited from class org.snmp4j.security.SNMPv3SecurityModel
localEngineIDFields inherited from interface org.snmp4j.security.SecurityModel
SECURITY_MODEL_ANY, SECURITY_MODEL_SNMPv1, SECURITY_MODEL_SNMPv2c, SECURITY_MODEL_TSM, SECURITY_MODEL_USM - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionprotected voidintgenerateRequestMessage(int messageProcessingModel, byte[] globalData, int maxMessageSize, int securityModel, byte[] securityEngineID, byte[] securityName, int securityLevel, BERInputStream scopedPDU, SecurityParameters securityParameters, BEROutputStream wholeMsg, TransportStateReference tmStateReference) Generate a request message.intgenerateResponseMessage(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.intgetID()Gets the ID of the security model.protected StringgetSecurityNamePrefix(byte[] securityName) protected StringgetTransportDomainPrefix(Address address) booleanChecks whether thisSecurityModelhas an authoritative engine ID.booleanReturns whether the transport domain prefix is prepended to the securityName.Creates a newSecurityParametersinstance that corresponds to this security model.Creates a newSecurityStateReferenceinstance that corresponds to this security model.intprocessIncomingMsg(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.voidsetLocalEngineID(OctetString localEngineID) voidsetUsePrefix(boolean usePrefix) Sets the flag that controls whether the transport domain prefix is prepended to the securityName.booleanChecks whether thisSecurityModelsupports authoritative engine ID discovery.Methods inherited from class org.snmp4j.security.SNMPv3SecurityModel
buildMessageBuffer, buildWholeMessage, getLocalEngineID 
- 
Constructor Details
- 
TSM
public TSM() - 
TSM
 
 - 
 - 
Method Details
- 
setLocalEngineID
 - 
fireIncrementCounter
 - 
getID
public int getID()Description copied from interface:SecurityModelGets the ID of the security model.- Returns:
 - one of the integer constants defined in the 
SecurityModelinterface. - See Also:
 
 - 
supportsEngineIdDiscovery
public boolean supportsEngineIdDiscovery()Description copied from interface:SecurityModelChecks whether thisSecurityModelsupports authoritative engine ID discovery. TheUSMfor instance, returnstruewhereasTSMreturnsfalse. See also RFC 5343 3.2 for details.- Returns:
 trueif this security model has its own authoritative engine ID discovery mechanism.
 - 
hasAuthoritativeEngineID
public boolean hasAuthoritativeEngineID()Description copied from interface:SecurityModelChecks whether thisSecurityModelhas an authoritative engine ID.- Returns:
 trueif an authoritative engine ID is exchanged between command sender and responder using this security model,falseotherwise.
 - 
newSecurityParametersInstance
Description copied from interface:SecurityModelCreates a newSecurityParametersinstance that corresponds to this security model.- Returns:
 - a new 
SecurityParametersinstance. 
 - 
newSecurityStateReference
Description copied from interface:SecurityModelCreates a newSecurityStateReferenceinstance that corresponds to this security model.- Returns:
 - a new 
SecurityStateReferenceinstance. 
 - 
generateRequestMessage
public int generateRequestMessage(int messageProcessingModel, byte[] globalData, int maxMessageSize, int securityModel, byte[] securityEngineID, byte[] securityName, int securityLevel, BERInputStream scopedPDU, SecurityParameters securityParameters, BEROutputStream wholeMsg, TransportStateReference tmStateReference) throws IOException Description copied from interface:SecurityModelGenerate 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 theSecurityParametersfilled by the security model.wholeMsg- returns the complete generated message in aBEROutputStream. The buffer ofwholeMsgis set tonullby the caller and must be set by the implementation of this method.tmStateReference- the transport model state reference as defined by RFC 5590.- Returns:
 - the error status of the message generation. On success
    
SnmpConstants.SNMPv3_USM_OKis 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.
 - 
getCounterSupport
 - 
getSecurityNamePrefix
 - 
getTransportDomainPrefix
 - 
generateResponseMessage
public 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 Description copied from interface:SecurityModelGenerates 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- aSecurityStateReferenceinstance providing information from original request.securityParameters- returns theSecurityParametersfilled by the security model.wholeMsg- returns the complete generated message in aBEROutputStream. The buffer ofwholeMsgis set tonullby 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_OKis 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
public 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 Description copied from interface:SecurityModelProcesses 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 themaxSizeResponseScopedPDUvalue.securityParameters- theSecurityParametersfor the received message.securityModel- theSecurityModelinstance for the received message.securityLevel- theSecurityLevelID.wholeMsg- theBERInputStreamcontaining 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 ofscopedPDUis set tonullby the caller and must be set by the implementation of this method.maxSizeResponseScopedPDU- the determined maximum size for a response PDU.securityStateReference- theSecurityStateReferenceinformation needed for a response.statusInfo- theStatusInformationneeded to generate reports if processing of the incoming message failed.- Returns:
 - the error status of the message processing. On success
    
SnmpConstants.SNMPv3_USM_OKis returned, otherwise one of the otherSnmpConstants.SNMPv3_USM_*values is returned. - Throws:
 IOException- if an unexpected (internal) or an resource error occurred.
 - 
isUsePrefix
public boolean isUsePrefix()Returns whether the transport domain prefix is prepended to the securityName.- Returns:
 trueif the transport domain prefix is prepended to the securityName.
 - 
setUsePrefix
public void setUsePrefix(boolean usePrefix) Sets the flag that controls whether the transport domain prefix is prepended to the securityName.- Parameters:
 usePrefix- iftruethe transport domain prefix is prepended to the securityName.
 
 -