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
|
@VisibleForTesting
|
||||||
void connectToDevice(Context context) throws IOException {
|
void connectToDevice(Context context) throws IOException {
|
||||||
// Connect on transport layer
|
try {
|
||||||
transport.connect();
|
// Connect on transport layer
|
||||||
|
transport.connect();
|
||||||
|
|
||||||
// dummy instance for initial communicate() calls
|
// dummy instance for initial communicate() calls
|
||||||
cardCapabilities = new CardCapabilities();
|
cardCapabilities = new CardCapabilities();
|
||||||
|
|
||||||
determineTokenType();
|
determineTokenType();
|
||||||
|
|
||||||
CommandApdu select = commandFactory.createSelectFileOpenPgpCommand();
|
CommandApdu select = commandFactory.createSelectFileOpenPgpCommand();
|
||||||
ResponseApdu response = communicate(select); // activate connection
|
ResponseApdu response = communicate(select); // activate connection
|
||||||
|
|
||||||
if (!response.isSuccess()) {
|
if (!response.isSuccess()) {
|
||||||
throw new CardException("Initialization failed!", response.getSw());
|
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
|
@VisibleForTesting
|
||||||
|
|
Loading…
Reference in a new issue