Re: T5: AccessController Dispatcher asm.exists() not working?
On Thu, Sep 10, 2009 at 7:06 PM, neo anderson wrote: > Is this the same way as explained in > http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher2? Or what's > difference between this srategy? The chenillekit access module comes from the experience that made up the wiki doc. Cheers -- Massimo http://meridio.blogspot.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: AccessController Dispatcher asm.exists() not working?
I am trying to do authorization stuff, but how to configure so that UserPermissions.class can be obtained using ApplicationStateManger.exists(UserPermissions.class) method? What I want to do is user request -> AccessController (Dispatcher) -> News (Page) User will click the url and then AccessController will check using ApplicationStateManager.exists() method, in which to check if user has privilege to access to the Page `News' class. I check the SessionApplicationStatePersistenceStrategy.java, discovering that it will lookup http session to see if class exists or not, but I can not figure out how to get UserPermission created so that when executing ApplicationStateManager.exists(), it will return true. public boolean exists(Class ssoClass) { String key = buildKey(ssoClass); Session session = request.getSession(false); return session != null && session.getAttribute(key) != null; } In addition, after reading the chenillenKit source code, I disocover that seemingly ChenilleKitAccessModule will build the AccessValidator (the same as UserPermission) first and then directly using that instance in PageRenderAccessFilter (that implements PageRenderRequestFilter). ChenilleKitAccessModule.java public static AccessValidator buildAccessValidator(ComponentSource componentSource, ...){ ... return new AccessValidatorImpl(componentSource, locator, logger, manager, webSessionUserClass); } PageRenderAccessFilter.java public void handle(PageRenderRequestParameters parameters, PageRenderRequestHandler handler) throws IOException{ ... if ( !accessValidator.hasAccess(parameters.getLogicalPageName(), null, null) ) ... ... } Is this the same way as explained in http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher2? Or what's difference between this srategy? Thanks for help. Howard Lewis Ship wrote: > > exists() looks for an instance in the HttpSession ... what is supposed > to be creating this instance? > > On Tue, Mar 31, 2009 at 3:52 AM, Kasper wrote: >> Hi, >> >> I am trying to create a dispatcher to define the access levels for the >> current user. I have followed the steps from the Wiki pages: >> http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher >> http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher2 >> >> This seems to work. But as I try to do asm.exists(UserPermissions.class) >> it >> returns false. I checked the classpath for the class >> my.project.services.UserPermissions. And there it does exist. I also >> tried >> to make it an interface but this didn't work out either. >> >> My classes: >> -- >> AccessController.java: >> >> public class AccessController implements Dispatcher { >> >> private ApplicationStateManager asm; >> >> public AccessController(ApplicationStateManager asm) { >> this.asm = asm; >> } >> >> public boolean dispatch(Request request, Response response) throws >> IOException { >> boolean canAccess = true; // to avoid the access violation >> for now >> >> if (asm.exists(UserPermissions.class)) { >> UserPermissions perms = >> asm.get(UserPermissions.class); >> >> canAccess = perms.canAccess(request); >> } >> >> if (!canAccess) { >> throw new RuntimeException("Access violation!"); >> } >> >> return false; >> } >> } >> >> -- >> UserPermissions.java: >> >> public class UserPermissions { >> >> public boolean canAccess(Request request) { >> return true; >> } >> >> } >> -- >> AppModule.java: >> >> public class AppModule { >> >> public static void bind(ServiceBinder binder) { >> >> binder.bind(AccessController.class).withId("AccessController"); >> } >> >> public void >> contributeMasterDispatcher(OrderedConfiguration >> configuration, >> �...@injectservice("AccessController") Dispatcher >> accessController) { >> configuration.add("AccessController", accessController, >> "before:PageRender"); >> } >> } >> -- >> >> Does anyone have a clue what I am doing wrong? >> >> Yours, >> Kasper >> >> >> This message was sent using IMP, the Internet Messaging Program. >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additi
Re: T5: AccessController Dispatcher asm.exists() not working?
On Tue, Mar 31, 2009 at 12:52 PM, Kasper wrote: > Hi, > > I am trying to create a dispatcher to define the access levels for the > current user. I have followed the steps from the Wiki pages: Look at the access module of the ChenilleKit project: http://tapestry.formos.com/nightly/chenille-kit/ You can use it for your purpose or as a reference/example on how to operate. Remember that chenillekit trunk is based on 5.1.0.2 Regards -- Massimo http://meridio.blogspot.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: AccessController Dispatcher asm.exists() not working?
exists() looks for an instance in the HttpSession ... what is supposed to be creating this instance? On Tue, Mar 31, 2009 at 3:52 AM, Kasper wrote: > Hi, > > I am trying to create a dispatcher to define the access levels for the > current user. I have followed the steps from the Wiki pages: > http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher > http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher2 > > This seems to work. But as I try to do asm.exists(UserPermissions.class) it > returns false. I checked the classpath for the class > my.project.services.UserPermissions. And there it does exist. I also tried > to make it an interface but this didn't work out either. > > My classes: > -- > AccessController.java: > > public class AccessController implements Dispatcher { > > private ApplicationStateManager asm; > > public AccessController(ApplicationStateManager asm) { > this.asm = asm; > } > > public boolean dispatch(Request request, Response response) throws > IOException { > boolean canAccess = true; // to avoid the access violation > for now > > if (asm.exists(UserPermissions.class)) { > UserPermissions perms = > asm.get(UserPermissions.class); > > canAccess = perms.canAccess(request); > } > > if (!canAccess) { > throw new RuntimeException("Access violation!"); > } > > return false; > } > } > > -- > UserPermissions.java: > > public class UserPermissions { > > public boolean canAccess(Request request) { > return true; > } > > } > -- > AppModule.java: > > public class AppModule { > > public static void bind(ServiceBinder binder) { > > binder.bind(AccessController.class).withId("AccessController"); > } > > public void > contributeMasterDispatcher(OrderedConfiguration configuration, > �...@injectservice("AccessController") Dispatcher > accessController) { > configuration.add("AccessController", accessController, > "before:PageRender"); > } > } > -- > > Does anyone have a clue what I am doing wrong? > > Yours, > Kasper > > > This message was sent using IMP, the Internet Messaging Program. > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
T5: AccessController Dispatcher asm.exists() not working?
Hi, I am trying to create a dispatcher to define the access levels for the current user. I have followed the steps from the Wiki pages: http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher2 This seems to work. But as I try to do asm.exists(UserPermissions.class) it returns false. I checked the classpath for the class my.project.services.UserPermissions. And there it does exist. I also tried to make it an interface but this didn't work out either. My classes: -- AccessController.java: public class AccessController implements Dispatcher { private ApplicationStateManager asm; public AccessController(ApplicationStateManager asm) { this.asm = asm; } public boolean dispatch(Request request, Response response) throws IOException { boolean canAccess = true; // to avoid the access violation for now if (asm.exists(UserPermissions.class)) { UserPermissions perms = asm.get(UserPermissions.class); canAccess = perms.canAccess(request); } if (!canAccess) { throw new RuntimeException("Access violation!"); } return false; } } -- UserPermissions.java: public class UserPermissions { public boolean canAccess(Request request) { return true; } } -- AppModule.java: public class AppModule { public static void bind(ServiceBinder binder) { binder.bind(AccessController.class).withId("AccessController"); } public void contributeMasterDispatcher(OrderedConfiguration configuration, @InjectService("AccessController") Dispatcher accessController) { configuration.add("AccessController", accessController, "before:PageRender"); } } -- Does anyone have a clue what I am doing wrong? Yours, Kasper This message was sent using IMP, the Internet Messaging Program. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org