filtermanagerproxy.java
来自「Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统,这是Jive论坛」· Java 代码 · 共 128 行
JAVA
128 行
/** * $RCSfile: FilterManagerProxy.java,v $ * $Revision: 1.2 $ * $Date: 2002/03/28 04:18:00 $ * * Copyright (C) 1999-2002 CoolServlets, Inc. All rights reserved. * * This software is the proprietary information of CoolServlets, Inc. * Use is subject to license terms. */package com.jivesoftware.forum;/** * A protection proxy for FilterManagers. A proxy has a set of permissions that * are specified at creation time of the proxy. Subsequently, those permissions * are use to restrict access to protected methods. If a user does * not have the right to execute a particular method, an UnauthorizedException * is thrown. * * @see FilterManager * @author Matt Tucker */public class FilterManagerProxy implements FilterManager { private FilterManager filterManager; private Authorization authorization; private ForumPermissions permissions; /** * Creates a new filterManagerProxy object. * * @param filterManager the filter manager to protect by proxy * @param authorization the user's authorization token * @param permissions the permissions to use with this proxy. */ public FilterManagerProxy(FilterManager filterManager, Authorization authorization, ForumPermissions permissions) { this.filterManager = filterManager; this.authorization = authorization; this.permissions = permissions; } //FROM THE FORUM INTERFACE// public ForumMessageFilter getFilter(int index) throws UnauthorizedException { if (isAdmin()) { return filterManager.getFilter(index); } else { throw new UnauthorizedException(); } } public int getFilterCount() throws UnauthorizedException { if (isAdmin()) { return filterManager.getFilterCount(); } else { throw new UnauthorizedException(); } } public void addFilter(ForumMessageFilter filter) throws UnauthorizedException { if (isAdmin()) { filterManager.addFilter(filter); } else { throw new UnauthorizedException(); } } public void addFilter(ForumMessageFilter filter, int index) throws UnauthorizedException { if (isAdmin()) { filterManager.addFilter(filter, index); } else { throw new UnauthorizedException(); } } public void removeFilter(int index) throws UnauthorizedException { if (isAdmin()) { filterManager.removeFilter(index); } else { throw new UnauthorizedException(); } } public void saveFilters() throws UnauthorizedException { if (isAdmin()) { filterManager.saveFilters(); } else { throw new UnauthorizedException(); } } public ForumMessage applyFilters(ForumMessage message) { return filterManager.applyFilters(message); } public ForumMessage applyCacheableFilters(ForumMessage message) { return filterManager.applyCacheableFilters(message); } public ForumMessage applyUncacheableFilters(ForumMessage message) { return filterManager.applyUncacheableFilters(message); } public boolean hasUncacheableFilters() { return filterManager.hasUncacheableFilters(); } private boolean isAdmin() { return permissions.get(ForumPermissions.SYSTEM_ADMIN) || permissions.get(ForumPermissions.CATEGORY_ADMIN) || permissions.get(ForumPermissions.FORUM_ADMIN); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?