users@jersey.java.net

Principal injection?

From: Zoltan Arnold NAGY <Zoltan.Nagy_at_Sun.COM>
Date: Wed, 04 Nov 2009 15:09:39 +0100

Hi,

I'm wondering if there's a better way.. I'm currently doing it like this:
@Path("/d")
public class DatasResource {
    @Context
    private SecurityContext securityContext;

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public Response addData(Sample s) {
        User user =
((InternalPrincipal)securityContext.getUserPrincipal()).getUser();
..
}

my own filter sets the appropriate principal (and securitycontext), and it's
always set.

Thanks,
Zoltan