Custom security realm and spring context

colr__
colr__ used Ask the Experts™
on
I have a Tomcat based web application that uses a custom security realm. Within the security realm I need access to a spring-managed bean, but the security realm interface doesnt provide any access to the servlet context or any other way for me to get access to the spring context.

Anybody got any ideas how I could get access to the spring context? I can't initialise the security realm in spring either as it is managed by the web container.

The security realm superclass is here: SimpleSecurityRealmBase
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Java Developer
Top Expert 2010
Commented:
the realm has nothing to do with spring so you cannot access spring from it.

what you instead need to access the spring context if the servlet context

WebApplicationContext sprintContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
If the security realm is managed by Tomcat at the container level and not at the webapp level, you may not be able to access your app's spring context because the container has no knowledge of it.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial