I am trying to make a spring web application and it will be requested from multiple devices (e.g. Android phones and iPhones). I need to identify the device which sends a request in order to recognize it in a later stage. How am I to achieve that in java?
A sample scenario: User signs in using a Samsung A7 and another user signs in using an iPhone 8.
I need to track and store the actions by the device. I think I need the user of a device to log in every time in order to show all actions executed by this related device. I need to recognize the device for every request here and also I will need to show to the user all logged-in devices.
I have tried to achieve this with a mac address but I think it's not effective.
when type on cmd "ipconfig/all" the following list appear but which physical address should choose between all of them ??!!!!
and i try this java code to get mac address but a NullPointerException is occurred
InetAddress address = InetAddress.getByName(HttpRequestHelper.getRemoteAddress());
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
byte[] mac = ni.getHardwareAddress();
Are you using a native app for mobile or yours is only a website?
Any way the only way is recognize user agents headers to know the device and you can use for example the device token push address that is mostly unique id.
If yours is only a website you can store the device with a generated id or random, save to your database and on browser cookies
Related
I am building an app similar to Instagram. User uploads a post and other others can like it. When people like the post, I want the post author to get a push notification using FCM (Firebase Cloud Messaging).
My problem is that the refreshToken (that is generated using FirebaseInstanceId.getInstance().getToken();) is specific to the device. So if the same user logs into the app from a different device, I want to make sure I send a push notification to all the devices. So here is my proposed solution, I want to know if it's the right way to do it:
Every time user logs into a device, I store the refreshToken into the database and when I want to generate a push notification, I can iterate over all those refreshTokens and send a push notification to all those devices.
Is there a better way to accomplish this?
Note: I am aware of Device Group Messaging and I can't use that because I don't have an app server. And I don't want to do it on the client side because that requires the client to have a Google account.
Yes, the implementation is okay.
Every time user logs into a device, I store the refreshToken into the
database.
This is actually not necessary to send the device push registration id (refreshToken in your case) each time user logs into your application from a device. You need to send the push registration id (i.e. refreshToken) from your device only when the device is not known to the server yet (i.e. new device).
Is there a better way to accomplish this?
I think no. This is the perfect way that you have implemented. However, we might always think of several optimization points like, tracking which devices are logged off, so that you do not need to send the push notification to that device any more. So in case of logging off from a device, send another invalidate refreshToken request to the server from that device, so that it does not get any further push notification. This is an improvement over the current implementation.
How to get mobile-device information through java or java script ?
I need to know whenever a customer from mobile phone enters into my Website
You have to read the User-Agent header from the request.
See more on : Detecting Device Type in a web application
is there a possibility to get USB mass storage information like the serial of an USB device in Java on Windows?
I tried to achieve that with USB4Java (low and high-level API) and it works, but the problem is that I have to install a customized driver to get access to the information from my Java app (described in the FAQ at http://usb4java.org/). When that special driver (created with Zadig) is installed I don't have any further access to the device from the Windows explorer (just from my Java app).
I would like to detect when a new USB device is attached and if it was attached, I would like to get some information like the serial number of the device, the device name, the drive letter that was assigned etc.
That app should be used by other users and I couldn't force them to create a customized driver for each device ...
Do you have any hints how to achieve that?
Thanks.
Edit: Is it possible to get the usb-port of a connected device with Java-built-in methods?
I've tried sth with FileSystemView.getFileSystemView().getSystemDisplayName() but there are no such options. Is there another possibility to get vendor id's or sth. similiar with Java?
Or is it possible to get the drive letter with USB4Java?
Thanks.
I have a project in mind, but i was hoping i could get some insight.
Would it be possible to have a page allow access to my phone, or a co workers phone or laptop or device, but refuse any other device to gain access to this page.
The idea of this project is through QR codes, for example,
If i generate a QR code, to access a list of lets say, inventory. i would like my phone, or my co workers phone to gain access to it, but if say my brother or someone outside trys the code and gets sent to this specific page(s), it doesn't allow it to happen because the phone ID or tablet ID is not in the list to gain access.
It would be difficult to create a login page and enable QR codes, because you cannot implement the login information in the QR code because then the security would be irrelevant.
Any suggestions??
Your page could restrict access based on the originating IP address. The feasibility of such a system would depend on a number of parameters, such as whether you are connecting over wifi or cellular, in the case of wifi - whether you trust the wifi network, in the case of cellular - how often the cell provider changes your address.
A better solution might be to use a custom URI scheme and a custom app installed on only the phones and tablets that you want to have access. When the device scans the QR code, the app would handle the request, and then log in to the web site over HTTPS with proper authentication. e.g.
QR code: my.app://blah/blah
App handles URL, logs into server, redirects to https://my.site/blah/blah
Why not use identity certificates? Sign your message (QR Code) with the corresponding private key and validate for scanner's Identity, Trust and Message integrity.
I am posting this in order to confirm if it is possible for PHP to get a user's machine hardware information when connected to a website?
In my case I am developing an Intranet which requires one user - one machine login. Which means a user assigned to his/ her machine can only login, others cannot login from that particular machine. In this regard, my database and PHP Code is already up and running without machine dependency.
I presume it is not possible because PHP is a Server Side code which requires none of the User's system resources to get in touch with. To get system's hardware information - some application must be installed in user's machine to get it done. But is this possible in any regard for example a PHP Desktop application (though not in development) or any Java application to check machine's information and get appended it to Normal user's login.
Awaiting experts solutions...
It depends what information you need. The HTTP Headers contain the user agent (what browers/OS) of the origin, the IP address and a few other things that the server needs in order to process the request, but you can't get for instance the brand of keyboard connected to that machine.
Simple: IMPOSSIBLE! As php will output text to a browser and the browser can gather some data, but only a little (like screen resolution, colors, IP and things that are not vurnelable.). But no, PHP cannot access hardware information.
You can use the IP address to know which machine it is only if your DHCP does not change the IP at each deconnexion.
You can also use the REMOTE_USER_AGENT super global to know more informations. Apart from an ajax request that can send datas that your security policy allows the browser to get, I see no solution for your problem.