Provisioning an Initial Password
The initial password is used to authenticate the user during device self issuance. Before the initial password can be provisioned, the following requirements must be met:
-
The device must be bound to the user.
-
An issuance request with the specified device policy must exist.
-
The initial password must comply with the PIN policy specified in the device policy provision.
To provision the initial password, complete the following steps:
-
Establish the wallet and credential manager clients.
CopyCredentialManager cm = …; WalletId walletId = …;
-
Set up search criteria based on password credential type and wallet ID, and observe the following considerations:
-
The application ID is not necessary since setting the password is not associated with the device profile.
-
CRED_ID_TYPE_PASSWORD is the credential type for initial passwords.
CopyCriteria[] criteria = {new Criteria(CCMConstants.
CRITERIA_CRED_TYPE, CCMConstants. CRITERIA_COMPARISON_EQUAL, CCMConstants. CRED_ID_TYPE_PASSWORD),
new Criteria(CCMConstants. CRITERIA_CRED_PARENT_WALLET, CCMConstants.
CRITERIA_COMPARISON_EQUAL, walletId.getId())
};
-
-
Find the credential IDs that meet the supplied search criteria:
CopyCredentialId[] credIds = cm.findCredentialIds(criteria, maxItem);
-
At this point, there are two possibilities:
-
Either an initial password has already been provisioned, or
-
An initial password has not been provisioned.
If an initial password has already been provisioned, then the update can occur based on the following conditions and tasks being met:
-
Once a credential that matches the supplied criteria has been found, get the credentials based on credential IDs:
Copyif (credIds.length == 1)
Credential[] creds = cm.getCredentials(credIds);
-
Get the Input Requirements for an update based on the profile ID:
CopyEntryTemplate[] entries = cm.getProfileDynamicEntries(creds[0]. getProfileId());
-
getProfileDynamicEntries should return only one entry. You can set its initial password value using setValue:
CopyString initialPassword=... // Initial Password
entries[0].setValue(initialPassword);
-
Once all inputs are collected from the user interface, perform an update:
Copycm.updateCredential(credIds[0], CCMConstants.
ACTION_ID_CRED_REPLACE, entries);
If an initial password has not yet been provisioned, then you can import the initial password and perform the following:
-
Set up new search criteria:
CopyCriteria[] profCriteria = {new Criteria(CCMConstants.
CRITERIA_CRED_TYPE, CCMConstants.CRITERIA_COMPARISON_EQUAL, CCMConstants.CRED_ID_TYPE_PASSWORD),
new Criteria(CCMConstants. CRITERIA_CRED_PARENT_WALLET, CCMConstants.CRITERIA_COMPARISON_EQUAL,
walletId.getId())
};
-
Retrieve the IDs of all credential profiles that match the supplied criteria:
CopyConfigurationId[] credProfIds = credMgr. findCredentialProfileIds(profCriteria, maxItems);
-
Throw an exception if there is no credential profile returned:
Copyif (credProfIds.length != 1) {
throw new Exception("more than expected single credential profile returned");
}
-
Get the list of runtime input requirements for the specified credential:
CopyEntryTemplate[] entries = credMgr. getProfileDynamicEntries(credProfIds[0]);
-
Create an array of credentials:
CopyCredential[] creds = { new Credential() }; creds[0].setProfileId(credProfIds[0]); CredentialElement credEl = new CredentialElement(); credEl.setId(entries[0].getKey()); credEl.setIsReference(false);
String initialPassword = ..........;
credEl.setValue(initialPassword);
creds[0].setCredentialElements(new CredentialElement[] {
credEl });
-
Import the set of externally formed credentials:
CopycredMgr.importCredentials(walletId, creds);
-