source: branches/TaskRewrite/src/plugins/acegi-0.5.1/src/groovy/org/codehaus/groovy/grails/plugins/springsecurity/RequestmapFilterInvocationDefinitionHelper.groovy @ 58

Last change on this file since 58 was 58, checked in by gav, 15 years ago

Configure BootStrap? with latest concepts.
Install and setup Acegi plugin with custom views.
Test Fixture plugin in a test app but couldn't get it to work with Acegi encodePassword() so gave up.

File size: 2.2 KB
Line 
1/* Copyright 2006-2009 the original author or authors.
2*
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7*      http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15package org.codehaus.groovy.grails.plugins.springsecurity
16
17import org.codehaus.groovy.grails.commons.ApplicationHolder as AH
18
19/**
20 * Helper class for RequestmapFilterInvocationDefinition to perform Requestmap dynamic query.
21 *
22 * @author <a href='mailto:beckwithb@studentsonly.com'>Burt Beckwith</a>
23 */
24class RequestmapFilterInvocationDefinitionHelper {
25
26        private String _requestMapClass // 'Requestmap'
27        private String _requestMapPathFieldName // 'url'
28        private String _requestMapConfigAttributeField // 'configAttribute'
29
30        /**
31         * Constructor.
32         * @param requestMapClass  Requestmap class name
33         * @param requestMapPathFieldName  Requestmap path pattern field name
34         * @param requestMapConfigAttributeField  Requestmap config attribute (roles) field name
35         */
36        RequestmapFilterInvocationDefinitionHelper(String requestMapClass,
37                        String requestMapPathFieldName, String requestMapConfigAttributeField) {
38                _requestMapClass = requestMapClass
39                _requestMapPathFieldName = requestMapPathFieldName
40                _requestMapConfigAttributeField = requestMapConfigAttributeField
41        }
42
43        /**
44         * Load all Requestmaps and build a map with the relevant data.
45         * @return keys are url patterns, values are roles
46         */
47        Map<String, String> loadRequestmaps() {
48                Class requestmapClass = AH.application.getClassForName(_requestMapClass)
49                Map<String, String> data = [:]
50                def requestmaps = requestmapClass.list()
51                for (requestmap in requestmaps) {
52                        String urlPattern = requestmap."${_requestMapPathFieldName}"
53                        String configAttribute = requestmap."${_requestMapConfigAttributeField}"
54                        data[urlPattern] = configAttribute
55                }
56
57                return data
58        }
59}
Note: See TracBrowser for help on using the repository browser.