public String getId() {
return "fetcher.netbios";
}
public Object scan(ScanningSubject subject) {
NetBIOSResolver netbios = null;
try {
netbios = new NetBIOSResolver(subject.getAdaptedPortTimeout());
String[] names = netbios.resolve(subject.getAddress());
if (names == null) return null;
String computerName = names[0];
String userName = names[1];
String groupName = names[2];
String macAddress = names[3];
return (groupName != null ? groupName + "\\" : "") +
(userName != null ? userName + "@" : "") +
computerName + " [" + macAddress + "]";
}
catch (SocketTimeoutException e) {
// this is not a derivative of SocketException
return null;
}
catch (SocketException e) {
// this includes PortUnreachableException
return null;
}
catch (Exception e) {
// bugs?
LOG.log(WARNING, null, e);
return null;
}
finally {
if (netbios != null) netbios.close();
}
}