Skip to content

Commit 1af990d

Browse files
committed
Fixed token decoding
1 parent 04d5e6f commit 1af990d

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/de/halirutan/mathematica/errorreporting/AnonymousFeedback.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
package de.halirutan.mathematica.errorreporting;
2323

24+
import com.intellij.openapi.diagnostic.Logger;
2425
import com.intellij.openapi.diagnostic.SubmittedReportInfo;
2526
import com.intellij.openapi.diagnostic.SubmittedReportInfo.SubmissionStatus;
2627
import org.eclipse.egit.github.core.Issue;
@@ -59,14 +60,16 @@ private AnonymousFeedback() {
5960
* of the created issue.
6061
*/
6162
static SubmittedReportInfo sendFeedback(LinkedHashMap<String, String> environmentDetails) {
63+
final Logger myLogger = Logger.getInstance(AnonymousFeedback.class.getName());
6264

6365
final SubmittedReportInfo result;
6466
try {
6567
final URL resource = AnonymousFeedback.class.getClassLoader().getResource(tokenFile);
6668
if (resource == null) {
69+
myLogger.info("Could not find token file");
6770
throw new IOException("Could not decrypt access token");
6871
}
69-
final String gitAccessToken = GitHubAccessTokenScrambler.decrypt(resource.getFile());
72+
final String gitAccessToken = GitHubAccessTokenScrambler.decrypt(resource);
7073
GitHubClient client = new GitHubClient();
7174
client.setOAuth2Token(gitAccessToken);
7275
RepositoryId repoID = new RepositoryId(gitRepoUser, gitRepo);

src/de/halirutan/mathematica/errorreporting/GitHubAccessTokenScrambler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import javax.crypto.spec.IvParameterSpec;
2828
import javax.crypto.spec.SecretKeySpec;
2929
import java.io.*;
30+
import java.net.URL;
3031

3132
/**
3233
* Provides functionality to encode and decode secret tokens to make them not directly readable. Let me be clear:
@@ -70,9 +71,9 @@ private static String encrypt(String value) {
7071
return null;
7172
}
7273

73-
static String decrypt(String file) throws Exception {
74+
static String decrypt(URL file) throws Exception {
7475
String in;
75-
final ObjectInputStream o = new ObjectInputStream(new FileInputStream(file));
76+
final ObjectInputStream o = new ObjectInputStream(file.openStream());
7677
in = (String) o.readObject();
7778
IvParameterSpec iv = new IvParameterSpec(myInitVector.getBytes("UTF-8"));
7879
SecretKeySpec keySpec = new SecretKeySpec(myKey.getBytes("UTF-8"), "AES");

0 commit comments

Comments
 (0)