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

## com.sun.management.snmp.agent
Class SnmpTrapForwarder

    java.lang.Object
      com.sun.management.snmp.agent.SnmpTrapReceiver
          com.sun.management.snmp.agent.SnmpTrapForwarder

All Implemented Interfaces:
  SnmpTrapForwarderMBean

public class SnmpTrapForwarder
extends SnmpTrapReceiver
implements SnmpTrapForwarderMBean

This MBean allows you to receive traps of subagents and forward them to managers.

This trap forwarder listen on a dedicated port and forward traps according to its configuration.

If you activate V1, V2 and V3 protocols, every received trap (in V1 / V2 or V3) will be forwarded in all SNMP protocols. It can be useful when you don't know which protocol the managers are using.

You can pass specific manager addresses when forwarding for a specific protocol. By default the `InetAddressAcl` is also parsed. So the set of actual manager addresses is the trap blocks located in the acl file and the set of added targets. You can disable the use of `InetAddressAcl` by calling the method ``setInetAddressAclUsed(false)``.

To enable trap forwarding you must start the forwarder.

WARNING : In case you have some manager addresses in your set of targets that are also present in InetAddressAcl (or no InetAddressAcl activated but a target equals to localhost), your manager will receive the trap twice. In order to protect yourself against this behavior, configure carefully the `SnmpTrapForwarder`. You can, for example, disable the InetAddressAcl parsing by calling ``setInetAddressAclUsed(false)``.

Since:
  Java DMK 5.1

Constructor Summary
`SnmpTrapForwarder(SnmpV3AdaptorServer server, int port)` Instantiate a `SnmpTrapForwarder` that will forward received traps according to its configuration.
`SnmpTrapForwarder(SnmpV3AdaptorServer server, int port, InetAddress address)` Instantiate a `SnmpTrapForwarder` that will forward received traps according to its configuration.

Method Summary
`void` | `addV1Target(String address, int port, String communityString)` Add a target to which SNMP V1 traps will be forwarded to.
`void` | `addV1Target(String address, String communityString)` Add a target to which SNMP V1 traps will be forwarded to.
`void` | `addV2Target(String address, int port, String communityString)` Add a target to which SNMP V2 traps will be forwarded to.
`void` | `addV2Target(String address, String communityString)` Add a target to which SNMP V2 traps will be forwarded to.
`void` | `addV3Target(String address, int port, String principal, String contextName, int securityLevel)` Add a target to which SNMP V3 traps will be forwarded to.
`void` | `addV3Target(String address, String principal, String contextName, int securityLevel)` Add a target to which SNMP V3 traps will be forwarded to.
`void` | `forwardAsNotificationOriginator()` By default a trap is sent as a notification originator.
`void` | `forwardAsProxy()` By default a trap is sent as a notification originator.
`boolean` | `isInetAddressAclUsed()` Says if The `SnmpTrapForwarder` parses or not the `InetAddressAcl` when forwarding traps.
`boolean` | `isOriginatorWay()` By default a trap is sent as a notification originator.
`boolean` | `isProxyWay()` By default a trap is sent as a notification originator.
`boolean` | `isV1Activated()` Return true if Snmp V1 forwarding is activated.
`boolean` | `isV2Activated()` Return true if Snmp V2 forwarding is activated.
`boolean` | `isV3Activated()` Return true if Snmp V3 forwarding is activated.
`protected void` | `receivedTrap(SnmpTrap trap)` You must implement this method in order to handle received traps in a generic way.
`boolean` | `removeV1Target(String address)` Remove the first occurrence of the passed target.
`boolean` | `removeV1Target(String address, int port)` Remove the first occurrence of the passed target.
`boolean` | `removeV2Target(String address)` Remove the first occurrence of the passed target.
`boolean` | `removeV2Target(String address, int port)` Remove the first occurrence of the passed target.
`boolean` | `removeV3Target(String address)` Remove the first occurrence of the passed target.
`boolean` | `removeV3Target(String address, int port)` Remove the first occurrence of the passed target.
`void` | `setCommunityString(String cs)` When forwarding in SNMP V1 and or V2, if useInetAddressAcl is activated and no ACL file or no destinations are available, the trap is sent to the local host using this specified community string.
`void` | `setInetAddressAclUsed(boolean use)` By default if an `InetAddressAcl` file is loaded by the SNMP adaptor, it will be parsed in order to find manager IP addresses.
`void` | `setSourceIpAddress(InetAddress addr)` When a trap is received, localhost is set as the source of the forwarded trap.
`void` | `setV3Parameters(String principal, String contextName, int securityLevel)` When forwarding in Snmp V3, the default principal, context and security level to use.
`void` | `snmpV1forwarding(boolean status)` Activate or deactivate SNMP V1 trap forwarding without providing targets (using the method `addV1Target`).
`void` | `snmpV2forwarding(boolean status)` Activate or deactivate SNMP V2 trap forwarding without providing targets (using the method `addV2Target`).
`void` | `snmpV3forwarding(boolean status)` Activate or deactivate SNMP V3 trap forwarding without providing targets (using the method `addV3Target`).

