Announcement Announcement Module
Collapse
No announcement yet.
why the rcp demo can't work after I add MethodSecurityInterc Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


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

      Comment

      Working...
      X