我的MySql数据库是大小写敏感的,在hibernate中一切正常,数据库中的表名和我的类是一样的。但是在Spring Security上,默认的身份验证不能很好地工作,使用表名的第一个字母小写而不是大写来构建SQL。有没有办法让spring security像hibernate一样理解大写?或者,我是否只需要构建一个自定义身份验证来将表名改为大写字母?
<!-- Session Factory Hibernate -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="packagesToScan" value="br.com.empresa.domain" />
<property name="dataSource">
<ref local="mySQLdataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
<!-- Novos geradores de ids recomendados pela documentação do hibernate -->
<prop key="hibernate.id.new_generator_mappings">false</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Conexão com o Banco de Dados -->
<bean id="mySQLdataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/db" /> -->
<property name="username" value="root" />
<property name="password" value="asd123456" />
</bean>
<!-- It is responsible for validating the user's credentials -->
<security:authentication-manager>
<!-- It is responsible for providing credential validation to the AuthenticationManager -->
<security:authentication-provider>
<security:password-encoder ref="passwordEncoder" />
<security:jdbc-user-service
data-source-ref="mySQLdataSource" />
</security:authentication-provider>
</security:authentication-manager>
<bean
class="org.springframework.security.crypto.password.StandardPasswordEncoder"
id="passwordEncoder" />发布于 2013-01-19 01:32:27
我假设您(通过jdbc-user-service元素)使用JdbcDaoImpl。如果这是真的,那么您可以为默认查询提供您自己的SQL。
<jdbc-user-service
users-by-username-query="select username, password, enabled from Users where username = ?"
authorities-by-username-query="select username, authority from Authorities where username = ?"
/>https://stackoverflow.com/questions/14404086
复制相似问题