- java.lang.Object
-
- com.aoindustries.aoserv.client.account.User.Name
-
- com.aoindustries.aoserv.client.linux.User.Name
-
- All Implemented Interfaces:
DtoFactory<UserName>,FastExternalizable,Internable<User.Name>,Externalizable,Serializable,Comparable<User.Name>
- Enclosing class:
- User
public static class User.Name extends User.Name implements FastExternalizable
Represents a Linux username.Usernames must:- Be non-null
- Be non-empty
- Be between 1 and 32 characters
- Must start with
[a-z] - Uses only ASCII 0x21 through 0x7f, excluding
space , : ( ) [ ] ' " | & ; A-Z \ / - If contains any @ symbol, must also be a valid email address. Please note that the reverse is not implied - email addresses may exist that are not valid user names.
- May not start with cyrus@
- TODO: May only end on "$"?
- TODO: "+" is allowed, "lost+found" should be specifically disallowed due to /home/lost+found on mount points.
- Must be a valid
User.Name- this is implied by the above rules
- Author:
- AO Industries, Inc.
- See Also:
Email.validate(java.lang.String), Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intLINUX_NAME_MAX_LENGTHThe maximum length of a Linux username.-
Fields inherited from class com.aoindustries.aoserv.client.account.User.Name
MAX_LENGTH, name
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LinuxUserNamegetDto()longgetSerialVersionUID()User.Nameintern()Interns this name much in the same fashion asString.intern().protected voidvalidate()static ValidationResultvalidate(String name)Validates aUsername.static User.NamevalueOf(String name)-
Methods inherited from class com.aoindustries.aoserv.client.account.User.Name
compareTo, equals, hashCode, readExternal, toString, writeExternal
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
-
-
-
-
Field Detail
-
LINUX_NAME_MAX_LENGTH
public static final int LINUX_NAME_MAX_LENGTH
The maximum length of a Linux username.Implementation Note:
32 characters- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Name
protected Name(String name, boolean validate) throws ValidationException
- Throws:
ValidationException
-
Name
protected Name(String name)
- Parameters:
name- Does not validate, should only be used with a known valid value.
-
Name
public Name()
-
-
Method Detail
-
validate
public static ValidationResult validate(String name)
Validates aUsername.
-
valueOf
public static User.Name valueOf(String name) throws ValidationException
- Parameters:
name- whennull, returnsnull- Throws:
ValidationException
-
validate
protected void validate() throws ValidationException- Overrides:
validatein classUser.Name- Throws:
ValidationException
-
intern
public User.Name intern()
Description copied from class:User.NameInterns this name much in the same fashion asString.intern().Because this has subtypes, two
User.Namethat areUser.Name.equals(java.lang.Object)may not necessarily return the same instance object after interning. Thus, unless you know objects are of the same class,User.Name.equals(java.lang.Object)should still be used for equality check instead of theobj1 == obj2shortcut.To more efficiently check post-interned equivalence, one could also do
obj1 == obj2 || (obj1.getClass() != obj2.getClass() && obj1.equals(obj2)), but is it worth it?And then if we abuse the fact that interned user ids have an interned name, one could check equivalence of post-interned user ids as
obj1.getId() == obj2.getId(), but once again, is it worth it? Just callUser.Name.equals(java.lang.Object).- Specified by:
internin interfaceInternable<User.Name>- Overrides:
internin classUser.Name- See Also:
String.intern()
-
getDto
public LinuxUserName getDto()
- Specified by:
getDtoin interfaceDtoFactory<UserName>- Overrides:
getDtoin classUser.Name
-
getSerialVersionUID
public long getSerialVersionUID()
- Specified by:
getSerialVersionUIDin interfaceFastExternalizable- Overrides:
getSerialVersionUIDin classUser.Name
-
-