1 7 8 package com.sun.security.auth; 9 10 import java.security.Principal ; 11 import javax.naming.InvalidNameException ; 12 import javax.naming.ldap.LdapName ; 13 14 30 public final class LdapPrincipal implements Principal , java.io.Serializable { 31 32 private static final long serialVersionUID = 6820120005580754861L; 33 34 39 private final String nameString; 40 41 46 private final LdapName name; 47 48 56 public LdapPrincipal(String name) throws InvalidNameException { 57 if (name == null) { 58 throw new NullPointerException ("null name is illegal"); 59 } 60 this.name = getLdapName(name); 61 nameString = name; 62 } 63 64 70 public boolean equals(Object object) { 71 if (this == object) { 72 return true; 73 } 74 if (object instanceof LdapPrincipal) { 75 try { 76 77 return 78 name.equals(getLdapName(((LdapPrincipal)object).getName())); 79 80 } catch (InvalidNameException e) { 81 return false; 82 } 83 } 84 return false; 85 } 86 87 92 public int hashCode() { 93 return name.hashCode(); 94 } 95 96 101 public String getName() { 102 return nameString; 103 } 104 105 112 public String toString() { 113 return name.toString(); 114 } 115 116 private LdapName getLdapName(String name) throws InvalidNameException { 118 return new LdapName (name); 119 } 120 } 121 | Popular Tags |