Getting the Initial PIN from a Device

To get the initial PIN, complete the following steps:

  1. Get the SecurityModule:

    Copy
    SecurityModule smo = smMgr.getSecurityModule(smId);
  2. Get the credentials for the SecurityModule:

    Copy
    Credential[] creds = smo.getCredentials();
  3. Find the PIN credential.

    Note: The CCM constant associated with the PIN credential element is CRED_ID_TYPE_PIN.
    Copy
    for (int i = 0; i < creds.length; i++){
    if (creds[i].getType().equals(CCMConstants. CRED_ID_TYPE_PIN){
    // Get the set of credential elements for each credential: 
    CredentialElement[] credEls = cred[i].getCredentialElements();
    // Iterate through credential elements looking for initial PIN 
    for (int j = 0; j < credEls.length; i++){
    if(credEls[j].getType().equals(CCMConstants. CRED_ELEMENT_ID_PIN){
       return credEls[j].getValue();
    }