Check for security token support
This commit is contained in:
committed by
Vincent Breitmoser
parent
e7705eaca8
commit
0920d97572
@@ -45,10 +45,11 @@ import org.sufficientlysecure.keychain.securitytoken.CardException;
|
||||
import org.sufficientlysecure.keychain.securitytoken.NfcTransport;
|
||||
import org.sufficientlysecure.keychain.securitytoken.SecurityTokenConnection;
|
||||
import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo;
|
||||
import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo.TokenType;
|
||||
import org.sufficientlysecure.keychain.securitytoken.Transport;
|
||||
import org.sufficientlysecure.keychain.securitytoken.UnsupportedSecurityTokenException;
|
||||
import org.sufficientlysecure.keychain.securitytoken.UsbConnectionDispatcher;
|
||||
import org.sufficientlysecure.keychain.securitytoken.usb.UsbTransport;
|
||||
import org.sufficientlysecure.keychain.securitytoken.usb.UsbTransportException;
|
||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
@@ -238,11 +239,21 @@ public abstract class BaseSecurityTokenActivity extends BaseActivity
|
||||
return;
|
||||
}
|
||||
|
||||
if (e instanceof IsoDepNotSupportedException) {
|
||||
if (e instanceof NfcTransport.IsoDepNotSupportedException) {
|
||||
onSecurityTokenError(getString(R.string.security_token_error_iso_dep_not_supported));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e instanceof UsbTransportException) {
|
||||
onSecurityTokenError(getString(R.string.security_token_error, e.getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e instanceof UnsupportedSecurityTokenException) {
|
||||
onSecurityTokenError(getString(R.string.security_token_not_supported));
|
||||
return;
|
||||
}
|
||||
|
||||
short status;
|
||||
if (e instanceof CardException) {
|
||||
status = ((CardException) e).getResponseCode();
|
||||
@@ -442,14 +453,6 @@ public abstract class BaseSecurityTokenActivity extends BaseActivity
|
||||
doSecurityTokenInBackground(stConnection);
|
||||
}
|
||||
|
||||
public static class IsoDepNotSupportedException extends IOException {
|
||||
|
||||
public IsoDepNotSupportedException(String detailMessage) {
|
||||
super(detailMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask user if she wants to install PGP onto her Fidesmo token
|
||||
*/
|
||||
|
||||
@@ -79,6 +79,7 @@ class ManageSecurityTokenContract {
|
||||
void showActionRetryOrFromFile();
|
||||
void showActionLocked(int unlockAttempts);
|
||||
void showActionEmptyToken();
|
||||
void showActionUnsupportedToken();
|
||||
void hideAction();
|
||||
|
||||
void operationImportKey(byte[] importKeyData);
|
||||
|
||||
@@ -263,6 +263,11 @@ public class ManageSecurityTokenFragment extends Fragment implements ManageSecur
|
||||
actionAnimator.setDisplayedChildId(R.id.token_layout_empty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showActionUnsupportedToken() {
|
||||
actionAnimator.setDisplayedChildId(R.id.token_layout_unsupported);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideAction() {
|
||||
actionAnimator.setDisplayedChild(0);
|
||||
|
||||
@@ -164,6 +164,14 @@ class ManageSecurityTokenPresenter implements ManageSecurityTokenMvpPresenter {
|
||||
|
||||
private void performKeyCheck() {
|
||||
boolean keyIsEmpty = tokenInfo.isEmpty();
|
||||
boolean putKeyIsSupported = tokenInfo.isPutKeySupported();
|
||||
|
||||
if (keyIsEmpty && !putKeyIsSupported) {
|
||||
view.statusLineOk();
|
||||
view.showActionUnsupportedToken();
|
||||
return;
|
||||
}
|
||||
|
||||
if (keyIsEmpty) {
|
||||
boolean tokenIsAdminLocked = tokenInfo.getVerifyAdminRetries() == 0;
|
||||
if (tokenIsAdminLocked) {
|
||||
|
||||
Reference in New Issue
Block a user