Methods inherited from class com.sun.management.snmp.agent.SnmpTrapReceiver
`createCallbackTaskServer, createDispatcherThread, createPacketTaskServer, receiveAsGeneric, receivedV1Trap, receivedV2Trap, receivedV3Trap, start, stop`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SnmpTrapForwarder

    public SnmpTrapForwarder(SnmpV3AdaptorServer server,
                             int port)

  Instantiate a `SnmpTrapForwarder` that will forward received traps according to its configuration.

Parameters:
  `server` - The current adaptor.
  `port` - The port the forwarder is listening to.

### SnmpTrapForwarder

    public SnmpTrapForwarder(SnmpV3AdaptorServer server,
                             int port,
                             InetAddress address)

  Instantiate a `SnmpTrapForwarder` that will forward received traps according to its configuration.

Parameters:
  `server` - The current adaptor.
  `port` - The port the forwarder is listening to.
  `address` - The address used to listen for incoming traps.

Method Detail

### setCommunityString

    public void setCommunityString(String cs)

  When forwarding in SNMP V1 and or V2, if useInetAddressAcl is activated and no ACL file or no destinations are available, the trap is sent to the local host using this specified community string.

  Parameters:
    `cs` - The default community string to use.

### setV3Parameters

    public void setV3Parameters(String principal,
                                String contextName,
                                int securityLevel)

  When forwarding in Snmp V3, the default principal, context and security level to use. These parameters are used for the targets specified in the InetAddressAcl.

  Parameters:
    `principal` - Will be used by Usm in order to find security parameters.
    `contextName` - The forwarded trap contextName.
    `securityLevel` - The message security level.

### setInetAddressAclUsed

    public void setInetAddressAclUsed(boolean use)

  By default if an `InetAddressAcl` file is loaded by the SNMP adaptor, it will be parsed in order to find manager IP addresses. This parsing is done when forwarding in SNMP V1 V2 and V3. In the case of SNMP V3 forwarding, the parsed targets are used only if the SNMP V3 parameters have been provided (via setV3Parameters method).

  If you provided some targets (addV1/2/3Target methods) they are also used when forwarding traps. The set of targets is `InetAddressAcl` trap blocks + added targets. If you don't use `InetAddressAcl` (passing false to this method), only the set of added targets is used.

  Specified by:
    `setInetAddressAclUsed` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `use` - The use of `InetAddressAcl`

### isInetAddressAclUsed

    public boolean isInetAddressAclUsed()

  Says if The `SnmpTrapForwarder` parses or not the `InetAddressAcl` when forwarding traps.

  Specified by:
    `isInetAddressAclUsed` in interface `SnmpTrapForwarderMBean`
  Returns:
    true the file is parsed, false the file is not parsed.

### isV1Activated

    public boolean isV1Activated()

  Return true if Snmp V1 forwarding is activated.

  Specified by:
    `isV1Activated` in interface `SnmpTrapForwarderMBean`

### isV2Activated

    public boolean isV2Activated()

  Return true if Snmp V2 forwarding is activated.

  Specified by:
    `isV2Activated` in interface `SnmpTrapForwarderMBean`

