Class Info |
|---|
public class Credential Credential which can be saved to or accessed from Keyring. |
Constructor Name |
|---|
public Credential(String username, CredentialType type, Boolean userAuth, byte[] newContent) Constructs a Credential object. |
Qualifier and Type | Method Name and Description |
|---|---|
public Boolean | Checks whether a credential is available. The credential whose userAuth is true will become unavailable permanently after the user cancels their lock screen password. |
public String | Obtains the URL of a user's avatar. |
public void | getContent(CredentialCallback<byte[]> callback) Obtains the secret content of a credential. If userAuth is set to true for a credential, the user needs to complete verification through their biometric feature or lock screen password before the credential content can be obtained. |
public String | Obtains the display name of the credential owner. |
public AppIdentity | getOwner() Obtains the credential owner, that is, the app which saves the credential. |
public List<AppIdentity> | Obtains the sharing relationship of a credential. Only the credential owner can obtain the sharing relationship. |
public Boolean | Checks whether a credential can be synchronized between devices. This method is reserved. In this version, the credential cannot be synchronized between devices. |
public String | getTag() Obtains the tag of a credential. |
public long | Obtains the time when a credential is created, which is a UNIX time. The unit is milliseconds. |
public long | Obtains the time when a credential is updated the last time, which is a UNIX time. The unit is milliseconds. |
public long | Obtains the time when a credential is used the last time, which is a UNIX time. The unit is milliseconds. |
public CredentialType | getType() Obtains the credential type. |
public Boolean | Checks whether the user identity needs to be verified when the getContent method is called. |
public String | Obtains the user name of a credential. |
public void | setAvatarUrl(String avatarUrl) Sets the URL of a user's avatar. |
public void | setDisplayName(String displayName) Sets a display name. |
public void | setNewContent(byte[] newContent) Sets the new sensitive information of a credential, such as the password, session token, and federated authentication URL. The sensitive information will be encrypted for storage. |
public void | setSharedWith(List<AppIdentity> sharedWith) Sets the sharing relationship of a credential to specify apps that can use the credential. |
public void | setSyncable(Boolean syncable) Sets whether a credential can be synchronized between devices. This method is reserved. In this version, the credential cannot be synchronized between devices. |
public void | setTag(String tag) Sets the tag of a credential. |
public String | toString() Obtains the string of a Credential object from which sensitive information has been deleted. The string does not include attributes such as username, content, and newContent. |
Constructor |
|---|
public Credential(String username, CredentialType type, Boolean userAuth, byte[] newContent) Constructs a Credential object. |
Parameters
Name | Description |
|---|---|
username | User name, which can contain a maximum of 128 characters. CAUTION: The user name will be displayed to the user on the credential management screen. Therefore, it must be understandable. For details about the credential management screen, please refer to Credential Management Screen. |
type | Credential type. |
userAuth | Indicates whether the user's biometric feature or lock screen password needs to be verified for using a credential. |
newContent | Credential content, such as the password, session token, and federated authentication URL. The content will be encrypted for storage. The value can contain a maximum of 16,384 characters. |
Method |
|---|
public Boolean getAvailable() Checks whether a credential is available. The credential whose userAuth is true will become unavailable permanently after the user cancels their lock screen password. |
Returns
Type | Description |
|---|---|
Boolean | true if the credential is available; false otherwise. |
Method |
|---|
public String getAvatarUrl() Obtains the URL of a user's avatar. |
Returns
Type | Description |
|---|---|
String | URL of a user's avatar. |
Method |
|---|
public void getContent(CredentialCallback<byte[]> callback) Obtains the secret content of a credential. If userAuth is set to true for a credential, the user needs to complete verification through their biometric feature or lock screen password before the credential content can be obtained. |
Parameters
Name | Description |
|---|---|
callback | Callback object. |
Method |
|---|
public String getDisplayName() Obtains the display name of the credential owner. |
Returns
Type | Description |
|---|---|
String | Display name of the credential owner. |
Method |
|---|
public AppIdentity getOwner() Obtains the credential owner, that is, the app which saves the credential. |
Returns
Type | Description |
|---|---|
Credential owner, that is, the app which saves the credential. |
Method |
|---|
public List<AppIdentity> getSharedWith() Obtains the sharing relationship of a credential. Only the credential owner can obtain the sharing relationship. |
Returns
Type | Description |
|---|---|
List<AppIdentity> | Sharing relationship of a credential. Only the credential owner can obtain the sharing relationship. |
Method |
|---|
public Boolean getSyncable() Checks whether a credential can be synchronized between devices. This method is reserved. In this version, the credential cannot be synchronized between devices. |
Returns
Type | Description |
|---|---|
Boolean | true if the credential can be synchronized between devices; false otherwise. |
Method |
|---|
public String getTag() Obtains the tag of a credential. |
Returns
Type | Description |
|---|---|
String | Tag of a credential. |
Method |
|---|
public long getTimeCreated() Obtains the time when a credential is created, which is a UNIX time. The unit is milliseconds. |
Returns
Type | Description |
|---|---|
long | Time when a credential is created, which is a UNIX time. The unit is milliseconds. |
Method |
|---|
public long getTimeUpdated() Obtains the time when a credential is updated the last time, which is a UNIX time. The unit is milliseconds. |
Returns
Type | Description |
|---|---|
long | Time when a credential is updated the last time, which is a UNIX time. The unit is milliseconds. |
Method |
|---|
public long getTimeUsed() Obtains the time when a credential is used the last time, which is a UNIX time. The unit is milliseconds. |
Returns
Type | Description |
|---|---|
long | Time when a credential is used the last time, which is a UNIX time. The unit is milliseconds. |
Method |
|---|
public CredentialType getType() Obtains the credential type. |
Returns
Type | Description |
|---|---|
Credential type. |
Method |
|---|
public Boolean getUserAuth() Checks whether the user identity needs to be verified when the getContent method is called. |
Returns
Type | Description |
|---|---|
Boolean | true if the user identity needs to be verified; false otherwise. |
Method |
|---|
public String getUsername() Obtains the user name of a credential. |
Returns
Type | Description |
|---|---|
String | User name of a credential. |
Method |
|---|
public void setAvatarUrl(String avatarUrl) Sets the URL of a user's avatar, which can contain a maximum of 16,384 characters. |
Parameters
Name | Description |
|---|---|
avatarUrl | URL of a user's avatar, which can contain a maximum of 16,384 characters. If you want to directly save the avatar content, you are advised to use the data URI scheme. |
Method |
|---|
public void setDisplayName(String displayName) Sets the display name, which can contain a maximum of 128 characters. |
Parameters
Name | Description |
|---|---|
displayName | Display name, which can contain a maximum of 128 characters. |
Method |
|---|
public void setNewContent(byte[] newContent) Sets the new sensitive information of a credential, such as the password, token, and federated authentication URL. The sensitive information will be encrypted for storage. The value can contain a maximum of 16,384 characters. |
Parameters
Name | Description |
|---|---|
newContent | New sensitive information of the credential, for example, the password, token, and federated authentication URL. The value can contain a maximum of 16,384 characters. |
Method |
|---|
public void setSharedWith(List<AppIdentity> sharedWith) Sets the sharing relationship of a credential to specify apps that can use the credential. A credential can be shared with a maximum of 128 apps. |
Parameters
Name | Description |
|---|---|
sharedWith | Sharing relationship of a credential, which specifies apps that can use the credential. A credential can be shared with a maximum of 128 apps. |
Method |
|---|
public void setSyncable(Boolean syncable) Sets whether a credential can be synchronized between devices. During synchronization, sensitive information in the credential is encrypted using password technologies. Huawei will not obtain the credential content. This method is reserved. In this version, the credential cannot be synchronized between devices. |
Parameters
Name | Description |
|---|---|
syncable | Indicates whether a credential can be synchronized between devices. |
Method |
|---|
public void setTag(String tag) Sets the tag of a credential. You can save some customized information in the tag, which can contain a maximum of 1024 characters. |
Parameters
Name | Description |
|---|---|
tag | Tag of a credential, which can contain a maximum of 1024 characters. |
Method |
|---|
public String toString() Obtains the string of a Credential object from which sensitive information has been deleted. The string does not include attributes such as username, content, and newContent. |
Returns
Type | Description |
|---|---|
String | String of a Credential object from which sensitive information has been deleted. The string does not include attributes such as username, content, and newContent. |