private boolean loadMatchRules ( String rulesUrl ) { //load match rules from file try { //check for file URL if ( rulesUrl != null && rulesUrl . toLowerCase ( ) . startsWith ( "file:" ) ) { return loadMatchRulesFromFile ( rulesUrl ) ; } //request match rules from remote URL mCallbacks . printOutput ( "Loading match rules from: " + rulesUrl ) ; URL url = new URL ( rulesUrl ) ; IHttpService service = new HttpService ( url ) ; HttpRequest request = new HttpRequest ( url ) ; byte [ ] responseBytes = mCallbacks . makeHttpRequest ( service . getHost ( ) , service . getPort ( ) , HttpService . PROTOCOL_HTTPS . equalsIgnoreCase ( service . getProtocol ( ) ) , request . getBytes ( ) ) ; //parse the response if ( responseBytes == null ) return false ; //no response received from server HttpResponse response = HttpResponse . parseMessage ( responseBytes ) ; //read match rules from the response Reader is = new StringReader ( response . getBody ( ) ) ; BufferedReader reader = new BufferedReader ( is ) ; processMatchRules ( reader ) ; return true ; } catch ( IOException e ) { scan . printStackTrace ( e ) ; } catch ( Exception e ) { scan . printStackTrace ( e ) ; } return false ; }
Load match rules from a URL