aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/smartcard/Transport.java
blob: fa8b0695a842e8245a10dd51206e3e15401ec716 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.sufficientlysecure.keychain.smartcard;

import java.io.IOException;

/**
 * Abstraction for transmitting APDU commands
 */
public interface Transport {
    /**
     * Transmit and receive data
     * @param data data to transmit
     * @return received data
     * @throws IOException
     */
    byte[] transceive(byte[] data) throws IOException;

    /**
     * Disconnect and release connection
     */
    void release();

    /**
     * Check if device is was connected to and still is connected
     * @return connection status
     */
    boolean isConnected();

    /**
     * Check if Transport supports persistent connections e.g connections which can
     * handle multiple operations in one session
     * @return true if transport supports persistent connections
     */
    boolean isPersistentConnectionAllowed();


    /**
     * Connect to device
     * @throws IOException
     */
    void connect() throws IOException;
}