Note that there are some explanatory texts on larger screens.

plurals
  1. POJersey + Spring Context Outside of Controller
    primarykey
    data
    text
    <p>I have a Spring bean that needs information from the request, but isn't directly called from the controller (although it could be - but I'd like to try this without it)</p> <p>Basically, my API makes requests to other services over thrift. When it makes the request, there's a service call like this:</p> <pre><code>authenticationService.authenticate(null, "username", "password"); </code></pre> <p>The first parameter (the <code>null</code>) is usually a "placeholder" instance of a request context. The request context contains information about the user making the request, the originating IP, etc. This way, I get all of the details about the original caller without letting my API infrastructure leak into the backend.</p> <p>However, to do this, I have an <code>InvocationHandler</code> that intercepts method calls made against a proxy of my service interfaces. Inside of that proxy handler, I have a <code>RequestContextFactory</code> wired in that creates instances of a <code>RequestContext</code>. Inside of this factory, I need to get information from the request. Particularly, the <code>SecurityContext</code>, so I can identify the user making the call.</p> <p>Right now, I have:</p> <pre><code>@Provider @Component public class WebRequestContextFactory implements RequestContextFactory { @Context private ContainerRequest containerRequest; public RequestContext createRequestContext() { } } </code></pre> <p>Unfortunately, <code>containerRequest</code> is always <code>null</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload