|
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.SnmpContextv3Pool
This class contains the pool of SNMP v3 contexts. This class reuses the existings contexts instead of creating a new one everytime.
Everytime a property changes the pool is checked for a SnmpContextv3 context that matches all the new properties of this class. If no such context exists, a new one is made. The Pdus associated with the old context remain associated with the old context.
A counter indicates the number of times the context is referenced.
The counter is decreased when destroy
is called.
When the counter
reaches zero, the context is released.
Note that because the underlying context can change when a property is changed and the Pdus remain associated with the old context, all properties have to be set BEFORE a Pdu is send.
SnmpContextv3
,
SnmpContextPool
,
SnmpContextv2cPool
Field Summary | |
protected int |
authenticationProtocol
|
protected SnmpContextv3 |
context
|
protected byte[] |
contextEngineId
|
protected java.lang.String |
contextName
|
protected static java.util.Hashtable |
contextPool
|
protected boolean |
hasChanged
|
protected java.lang.String |
hostAddr
|
protected int |
hostPort
|
protected java.lang.String |
socketType
|
protected boolean |
useAuthentication
|
protected boolean |
usePrivacy
|
protected java.lang.String |
userAuthenticationPassword
|
protected java.lang.String |
userName
|
protected java.lang.String |
userPrivacyPassword
|
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 |
Constructor Summary | |
SnmpContextv3Pool(java.lang.String host,
int port)
Constructor. |
|
SnmpContextv3Pool(java.lang.String host,
int port,
java.lang.String typeSocket)
Constructor. |
Method Summary | |
boolean |
addDiscoveryPdu(DiscoveryPdu pdu)
Adds an discovery pdu. |
boolean |
addPdu(Pdu pdu)
Adds an pdu. |
void |
addTrapListener(TrapListener l)
Adds the specified trap listener. |
void |
destroy()
Releases the resources held by this context. |
void |
dumpContexts(java.lang.String title)
Dumps the pool of contexts. |
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 |
getHashKey()
Returns the hash key. |
java.lang.String |
getHost()
Returns the host |
protected SnmpContextv3 |
getMatchingContext()
Returns a context from the pool. |
int |
getPort()
Returns the port number |
java.lang.String |
getTypeSocket()
Returns the type socket |
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. |
boolean |
isUseAuthentication()
Return if authentication is used or not. |
boolean |
isUsePrivacy()
Return if privacy is used or not. |
Pdu |
processIncomingTrap(byte[] message)
Processes the incoming trap with the current context. |
boolean |
removePdu(int requestId)
Removes a pdu. |
void |
removeTrapListener(TrapListener l)
Removes the specified trap listener. |
void |
sendPacket(byte[] packet)
Pass a correctly encoded SNMP packet, and we'l send it... |
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 newUserAuthenticationPd)
Sets the user authentication password. |
void |
setUserName(java.lang.String newUserName)
Sets the username. |
void |
setUserPrivacyPassword(java.lang.String newUserPrivacyPd)
Sets the user privacy password. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static java.util.Hashtable contextPool
protected java.lang.String hostAddr
protected java.lang.String socketType
protected int hostPort
protected SnmpContextv3 context
protected java.lang.String userName
protected boolean useAuthentication
protected java.lang.String userAuthenticationPassword
protected boolean usePrivacy
protected java.lang.String userPrivacyPassword
protected int authenticationProtocol
protected byte[] contextEngineId
protected java.lang.String contextName
protected boolean hasChanged
Constructor Detail |
public SnmpContextv3Pool(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 beSnmpContextv3.SnmpContextv3(String, int)
public SnmpContextv3Pool(java.lang.String host, int port, java.lang.String typeSocket) throws java.io.IOException
host
- The host to which the Pdu will sendport
- The port where the SNMP server will betypeSocket
- The type of socket to use.SnmpContextv3.SnmpContextv3(String, int, String)
,
SnmpContextBasisFace.STANDARD_SOCKET
,
SnmpContextBasisFace.NETSCAPE_SOCKET
,
SnmpContextBasisFace.KVM_SOCKET
Method Detail |
public int getVersion()
getVersion
in interface SnmpContextBasisFace
public java.lang.String getHost()
getHost
in interface SnmpContextBasisFace
public int getPort()
getPort
in interface SnmpContextBasisFace
public java.lang.String getTypeSocket()
getTypeSocket
in interface SnmpContextBasisFace
public java.lang.String getUserName()
getUserName
in interface SnmpContextv3Face
SnmpContextv3.getUserName()
public void setUserName(java.lang.String newUserName)
setUserName
in interface SnmpContextv3Face
newUserName
- The new usernameSnmpContextv3.setUserName(String)
public boolean isUseAuthentication()
isUseAuthentication
in interface SnmpContextv3Face
SnmpContextv3.isUseAuthentication()
public void setUseAuthentication(boolean newUseAuthentication)
setUseAuthentication
in interface SnmpContextv3Face
newUseAuthentication
- The use of authenticationSnmpContextv3.setUseAuthentication(boolean)
public java.lang.String getUserAuthenticationPassword()
getUserAuthenticationPassword
in interface SnmpContextv3Face
SnmpContextv3.getUserAuthenticationPassword()
public void setUserAuthenticationPassword(java.lang.String newUserAuthenticationPd)
setUserAuthenticationPassword
in interface SnmpContextv3Face
newUserAuthenticationPassword
- The user authentication passwordSnmpContextv3.setUserAuthenticationPassword(String)
public void setAuthenticationProtocol(int protocol)
setAuthenticationProtocol
in interface SnmpContextv3Face
protocol
- The authentication protocol to be usedSnmpContextv3.setAuthenticationProtocol(int)
public int getAuthenticationProtocol()
getAuthenticationProtocol
in interface SnmpContextv3Face
SnmpContextv3.getAuthenticationProtocol()
public boolean isUsePrivacy()
isUsePrivacy
in interface SnmpContextv3Face
SnmpContextv3.isUsePrivacy()
public void setUsePrivacy(boolean newUsePrivacy)
setUsePrivacy
in interface SnmpContextv3Face
newUsePrivacy
- The use of privacySnmpContextv3.setUsePrivacy(boolean)
public java.lang.String getUserPrivacyPassword()
getUserPrivacyPassword
in interface SnmpContextv3Face
SnmpContextv3.getUserPrivacyPassword()
public void setUserPrivacyPassword(java.lang.String newUserPrivacyPd)
setUserPrivacyPassword
in interface SnmpContextv3Face
newUserPrivacyPassword
- The user privacy passwordSnmpContextv3.setUserPrivacyPassword(String)
public void setContextEngineId(byte[] newContextEngineId)
setContextEngineId
in interface SnmpContextv3Face
newContextEngineId
- The contextEngineIDSnmpContextv3.setContextEngineId(byte [])
public byte[] getContextEngineId()
getContextEngineId
in interface SnmpContextv3Face
SnmpContextv3.getContextEngineId()
public void setContextName(java.lang.String newContextName)
setContextName
in interface SnmpContextv3Face
newContextName
- The contextNameSnmpContextv3.setContextName(String)
public java.lang.String getContextName()
getContextName
in interface SnmpContextv3Face
SnmpContextv3.getContextName()
public boolean addDiscoveryPdu(DiscoveryPdu pdu) throws java.io.IOException, PduException, java.lang.IllegalArgumentException
addDiscoveryPdu
in interface SnmpContextv3Face
pdu
- the discovery pduSnmpContextv3.addPdu(Pdu)
,
addPdu(Pdu)
public boolean addPdu(Pdu pdu) throws java.io.IOException, PduException, java.lang.IllegalArgumentException
addPdu
in interface SnmpContextBasisFace
pdu
- the pduSnmpContextv3.addPdu(Pdu)
,
addDiscoveryPdu(DiscoveryPdu)
public boolean removePdu(int requestId)
removePdu
in interface SnmpContextBasisFace
rid
- the Pdu request idSnmpContextv3.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
uk.co.westhawk.snmp.stack.SnmpContextBasisFace
public void sendPacket(byte[] packet)
sendPacket
in interface SnmpContextBasisFace
uk.co.westhawk.snmp.stack.SnmpContextBasisFace
packet
- The encoded packetpublic void destroy()
destroy
in interface SnmpContextBasisFace
protected SnmpContextv3 getMatchingContext() throws java.io.IOException, java.lang.IllegalArgumentException
getHashKey()
public void dumpContexts(java.lang.String title)
title
- The title of the dumppublic java.lang.String getHashKey()
public void addTrapListener(TrapListener l) throws java.io.IOException
addTrapListener
in interface SnmpContextBasisFace
AbstractSnmpContext.addTrapListener(uk.co.westhawk.snmp.event.TrapListener)
public void removeTrapListener(TrapListener l) throws java.io.IOException
removeTrapListener
in interface SnmpContextBasisFace
AbstractSnmpContext.removeTrapListener(uk.co.westhawk.snmp.event.TrapListener)
public Pdu processIncomingTrap(byte[] message) throws DecodingException, java.io.IOException
processIncomingTrap
in interface SnmpContextBasisFace
SnmpContextv3.processIncomingTrap(byte[])
public 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 |