sav.z
Class User

java.lang.Object
  extended bysav.z.User

public class User
extends java.lang.Object

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());
 

Since:
7.0
See Also:
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

NONAME

public static final int NONAME
Access right (with value < NOPASSW) specifying no permission for reason of non-correct user name.

See Also:
Constant Field Values

NOPASSW

public static final int NOPASSW
Access right (with value < NONE) specifying no permission for reason of non-correct password.

See Also:
Constant Field Values

NONE

public static final int NONE
Access right (with value 0) specifying no permission for the user.

See Also:
Constant Field Values

READ

public static final int READ
Access right (with value > NONE) allowing to read data.

See Also:
Constant Field Values

WRITE

public static final int WRITE
Access right (with value > READ) allowing to write and read data.

See Also:
Constant Field Values

EDIT

public static final int EDIT
Access right (with value > 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.

See Also:
Constant Field Values

MANAG

public static final int MANAG
Access right (with value > 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.

See Also:
Constant Field Values

ADMIN

public static final int ADMIN
Access right (with value > MANAG) allowing to administrate, manage, edit, write and read data.

See Also:
Constant Field Values

service

public java.lang.String service
A service name, which has effect on the application behavior, together with access right of the current user.


context

public java.util.Hashtable context
Controled by application the hashed context, which keeps arbitrary data.

Constructor Detail

User

public User(java.lang.String name,
            java.lang.String password)
Constructs the User object with name and password.


User

public User()
Constructs the User object with empty "" value of name and password.

See Also:
User(String, String)
Method Detail

access

public static int access(java.lang.String role)
Transforms the role to its number representation the access right.

See Also:
role(int)

role

public static java.lang.String role(int access)
Transforms the access to its String representation the role. Accordances access->role: NONE->"none", READ->"read", WRITE->"write", EDIT->"edit", MANAG->"manag", ADMIN->"admin", other->null.

See Also:
access(String)

mode

public 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.

See Also:
role(int)

mark

public static char mark(int access)
Transforms the access to the mark, first the capital letter of role, like N, R and so on.

See Also:
role(int)

init

public void init(java.lang.String name,
                 java.lang.String password)
Inits value of name and password.

See Also:
User(String, String)

name

public java.lang.String name()
Returns user name. Below user name is "ann".
  User u = new User("ann", "111111");
  String userName = u.name();
 


password

public java.lang.String password()
Returns password. Below password is "111111".
  User u = new User("ann", "111111");
  String userPassword = u.password();
 


access

public int access()
Returns right access of this User.

Returns:
0 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.
See Also:
access(int), Session.login(User)

access

public int access(int access)
Sets access right to this User.

See Also:
access()

role

public java.lang.String role()
Returns role (access right in String format) of this User. Possible values are in role(int).

See Also:
access()