Skip to content

Commit 81df035

Browse files
committed
Implemented reporting, all is ok, but it remains
1 parent ce61ea4 commit 81df035

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

src/main/java/org/jetbrains/research/groups/ml_methods/error_reporting/AnonymousFeedback.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212

1313
import javax.annotation.Nullable;
1414
import java.io.IOException;
15-
import java.net.URL;
1615
import java.util.*;
1716
import java.util.Map.Entry;
1817

1918
/**
2019
* Provides functionality to create and send GitHub issues when an exception is thrown by a plugin.
2120
*/
2221
class AnonymousFeedback {
23-
24-
private final static String tokenFile = "de/halirutan/mathematica/errorreporting/ScrambledToken.bin";
22+
private final static String tokenFile = "errorReporterToken";
2523
private final static String gitRepoUser = "ml-in-programming";
2624
private final static String gitRepo = "ArchitectureReloaded";
2725

@@ -42,12 +40,7 @@ static SubmittedReportInfo sendFeedback(LinkedHashMap<String, String> environmen
4240

4341
final SubmittedReportInfo result;
4442
try {
45-
// TODO: erase token
46-
final URL resource = AnonymousFeedback.class.getClassLoader().getResource(tokenFile);
47-
if (resource == null) {
48-
throw new IOException("Could not decrypt access token");
49-
}
50-
final String gitAccessToken = GitHubAccessTokenScrambler.decrypt(resource.getFile());
43+
final String gitAccessToken = GitHubAccessTokenScrambler.decrypt(AnonymousFeedback.class.getResourceAsStream(tokenFile));
5144

5245
GitHubClient client = new GitHubClient();
5346
client.setOAuth2Token(gitAccessToken);

src/main/java/org/jetbrains/research/groups/ml_methods/error_reporting/GitHubAccessTokenScrambler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import javax.crypto.Cipher;
77
import javax.crypto.spec.IvParameterSpec;
88
import javax.crypto.spec.SecretKeySpec;
9-
import java.io.FileInputStream;
109
import java.io.FileOutputStream;
10+
import java.io.InputStream;
1111
import java.io.ObjectInputStream;
1212
import java.io.ObjectOutputStream;
1313

@@ -52,9 +52,9 @@ private static String encrypt(String value) {
5252
return null;
5353
}
5454

55-
static String decrypt(String file) throws Exception {
55+
static String decrypt(InputStream inputStream) throws Exception {
5656
String in;
57-
final ObjectInputStream o = new ObjectInputStream(new FileInputStream(file));
57+
final ObjectInputStream o = new ObjectInputStream(inputStream);
5858
in = (String) o.readObject();
5959
IvParameterSpec iv = new IvParameterSpec(myInitVector.getBytes("UTF-8"));
6060
SecretKeySpec keySpec = new SecretKeySpec(myKey.getBytes("UTF-8"), "AES");
Binary file not shown.

0 commit comments

Comments
 (0)