Skip to content

Commit

Permalink
More robust to jwt generation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dimtion committed Apr 1, 2020
1 parent c2f4f55 commit 6044b42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/src/main/java/com/dimtion/shaarlier/helpers/DebugHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.util.Log;

import com.dimtion.shaarlier.R;

Expand All @@ -21,12 +22,14 @@
public class DebugHelper {

public static void sendMailDev(Activity context, String subject, String content) {
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", context.getString(R.string.developer_mail), null));
Log.d("sendMailDev", content);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{context.getString(R.string.developer_mail)});
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, content);

context.startActivity(Intent.createChooser(intent, "Debug report..."));
context.startActivity(intent);
}

public static String generateReport(Exception e, Activity activity, String extra) {
Expand All @@ -36,7 +39,7 @@ public static String generateReport(Exception e, Activity activity, String extra
}

public static String generateReport(String[] errorMessage, Activity activity, String extra){
String message = "Feel free to add a little message : \n\n";
String message = "Feel free to add a little message: \n\n";

message += "-----BEGIN REPORT-----\n";
message += "Report type: DEBUG \n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public boolean isCompatibleShaarli() throws IOException {
} catch (JSONException e) {
Log.e("RestAPINetworkManager", e.toString());
return false;
} catch (IllegalArgumentException e) {
// This exception arises in a bug in JJWT module. I added that to help with the debugging
Log.e("RestAPINetworkManager", e.toString());
throw new IOException("isCompatibleShaarli: " + e.toString());
}
// assume a 2XX or 3XX means API V1 supported
return true;
Expand Down Expand Up @@ -211,6 +215,8 @@ public List<String> retrieveTags() throws Exception {
* @return JWT encoded in base 64
*/
String getJwt() {
// TODO: we are obligated to stay with jjwt 0.9.1 because of Shaarli week keys

// iat in the payload
Date date = new Date();
// During debugging I found that given that some servers and phones are not absolutely in sync
Expand Down

0 comments on commit 6044b42

Please sign in to comment.