Announcement Announcement Module
No announcement yet.
Use acegi in a standalone application Page Title Module
Move Remove Collapse
This topic is closed
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use acegi in a standalone application

    I'm developing a web based application with Spring and Acegi.
    I have to develop a standalone application (it'll use the same Spring configuration files) in order to load legacy data on demand or with Quartz (everything will be on the same server) every night.
    My question is: is it possible to use the Acegi for authentication in the standalone application? :?:


  • #2
    I am also interested in this, since I have a similar problem.

    I plan to have a Spring-enabled application within an application server (EJB facades with spring-configured POJOs behind).

    The EJBs should be accessed by both a web application and a standalone swing-based application (via RMI).

    How can Acegi Security support this case? Especially, the login and authentification in the case of the standalone application is not clear to me.



    • #3
      see spring rcp's demo

      int springrcp ,there is a petclinic demo for rpc standlone and c/s demo.

      but I find some error: when I have login in successful. the error:

      ERROR org.springframework.richclient.application.Applica tionLauncher - Exception occured initializing Application bean
      net.sf.acegisecurity.AuthenticationCredentialsNotF oundException: A valid SecureContext was not provided in the RequestContext
      at net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor.credentialsNotFound(AbstractSecurityInter
      at net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor.beforeInvocation(AbstractSecurityIntercep
      at net.sf.acegisecurity.intercept.method.aopalliance. MethodSecurityInterceptor.invoke(MethodSecurityInt
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :143)
      at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:56)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed( :143)
      at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(
      at $Proxy0.findOwners(Unknown Source)
      at org.springframework.richclient.samples.petclinic.u i.OwnerManagerView.createOwnerManagerTree(OwnerMan
      at org.springframework.richclient.samples.petclinic.u i.OwnerManagerView.createControl(OwnerManagerView. java:96)
      at org.springframework.richclient.factory.AbstractCon trolFactory.getControl( :48)
      at org.springframework.richclient.application.APagePa ne.createControl(
      at org.springframework.richclient.factory.AbstractCon trolFactory.getControl( :48)
      at .AppPage.addView(
      at .SingleViewPageDescriptor.buildInitialLayout(Singl
      at .AppPage.getControl(
      at .DefaultApplicationWindow.applyCustomLayout(Defaul
      at .DefaultApplicationWindow.initWindowControl(Defaul
      at .DefaultApplicationWindow.initWindow(DefaultApplic
      at .DefaultApplicationWindow.showPage(DefaultApplicat
      at org.springframework.richclient.application.Applica tion.openWindow(
      at org.springframework.richclient.application.Applica tionLauncher.launchMyRichClient(ApplicationLaunche
      at org.springframework.richclient.application.Applica tionLauncher.<init>(
      at org.springframework.richclient.samples.petclinic.P etClinicStandalone.main( 1)

      ,I have step into, i find login form set context successful:
      public void login() throws AuthenticationException {
      // Attempt login
      UsernamePasswordAuthenticationToken request = new UsernamePasswordAuthenticationToken(getUsername(),

      Authentication result = authenticationManager.authenticate(request);

      // Setup a secure ContextHolder (if required)
      if (ContextHolder.getContext() == null || !(ContextHolder.getContext() instanceof SecureContext)) {
      try {
      ContextHolder.setContext((SecureContext)getSecureC ontextClass().newInstance());
      catch (Exception e) {
      throw new RuntimeException(e);

      // Commit the successful Authentication object to the secure
      // ContextHolder
      SecureContext sc = (SecureContext)ContextHolder.getContext();

      // Fire application event to advise of new login
      ApplicationContext appCtx =;
      appCtx.publishEvent(new LoginEvent(result));


      but in
      if ((ContextHolder.getContext() == null)
      || !(ContextHolder.getContext() instanceof SecureContext)) {
      credentialsNotFound("A valid SecureContext was not provided in the RequestContext",
      object, attr);

      get the" ContextHolder.getContext() =" null

      they are all static member in ContextHolder. why in the interceptor call it get a null return?


      • #4
        Re: see spring rcp's demo

        Originally posted by lin_xd
        int springrcp ,there is a petclinic demo for rpc standlone and c/s demo.
        Thanks for the hint. I guess then net.sf.acegisecurity.providers.rcp.RemoteAuthentic ationProvider does the job. By scanning through the documentation I haven't found it.

        May I suggest to place the RCP use case more prominently in the documentation? I always had a notion of Acegi Security being a more or less pure web-based security solution, but it seems to provide more value than it seems on first glance.



        • #5
          Sorry, Petclinic Rich Client has fallen out of sync with the current Acegi Security latest releases.

          I am a committer to the Rich Client project, but haven't had much time recently do go and fix it. I will ensure it works with Acegi Security 1.0.0 when released. In the meantime, if you follow the upgrade-xx-xx.txt files from the current Petclinic acegi-security.jar version, you should have no difficult migrating in your own application.