From 14f94c13789b8ace4eae258b5f1d64494518f9c3 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 21 Dec 2015 14:04:12 +0000
Subject: [PATCH] Remove null checks on returned values of Entry.get*Attribute*() methods.
---
opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java | 62 ++++++++++++++-----------------
1 files changed, 28 insertions(+), 34 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java b/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
index 0f636b4..2b219f9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
@@ -1067,48 +1067,42 @@
}
AttributeType privType = DirectoryServer.getAttributeTypeOrNull(OP_ATTR_PRIVILEGE_NAME);
- List<Attribute> attrList = entry.getAttribute(privType);
- if (attrList != null)
+ for (Attribute a : entry.getAttribute(privType))
{
- for (Attribute a : attrList)
+ for (ByteString v : a)
{
- for (ByteString v : a)
+ String privName = toLowerCase(v.toString());
+
+ // If the name of the privilege is prefixed with a minus sign,
+ // then we will take away that privilege from the user.
+ // We'll handle that at the end so that we can make sure it's not added back later.
+ if (privName.startsWith("-"))
{
- String privName = toLowerCase(v.toString());
-
- // If the name of the privilege is prefixed with a minus
- // sign, then we will take away that privilege from the
- // user. We'll handle that at the end so that we can make
- // sure it's not added back later.
- if (privName.startsWith("-"))
+ privName = privName.substring(1);
+ Privilege p = Privilege.privilegeForName(privName);
+ if (p == null)
{
- privName = privName.substring(1);
- Privilege p = Privilege.privilegeForName(privName);
- if (p == null)
- {
- // FIXME -- Generate an administrative alert.
+ // FIXME -- Generate an administrative alert.
- // We don't know what privilege to remove, so we'll
- // remove all of them.
- newPrivileges.clear();
- return newPrivileges;
- }
- else
- {
- removePrivileges.add(p);
- }
+ // We don't know what privilege to remove, so we'll remove all of them.
+ newPrivileges.clear();
+ return newPrivileges;
}
else
{
- Privilege p = Privilege.privilegeForName(privName);
- if (p == null)
- {
- // FIXME -- Generate an administrative alert.
- }
- else
- {
- newPrivileges.add(p);
- }
+ removePrivileges.add(p);
+ }
+ }
+ else
+ {
+ Privilege p = Privilege.privilegeForName(privName);
+ if (p == null)
+ {
+ // FIXME -- Generate an administrative alert.
+ }
+ else
+ {
+ newPrivileges.add(p);
}
}
}
--
Gitblit v1.10.0