1 23 24 package com.sun.enterprise.resource; 25 26 import java.security.Principal ; 27 import javax.resource.spi.ConnectionRequestInfo ; 28 import com.sun.enterprise.deployment.ResourcePrincipal; 29 30 36 public class ClientSecurityInfo { 37 38 private ResourcePrincipal prin; 40 private ConnectionRequestInfo info; 41 42 static private final int NULL_HASH_CODE = new Integer (1).hashCode(); 43 44 public ClientSecurityInfo(ResourcePrincipal prin) { 45 if (prin == null) { 46 throw new NullPointerException ("Principal is null"); 47 } 48 this.prin = prin; 49 this.info = null; 50 } 51 52 public ClientSecurityInfo(ConnectionRequestInfo info) { 53 this.prin = null; 55 this.info = info; 56 } 57 58 59 public ResourcePrincipal getPrincipal() { 60 return prin; 61 } 62 63 public ConnectionRequestInfo getConnectionRequestInfo() { 64 return info; 65 } 66 67 public boolean equals(Object obj) { 68 if (this == obj) return true; 69 if (obj == null) return false; 70 if (obj instanceof ClientSecurityInfo) { 71 ClientSecurityInfo other = (ClientSecurityInfo) obj; 72 return ((isEqual(prin, other.prin)) && 73 (isEqual(info, other.info))); 74 } 75 return false; 76 } 77 78 public int hashCode() { 79 int result = NULL_HASH_CODE; 80 if (prin != null) { 81 result = prin.hashCode(); 82 } 83 if (info != null) { 84 result += info.hashCode(); 85 } 86 return result; 87 } 88 89 private boolean isEqual(Object a, Object b) { 90 if (a == null) { 91 return (b == null); 92 } else { 93 return (a.equals(b)); 94 } 95 } 96 97 public String toString() { 98 return "ClientSecurityInfo: prin=" + prin + " info="+info; 99 } 100 } 101 | Popular Tags |