Ignore:
Timestamp:
2019-11-20T11:30:47+13:00 (4 years ago)
Author:
davidb
Message:

Changed code so api key can be in separate file, and passed in on the command-line to the Java code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/malware-checker/trunk/java/src/main/java/org/greenstone/virustotal/ScanFile.java

    r33664 r33708  
    1515public class ScanFile {
    1616    public static void printUsage(){
    17         System.err.println("Usage: ScanFile [all] file");
     17        System.err.println("Usage: ScanFile [-all] api-key file");
    1818        System.exit(1);
    1919    }
    2020
    2121    public static void main(String[] args) {
     22    String apiKey = null;
    2223    String inputFileName = null;
     24   
    2325    boolean printall=false;
    24     if (args.length<1 || args.length>2){
     26    if (args.length<1 || args.length>3){
    2527        printUsage();
    2628
    2729    }
    28     else if(args.length==2){
    29         if(args[0].equals("all")){
    30             inputFileName = args[1];
     30    else if(args.length==3){
     31        if(args[0].equals("-all")){
     32            apiKey = args[1];
     33            inputFileName = args[2];
    3134            printall=true;
    3235        }
     
    3639           
    3740    }
    38    
    39     else{
    40         inputFileName = args[0];
     41    else if(args.length==2){
     42        apiKey = args[0];
     43        inputFileName = args[1];
     44    }
     45    else {
     46        printUsage();
    4147    }
    4248
    4349    try {
    4450   
    45             VirusTotalConfig.getConfigInstance().setVirusTotalAPIKey("09311639ef4193fc22faa35d493a5bf12dc44844a55f03812e40bd1a16fd7b6f");
     51            VirusTotalConfig.getConfigInstance().setVirusTotalAPIKey(apiKey);
     52       
    4653            VirustotalPublicV2 virusTotalRef = new VirustotalPublicV2Impl();
    4754
Note: See TracChangeset for help on using the changeset viewer.