From 377b2709c64b32fe93905b466482216c2cc0581c Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 19 Mar 2014 16:30:32 +0000
Subject: [PATCH] OPENDJ-1368 (CR-3232) Remove AttributeValue

---
 opendj3-server-dev/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java |   50 ++++++++++++++++++--------------------------------
 1 files changed, 18 insertions(+), 32 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java b/opendj3-server-dev/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java
index 0ba7450..37cf958 100644
--- a/opendj3-server-dev/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/extensions/ExternalSASLMechanismHandler.java
@@ -243,22 +243,8 @@
         {
           try
           {
-            byte[] certBytes = clientCertChain[0].getEncoded();
-            AttributeValue v =
-                AttributeValues.create(
-                    certificateAttributeType, ByteString.wrap(certBytes));
-
-            boolean found = false;
-            for (Attribute a : certAttrList)
-            {
-              if (a.contains(v))
-              {
-                found = true;
-                break;
-              }
-            }
-
-            if (! found)
+            ByteString certBytes = ByteString.wrap(clientCertChain[0].getEncoded());
+            if (!find(certAttrList, certBytes))
             {
               bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS);
 
@@ -286,22 +272,8 @@
         {
           try
           {
-            byte[] certBytes = clientCertChain[0].getEncoded();
-            AttributeValue v =
-                AttributeValues.create(
-                    certificateAttributeType, ByteString.wrap(certBytes));
-
-            boolean found = false;
-            for (Attribute a : certAttrList)
-            {
-              if (a.contains(v))
-              {
-                found = true;
-                break;
-              }
-            }
-
-            if (! found)
+            ByteString certBytes = ByteString.wrap(clientCertChain[0].getEncoded());
+            if (!find(certAttrList, certBytes))
             {
               bindOperation.setResultCode(ResultCode.INVALID_CREDENTIALS);
 
@@ -333,6 +305,20 @@
 
 
 
+  private boolean find(List<Attribute> certAttrList, ByteString certBytes)
+  {
+    for (Attribute a : certAttrList)
+    {
+      if (a.contains(certBytes))
+      {
+        return true;
+      }
+    }
+    return false;
+  }
+
+
+
   /**
    * {@inheritDoc}
    */

--
Gitblit v1.10.0