⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iofficefactoryproxy.java

📁 一套完整的工商12315的源程序jsp部分在12315里,后台JAVA部分在gs12315src里,没有打包数据库.
💻 JAVA
字号:
package com.gs.db;

/**
 * Protection for IofficeFactory interface.
 */
import java.util.*;
import com.gs.db.dbimp.*;

public class IofficeFactoryProxy extends IofficeFactory {

    private IofficeFactory factory;
    private Authorization authorization;
    private IofficePermissions permissions;

    /**
     *  Create a proxy object by the an existing IofficeFactory object.
     * @param group the existing IofficeFactory, de facto is a DbIofficeFactory
     *  object
     * @param authorization the token to the calling code
     * @permissions the permissions owned by the calling code
     * @see DbIofficeFactory
     */
    public IofficeFactoryProxy(IofficeFactory factory, Authorization authorization,
            IofficePermissions permissions)
    {
        this.factory = factory;
        this.authorization = authorization;
        this.permissions = permissions;
    }

    /**
     * 获取用来管理用户、组、组织结构的ProfileManager对象
     * Returns a ProfileManager that can be used to manage Users and Groups.
     * @see ProfileManager
     */
    public ProfileManager getProfileManager() {
        ProfileManager profileManager = factory.getProfileManager();
        return new ProfileManagerProxy(profileManager, authorization, permissions);
    }

