Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 5_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.co.westhawk.snmp.stack
Class SnmpContextv3

    java.lang.Object
      |
      +--uk.co.westhawk.snmp.stack.AbstractSnmpContext
            |
            +--uk.co.westhawk.snmp.stack.SnmpContextv3Basis
                  |
                  +--uk.co.westhawk.snmp.stack.SnmpContextv3

All Implemented Interfaces:
  java.lang.Cloneable, java.util.EventListener, RawPduListener, java.lang.Runnable, SnmpContextBasisFace, SnmpContextv3Face

public class SnmpContextv3
extends SnmpContextv3Basis

This class contains the SNMP v3 context that is needed by every PDU to send a SNMP v3 request. Most of the work is done by SnmpContextv3Basis, like doing discovery.

Now that the stack can send traps and receive requests, 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 adds a UsmBeingDiscoveredBean as listener. This bean handles any incoming discovery PDU. Only when acting as authoritative engine should there be any discovery PDU.

Version:
  $Revision: 3.29 $ $Date: 2006/03/23 14:54:10 $
Author:
  Birgit Arkesteijn
See Also:
  `SnmpContextv3Face`, `SnmpContextv3Pool`, `TimeWindow`, `DefaultUsmAgent`, `UsmAgent`, `SnmpContextv3Basis.setUsmAgent(UsmAgent)`, `UsmDiscoveryBean`

Field Summary

Fields inherited from class uk.co.westhawk.snmp.stack.SnmpContextv3Basis
`authenticationProtocol, contextEngineId, contextName, useAuthentication, usePrivacy, userAuthenticationPassword, userAuthKeyMD5, userAuthKeySHA1, userName, userPrivacyPassword, userPrivKeyMD5, userPrivKeySHA1, usmAgent`

Fields inherited from class uk.co.westhawk.snmp.stack.AbstractSnmpContext
`anyPduExpectingResponse, bindAddr, hostname, hostPort, isDestroyed, maxRecvSize, pduSupport, trapSupport, 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, TCP_SOCKET`

Fields inherited from interface uk.co.westhawk.snmp.event.RawPduListener
`version_id`

Constructor Summary
`SnmpContextv3(java.lang.String host, int port)` Constructor.
`SnmpContextv3(java.lang.String host, int port, java.lang.String typeSocketA)` Constructor.
`SnmpContextv3(java.lang.String host, int port, java.lang.String bindAddress, java.lang.String typeSocketA)` Constructor.

Method Summary
`void` | `addRequestPduListener(RequestPduListener l, ListeningContextPool lcontext)` Makes sure the UsmBeingDiscoveredBean is added as RequestPduListener, so that discovery requests are handled.
`java.lang.Object` | `clone()` Returns a clone of this SnmpContextv3.
`Pdu` | `processIncomingPdu(byte[] message)` Processes an incoming PDU, that is not a Discovery PDU.
`Pdu` | `processPotentialRequest(uk.co.westhawk.snmp.stack.AsnDecoderv3 rpdu, uk.co.westhawk.snmp.stack.AsnSequence asnTopSeq, byte[] message)` Processes an incoming PDU, to see if it is a Request.
`Pdu` | `processPotentialTrap(uk.co.westhawk.snmp.stack.AsnDecoderv3 rpdu, uk.co.westhawk.snmp.stack.AsnSequence asnTopSeq, byte[] message)` Processes an incoming PDU, to see if it is a Trap.
`void` | `removeRequestPduListener(RequestPduListener l, ListeningContextPool lcontext)` Removes the UsmBeingDiscoveredBean as listener.

Methods inherited from class uk.co.westhawk.snmp.stack.SnmpContextv3Basis
`actualEncodePacket, addDiscoveryPdu, addPdu, addPdu, checkContextSanity, cloneParameters, createUsmAgent, encodeDiscoveryPacket, encodePacket, getAuthenticationProtocol, getContextEngineId, getContextName, getHashKey, getUserAuthenticationPassword, getUserName, getUserPrivacyPassword, getUsmAgent, getVersion, isAuthoritative, isUseAuthentication, isUsePrivacy, processIncomingResponse, removePdu, setAuthenticationProtocol, setContextEngineId, setContextName, setUseAuthentication, setUsePrivacy, setUserAuthenticationPassword, setUserName, setUserPrivacyPassword, setUsmAgent, toString`

Methods inherited from class uk.co.westhawk.snmp.stack.AbstractSnmpContext
`activate, addRequestPduListener, addRequestPduListener, addTrapListener, addTrapListener, addTrapListener, destroy, freeTransmitters, getBindAddress, getDebugString, getHost, getHostAddress, getMaxRecvSize, getPort, getReceivedFromHostAddress, getSendToHostAddress, getTypeSocket, isDestroyed, rawPduReceived, removeRequestPduListener, removeRequestPduListener, removeTrapListener, removeTrapListener, removeTrapListener, run, sendPacket, setMaxRecvSize, stop`

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
`addRequestPduListener, addRequestPduListener, addTrapListener, addTrapListener, addTrapListener, destroy, getBindAddress, getHost, getPort, getReceivedFromHostAddress, getSendToHostAddress, getTypeSocket, isDestroyed, removeRequestPduListener, removeRequestPduListener, removeTrapListener, removeTrapListener, removeTrapListener, sendPacket`

Constructor Detail

### SnmpContextv3

    public SnmpContextv3(java.lang.String host,
                         int port)
                  throws java.io.IOException

  Constructor.

Parameters:
  `host` - The host to which the PDU will be sent
  `port` - The port where the SNMP server will be
See Also:
  `AbstractSnmpContext.AbstractSnmpContext(String, int)`

