@RequestMapping("/user") public String user(@RequestHeader(name="Authorization") String auth, @RequestBody Users items, HttpServletResponse response){ if(!this.authRequest(auth)) { response.setStatus(401); return ""; } ... }
private Boolean authRequest(String auth){ String authStr = Base64.decodeStr(auth.replaceAll("Basic ","").trim()); String username = ""; String password = ""; if(authStr != null){ username = authStr.split(":")[0]; password = authStr.split(":")[1]; } logger.info(authStr); if(auth == null){ return false; } if(!username.equals("cmp") || !password.equals("Cmp@123")){ return false; } return true; }