public class HardwareBinder extends Object
It is recommended that such a checking is used only with warning purposes and not treated as a strict license violation. It may happen that the ethernet card of a server is replaced due to some failure and there is no time to request a new license.
Therefore it is a recommended practice to note the disalignment of the license and send it to the log, but do not deter the operation of the software.
| Constructor and Description |
|---|
HardwareBinder() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
assertUUID(String uuid)
Asserts that the current machine has the UUID.
|
boolean |
assertUUID(UUID uuid)
Asserts that the current machine has the UUID.
|
UUID |
getMachineId()
Calculate the UUID for the machine this code is running on.
|
String |
getMachineIdString()
Get the machine id as an UUID string.
|
void |
ignoreArchitecture()
The UUID generation uses the architecture string as returned by
System.getProperty("os.arch"). |
void |
ignoreHostName()
When calculating the machine UUID the host name is also taken into
account by default.
|
void |
ignoreNetwork()
When calculating the uuid of a machine the network interfaces are
enumerated and their parameters are taken into account.
|
void |
interfaceAllowed(String regex)
Add a regular expression to the set of the regular expressions that are
checked against the display name of the network interface cards.
|
void |
interfaceDenied(String regex)
Add a regular expression to the set of the regular expressions that are
checked against the display name of the network interface cards.
|
static void |
main(String[] args)
A very simple main that prints out the machine UUID to the standard
output.
|
public void ignoreHostName()
public void ignoreNetwork()
If you want to ignore the network when generating the uuid then call this method before any uuid calculating methods.
public void ignoreArchitecture()
System.getProperty("os.arch"). In some rare cases you want to
have a UUID that is independent of the architecture.public void interfaceAllowed(String regex)
Note that there is also a denied set of regular expressions. A network interface card is used during the calculation of the machine uuid if any of the allowing regular expressions match and none of the denying regular expressions match.
Note that if there is no any allowing regular expressions, then this is treated that all the interface cards are allowed unless explicitly denied by any of the denying regular expressions. This way the functionality of the hardware binder class is compatible with previous versions. If you define nor allowed set, neither denied set then the interface cards are treated the same as with the old version.
This functionality is needed only when you have problem with some virtual network interface cards that are erroneously reported by the Java run time system as physical cards. This is a well known bug that is low priority in the Java realm and there is no general workaround. If you face that problem, then try programmatically exclude from the calculation the network cards that cause you problem.
regex - public void interfaceDenied(String regex)
See also the documentation of the method
interfaceAllowed(String).
regex - public UUID getMachineId() throws UnsupportedEncodingException, SocketException, UnknownHostException
The method also feeds the local machine name into the digest.
This method relies on Java 6 methods, but also works with Java 5. However the result will not be the same on Java 5 as on Java 6.
SocketExceptionUnsupportedEncodingExceptionUnknownHostExceptionpublic String getMachineIdString() throws UnsupportedEncodingException, SocketException, UnknownHostException
UnknownHostExceptionSocketExceptionUnsupportedEncodingExceptionpublic boolean assertUUID(UUID uuid) throws UnsupportedEncodingException, SocketException, UnknownHostException
uuid - expectedUnknownHostExceptionSocketExceptionUnsupportedEncodingExceptionpublic boolean assertUUID(String uuid)
uuid - expected in String formatpublic static void main(String[] args) throws UnsupportedEncodingException, SocketException, UnknownHostException
This code takes into account the hardware address (Ethernet MAC) when calculating the hardware UUID.
args - not usedUnknownHostExceptionSocketExceptionUnsupportedEncodingExceptionCopyright © 2015. All Rights Reserved.