001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: MethodSecurityInfo.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.container.info.security;
025:
026: import java.security.Permission;
027: import java.util.ArrayList;
028: import java.util.List;
029:
030: import org.ow2.easybeans.api.bean.info.IMethodSecurityInfo;
031:
032: /**
033: * Used to describe permission information for a given method.
034: * @author Florent Benoit
035: */
036: public class MethodSecurityInfo implements IMethodSecurityInfo {
037:
038: /**
039: * Excluded method ?.
040: */
041: private boolean excluded = false;
042:
043: /**
044: * Unchecked method ?.
045: */
046: private boolean unchecked = false;
047:
048: /**
049: * List of roles for this method.
050: */
051: private List<String> roles = null;
052:
053: /**
054: * Permission for this method.
055: */
056: private Permission permission;
057:
058: /**
059: * Default constructor.
060: */
061: public MethodSecurityInfo() {
062: this .roles = new ArrayList<String>();
063: }
064:
065: /**
066: * This method is excluded (no call allowed if true).
067: * @param excluded boolean true/false.
068: */
069: public void setExcluded(final boolean excluded) {
070: this .excluded = excluded;
071: }
072:
073: /**
074: * @return true if the method is excluded.
075: */
076: public boolean isExcluded() {
077: return excluded;
078: }
079:
080: /**
081: * This method is unchecked (if true, all calls are allowed to this method).
082: * @param unchecked boolean true/false.
083: */
084: public void setUnchecked(final boolean unchecked) {
085: this .unchecked = unchecked;
086: }
087:
088: /**
089: * @return true if the method is unchecked.
090: */
091: public boolean isUnchecked() {
092: return unchecked;
093: }
094:
095: /**
096: * Add the given role to the list of roles allowed to call this method.
097: * @param roleName the name of the role.
098: */
099: public void addRole(final String roleName) {
100: this .roles.add(roleName);
101: }
102:
103: /**
104: * @return list of roles allowed to call this method.
105: */
106: public List<String> getRoles() {
107: return roles;
108: }
109:
110: /**
111: * Sets the permission.
112: * @param permission the permission to set.
113: */
114: public void setPermission(final Permission permission) {
115: this .permission = permission;
116: }
117:
118: /**
119: * @return permissions for this method.
120: */
121: public Permission getPermission() {
122: return permission;
123: }
124:
125: }
|