From 3d06b68e0e208ad92183c102653d9fc9a167e30c Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 12 Mar 2013 09:50:26 +0000
Subject: [PATCH] OPENDJ-813 (CR-1404) SNMP connection handler does not start when allowed-manager prop is set and server is running with JDK1.7
---
opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java | 37 +++++++++++++------------------------
1 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java b/opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java
index 7c727d50..3e4506e 100644
--- a/opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java
+++ b/opends/src/snmp/src/org/opends/server/snmp/SNMPInetAddressAcl.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
+ * Portions copyright 2013 ForgeRock AS
*/
package org.opends.server.snmp;
@@ -30,10 +31,11 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Enumeration;
-import java.util.Iterator;
+import java.util.HashSet;
+import java.util.Set;
import java.util.SortedSet;
-import java.util.TreeSet;
import java.util.Vector;
+
import org.opends.server.admin.std.server.SNMPConnectionHandlerCfg;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.loggers.debug.DebugTracer;
@@ -57,7 +59,7 @@
*/
private static final String ALL_MANAGERS_ALLOWED = "*";
- private TreeSet<InetAddress> hostsList;
+ private Set<InetAddress> hostsList;
private boolean allManagers = false;
private SortedSet<String> trapsDestinations;
@@ -76,17 +78,16 @@
this.currentConfig = configuration;
// hostsList
- SortedSet tmp = this.currentConfig.getAllowedManager();
+ SortedSet<String> tmp = this.currentConfig.getAllowedManager();
if (tmp.contains(ALL_MANAGERS_ALLOWED)) {
this.allManagers=true;
}
- this.hostsList = new TreeSet<InetAddress>();
+ this.hostsList = new HashSet<InetAddress>();
// Transform the String list into InetAddress List
- for (Iterator iter = tmp.iterator(); iter.hasNext();) {
+ for (String dest : tmp) {
try {
- String dest = (String) iter.next();
this.hostsList.add(InetAddress.getByName(dest));
- } catch (UnknownHostException ex) {
+ } catch (UnknownHostException ignore) {
}
}
@@ -110,7 +111,6 @@
* {@inheritDoc}
*/
public boolean checkReadPermission(InetAddress address) {
-
if (this.allManagers) {
return true;
}
@@ -120,15 +120,7 @@
}
// check the address is in the configured allowed managers
- boolean found = false;
- for (Iterator iter = this.hostsList.iterator(); iter.hasNext();) {
- InetAddress host = (InetAddress)iter.next();
- if (host.equals(address)) {
- found = true;
- break;
- }
- }
- return found;
+ return this.hostsList.contains(address);
}
/**
@@ -172,13 +164,10 @@
*/
public Enumeration getTrapDestinations() {
Vector<InetAddress> tempDests = new Vector<InetAddress>();
- for (Iterator iter = this.trapsDestinations.iterator(); iter.hasNext();)
- {
+ for (String dest : this.trapsDestinations) {
try {
- String dest = (String) iter.next();
- InetAddress addr = InetAddress.getByName(dest);
- tempDests.add(addr);
- } catch (UnknownHostException ex) {
+ tempDests.add(InetAddress.getByName(dest));
+ } catch (UnknownHostException ignore) {
}
}
return tempDests.elements();
--
Gitblit v1.10.0