Skip to content

Commit

Permalink
Merge pull request #549 from martenrebane/MOPPAND-1418
Browse files Browse the repository at this point in the history
Add better message when NFC CAN number is wrong
  • Loading branch information
Counter178 authored Nov 12, 2024
2 parents 4a74e42 + 563025e commit fab9c9b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ private NFCResponse onTagDiscovered(NfcAdapter adapter, Tag tag) {
result = NFCResponse.createWithStatus(SessionStatusResponse.ProcessStatus.TECHNICAL_ERROR, exc.getMessage());
} catch (Exception exc) {
Timber.log(Log.ERROR, exc.getMessage());
result = NFCResponse.createWithStatus(SessionStatusResponse.ProcessStatus.TECHNICAL_ERROR, exc.getMessage());
if (exc.getMessage() != null && exc.getMessage().contains("Mutual authentication: Invalid result")) {
Timber.log(Log.ERROR, "Wrong NFC CAN number");
result = NFCResponse.createWithStatus(SessionStatusResponse.ProcessStatus.TECHNICAL_ERROR, navigator.activity().getString(R.string.signature_update_nfc_wrong_can));
} else {
result = NFCResponse.createWithStatus(SessionStatusResponse.ProcessStatus.TECHNICAL_ERROR, exc.getMessage());
}
} finally {
adapter.disableReaderMode(navigator.activity());
card = null;
Expand Down
1 change: 1 addition & 0 deletions common-lib/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<string name="signature_update_signature_error_message_too_many_requests">Sinu %1$s tasuta allkirjade kuulimiit on ületatud. https://www.id.ee/artikkel/asutustele-kus-allkirjastatakse-digidoc4-kliendi-kaudu-suuremates-kogustes-dokumente/</string>
<string name="id_card_conditional_speech">ID-kaardi</string>
<string name="main_settings_proxy_invalid_settings">Teenuse serveriga ühendus ebaõnnestus. Palun kontrolli võrgu sätteid või proovi hiljem uuesti.</string>
<string name="signature_update_nfc_wrong_can">Vale ligipääsu number (CAN kood)!</string>
</resources>
1 change: 1 addition & 0 deletions common-lib/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<string name="signature_update_signature_error_message_too_many_requests">Ваш месячный лимит бесплатных подписей для %1$s превышен. https://www.id.ee/ru/artikkel/dlya-uchrezhdenij-v-kotoryh-v-bolshom-obeme-podpisyvayutsya-dokumenty-s-pomoshhyu-digidoc4-klienta/</string>
<string name="id_card_conditional_speech">ID-карты</string>
<string name="main_settings_proxy_invalid_settings">Не удалось связаться с сервером услуги. Пожалуйста, проверьте настройки сети или повторите попытку позже.</string>
<string name="signature_update_nfc_wrong_can">Некорректный номер доступа (CAN код)!</string>
</resources>
1 change: 1 addition & 0 deletions common-lib/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<string name="signature_update_signature_error_message_too_many_requests">The limit for %1$s digital signatures per month has been reached. https://www.id.ee/en/article/for-organisations-that-sign-large-quantities-of-documents-using-digidoc4-client/</string>
<string name="id_card_conditional_speech">ID-card\'s</string>
<string name="main_settings_proxy_invalid_settings">Failed to connect with service server. Please check your network settings or try again later.</string>
<string name="signature_update_nfc_wrong_can">Wrong access number (CAN code)!</string>
</resources>
3 changes: 3 additions & 0 deletions id-card-lib/src/main/java/ee/ria/DigiDoc/idcard/NFC.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public NFCException(String message) {

@Override
public String getMessage(Context context) {
if (message.contains("Mutual authentication: Invalid result")) {
return context.getString(R.string.signature_update_nfc_wrong_can);
}
return message;
}
}
Expand Down

0 comments on commit fab9c9b

Please sign in to comment.