Package com.scytales.mvalid.sdk.session
Class SessionManager
-
- All Implemented Interfaces:
public final class SessionManager
SessionManager implements the necessary functionality required to encrypt/decrypt data transferred between devices.
SessionManager requires DeviceEngagement and Handover to be instantiated. Usually this is done after device engagement phase and this instance must be available after receiving data from devices, in order to decrypt them.
public class SomeActivity extends androidx.appcompat.app.AppCompatActivity implements DeviceEngagementCallback, TransferReceiveCallback { private SessionManager sessionManager; private Map<String, Map<String, Map<String, Boolean>>> docRequests = ... @Override public void onEngage(@NonNull Received<EngagementReceived> engagementReceived) { engagementReceived.run( failure -> { android.util.Log.e(TAG, failure.toString()); }, success -> { DeviceEngagement deviceEngagement = success.getDeviceEngagement(); Handover handover = success.getHandover(); try { sessionManager = new SessionManager(deviceEngagement, handover); // create request Request request = Request.create(docRequests, sessionManager); // or get encrypted bytes byte[] encryptedBytes = sessionManager..createRequest(docRequests); // use deviceEngagement, handover and request or encryptedBytes to send // via a Transfer implementation } catch (SDKException e) { android.util.Log.e(TAG, e.getMessage(), e); } }); } @Override public void onReceive(@NonNull Received<TransferReceived> transferReceived) { transferReceived.run( failure -> { android.util.Log.e(TAG, failure.toString()); }, success -> { success.runForDevice(receivedBytes -> { try { SessionData sessionData = sessionManager.decryptResponse(receivedBytes); // do stuff with decrypted sessionData } catch (SDKException e) { // handle error when decrypting } }); }); } }
-
-
Field Summary
Fields Modifier and Type Field Description public final static Array<byte>
SESSION_TERMINATION_BYTES
public final DeviceEngagement
deviceEngagement
public final Handover
handover
public final SessionTranscript
sessionTranscript
public PrivateKey
readerAuthPrivateKey
public Certificate
readerAuthCertificate
-
Constructor Summary
Constructors Constructor Description SessionManager(DeviceEngagement deviceEngagement, Handover handover)
Instantiates a new Session manager.
-
Method Summary
Modifier and Type Method Description DeviceEngagement
getDeviceEngagement()
Gets device engagement. Handover
getHandover()
Gets handover. SessionTranscript
getSessionTranscript()
Gets session transcript. PrivateKey
getReaderAuthPrivateKey()
Gets reader auth private key. SessionManager
setReaderAuthPrivateKey(@NonNull() PrivateKey readerAuthPrivateKey)
Sets reader auth private key. Certificate
getReaderAuthCertificate()
Gets reader auth certificate. SessionManager
setReaderAuthCertificate(@NonNull() Certificate readerAuthCertificate)
Sets reader auth certificate. Array<byte>
createRequest(@NonNull() Map<String, Map<String, Map<String, Boolean>>> docRequests)
Create request byte [ ]. SessionData
decryptResponse(@NonNull() Array<byte> responseData)
Decrypt response session data. KeyPair
getEphemeralKeys()
Gets ephemeral keys. DeviceResponseVerifier
getVerifier(@NonNull() Collection<X509Certificate> rootCertificates)
Gets verifier. -
-
Constructor Detail
-
SessionManager
SessionManager(DeviceEngagement deviceEngagement, Handover handover)
Instantiates a new Session manager.- Parameters:
deviceEngagement
- the device engagementhandover
- the handover
-
-
Method Detail
-
getDeviceEngagement
@NonNull() DeviceEngagement getDeviceEngagement()
Gets device engagement.
-
getHandover
@NonNull() Handover getHandover()
Gets handover.
-
getSessionTranscript
@NonNull() SessionTranscript getSessionTranscript()
Gets session transcript.
-
getReaderAuthPrivateKey
@Nullable() PrivateKey getReaderAuthPrivateKey()
Gets reader auth private key.
-
setReaderAuthPrivateKey
SessionManager setReaderAuthPrivateKey(@NonNull() PrivateKey readerAuthPrivateKey)
Sets reader auth private key.
- Parameters:
readerAuthPrivateKey
- the reader auth private key
-
getReaderAuthCertificate
@Nullable() Certificate getReaderAuthCertificate()
Gets reader auth certificate.
-
setReaderAuthCertificate
SessionManager setReaderAuthCertificate(@NonNull() Certificate readerAuthCertificate)
Sets reader auth certificate.
- Parameters:
readerAuthCertificate
- the reader auth certificate
-
createRequest
@NonNull() Array<byte> createRequest(@NonNull() Map<String, Map<String, Map<String, Boolean>>> docRequests)
Create request byte [ ].
- Parameters:
docRequests
- the doc requests
-
decryptResponse
@NonNull() SessionData decryptResponse(@NonNull() Array<byte> responseData)
Decrypt response session data.
- Parameters:
responseData
- the response data
-
getEphemeralKeys
@NonNull() KeyPair getEphemeralKeys()
Gets ephemeral keys.
-
getVerifier
@NonNull() DeviceResponseVerifier getVerifier(@NonNull() Collection<X509Certificate> rootCertificates)
Gets verifier.
- Parameters:
rootCertificates
- the root certificates
-
-
-
-