1 17 18 package org.apache.geronimo.util.jce; 19 20 import java.io.ByteArrayInputStream ; 21 import java.io.ByteArrayOutputStream ; 22 import java.io.IOException ; 23 import java.security.Principal ; 24 import java.util.Hashtable ; 25 import java.util.Vector ; 26 27 import org.apache.geronimo.util.asn1.ASN1InputStream; 28 import org.apache.geronimo.util.asn1.ASN1Sequence; 29 import org.apache.geronimo.util.asn1.DEROutputStream; 30 import org.apache.geronimo.util.asn1.x509.X509Name; 31 32 public class X509Principal 33 extends X509Name 34 implements Principal 35 { 36 39 public X509Principal( 40 byte[] bytes) 41 throws IOException 42 { 43 super((ASN1Sequence)(new ASN1InputStream(new ByteArrayInputStream (bytes)).readObject())); 44 } 45 46 49 public X509Principal( 50 X509Name name) 51 { 52 super((ASN1Sequence)name.getDERObject()); 53 } 54 55 60 public X509Principal( 61 Hashtable attributes) 62 { 63 super(attributes); 64 } 65 66 72 public X509Principal( 73 Vector ordering, 74 Hashtable attributes) 75 { 76 super(ordering, attributes); 77 } 78 79 82 public X509Principal( 83 Vector oids, 84 Vector values) 85 { 86 super(oids, values); 87 } 88 89 93 public X509Principal( 94 String dirName) 95 { 96 super(dirName); 97 } 98 99 106 public X509Principal( 107 boolean reverse, 108 String dirName) 109 { 110 super(reverse, dirName); 111 } 112 113 123 public X509Principal( 124 boolean reverse, 125 Hashtable lookUp, 126 String dirName) 127 { 128 super(reverse, lookUp, dirName); 129 } 130 131 public String getName() 132 { 133 return this.toString(); 134 } 135 136 139 public byte[] getEncoded() 140 { 141 ByteArrayOutputStream bOut = new ByteArrayOutputStream (); 142 DEROutputStream dOut = new DEROutputStream(bOut); 143 144 try 145 { 146 dOut.writeObject(this); 147 } 148 catch (IOException e) 149 { 150 throw new RuntimeException (e.toString()); 151 } 152 153 return bOut.toByteArray(); 154 } 155 } 156 | Popular Tags |