사용자 지정 인증 공급자가 있습니다. 다른 클래스의 메서드를 호출하고 싶을 때 아무 일도 일어나지 않고 왜 그럴지 모릅니다. 도와주세요 : 인증 방법의사용자 지정 인증 공급자를 구현할 때 다른 클래스의 메서드를 호출 할 수없는 이유
package org.sample.web.security;
import java.util.ArrayList;
import java.util.List;
import org.sample.web.service.SimpleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.stereotype.Component;
@Component
public class CustomAuthenticationProvider implements AuthenticationProvider {
protected final Logger logger = LoggerFactory.getLogger(getClass());
private SimpleService simpleService;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
logger.error("1111111111111111");
String name = authentication.getName();
String password = authentication.getCredentials().toString();
simpleService.doNothing();
logger.error("2222222222222222");
if (name.equals("admin") && password.equals("system")) {
List<GrantedAuthority> grantedAuths = new ArrayList<GrantedAuthority>();
grantedAuths.add(new SimpleGrantedAuthority("ROLE_USER"));
Authentication auth = new UsernamePasswordAuthenticationToken(name, password, grantedAuths);
return auth;
} else {
return null;
}
}
@Override
public boolean supports(Class<?> authentication) {
return authentication.equals(UsernamePasswordAuthenticationToken.class);
}
public void setSimpleService(SimpleService simpleService) {
this.simpleService = simpleService;
}
}
출력은 그냥 : I 줄 아무것도하지 않는다 칭찬 할 때
DEBUG - ProviderManager - Authentication attempt using org.sample.web.security.CustomAuthenticationProvider
ERROR - stomAuthenticationProvider - 1111111111111111
// simpleService.doNothing();
는 다음 이유 작업을 시작?
DEBUG - ProviderManager - Authentication attempt using org.sample.web.security.CustomAuthenticationProvider
ERROR - stomAuthenticationProvider - 1111111111111111
ERROR - stomAuthenticationProvider - 2222222222222222
TRACE - XmlWebApplicationContext - Publishing event in Root WebApplicationContext: org.springframework.security.authentication.event.AuthenticationFailureProviderNotFoundEvent[source=org.springframew[email protected]9561: Principal: aaa; Credentials: [PROTECTED]; Authenticated: false; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Not granted any authorities]
DEBUG - DefaultListableBeanFactory - Returning cached instance of singleton bean 'methodRegistrar'
DEBUG - BasicAuthenticationFilter - Authentication request for failed: org.springframework.security.authentication.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken
DEBUG - nSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
DEBUG - tyContextPersistenceFilter - SecurityContextHolder now cleared, as request processing completed
보안 컨텍스트 : 당신의 설명에서
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd">
<http use-expressions="true">
<intercept-url pattern="/**" access="isAuthenticated()" />
<http-basic />
</http>
<global-method-security pre-post-annotations="enabled" />
<authentication-manager>
<authentication-provider ref="customAuthenticationProvider" />
</authentication-manager>
</beans:beans>
doNothing 정말 아무것도하지 않고 : 공공 무효 doNothing() 나는 방법이 로그인 – hudi
흠 { // TODO 자동 생성 방법은 스텁}하지 않으면 당신은 코드를 주석 때 당신이 그것을 부르면 작동하지 않습니다. 디버거를 보셨습니까? – hudi
를 디버깅하는 방법 아무 생각 –