code: @Path("authenticate")
      @POST
      @Produces(MediaType.APPLICATION_JSON)
      public TokenDto authenticate(@FormParam("username") String username, @FormParam("password") String password) {
          UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
          Authentication authentication = this.authManager.authenticate(authenticationToken);
          SecurityContextHolder.getContext().setAuthentication(authentication);
  
          return new TokenDto(TokenUtils.createToken((UserDetails) authentication.getPrincipal()));
      }
docs: Authenticates a user and creates an authentication token.
  
  @param username name of the user.
  @param password password of the user.
  @return authentication token.