|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnetbattle.database.registry.AccountRegistry
netbattle.database.registry.FileImpl
public class FileImpl
This is an implementation of the AccountRegistry that uses only flat files.
The impl. works by internally storing the registry data as a HashMap. When
an instance is created, the map is unseralised from a file. When the
close
method is called, the map is seralised to the same file.
To reduce susceptibility to data loss, the data is also serialised
periodically, as specified when the class is instantiated.
Field Summary |
---|
Fields inherited from class netbattle.database.registry.AccountRegistry |
---|
LEVEL_ADMIN, LEVEL_MOD, LEVEL_USER |
Constructor Summary | |
---|---|
FileImpl(java.lang.String file,
long delta)
Creates a new instance of FileImpl |
Method Summary | |
---|---|
boolean |
addNewUser(java.lang.String user,
java.lang.String password)
Add a new user to the registry. |
boolean |
banUser(java.lang.String user,
long date)
Set the date upon which a user becomes unbanned. |
boolean |
banUser(java.lang.String user,
java.lang.String ip,
long date)
Set the date upon which a user becomes unbanned. |
void |
close()
Close this AccountRegistry. |
java.lang.String |
getIpAddress(java.lang.String user)
Get the IP Address of a particular user. |
long |
getIpUnbanDate(java.lang.String ip)
Return the date upon which an IP address becomes unbanned. |
java.lang.String |
getPassword(java.lang.String user)
Get the SHA-1 hash of a user's password. |
int |
getUserLevel(java.lang.String user)
Get the level of a user. |
UserTableMessage |
getUserList()
Get a list of all users in this registry. |
java.util.List |
getUsersByIp(java.lang.String ip)
Get a List of users with a given IP Address. |
long |
getUserUnbanDate(java.lang.String user)
Determine when a user becomes unbanned. |
boolean |
setUserLevel(java.lang.String user,
int level)
Set the level of a user. |
Methods inherited from class netbattle.database.registry.AccountRegistry |
---|
finalize, getInstance, setInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileImpl(java.lang.String file, long delta)
delta
- the number of milliseconds between each backup of the mapMethod Detail |
---|
public void close()
close
in class AccountRegistry
public java.lang.String getPassword(java.lang.String user)
getPassword
in class AccountRegistry
public boolean addNewUser(java.lang.String user, java.lang.String password)
addNewUser
in class AccountRegistry
user
- the user name of the userpassword
- an SHA-1 hash of the user's password
public boolean banUser(java.lang.String user, long date)
banUser
in class AccountRegistry
public boolean banUser(java.lang.String user, java.lang.String ip, long date)
banUser
in class AccountRegistry
public long getUserUnbanDate(java.lang.String user)
getUserUnbanDate
in class AccountRegistry
public long getIpUnbanDate(java.lang.String ip)
getIpUnbanDate
in class AccountRegistry
public UserTableMessage getUserList()
getUserList
in class AccountRegistry
public java.lang.String getIpAddress(java.lang.String user)
getIpAddress
in class AccountRegistry
public java.util.List getUsersByIp(java.lang.String ip)
getUsersByIp
in class AccountRegistry
public int getUserLevel(java.lang.String user)
getUserLevel
in class AccountRegistry
public boolean setUserLevel(java.lang.String user, int level)
setUserLevel
in class AccountRegistry
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |