use of de.janrufmonitor.fritzbox.firmware.exception.GetBlockedListException in project janrufmonitor by tbrandt77.
the class AbstractFritzBoxFirmware method getBlockedList.
public List getBlockedList() throws IOException, GetBlockedListException {
if (!this.isInitialized())
throw new GetBlockedListException("Could not get blocked list from FritzBox: FritzBox firmware not initialized.");
InputStream in = null;
try {
in = this.getBlockedListAsStream();
} catch (IOException e) {
throw new GetBlockedListException(e.getMessage());
} catch (DoBlockException e) {
throw new GetBlockedListException(e.getMessage());
}
if (in == null)
return new ArrayList(0);
List result = new ArrayList();
StringBuffer parseBuffer = new StringBuffer();
InputStreamReader inr = new InputStreamReader(in);
BufferedReader bufReader = new BufferedReader(inr);
// drop header
String line = bufReader.readLine();
// fasten the processing
bufReader.skip(4096);
while (bufReader.ready()) {
line = bufReader.readLine();
parseBuffer.append(line);
parseBuffer.append(IJAMConst.CRLF);
}
bufReader.close();
in.close();
Pattern p = Pattern.compile(PATTERN_DETECT_BLOCKED_LIST, Pattern.UNICODE_CASE);
Matcher m = p.matcher(parseBuffer);
while (m.find() && m.groupCount() == 1) {
result.add(m.group(1).trim());
}
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Blocked list from FritzBox successfully fetched. List size: " + result.size());
return result;
}
use of de.janrufmonitor.fritzbox.firmware.exception.GetBlockedListException in project janrufmonitor by tbrandt77.
the class FritzOS559Firmware method getBlockedList.
public List getBlockedList() throws GetBlockedListException, IOException {
if (!this.isInitialized())
throw new GetBlockedListException("Could not get blocked list from FritzBox: FritzBox firmware not initialized.");
StringBuffer data = new StringBuffer();
String urlstr = getProtocol() + this.m_address + ":" + this.m_port + "/fon_num/sperre.lua?sid=" + this.m_sid;
try {
data.append(this.executeURL(urlstr, null, true).trim());
} catch (UnsupportedEncodingException e) {
this.m_logger.log(Level.WARNING, e.getMessage(), e);
} catch (IOException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
throw new GetBlockedListException("Could not get blocked list from FritzBox: " + e.getMessage());
}
List blockedNumbers = new ArrayList();
String[] s = data.toString().split("CallerID");
Pattern p = Pattern.compile(PATTERN_DETECT_BLOCKED_NUMBER, Pattern.UNICODE_CASE);
for (int i = 0, j = s.length; i < j; i++) {
Matcher m = p.matcher(s[i]);
while (m.find()) {
if (m.group(1).trim().length() > 3)
blockedNumbers.add(m.group(1).trim());
}
}
return blockedNumbers;
}
use of de.janrufmonitor.fritzbox.firmware.exception.GetBlockedListException in project janrufmonitor by tbrandt77.
the class FritzOSFirmware method getBlockedList.
public List getBlockedList() throws GetBlockedListException, IOException {
if (!this.isInitialized())
throw new GetBlockedListException("Could not get blocked list from FritzBox: FritzBox firmware not initialized.");
StringBuffer data = new StringBuffer();
String urlstr = getProtocol() + this.m_address + ":" + this.m_port + "/fon_num/sperre.lua?sid=" + this.m_sid;
try {
data.append(this.executeURL(urlstr, null, true).trim());
} catch (UnsupportedEncodingException e) {
this.m_logger.log(Level.WARNING, e.getMessage(), e);
} catch (IOException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
throw new GetBlockedListException("Could not get blocked list from FritzBox: " + e.getMessage());
}
List blockedNumbers = new ArrayList();
String[] s = data.toString().split("CallerID");
Pattern p = Pattern.compile(PATTERN_DETECT_BLOCKED_NUMBER, Pattern.UNICODE_CASE);
for (int i = 0, j = s.length; i < j; i++) {
Matcher m = p.matcher(s[i]);
while (m.find()) {
if (m.group(1).trim().length() > 3)
blockedNumbers.add(m.group(1).trim());
}
}
return blockedNumbers;
}
use of de.janrufmonitor.fritzbox.firmware.exception.GetBlockedListException in project janrufmonitor by tbrandt77.
the class UnitymediaFirmware method getBlockedList.
public List getBlockedList() throws GetBlockedListException, IOException {
if (!this.isInitialized())
throw new GetBlockedListException("Could not get blocked list from FritzBox: FritzBox firmware not initialized.");
StringBuffer data = new StringBuffer();
String urlstr = getProtocol() + this.m_address + ":" + this.m_port + "/fon_num/sperre.lua?sid=" + this.m_sid;
try {
data.append(this.executeURL(urlstr, null, true).trim());
} catch (UnsupportedEncodingException e) {
this.m_logger.log(Level.WARNING, e.getMessage(), e);
} catch (IOException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
throw new GetBlockedListException("Could not get blocked list from FritzBox: " + e.getMessage());
}
List blockedNumbers = new ArrayList();
String[] s = data.toString().split("CallerID");
Pattern p = Pattern.compile(PATTERN_DETECT_BLOCKED_NUMBER, Pattern.UNICODE_CASE);
for (int i = 0, j = s.length; i < j; i++) {
Matcher m = p.matcher(s[i]);
while (m.find()) {
if (m.group(1).trim().length() > 3)
blockedNumbers.add(m.group(1).trim());
}
}
return blockedNumbers;
}
use of de.janrufmonitor.fritzbox.firmware.exception.GetBlockedListException in project janrufmonitor by tbrandt77.
the class TR064FritzBoxFirmware method getBlockedList.
public List getBlockedList() throws GetBlockedListException, IOException {
if (!this.isInitialized())
throw new GetBlockedListException("Could not get blocked list from FritzBox: FritzBox firmware not initialized.");
StringBuffer data = new StringBuffer();
String u = "http://" + this.m_server + ":" + this.m_port + "/fon_num/sperre.lua?sid=" + FritzBoxTR064Manager.getInstance().getSID(this.m_user, this.m_password, this.m_server, (this.m_useHttp ? FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064Port() : FritzBoxTR064Manager.getInstance().getDefaultFritzBoxTR064SecurePort(this.m_server)), (this.m_useHttp ? "http" : "https"));
try {
data.append(doHttpCall(u, "GET", null, new String[][] {}));
} catch (UnsupportedEncodingException e) {
this.m_logger.log(Level.WARNING, e.getMessage(), e);
} catch (IOException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
throw new GetBlockedListException("Could not get blocked list from FritzBox: " + e.getMessage());
}
List blockedNumbers = new ArrayList();
String[] s = data.toString().split("CallerID");
Pattern p = Pattern.compile("] = \"([\\d]*)\",", Pattern.UNICODE_CASE);
for (int i = 0, j = s.length; i < j; i++) {
Matcher m = p.matcher(s[i]);
while (m.find()) {
if (m.group(1).trim().length() > 3)
blockedNumbers.add(m.group(1).trim());
}
}
return blockedNumbers;
}
Aggregations