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 better NFC translations #540

Merged
merged 2 commits into from
Sep 6, 2024
Merged
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 @@ -49,9 +49,9 @@
import ee.ria.DigiDoc.android.ApplicationApp;
import ee.ria.DigiDoc.android.accessibility.AccessibilityUtils;
import ee.ria.DigiDoc.android.signature.update.mobileid.MobileIdResponse;
import ee.ria.DigiDoc.android.signature.update.smartid.SmartIdResponse;
import ee.ria.DigiDoc.android.signature.update.nfc.NFCDialog;
import ee.ria.DigiDoc.android.signature.update.nfc.NFCResponse;
import ee.ria.DigiDoc.android.signature.update.smartid.SmartIdResponse;
import ee.ria.DigiDoc.android.utils.DateUtil;
import ee.ria.DigiDoc.android.utils.ToastUtil;
import ee.ria.DigiDoc.android.utils.ViewDisposables;
Expand Down Expand Up @@ -587,10 +587,14 @@ public void render(ViewState state) {

if (signatureAddResponse instanceof NFCResponse) {
NFCResponse nfcResponse = (NFCResponse) signatureAddResponse;
Timber.log(Log.DEBUG, "NFC:SignatureUpdateView.render, status %s", nfcResponse.status().toString());
if (nfcResponse.status() != null) {
Timber.log(Log.DEBUG, "NFC:SignatureUpdateView.render, status %s", nfcResponse.status().toString());
}
nfcDialog.showStatus(nfcResponse);
nfcDialog.show();
}
} else {
nfcDialog.dismiss();
}