### isV3Activated

    public boolean isV3Activated()

  Return true if Snmp V3 forwarding is activated.

  Specified by:
    `isV3Activated` in interface `SnmpTrapForwarderMBean`

### snmpV1forwarding

    public void snmpV1forwarding(boolean status)

  Activate or deactivate SNMP V1 trap forwarding without providing targets (using the method `addV1Target`). InetAddressAcl or localhost are used as the default targets.

  Specified by:
    `snmpV1forwarding` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `status` - True activate it, false deactivate it.

### snmpV2forwarding

    public void snmpV2forwarding(boolean status)

  Activate or deactivate SNMP V2 trap forwarding without providing targets (using the method `addV2Target`). InetAddressAcl or localhost are used as the default targets.

  Specified by:
    `snmpV2forwarding` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `status` - True activate it, false deactivate it.

### snmpV3forwarding

    public void snmpV3forwarding(boolean status)

  Activate or deactivate SNMP V3 trap forwarding without providing targets (using the method `addV3Target`). InetAddressAcl or localhost are used as the default targets.

  Specified by:
    `snmpV3forwarding` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `status` - True activate it, false deactivate it.

### removeV1Target

    public boolean removeV1Target(String address)

  Remove the first occurrence of the passed target.

  Specified by:
    `removeV1Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name).
  Returns:
    True removed, false target not present.

### removeV2Target

    public boolean removeV2Target(String address)

  Remove the first occurrence of the passed target.

  Specified by:
    `removeV2Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name).
  Returns:
    True removed, false target not present.

### removeV3Target

    public boolean removeV3Target(String address)

  Remove the first occurrence of the passed target.

  Specified by:
    `removeV3Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name).
  Returns:
    True removed, false target not present.

### removeV1Target

    public boolean removeV1Target(String address,
                                  int port)

  Remove the first occurrence of the passed target.

  Specified by:
    `removeV1Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name).
    `port` - The port to which the trap is sent.
  Returns:
    True removed, false target not present.

### removeV2Target

    public boolean removeV2Target(String address,
                                  int port)

  Remove the first occurrence of the passed target.

  Specified by:
    `removeV2Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name).
    `port` - The port to which the trap is sent.
  Returns:
    True removed, false target not present.

### removeV3Target

    public boolean removeV3Target(String address,
                                  int port)

  Remove the first occurrence of the passed target.

  Specified by:
    `removeV3Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name).
    `port` - The port to which the trap is sent.
  Returns:
    True removed, false target not present.

### addV1Target

    public void addV1Target(String address,
                            int port,
                            String communityString)

  Add a target to which SNMP V1 traps will be forwarded to. WARNING: When specifying a port to send trap, the whole `SnmpV3AdaptorServer` is impacted. The port changing is effective when sending the trap. Concurrent call to `SnmpV3AdaptorServer` trap API can lead to unpredictable behavior.

  The same target can be added multiple time.

  Specified by:
    `addV1Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name);
    `port` - The port to which the trap is sent. If port == -1, the adaptor port is used.
    `communityString` - The associated community string.
  Throws:
    `IllegalArgumentException` - If the the port is == 0 or the address is invalid (cause field set to `java.net.UnknownHostException` if JDK Version >= 1.4).

### addV2Target

    public void addV2Target(String address,
                            int port,
                            String communityString)

  Add a target to which SNMP V2 traps will be forwarded to. WARNING: When specifying a port to send trap, the whole `SnmpV3AdaptorServer` is impacted. The port changing is effective when sending the trap. Concurrent call to `SnmpV3AdaptorServer` trap API can lead to unpredictable behavior.

  The same target can be added multiple time.

  Specified by:
    `addV2Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name);
    `port` - The port to which the trap is sent. If port == -1, the adaptor port is used.
    `communityString` - The associated community string.
  Throws:
    `IllegalArgumentException` - If the the port is == 0 or the address is invalid (cause field set to `java.net.UnknownHostException` if JDK Version >= 1.4).

