Enhanced the test to deal with binary identity attributes.

This commit is contained in:
Juan Carlos Luciani 2006-05-31 15:24:55 +00:00
parent b1966cac5f
commit 228ffd5164

View File

@ -123,7 +123,24 @@ public class SampleApp
while (enumeration.hasMore())
{
System.out.print(" Attribute Name: " + attr.getID());
System.out.println(" :: Attribute Value: " + (String) enumeration.next());
Object attrValue = enumeration.next();
if (attrValue instanceof byte[])
{
// The attribute value is binary data
StringBuffer buf = new StringBuffer();
char[] hex = "0123456789ABCDEF".toCharArray();
for (int i = 0; i < ((byte[]) attrValue).length; i++)
{
buf.append(hex[(((byte[]) attrValue)[i] >> 4) & 0xF]);
buf.append(hex[((byte[]) attrValue)[i] & 0xF]);
}
System.out.println(" :: Attribute Value: " + buf.toString());
}
else
{
// The attribute value is contained in a string
System.out.println(" :: Attribute Value: " + (String) attrValue);
}
}
}
}