You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2009/10/07 10:05:04 UTC

svn commit: r822618 - in /directory/studio/trunk/valueeditors: ./ resources/icons/ src/main/java/org/apache/directory/studio/valueeditors/msad/ src/main/java/org/apache/directory/studio/valueeditors/uuid/ src/test/java/org/ src/test/java/org/apache/ sr...

Author: seelmann
Date: Wed Oct  7 08:05:04 2009
New Revision: 822618

URL: http://svn.apache.org/viewvc?rev=822618&view=rev
Log:
DIRSTUDIO-434 (Add value editor for Active Directory objectGUID and objectSid attributes)
DIRSTUDIO-556 (Add value editor for UUID)
o Added value editor for objectGUID
o Added value editor for objectSID
o Fixed value editor for entryUUID, added a converter method from binary to string
o Added icons
o Added JUnit test dependency and some tests

Added:
    directory/studio/trunk/valueeditors/resources/icons/entryuuideditor.gif   (with props)
    directory/studio/trunk/valueeditors/resources/icons/msadobjectguideditor.gif   (with props)
    directory/studio/trunk/valueeditors/resources/icons/msadobjectsideditor.gif   (with props)
    directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/
    directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditor.java
    directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditor.java
    directory/studio/trunk/valueeditors/src/test/java/org/
    directory/studio/trunk/valueeditors/src/test/java/org/apache/
    directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/
    directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/
    directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/
    directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/
    directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditorTest.java
    directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditorTest.java
    directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/uuid/
    directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditorTest.java
Modified:
    directory/studio/trunk/valueeditors/plugin.properties
    directory/studio/trunk/valueeditors/plugin.xml
    directory/studio/trunk/valueeditors/plugin_de.properties
    directory/studio/trunk/valueeditors/plugin_fr.properties
    directory/studio/trunk/valueeditors/pom.xml
    directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java

Modified: directory/studio/trunk/valueeditors/plugin.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/plugin.properties?rev=822618&r1=822617&r2=822618&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/plugin.properties (original)
+++ directory/studio/trunk/valueeditors/plugin.properties Wed Oct  7 08:05:04 2009
@@ -37,4 +37,8 @@
 
 ValueEditor_InPlaceEntryUUIDValueEditor_name=Entry UUID Editor
 
+ValueEditor_InPlaceMsAdObjectGuidValueEditor_name=MS AD GUID Editor
+
+ValueEditor_InPlaceMsAdObjectSidValueEditor_name=MS AD SID Editor
+
 ValueEditor_CertificateValueEditor_name=Certificate Editor
\ No newline at end of file

Modified: directory/studio/trunk/valueeditors/plugin.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/plugin.xml?rev=822618&r1=822617&r2=822618&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/plugin.xml (original)
+++ directory/studio/trunk/valueeditors/plugin.xml Wed Oct  7 08:05:04 2009
@@ -82,13 +82,25 @@
     </valueEditor>
     <valueEditor
           class="org.apache.directory.studio.valueeditors.uuid.InPlaceUuidValueEditor"
-          icon="resources/icons/passwordeditor.gif"
+          icon="resources/icons/entryuuideditor.gif"
           name="%ValueEditor_InPlaceEntryUUIDValueEditor_name">
        <syntax
              syntaxOID="1.3.6.1.1.16.1">
        </syntax>
     </valueEditor>
     <valueEditor
+          class="org.apache.directory.studio.valueeditors.msad.InPlaceMsAdObjectGuidValueEditor"
+          icon="resources/icons/msadobjectguideditor.gif"
+          name="%ValueEditor_InPlaceMsAdObjectGuidValueEditor_name">
+      <attribute attributeType="objectGUID"/>
+    </valueEditor>
+    <valueEditor
+          class="org.apache.directory.studio.valueeditors.msad.InPlaceMsAdObjectSidValueEditor"
+          icon="resources/icons/msadobjectsideditor.gif"
+          name="%ValueEditor_InPlaceMsAdObjectSidValueEditor_name">
+      <attribute attributeType="objectSid"/>
+    </valueEditor>
+    <valueEditor
           class="org.apache.directory.studio.valueeditors.certificate.CertificateValueEditor"
           icon="resources/icons/certificateeditor.png"
           name="%ValueEditor_CertificateValueEditor_name">

