我正在使用
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.2.4.RELEASE</version>
</dependency>
身份验证后,我需要密码才能登录其他服务。对于这种方法,我将身份验证配置如下:
<sec:authentication-manager alias="authenticationManager" erase-credentials="false">
<sec:authentication-provider>
<sec:password-encoder ref="defaultPasswordEncoder" />
<sec:jdbc-user-service data-source-ref="dataSource"
users-by-username-query="SELECT .."
authorities-by-username-query="SELECT .." />
</sec:authentication-provider>
</sec:authentication-manager>
但是,当我检索凭据时,我仍然会得到null:
SecurityContextHolder.getContext().getAuthentication().getCredentials();