user2035039 user2035039 - 10 months ago 49
Java Question

How to read webserver environment variables using Apache TomEE?

I am planning to use the Shibboleth SSO Service Provider in my application, which is explained here. It is mentioned, that after a successful login, user information can be

"read from the webserver environment, e.g. with
in PHP".

How do I accomplish this in Java with TomEE?

I am using Apache Web Server in combination with Tomcat, such that servlet requests are forwarded to Tomcat. Is it even possible to access the Apache environment?

Answer Source

According to the documentation of mod_proxy_ajp:

Environment variables whose names have the prefix AJP_ are forwarded to the origin server as AJP request attributes (with the AJP_ prefix removed from the name of the key).

So assuming you configure your Shibboleth SP to decode a SAML Attribute as the webserver environment variable "mail", in your application code you can get the value by using