org.apache.ace.identification.ifconfig
Class IfconfigIdentification
java.lang.Object
org.apache.ace.identification.ifconfig.IfconfigIdentification
- All Implemented Interfaces:
- org.apache.ace.identification.Identification
public class IfconfigIdentification
- extends Object
- implements org.apache.ace.identification.Identification
Implementation of the Identification
interface which will determine a mac-address based ID which is determined
by running the ifconfig command. The first adapter that has been assigned an ip address is used.
The identification has been tested on ifconfig 1.42 (2001-04-13)
which comes with Debian Linux. Similar
versions of ifconfig are likely to work.
Method Summary |
String |
getID()
|
protected boolean |
isValidMac(String mac)
Verifies whether a string contains a valid mac addres, a valid mac address consists of
6 pairs of [A-F,a-f,0-9] separated by ':', e.g. |
protected String |
parseIfconfigOutput(BufferedReader ifconfigOutput)
Parses the mac address of the first active adapter from the output of the ifconfig command. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IfconfigIdentification
public IfconfigIdentification()
getID
public String getID()
- Specified by:
getID
in interface org.apache.ace.identification.Identification
parseIfconfigOutput
protected String parseIfconfigOutput(BufferedReader ifconfigOutput)
throws IOException
- Parses the mac address of the first active adapter from the output of the ifconfig command.
- Parameters:
ifconfigOutput
- Reader pointing to the output of the ifconfig command.
- Returns:
- String containing the mac address or
null
if no valid mac address could be determined.
- Throws:
IOException
- If the specified reader could not be read correctly.
isValidMac
protected boolean isValidMac(String mac)
- Verifies whether a string contains a valid mac addres, a valid mac address consists of
6 pairs of [A-F,a-f,0-9] separated by ':', e.g.
0A:F6:33:19:DE:2A
.
- Parameters:
mac
- String containing the possible mac address
- Returns:
- true If the specified string contains a valid mac address, false otherwise.
Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.