public class

MPOSPolicy

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.mpos.MPOSPolicy

Class Overview

This class provides functionality settings.

Summary

Public Methods
byte[] getCertificateChain()
API to get device certificate.
static MPOSPolicy getInstance(Context context)
API to get the MPOSPolicy instance.
boolean isSupported()
API to check whether the Knox POS SDK is supported or not.
void showConfirmView(Activity activity, String xmlName, MPOSPayInfo info, byte[] encryptKey, MPOSPolicyCallback cb)
API to show TUI View based on layout.
void showConfirmView(Activity activity, String xmlName, MPOSPayInfo info, byte[] encryptKey, Map<IntegerString> dynamicValues, MPOSPolicyCallback cb)
API to show TUI View based on layout with dynamic String.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public byte[] getCertificateChain ()

API to get device certificate.
It can be used to encrypt important data like AES encrypt key.
This API should be called every time when encrypt key is needed.

     
     MPOSPolicy mpospolicy = getInstance(Context);
     byte[] certChain = mMPOSPolicy.getCertificateChain();

     int index = 0;
     //root_certificate_buffer_length
     byte[] root_certificate_buffer_length_bytes = Arrays.copyOfRange(certChain, index, index + CERT_LENGTH_BYTE);
     index = index + CERT_LENGTH_BYTE;

     int root_certificate_buffer_length = convertByteArrayToInt(root_certificate_buffer_length_bytes);
     ByteBuffer data1 = ByteBuffer.allocate(CERT_LENGTH_BYTE);
     data1.order(ByteOrder.LITTLE_ENDIAN);
     data1.putInt(root_certificate_buffer_length);
     root_certificate_buffer_length_bytes = data1.array();
     root_certificate_buffer_length  = convertByteArrayToInt(root_certificate_buffer_length_bytes);

     //root_certificate
     byte[] root_certificate = Arrays.copyOfRange(certChain, index, index + root_certificate_buffer_length);
     //Device root certificate used to derive client certificate
     X509Certificate rootCert = byteToX509Certificate(root_certificate);
     index = index + root_certificate_buffer_length;

     //leaf_certificate_buffer_length
     byte[] leaf_certificate_buffer_length_bytes = Arrays.copyOfRange(certChain, index, index + CERT_LENGTH_BYTE);
     index = index + CERT_LENGTH_BYTE;
     int leaf_cert_length = convertByteArrayToInt(leaf_certificate_buffer_length_bytes);
     ByteBuffer data2 = ByteBuffer.allocate(4);
     data2.order(ByteOrder.LITTLE_ENDIAN);
     data2.putInt(leaf_cert_length);
     leaf_certificate_buffer_length_bytes = data2.array();
     leaf_cert_length = convertByteArrayToInt(leaf_certificate_buffer_length_bytes);

     //leaf_certificate
     byte[] leaf_certificate = Arrays.copyOfRange(certChain, index, index + leaf_cert_length);
     //You should use leaf_cert (X509Certificate driven from Samsung device root key) to encrypt your symmetric key.
     X509Certificate leafCert = byteToX509Certificate(leaf_certifcate);
     
 

Returns
  • device certificate byte[] in tlv format.

public static MPOSPolicy getInstance (Context context)

API to get the MPOSPolicy instance.

Parameters
context
context of caller app.
Returns
  • MPOSPolicy instance.

public boolean isSupported ()

API to check whether the Knox POS SDK is supported or not.

Returns
  • true if supported, false if not supported.

public void showConfirmView (Activity activity, String xmlName, MPOSPayInfo info, byte[] encryptKey, MPOSPolicyCallback cb)

API to show TUI View based on layout.

Parameters
activity
activity of caller app.
xmlName
name of tui layout.
info
payment info instance.
encryptKey
encryptKey to encrypt entered pin. can be null when MPOSPayInfo algorithm is MPOS_SHA_384.
cb
callback instance to receive TUI result.

public void showConfirmView (Activity activity, String xmlName, MPOSPayInfo info, byte[] encryptKey, Map<IntegerString> dynamicValues, MPOSPolicyCallback cb)

API to show TUI View based on layout with dynamic String.

Parameters
activity
activity of caller app.
xmlName
name of tui layout.
info
payment info instance.
encryptKey
encryptKey to encrypt entered pin. can be null when MPOSPayInfo algorithm is MPOS_SHA_384.
dynamicValues
Map to allow run time string on TUI View.
cb
callback instance to receive TUI result.