1 | package org.greenstone.virustotal;
|
---|
2 | import com.kanishka.virustotal.dto.GeneralResponse;
|
---|
3 | import com.kanishka.virustotal.exception.APIKeyNotFoundException;
|
---|
4 | import com.kanishka.virustotal.exception.UnauthorizedAccessException;
|
---|
5 | import com.kanishka.virustotalv2.VirusTotalConfig;
|
---|
6 | import com.kanishka.virustotalv2.VirustotalPublicV2;
|
---|
7 | import com.kanishka.virustotalv2.VirustotalPublicV2Impl;
|
---|
8 |
|
---|
9 | import java.io.UnsupportedEncodingException;
|
---|
10 |
|
---|
11 | public 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 | }
|
---|