Announcement Announcement Module
Collapse
No announcement yet.
Use acegi in a standalone application Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • 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? :?:

    Thanks

  • #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.

    Regards,
    Andreas

    Comment


    • #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 ceptor.java:504)
      at net.sf.acegisecurity.intercept.AbstractSecurityInt erceptor.beforeInvocation(AbstractSecurityIntercep tor.java:380)
      at net.sf.acegisecurity.intercept.method.aopalliance. MethodSecurityInterceptor.invoke(MethodSecurityInt erceptor.java:77)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :143)
      at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:56)
      at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :143)
      at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
      at $Proxy0.findOwners(Unknown Source)
      at org.springframework.richclient.samples.petclinic.u i.OwnerManagerView.createOwnerManagerTree(OwnerMan agerView.java:104)
      at org.springframework.richclient.samples.petclinic.u i.OwnerManagerView.createControl(OwnerManagerView. java:96)
      at org.springframework.richclient.factory.AbstractCon trolFactory.getControl(AbstractControlFactory.java :48)
      at org.springframework.richclient.application.APagePa ne.createControl(APagePane.java:44)
      at org.springframework.richclient.factory.AbstractCon trolFactory.getControl(AbstractControlFactory.java :48)
      at org.springframework.richclient.application.support .AppPage.addView(AppPage.java:189)
      at org.springframework.richclient.application.support .SingleViewPageDescriptor.buildInitialLayout(Singl eViewPageDescriptor.java:60)
      at org.springframework.richclient.application.support .AppPage.getControl(AppPage.java:77)
      at org.springframework.richclient.application.support .DefaultApplicationWindow.applyCustomLayout(Defaul tApplicationWindow.java:237)
      at org.springframework.richclient.application.support .DefaultApplicationWindow.initWindowControl(Defaul tApplicationWindow.java:223)
      at org.springframework.richclient.application.support .DefaultApplicationWindow.initWindow(DefaultApplic ationWindow.java:213)
      at org.springframework.richclient.application.support .DefaultApplicationWindow.showPage(DefaultApplicat ionWindow.java:155)
      at org.springframework.richclient.application.Applica tion.openWindow(Application.java:166)
      at org.springframework.richclient.application.Applica tionLauncher.launchMyRichClient(ApplicationLaunche r.java:178)
      at org.springframework.richclient.application.Applica tionLauncher.<init>(ApplicationLauncher.java:100)
      at org.springframework.richclient.samples.petclinic.P etClinicStandalone.main(PetClinicStandalone.java:4 1)


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

      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();
      sc.setAuthentication(result);
      ContextHolder.setContext(sc);

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

      /////////


      but in methodinvokationinterceptor.java:
      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?

      Comment


      • #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.

        Regards,
        Andreas

        Comment


        • #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.

          Comment

          Working...
          X