In my daily job I’m a building SmartGWT application on top of grails server layer. I came to the point that I need all of +100 controllers to be secure. Moreover I need to distinguish which controllers actions should be given certain permissions. That’s a tough (boring) thing to do for that number of controllers.
Not to go deep into technical stuff I choosed SpringSecurity annotations to achive my goal. Again - when processing that number of controllers you can easily make mistake. I knew that I was lacking some solution that could help me manage what controller methods I should path and how. I needed to simply list all actions of the controller.
As usually I found my answer on stackoverflow:
import org.springframework.beans.BeanWrapper
import org.springframework.beans.PropertyAccessorFactory
def data = []
for (controller in grailsApplication.controllerClasses) {
def controllerInfo = [:]
controllerInfo.controller = controller.logicalPropertyName
controllerInfo.controllerName = controller.fullName
List actions = []
BeanWrapper beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(controller.newInstance())
for (pd in beanWrapper.propertyDescriptors) {
String closureClassName = controller.getPropertyOrStaticPropertyOrFieldValue(pd.name, Closure)?.class?.name
if (closureClassName) actions << pd.name
}
controllerInfo.actions = actions.sort()
data << controllerInfo
}
Recent comments
1 year 20 weeks ago
1 year 20 weeks ago
1 year 27 weeks ago
1 year 29 weeks ago
1 year 47 weeks ago
1 year 49 weeks ago
1 year 49 weeks ago
1 year 49 weeks ago
1 year 49 weeks ago
1 year 49 weeks ago