Menu

Spring integration (realm usage)

tim f
2006-01-12
2013-04-15
  • tim f

    tim f - 2006-01-12

    I'm using v2.0 and have decided to try and integrate things with Spring which is employed elsewhere in my webapp. Specifically I'd like to get the realm as a bean from the Spring WebApplicationContext. This way I could either set the realm from within the filter init method (ignoring the filter config file), or perhaps more generically, there's a Realm wrapper class built which accepts the spring bean name as a realm-param, and delegates to this on all methods. This latter approach would require these changes -

    - Authenticator implementations have a field to hold the realm, but surely this isn't required, since the realm can be accessed from the SecurityRequestWrapper argument. As it is I'd have to hack Authenticator(s) to allow get/set on the realm field.
    - Realm implementations could have an init method (as suggested on this list) to access servletContext (and hence the spring app context)

    Or is there a simpler way I'm not seeing?

    Tim

     
    • Richard Senior

      Richard Senior - 2006-07-18

      Create a new spring config file which JUST has your login definition declared.

      Then in your realm implementation try something like this :

           * @return Returns the loginDelegate.
           */
          public synchronized LoginDelegate getLoginDelegate() {
              if (loginDelegate == null) {
                  ApplicationContext ctx = new ClassPathXmlApplicationContext("com/..../loginContext.xml");
                  loginDelegate = (LoginDelegate) ctx.getBean("loginDelegate");
              }
              return loginDelegate;
          }

      Now you can get the delegate from inside your REALM implementation and hand off the actual work of login to your delegate...

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.