Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "deprecationInformation" field support #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class SafetyNetResponse {
private boolean basicIntegrity;
private String evaluationType;
private String advice;
private String deprecationInformation;

//forces the parse()
private SafetyNetResponse() {
Expand Down Expand Up @@ -119,6 +120,15 @@ public String getAdvice() {
return advice;
}

/**
* Info about SN API Deprecation
*
* @return
*/
public String getDeprecationInformation() {
return deprecationInformation;
}

/**
* Parse the JSON string into populated SafetyNetResponse object
*
Expand Down Expand Up @@ -174,6 +184,10 @@ public static SafetyNetResponse parse(@NonNull String decodedJWTPayload) {
response.advice = root.getString("advice");
}

if (root.has("deprecationInformation")) {
response.deprecationInformation = root.getString("deprecationInformation");
}

return response;
} catch (JSONException e) {
Log.e(TAG, "problem parsing decodedJWTPayload:" + e.getMessage(), e);
Expand All @@ -194,6 +208,7 @@ public String toString() {
", basicIntegrity=" + basicIntegrity +
", evaluationType=" + evaluationType +
", advice=" + advice +
", deprecationInformation=" + deprecationInformation +
'}';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ public void onAnimationUpdate(ValueAnimator animator) {

private void updateUIWithSuccessfulResult(SafetyNetResponse safetyNetResponse) {
String advice = safetyNetResponse.getAdvice() == null ? "None available" : safetyNetResponse.getAdvice();
String deprecationInformation = safetyNetResponse.getDeprecationInformation() == null ? "None available" : safetyNetResponse.getDeprecationInformation();

resultsTV.setText(getString(R.string.safety_results,
safetyNetResponse.isCtsProfileMatch(),
safetyNetResponse.isBasicIntegrity(),
safetyNetResponse.getEvaluationType(),
advice));
advice,
deprecationInformation));
resultNoteTV.setText(R.string.safety_results_note);

successResultsContainer.setVisibility(View.VISIBLE);
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<string name="action_share">Share</string>
<string name="about_version">version %1$s [%2$d]</string>
<string name="action_github">View code on GitHub</string>
<string name="safety_results">SafetyNet response\nCTS profile match: %1$b\nBasic Integrity: %2$b\nEvaluation type: %3$s\nAdvice: %4$s</string>
<string name="safety_results">SafetyNet response\nCTS profile match: %1$b\nBasic Integrity: %2$b\nEvaluation type: %3$s\nAdvice: %4$s\nDeprecation Information: %5$s</string>
<string name="safety_results_note">Note: The "basicIntegrity" field is a weaker check than "ctsProfileMatch". For apps requiring stronger checks, use only the result from "ctsProfileMatch".</string>
<string name="request_token">One time request token</string>
<string name="timestamp">Request timestamp</string>
Expand Down