Modified: directory/studio/trunk/valueeditors/plugin_de.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/plugin_de.properties?rev=822618&r1=822617&r2=822618&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/plugin_de.properties (original)
+++ directory/studio/trunk/valueeditors/plugin_de.properties Wed Oct  7 08:05:04 2009
@@ -29,4 +29,8 @@
 
 ValueEditor_InPlaceEntryUUIDValueEditor_name=Entry UUID Editor
 
+ValueEditor_InPlaceMsAdObjectGuidValueEditor_name=MS AD GUID Editor
+
+ValueEditor_InPlaceMsAdObjectSidValueEditor_name=MS AD SID Editor
+
 ValueEditor_CertificateValueEditor_name=Zertifikats-Editor
\ No newline at end of file

Modified: directory/studio/trunk/valueeditors/plugin_fr.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/plugin_fr.properties?rev=822618&r1=822617&r2=822618&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/plugin_fr.properties (original)
+++ directory/studio/trunk/valueeditors/plugin_fr.properties Wed Oct  7 08:05:04 2009
@@ -25,4 +25,6 @@
 ValueEditor_AdministrativeRoleValueEditor_name=Editeur de r\u00F4le d'administration
 ValueEditor_InPlaceOidValueEditor_name=Editeur d'OID
 ValueEditor_InPlaceEntryUUIDValueEditor_name=Editeur d'EntryUUID
+ValueEditor_InPlaceMsAdObjectGuidValueEditor_name=TODO:MS AD GUID Editor
+ValueEditor_InPlaceMsAdObjectSidValueEditor_name=TODO:MS AD SID Editor
 ValueEditor_CertificateValueEditor_name=Editeur de certificat
\ No newline at end of file

Modified: directory/studio/trunk/valueeditors/pom.xml
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/pom.xml?rev=822618&r1=822617&r2=822618&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/pom.xml (original)
+++ directory/studio/trunk/valueeditors/pom.xml Wed Oct  7 08:05:04 2009
@@ -227,6 +227,13 @@
       <artifactId>commands</artifactId>
       <scope>provided</scope>
     </dependency>
+    
+    <!-- JUnit for test only -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>
\ No newline at end of file

