From ca57d6ca9f260c6332d0bf0ab3ff37c476ec9fb3 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 18 Mar 2013 17:06:12 +0000
Subject: [PATCH] OPENDJ-808 Implement a simple commons REST based HTTP connection handler
---
opends/src/server/org/opends/server/core/networkgroups/IPConnectionCriteria.java | 30 +++++++++++++-----------------
1 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/opends/src/server/org/opends/server/core/networkgroups/IPConnectionCriteria.java b/opends/src/server/org/opends/server/core/networkgroups/IPConnectionCriteria.java
index b67e15e..0abc89f 100644
--- a/opends/src/server/org/opends/server/core/networkgroups/IPConnectionCriteria.java
+++ b/opends/src/server/org/opends/server/core/networkgroups/IPConnectionCriteria.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2009 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS.
+ * Portions copyright 2011-2013 ForgeRock AS.
*/
package org.opends.server.core.networkgroups;
@@ -46,11 +46,11 @@
final class IPConnectionCriteria implements ConnectionCriteria
{
- // The list of allowed client address masks.
- private final AddressMask[] allowedClients;
+ /** The collection of allowed client address masks. */
+ private final Collection<AddressMask> allowedClients;
- // The list of denied client address masks.
- private final AddressMask[] deniedClients;
+ /** The collection of denied client address masks. */
+ private final Collection<AddressMask> deniedClients;
@@ -66,8 +66,8 @@
public IPConnectionCriteria(Collection<AddressMask> allowedClients,
Collection<AddressMask> deniedClients)
{
- this.allowedClients = allowedClients.toArray(new AddressMask[0]);
- this.deniedClients = deniedClients.toArray(new AddressMask[0]);
+ this.allowedClients = allowedClients;
+ this.deniedClients = deniedClients;
}
@@ -79,20 +79,16 @@
{
InetAddress ipAddr = connection.getRemoteAddress();
- if (deniedClients.length > 0)
+ if (!deniedClients.isEmpty()
+ && AddressMask.maskListContains(ipAddr, deniedClients))
{
- if (AddressMask.maskListContains(ipAddr, deniedClients))
- {
- return false;
- }
+ return false;
}
- if (allowedClients.length > 0)
+ if (!allowedClients.isEmpty()
+ && !AddressMask.maskListContains(ipAddr, allowedClients))
{
- if (!AddressMask.maskListContains(ipAddr, allowedClients))
- {
- return false;
- }
+ return false;
}
return true;
--
Gitblit v1.10.0