### SnmpContextv3

    public SnmpContextv3(java.lang.String host,
                         int port,
                         java.lang.String typeSocketA)
                  throws java.io.IOException

  Constructor.

Parameters:
  `host` - The host to which the Pdu will be sent
  `port` - The port where the SNMP server will be
  `typeSocketA` - The local address the server will bind to
See Also:
  `AbstractSnmpContext.AbstractSnmpContext(String, int, String)`

### SnmpContextv3

    public SnmpContextv3(java.lang.String host,
                         int port,
                         java.lang.String bindAddress,
                         java.lang.String typeSocketA)
                  throws java.io.IOException

  Constructor.

Parameters:
  `host` - The host to which the PDU will be sent
  `port` - The port where the SNMP server will be
  `bindAddress` - The local address the server will bind to
  `typeSocketA` - The type of socket to use.
Since:
  4_14
See Also:
  `AbstractSnmpContext.AbstractSnmpContext(String, int, String, String)`, `SnmpContextBasisFace.STANDARD_SOCKET`, `SnmpContextBasisFace.TCP_SOCKET`, `SnmpContextBasisFace.NETSCAPE_SOCKET`, `SnmpContextBasisFace.KVM_SOCKET`

Method Detail

### addRequestPduListener

    public void addRequestPduListener(RequestPduListener l,
                                      ListeningContextPool lcontext)
                               throws java.io.IOException

  Makes sure the UsmBeingDiscoveredBean is added as RequestPduListener, so that discovery requests are handled. When listening for incoming requests, the stack become authoritative. You have (!) to create a proper usmAgent so the stack can be discovered.

  Don't use the TCP_SOCKET when listening for request PDUs. It doesn't provide functionality to send a response back.

  Specified by:
    `addRequestPduListener` in interface `SnmpContextBasisFace`
  Overrides:
    `addRequestPduListener` in class `SnmpContextv3Basis`
  Parameters:
    `l` - The request PDU listener
    `lcontext` - The listening context
    `java.io.IOException`
  See Also:
    `removeRequestPduListener(RequestPduListener, ListeningContextPool)`, `UsmBeingDiscoveredBean`, `SnmpContextv3Basis.setUsmAgent(UsmAgent)`

### removeRequestPduListener

    public void removeRequestPduListener(RequestPduListener l,
                                         ListeningContextPool lcontext)
                                  throws java.io.IOException

  Removes the UsmBeingDiscoveredBean as listener.

  Specified by:
    `removeRequestPduListener` in interface `SnmpContextBasisFace`
  Overrides:
    `removeRequestPduListener` in class `AbstractSnmpContext`
  Parameters:
    `l` - The request PDU listener
    `lcontext` - The listening context
    `java.io.IOException`
  See Also:
    `addRequestPduListener(RequestPduListener, ListeningContextPool)`

### processIncomingPdu

    public Pdu processIncomingPdu(byte[] message)
                           throws DecodingException,
                                  java.io.IOException

  Processes an incoming PDU, that is not a Discovery PDU.

  See SNMP-USER-BASED-SM-MIB.

  This method calls first processPotentialTrap and then processPotentialRequest. The reason this code is split up is because in one case the stack acts as authoritative engine and as non authoritative engine in the other..

  Specified by:
    `processIncomingPdu` in interface `SnmpContextBasisFace`
  Specified by:
    `processIncomingPdu` in class `AbstractSnmpContext`
    `DecodingException`
    `java.io.IOException`
  See Also:
    `AbstractSnmpContext.rawPduReceived(uk.co.westhawk.snmp.event.RawPduEvent)`, `processPotentialTrap(uk.co.westhawk.snmp.stack.AsnDecoderv3, uk.co.westhawk.snmp.stack.AsnSequence, byte[])`, `processPotentialRequest(uk.co.westhawk.snmp.stack.AsnDecoderv3, uk.co.westhawk.snmp.stack.AsnSequence, byte[])`

### processPotentialTrap

    public Pdu processPotentialTrap(uk.co.westhawk.snmp.stack.AsnDecoderv3 rpdu,
                                    uk.co.westhawk.snmp.stack.AsnSequence asnTopSeq,
                                    byte[] message)
                             throws DecodingException,
                                    java.io.IOException

  Processes an incoming PDU, to see if it is a Trap. This method is called by processIncomingPdu. When receiving traps the stack is non authoritative.

    `DecodingException`
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `processIncomingPdu(byte[])`, `processPotentialRequest(uk.co.westhawk.snmp.stack.AsnDecoderv3, uk.co.westhawk.snmp.stack.AsnSequence, byte[])`

### processPotentialRequest

    public Pdu processPotentialRequest(uk.co.westhawk.snmp.stack.AsnDecoderv3 rpdu,
                                       uk.co.westhawk.snmp.stack.AsnSequence asnTopSeq,
                                       byte[] message)
                                throws DecodingException,
                                       java.io.IOException

  Processes an incoming PDU, to see if it is a Request. This method is called by processIncomingPdu. When receiving pdu requests the stack is authoritative.

    `DecodingException`
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `processIncomingPdu(byte[])`, `processPotentialTrap(uk.co.westhawk.snmp.stack.AsnDecoderv3, uk.co.westhawk.snmp.stack.AsnSequence, byte[])`

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Returns a clone of this SnmpContextv3.

  Specified by:
    `clone` in interface `SnmpContextBasisFace`
  Specified by:
    `clone` in class `AbstractSnmpContext`
  Throws:
    `java.lang.CloneNotSupportedException` - Thrown when the constructor generates an IOException

Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 5_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD