Results 1 to 3 of 3

Thread: why the rcp demo can't work after I add MethodSecurityInterc

  1. #1

    Default why the rcp demo can't work after I add MethodSecurityInterc

    the xml bean define:

    security-context-server.xml:

    /////////////////
    ............
    <bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>

    <bean id="accessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased" >
    <property name="allowIfAllAbstainDecisions"><value>false</value></property>
    <property name="decisionVoters">
    <list>
    <ref bean="roleVoter"/>
    </list>
    </property>
    </bean>

    <bean id="clinicSecurity" class="net.sf.acegisecurity.intercept.method.Metho dSecurityInterceptor">
    <property name="authenticationManager"><ref bean="authenticationManager"/></property>
    <property name="accessDecisionManager"><ref local="accessDecisionManager"/></property>
    <!-- <property name="afterInvocationManager"><ref local="afterInvocationManager"/></property>
    --> <property name="objectDefinitionSource">
    <value>
    org.springframework.samples.petclinic.Clinic.f*=RO LE_CLINIC_CUSTOMER
    </value>
    </property>
    </bean>
    </beans>
    ///////////////
    the bussiness-layer-context.xml add:
    <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor .TransactionInterceptor">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="transactionAttributeSource">
    <value>
    org.springframework.samples.petclinic.Clinic.g*=PR OPAGATION_REQUIRED
    </value>
    </property>
    </bean>

    <bean id="clinic" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces"><value>org.springframework. samples.petclinic.Clinic</value></property>
    <property name="interceptorNames">
    <list>
    <idref local="transactionInterceptor"/>
    <idref bean="clinicSecurity"/>
    <idref local="hsqlClinic"/>
    </list>
    </property>
    </bean>
    ///////////////

    the error is: I can login success, but can/t enter app:


    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 sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.caucho.hessian.io.JavaDeserializer.instantiate (JavaDeserializer.java:170)
    at com.caucho.hessian.io.JavaDeserializer.readMap(Jav aDeserializer.java:112)
    at com.caucho.hessian.io.SerializerFactory.readMap(Se rializerFactory.java:147)
    at com.caucho.hessian.io.HessianInput.readObject(Hess ianInput.java:781)
    at com.caucho.hessian.io.HessianInput.readFault(Hessi anInput.java:624)
    at com.caucho.hessian.io.HessianInput.readReply(Hessi anInput.java:223)
    at com.caucho.hessian.client.HessianProxy.invoke(Hess ianProxy.java:179)
    at $Proxy0.findOwners(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.remoting.caucho.HessianClientI nterceptor.invoke(HessianClientInterceptor.java:12 0)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :143)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy1.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 etClinicClientServer.main(PetClinicClientServer.ja va:41)

  2. #2

    Default the debug step info

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

    The -->
    private static ThreadLocal contextHolder = new ThreadLocal();
    cause the login swing thread and the appwindow create thread not the same ?

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

    Default

    Sorry about this. Petclinic RCP is out of date with current Acegi Security code. I will be revisiting Petclinic RCP integration when Acegi Security 1.0.0 is released.

Similar Threads

  1. Replies: 28
    Last Post: Jun 14th, 2011, 01:48 PM
  2. PagedList demo without using session
    By zcauto in forum Web
    Replies: 5
    Last Post: Oct 13th, 2005, 10:59 AM
  3. Jasper Demo is broken!!!
    By j2eeguru in forum Web
    Replies: 1
    Last Post: Apr 20th, 2005, 04:07 AM
  4. Replies: 3
    Last Post: Dec 22nd, 2004, 02:30 PM
  5. Spring can't work on Eclipse
    By ryanhowai in forum Architecture
    Replies: 1
    Last Post: Nov 9th, 2004, 06:50 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
  •