Describe the bug If I define A class UserAuthenticationTokenBO extends AbstractAuthenticationToken, and do not override Principal's getName method, then if I direct call UserAuthenticationTokenBO instance's getName will happen expection!!!
To Reproduce Can use below test class:
public class UserAuthenticationTokenBO extends AbstractAuthenticationToken{
public UserAuthenticationTokenBO(Collection<? extends GrantedAuthority> authorities) {
super(authorities);
}
@Override
public Object getCredentials() {
return null;
}
@Override
public Object getPrincipal() {
return this;
}
}
Expected behavior A clear and concise description of what you expected to happen.
Sample
A link to a GitHub repository with a minimal, reproducible sample.
Reports that include a sample will take priority over reports that do not. At times, we may require a sample, so it is good to try and include a sample up front.
Comment From: eleftherias
Hi @gongxh13, the code you shared will produce a StackOverflowError when calling getName because it returns this when calling getPrincipal.
@Override
public Object getPrincipal() {
return this;
}
The default implementation of getName() will call getPrincipal().getName() which is equivalent to this.getName() since the principal is this, causing an infinite loop.
If you're having trouble adding custom logic and would like some help, the best place to ask is Stack Overflow. We prefer to use GitHub issues only for bugs and enhancements.
Comment From: gongxh13
小伙伴们,给大家分享一个好消息,草cao榴kiu社区(1024)最新地址,开放注册三天,时间有限,抓紧了!!!地址: http://url.cn/XspvuD