I seen other post about this but still doesnt find appropriate answer.
My form submitted have three parameter instead of two.
Here my CustomAuthenticationProvider:
@Component
public class CustomAuthenticationProvider implements AuthenticationProvider {
private static final Logger logger = LoggerFactory.getLogger(CustomAuthenticationProvider.class);
@Override
public Authentication authenticate(Authentication auth) throws AuthenticationException {
String userName = auth.getName().trim();
String password = auth.getCredentials().toString().trim();
String companyName ;
if (userName.equals("admin") && password.equals("123456")) {
List<GrantedAuthority> grantedAuths = new ArrayList<>();
grantedAuths.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
Authentication upat = new UsernamePasswordAuthenticationToken(userName, password, grantedAuths);
logger.info("{}:{}",userName,grantedAuths);
return upat;
} else {
return null;
}
}
@Override
public boolean supports(Class<?> auth) {
return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(auth));
}
I want to get extra parameter from login form to authenticate the companyName in CustomAuthenticationProvider
How can I get the parameter from the login form?