Class MIDClientImpl

java.lang.Object
ch.swisscom.mid.client.impl.MIDClientImpl
All Implemented Interfaces:
MIDClient, AutoCloseable

public class MIDClientImpl extends Object implements MIDClient
  • Constructor Details

  • Method Details

    • requestSyncSignature

      public SignatureResponse requestSyncSignature(SignatureRequest request)
      Description copied from interface: MIDClient
      Requests a MSS Signature to the connected Mobile ID service, using synchronous communication (the client's thread is blocked until the final response is received; this could take a while, e.g. 80 seconds, so make sure that the HTTP response timeout is properly set in the client configuration otherwise a timeout will occur). The response is returned to the caller or, if something breaks during the communication, a MIDClientException is thrown.
      Specified by:
      requestSyncSignature in interface MIDClient
      Parameters:
      request - the MSS Signature request to send
      Returns:
      the response, as received from the Mobile ID service.
    • requestAsyncSignature

      public SignatureResponse requestAsyncSignature(SignatureRequest request)
      Description copied from interface: MIDClient
      Requests a MSS Signature to the connected Mobile ID service, using asynchronous communication (the method terminates immediately, returning a signature object that is mostly empty, with a inner signature tracking object; the caller is expected to poll for the status of this MSS Signature flow by repeatedly calling MIDClient.pollForSignatureStatus(SignatureTracking) with the aforementioned signature tracking object). The method returns either with a response object and a tracking object to use in subsequent polls or by throwing an exception is something is misaligned.
      Specified by:
      requestAsyncSignature in interface MIDClient
      Parameters:
      request - the MSS Signature request to send
      Returns:
      a signature response object, containing the tracking element to use in subsequent polls.
    • pollForSignatureStatus

      public SignatureResponse pollForSignatureStatus(SignatureTracking signatureTracking)
      Description copied from interface: MIDClient
      Poll for the status of a previously requested asynchronous MSS Signature. The caller is expected to check the Status object from the returned response in order to learn about the current status of the signature flow. If the signature is not finished, the caller needs to poll again, with the same input tracking object.
      Specified by:
      pollForSignatureStatus in interface MIDClient
      Parameters:
      signatureTracking - the signature tracking object received from the call to MIDClient.requestAsyncSignature(SignatureRequest)
      Returns:
      a response object that contains only the Status populated with an intermediary status value or the final signature response
    • requestSyncReceipt

      public ReceiptResponse requestSyncReceipt(SignatureTracking signatureTracking, ReceiptRequest request)
      Description copied from interface: MIDClient
      A receipt can be sent to the mobile user that has just finished a digital signature. The call is synchronous and optional. Making such a call allows the AP to send a confirmation message to the mobile user (e.g. "Access granted").
      Specified by:
      requestSyncReceipt in interface MIDClient
      Parameters:
      signatureTracking - the signature tracking object received from the call to MIDClient.requestAsyncSignature(SignatureRequest) or MIDClient.requestSyncSignature(SignatureRequest)
      request - the request data additional to what the signatureTracking already provides
      Returns:
      a response object containing the status of the operation.
    • requestProfile

      public ProfileResponse requestProfile(ProfileRequest request)
      Description copied from interface: MIDClient
      The profile of a mobile user can be queried using this method. No interaction with the mobile user is performed. The backend just returns whatever data is available for the designated mobile user. This operation is synchronous.
      Specified by:
      requestProfile in interface MIDClient
      Parameters:
      request - the profile request data
      Returns:
      a response object containing the status outcome of the operation and the requested profile data.
    • close

      public void close()
      Description copied from interface: MIDClient
      Disposes any internal resources allocated by this instance of the MID Client. This method should be used ONLY when the MID Client cannot be used anymore (e.g. it is really not needed and needs to go away). The implementation of MID Client should be thread-safe and resource pooled, so that it can be reused in as many threads and for as long as possible. Call this method only when your app is shutting down or you really don't need the client anymore.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface MIDClient