合作咨询
我们的专家服务团队将竭诚为您提供专业的合作咨询服务
Class Info |
|---|
public class Credential 一个可以保存到钥匙环服务的凭据,或者从钥匙环服务读取到的凭据。 |
Constructor Name |
|---|
public Credential(String username, CredentialType type, Boolean userAuth, byte[] newContent) 构造Credential对象。 |
Qualifier and Type | Method Name and Description |
|---|---|
public Boolean | 获取凭据是否处于可用状态。对于userAuth设为True的凭据,当用户取消了锁屏密码后,永久变为不可用状态。 |
public String | 获取用户头像URL。 |
public void | getContent(CredentialCallback<byte[]> callback) 获取凭据的保密内容。如果userAuth设置为true,则需要验证用户的生物特征或者锁屏码后才能获得凭据的内容。 |
public String | 获取凭据所属用户的显示名称。 |
public AppIdentity | getOwner() 获取凭据的所有者,即最初保存本凭据的应用。 |
public List<AppIdentity> | 获取凭据的共享关系,只有凭据的所有者可以获取。 |
public Boolean | 获取是否支持在设备间进行同步。预留能力,当前版本不支持同步。 |
public String | getTag() 获取凭据的标签。 |
public long | 获取凭据创建时间,返回UNIX时间戳。(单位:毫秒) |
public long | 获取凭据最后更新时间,返回UNIX时间戳。(单位:毫秒) |
public long | 获取凭据最后使用时间,返回UNIX时间戳。(单位:毫秒) |
public CredentialType | getType() 获取凭据类型。 |
public Boolean | 调用getContent时,是否需要对用户的身份进行认证。 |
public String | 获取凭据的用户名。 |
public void | setAvatarUrl(String avatarUrl) 设置用户头像URL。 |
public void | setDisplayName(String displayName) 设置显示名称。 |
public void | setNewContent(byte[] newContent) 设置凭据敏感信息的新内容,如密码、会话令牌、联邦认证URL的值,数据将被加密保存。 |
public void | setSharedWith(List<AppIdentity> sharedWith) 设置凭据的共享关系,授权给哪些应用使用。 |
public void | setSyncable(Boolean syncable) 设置是否支持在设备间进行同步。预留能力,当前版本不支持同步。 |
public void | setTag(String tag) 设置凭据的标签。 |
public String | toString() 获得去掉敏感信息的Credential对象的字符串表示。不包含username、content、newContent等属性。 |
Constructor |
|---|
public Credential(String username, CredentialType type, Boolean userAuth, byte[] newContent) 构造Credential对象。 |
Parameters
Name | Description |
|---|---|
username | 用户名,最大长度128个字符。 注意 username会在凭据管理界面向用户展示,因此需要让用户可理解。凭据管理界面请参考凭据管理界面。 |
type | 凭据类型。 |
userAuth | 使用凭据时,是否需要验证用户的生物特征或锁屏口令。 |
newContent | 凭据内容,如密码、会话令牌、联邦认证URL的值,数据将被加密保存。最大长度为16384。 |
Method |
|---|
public Boolean getAvailable() 获取凭据是否处于可用状态。对于userAuth设为True的凭据,当用户取消了锁屏密码后,永久变为不可用状态。 |
Returns
Type | Description |
|---|---|
Boolean | 凭据可用状态。返回值为True时表示当前可用,False时表示当前不可用。 |
Method |
|---|
public String getAvatarUrl() 获取用户头像URL。 |
Returns
Type | Description |
|---|---|
String | 用户头像URL。 |
Method |
|---|
public void getContent(CredentialCallback<byte[]> callback) 获取凭据的保密内容。如果userAuth设置为true,则需要验证用户的生物特征或者锁屏码后才能获得凭据的内容。 |
Parameters
Name | Description |
|---|---|
callback | 回调对象。 |
Method |
|---|
public String getDisplayName() 获取凭据所属用户的显示名称。 |
Returns
Type | Description |
|---|---|
String | 凭据所属用户的显示名称。 |
Method |
|---|
public AppIdentity getOwner() 获取凭据的所有者,即最初保存本凭据的应用。 |
Returns
Type | Description |
|---|---|
凭据的所有者,即最初保存本凭据的应用。 |
Method |
|---|
public List<AppIdentity> getSharedWith() 获取凭据的共享关系,只有凭据的所有者可以获取,授权使用凭据的应用无法获取到共享关系。 |
Returns
Type | Description |
|---|---|
List<AppIdentity> | 凭据的共享关系,只有凭据的所有者可以获取。 |
Method |
|---|
public Boolean getSyncable() 获取是否支持在设备间进行同步。预留能力,当前版本不支持同步。 |
Returns
Type | Description |
|---|---|
Boolean | 是否支持在设备间进行同步。 |
Method |
|---|
public String getTag() 获取凭据的标签。 |
Returns
Type | Description |
|---|---|
String | 凭据的标签。 |
Method |
|---|
public long getTimeCreated() 获取凭据创建时间,返回UNIX时间戳(单位:毫秒)。 |
Returns
Type | Description |
|---|---|
long | 凭据创建时间,返回UNIX时间戳(单位:毫秒)。 |
Method |
|---|
public long getTimeUpdated() 获取凭据最后更新时间,返回UNIX时间戳(单位:毫秒)。 |
Returns
Type | Description |
|---|---|
long | 凭据最后更新时间,返回UNIX时间戳(单位:毫秒)。 |
Method |
|---|
public long getTimeUsed() 获取凭据最后使用时间,返回UNIX时间戳(单位:毫秒)。 |
Returns
Type | Description |
|---|---|
long | 凭据最后使用时间,返回UNIX时间戳(单位:毫秒)。 |
Method |
|---|
public Boolean getUserAuth() 调用getContent时,是否需要对用户的身份进行认证。 |
Returns
Type | Description |
|---|---|
Boolean | 返回值为True时,表示调用getContent方法时,需要对用户的身份进行认证;返回值为False时,则不需要。 |
Method |
|---|
public String getUsername() 获取凭据的用户名。 |
Returns
Type | Description |
|---|---|
String | 凭据的用户名。 |
Method |
|---|
public void setAvatarUrl(String avatarUrl) 户头像URL,最大长度为16384。 |
Parameters
Name | Description |
|---|---|
avatarUrl | 户头像URL,最大长度为16384。如果您希望直接保存图像的内容,建议使用data URI scheme。 |
Method |
|---|
public void setDisplayName(String displayName) 设置显示名称,最大长度为128。 |
Parameters
Name | Description |
|---|---|
displayName | 显示名称,最大长度为128。 |
Method |
|---|
public void setNewContent(byte[] newContent) 设置凭据敏感信息的新内容,如口令、Token、联邦认证URL的值,数据将被加密保存。最大长度为16384。 |
Parameters
Name | Description |
|---|---|
newContent | 凭据敏感信息的新内容,如口令、Token、联邦认证URL的值。最大长度为16384。 |
Method |
|---|
public void setSharedWith(List<AppIdentity> sharedWith) 设置凭据的共享关系,授权给哪些应用使用。最多支持共享给128个应用。 |
Parameters
Name | Description |
|---|---|
sharedWith | 凭据的共享关系,授权给哪些应用使用。最多支持共享给128个应用。 |
Method |
|---|
public void setSyncable(Boolean syncable) 设置是否支持在设备间进行同步。数据同步过程中,使用密码技术对凭据的敏感信息进行加密,华为不掌握凭据的内容。预留能力,当前版本不支持同步。 |
Parameters
Name | Description |
|---|---|
syncable | 是否支持在设备间进行同步。 |
Method |
|---|
public void setTag(String tag) 设置凭据的标签,您可以在标签中保存一些自定义的信息,最大长度为1024。 |
Parameters
Name | Description |
|---|---|
tag | 凭据的标签,最大长度为1024。 |
Method |
|---|
public String toString() 获得去掉敏感信息的Credential对象的字符串表示。不包含username、content、newContent等属性。 |
Returns
Type | Description |
|---|---|
String | 去掉敏感信息的Credential对象的字符串表示。不包含username、content、newContent等属性。 |