Method for automatically logging into user accounts of multiple smart devices under the same local area network
By obtaining the IP and MAC addresses of smart devices, creating chat rooms and synchronizing access tokens using the Openfire platform, the problem of manual login in multi-device LANs was solved, enabling automatic login between devices and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SICHUAN HONGMOFANG NETWORK TECH CO LTD
- Filing Date
- 2023-07-31
- Publication Date
- 2026-07-07
AI Technical Summary
Multiple smart devices on the same local area network require users to manually log in and enter their account and password, which is cumbersome and time-consuming.
By obtaining the IP address and MAC address of smart devices, a chat room is created using the Openfire instant messaging platform, an access token is generated, and the login status is synchronized to achieve automatic login between devices.
This feature enables users to automatically connect to the same user account on other devices after successfully logging in on any device, eliminating the need to manually enter username and password, thus improving user experience and login efficiency.
Smart Images

Figure CN116827665B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network communication technology, specifically, to a method for automatic login of user accounts of multiple smart devices on the same local area network. Background Technology
[0002] In existing technologies, when a user connects a smart device to a local area network (LAN), each smart device needs to log in separately and enter the corresponding login credentials, which can become cumbersome and time-consuming in a multi-device environment. Currently, there is no method to solve the problem of users needing to manually log in to the same user account and add associated devices on each device after connecting them to the same LAN. Summary of the Invention
[0003] The purpose of this invention is to provide a method for automatic login of user accounts of multiple smart devices under the same local area network. This method enables users to automatically connect other devices to the same user account after successfully logging into their user account on any device, through network discovery, without requiring users to manually enter their account and password on each device.
[0004] The present invention solves the above problems through the following technical solution:
[0005] A method for automatic login of user accounts of multiple smart devices on the same local area network includes a server, a router, and at least two smart devices. The smart devices and the server are connected to the network via the router. An automatic user account login application is installed on each smart device. A user system is installed on the server for user registration, login, authentication and authorization, recording login status, and automatic binding of accounts and devices via network discovery. An instant messaging platform is also built on the server for instant messaging with the automatic user account login application. The automatic user account login application is used to execute:
[0006] Step A: Obtain the smart device's own IP address and obtain the network interface device information of other smart devices within the same local area network;
[0007] Step B: Obtain the smart device's own MAC address, establish a connection with the router using its own MAC address, and obtain the MAC addresses of all network interfaces of the router;
[0008] Step C: Communicate with the server's instant messaging platform to manage users, transmit messages, and create chat rooms;
[0009] Step D: After detecting the user's entered account and password, a login request is sent to the user system. After the user system verifies the account and password, an access token is generated and returned to the program memory in the smart device storage. The generated access token is also associated with the user account and stored on the server.
[0010] Step E: Send the obtained access token to the chat room to communicate with other smart devices that have joined the chat room and to synchronize login status;
[0011] Step F: Other smart devices listen to messages in the chat room to enable automatic login for smart devices in the same local area network environment.
[0012] Step A specifically includes:
[0013] Step A1: Obtain the network IP address currently connected to the smart device by calling the native method InetAddress.getByName() provided by JDK;
[0014] Step A2: By calling the native method NetworkInterface.getByInetAddress() provided by JDK, the native method NetworkInterface.getByInetAddress() takes the network IP address to which the current smart device is connected as a parameter and returns the network interface object associated with the network IP address to which the current smart device is connected, thus obtaining the network interface device information.
[0015] Step B specifically includes:
[0016] Step B1: Call the network interface object and use the getHardwareAddress() method to obtain the MAC address of the current smart device associated with the network interface;
[0017] Step B2: Convert the obtained MAC address of the current smart device into a hexadecimal string format to obtain the unique identifier MAC address of the network interface to which the current smart device is connected;
[0018] Step B3: By calling the NetworkInterface.getNetworkInterfaces() method, obtain a list of all network interfaces on the local router, and by traversing the list of network interfaces, obtain the IP address and subnet mask of each network interface, calculate and obtain the broadcast address, and use it as the router's IP address;
[0019] Step B4: By calling the NetworkInterface.getByInetAddress() method with the router's IP address as a parameter, obtain the network interface associated with the IP address, and then call the NetworkInterface.getHardwareAddress() method to obtain the hardware address of the network interface, i.e., the router's MAC address, and convert the router's MAC address into a hexadecimal string format.
[0020] Step C specifically includes:
[0021] Step C1: Connect to the server's instant messaging platform via the network. The instant messaging platform is the Openfire messaging platform. Use the API provided by the Openfire service of the Openfire messaging platform to create a MultiUserChatManager instance and establish a connection with the Openfire server.
[0022] Step C2: Use the MAC address of the router as the name of the chat room. By calling the manager.getMultiUserChat(“MAC”) method, create a MultiUserChat instance associated with the current local area network. If a smart device that joins the current local area network environment finds that the chat room already exists by querying the MAC address, it will not be created again.
[0023] Step C3: Using the MultiUserChat instance, by calling the muc.join("MAC") method and passing in the MAC address of the current smart device, the current smart device is added to the chat room named after the MAC address of the router.
[0024] The method for sending the access token to the chat room in step E is as follows: the access token is sent to the chat room using the muc.sendMessage("token") method provided by the Openfire API.
[0025] The method for other smart devices to listen to messages in the chat room in step F is as follows: the smart devices that join the chat room listen to messages in the chat room based on the interface method muc.addMessageListener() provided by the Openfire API, thereby enabling the listening of the login status and access token of other smart devices.
[0026] The method for automatic login of smart devices in the same local area network environment in step F is as follows:
[0027] Step 1: Obtain the access token. First, check if the current smart device's program memory already contains access token information and if it matches the latest access token information obtained in the chat room. If they match, it means the current smart device is already logged in and there is no need to log in again. If they do not match or there is no access token, then write the latest access token information obtained in the chat room into the program memory.
[0028] Step 2: After the token is written to the program's memory, a token access verification is initiated to the user system on the server. The user system queries and verifies whether the token exists. If it exists, the user information is returned, and the login status displayed to the user is modified. If it does not exist, the token information originally stored in the program's memory is deleted, and automatic login fails.
[0029] If a new smart device joins the chat room for the first time, it can obtain the latest messages in the current chat room by calling the REST API interface provided by the OpenFire service and obtain the token information. Then, it can complete the login by following steps one and two.
[0030] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0031] (1) This invention provides an automatic login function that enables users to automatically connect other devices to the same user account after successfully logging into their user account on any device, through network discovery, without requiring users to manually enter their username and password on each device. This allows users to more easily access applications and services under their account, improving the overall user experience.
[0032] (2) This invention provides a convenient, fast and secure user login method for smart devices under the same local area network. Attached Figure Description
[0033] Figure 1 This is an overall schematic diagram of the present invention;
[0034] Figure 2 This is a schematic diagram illustrating how the present invention obtains the IP and MAC addresses of smart devices;
[0035] Figure 3 A diagram illustrating the addition of chat rooms to smart devices;
[0036] Figure 4 A diagram illustrating how smart devices obtain access tokens in a local area network environment;
[0037] Figure 5 Flowchart for automatic login verification for smart devices;
[0038] Figure 6 Flowchart for automatic login of newly added smart devices to the local area network. Detailed Implementation
[0039] The present invention will be further described in detail below with reference to embodiments, but the implementation of the present invention is not limited thereto.
[0040] Example 1
[0041] Combined with appendix Figure 1 As shown, a method for automatic login of user accounts for multiple smart devices within the same local area network (LAN) aims to solve the problem that users need to manually log in to the same user account and add associated devices on each smart device after connecting them to the same LAN. This addresses the issue in existing technologies where each device needs to log in separately and enter corresponding login credentials when connected to a LAN, which is cumbersome and time-consuming in multi-device environments.
[0042] Specifically, it includes a server, a router, and at least two smart devices (which may be smart TVs, smart refrigerators, smartphones, etc.). The smart devices and the server are connected to the network via the router. The smart devices have an automatic user account login application installed. The server has a user system installed for user registration, login, authentication and authorization, recording login status, and automatic binding of accounts and devices via network discovery. The server also has an instant messaging platform for instant messaging with the automatic user account login application. The automatic user account login application is used to execute:
[0043] Step A: Obtain the smart device's own IP address and obtain the network interface device information of other smart devices within the same local area network;
[0044] Step B: Obtain the smart device's own MAC address (Media Access Control) - the unique identifier of the smart device, establish a connection with the router through its own MAC address, and obtain the MAC addresses of all network interfaces of the router - the unique identifier of the router;
[0045] Step C: Communicate with the server's instant messaging platform to manage users, transmit messages, and create chat rooms;
[0046] Step D: After detecting the user's entered account and password, a login request is sent to the user system. After the user system verifies the account and password, an access token is generated and returned to the program memory in the smart device storage. The generated access token is also associated with the user account and stored on the server.
[0047] Step E: Send the obtained access token to the chat room to communicate with other smart devices that have joined the chat room and to synchronize login status;
[0048] Step F: Other smart devices listen to messages in the chat room to enable automatic login for smart devices in the same local area network environment.
[0049] This invention provides an automatic login function. Once a user successfully logs into their account on any smart device, other devices are automatically connected to the same account via network discovery, eliminating the need for the user to manually enter their username and password on each device. This allows users to more easily access applications and services under their account, improving the overall user experience. The key to this function is obtaining the device's IP address and MAC address for authentication and communication with the server. The server can then identify and confirm the user account and transmit the account's login status to other devices. Other devices automatically complete the login process by listening to the information sent by the server, without user intervention. In short, by using network discovery and automatic login, this invention solves the problem of manual login in a multi-device local area network environment, providing a convenient, fast, and secure user login method for smart devices within the same local area network.
[0050] Example 2:
[0051] Based on Example 1, the user account automatic login application can be developed using Java, and step A specifically includes:
[0052] Step A1: Obtain the network IP address to which the current smart device is connected by calling the native method InetAddress.getByName() provided by JDK; InetAddress.getByName() is used to query the IP address corresponding to a specified hostname, which is a unique identifier for the device to connect to the current local area network;
[0053] Step A2: By calling the native method NetworkInterface.getByInetAddress() provided by the JDK, the network IP address to which the current smart device is connected is passed as a parameter to the native method NetworkInterface.getByInetAddress(), and it returns the network interface object associated with the network IP address to which the current smart device is connected, thus obtaining the network interface device information. NetworkInterface.getByInetAddress() is used to query the network interface associated with the specified IP address.
[0054] like Figure 2 As shown, step B specifically includes:
[0055] Step B1: Call the network interface object and use the getHardwareAddress() method to obtain the MAC address of the current smart device associated with the network interface; this MAC address is the unique identifier of the network interface, used to uniquely identify the device in the local area network;
[0056] Step B2: Convert the obtained MAC address of the current smart device into a hexadecimal string format, for example: 01:23:45:67:89:ab, for later use. This gives you the unique MAC address of the network interface to which the current smart device is connected, which is used to identify the smart device and perform related operations.
[0057] Step B3: By calling the NetworkInterface.getNetworkInterfaces() method, obtain a list of all network interfaces on the local router, and by traversing the list of network interfaces, obtain the IP address and subnet mask of each network interface, calculate and obtain the broadcast address, which will be used as the router's IP address; the purpose of this step is to determine the router's IP address on the local area network to which the current smart device is connected.
[0058] Step B4: By calling the `NetworkInterface.getByInetAddress()` method with the router's IP address as a parameter, the network interface associated with that IP address is obtained. Then, the `NetworkInterface.getHardwareAddress()` method is called to obtain the hardware address of that network interface, i.e., the router's MAC address, and the router's MAC address is converted into a hexadecimal string format. The `NetworkInterface.getByInetAddress()` method is a native `NetworkInterface` class provided by the JDK. The purpose of this step is to obtain the MAC address of the router on the local area network to which the current smart device is connected, which will be used as a unique identifier for creating the chat room later.
[0059] Step C specifically includes:
[0060] Step C1: Connect to the server's instant messaging platform via the network. The instant messaging platform is the Openfire messaging platform. Use the API provided by the Openfire service to create a MultiUserChatManager instance and establish a connection with the Openfire server. The user account auto-login application, based on the Openfire API, has developed a program that interacts with Openfire. This program utilizes the Openfire API to implement functions such as user management, message transmission, and chat room creation to meet the needs of instant messaging, such as:
[0061] MultiUserChatManager manager=MultiUserChatManager.getInstanceFor(connection);
[0062] Step C2: To ensure the uniqueness of the chat room, the MAC address of the router is used as the name of the chat room. By calling the manager.getMultiUserChat(“MAC”) method, a MultiUserChat instance associated with the current local area network is created. If a smart device that joins the current local area network environment finds that the current chat room already exists by querying the MAC address, it will not be created again.
[0063] Step C3: Using the MultiUserChat instance, by calling the muc.join("MAC") method and passing in the MAC address of the current smart device, the current smart device is added to a chat room named after the router's MAC address. Figure 3 As shown.
[0064] The method for sending the access token to the chat room in step E is as follows: the access token is sent to the chat room via the muc.sendMessage("token") method provided by the Openfire API, so as to communicate with other smart devices that have joined the chat room and synchronize their login status.
[0065] The server's user system provides core functions such as user registration, login, and automatic account and device discovery and binding via the network. This system allows users to register on smart home appliances, create personal accounts, and log in using those accounts. Key functions include:
[0066] ① User Registration: Allows users to register a new account by providing necessary information (such as username, password, email, etc.). The registration process verifies the validity of the information provided by the user and saves it in the backend database.
[0067] ② User Login: Registered users can log in to the system using their username and password. The login process verifies the credentials provided by the user and assigns an access token as a session authentication identifier upon successful verification.
[0068] ③ Authentication and Authorization: After a user logs in, the system will authenticate their identity and grant appropriate access permissions. In this way, the user can only access resources and functions within their authorized scope.
[0069] ④ Remember Login State: This system supports maintaining the user's login state on subsequent visits. After logging in, the system generates a long-term valid access token and stores it on the user's device. On the next visit, the system checks the token on the device and automatically restores the user's login state without requiring them to re-enter their credentials.
[0070] ⑤ Automatic account and device discovery and binding via network: This system supports registering users to the user system and automatically binding the current device to the account name when the current user logs in to the smart device.
[0071] The method for other smart devices to listen to messages in the chat room in step F is as follows: the smart devices that join the chat room listen to messages in the chat room based on the interface method muc.addMessageListener() provided by the Openfire API, thereby enabling the listening of the login status and access token of other smart devices.
[0072] muc.addMessageListener(new MessageListener(){
[0073] @Override
[0074] public void processMessage(Message message){
[0075] / / Login password message processing
[0076] }});
[0077] The method for automatic login of smart devices in the same local area network environment in step F is as follows:
[0078] Step 1: Verify if the current smart device is logged in: Obtain the access token. First, check if the smart device's program memory already contains the access token information and if it matches the latest access token information obtained in the chat room. If they match, it means the smart device is already logged in and no further login is needed. If they don't match or there is no access token, write the latest access token information obtained in the chat room into the program memory. When the user makes subsequent business access requests initiated through the smart device, the request will carry this token information. The user system will use the token to verify the user's identity and authorize the corresponding access permissions, such as... Figure 4 As shown;
[0079] Step Two: Login Verification and Status Modification: After the token is written to the program's memory, a token access verification is initiated to the user's system on the server. The user's system queries and verifies the existence of the token. If it exists, the user information is returned, and the login status displayed to the user is modified accordingly. If it does not exist, the token information originally stored in the program's memory is deleted, and automatic login fails. Figure 5 As shown.
[0080] If a new smart device joins the chat room for the first time, it retrieves the latest messages and token information by calling the REST API provided by the OpenFire service. If token information is obtained, it completes the login process according to steps one and two. If token information is not obtained, it means the user has not logged in on any smart device with an auto-login application installed on the current local network. Automatic login synchronization is not required. Figure 6 As shown.
[0081] Although the present invention has been described herein with reference to illustrative embodiments, the above embodiments are merely preferred embodiments of the present invention, and the implementation of the present invention is not limited to the above embodiments. It should be understood that those skilled in the art can devise many other modifications and implementations, which will fall within the scope and spirit of the principles disclosed in this application.
Claims
1. A method for automatic login of user accounts of multiple smart devices under the same local area network, characterized in that, The system includes a server, a router, and at least two smart devices. The smart devices and the server are connected to the network via the router. Each smart device has an automatic user account login application installed. The server has a user system installed for user registration, login, authentication and authorization, recording login status, and automatic binding of accounts and devices via network discovery. The server also has an instant messaging platform for instant messaging with the automatic user account login application. The automatic user account login application is used to perform the following: Step A: Obtain the smart device's own IP address and obtain the network interface device information of other smart devices within the same local area network; Step B: Obtain the smart device's own MAC address, establish a connection with the router using its own MAC address, and obtain the MAC addresses of all network interfaces of the router; Step C: Communicate with the server's instant messaging platform to manage users, transmit messages, and create chat rooms; Step D: After detecting the user's entered account and password, a login request is sent to the user system. After the user system verifies the account and password, an access token is generated and returned to the smart device for storage in the program's memory. The generated access token is also associated with the user account and stored on the server. Step E: Send the obtained access token to the chat room to communicate with other smart devices that have joined the chat room and to synchronize login status; Step F: Other smart devices listen to messages in the chat room to enable automatic login of smart devices in the same local area network environment. The method for other smart devices to listen to messages in the chat room is as follows: the smart devices that join the chat room listen to messages in the chat room based on the interface method muc.addMessageListener() provided by the Openfire API to realize the listening of login status and access token of other smart devices. The method for automatic login of smart devices in the same local area network environment is as follows: Step 1: Obtain the access token. First, check if the current smart device's program memory already contains access token information and if it matches the latest access token information obtained in the chat room. If they match, it means the current smart device is already logged in and there is no need to log in again. If they do not match or there is no access token, then write the latest access token information obtained in the chat room into the program memory. Step 2: After the token is written to the program memory, a token access verification is initiated to the user system on the server. The user system queries and verifies whether the token exists. If it exists, the user information is returned, and the login status displayed to the user is modified. If it does not exist, the token information originally stored in the program's memory will be deleted, and automatic login will fail.
2. The method for automatic login of multiple smart device user accounts under the same local area network according to claim 1, characterized in that, Step A specifically includes: Step A1: Obtain the network IP address currently connected to the smart device by calling the native method InetAddress.getByName() provided by JDK; Step A2: By calling the native method NetworkInterface.getByInetAddress() provided by JDK, the native method NetworkInterface.getByInetAddress() takes the network IP address to which the current smart device is connected as a parameter and returns the network interface object associated with the network IP address to which the current smart device is connected, thus obtaining the network interface device information.
3. The method for automatic login of multiple smart device user accounts under the same local area network according to claim 2, characterized in that, Step B specifically includes: Step B1: Call the network interface object and use the getHardwareAddress() method to obtain the MAC address of the current smart device associated with the network interface; Step B2: Convert the obtained MAC address of the current smart device into a hexadecimal string format to obtain the unique identifier MAC address of the network interface to which the current smart device is connected; Step B3: By calling the NetworkInterface.getNetworkInterfaces() method, obtain a list of all network interfaces on the local router, and by traversing the list of network interfaces, obtain the IP address and subnet mask of each network interface, calculate and obtain the broadcast address, and use it as the router's IP address; Step B4: By calling the NetworkInterface.getByInetAddress() method with the router's IP address as a parameter, obtain the network interface associated with the IP address, and then call the NetworkInterface.getHardwareAddress() method to obtain the hardware address of the network interface, i.e., the router's MAC address, and convert the router's MAC address into a hexadecimal string format.
4. The method for automatic login of multiple smart device user accounts under the same local area network according to claim 3, characterized in that, Step C specifically includes: Step C1: Connect to the server's instant messaging platform via the network. The instant messaging platform is the Openfire messaging platform. Use the API provided by the Openfire service of the Openfire messaging platform to create a MultiUserChatManager instance and establish a connection with the Openfire server. Step C2: Use the MAC address of the router as the name of the chat room. By calling the manager.getMultiUserChat("MAC") method, create a MultiUserChat instance associated with the current local area network. If a smart device that joins the current local area network environment finds that the chat room already exists by querying the MAC address, it will not be created again. Step C3: Using the MultiUserChat instance, by calling the muc.join("MAC") method and passing in the MAC address of the current smart device, the current smart device is added to the chat room named after the MAC address of the router.
5. The method for automatic login of multiple smart device user accounts under the same local area network according to claim 4, characterized in that, The method for sending the access token to the chat room in step E is as follows: the access token is sent to the chat room using the muc.sendMessage("token") method provided by the Openfire API.
6. The method for automatic login of multiple smart device user accounts under the same local area network according to claim 1, characterized in that, If a new smart device joins the chat room for the first time, it can obtain the latest messages in the current chat room by calling the REST API interface provided by the OpenFire service and obtain the token information. Then, it can complete the login by following steps one and two.