001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/security/owsrequestvalidator/Policy.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstr. 19
030: 53115 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042: ---------------------------------------------------------------------------*/
043: package org.deegree.security.owsrequestvalidator;
044:
045: import java.util.HashMap;
046: import java.util.Map;
047:
048: import org.deegree.security.owsproxy.Condition;
049: import org.deegree.security.owsproxy.Request;
050: import org.deegree.security.owsproxy.SecurityConfig;
051:
052: /**
053: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
054: * @author last edited by: $Author: apoth $
055: *
056: * @version $Revision: 9346 $, $Date: 2007-12-27 08:39:07 -0800 (Thu, 27 Dec 2007) $
057: */
058:
059: public class Policy {
060:
061: private SecurityConfig securityConfig;
062:
063: private Map<String, Request> requests;
064:
065: private Condition generalCondition;
066:
067: /**
068: * @param securityConfig
069: * configuration for accessing user based security/right informations
070: * @param requests
071: * description of constraints for several OWS requests
072: * @param generalCondition
073: * general security/right constraints
074: */
075: public Policy(SecurityConfig securityConfig,
076: Condition generalCondition, Request[] requests) {
077: this .requests = new HashMap<String, Request>();
078: this .securityConfig = securityConfig;
079: this .generalCondition = generalCondition;
080: setRequests(requests);
081: }
082:
083: /**
084: * returns the requests/condintions described by a <tt>Policy</tt>. A request objects
085: * contains conditions for each parameter and maybe for combinations of two or more parameters.
086: *
087: * @return the requests/condintions described by a <tt>Policy</tt>.
088: *
089: */
090: public Request[] getRequests() {
091: Request[] req = new Request[requests.size()];
092: return requests.values().toArray(req);
093: }
094:
095: /**
096: * returns one request/condintionset from the <tt>Policy</tt> matching the passed service and
097: * request name. If no request for the passed combination of service and request name is
098: * registered <tt>null</tt> will be returned
099: *
100: * @see #getRequests()
101: * @param service
102: * @param request
103: * @return one request/condintionset from the <tt>Policy</tt> matching the passed service and
104: * request name. If no request for the passed combination of service and request name is
105: * registered <tt>null</tt> will be returned
106: */
107: public Request getRequest(String service, String request) {
108: return requests.get(service + ':' + request);
109: }
110:
111: /**
112: * sets the requests/condintions described by a <tt>Policy</tt>
113: *
114: * @see #getRequests()
115: * @param requests
116: */
117: public void setRequests(Request[] requests) {
118: this .requests.clear();
119: for (int i = 0; i < requests.length; i++) {
120: addRequest(requests[i]);
121: }
122: }
123:
124: /**
125: * adds a request/condintions to the <tt>Policy</tt>
126: *
127: * @see #getRequests()
128: * @param request
129: */
130: public void addRequest(Request request) {
131: String key = request.getService() + ':' + request.getName();
132: this .requests.put(key, request);
133: }
134:
135: /**
136: * removes a request/condintions from the Policy
137: *
138: * @see #getRequests()
139: * @param service
140: * @param name
141: */
142: public void removeRequest(String service, String name) {
143: requests.remove(service + ':' + name);
144: }
145:
146: /**
147: * sets the configuration for access to the configuration of the security persistence mechanim
148: *
149: * @return securityConfig
150: *
151: */
152: public SecurityConfig getSecurityConfig() {
153: return securityConfig;
154: }
155:
156: /**
157: * returns the general conditions that must be fullfilled by a request
158: *
159: * @return the general conditions that must be fullfilled by a request
160: *
161: */
162: public Condition getGeneralCondition() {
163: return generalCondition;
164: }
165:
166: }
|