2

我正在尝试访问针对 samsung knox SDK 运行的 TIMAKeystore CCM

执行以下操作:

  startAdminIfNeeded(activity)
//assumes admin is already on
  activateKPELicense(activity)
 //assumes license has been activated
  enableCCM(activity)


private fun startAdminIfNeeded(context: Context) {
    val deviceAdmin = ComponentName(context, SampleAdminReceiver::class.java)

    val dpm = context.getSystemService(DEVICE_POLICY_SERVICE) as DevicePolicyManager

    val adminActive = dpm.isAdminActive(deviceAdmin)

    if (!adminActive) {
        val intent = Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN)
        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdmin)
        if (context is Activity) {
            context.startActivityForResult(intent, 100)
        }
    }
}



    private fun activateKPELicense(context: Context) {
    // Instantiate the KnoxEnterpriseLicenseManager class to use the activateLicense method
    val kpeManager = KnoxEnterpriseLicenseManager.getInstance(context.applicationContext)

    try {
        kpeManager.activateLicense(KPE_LICENSE_KEY)

    } catch (e: Exception) {
        Log.e(TAG, "exception", e)
    }
}


private var mCCMProfileObj: CCMProfile? = null
private var mCertificateProfile: CertificateProfile? = null

@Throws(SecurityException::class)
private fun enableCCM(context: Context): Boolean {
    mCCMProfileObj = CCMProfile() // Initialize a CCMProfile object
    mCCMProfileObj?.accessControlMethod = CCMProfile.AccessControlMethod.LOCK_STATE // Set its accessControlMethod to the default method
    mCertificateProfile = CertificateProfile()
    mCCMProfileObj?.packageList = listOf(context.packageName) // Set the CCM Profile's packageList to that of whitelisted packages by user
    mCCMProfileObj?.whiteListAllPackages = false
    val ekm = EnterpriseKnoxManager.getInstance(context.applicationContext) // Instantiate the EnterpriseKnoxManager class
    val clientCertificateManager = ekm.clientCertificateManagerPolicy // Get the ClientCertificateManager where the setCCMProfile method lives
    return clientCertificateManager.setCCMProfile(mCCMProfileObj) // Apply the CCM Profile
}

我使用的许可证是以下两个之一:

1. KPE development license - which gives this error
2. KPE Enterprise free trial license - which fails to validate

我错过了什么?

4

0 回答 0