From eaee3f6a42c1a129f07e2364a4c32c59b9e03e19 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 09 Feb 2016 15:22:22 +0000
Subject: [PATCH] Prep work for OPENDJ-1342: align APIs for RDNs

---
 opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
index e651a33..3d7a6be 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
@@ -285,9 +285,7 @@
   {
     RDN srcRDN = searchEntry.getName().rdn();
 
-    // Only process the entry if it has the expected form of RDN.
-    if (!srcRDN.isMultiValued() &&
-         srcRDN.getAttributeType(0).equals(attrAlias))
+    if (canProcessEntry(srcRDN))
     {
       DN dstDN = trustStoreRootDN.child(srcRDN);
 
@@ -350,6 +348,12 @@
     }
   }
 
+  /** Only process the entry if it has the expected form of RDN. */
+  private boolean canProcessEntry(RDN rdn)
+  {
+    return !rdn.isMultiValued() && rdn.getFirstAVA().getAttributeType().equals(attrAlias);
+  }
+
 
   /**
    * Modify an entry in the local trust store if it differs from an entry in
@@ -461,10 +465,7 @@
   private void handleInstanceKeyAddOperation(Entry entry)
   {
     RDN srcRDN = entry.getName().rdn();
-
-    // Only process the entry if it has the expected form of RDN.
-    if (!srcRDN.isMultiValued() &&
-         srcRDN.getAttributeType(0).equals(attrAlias))
+    if (canProcessEntry(srcRDN))
     {
       DN dstDN = trustStoreRootDN.child(srcRDN);
 
@@ -486,12 +487,10 @@
 
     RDN srcRDN = op.getEntryToDelete().getName().rdn();
 
-    // Only process the entry if it has the expected form of RDN.
     // FIXME: Technically it is possible to perform a subtree in
     // this case however such subtree delete would essentially be
     // removing configuration branches which should not happen.
-    if (!srcRDN.isMultiValued() &&
-         srcRDN.getAttributeType(0).equals(attrAlias))
+    if (canProcessEntry(srcRDN))
     {
       DN destDN = trustStoreRootDN.child(srcRDN);
       deleteEntry(destDN);
@@ -539,9 +538,7 @@
   {
     RDN srcRDN = newEntry.getName().rdn();
 
-    // Only process the entry if it has the expected form of RDN.
-    if (!srcRDN.isMultiValued() &&
-         srcRDN.getAttributeType(0).equals(attrAlias))
+    if (canProcessEntry(srcRDN))
     {
       DN dstDN = trustStoreRootDN.child(srcRDN);
 

--
Gitblit v1.10.0