Results 1 to 4 of 4

Thread: JPA and spring-security 2.0

  1. #1
    Join Date
    Feb 2008
    Posts
    29

    Default JPA and spring-security 2.0

    Hi,


    I'm integrating the just released spring-security 2.0.0-RC1 on my existent application. I already have my own User, UserDao an UserService implementation, based on JPA. In order to my software to work with spring-security I made User implements UserDetails and UserServices to implements UserDetailsService.

    When adding the user service on the security context I cannot load the beans using Spring 2.5 annotation (I'm guessing this happens on security purposes), but I'm finding some problems on injecting the EntityManager on the JPA DAO implementation.

    This code is where I configure spring-security:

    Code:
        <security:http auto-config="true" >
            <security:intercept-url pattern="/spring/login*" access="ROLE_ANONYMOUS" />
            <security:intercept-url pattern="/spring/logout-success*" access="ROLE_ANONYMOUS" />
            
            <security:form-login login-page="/spring/login" login-processing-url="/spring/login-process" default-target-url="/spring/empresa" authentication-failure-url="/spring/login?login_error=1" />
            <security:logout logout-url="/spring/logout" logout-success-url="/spring/logout-success" />
        </security:http>
        
        <security:authentication-provider user-service-ref="usuarioService">
            <security:password-encoder hash="plaintext" />
        </security:authentication-provider>
        
        <bean id="usuarioService" class="com.service.UsuarioService">
            <constructor-arg ref="usuarioDao" />
            <constructor-arg ref="mailSender" />
        </bean>
        
        <bean id="usuarioDao" class="com.repository.jpa.JpaUsuarioDao">
            <property name="entityManager">
                <bean class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
                    <property name="entityManagerFactory" ref="entityManagerFactory"/>	
                </bean>
            </property>
        </bean>
    Is there a better way to use a JPA Dao as the UserDetailsService? Using the above code I'm getting SessionClosed exception.


    Thanks in advance,
    Pedro Casagrande de Campos

  2. #2
    Join Date
    Oct 2006
    Posts
    13

    Default

    Hello,

    I just came across the same issue with a similar configuration. Removing all Spring Security configuration resolved the problem : the annotations were taken into account (Tx support, essentially).

    Regards,
    Xavier

  3. #3
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    Could you post a test case in Jira please and we will look into it.

  4. #4
    Join Date
    Oct 2006
    Posts
    13

    Default

    Hello,

    It's done here : http://jira.springframework.org/browse/SEC-750

    Regards,
    Xavier

Posting Permissions

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