📄 client.java
字号:
* the warning message from the server will be thrown. * @param request a vector includes a group's name and a vector of users. * @return The messages returned from server. */ public static Vector addGroupToUser(Vector request) throws ClientErrorException, ClientWarningException { try { out.reset(); out.writeObject("ADDGRPTOUSRS"); //System.out.println("addGroupToUser: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("addGroupToUser: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); if (status.equals(strERROR)) throw new ClientErrorException((String)response.get(0)); else //if (status.equals(strWARNING)) throw new ClientWarningException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Add group to user" + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Add group to user " + e); throw new ClientErrorException(e.toString()); } } /** * Set groups for an user. * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @exception ClientWarningException The operation can be completed, * the warning message from the server will be thrown. * @param request a vector includes an user's name and a vector of groups. * @return The messages returned from server. */ public static Vector setGroupsForUser(Vector request) throws ClientErrorException, ClientWarningException { try { out.reset(); out.writeObject("SETGRPSFORUSR"); //System.out.println("setGroupsForUser: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("setGroupsForUser: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); if (status.equals(strERROR)) throw new ClientErrorException((String)response.get(0)); else //if (status.equals(strWARNING)) throw new ClientWarningException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Set groups for user" + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Set groups for user " + e); throw new ClientErrorException(e.toString()); } } /** * Remove group access for an user. * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @param request a vector includes a group's name and its users. * @return The messages returned from server. */ public static Vector deleteGroupFromUser(Vector request) throws ClientErrorException { try { out.reset(); out.writeObject("DELGRPFROMUSRS"); out.writeObject(request); out.flush(); status = (String)in.readObject(); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); throw new ClientErrorException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Delete group from user" + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Delete group from user " + e); throw new ClientErrorException(e.toString()); } } /** * Add an user to the system. * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @exception ClientWarningException The operation can be completed, * the warning message from the server will be thrown. * @param request a vector includes an user's name, password, permission and groups to which the user belong. * @return The messages returned from server. */ public static Vector addUser(Vector request) throws ClientErrorException, ClientWarningException { try { out.reset(); out.writeObject("ADDUSR"); //System.out.println("addUser: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("addUser: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); if (status.equals(strERROR)) throw new ClientErrorException((String)response.get(0)); else //if (status.equals(strWARNING)) throw new ClientWarningException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Add user" + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Add user " + e); throw new ClientErrorException(e.toString()); } } /** * Delete an user from the system * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @param request a vector includes an user's name. * @return The messages returned from server. */ public static Vector deleteUser(Vector request) throws ClientErrorException { try { out.reset(); out.writeObject("DELUSR"); //System.out.println("deleteUser: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("addUser: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); throw new ClientErrorException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Delete user" + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Delete user " + e); throw new ClientErrorException(e.toString()); } } /** * Modify an user's name * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @param request a vector includes an user name and a new name. * @return The messages returned from server. */ public static Vector modifyUserName(Vector request) throws ClientErrorException { try { out.reset(); out.writeObject("CHGNAMEUSR"); //System.out.println("modifyUserName: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("modifyUserName: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); throw new ClientErrorException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Modify user name" + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Modify user name" + e); throw new ClientErrorException(e.toString()); } } /** * Modify an user's password * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @param request a vector includes an user name and password. * @return The messages returned from server. */ public static Vector modifyUserPassword(Vector request) throws ClientErrorException { try { out.reset(); out.writeObject("CHGPASSW"); //System.out.println("modifyUserPassword: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("modifyUserPassword: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); throw new ClientErrorException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Modify user password " + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Modify user password " + e); throw new ClientErrorException(e.toString()); } } /** * Modify an user's privilege * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @param request a vector includes an user name and permission. * @return The messages returned from server. */ public static Vector modifyUserPrivlg(Vector request) throws ClientErrorException { try { out.reset(); out.writeObject("CHGPERM"); //System.out.println("modifyUserPrivlg: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("modifyUserPrivlg: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); throw new ClientErrorException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Modify user permission " + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Modify user permission " + e); throw new ClientErrorException(e.toString()); } } /** * Add an user to a group * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @exception ClientWarningException The operation can be completed, * the warning message from the server will be thrown. * @param request a vector includes an user name and a vector of groups. * @return The messages returned from server. */ public static Vector addUserToGroup(Vector request) throws ClientErrorException, ClientWarningException { try { out.reset(); out.writeObject("ADDUSRTOGRPS"); //System.out.println("addUserToGroup: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("addUserToGroup: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); if (status.equals(strERROR)) throw new ClientErrorException((String)response.get(0)); else //if (status.equals(strWARNING)) throw new ClientWarningException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Add user to group " + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Add user to group " + e); throw new ClientErrorException(e.toString()); } } /** * Set user(s) for a group * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @exception ClientWarningException The operation can be completed, * the warning message from the server will be thrown. * @param request a vector includes an group name and a vector of users. * @return The messages returned from server. */ public static Vector setUsersForGroup(Vector request) throws ClientErrorException, ClientWarningException { try { out.reset(); out.writeObject("SETUSRSFORGRP"); //System.out.println("setUsersForGroup: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("setUsersForGroup: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); if (status.equals(strERROR)) throw new ClientErrorException((String)response.get(0)); else //if (status.equals(strWARNING)) throw new ClientWarningException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Set users for group " + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Set users for group " + e); throw new ClientErrorException(e.toString()); } } /** * Remove an user from a group * @exception ClientErrorException The operation can not be completed, * the error message from the server will be thrown. * @exception ClientWarningException The operation can be completed, * the warning message from the server will be thrown. * @param request a vector includes an user name and a vector of groups. * @return The messages returned from server. */ public static Vector deleteUserFromGroup(Vector request) throws ClientErrorException, ClientWarningException { try { out.reset(); out.writeObject("DELUSRFROMGRPS"); //System.out.println("deleteUserFromGroup: request: " + request.toString()); out.writeObject(request); out.flush(); status = (String)in.readObject(); //System.out.println("deleteUserFromGroup: status: " + status); if (status.equals(strOK)) return null; response = (Vector)in.readObject(); if (status.equals(strERROR)) throw new ClientErrorException((String)response.get(0)); else //if (status.equals(strWARNING)) throw new ClientWarningException((String)response.get(0)); } catch (IOException e) { //System.err.println("Client: Delete user from group " + e); throw new ClientErrorException(e.toString()); } catch (ClassNotFoundException e) { //System.err.println("Client: Delete user froms group " + e); throw new ClientErrorException(e.toString()); } } public static Vector benchmark (Vector benchInput) throws ClientErrorException
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -