You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by we...@apache.org on 2004/02/08 16:59:08 UTC
svn commit: rev 6596 - incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber
Author: wesmckean
Date: Sun Feb 8 07:59:08 2004
New Revision: 6596
Modified:
incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoder.java
Log:
Added decodeNull and decodeObjectIdentifier.
Modified: incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoder.java
==============================================================================
--- incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoder.java (original)
+++ incubator/directory/snickers/trunk/ber/src/java/org/apache/snickers/ber/BERDecoder.java Sun Feb 8 07:59:08 2004
@@ -117,4 +117,67 @@
return new String( bytes );
}
+
+ /* (non-Javadoc)
+ * @see org.apache.snickers.asn.ASNDecoder#decodeNull(int[])
+ */
+ public void decodeNull(int[] value) {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.snickers.asn.ASNDecoder#decodeObjectIdentifier(int[])
+ */
+ public String decodeObjectIdentifier(int[] value) {
+ StringBuffer sb = new StringBuffer();
+ int length = value.length;
+ int index = 0;
+ int aByte;
+
+ // The first byte is special, so we have to handle it outside our
+ // our loop where we process it below. Special thanks to the folks
+ // at Cryptix, on SourceForge for helping me understand how to do
+ // this.
+
+ if( length > 1 ) {
+ length--;
+
+ // Isolate t first byte
+ aByte = value[index++] & 0xFF;
+ int firstValue = 0;
+
+ if( aByte >= 40 && aByte < 80 ) {
+ firstValue = 1;
+ }
+ else if( aByte >= 80 ) {
+ firstValue = 2;
+ }
+
+ int secondValue = aByte - ( firstValue * 40 );
+ sb.append( firstValue );
+ sb.append( '.' );
+ sb.append( secondValue );
+ }
+
+ // Now process the rest of the OID ints. Each individual
+ // integer is part of the value, and we keep processing it
+ // while the more bit is set.
+ while (length > 0) {
+ sb.append(".");
+ int subId = 0;
+ boolean more;
+
+ do {
+ more = ((value[index] & 0x80) != 0 );
+ aByte = value[index++] & 0x7F;
+ subId = (subId << 7) | aByte;
+ } while (--length > 0 && more );
+
+ sb.append(subId);
+ }
+
+ String result = sb.toString();
+ return (result);
+ }
+
}