-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 7/6/20 16:45, Mark Thomas wrote:
> On 06/07/2020 21:23, Christopher Schultz wrote:
>> All,
>>
>> I'm looking at modifying the existing LoadBalancerDrainingValve
>> to also function as a Filter if necessary (my application uses a
>> Filter to establish authentication information, so I'd like the
>> "valve" to act *after* the filter if possible) and it looks like
>> I need access to some Tomcat internals.
>>
>> Specifically, I'd like to be able to get to the
>> org.apache.catalina.Context object for the request. Is this
>> available without reflection and/or other ugly things?
>>
>> Hmm. It looks like a Valve *cannot* be a Filter because of the
>> presence of the incompatible destroy() method.
>>
>> I still want to provide a Filter if possible, so the above
>> question still stands.
>>
>> If the Context isn't available, could it be added to the
>> ServletContext attributes, possibly under a non-reported hash
>> key?
>
> That would create security issues.
>
> A Filter equivalent to ContainerServlet could work - although that
> is a fairly invasive change for something that could be fixed more
> easily.
>
> How about a Valve that injects the necessary internal object(s) as
> request attributes? Alternatively, you could inject some custom
> object that held the references internally and just exposed the
> functionality you wanted to expose.

The calls I'm having trouble with are similar to this one:

        if (drain) {
            boolean ignoreRebalance = false;
            Cookie sessionCookie = null;

            final Cookie[] cookies = request.getCookies();

            final String sessionCookieName =
SessionConfig.getSessionCookieName(request.getContext());


That last call to request.getContext is calling
o.a.c.connector.Request.getContext to hand to
SessionConfig.getSessionCookieName.

This valve also does something similar for
SessionConfig.getSessionCookiePath and
SessionConfig.getSessionUriParamName.

I could read those values from elsewhere (e.g. during startup?), or
even make them init-param of the Filter and avoid the whole thing, but
that does require some additional configuration. The valve is nice and
magical :)

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl8EgfoACgkQHPApP6U8
pFhQaw/9GS6/JH7IGNMhbuRMHwdYBlCLam9cBZuEz1tiJW4F+hk7kr7/phGJu+Sy
DAHPGMIlUpcSaH0KoPnE2OWzM0xqBJydIuoI+pydc1/MEPNVDD/uUbvHyIacRWoa
ucgYbwDDq8n23cujJYstvm4MJBcFOhxgnyaG+XFSUuDUZARCw6hXSJx7kxr+V07z
4K0P0wcYUisPzN3bFQhzRanJ494izfYz0w7AybnmWYPLmBEX5PObt3aYCW6ZaTXs
ajQjyg441pSFkjk1F6MeYJSbAFW+aomU9zrgTgHEcZJ1OkZG6EwS0dD2tbDi7vVU
Ns1jjxDD0ZPgHI9rkiFzhI1gb38/HmbgeU2AIF64r3DIol9/d2R/6bYS5yh6jMXl
1ne5XIXlNq8SLMvbcbCtHE4t5hfKgCQ54jsAY7tgHCRbixwJnftUQMYCfmImuIko
NAQ3BzZw3P04XGXPEDZ0NqKvplxV/yoAf/BtD1xE6bySPoXbrx2UMDEIHU5zeiP8
xH5JC9Dg0Qz6yAEKQd1Sk9BrxmY3Fr4spnVTcuU/fU7OSWF+1vf0wTZ1CT/JcQmB
aYvTQcGYjxi9GynZKDS6TM1kAenul5QF5sDLmLMGtXpzSXjMKK0IEKhpXlG2013F
ktDMhbaM4tXAmZr3lBjpYwYiWSFCZ7tJDflO2EAHbGXweU+ehkQ=
=eS0L
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to