source: gs2-extensions/malware-checker/trunk/java/src/main/java/org/greenstone/virustotal/AddComment.java@ 33664

Last change on this file since 33664 was 33664, checked in by davidb, 4 years ago

Initial version code for running VirusTotal API against files, CLI scripts

File size: 1.6 KB
Line 
1package org.greenstone.virustotal;
2import com.kanishka.virustotal.dto.GeneralResponse;
3import com.kanishka.virustotal.exception.APIKeyNotFoundException;
4import com.kanishka.virustotal.exception.UnauthorizedAccessException;
5import com.kanishka.virustotalv2.VirusTotalConfig;
6import com.kanishka.virustotalv2.VirustotalPublicV2;
7import com.kanishka.virustotalv2.VirustotalPublicV2Impl;
8
9import java.io.UnsupportedEncodingException;
10
11public class AddComment {
12 public static void main(String[] args) {
13
14 try {
15 VirusTotalConfig.getConfigInstance().setVirusTotalAPIKey("09311639ef4193fc22faa35d493a5bf12dc44844a55f03812e40bd1a16fd7b6f");
16 VirustotalPublicV2 virusTotalRef = new VirustotalPublicV2Impl();
17
18 String resourceID = null;
19 String comment = null;
20 resourceID = args[0];
21 comment = args[1];
22
23 GeneralResponse gRespo = virusTotalRef.makeAComment(resourceID, comment);
24
25 System.out.println("Response Code : " + gRespo.getResponseCode());
26 System.out.println("Verbose Message : " + gRespo.getVerboseMessage());
27
28 } catch (APIKeyNotFoundException ex) {
29 System.err.println("API Key not found! " + ex.getMessage());
30 System.exit(1);
31 } catch (UnsupportedEncodingException ex) {
32 System.err.println("Unsupported Encoding Format!" + ex.getMessage());
33 System.exit(2);
34 } catch (UnauthorizedAccessException ex) {
35 System.err.println("Invalid API Key " + ex.getMessage());
36 System.exit(3);
37 } catch (Exception ex) {
38 System.err.println("Something Bad Happened! " + ex.getMessage());
39 System.exit(4);
40 }
41 }
42
43}
Note: See TracBrowser for help on using the repository browser.