Added: directory/studio/trunk/valueeditors/resources/icons/entryuuideditor.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/resources/icons/entryuuideditor.gif?rev=822618&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/valueeditors/resources/icons/entryuuideditor.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/studio/trunk/valueeditors/resources/icons/msadobjectguideditor.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/resources/icons/msadobjectguideditor.gif?rev=822618&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/valueeditors/resources/icons/msadobjectguideditor.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/studio/trunk/valueeditors/resources/icons/msadobjectsideditor.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/resources/icons/msadobjectsideditor.gif?rev=822618&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/valueeditors/resources/icons/msadobjectsideditor.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditor.java?rev=822618&view=auto
==============================================================================
--- directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditor.java (added)
+++ directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditor.java Wed Oct  7 08:05:04 2009
@@ -0,0 +1,96 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.valueeditors.msad;
+
+
+import org.apache.commons.codec.binary.Hex;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.valueeditors.HexValueEditor;
+
+
+/**
+ * Implementation of IValueEditor for Microsoft Active Directory attribute 'objectGUID'.
+ * 
+ * Currently only the getDisplayValue() method is implemented.
+ * For modification the raw string must be edited.
+ * 
+ * There are two special characteristics compared to the default UUID editor:
+ * <ul>
+ * <li>The first 64 bit of the MS AD GUID are little-endian, so we must reorder the bytes.
+ *     See <a href="http://msdn.microsoft.com/en-us/library/dd302644(PROT.10).aspx">
+ *     http://msdn.microsoft.com/en-us/library/dd302644(PROT.10).aspx</a> or
+ *     <a href="http://en.wikipedia.org/wiki/Globally_Unique_Identifier">
+ *     http://en.wikipedia.org/wiki/Globally_Unique_Identifier</a>.
+ * <li>The Curly Braced GUID String Syntax is used.
+ *     See <a href="http://msdn.microsoft.com/en-us/library/cc230316(PROT.10).aspx">
+ *     http://msdn.microsoft.com/en-us/library/cc230316(PROT.10).aspx</a>.
+ * </ul>
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InPlaceMsAdObjectGuidValueEditor extends HexValueEditor
+{
+    public String getDisplayValue( IValue value )
+    {
+        if ( !showRawValues() )
+        {
+            Object rawValue = super.getRawValue( value );
+            if ( rawValue instanceof byte[] )
+            {
+                byte[] bytes = ( byte[] ) rawValue;
+                return convertToString( bytes );
+            }
+        }
+
+        return super.getDisplayValue( value );
+    }
+
+
+    String convertToString( byte[] bytes )
+    {
+        if ( bytes == null || bytes.length != 16 )
+        {
+            return "Invalid GUID";
+        }
+
+        char[] hex = Hex.encodeHex( bytes );
+        StringBuffer sb = new StringBuffer();
+        sb.append( '{' );
+        sb.append( hex, 6, 2 );
+        sb.append( hex, 4, 2 );
+        sb.append( hex, 2, 2 );
+        sb.append( hex, 0, 2 );
+        sb.append( '-' );
+        sb.append( hex, 10, 2 );
+        sb.append( hex, 8, 2 );
+        sb.append( '-' );
+        sb.append( hex, 14, 2 );
+        sb.append( hex, 12, 2 );
+        sb.append( '-' );
+        sb.append( hex, 16, 4 );
+        sb.append( '-' );
+        sb.append( hex, 20, 12 );
+        sb.append( '}' );
+        return sb.toString().toLowerCase();
+    }
+
+}

Added: directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditor.java?rev=822618&view=auto
==============================================================================
--- directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditor.java (added)
+++ directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditor.java Wed Oct  7 08:05:04 2009
@@ -0,0 +1,124 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.valueeditors.msad;
+
+
+import org.apache.commons.codec.binary.Hex;
+import org.apache.directory.studio.ldapbrowser.core.model.IValue;
+import org.apache.directory.studio.valueeditors.HexValueEditor;
+
+
+/**
+ * Implementation of IValueEditor for Microsoft Active Directory attribute 'objectSid'.
+ * 
+ * Currently only the getDisplayValue() method is implemented.
+ * For modification the raw string must be edited.
+ * 
+ * See <a href="http://msdn.microsoft.com/en-us/library/cc230371(PROT.10).aspx">
+ * http://msdn.microsoft.com/en-us/library/cc230371(PROT.10).aspx</a> for details.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InPlaceMsAdObjectSidValueEditor extends HexValueEditor
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getDisplayValue( IValue value )
+    {
+        if ( !showRawValues() )
+        {
+            Object rawValue = super.getRawValue( value );
+            if ( rawValue instanceof byte[] )
+            {
+                byte[] bytes = ( byte[] ) rawValue;
+                return convertToString( bytes );
+            }
+        }
+
+        return super.getDisplayValue( value );
+    }
+
+
+    protected String convertToString( byte[] bytes )
+    {
+        /*
+         * The binary data structure, from http://msdn.microsoft.com/en-us/library/cc230371(PROT.10).aspx:
+         *   byte[0] - Revision (1 byte): An 8-bit unsigned integer that specifies the revision level of the SID structure. This value MUST be set to 0x01.
+         *   byte[1] - SubAuthorityCount (1 byte): An 8-bit unsigned integer that specifies the number of elements in the SubAuthority array. The maximum number of elements allowed is 15.
+         *   byte[2-7] - IdentifierAuthority (6 bytes): A SID_IDENTIFIER_AUTHORITY structure that contains information, which indicates the authority under which the SID was created. It describes the entity that created the SID and manages the account.
+         *               Six element arrays of 8-bit unsigned integers that specify the top-level authority 
+         *               big-endian!
+         *   and then - SubAuthority (variable): A variable length array of unsigned 32-bit integers that uniquely identifies a principal relative to the IdentifierAuthority. Its length is determined by SubAuthorityCount. 
+         *              little-endian!
+         */
+
+        if ( bytes == null || bytes.length < 8 )
+        {
+            return "Invalid SID";
+        }
+
+        char[] hex = Hex.encodeHex( bytes );
+        StringBuffer sb = new StringBuffer();
+
+        // start with 'S'
+        sb.append( 'S' );
+
+        // revision
+        int revision = Integer.parseInt( new String( hex, 0, 2 ), 16 );
+        sb.append( '-' );
+        sb.append( revision );
+
+        // get count
+        int count = Integer.parseInt( new String( hex, 2, 2 ), 16 );
+
+        // check length
+        if ( bytes.length != ( 8 + count * 4 ) )
+        {
+            return "Invalid SID";
+        }
+
+        // get authority, big-endian
+        long authority = Long.parseLong( new String( hex, 4, 12 ), 16 );
+        sb.append( '-' );
+        sb.append( authority );
+
+        // sub-authorities, little-endian
+        for ( int i = 0; i < count; i++ )
+        {
+            StringBuffer rid = new StringBuffer();
+            for ( int k = 3; k >= 0; k-- )
+            {
+                rid.append( hex[16 + ( i * 8 ) + ( k * 2 )] );
+                rid.append( hex[16 + ( i * 8 ) + ( k * 2 ) + 1] );
+            }
+
+            long subAuthority = Long.parseLong( rid.toString(), 16 );
+            sb.append( '-' );
+            sb.append( subAuthority );
+        }
+
+        return sb.toString();
+    }
+
+}

