Clean up security token transport if connection procedure failed
This commit is contained in:
parent
fbbc77335b
commit
a3021bbd83
|
@ -103,28 +103,33 @@ public class SecurityTokenConnection {
|
|||
*/
|
||||
@VisibleForTesting
|
||||
void connectToDevice(Context context) throws IOException {
|
||||
// Connect on transport layer
|
||||
transport.connect();
|
||||
try {
|
||||
// Connect on transport layer
|
||||
transport.connect();
|
||||
|
||||
// dummy instance for initial communicate() calls
|
||||
cardCapabilities = new CardCapabilities();
|
||||
// dummy instance for initial communicate() calls
|
||||
cardCapabilities = new CardCapabilities();
|
||||
|
||||
determineTokenType();
|
||||
determineTokenType();
|
||||
|
||||
CommandApdu select = commandFactory.createSelectFileOpenPgpCommand();
|
||||
ResponseApdu response = communicate(select); // activate connection
|
||||
CommandApdu select = commandFactory.createSelectFileOpenPgpCommand();
|
||||
ResponseApdu response = communicate(select); // activate connection
|
||||
|
||||
if (!response.isSuccess()) {
|
||||
throw new CardException("Initialization failed!", response.getSw());
|
||||
if (!response.isSuccess()) {
|
||||
throw new CardException("Initialization failed!", response.getSw());
|
||||
}
|
||||
|
||||
refreshConnectionCapabilities();
|
||||
|
||||
isPw1ValidatedForSignature = false;
|
||||
isPw1ValidatedForOther = false;
|
||||
isPw3Validated = false;
|
||||
|
||||
smEstablishIfAvailable(context);
|
||||
} catch (IOException e) {
|
||||
transport.release();
|
||||
throw e;
|
||||
}
|
||||
|
||||
refreshConnectionCapabilities();
|
||||
|
||||
isPw1ValidatedForSignature = false;
|
||||
isPw1ValidatedForOther = false;
|
||||
isPw3Validated = false;
|
||||
|
||||
smEstablishIfAvailable(context);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
|
Loading…
Reference in a new issue