'how to get the mac Address , user , through an end-point request
I have a controller that when accessing it I need to get the ip, user, macAdress information that are accessing this new end-point. I have the code below and I would like to get this other information I need. Can you help me?
@RequestMapping(value = "/account", method = RequestMethod.GET)
public String getIp(HttpServletRequest request) {
String ipAddress = request.getHeader("X-FORWARDED-FOR");
if (ipAddress == null) {
ipAddress = request.getRemoteAddr();
}
return "page";
}
Solution 1:[1]
As you can see from the image below, a Network Layer packet does not contain fields for transporting the information you are asking about.
However, nothing stops you from putting this information on the payload. You could, for instance, establish a format for messages exchanged between applications where the sender's MAC address and the signed-in username is stored. The receiver could then extract this information from the payload.
I think you should be able to do something like this:
{
"metadata":
{
"username" : "hector",
"mac" : "00:00:00:00:00:00"
},
"payload" : {-WHATEVER YOU'RE SENDING HERE-}
}
In XML
<?xml version="1.0" encoding="UTF-8" ?>
<metadata>
<username>hector</username>
<mac>00:00:00:00:00:00</mac>
</metadata>
<payload>...</payload>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

