Cas 5.2.4 using REST API to return a 401 Unauthorized error, solve

Dependencies have been added according to the instructions on REST Protocol on the official website.

public class CustomAuthentionHandler extends AbstractPreAndPostProcessingAuthenticationHandler {
    @Autowired
    private UserServiceImpl userService;
    public CustomAuthentionHandler(String name, ServicesManager servicesManager, PrincipalFactory principalFactory, Integer order){
        super(name,servicesManager,principalFactory,order);
    }
    @Override
    protected HandlerResult doAuthentication(Credential credential) throws GeneralSecurityException, PreventedException {
        System.out.println("\nCredential==="+credential.getClass().getName()+"\n");
        UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential) credential;
        String username = usernamePasswordCredential.getUsername();
        String password = usernamePasswordCredential.getPassword();
        //
        UserVo userVo = userService.getUserWithMultiAttrs(username, password);
        System.out.println("userVo: "+userVo.toString());
        if(userVo==null){
            throw new AccountNotFoundException("");
        }
        //  
        Map<String, Object> map = new HashMap<>();  
        map.put("external\_userinfo", JSON.toJSONString(userVo));
        return createHandlerResult(usernamePasswordCredential, principalFactory.createPrincipal(username, map), null);
    }

    @Override
    public boolean supports(Credential credential) {
        return credential instanceof UsernamePasswordCredential;
    }
}
Mar.22,2021

has been resolved, because the REST API, included with: CAS Server only supports the default UsernamePasswordCredential , and my project extends the custom UsernamePasswordCredential , so you need to make a judgment in the custom verification Handler. If the Credential type of the request is org.apereo.cas.authentication.UsernamePasswordCredential , it comes from the REST request, and you can directly return the corresponding UsernamePasswordCredential object.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3cec4-2c35c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3cec4-2c35c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?