1 23 package com.sun.enterprise.deployment; 24 25 31 public class ResourcePrincipal extends PrincipalImpl { 32 private String password; 33 34 static private final int NULL_HASH_CODE = new Integer (1).hashCode(); 35 36 43 private static final String DEFAULT_USERNAME = "__default__user__name__"; 45 private static final String DEFAULT_PASSWORD = "__default__password__"; 47 48 private boolean defaultPrincipal = false; 49 50 55 public ResourcePrincipal() { 56 super(DEFAULT_USERNAME); 57 this.password = DEFAULT_PASSWORD; 58 defaultPrincipal = true; 59 } 60 61 63 public ResourcePrincipal(String name, String password) { 64 super(name); 65 this.password = password; 66 } 67 68 public String getPassword() { 69 return password; 70 } 71 72 77 public boolean isDefault() { 78 return defaultPrincipal; 79 } 80 82 public boolean equals(Object o) { 83 if (this == o) return true; 84 if (o == null) return false; 85 if (o instanceof ResourcePrincipal) { 86 ResourcePrincipal other = (ResourcePrincipal) o; 87 88 if (isDefault()) { 91 return other.isDefault(); 92 } else if (other.isDefault()) { 93 return false; 94 } 95 97 return ((isEqual(getName(), other.getName())) && 98 (isEqual(this.password, other.password))); 99 } 100 return false; 101 } 102 103 public int hashCode() { 104 int result = NULL_HASH_CODE; 105 String name = getName(); 106 if (name != null) { 107 result += name.hashCode(); 108 } 109 if (password != null) { 110 result += password.hashCode(); 111 } 112 return result; 113 } 114 115 private boolean isEqual(Object a, Object b) { 116 if (a == null) { 117 return (b == null); 118 } else { 119 return (a.equals(b)); 120 } 121 } 122 123 } 124 | Popular Tags |