1 7 8 package org.jboss.security; 9 10 import java.security.Principal ; 11 12 20 public class SimplePrincipal implements Principal , java.io.Serializable 21 { 22 static final long serialVersionUID = 7701951188631723261L; 23 private String name; 24 25 public SimplePrincipal(String name) 26 { 27 this.name = name; 28 } 29 30 34 public boolean equals(Object another) 35 { 36 if (!(another instanceof Principal )) 37 return false; 38 String anotherName = ((Principal ) another).getName(); 39 boolean equals = false; 40 if (name == null) 41 equals = anotherName == null; 42 else 43 equals = name.equals(anotherName); 44 return equals; 45 } 46 47 public int hashCode() 48 { 49 return (name == null ? 0 : name.hashCode()); 50 } 51 52 public String toString() 53 { 54 return name; 55 } 56 57 public String getName() 58 { 59 return name; 60 } 61 } 62 | Popular Tags |