Announcement Announcement Module
Collapse
No announcement yet.
Add Exeption Handling (Plain Java Program) Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Add Exeption Handling (Plain Java Program)

    I have a java program without any other framework (except spring :-) )

    I want that all exceptions thrown to be caught (and logged).

    Searching confused me more and more...please tell me where to add which property. (And the method needed for the corresponding bean)
    ..if possible for dummies, please

    Thanks in advance.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

    <beans>

    <bean id="serverManagementSecurityInterceptor" class="org.acegisecurity.intercept.method.aopallia nce.MethodSecurityInterceptor">
    <property name="authenticationManager"
    ref="authenticationManager" />
    <property name="accessDecisionManager"
    ref="accessDecisionManager" />


    <property name="objectDefinitionSource">
    <value>
    xx.xxx.loginserver.Server.*=ROLE_READ
    </value>
    </property>
    </bean>
    <bean id="accessDecisionManager" class="org.acegisecurity.vote.AffirmativeBased" >
    <property name="decisionVoters">
    <list>
    <bean class="org.acegisecurity.vote.RoleVoter">
    <property name="rolePrefix" value="ROLE_" />
    </bean>
    </list>
    </property>
    </bean>
    <bean id="authenticationManager"
    class="org.acegisecurity.providers.ProviderManager " >
    <property name="providers">
    <list>
    <ref local="authenticationProvider" />
    </list>
    </property>
    </bean>

    <bean id="authenticationProvider"
    class="org.acegisecurity.providers.dao.DaoAuthenti cationProvider">
    <property name="userDetailsService" ref="authenticationDao"/>
    <property name="hideUserNotFoundExceptions" value="false" />
    </bean>


    <!-- TODO REPLACE IN MEMORY DAO -->
    <bean id="authenticationDao"
    class="org.acegisecurity.userdetails.memory.InMemo ryDaoImpl">
    <property name="userMap">
    <value>
    user1=xxx, ROLE_READ
    user2=xxx2,ROLE_READ,ROLE_WRITE
    </value>
    </property>
    </bean>


    <bean id="autoProxyCreator"
    class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="interceptorNames">
    <list>
    <value>serverManagementSecurityInterceptor</value>
    </list>
    </property>
    <property name="beanNames">
    <list>
    <value>server</value>
    </list>
    </property>
    <property name="proxyTargetClass" value="true" />
    </bean>


    <bean id="server" class="xx.xxx.loginserver.Server" />


    </beans>

    I mean exceptions like "Accessdenied" or "BadCredentials"....
    Last edited by Re-Rei-Rev; Mar 12th, 2007, 07:10 AM.

  • #2
    Just to clarify when you say you want all exceptions to be caught and logged, what do you actually mean here?

    Comment


    • #3
      I mean all exceptions thrown by acegi, like when entering bad credentials or invoking a secured method.

      Is there a way similar to the in Spring?

      public void afterThrowing(Method method, Object[] args, Object target,
      Exception ex) throws Throwable
      Last edited by Re-Rei-Rev; Mar 13th, 2007, 02:45 AM.

      Comment


      • #4
        Acegi fires lots of events so you could just write a listener that logs the errors, this has been covered a few times on the forum. Otherwise you'd have to write an interceptor to do it.

        Comment

        Working...
        X