1 7 8 package com.sun.security.auth; 9 10 import java.security.Principal ; 11 12 27 public class UnixNumericGroupPrincipal implements 28 Principal , 29 java.io.Serializable { 30 31 private static final long serialVersionUID = 3941535899328403223L; 32 33 36 private String name; 37 38 41 private boolean primaryGroup; 42 43 59 public UnixNumericGroupPrincipal(String name, boolean primaryGroup) { 60 if (name == null) { 61 java.text.MessageFormat form = new java.text.MessageFormat 62 (sun.security.util.ResourcesMgr.getString 63 ("invalid null input: value", 64 "sun.security.util.AuthResources")); 65 Object [] source = {"name"}; 66 throw new NullPointerException (form.format(source)); 67 } 68 69 this.name = name; 70 this.primaryGroup = primaryGroup; 71 } 72 73 86 public UnixNumericGroupPrincipal(long name, boolean primaryGroup) { 87 this.name = (new Long (name)).toString(); 88 this.primaryGroup = primaryGroup; 89 } 90 91 100 public String getName() { 101 return name; 102 } 103 104 113 public long longValue() { 114 return ((new Long (name)).longValue()); 115 } 116 117 127 public boolean isPrimaryGroup() { 128 return primaryGroup; 129 } 130 131 140 public String toString() { 141 142 if (primaryGroup) { 143 java.text.MessageFormat form = new java.text.MessageFormat 144 (sun.security.util.ResourcesMgr.getString 145 ("UnixNumericGroupPrincipal [Primary Group]: name", 146 "sun.security.util.AuthResources")); 147 Object [] source = {name}; 148 return form.format(source); 149 } else { 150 java.text.MessageFormat form = new java.text.MessageFormat 151 (sun.security.util.ResourcesMgr.getString 152 ("UnixNumericGroupPrincipal [Supplementary Group]: name", 153 "sun.security.util.AuthResources")); 154 Object [] source = {name}; 155 return form.format(source); 156 } 157 } 158 159 175 public boolean equals(Object o) { 176 if (o == null) 177 return false; 178 179 if (this == o) 180 return true; 181 182 if (!(o instanceof UnixNumericGroupPrincipal)) 183 return false; 184 UnixNumericGroupPrincipal that = (UnixNumericGroupPrincipal)o; 185 186 if (this.getName().equals(that.getName()) && 187 this.isPrimaryGroup() == that.isPrimaryGroup()) 188 return true; 189 return false; 190 } 191 192 199 public int hashCode() { 200 return toString().hashCode(); 201 } 202 } 203 | Popular Tags |