Modified: directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java?rev=822618&r1=822617&r2=822618&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java (original)
+++ directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditor.java Wed Oct  7 08:05:04 2009
@@ -21,18 +21,16 @@
 package org.apache.directory.studio.valueeditors.uuid;
 
 
-import java.util.UUID;
-
+import org.apache.commons.codec.binary.Hex;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
 import org.apache.directory.studio.valueeditors.HexValueEditor;
 
 
 /**
- * Implementation of IValueEditor for attribute 'entryUUID' with syntax 1.3.6.1.1.16.1.
- * 
+ * Implementation of IValueEditor for syntax 1.3.6.1.1.16.1 (UUID), e.g. used by entryUUID.
  * 
- * Currently only the getDisplayXXX() methods are implemented.
+ * Currently only the getDisplayValue() method is implemented.
  * For modification the raw string must be edited.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -61,7 +59,7 @@
                 }
                 else
                 {
-                    return UUID.nameUUIDFromBytes( bytes ).toString();
+                    return convertToString( bytes );
                 }
             }
         }
@@ -69,4 +67,25 @@
         return super.getDisplayValue( value );
     }
 
+
+    String convertToString( byte[] bytes )
+    {
+        if ( bytes == null || bytes.length != 16 )
+        {
+            return "Invalid UUID";
+        }
+
+        char[] hex = Hex.encodeHex( bytes );
+        StringBuffer sb = new StringBuffer();
+        sb.append( hex, 0, 8 );
+        sb.append( '-' );
+        sb.append( hex, 8, 4 );
+        sb.append( '-' );
+        sb.append( hex, 12, 4 );
+        sb.append( '-' );
+        sb.append( hex, 16, 4 );
+        sb.append( '-' );
+        sb.append( hex, 20, 12 );
+        return sb.toString().toLowerCase();
+    }
 }

Added: directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditorTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditorTest.java?rev=822618&view=auto
==============================================================================
--- directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditorTest.java (added)
+++ directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectGuidValueEditorTest.java Wed Oct  7 08:05:04 2009
@@ -0,0 +1,96 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.valueeditors.msad;
+
+
+import static junit.framework.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+public class InPlaceMsAdObjectGuidValueEditorTest
+{
+
+    @Test
+    public void testConvertToString1()
+    {
+        InPlaceMsAdObjectGuidValueEditor editor = new InPlaceMsAdObjectGuidValueEditor();
+        byte[] bytes = new byte[]
+            {
+            //
+                ( byte ) 0x89, ( byte ) 0xBA, ( byte ) 0x78, ( byte ) 0xDB, //
+                ( byte ) 0x5F, ( byte ) 0xB8, //
+                ( byte ) 0x7F, ( byte ) 0x44, //
+                ( byte ) 0xBD, ( byte ) 0x06, //
+                ( byte ) 0xE3, ( byte ) 0xA4, ( byte ) 0x09, ( byte ) 0x96, ( byte ) 0xA9, ( byte ) 0xA8 };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "{db78ba89-b85f-447f-bd06-e3a40996a9a8}".toLowerCase(), displayValue );
+    }
+
+
+    @Test
+    public void testConvertToString2()
+    {
+        InPlaceMsAdObjectGuidValueEditor editor = new InPlaceMsAdObjectGuidValueEditor();
+        byte[] bytes = new byte[]
+            {
+            //
+                ( byte ) 0x00, ( byte ) 0x11, ( byte ) 0x22, ( byte ) 0x33, //
+                ( byte ) 0x44, ( byte ) 0x55, //
+                ( byte ) 0x66, ( byte ) 0x77, //
+                ( byte ) 0x88, ( byte ) 0x99, //
+                ( byte ) 0xAA, ( byte ) 0xBB, ( byte ) 0xCC, ( byte ) 0xDD, ( byte ) 0xEE, ( byte ) 0xFF };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "{33221100-5544-7766-8899-AABBCCDDEEFF}".toLowerCase(), displayValue );
+    }
+
+
+    @Test
+    public void testConvertToStringInvalid()
+    {
+        InPlaceMsAdObjectGuidValueEditor editor = new InPlaceMsAdObjectGuidValueEditor();
+
+        // test too short
+        byte[] bytes = new byte[]
+            { ( byte ) 0x00, ( byte ) 0x11, ( byte ) 0x22, ( byte ) 0x33 };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "Invalid GUID", displayValue );
+
+        // test too long
+        byte[] bytes2 = new byte[]
+            { ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
+                ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
+                ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
+                ( byte ) 0x00, };
+        String displayValue2 = editor.convertToString( bytes2 );
+        assertEquals( "Invalid GUID", displayValue2 );
+    }
+
+
+    @Test
+    public void testConvertToStringNull()
+    {
+        InPlaceMsAdObjectGuidValueEditor editor = new InPlaceMsAdObjectGuidValueEditor();
+        byte[] bytes = null;
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "Invalid GUID", displayValue );
+    }
+}

Added: directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditorTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditorTest.java?rev=822618&view=auto
==============================================================================
--- directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditorTest.java (added)
+++ directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/msad/InPlaceMsAdObjectSidValueEditorTest.java Wed Oct  7 08:05:04 2009
@@ -0,0 +1,144 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.valueeditors.msad;
+
+
+import static junit.framework.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+public class InPlaceMsAdObjectSidValueEditorTest
+{
+
+    @Test
+    public void testConvertToString1()
+    {
+        InPlaceMsAdObjectSidValueEditor editor = new InPlaceMsAdObjectSidValueEditor();
+        byte[] bytes = new byte[]
+            {
+            // 01 01 00 00 00 00 00 05  04 00 00 00 
+                ( byte ) 0x01, //
+                ( byte ) 0x01, //
+                ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x05, //
+                ( byte ) 0x04, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00 //
+            };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "S-1-5-4", displayValue );
+    }
+
+
+    @Test
+    public void testConvertToString2()
+    {
+        InPlaceMsAdObjectSidValueEditor editor = new InPlaceMsAdObjectSidValueEditor();
+        byte[] bytes = new byte[]
+            {
+            // 01 02 00 00 00 00 00 05  20 00 00 00 25 02 00 00
+                ( byte ) 0x01, //
+                ( byte ) 0x02, //
+                ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x05, //
+                ( byte ) 0x20, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, //
+                ( byte ) 0x25, ( byte ) 0x02, ( byte ) 0x00, ( byte ) 0x00 //
+            };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "S-1-5-32-549", displayValue );
+    }
+
+
+    @Test
+    public void testConvertToString3()
+    {
+        InPlaceMsAdObjectSidValueEditor editor = new InPlaceMsAdObjectSidValueEditor();
+        byte[] bytes = new byte[]
+            {
+            // 01 05 00 00 00 00 00 05  15 00 00 00 af 6e b6 27
+                // 0c f5 77 a0 a7 10 df 6e  f4 01 00 00
+                ( byte ) 0x01, //
+                ( byte ) 0x05, //
+                ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x05, //
+                ( byte ) 0x15, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, //
+                ( byte ) 0xaf, ( byte ) 0x6e, ( byte ) 0xb6, ( byte ) 0x27, //
+                ( byte ) 0x0c, ( byte ) 0xf5, ( byte ) 0x77, ( byte ) 0xa0, //
+                ( byte ) 0xa7, ( byte ) 0x10, ( byte ) 0xdf, ( byte ) 0x6e, //
+                ( byte ) 0xf4, ( byte ) 0x01, ( byte ) 0x00, ( byte ) 0x00 //
+            };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "S-1-5-21-666267311-2692216076-1860112551-500", displayValue );
+    }
+
+
+    @Test
+    public void testConvertToStringInvalid()
+    {
+        InPlaceMsAdObjectSidValueEditor editor = new InPlaceMsAdObjectSidValueEditor();
+
+        // test too short
+        byte[] bytes = new byte[]
+            { ( byte ) 0x00 };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "Invalid SID", displayValue );
+
+        // test missing sub aurhority byte
+        byte[] bytes2 = new byte[]
+            {
+            // 01 05 00 00 00 00 00 05  15 00 00 00 af 6e b6 27
+                // 0c f5 77 a0 a7 10 df 6e  f4 01 00 00
+                ( byte ) 0x01, //
+                ( byte ) 0x05, //
+                ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x05, //
+                ( byte ) 0x15, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, //
+                ( byte ) 0xaf, ( byte ) 0x6e, ( byte ) 0xb6, ( byte ) 0x27, //
+                ( byte ) 0x0c, ( byte ) 0xf5, ( byte ) 0x77, ( byte ) 0xa0, //
+                ( byte ) 0xa7, ( byte ) 0x10, ( byte ) 0xdf, ( byte ) 0x6e, //
+                ( byte ) 0xf4, ( byte ) 0x01, ( byte ) 0x00, /*( byte ) 0x00*///
+            };
+        String displayValue2 = editor.convertToString( bytes2 );
+        assertEquals( "Invalid SID", displayValue2 );
+
+        // test additional sub authority byte
+        byte[] bytes3 = new byte[]
+            {
+            // 01 05 00 00 00 00 00 05  15 00 00 00 af 6e b6 27
+                // 0c f5 77 a0 a7 10 df 6e  f4 01 00 00
+                ( byte ) 0x01, //
+                ( byte ) 0x05, //
+                ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x05, //
+                ( byte ) 0x15, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, //
+                ( byte ) 0xaf, ( byte ) 0x6e, ( byte ) 0xb6, ( byte ) 0x27, //
+                ( byte ) 0x0c, ( byte ) 0xf5, ( byte ) 0x77, ( byte ) 0xa0, //
+                ( byte ) 0xa7, ( byte ) 0x10, ( byte ) 0xdf, ( byte ) 0x6e, //
+                ( byte ) 0xf4, ( byte ) 0x01, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00 //
+            };
+        String displayValue3 = editor.convertToString( bytes3 );
+        assertEquals( "Invalid SID", displayValue3 );
+    }
+
+
+    @Test
+    public void testConvertToStringNull()
+    {
+        InPlaceMsAdObjectSidValueEditor editor = new InPlaceMsAdObjectSidValueEditor();
+        byte[] bytes = null;
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "Invalid SID", displayValue );
+    }
+}