setupAccessibilityTabs();
Expand Down Expand Up @@ -741,15 +745,19 @@ private void sendMethodSelectionAccessibilityEvent(int method) {
if (signatureMethod.equalsIgnoreCase(getResources().getString(R.string.signature_update_signature_add_method_mobile_id))) {
AccessibilityUtils.sendAccessibilityEvent(getContext(), TYPE_WINDOW_STATE_CHANGED,
getResources().getString(R.string.signature_update_signature_chosen_method_mobile_id));
AccessibilityUtils.sendAccessibilityEvent(getContext(), TYPE_ANNOUNCEMENT, getResources().getString(R.string.signature_update_signature_selected_method_mobile_id, 1, 4));
} else if (signatureMethod.equalsIgnoreCase(getResources().getString(R.string.signature_update_signature_add_method_smart_id))) {
AccessibilityUtils.sendAccessibilityEvent(getContext(), TYPE_WINDOW_STATE_CHANGED,
getResources().getString(R.string.signature_update_signature_chosen_method_smart_id));
AccessibilityUtils.sendAccessibilityEvent(getContext(), TYPE_ANNOUNCEMENT, getResources().getString(R.string.signature_update_signature_selected_method_smart_id, 2, 4));
} else if (signatureMethod.equalsIgnoreCase(getResources().getString(R.string.signature_update_signature_add_method_id_card))) {
AccessibilityUtils.sendAccessibilityEvent(getContext(), TYPE_WINDOW_STATE_CHANGED,
getResources().getString(R.string.signature_update_signature_chosen_method_id_card));
AccessibilityUtils.sendAccessibilityEvent(getContext(), TYPE_ANNOUNCEMENT, getResources().getString(R.string.signature_update_signature_selected_method_id_card, 3, 4));
} else if (signatureMethod.equalsIgnoreCase(getResources().getString(R.string.signature_update_signature_add_method_nfc))) {
AccessibilityUtils.sendAccessibilityEvent(getContext(), TYPE_WINDOW_STATE_CHANGED,
getResources().getString(R.string.signature_update_signature_chosen_method_nfc));
AccessibilityUtils.sendAccessibilityEvent(getContext(), TYPE_ANNOUNCEMENT, getResources().getString(R.string.signature_update_signature_selected_method_nfc, 4, 4));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,18 @@ public void subscribe(ObservableEmitter<NFCResponse> emitter) {
emitter.onNext(NFCResponse.createWithStatus(SessionStatusResponse.ProcessStatus.OK, navigator.activity().getString(R.string.signature_update_nfc_detected)));
NFCResponse response = onTagDiscovered(adapter, tag);
Timber.log(Log.DEBUG, "NFC::completed");
emitter.onNext((response != null) ? response : NFCResponse.success(container));
emitter.onComplete();
if (response != null) {
if (response.status() != SessionStatusResponse.ProcessStatus.OK) {
Timber.log(Log.ERROR, String.format("NFC status: %s", response.status()));
emitter.onError(new NFC.NFCException(response.message()));
} else {
emitter.onNext(response);
emitter.onComplete();
}
} else {
emitter.onNext(NFCResponse.success(container));
emitter.onComplete();
}
}, NfcAdapter.FLAG_READER_NFC_A, null);
}
}
Expand Down Expand Up @@ -94,14 +104,14 @@ private NFCResponse onTagDiscovered(NfcAdapter adapter, Tag tag) {
byte[] certificate = nfc.readCertificate();
if (certificate == null) {
Timber.log(Log.ERROR, "Failed to read certificate. Certificate is null");
throw new RuntimeException("Unable to read certificate for NFC");
throw new RuntimeException(navigator.activity().getString(R.string.signature_update_nfc_technical_error));
}
Timber.log(Log.DEBUG, "CERT:%s", Hex.toHexString(certificate));
Timber.log(Log.DEBUG, "CERT: %s", Hex.toHexString(certificate));
Certificate cert = Certificate.create(ByteString.of(certificate, 0, certificate.length));

// Step 2 - verify PIN2
NFC.Result r = nfc.communicateSecure(SEL_QSCD_CMD, SEL_QSCD);
Timber.log(Log.DEBUG, "Select QSCD AID:%x %s", r.code, Hex.toHexString(r.data));
Timber.log(Log.DEBUG, "Select QSCD AID: %x %s", r.code, Hex.toHexString(r.data));

// pad the PIN and use the chip for verification
byte[] paddedPIN = Hex.decode("ffffffffffffffffffffffff");
Expand All @@ -110,19 +120,20 @@ private NFCResponse onTagDiscovered(NfcAdapter adapter, Tag tag) {
if (null != pin2 && pin2.length > 0) {
Arrays.fill(pin2, (byte) 0);
}
Timber.log(Log.DEBUG, "Verify PIN2:%x %s", r.code, Hex.toHexString(r.data));
Timber.log(Log.DEBUG, "Verify PIN2: %x %s", r.code, Hex.toHexString(r.data));
if (r.code != 0x9000) {
if (r.code == 0x6983) {
throw new RuntimeException(navigator.activity().getString(R.string.signature_update_id_card_sign_pin2_locked));
} else if ((r.code & 0xfff0) == 0x63c0) {
throw new RuntimeException(String.format(navigator.activity().getString(R.string.signature_update_id_card_sign_pin2_invalid), r.code & 0xf));
} else {
throw new RuntimeException("Verification error");
Timber.log(Log.ERROR, "PIN2 verification error");
throw new RuntimeException(navigator.activity().getString(R.string.signature_update_nfc_technical_error));
}
}

r = nfc.communicateSecure(CMD_SET_ENV_SIGN, SET_ENV_SIGN);
Timber.log(Log.DEBUG, "Set ENV:%x %s", r.code, Hex.toHexString(r.data));
Timber.log(Log.DEBUG, "Set ENV: %x %s", r.code, Hex.toHexString(r.data));

container.sign(cert.data(),
signData -> ByteString.of(nfc.calculateSignature(signData.toByteArray())), role);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

import com.google.auto.value.AutoValue;

import ee.ria.DigiDoc.android.model.idcard.IdCardDataResponse;
import ee.ria.DigiDoc.android.model.idcard.IdCardSignResponse;
import ee.ria.DigiDoc.android.signature.update.SignatureAddResponse;
import ee.ria.DigiDoc.android.signature.update.smartid.SmartIdResponse;
import ee.ria.DigiDoc.sign.SignedContainer;
import ee.ria.DigiDoc.smartid.dto.response.SessionStatusResponse;

Expand Down
18 changes: 11 additions & 7 deletions app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@
<string name="signature_update_signature_selected_method_mobile_id">Allkirjastamise viisiks on Mobiil-ID, vahekaart %1$d / %2$d</string>
<string name="signature_update_signature_selected_method_smart_id">Allkirjastamise viisiks on Smart-ID, vahekaart %1$d / %2$d</string>
<string name="signature_update_signature_selected_method_id_card">Allkirjastamise viisiks on ID-kaart, vahekaart %1$d / %2$d</string>
<string name="signature_update_signature_selected_method_nfc">Allkirjastamise viisiks on NFC, vahekaart %1$d / %2$d</string>
<string name="signature_update_signature_selected_method_nfc">Kontaktivaba allkirjastamise võimalus (NFC), vahekaart %1$d / %2$d</string>

<string name="signature_update_signature_chosen_method_mobile_id">Allkirjastamisviis mobiil-ID on valitud</string>
<string name="signature_update_signature_chosen_method_smart_id">Smart-ID allkirjastamise vahend valitud</string>
<string name="signature_update_signature_chosen_method_id_card">ID-kaart allkirjastamise vahend valitud</string>
<string name="signature_update_signature_chosen_method_nfc">NFC allkirjastamise vahend valitud</string>
<string name="signature_update_signature_chosen_method_nfc">Kontaktivaba allkirjastamise vahend valitud</string>

<string name="signature_update_mobile_id_message">Sisesta oma telefoninumber ja isikukood mobiil-IDga allkirjastamiseks</string>
<string name="signature_update_mobile_id_phone_no">Riigikood ja telefoninumber</string>
Expand Down Expand Up @@ -297,13 +297,17 @@
<string name="signature_update_id_card_sign_pin2_invalid_final">Vale PIN2. Järgmise vale sisestusega lukustub PIN.</string>
<string name="signature_update_id_card_sign_pin2_locked">PIN2 on lukus. Mine Minu eID, et avada.</string>

<string name="nfc_sign_can_invalid_length">CAN-kood peab olema %1$s-kohaline</string>
<string name="nfc_sign_can_invalid_length">Ligipääsu number (CAN) peab olema %1$s-kohaline</string>
<string name="id_card_sign_pin_invalid_length">%1$s-kood peab olema vähemalt %2$s-kohaline ja maksimaalselt %3$s-kohaline</string>

<string name="signature_update_nfc_message">Enter your CAN number and PIN 2 code to sign with ID-Card using NFC</string>
<string name="signature_update_nfc_can">CAN code on card</string>
<string name="signature_update_nfc_pin2">PIN 2 code</string>
<string name="signature_update_nfc_adapter_missing">See seade ei toeta NFC-d.</string>
<string name="signature_update_nfc_message">ID-kaardiga allkirjastamiseks sisesta oma ID-kaardi ligipääsu number (CAN) ja PIN2 kood</string>
<string name="signature_update_nfc_can">ID-kaardi ligipääsu number (CAN)</string>
<string name="signature_update_nfc_pin2">PIN2 kood</string>
<string name="signature_update_nfc_adapter_missing">See seade ei toeta kontaktivaba ühendust või NFC on välja lülitatud</string>
<string name="signature_update_nfc_tag_lost">Kontaktivaba ühendust ei saa luua</string>
<string name="signature_update_nfc_technical_error">Midagi läks valesti. Palun proovi uuesti</string>
<string name="signature_update_nfc_hold">Hoia ID-kaarti telefoni lähedal</string>
<string name="signature_update_nfc_detected">ID-kaardiga kontaktivaba ühenduse loomine</string>

<!-- Signature Details -->
<string name="signature_error_details_title">Hoiatused</string>
Expand Down
18 changes: 11 additions & 7 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@
<string name="signature_update_signature_selected_method_mobile_id">Метод подписи – Mobiil-ID, вкладка %1$d из %2$d</string>
<string name="signature_update_signature_selected_method_smart_id">Метод подписи – Smart-ID, вкладка %1$d из %2$d</string>
<string name="signature_update_signature_selected_method_id_card">Метод подписи – ID-карта, вкладка %1$d из %2$d</string>
<string name="signature_update_signature_selected_method_nfc">Метод подписи – NFC, вкладка %1$d из %2$d</string>
<string name="signature_update_signature_selected_method_nfc">Возможность бесконтактного подписания (NFC), вкладка %1$d из %2$d</string>

<string name="signature_update_signature_chosen_method_mobile_id">Выбран метод подписи Mobiil-ID</string>
<string name="signature_update_signature_chosen_method_smart_id">Выбран метод подписи Smart-ID</string>
<string name="signature_update_signature_chosen_method_id_card">Выбран метод подписи ID-карта</string>
<string name="signature_update_signature_chosen_method_nfc">Выбран метод подписи NFC</string>
<string name="signature_update_signature_chosen_method_nfc">Cредство бесконтактного подписания выбрано</string>

<string name="signature_update_mobile_id_message">Введите свой телефонный номер и личный код для подписания с помощью mobiil-ID</string>
<string name="signature_update_mobile_id_phone_no">Код страны и телефонный номер</string>
Expand Down Expand Up @@ -299,13 +299,17 @@
<string name="signature_update_id_card_sign_pin2_invalid_final">Неверный PIN2. У Вас осталась 1 попытка до блокировки Вашего PIN2.</string>
<string name="signature_update_id_card_sign_pin2_locked">PIN2 заблокирован. Зайдите в Мой eID, чтобы разблокировать его.</string>

<string name="nfc_sign_can_invalid_length">CAN-код должен состоять из %1$s символов</string>
<string name="nfc_sign_can_invalid_length">Номер доступа (CAN) должен состоять из %1$s-цифр</string>
<string name="id_card_sign_pin_invalid_length">%1$s-код должен состоять минимум из %2$s и максимум из %3$s символов</string>

<string name="signature_update_nfc_message">Enter your CAN number and PIN 2 code to sign with ID-Card using NFC</string>
<string name="signature_update_nfc_can">CAN code on card</string>
<string name="signature_update_nfc_pin2">PIN 2 code</string>
<string name="signature_update_nfc_adapter_missing">Это устройство не поддерживает NFC.</string>
<string name="signature_update_nfc_message">Чтобы подписать с помощью ID-карты, введите ее номер доступа (CAN) и PIN2-код</string>
<string name="signature_update_nfc_can">Номер доступа ID-карты (CAN)</string>
<string name="signature_update_nfc_pin2">PIN2-код</string>
<string name="signature_update_nfc_adapter_missing">Данное устройство не поддерживает бесконтактное соединение или NFC отключен</string>
<string name="signature_update_nfc_tag_lost">Создание бесконтактного соединения не удалось</string>
<string name="signature_update_nfc_technical_error">Что-то пошло не так. Пожалуйста, попробуйте еще раз</string>
<string name="signature_update_nfc_hold">Удерживайте ID-карту рядом с телефоном</string>
<string name="signature_update_nfc_detected">Создание бесконтактного соединения с ID-картой</string>

<!-- Signature Details -->
<string name="signature_error_details_title">Предупреждения</string>
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
<string name="signature_update_signature_selected_method_mobile_id">Signing option Mobile-ID, tab %1$d of %2$d</string>
<string name="signature_update_signature_selected_method_smart_id">Signing option Smart-ID, tab %1$d of %2$d</string>
<string name="signature_update_signature_selected_method_id_card">Signing option ID-card, tab %1$d of %2$d</string>
<string name="signature_update_signature_selected_method_nfc">Signing option NFC, tab %1$d / %2$d</string>
<string name="signature_update_signature_selected_method_nfc">Signing option NFC, tab %1$d of %2$d</string>

<string name="signature_update_signature_chosen_method_mobile_id">Signing method Mobile-ID, selected</string>
<string name="signature_update_signature_chosen_method_smart_id">Signing method Smart-ID, selected</string>
Expand Down Expand Up @@ -300,14 +300,14 @@
<string name="nfc_sign_can_invalid_length">CAN-code must be %1$s digits long</string>
<string name="id_card_sign_pin_invalid_length">%1$s code must be at least %2$s and a maximum of %3$s digits long</string>

<string name="signature_update_nfc_message">Enter your CAN and PIN 2 code to sign with ID-Card using NFC</string>
<string name="signature_update_nfc_can">CAN code on card</string>
<string name="signature_update_nfc_pin2">PIN 2 code</string>
<string name="signature_update_nfc_adapter_missing">This device does not support NFC.</string>
<string name="signature_update_nfc_message">Enter your ID-card access number (CAN) and PIN2 code to sign with ID-card</string>
<string name="signature_update_nfc_can">ID-card access number (CAN)</string>
<string name="signature_update_nfc_pin2">PIN2 code</string>
<string name="signature_update_nfc_adapter_missing">This device does not support contactless connection or NFC is turned off </string>
<string name="signature_update_nfc_tag_lost">NFC connection lost</string>
<string name="signature_update_nfc_technical_error">Technical error</string>
<string name="signature_update_nfc_hold">Please hold your ID Card against the phone until the signing process is completed</string>
<string name="signature_update_nfc_detected">Card detected. Please keep holding it until the signing process is completed</string>
<string name="signature_update_nfc_hold">Hold your phone near the ID-card</string>
<string name="signature_update_nfc_detected">Authenticating with ID-card</string>

<!-- Signature Details -->
<string name="signature_error_details_title">Warnings</string>
Expand Down
Loading