|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsav.z.User
Optional class for advanced developers to control access right.
The User object, beside the name and password, has the important
access
field (more exactly access right), which may
be got via access()
method. By default value of access is a
NONAME
. To set an access, it is enough to use the
access(int)
or Session.login(User)
.
String representation of the access is role
.
The Session's method Session.login(User)
defines User's
access depending on the special relation in database. This relation
has structure $User ($Password,$Role). For example,
to set the edit role (or EDIT
access) for
bob user, Zigzag expression $User:'bob' ($Role:write)
is used. To set the read role (or READ
access) for
any user, we have to use $User:'' ($Role:read) expression.
The following example determines access and role of the user via
account1 database.
Session ss = new Session(); ss.exploreBase("account1"); ss.login(new User(name, password)); if (ss.user().access() <= User.NONE) System.out.println("Sorry, login is not correct"); else System.out.println("Thanks " + name + ", your functional role is " + ss.user().role());
Session.user()
Field Summary | |
static int |
ADMIN
Access right (with value > MANAG ) allowing to administrate, manage, edit,
write and read data. |
java.util.Hashtable |
context
Controled by application the hashed context, which keeps arbitrary data. |
static int |
EDIT
Access right (with value > WRITE ) allowing to edit, write and read data.
|
static int |
MANAG
Access right (with value > EDIT ) allowing to manage, edit, write and read data.
|
static int |
NONAME
Access right (with value < NOPASSW ) specifying no permission
for reason of non-correct user name. |
static int |
NONE
Access right (with value 0) specifying no permission for the user. |
static int |
NOPASSW
Access right (with value < NONE ) specifying no permission
for reason of non-correct password. |
static int |
READ
Access right (with value > NONE ) allowing to read data. |
java.lang.String |
service
A service name, which has effect on the application behavior, together with access right of the current user. |
static int |
WRITE
Access right (with value > READ ) allowing to write and read data. |
Constructor Summary | |
User()
Constructs the User object with empty "" value of name and password. |
|
User(java.lang.String name,
java.lang.String password)
Constructs the User object with name and password . |
Method Summary | |
int |
access()
Returns right access of this User. |
int |
access(int access)
Sets access right to this User. |
static int |
access(java.lang.String role)
Transforms the role to its number representation the access right. |
void |
init(java.lang.String name,
java.lang.String password)
Inits value of name and password . |
static char |
mark(int access)
Transforms the access to the mark,
first the capital letter of role, like N, R and so on. |
static java.lang.String |
mode(int access)
Transforms the access to the mode, its String representation
with the capital letter, like None, Read and so on. |
java.lang.String |
name()
Returns user name. |
java.lang.String |
password()
Returns password. |
java.lang.String |
role()
Returns role (access right in String format) of this User. |
static java.lang.String |
role(int access)
Transforms the access to its String representation the role.
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NONAME
NOPASSW
) specifying no permission
for reason of non-correct user name.
public static final int NOPASSW
NONE
) specifying no permission
for reason of non-correct password.
public static final int NONE
public static final int READ
NONE
) allowing to read data.
public static final int WRITE
READ
) allowing to write and read data.
public static final int EDIT
WRITE
) allowing to edit, write and read data.
The EDIT
may signify permission to edit structure,
not only to write record. Additionally the EDIT
may permit
to set up access right (READ
, WRITE
) to the corresponding data.
public static final int MANAG
EDIT
) allowing to manage, edit, write and read data.
The MANAG
may signify permission to edit all the data
of any user and set access rights for their.
public static final int ADMIN
MANAG
) allowing to administrate, manage, edit,
write and read data.
public java.lang.String service
public java.util.Hashtable context
Constructor Detail |
public User(java.lang.String name, java.lang.String password)
name
and password
.
public User()
User(String, String)
Method Detail |
public static int access(java.lang.String role)
role
to its number representation the access right.
role(int)
public static java.lang.String role(int access)
access
to its String representation the role.
Accordances access->role:
NONE
->"none",
READ
->"read",
WRITE
->"write",
EDIT
->"edit",
MANAG
->"manag",
ADMIN
->"admin",
other->null.
access(String)
public static java.lang.String mode(int access)
access
to the mode, its String representation
with the capital letter, like None, Read and so on.
role(int)
public static char mark(int access)
access
to the mark,
first the capital letter of role, like N, R and so on.
role(int)
public void init(java.lang.String name, java.lang.String password)
name
and password
.
User(String, String)
public java.lang.String name()
User u = new User("ann", "111111"); String userName = u.name();
public java.lang.String password()
User u = new User("ann", "111111"); String userPassword = u.password();
public int access()
NONE
if user has no permission,
>User.NONE ADMIN
, MANAG
, EDIT
,
WRITE
, READ
if user has access right,
<User.NONE if login is not correct, namely
NONAME
if user name is wrong,
NOPASSW
if password is wrong.access(int)
,
Session.login(User)
public int access(int access)
access()
public java.lang.String role()
role(int)
.
access()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |