|
SNMP Stack 4_12 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.co.westhawk.snmp.stack.AbstractSnmpContext | +--uk.co.westhawk.snmp.stack.SnmpContextv3
This class contains the SNMP v3 context that is needed by every Pdu to send a SNMP v3 request.
This class will perform the v3 discovery of the SNMP engine ID and
time line if necessary. This is done with the classes
TimeWindow
and UsmDiscoveryBean
.
Now that the stack can send traps, it needs to be able to act as an authoritative SNMP engine. This is done via the interface UsmAgent. The DefaultUsmAgent is not guaranteed to work; agents (or rather authoritative engines) should provide a better implementation.
This class will use the User Security Model (USM) as described in RFC 2574. See also RFC 2571.
It is advised to set all the properties of this class before any Pdu,
using this class, is sent.
All properties are being used to encode the message. Some properties are
being used to decode the Reponse or Report Pdu.
When any of these last properties were changed in between flight there
is a possibility the decoding fails, causing a
DecodingException
.
destroy()
should be called when the context is no longer
used. This is the only way the threads will be stopped and garbage
collected.
SnmpContextv3Face
,
SnmpContextv3Pool
,
TimeWindow
,
UsmAgent
,
UsmDiscoveryBean
Fields inherited from class uk.co.westhawk.snmp.stack.AbstractSnmpContext |
hostAddr, hostPort, isDestroyed, maxRecvSize, typeSocket |
Fields inherited from interface uk.co.westhawk.snmp.stack.SnmpContextv3Face |
Default_ContextName, Default_UserName, MD5_PROTOCOL, ProtocolNames, SHA1_PROTOCOL, SNMPv1_Security_Model, SNMPv2c_Security_Model, USM_Security_Model, version_id |
Fields inherited from interface uk.co.westhawk.snmp.stack.SnmpContextBasisFace |
DEFAULT_PORT, KVM_SOCKET, MAXPDU, MSS, NETSCAPE_SOCKET, STANDARD_SOCKET |
Fields inherited from interface uk.co.westhawk.snmp.event.TrapListener |
version_id |
Constructor Summary | |
SnmpContextv3(java.lang.String host,
int port)
Constructor. |
|
SnmpContextv3(java.lang.String host,
int port,
java.lang.String typeSocketA)
Constructor. |
Method Summary | |
protected byte[] |
actualEncodePacket(byte msg_type,
int rId,
int errstat,
int errind,
java.util.Enumeration ve,
uk.co.westhawk.snmp.stack.TimeWindowNode node)
Does the actual encoding. |
boolean |
addDiscoveryPdu(DiscoveryPdu pdu)
Adds an discovery pdu. |
boolean |
addPdu(Pdu pdu)
Adds an pdu. |
protected boolean |
addPdu(Pdu pdu,
boolean checkDiscovery)
Adds an pdu. |
java.lang.Object |
clone()
Returns a clone of this SnmpContextv3. |
protected UsmAgent |
createUsmAgent()
Creates the USM agent. |
byte[] |
encodeDiscoveryPacket(byte msg_type,
int rId,
int errstat,
int errind,
java.util.Enumeration ve)
Encodes a discovery pdu packet. |
byte[] |
encodePacket(byte msg_type,
int rId,
int errstat,
int errind,
java.util.Enumeration ve)
Encodes a pdu packet. |
int |
getAuthenticationProtocol()
Returns the protocol to be used for authentication. |
byte[] |
getContextEngineId()
Returns the contextEngineID. |
java.lang.String |
getContextName()
Returns the contextName. |
java.lang.String |
getUserAuthenticationPassword()
Returns the user authentication password. |
java.lang.String |
getUserName()
Returns the username. |
java.lang.String |
getUserPrivacyPassword()
Returns the user privacy password. |
int |
getVersion()
Return the SNMP version of the context. |
protected boolean |
isAuthoritative(byte msg_type)
Returns if we send this pdu in authoritative role or not. |
boolean |
isUseAuthentication()
Return if authentication is used or not. |
boolean |
isUsePrivacy()
Return if privacy is used or not. |
protected void |
ProcessIncomingMessage(uk.co.westhawk.snmp.stack.AsnDecoder rpdu,
java.io.ByteArrayInputStream in)
Processes an incoming SNMP v3 message. |
Pdu |
processIncomingTrap(byte[] message)
Processes an incoming trap. |
boolean |
removePdu(int rid)
Removes a pdu. |
void |
setAuthenticationProtocol(int protocol)
Sets the protocol to be used for authentication. |
void |
setContextEngineId(byte[] newContextEngineId)
Sets the contextEngineID. |
void |
setContextName(java.lang.String newContextName)
Sets the contextName. |
void |
setUseAuthentication(boolean newUseAuthentication)
Sets whether authentication has to used. |
void |
setUsePrivacy(boolean newUsePrivacy)
Sets whether privacy has to used. |
void |
setUserAuthenticationPassword(java.lang.String newUserAuthPassword)
Sets the user authentication password. |
void |
setUserName(java.lang.String newUserName)
Sets the username. |
void |
setUserPrivacyPassword(java.lang.String newUserPrivacyPassword)
Sets the user privacy password. |
static void |
setUsmAgent(UsmAgent agent)
Sets the UsmAgent, needed when this stack is used as authoritative SNMP engine. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class uk.co.westhawk.snmp.stack.AbstractSnmpContext |
activate, addTrapListener, destroy, getDebugString, getHost, getHostAddress, getMaxRecvSize, getPort, getTypeSocket, removeTrapListener, run, sendPacket, setMaxRecvSize, stop, trapReceived |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface uk.co.westhawk.snmp.stack.SnmpContextBasisFace |
addTrapListener, destroy, getHost, getPort, getTypeSocket, removeTrapListener, sendPacket |
Constructor Detail |
public SnmpContextv3(java.lang.String host, int port) throws java.io.IOException
host
- The host to which the Pdu will sendport
- The port where the SNMP server will beAbstractSnmpContext.AbstractSnmpContext(String, int)
public SnmpContextv3(java.lang.String host, int port, java.lang.String typeSocketA) throws java.io.IOException
host
- The host to which the Pdu will sendport
- The port where the SNMP server will betypeSocketA
- The type of socket to use.AbstractSnmpContext.AbstractSnmpContext(String, int, String)
,
SnmpContextBasisFace.STANDARD_SOCKET
,
SnmpContextBasisFace.NETSCAPE_SOCKET
,
SnmpContextBasisFace.KVM_SOCKET
Method Detail |
public int getVersion()
SnmpContextBasisFace
getVersion
in interface SnmpContextBasisFace
getVersion
in class AbstractSnmpContext
uk.co.westhawk.snmp.stack.SnmpContextBasisFace
public java.lang.String getUserName()
getUserName
in interface SnmpContextv3Face
public void setUserName(java.lang.String newUserName)
setUserName
in interface SnmpContextv3Face
newUserName
- The new usernameSnmpContextv3Face.Default_UserName
public boolean isUseAuthentication()
isUseAuthentication
in interface SnmpContextv3Face
public void setUseAuthentication(boolean newUseAuthentication)
setUseAuthentication
in interface SnmpContextv3Face
newUseAuthentication
- The use of authenticationpublic java.lang.String getUserAuthenticationPassword()
getUserAuthenticationPassword
in interface SnmpContextv3Face
public void setUserAuthenticationPassword(java.lang.String newUserAuthPassword)
setUserAuthenticationPassword
in interface SnmpContextv3Face
newUserAuthPassword
- The user authentication passwordpublic void setAuthenticationProtocol(int protocol) throws java.lang.IllegalArgumentException
setAuthenticationProtocol
in interface SnmpContextv3Face
protocol
- The authentication protocol to be usedSnmpContextv3Face.MD5_PROTOCOL
,
SnmpContextv3Face.SHA1_PROTOCOL
public int getAuthenticationProtocol()
getAuthenticationProtocol
in interface SnmpContextv3Face
SnmpContextv3Face.MD5_PROTOCOL
,
SnmpContextv3Face.SHA1_PROTOCOL
public boolean isUsePrivacy()
isUsePrivacy
in interface SnmpContextv3Face
public void setUsePrivacy(boolean newUsePrivacy)
setUsePrivacy
in interface SnmpContextv3Face
newUsePrivacy
- The use of privacypublic java.lang.String getUserPrivacyPassword()
getUserPrivacyPassword
in interface SnmpContextv3Face
public void setUserPrivacyPassword(java.lang.String newUserPrivacyPassword)
setUserPrivacyPassword
in interface SnmpContextv3Face
newUserPrivacyPassword
- The user privacy passwordpublic void setContextEngineId(byte[] newContextEngineId) throws java.lang.IllegalArgumentException
setContextEngineId
in interface SnmpContextv3Face
newContextEngineId
- The contextEngineIDpublic byte[] getContextEngineId()
getContextEngineId
in interface SnmpContextv3Face
public void setContextName(java.lang.String newContextName)
setContextName
in interface SnmpContextv3Face
newContextName
- The contextNameSnmpContextv3Face.Default_ContextName
public java.lang.String getContextName()
getContextName
in interface SnmpContextv3Face
public boolean addDiscoveryPdu(DiscoveryPdu pdu) throws java.io.IOException, PduException
addDiscoveryPdu
in interface SnmpContextv3Face
pdu
- the discovery pduAbstractSnmpContext.addPdu(Pdu)
,
addPdu(Pdu)
public boolean addPdu(Pdu pdu) throws java.io.IOException, PduException
addPdu
in interface SnmpContextBasisFace
addPdu
in class AbstractSnmpContext
pdu
- the pduAbstractSnmpContext.addPdu(Pdu)
,
addDiscoveryPdu(DiscoveryPdu)
protected UsmAgent createUsmAgent()
public static void setUsmAgent(UsmAgent agent)
agent
- The USM authoritative interfaceprotected boolean addPdu(Pdu pdu, boolean checkDiscovery) throws java.io.IOException, PduException
checkDiscovery
.
If discovery is needed this method will block until it have done so.
Discovery is only needed if the stack is non authoritative.pdu
- the pducheckDiscovery
- check if discovery is neededAbstractSnmpContext.addPdu(Pdu)
,
addDiscoveryPdu(DiscoveryPdu)
,
addPdu(Pdu)
public boolean removePdu(int rid)
removePdu
in interface SnmpContextBasisFace
removePdu
in class AbstractSnmpContext
rid
- the Pdu request idAbstractSnmpContext.removePdu(int)
public byte[] encodeDiscoveryPacket(byte msg_type, int rId, int errstat, int errind, java.util.Enumeration ve) throws java.io.IOException, EncodingException
encodeDiscoveryPacket
in interface SnmpContextv3Face
uk.co.westhawk.snmp.stack.SnmpContextv3Face
public byte[] encodePacket(byte msg_type, int rId, int errstat, int errind, java.util.Enumeration ve) throws java.io.IOException, EncodingException
encodePacket
in interface SnmpContextBasisFace
encodePacket
in class AbstractSnmpContext
uk.co.westhawk.snmp.stack.SnmpContextBasisFace
protected byte[] actualEncodePacket(byte msg_type, int rId, int errstat, int errind, java.util.Enumeration ve, uk.co.westhawk.snmp.stack.TimeWindowNode node) throws java.io.IOException, EncodingException
encodeDiscoveryPacket(byte, int, int, int, java.util.Enumeration)
,
encodePacket(byte, int, int, int, java.util.Enumeration)
protected void ProcessIncomingMessage(uk.co.westhawk.snmp.stack.AsnDecoder rpdu, java.io.ByteArrayInputStream in) throws DecodingException, java.io.IOException
ProcessIncomingMessage
in class AbstractSnmpContext
uk.co.westhawk.snmp.stack.AbstractSnmpContext
AbstractSnmpContext.run()
protected boolean isAuthoritative(byte msg_type)
public Pdu processIncomingTrap(byte[] message) throws DecodingException, java.io.IOException
SnmpContextBasisFace
processIncomingTrap
in interface SnmpContextBasisFace
processIncomingTrap
in class AbstractSnmpContext
uk.co.westhawk.snmp.stack.AbstractSnmpContext
AbstractSnmpContext.trapReceived(uk.co.westhawk.snmp.event.TrapEvent)
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- Thrown when the constructor
generates an IOExceptionpublic java.lang.String toString()
toString
in class java.lang.Object
|
SNMP Stack 4_12 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |