1 17 package org.apache.servicemix.jbi.security; 18 19 import java.security.Principal ; 20 21 22 25 public class UserPrincipal implements Principal { 26 27 private final String name; 28 private transient int hash; 29 30 public UserPrincipal(String name) { 31 if (name == null) throw new IllegalArgumentException ("name cannot be null"); 32 this.name = name; 33 } 34 35 public String getName() { 36 return name; 37 } 38 39 public boolean equals(Object o) { 40 if (this == o) return true; 41 if (o == null || getClass() != o.getClass()) return false; 42 43 final UserPrincipal that = (UserPrincipal) o; 44 45 if (!name.equals(that.name)) return false; 46 47 return true; 48 } 49 50 public int hashCode() { 51 if (hash == 0) { 52 hash = name.hashCode(); 53 } 54 return hash; 55 } 56 57 public String toString() { 58 return name; 59 } 60 } 61 | Popular Tags |