    /*
    public SearchIndexer getSearchIndexer() throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            return factory.getSearchIndexer();
        }
        else {
            throw new 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 int [] usersWithPermission(int permissionType)
            throws UnauthorizedException
    {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            return factory.usersWithPermission(permissionType);
        }
        else {
            throw new 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 int[] groupsWithPermission(int permissionType)
            throws UnauthorizedException
    {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            return factory.groupsWithPermission(permissionType);
        }
        else {
            throw new 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 IofficePermissions getPermissions(Authorization authorization) {
        return factory.getPermissions(authorization);
    }

    /**
     * 测试这个段代码是否拥有某种权限
     * 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 boolean hasPermission(int type) {
        return permissions.get(type);
    }

    /**
     * Get the underlying IofficeFactory object which is wrapped by this proxy.
     * @return the IofficeFactory object, usually is a DbIofficeFactory object
     * @throw UnauthorizedException is the handle of the code does not have
     * SYSTEM_ADMIN permission
     */
    public IofficeFactory getUnderlyingIofficeFactory()
            throws UnauthorizedException
    {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            return factory;
        }
        else {
            throw new UnauthorizedException();
        }
    }

    /**
     * 给一个用户增加权限
     * 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 void addUserPermission(User user, int permtype)
    	throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            factory.addUserPermission( user, permtype);
        }
        else {
            throw new 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 void addGroupPermission(Group group, int permtype)
    	throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            factory.addGroupPermission( group, permtype);
        }
        else {
            throw new 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 void removeUserPermission(User user, int permissionType)
    throws UnauthorizedException{
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            factory.removeUserPermission( user, permissionType);
        }
        else {
            throw new 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 void removeGroupPermission(Group group, int permissionType)
    	throws UnauthorizedException {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            factory.removeGroupPermission( group, permissionType);
        }
        else {
            throw new UnauthorizedException();
        }
    }

    /**
     * 根据权限的名称得到权限代码(查字典)
     * Lookup the a permission type code by its permission name
     */
    public int permFromName(String permName)
      throws PermissionNameException
    {
    	return factory.permFromName( permName );
    }

    /**
     * 根据权限的代码得到名称(查字典)
     * Lookup the type permission name by type code
     */
    public String getPermName(int perm)
          throws PermissionNameException
    {
    	return factory.getPermName( perm );
    }

    /**
     * 得到InterOffice系统管理的所有权限的代码
     * Return all the permissions types that InterOffice supports in an array
     */
    public int[] getAllPermissionTypes()
    {
    	return factory.getAllPermissionTypes(  );
    }
    /**
     * 得到InterOffice系统管理的所有权限的名称
     * Return all the permissions names that InterOffice supports in an array
     */
    public String[] getAllPermissionNames()
    {
    	return factory.getAllPermissionNames(  );
    }
    /**
     * 得到某个组不具有的全部权限,数组元素是权限代码
     * Return all permissions that the group does not own
     */
    public int[] getAbsentPermissionTypes(Group group)
    {
        return factory.getAbsentPermissionTypes(group);
    }
    /**
     * 得到某个用户没有的权限,数组元素是权限代码
     * Return all permissions that the user does not own in specific
     */
   public int[] getAbsentPermissionTypes(User user)
    {
        return factory.getAbsentPermissionTypes(user);
    }
    /**
     * 得到某个用户被明确授予的全部权限,数组元素是权限代码
     * Return all permissions that are assigned to the user
     */
    public int[] getUserPermissionTypes(User user)
    {
        return factory.getUserPermissionTypes(user);
    }
    /**
     * 得到某个组具有的全部权限,数组元素是权限代码
     * Return all permissions that the group owns
     */
    public int[] getGroupPermissionTypes(Group group)
    {
        return factory.getGroupPermissionTypes(group);
    }
    public boolean testUserFinalPermission( int userID, int permType )
    {
        return factory.testUserFinalPermission( userID, permType );
    }

    public void refreshPerm(){
      factory.refreshPerm();
    }

    /**
     * Get the ComponentManager object
     *
     * @return ComponentManager object
     * @see ComponentManager
     */
    public ComponentManager getComponentManager (){
        ComponentManager manager =  factory.getComponentManager();
        return new ComponentManagerProxy( manager, authorization, permissions );
    }

    /**
     *  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  void reportPulse(String ipAddr,  String doingWhat )
    {
        if ( authorization.getUserID() <=0 ) return;        //do nothing for anoymous users
        com.gs.db.dbimp.DbIofficeFactory dbfac = (com.gs.db.dbimp.DbIofficeFactory)factory;
        dbfac.reportPulse(authorization.getUserID(), ipAddr, doingWhat );
    }
     /**
     *  Call this to delete login record the current non-anonymous user
     *  @see LoginRecord
     */
   public void deleteLoginRecord() {
        if ( authorization.getUserID() <=0 ) return;        //do nothing for anoymous users
        com.gs.db.dbimp.DbIofficeFactory dbfac = (com.gs.db.dbimp.DbIofficeFactory)factory;
        dbfac.deleteLoginRecord(authorization.getUserID() );
    }
    /**
     *  Get a iterator to check all login records
     *  @return a Iterator of LoginRecord objects
     *  @see LoginRecord
     */
    public Iterator getLoginRecordIterator()
    {
       return  factory.getLoginRecordIterator();
    }

    /**
     * Tells if a component is accessible to a certain authorization
     */
    public boolean isAccessbile( Authorization authorization, IofficeComponent component)
    {
        return factory.isAccessbile(authorization,component);
    }

    public boolean isAccessibleToAnonymousUsers( IofficeComponent component)
    {
        return isAccessibleToAnonymousUsers(  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 void addAccess( String componentName, Group group ) throws UnauthorizedException
    {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            factory.addAccess(  componentName,  group );
        }
        else {
            throw new UnauthorizedException();
        }
    }
    /**
     * Test if the unitToTest is the the predecendant unit of me
     */
    public boolean isInCharge ( Unit me , Unit unitToTest )
    {
        return factory.isInCharge( me, unitToTest );
    }

    /**
     *  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 void removeAccess(String componentName, Group group ) throws UnauthorizedException
    {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
        factory.removeAccess(  componentName,  group );
        }
        else {
            throw new UnauthorizedException();
        }
    }

    public synchronized void  addAccessToAnonymousUsers(IofficeComponent component) throws UnauthorizedException
    {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            factory.addAccessToAnonymousUsers( component);
        }
        else {
            throw new UnauthorizedException();
        }

    }

    public void removeAccessToAnonymousUsers(IofficeComponent component) throws UnauthorizedException
    {
        if (permissions.get(IofficePermissions.SYSTEM_ADMIN)) {
            factory.removeAccessToAnonymousUsers( component);
        }
        else {
            throw new UnauthorizedException();
        }

    }

    public boolean hasAccess( String componentName, Group group )
    {
        return factory.hasAccess( componentName, group );
    }


   /**
    * During the initialization of the ioffice kernel, a seperate thread will be
    * started to deliver information to the subscribers. The thread runs in a
    * continual manner to avoid consuming much system resources.To be frank, after
    * checking and sending each mail, it will sleep a little while.
    */

    ////////////////////////////////////////////////////////////////
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -