1 module hunt.security.x509.UniqueIdentity; 2 3 import hunt.security.util.DerValue; 4 import hunt.security.util.DerInputStream; 5 import hunt.security.util.DerOutputStream; 6 7 import hunt.Exceptions; 8 import std.bitmanip; 9 10 11 /** 12 * This class defines the UniqueIdentity class used by certificates. 13 * 14 * @author Amit Kapoor 15 * @author Hemma Prafullchandra 16 */ 17 class UniqueIdentity { 18 // Private data members 19 private BitArray id; 20 21 /** 22 * The default constructor for this class. 23 * 24 * @param id the byte array containing the unique identifier. 25 */ 26 this(BitArray id) { 27 this.id = id; 28 } 29 30 /** 31 * The default constructor for this class. 32 * 33 * @param id the byte array containing the unique identifier. 34 */ 35 this(byte[] id) { 36 // this.id = new BitArray(id.length*8, id); 37 implementationMissing(); 38 } 39 40 /** 41 * Create the object, decoding the values from the passed DER stream. 42 * 43 * @param stream the DerInputStream to read the UniqueIdentity from. 44 * @exception IOException on decoding errors. 45 */ 46 this(DerInputStream stream) { 47 DerValue derVal = stream.getDerValue(); 48 id = derVal.getUnalignedBitString(true); 49 } 50 51 /** 52 * Create the object, decoding the values from the passed DER stream. 53 * 54 * @param derVal the DerValue decoded from the stream. 55 * @param tag the tag the value is encoded under. 56 * @exception IOException on decoding errors. 57 */ 58 this(DerValue derVal) { 59 id = derVal.getUnalignedBitString(true); 60 } 61 62 /** 63 * Return the UniqueIdentity as a printable string. 64 */ 65 override string toString() { 66 // return ("UniqueIdentity:" ~ id.toString() ~ "\n"); 67 implementationMissing(); 68 return ""; 69 } 70 71 /** 72 * Encode the UniqueIdentity in DER form to the stream. 73 * 74 * @param stream the DerOutputStream to marshal the contents to. 75 * @param tag enocode it under the following tag. 76 * @exception IOException on errors. 77 */ 78 void encode(DerOutputStream stream, byte tag) { 79 // byte[] bytes = id.toByteArray(); 80 // int excessBits = bytes.length*8 - id.length(); 81 82 // stream.write(tag); 83 // stream.putLength(bytes.length + 1); 84 85 // stream.write(excessBits); 86 // stream.write(bytes); 87 implementationMissing(); 88 } 89 90 /** 91 * Return the unique id. 92 */ 93 bool[] getId() { 94 // if (id == BitArray.init) return null; 95 96 // return id.toBooleanArray(); 97 implementationMissing(); 98 return []; 99 } 100 }