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