Hi Michal,
Thanks for the help.
Tried this but the SecurityContext doesn't get injected into the custom ResourceMethodDispatchProvider.
~ Barada
@baradasahu
On Jul 17, 2013, at 5:31 PM, Michal Gajdos wrote:
> Hi Barada,
>
> ResourceMethodDispatchProvider are invoked during JAX-RS application creation (i.e. deployment time) and you have no security context available at this time. You can, of course, inject the SecurityContext (it will be a proxy) into your ResourceMethodDispatchProvider implementation (via @Context) but you can't use it sooner than in a RequestDispatcher instance you're creating and returning from the ResourceMethodDispatchProvider#create method:
>
> public class MyDispatchProvider implements ResourceMethodDispatchProvider {
>
> @Context
> private SecurityContext securityContext;
>
> @Override
> public RequestDispatcher create(AbstractResourceMethod abstractResourceMethod) {
> return new RequestDispatcher() {
> @Override
> public void dispatch(final Object resource, final HttpContext context) {
> // Here you can use the SecurityContext.
> // if (securityContext.isSecure()) {
> // ...
> // }
> }
> };
> }
> }
>
> Michal
>
> On 17.07.2013 08:56 , Barada (Personal) wrote:
>> Hi,
>>
>> Am using Jersey 1.17.
>> Am using a custom ResourceMethodDispatchProvider to decorate a resource method.
>>
>> Does Jersey provide any method of doing a class field injection (by using an InjectableProvider) into a custom ResourceMethodDispatchProvider?
>>
>> Am attempting to use the SecurityContext under which the request is executed.
>>
>> ~ Barada
>> @baradasahu
>>
>>
>>
>>
>