1 7 8 package com.sun.security.auth; 9 10 import java.security.Principal ; 11 import sun.security.x509.X500Name; 12 13 35 @Deprecated 36 public class X500Principal implements Principal , java.io.Serializable { 37 38 private static final long serialVersionUID = -8222422609431628648L; 39 40 private static final java.util.ResourceBundle rb = 41 (java.util.ResourceBundle )java.security.AccessController.doPrivileged 42 (new java.security.PrivilegedAction () { 43 public Object run() { 44 return (java.util.ResourceBundle.getBundle 45 ("sun.security.util.AuthResources")); 46 } 47 }); 48 49 52 private String name; 53 54 transient private X500Name thisX500Name; 55 56 71 public X500Principal(String name) { 72 if (name == null) 73 throw new NullPointerException (rb.getString("provided null name")); 74 75 try { 76 thisX500Name = new X500Name(name); 77 } catch (Exception e) { 78 throw new IllegalArgumentException (e.toString()); 79 } 80 81 this.name = name; 82 } 83 84 91 public String getName() { 92 return thisX500Name.getName(); 93 } 94 95 102 public String toString() { 103 return thisX500Name.toString(); 104 } 105 106 118 public boolean equals(Object o) { 119 if (o == null) 120 return false; 121 122 if (this == o) 123 return true; 124 125 if (o instanceof X500Principal) { 126 X500Principal that = (X500Principal)o; 127 try { 128 X500Name thatX500Name = new X500Name(that.getName()); 129 return thisX500Name.equals(thatX500Name); 130 } catch (Exception e) { 131 return false; 133 } 134 } else if (o instanceof Principal ) { 135 return o.equals(thisX500Name); 138 } 139 140 return false; 141 } 142 143 150 public int hashCode() { 151 return thisX500Name.hashCode(); 152 } 153 154 157 private void readObject(java.io.ObjectInputStream s) throws 158 java.io.IOException , 159 java.io.NotActiveException , 160 ClassNotFoundException { 161 162 s.defaultReadObject(); 163 164 thisX500Name = new X500Name(name); 166 } 167 } 168 | Popular Tags |