001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.directwebremoting.spring;
017:
018: import java.util.List;
019: import java.util.Properties;
020: import java.util.ArrayList;
021:
022: import org.directwebremoting.AjaxFilter;
023: import org.directwebremoting.extend.Creator;
024:
025: /**
026: * The configuration for a creator. <br>
027: * You can either specify the creator directly or specify one of the build in creator types,
028: * for instance "new".
029: *
030: * It allows the specification of the following optional configuration parameters:
031: * <ul>
032: * <li>includes - the list of method names to include</li>
033: * <li>excludes - the list of method names to exclude</li>
034: * <li>auth - the <code>Properties</code> object containing method names and corresponding
035: * required role</li>
036: * <li>filters - the list of filter objects</li>
037: * </ul>
038: *
039: * @see org.directwebremoting.extend.AccessControl#addIncludeRule(String, String)
040: * @see org.directwebremoting.extend.AccessControl#addExcludeRule(String, String)
041: * @see org.directwebremoting.extend.AccessControl#addRoleRestriction(String, String, String)
042: * @see org.directwebremoting.AjaxFilter
043: * @see org.directwebremoting.extend.AjaxFilterManager#addAjaxFilter(org.directwebremoting.AjaxFilter, String)
044: *
045: * @author Bram Smeets
046: * @author Joe Walker [joe at getahead dot ltd dot uk]
047: */
048: public class CreatorConfig extends AbstractConfig {
049: /**
050: * The creator type that will be used to create new objects for remoting
051: * @return Returns the creator type.
052: */
053: public String getCreatorType() {
054: return creatorType;
055: }
056:
057: /**
058: * The creator that will be used to create new objects for remoting
059: * @param creatorType The creator type to set.
060: */
061: public void setCreatorType(String creatorType) {
062: this .creatorType = creatorType;
063: }
064:
065: /**
066: * The creator that will be used to create new objects for remoting
067: * @return Returns the creator.
068: */
069: public Creator getCreator() {
070: return creator;
071: }
072:
073: /**
074: * The creator type that will be used to create new objects for remoting
075: * @param creator The creator to set.
076: */
077: public void setCreator(Creator creator) {
078: this .creator = creator;
079: }
080:
081: /**
082: * Sets the authentication parameters for this creator.
083: * @return the map containing the method name and the corrosponding required role
084: * @see org.directwebremoting.extend.AccessControl#addRoleRestriction(String, String, String)
085: */
086: public Properties getAuth() {
087: return auth;
088: }
089:
090: /**
091: * Sets the authentication parameters for this creator.
092: * @param auth the map containing the method name and the corrosponding required role
093: * @see org.directwebremoting.extend.AccessControl#addRoleRestriction(String, String, String)
094: */
095: public void setAuth(Properties auth) {
096: this .auth = auth;
097: }
098:
099: /**
100: * Gets the list of all filters for this creator.
101: * @return the list containing all filters
102: * @see org.directwebremoting.AjaxFilter
103: * @see org.directwebremoting.extend.AjaxFilterManager#addAjaxFilter(org.directwebremoting.AjaxFilter, String)
104: */
105: public List<?> getFilters() {
106: return filters;
107: }
108:
109: /**
110: * Sets the list of all filters for this creator.
111: * @param filters the list containing all filters
112: * @see org.directwebremoting.AjaxFilter
113: * @see org.directwebremoting.extend.AjaxFilterManager#addAjaxFilter(org.directwebremoting.AjaxFilter, String)
114: */
115: public void setFilters(List<Object> filters) {
116: this .filters = filters;
117: }
118:
119: /**
120: * Convenience method for adding an authentication rule.
121: * @param method the method to add the authentication rule
122: * @param role the role to add the authentication constraint for
123: * @throws IllegalArgumentException in case the specified argument is null
124: */
125: public void addAuth(String method, String role) {
126: auth.setProperty(method, role);
127: }
128:
129: /**
130: * Convenience method for adding a filter.
131: * @param filter the filter to add for this creator
132: * @throws IllegalArgumentException in case the specified argument is null
133: */
134: public void addFilter(AjaxFilter filter) {
135: filters.add(filter);
136: }
137:
138: /**
139: * The creator type to use
140: */
141: private String creatorType;
142:
143: /**
144: * The creator to use
145: */
146: private Creator creator;
147:
148: /**
149: * The properties containing the method name and the corresponding required role.
150: */
151: private Properties auth = new Properties();
152:
153: /**
154: * The list of filter objects for this creator.
155: */
156: private List<Object> filters = new ArrayList<Object>();
157: }
|