### addV3Target

    public void addV3Target(String address,
                            int port,
                            String principal,
                            String contextName,
                            int securityLevel)

  Add a target to which SNMP V3 traps will be forwarded to. WARNING: When specifying a port to send trap, the whole `SnmpV3AdaptorServer` is impacted. The port changing is effective when sending the trap. Concurrent call to `SnmpV3AdaptorServer` trap API can lead to unpredictable behavior.

  The same target can be added multiple time.

  Specified by:
    `addV3Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name);
    `port` - The port to which the trap is sent. If port == -1, the adaptor port is used.
    `principal` - The user.
    `contextName` - The context name.
    `securityLevel` - The security level.
  Throws:
    `IllegalArgumentException` - If the the port is == 0, if the principal is null, if the security level is not valid or if the address is invalid (cause field set to `java.net.UnknownHostException` if JDK Version >= 1.4).

### addV1Target

    public void addV1Target(String address,
                            String communityString)

  Add a target to which SNMP V1 traps will be forwarded to. The port used is the `SnmpV3AdaptorServer` one.

  The same target can be added multiple time.

  Specified by:
    `addV1Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name);
    `communityString` - The associated community string.
  Throws:
    `IllegalArgumentException` - If the address is invalid (cause field set to `java.net.UnknownHostException` if JDK Version >= 1.4).

### addV2Target

    public void addV2Target(String address,
                            String communityString)

  Add a target to which SNMP V2 traps will be forwarded to. The port used is the `SnmpV3AdaptorServer` one.

  The same target can be added multiple time.

  Specified by:
    `addV2Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name);
    `communityString` - The associated community string.
  Throws:
    `IllegalArgumentException` - If the address is invalid (cause field set to `java.net.UnknownHostException` if JDK Version >= 1.4).

### forwardAsNotificationOriginator

    public void forwardAsNotificationOriginator()

  By default a trap is sent as a notification originator. The difference between acting as a notification originator or a proxy when forwarding the trap is detailed in rfc 2576 section 3.1 and 3.2.

### forwardAsProxy

    public void forwardAsProxy()

  By default a trap is sent as a notification originator. The difference between acting as a notification originator or a proxy when forwarding the trap is detailed in rfc 2576 section 3.1 and 3.2.

### isOriginatorWay

    public boolean isOriginatorWay()

  By default a trap is sent as a notification originator. The difference between acting as a notification originator or a proxy when forwarding the trap is detailed in rfc 2576 section 3.1 and 3.2.

### isProxyWay

    public boolean isProxyWay()

  By default a trap is sent as a notification originator. The difference between acting as a notification originator or a proxy when forwarding the trap is detailed in rfc 2576 section 3.1 and 3.2.

### setSourceIpAddress

    public void setSourceIpAddress(InetAddress addr)

  When a trap is received, localhost is set as the source of the forwarded trap. In case you want a specific address, call this method providing it an ip address. If `isProxyWay()` returns true, the source address is the received one.

  Parameters:
    `addr` - The source address to use when forwarding the trap.

### addV3Target

    public void addV3Target(String address,
                            String principal,
                            String contextName,
                            int securityLevel)

  Add a target to which SNMP V3 traps will be forwarded to. The port used is the `SnmpV3AdaptorServer` one.

  The same target can be added multiple time.

  Specified by:
    `addV3Target` in interface `SnmpTrapForwarderMBean`
  Parameters:
    `address` - The target address (IP or name);
    `principal` - The user.
    `contextName` - The context name.
    `securityLevel` - The security level.
  Throws:
    `IllegalArgumentException` - If the principal is null, if the security level is not valid or if the address is invalid (cause field set to `java.net.UnknownHostException` if JDK Version >= 1.4).

### receivedTrap

    protected void receivedTrap(SnmpTrap trap)

  Description copied from class: `SnmpTrapReceiver`
  You must implement this method in order to handle received traps in a generic way. The default implementation does nothing.

  Overrides:
    `receivedTrap` in class `SnmpTrapReceiver`
  Parameters:
    `trap` - The received trap pdu.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| FCS Release jdmk-5_1-b34.3 2007.01.18_18:11:52_MET
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.