Results 1 to 5 of 5

Thread: Use acegi in a standalone application

  1. #1
    Join Date
    Feb 2005
    Posts
    13

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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

  3. #3

    Default 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?

  4. #4
    Join Date
    Aug 2004
    Posts
    2,715

    Default Re: see spring rcp's demo

    Quote 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

  5. #5
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    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.

Similar Threads

  1. Replies: 2
    Last Post: May 29th, 2008, 12:47 PM
  2. Webservices + web application + swing - acegi
    By amit_shah25 in forum Security
    Replies: 3
    Last Post: Jun 26th, 2005, 09:13 PM
  3. Questioning the core component
    By Martin Kersten in forum Swing
    Replies: 6
    Last Post: Feb 21st, 2005, 03:45 AM
  4. Remote application using Burlap + ACEGI
    By Adventure in forum Security
    Replies: 1
    Last Post: Jan 27th, 2005, 07:00 AM
  5. Replies: 1
    Last Post: Oct 13th, 2004, 03:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •