📄 iofficefactory.java
字号:
package com.gs.db;
import java.lang.reflect.*;
import java.util.*;
import com.gs.db.dbimp.*;
/**
* A IofficeFactory provides access to and management of system-level resources.
* It is the point of entry for the entire Ioffice system.
* <p>
* A concrete instance of IofficeFactory can be obtained by calling the getInstance()
* method with an Authorization token. The Authorization token determines with
* what permissions the rest of the objects in the system will be accessed with.
* <p>
* Usually the first steps of any program interacting with the InterOffice system are:
* <ul>
* <li> Obtain an authorization token by calling
* AuthorizationFactory.getInstance().getAuthorization(username, password);
* <li> Use that authorization to get a IofficeFactory instance.
* <li> Use the forum factory to access forums and other InterOffice content.
* </ul>
* It is also possible to access InterOffice content with anonymous permissions. See
* the AuthorizationFactory class for more information.
* <p>
* IofficeFactory is an abstract class so that the actual implementation is
* pluggable. For example, the default InterOffice implementation uses a database
* backend. You can optionally plug in your own backend that might use the
* filesystem, for example. When first creating the forum factory, InterOffice will
* look for the InterOffice property "IofficeFactory.className". If it fails to find
* that property, it will use the default class.
*
* @see AuthorizationFactory
*/
public abstract class IofficeFactory {
private static Object initLock = new Object();
private static String className = "com.gs.db.dbimp.DbIofficeFactory";
private static IofficeFactory factory = null;
/**
* 返回IofficeFactory的具体实例。
* Returns a concrete IofficeFactory instance. IofficePermissions corresponding
* to the Authorization will be used. If getting the factory fails, null
* will be returned.
*
* @param authorization the auth token for the user.
* @return a concrete IofficeFactory instance.
*/
public static IofficeFactory getInstance(Authorization authorization) {
//If no valid authorization passed in, return null.
Date curdate = new Date();
Date enddate = new Date(2001,12,31);
//if ( curdate.after( enddate ))
//{
// System.out.println("The test license expires, please contact Stone Powerrun Co.");
// return null;
//}
if (authorization == null) {
return null;
}
if (factory == null) {
synchronized(initLock) {
if (factory == null) {
String classNameProp = PropertyManager.getProperty("IofficeFactory.className");
if (classNameProp != null) {
className = classNameProp;
}
try {
//Load the class and create an instance.
Class c = Class.forName(className);
factory = (IofficeFactory)c.newInstance();
}
catch (Exception e) {
System.err.println("Failed to load IofficeFactory class "
+ className + ". Ioffice cannot function normally.");
e.printStackTrace();
return null;
}
}
}
}
//Wrap the factory with a proxy to provide security. We also pass
//in the username and password to the proxy for its special
//implementation of the getForum() method. See below for more details.
IofficeFactoryProxy proxy = new IofficeFactoryProxy(
factory,
authorization,
factory.getPermissions(authorization)
);
return proxy;
}
/**
* 获取用来管理用户、组、组织结构的ProfileManager对象
* Returns a ProfileManager that can be used to manage Users and Groups.
* @see ProfileManager
*/
public abstract ProfileManager getProfileManager();
//public abstract SearchIndexer getSearchIndexer()
// throws UnauthorizedException;
/**
* 返回拥有某种权限的所有用户
* Returns all the userID's of users with a particular system permission.
* System permissions apply to all forums.
*
* @throws UnauthorizedException if does not have SYS_ADMIN permissions.
*/
public abstract int [] usersWithPermission(int permissionType)
throws UnauthorizedException;
/**
* 返回拥有某种权限的所有的用户组
* Returns all the groupID's of groups with a particular system permission.
* System permissions apply to all forums.
*
* @throws UnauthorizedException if does not have ADMIN permissions.
*/
public abstract int[] groupsWithPermission(int permissionType)
throws UnauthorizedException;
/**
* 得到某个登录者拥有的权限
* Returns the permissions for the factory that correspond to the
* passed-in Authorization.
*
* @param authorization the auth token for the user.
* @return the permissions for this object.
*/
public abstract IofficePermissions getPermissions(Authorization authorization);
/**
* 刷新权限表
*/
public abstract void refreshPerm();
/**
* 测试这个段代码是否拥有某种权限
* Returns true if the handle on the object has the permission specified.
* A list of possible permissions can be found in the IofficePermissions
* class. Certain methods of this class are restricted to certain
* permissions as specified in the method comments.
*
* @param type the type of permission to check for.
* @see IofficePermissions
*/
public abstract boolean hasPermission(int type);
/**
* 给一个用户增加权限
* Add permission to a user, it will throw UnauthorizedException if the handle
* of this code is not allowed to do this.
*
* @param user the user to add permission to
* @param permtype the permission type to add
* @see IofficePermissions
*/
public abstract void addUserPermission(User user, int permissionType) throws UnauthorizedException;
/**
* 给用户组增加权限
* Add permission to a group, it will throw UnauthorizedException if the handle
* of this code is not allowed to do this.
* @param group the group to add permission to
* @param permissionType the permission type to add
* @see IofficePermissions
*/
public abstract void addGroupPermission(Group group, int permissionType) throws UnauthorizedException;
/**
* 给一个用户删除权限
* Remove permission to a user, it will throw UnauthorizedException if the handle
* of this code is not allowed to do this.
*
* @param user the user to add permission to
* @param permissionType the permission type to add
* @see IofficePermissions
*/
public abstract void removeUserPermission(User user, int permtype) throws UnauthorizedException;
/**
* 给用户组删除权限
* Remove permission to a group, it will throw UnauthorizedException if the handle
* of this code is not allowed to do this.
* @param group the group to add permission to
* @param permtype the permission type to add
* @see IofficePermissions
*/
public abstract void removeGroupPermission(Group group, int permtype) throws UnauthorizedException;
/**
* 根据权限的名称得到权限代码(查字典)
* Lookup the a permission type code by its permission name
*/
public abstract int permFromName(String permName) throws PermissionNameException;
/**
* 根据权限的代码得到名称(查字典)
* Lookup the type permission name by type code
*/
public abstract String getPermName(int perm) throws PermissionNameException;
/**
* 得到InterOffice系统管理的所有权限的代码
* Return all the permissions types that InterOffice supports in an array
*/
public abstract int[] getAllPermissionTypes();
/**
* 得到InterOffice系统管理的所有权限的名称
* Return all the permissions names that InterOffice supports in an array
*/
public abstract String[] getAllPermissionNames();
/**
* 得到某个组不具有的全部权限,数组元素是权限代码
* Return all permissions that the group does not own
*/
public abstract int[] getAbsentPermissionTypes(Group group);
/**
* 得到某个用户没有的权限,数组元素是权限代码
* Return all permissions that the user does not own in specific
*/
public abstract int[] getAbsentPermissionTypes(User user);
/**
* 得到某个用户被明确授予的全部权限,数组元素是权限代码
* Return all permissions that are assigned to the user
*/
public abstract int[] getUserPermissionTypes(User user);
/**
* 检察用户最终是否具有某种权限
* Test if the user has some permission finally, i.e., including the
* perm types assigned to the group it belongs to
*/
public abstract boolean testUserFinalPermission( int userID, int permType );
/**
* 得到某个组具有的全部权限,数组元素是权限代码
* Return all permissions that the group owns
*/
public abstract int[] getGroupPermissionTypes(Group group);
/**
* Test if the unitToTest is the the predecendant unit of me
*/
public abstract boolean isInCharge ( Unit me , Unit unitToTest );
/**
* Get the ComponentManager object
*
* @return ComponentManager object
* @see ComponentManager
*/
public abstract ComponentManager getComponentManager ();
/**
* The JSPs can use this function to report a client's action, if your system
* want to track the client side activities. This will be recorded in the login DB-table.
* @param ipAddr the address of the client
* @doingWhat the activity description
*/
public abstract void reportPulse(String ipAddr, String doingWhat );
/**
* Call this to delete login record the current non-anonymous user
* @see LoginRecord
*/
public abstract void deleteLoginRecord();
/**
* Get a iterator to check all login records
* @return a Iterator of LoginRecord objects
* @see LoginRecord
*/
public abstract Iterator getLoginRecordIterator();
/**
* Tells if a component is accessible to a certain authorization
*/
public abstract boolean isAccessbile( Authorization authorization, IofficeComponent component);
public abstract boolean isAccessibleToAnonymousUsers( IofficeComponent component);
/**
* Add accessiblity to a component or components for a group
* @param componentName the name of a specified component or 'ALL' OR 'DEFAULTS'
* @param group the object group
* @throws UnauthorizedException if the handle donnot have the right
*/
public abstract void addAccess( String componentName, Group group ) throws UnauthorizedException;
/**
* Remove accessiblity to a component or components for a group
* @param componentName the name of a specified component or 'ALL' OR 'DEFAULTS'
* @param group the object group
* @throws UnauthorizedException if the handle donnot have the right
*/
public abstract void removeAccess( String componentName, Group group ) throws UnauthorizedException;
public abstract void addAccessToAnonymousUsers(IofficeComponent component) throws UnauthorizedException;
public abstract void removeAccessToAnonymousUsers(IofficeComponent component) throws UnauthorizedException;
public abstract boolean hasAccess( String componentName, Group group ) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -