Search in sources :

Example 1 with Priv3DES

use of org.snmp4j.security.Priv3DES in project openhab1-addons by openhab.

the class SnmpBinding method listen.

/**
     * Configures a {@link DefaultUdpTransportMapping} and starts listening on
     * <code>SnmpBinding.port</code> for incoming SNMP Traps.
     */
private void listen() {
    UdpAddress address = new UdpAddress(SnmpBinding.port);
    try {
        if (transport != null) {
            transport.close();
            transport = null;
        }
        if (snmp != null) {
            snmp.close();
            snmp = null;
        }
        transport = new DefaultUdpTransportMapping(address);
        // add all security protocols
        SecurityProtocols.getInstance().addDefaultProtocols();
        SecurityProtocols.getInstance().addPrivacyProtocol(new Priv3DES());
        // Create Target
        if (SnmpBinding.community != null) {
            CommunityTarget target = new CommunityTarget();
            target.setCommunity(new OctetString(SnmpBinding.community));
        }
        snmp = new Snmp(transport);
        transport.listen();
        logger.debug("SNMP binding is listening on " + address);
    } catch (IOException ioe) {
        logger.error("SNMP binding couldn't listen to " + address, ioe);
    }
}
Also used : OctetString(org.snmp4j.smi.OctetString) UdpAddress(org.snmp4j.smi.UdpAddress) Priv3DES(org.snmp4j.security.Priv3DES) Snmp(org.snmp4j.Snmp) DefaultUdpTransportMapping(org.snmp4j.transport.DefaultUdpTransportMapping) IOException(java.io.IOException) CommunityTarget(org.snmp4j.CommunityTarget)

Aggregations

IOException (java.io.IOException)1 CommunityTarget (org.snmp4j.CommunityTarget)1 Snmp (org.snmp4j.Snmp)1 Priv3DES (org.snmp4j.security.Priv3DES)1 OctetString (org.snmp4j.smi.OctetString)1 UdpAddress (org.snmp4j.smi.UdpAddress)1 DefaultUdpTransportMapping (org.snmp4j.transport.DefaultUdpTransportMapping)1