mycq.UserManager Interface Reference

Manages users of a MyCQ Server. More...

List of all members.

Public Member Functions

void createUser (String username, String password, UserType userType) throws MyCQException
 Create a new user.
void deleteUser (String username) throws MyCQException
 Delete a user.
void changePassword (String username, String password) throws MyCQException
 Change the password of a user.
void changeUserType (String username, UserType userType) throws MyCQException
 Change the type of a user.
List< UserInfogetAllUserInfo () throws MyCQException
 Get the user information list of a MyCQ Server.

Detailed Description

Manages users of a MyCQ Server.

import java.util.List;
import mycq.*;

public class ExamUserManager {

            public void sample() {
                        // get client instance
                        MyCQClient client = MyCQFactory.getMyCQClient();

                        try {
                                    // connect
                                    client.connect("localhost", 3030, "root", "1234");

                                    // get user manger
                                    UserManager userManager = client.getUserManager();

                                    // create user
                                    userManager.createUser("user1", "password1", UserType.SUPER_USER);

                                    // change user type
                                    userManager.changeUserType("user1", UserType.NORMAL_USER);

                                    // change password
                                    userManager.changePassword("user1", "password2");

                                    // get all user information
                                    List<UserInfo> result = userManager.getAllUserInfo();
                                    for (UserInfo userInfo : result) {
                                                System.out.println(userInfo.username);

                                                if (userInfo.type == UserType.SUPER_USER) {
                                                            System.out.println("super user");
                                                } else {
                                                            System.out.println("normal user");
                                                }
                                    }

                                    // delete user
                                    userManager.deleteUser("user1");
                        } catch (MyCQException ex) {
                                    System.out.println("code:" + ex.getCode() + ", message:"
                                                            + ex.getMessage());
                        }

                        // close connection
                        client.close();
            }
}

Member Function Documentation

void mycq.UserManager.changePassword ( String  username,
String  password 
) throws MyCQException

Change the password of a user.

Parameters:
username A user name of a MyCQ Server to change the password.
password A password of a user to change. (size:= under 64).
Exceptions:
MyCQException An error occurred while changing the password of a user.
void mycq.UserManager.changeUserType ( String  username,
UserType  userType 
) throws MyCQException

Change the type of a user.

Parameters:
username A user name of a MyCQ Server to change the user type.
userType A user type of a user to change.
Exceptions:
MyCQException An error occurred while changing the user type of a user.
void mycq.UserManager.createUser ( String  username,
String  password,
UserType  userType 
) throws MyCQException

Create a new user.

Parameters:
username A user name of a MyCQ Server to create. (size:= under 64). A user name is a combination of alphabets and numerics which starts with alphabet character.
password A password of a user to create. (size:= under 64).
userType A user type of a user to create.
Exceptions:
MyCQException An error occurred while creating a new user.
void mycq.UserManager.deleteUser ( String  username  )  throws MyCQException

Delete a user.

Parameters:
username A user name of a MyCQ Server to delete.
Exceptions:
MyCQException An error occurred while deleting a user.
List<UserInfo> mycq.UserManager.getAllUserInfo (  )  throws MyCQException

Get the user information list of a MyCQ Server.

Returns:
User information list.
Exceptions:
MyCQException An error occurred while getting the user information list.
 All Classes Namespaces Functions Variables Enumerations
MyCQ Java User's Document. Copyright@MyCQ Inc., All Rights Reserved.