www.pudn.com > SecurityFilter.rar > SecurityConstraint.java


package dev.trade.common.securityfilter.config; 
 
import java.util.*; 
 
/** 
 * 

Title: 权限过滤器

* *

Description: 权限配置

* *

Copyright: Copyright (c) 2006

* *

Company:

* * @author Zheng YanNan * @version 1.0 */ public class SecurityConstraint { private List resourceCollections; private AuthConstraint authConstraint = null; /** * Constructor */ public SecurityConstraint() { this.resourceCollections = new ArrayList(); } /** * Add a WebResourceCollection to this SecurityConstraint. * * @param resourceCollection the WebResourceCollection to add */ public void addWebResourceCollection(WebResourceCollection resourceCollection) { resourceCollections.add(resourceCollection); } /** * Get the WebResourceCollections for this SecurityConstraint. The order of the list is the order in which the * WebResourceCollections appeared in the config file. * * @return a List of WebResourceCollections, an empty list if none were added */ public List getWebResourceCollections() { return this.resourceCollections; } /** * Set the AuthConstraint. * * @param authConstraint the AuthConstraint */ public void setAuthConstraint(AuthConstraint authConstraint) { this.authConstraint = authConstraint; } /** * Get the AuthConstraint. * * @return an AuthConstraint object, or null if none has been set */ public AuthConstraint getAuthConstraint() { return authConstraint; } /** * 通过WEB资源名称获取指定配置的角色集合 * @param name String * @return Collection */ public Collection getRolesByResourceName(String name){ if(name!=null && authConstraint!=null){ WebResourceCollection res = null; for(int i = 0, l = resourceCollections.size(); i < l; i++){ res = (WebResourceCollection)resourceCollections.get(i); if(name.equals(res.getWebResourceName())){ return authConstraint.getRoles(); } } } return null; } }