users@jersey.java.net

Re: [Jersey] How to get the value of a PathParam outside a Resource class

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 19 Oct 2009 22:07:53 +0200

Hi Dirk,

See:

   https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/core/UriInfo.html
#getPathParameters%28%29

ContainerRequest implements UriInfo.

Paul.

On Oct 19, 2009, at 5:45 PM, DirkM wrote:

>
> I'm writing a ResourceFilterFactory, and I need to get the value of
> a path
> param, so that I can validate it.
>
> In this case I want to check that the token supplied in the oAuth
> authentication header matches the userId specified in the request:
>
> user/{userId}/getPrivateStuff
>
> if(userId != oAuthUserId) {
> throw AuthenticationException("This is not your stuff");
> }
>
> This is easy enough to do for a single method, but I'd like to do it
> in the
> ResourceFilterFactory so that I can check any method that has a userId
> parameter in the query or path.
>
> I can get the query parameter using
> ContainerRequest.getQueryParameters().containsKey("userId");
> Is it possible to get the PathParam?
>
> Thanks,
> Dirk
> --
> View this message in context: http://n2.nabble.com/How-to-get-the-value-of-a-PathParam-outside-a-Resource-class-tp3849795p3849795.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>