1 7 8 package com.sun.security.auth; 9 10 import java.security.Principal ; 11 12 27 public class UnixNumericUserPrincipal implements 28 Principal , 29 java.io.Serializable { 30 private static final long serialVersionUID = -4329764253802397821L; 31 32 35 private String name; 36 37 49 public UnixNumericUserPrincipal(String name) { 50 if (name == null) { 51 java.text.MessageFormat form = new java.text.MessageFormat 52 (sun.security.util.ResourcesMgr.getString 53 ("invalid null input: value", 54 "sun.security.util.AuthResources")); 55 Object [] source = {"name"}; 56 throw new NullPointerException (form.format(source)); 57 } 58 59 this.name = name; 60 } 61 62 71 public UnixNumericUserPrincipal(long name) { 72 this.name = (new Long (name)).toString(); 73 } 74 75 84 public String getName() { 85 return name; 86 } 87 88 97 public long longValue() { 98 return ((new Long (name)).longValue()); 99 } 100 101 110 public String toString() { 111 java.text.MessageFormat form = new java.text.MessageFormat 112 (sun.security.util.ResourcesMgr.getString 113 ("UnixNumericUserPrincipal: name", 114 "sun.security.util.AuthResources")); 115 Object [] source = {name}; 116 return form.format(source); 117 } 118 119 135 public boolean equals(Object o) { 136 if (o == null) 137 return false; 138 139 if (this == o) 140 return true; 141 142 if (!(o instanceof UnixNumericUserPrincipal)) 143 return false; 144 UnixNumericUserPrincipal that = (UnixNumericUserPrincipal)o; 145 146 if (this.getName().equals(that.getName())) 147 return true; 148 return false; 149 } 150 151 158 public int hashCode() { 159 return name.hashCode(); 160 } 161 } 162 | Popular Tags |