Announcement Announcement Module
Collapse
No announcement yet.
Convert Hispacta to annotations Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert Hispacta to annotations

    My team prefers to use the source annotations over the XML definition, so to learn more about them we're converting Hispacta to use the annotations instead of its XML definition.

    I changed the XML file to look like the example in the Acegi docs, and added the annotations to the source file on the methods that were mentioned in the XML file (and no others). I also had to change the "allowIfAllAbstain" attribute to true, but I think this gives me more access than I should have.

    Currently, if I try to access the /home page, I get an exception that it cannot find the AuthenticationCredentials. I'm not sure why I get this, since I didn't change the web.xml file.

    Has anyone else done this, and what steps did you take?

    (piece of the XML file)
    Code:
    <bean id="attributes" 
        class="org.springframework.metadata.commons.CommonsAttributes"/>
        
      <bean id="objectDefinitionSource" 
        class="net.sf.acegisecurity.intercept.method.MethodDefinitionAttributes">
        <property name="attributes">
          <ref local="attributes"/>
        </property>
      </bean>
      
      <bean id="personnelSecurity" 
        class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
        <property name="authenticationManager">
          <ref bean="authenticationManager"/>
        </property>
        <property name="accessDecisionManager">
          <ref bean="accessDecisionManager"/>
        </property>
        <property name="objectDefinitionSource">
          <ref bean="objectDefinitionSource"/>
        </property>
      </bean>
      
      <bean id="personnelService" 
        class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="proxyInterfaces">
          <value>hispacta.service.PersonnelService</value>
        </property>
        <property name="interceptorNames">
          <list>
            <value>personnelSecurity</value>
            <value>personnelServiceTarget</value>
          </list>
        </property>
      </bean>
      
      <bean id="homeServiceTarget" class="hispacta.service.impl.HomeServiceImpl">
        <property name="newsDao">
          <ref local="newsDao"/>
        </property>
      </bean>
      
      <bean id="homeSecurity" 
        class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
        <property name="authenticationManager">
          <ref bean="authenticationManager"/>
        </property>
        <property name="accessDecisionManager">
          <ref bean="accessDecisionManager"/>
        </property>
        <property name="objectDefinitionSource">
          <ref bean="objectDefinitionSource"/>
        </property>
      </bean>
      
      <bean id="homeService" 
        class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="proxyInterfaces">
          <value>hispacta.service.HomeService</value>
        </property>
        <property name="interceptorNames">
          <list>
            <value>homeSecurity</value>
            <value>homeServiceTarget</value>
          </list>
        </property>
      </bean>

  • #2
    Re: Convert Hispacta to annotations

    Originally posted by jasonab
    My team prefers to use the source annotations over the XML definition, so to learn more about them we're converting Hispacta to use the annotations instead of its XML definition.
    I am unsure what version of Acegi Security that Hispacta uses, and whether you're trying to use a more recent version of Acegi Security with it. As indicated in the upgrade-xx-xx.txt files, we've continued to refactor the project and chances are that the configuration is wrong. The exception you're getting sounds more a case of the ContextHolder not contain an Authentication - as opposed to a problem with annotation-based configuration.

    Speaking of annotations, I'd suggest you look at http://acegisecurity.sourceforge.net/articles.html, which links to a JDK1.5 annotation-based solution you could consider using with Acegi Security. It's probably better moving to JDK1.5 annotations than using Commons Attributes.

    Comment


    • #3
      Re: Convert Hispacta to annotations

      Originally posted by Ben Alex
      I am unsure what version of Acegi Security that Hispacta uses, and whether you're trying to use a more recent version of Acegi Security with it.
      Thanks, Ben, I forgot about that. I suspect that is complicating things.

      Speaking of annotations, I'd suggest you look at http://acegisecurity.sourceforge.net/articles.html, which links to a JDK1.5 annotation-based solution you could consider using with Acegi Security. It's probably better moving to JDK1.5 annotations than using Commons Attributes.
      Well, obviously that tends to open up a different can of worms, but we'll certainly consider it.

      Comment

      Working...
      X