Added: directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditorTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditorTest.java?rev=822618&view=auto
==============================================================================
--- directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditorTest.java (added)
+++ directory/studio/trunk/valueeditors/src/test/java/org/apache/directory/studio/valueeditors/uuid/InPlaceUuidValueEditorTest.java Wed Oct  7 08:05:04 2009
@@ -0,0 +1,97 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+
+package org.apache.directory.studio.valueeditors.uuid;
+
+
+import static junit.framework.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+public class InPlaceUuidValueEditorTest
+{
+
+    @Test
+    public void testConvertToString1()
+    {
+        InPlaceUuidValueEditor editor = new InPlaceUuidValueEditor();
+        byte[] bytes = new byte[]
+            {
+            //
+                ( byte ) 0x6b, ( byte ) 0xa7, ( byte ) 0xb8, ( byte ) 0x10, //
+                ( byte ) 0x9d, ( byte ) 0xad, //
+                ( byte ) 0x11, ( byte ) 0xd1, //
+                ( byte ) 0x80, ( byte ) 0xb4, //
+                ( byte ) 0x00, ( byte ) 0xc0, ( byte ) 0x4f, ( byte ) 0xd4, ( byte ) 0x30, ( byte ) 0xc8 };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "6ba7b810-9dad-11d1-80b4-00c04fd430c8".toLowerCase(), displayValue );
+    }
+
+
+    @Test
+    public void testConvertToString2()
+    {
+        InPlaceUuidValueEditor editor = new InPlaceUuidValueEditor();
+        byte[] bytes = new byte[]
+            {
+            //
+                ( byte ) 0x00, ( byte ) 0x11, ( byte ) 0x22, ( byte ) 0x33, //
+                ( byte ) 0x44, ( byte ) 0x55, //
+                ( byte ) 0x66, ( byte ) 0x77, //
+                ( byte ) 0x88, ( byte ) 0x99, //
+                ( byte ) 0xAA, ( byte ) 0xBB, ( byte ) 0xCC, ( byte ) 0xDD, ( byte ) 0xEE, ( byte ) 0xFF };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "00112233-4455-6677-8899-AABBCCDDEEFF".toLowerCase(), displayValue );
+    }
+
+
+    @Test
+    public void testConvertToStringInvalid()
+    {
+        InPlaceUuidValueEditor editor = new InPlaceUuidValueEditor();
+
+        // test too short
+        byte[] bytes = new byte[]
+            { ( byte ) 0x00, ( byte ) 0x11, ( byte ) 0x22, ( byte ) 0x33 };
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "Invalid UUID", displayValue );
+
+        // test too long
+        byte[] bytes2 = new byte[]
+            { ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
+                ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
+                ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
+                ( byte ) 0x00, };
+        String displayValue2 = editor.convertToString( bytes2 );
+        assertEquals( "Invalid UUID", displayValue2 );
+    }
+
+
+    @Test
+    public void testConvertToStringNull()
+    {
+        InPlaceUuidValueEditor editor = new InPlaceUuidValueEditor();
+        byte[] bytes = null;
+        String displayValue = editor.convertToString( bytes );
+        assertEquals( "Invalid UUID", displayValue );
+    }
+
+}