U have to create a binding for the request filter.
Just add in the bind method of ur module something like:

binder.bind(PageRenderRequestFilter.class,
SecurityContextPageRenderRequestFilter.class).withId("securityContextPageRenderRequestFilter");

On Wed, Jul 29, 2009 at 9:51 AM, "Max Weißböck
(info)"<m...@weissboeck.info> wrote:
> Hi Juan, thanks very much!
>
> I'm using Chenillekit Acess too, so  just tried it but I'm having a little
> problem.
> Must be something obvious I can't see ....
>
> I put all your classes in the services directory. The only thing I changed
> is  RincoSessionUser  to my own WebUser class.
>
> On first access to Appliction I'm getting the following error:
>
> [ERROR] ioc.Registry Service id 'securityContextPageRenderRequestFilter' isa
> not defined by any module.  Defined services: AccessValidator,
> ActionRenderResponseGenerator, AdminService, ........
> [ERROR] ioc.Registry Operations trace:
> [ERROR] ioc.Registry [ 1] Realizing service PageRenderRequestHandler
> [ERROR] ioc.Registry [ 2] Invoking
> org.apache.tapestry5.services.TapestryModule.buildPageRenderRequestHandler(List,
> Logger, PageRenderRequestHandlerImpl) (at TapestryModule.java:1415)
> [ERROR] ioc.Registry [ 3] Determining injection value for parameter #1
> (java.util.List)
> [ERROR] ioc.Registry [ 4] Collecting ordered configuration for service
> PageRenderRequestHandler
> [ERROR] ioc.Registry [ 5] Invoking method
> net.weissboeck.gimmo.services.AppModule.contributePageRenderRequestHandler(OrderedConfiguration,
> PageRenderRequestFilter) (at AppModule.java:227).
> [ERROR] ioc.Registry [ 6] Determining injection value for parameter #2
> (org.apache.tapestry5.services.PageRenderRequestFilter)
> [ERROR] TapestryModule.PageRenderRequestHandler Construction of service
> PageRenderRequestHandler failed: Error invoking service builder method
> org.apache.tapestry5.services.TapestryModule.buildPageRenderRequestHandler(List,
> Logger, PageRenderRequestHandlerImpl) (at TapestryModule.java:1415) (for
> service 'PageRenderRequestHandler'): Error invoking service contribution
> method
> net.weissboeck.gimmo.services.AppModule.contributePageRenderRequestHandler(OrderedConfiguration,
> PageRenderRequestFilter): Service id
> 'securityContextPageRenderRequestFilter' is not defined by any module.
>  Defined services: AccessValidator, ActionRenderResponseGenerator,
> AdminService, .......
> java.lang.RuntimeException: Error invoking service builder method
> org.apache.tapestry5.services.TapestryModule.buildPageRenderRequestHandler(List,
> Logger, PageRenderRequestHandlerImpl) (at TapestryModule.java:1415) (for
> service 'PageRenderRequestHandler'): Error invoking service contribution
> method
> net.weissboeck.gimmo.services.AppModule.contributePageRenderRequestHandler(OrderedConfiguration,
> PageRenderRequestFilter): Service id
> 'securityContextPageRenderRequestFilter' is not defined by any module.
>  Defined services: AccessValidator, ActionRenderResponseGenerator,
> AdminService, ......
>        at
> org.apache.tapestry5.ioc.internal.ServiceBuilderMethodInvoker.createObject(ServiceBuilderMethodInvoker.java:76)
>        at
> org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator$1.invoke(OperationTrackingObjectCreator.java:45)
>        at
> org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:68)
>        at
> org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68)
>        at
> org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:941)
>        at
> org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator.createObject(OperationTrackingObjectCreator.java:49)
>        at
> org.apache.tapestry5.ioc.internal.SingletonServiceLifecycle.createService(SingletonServiceLifecycle.java:29)
>        at
> org.apache.tapestry5.ioc.internal.LifecycleWrappedServiceCreator.createObject(LifecycleWrappedServiceCreator.java:46)
>
>
>
>
> Am 28.07.2009 um 01:06 schrieb Juan E. Maya:
>
>> What i am doing is to contribute a PageRenderRequestHandler like this:
>>
>>        public static void
>>
>> contributePageRenderRequestHandler(OrderedConfiguration<PageRenderRequestFilter>
>> configuration,
>>                        final @Local
>> @InjectService("securityContextPageRenderRequestFilter")
>> PageRenderRequestFilter securityContextPageRenderRequestFilter) {
>>                configuration.add("securityContext",
>> securityContextPageRenderRequestFilter, "after:*");
>>        }
>>
>> I am using Chenillekit's access component:
>> (http://www.chenillekit.org/chenillekit-access/index.html) so in the
>> filter i get the WebSessionUser using the ApplicationStateManager.
>> Here u should get the object from the session. Just be sure that the
>> filter is executed after the WebSessionUser is put into the session.
>> the filter look like this:
>>
>> public class SecurityContextPageRenderRequestFilter implements
>> PageRenderRequestFilter {
>>
>>        private final ApplicationStateManager _manager;
>>        private final Logger _logger;
>>
>>        /**
>>         * @param manager
>>         * @author jmayaalv
>>         */
>>        public
>> SecurityContextPageRenderRequestFilter(ApplicationStateManager
>> manager, Logger logger) {
>>                super();
>>                _manager = manager;
>>                _logger = logger;
>>        }
>>
>>        public void handle(PageRenderRequestParameters parameters,
>> PageRenderRequestHandler handler) throws IOException {
>>                RincoSessionUser webSessionUser = (RincoSessionUser)
>> _manager.getIfExists(WebSessionUser.class);
>>                if (webSessionUser != null) {
>>                        SecurityContext securityContext = new
>> SecurityContext(webSessionUser.getUserId());
>>                        SecurityContextHolder.set(securityContext);
>>                        _logger.debug("SecurityContext added to the thread
>> {} ", new
>> Object[] { securityContext });
>>                }
>>                handler.handle(parameters);
>>        }
>> }
>>
>> SecurityContextHolder is the class that interacts with threadlocal:
>>
>> public class SecurityContextHolder {
>>
>>        private static ThreadLocal<SecurityContext> tLocal = new
>> ThreadLocal<SecurityContext>();
>>
>>        public static void set(SecurityContext securityContext) {
>>                tLocal.set(securityContext);
>>        }
>>
>>        public static SecurityContext get() {
>>                return tLocal.get();
>>        }
>>
>>        public static void remove() {
>>                tLocal.remove();
>>        }
>>
>> }
>>
>> U can get the SecurityContext during the thread execution with:
>> SecurityContextHolder.get()
>>
>> Let me know if u need something else
>>
>>
>> On Tue, Jul 28, 2009 at 12:25 AM, "Max Weißböck
>> (info)"<m...@weissboeck.info> wrote:
>>>
>>> Ok, I think I get the idea...
>>>
>>> But where and when do you set the ThreadLocal? It must be set on every
>>> request (each request is another thread...)
>>> Do you have a common base class where you handle this? Any other way you
>>> do
>>> it?
>>>
>>> Max
>>>
>>>
>>> Am 28.07.2009 um 00:08 schrieb Juan E. Maya:
>>>
>>>> Hey Max, I had a similar problem and at the end create an object in
>>>> the ThreadLocal that contains a SecurityContext with the user
>>>> information (very lightweight object). The idea was taken from
>>>> Spring-Security. This way u have access to the user in the execution
>>>> thread. It was kind of weird for me to be accessing the HttpSession in
>>>> all the layers of the application.
>>>>
>>>>
>>>> On Mon, Jul 27, 2009 at 11:18 PM, "Max Weißböck
>>>> (info)"<m...@weissboeck.info> wrote:
>>>>>
>>>>> Sorry, my question seems not to be clear.
>>>>>
>>>>> It is not a Hibernate question, I now how to acces and set the
>>>>> attributes
>>>>> using the event.
>>>>> I already set the creation and modification date in each entity.
>>>>>
>>>>> But what I need too, is who (which user) did the creation/modification
>>>>> of
>>>>> an
>>>>> entity.
>>>>> This information (the user) is in an SSO (WebUser in my case) but I
>>>>> could
>>>>> not figure out,
>>>>> how I can get access to this SSO from the Hibernate Listener Class.
>>>>>
>>>>> thx, Max
>>>>>
>>>>> Am 27.07.2009 um 22:42 schrieb Igor Drobiazko:
>>>>>
>>>>>> This is a Hibernate question, not Tapestry. Have a look into the event
>>>>>> passed to your listener.
>>>>>> There is a method called getEntity().
>>>>>>
>>>>>> On Mon, Jul 27, 2009 at 10:34 PM, Max Weißböck (info)
>>>>>> <m...@weissboeck.info>wrote:
>>>>>>
>>>>>>> I'm using Hibernate Listeners PreUpdateEventListener and
>>>>>>> PreInsertEventListener to do audit logging in the DB.
>>>>>>>
>>>>>>> Now my problem is, how can I get access in the EventListenr class to
>>>>>>> the
>>>>>>> SSO where the user is stored? As Hibernate loads
>>>>>>> the classes as defined in the config file (see below), I can not bind
>>>>>>> them
>>>>>>> using AppModule and @Inject something - or at least I do not know
>>>>>>> how.
>>>>>>>
>>>>>>> I searched the list but found no solution (or did not understand it
>>>>>>> ;-)
>>>>>>>
>>>>>>> Thx, Max
>>>>>>>
>>>>>>> --- definition in hibernate.cfg.xml ---
>>>>>>>
>>>>>>> <!-- Audit Listener -->
>>>>>>> <listener type="pre-insert"
>>>>>>> class="net.weissboeck.gimmo.entities.AuditListenerImpl"/>
>>>>>>> <listener type="pre-update"
>>>>>>> class="net.weissboeck.gimmo.entities.AuditListenerImpl"/>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Best regards,
>>>>>>
>>>>>> Igor Drobiazko
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to