未验证 提交 7f5c1996 编写于 作者: O openharmony_ci 提交者: Gitee

!22325 [翻译完成】#I7OJ7Z (20749、21039)

Merge pull request !22325 from Annie_wang/PR21458
......@@ -1470,7 +1470,7 @@ Obtains the authorization token of the specified authentication type for an app
| ID| Error Message|
| ------- | -------|
| 12300001 | System service exception. |
| 12300002 | Invalid name, owner or authType. |
| 12300002 | Invalid name, owner, or authType. |
| 12300003 | Account not found. |
| 12300107 | AuthType not found. |
......@@ -1559,7 +1559,7 @@ Sets an authorization token of the specific authentication type for an app accou
| 12300001 | System service exception. |
| 12300002 | Invalid name, authType, or token. |
| 12300003 | Account not found. |
| 12400004 | The number of token reaches the upper limit. |
| 12400004 | The number of tokens reaches the upper limit. |
**Example**
......@@ -1606,7 +1606,7 @@ Sets an authorization token of the specific authentication type for an app accou
| 12300001 | System service exception. |
| 12300002 | Invalid name, authType, or token. |
| 12300003 | Account not found. |
| 12400004 | The number of token reaches the upper limit. |
| 12400004 | The number of tokens reaches the upper limit. |
**Example**
......@@ -1637,7 +1637,7 @@ Deletes the authorization token of the specified authentication type for an app
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
| authType | string | Yes | Authentication type. |
| token | string | Yes | Token to delete.|
| token | string | Yes | Authorization token to delete.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
......@@ -4982,298 +4982,3 @@ Obtains the remote object of an authenticator. This API cannot be overloaded.
}
}
```
## AccountCapabilityType<sup>10+</sup>
Enumerates the account capability types.
**System capability**: SystemCapability.Account.AppAccount
| Name | Value | Description |
| ---------------- | ----- | ----------------------- |
| AUTHORIZATION | 1 | Authorization capability. |
## AccountCapabilityProvider<sup>10+</sup>
Represents the **AccountCapabilityProvider** class.
### Attributes
**System capability**: SystemCapability.Account.AppAccount
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| capabilityType | [AccountCapabilityType](#accountcapabilitytype10) | Yes| No| Capability type of the account.|
### constructor<sup>10+</sup>
constructor(capabilityType: AccountCapabilityType)
A constructor used to create an **AccountCapabilityProvider** instance.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| capabilityType | [AccountCapabilityType](#accountcapabilitytype10) | Yes | Capability type of the account. |
**Example**
```ts
class MyAuthorizationProvider extends account_appAccount.AccountCapabilityProvider {
constructor() {
super(account_appAccount.AccountCapabilityType.AUTHORIZATION);
}
}
try {
let provider = new MyAuthorizationProvider();
if (provider instanceof account_appAccount.AccountCapabilityProvider) {
console.log("the provider is an instance of AccountCapabilityProvider");
}
} catch (err) {
console.error('catch error: ' + JSON.stringify(err));
}
```
## AccountCapabilityRequest<sup>10+</sup>
Represents the **AccountCapabilityRequest** class.
### constructor<sup>10+</sup>
constructor(provider: AccountCapabilityProvider)
A constructor used to create an **AccountCapabilityRequest** instance.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| provider | [AccountCapabilityProvider](#accountcapabilityprovider10) | Yes | Provider of the account capability. |
**Example**
```ts
class MyAuthorizationProvider extends account_appAccount.AccountCapabilityProvider {
constructor() {
super(account_appAccount.AccountCapabilityType.AUTHORIZATION);
}
}
class MyAuthorizationRequest extends account_appAccount.AccountCapabilityRequest {
constructor() {
let provider = new MyAuthorizationProvider();
super(provider);
}
}
try {
let request = new MyAuthorizationRequest();
if (request instanceof account_appAccount.AccountCapabilityRequest) {
console.log("the request is an instance of AccountCapabilityRequest");
}
} catch (err) {
console.error('catch error: ' + JSON.stringify(err));
}
```
## AccountCapabilityResponse<sup>10+</sup>
Represents the **AccountCapabilityResponse** class.
### Attributes
**System capability**: SystemCapability.Account.AppAccount
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| request | [AccountCapabilityRequest](#accountcapabilityrequest10) | Yes| No| Account capability request corresponding to the response.|
### constructor<sup>10+</sup>
constructor(request: AccountCapabilityRequest)
A constructor used to create an **AccountCapabilityResponse** instance.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| request | [AccountCapabilityRequest](#accountcapabilityrequest10) | Yes | Account capability request corresponding to the response.|
**Example**
```ts
class MyAuthorizationProvider extends account_appAccount.AccountCapabilityProvider {
constructor() {
super(account_appAccount.AccountCapabilityType.AUTHORIZATION);
}
}
class MyAuthorizationRequest extends account_appAccount.AccountCapabilityRequest {
constructor() {
let provider = new MyAuthorizationProvider();
super(provider);
}
}
class MyAuthorizationResponse extends account_appAccount.AccountCapabilityResponse {
constructor(request) {
super(request)
}
}
try {
let request = new MyAuthorizationRequest();
let response = new MyAuthorizationResponse(request);
if (response instanceof account_appAccount.AccountCapabilityResponse) {
console.log("the response is an instance of AccountCapabilityResponse");
}
} catch (err) {
console.error('catch error: ' + JSON.stringify(err));
}
```
## AuthorizationProviderInfo<sup>10+</sup>
Defines information about the authorization provider.
**System capability**: SystemCapability.Account.AppAccount
| Name | Type | Readable| Writable| Description |
| ------- | ------ | ---- | --- | ---------- |
| bundleName | string | Yes| No| Bundle name of the authorization provider.|
| abilityName | string | Yes| No| Ability name of the authorization provider.|
## AuthorizationProvider<sup>10+</sup>
Represents the **AuthorizationProvider** class.
### constructor<sup>10+</sup>
constructor(info: AuthorizationProviderInfo)
A constructor used to create an **AuthorizationProvider** instance.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| info | [AuthorizationProviderInfo](#authorizationproviderinfo10) | Yes | Information about the authorization provider.|
**Example**
```ts
class MyAuthorizationProvider extends account_appAccount.AuthorizationProvider {
constructor() {
super({bundleName: 'xxx', abilityName: 'xxx'});
}
}
try {
let provider = new MyAuthorizationProvider();
if (provider instanceof account_appAccount.AuthorizationProvider) {
console.log("the provider is an instance of AuthorizationProvider");
}
} catch (err) {
console.error("catch error: " + JSON.stringify(err));
}
```
## AccountCapabilityScheduler<sup>10+</sup>
Represents the **AccountCapabilityScheduler** class.
### executeRequest<sup>10+</sup>
executeRequest(request: AccountCapabilityRequest, callback: AsyncCallback&lt;AccountCapabilityResponse, { [key: string]: object }&gt;): void
Executes an account capability request. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | ------------------------- | ---- | ------------------------- |
| request | [AccountCapabilityRequest](#accountcapabilityrequest10) | Yes | Account capability request to execute. |
| callback | AsyncCallback&lt;[AccountCapabilityResponse](#accountcapabilityresponse10), { [key: string]: object }&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
| ID| Error Message|
| ------- | ------- |
| 12300001 | System service exception. |
| 12300002 | Invalid request. |
**Example**
```ts
let scheduler = new account_appAccount.AccountCapabilityScheduler();
let provider = new account_appAccount.AuthorizationProvider({ bundleName: 'xxx', abilityName: 'xxx' });
let request = new account_appAccount.AccountCapabilityRequest(provider);
try {
scheduler.executeRequest(request, (err, response) => {
if (err != null) {
console.log('executeRequest failed, error: ' + JSON.stringify(err));
} else {
console.log('executeRequest response: ' + JSON.stringify(response));
}
});
} catch (err) {
console.log('executeRequest exception: ' + JSON.stringify(err));
}
```
### executeRequest<sup>10+</sup>
executeRequest(request: AccountCapabilityRequest): Promise&lt;AccountCapabilityResponse&gt;
Executes an account capability request. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | ------- | ---- | ------------ |
| request | [AccountCapabilityRequest](#accountcapabilityrequest10) | Yes | Account capability request to execute.|
**Return value**
| Type | Description |
| ------------------- | --------------------- |
| Promise&lt;[AccountCapabilityResponse](#accountcapabilityresponse10)&gt; | Promise used to return the result. |
**Error codes**
| ID| Error Message|
| ------- | ------- |
| 12300001 | System service exception. |
| 12300002 | Invalid request. |
**Example**
```ts
let scheduler = new account_appAccount.AccountCapabilityScheduler();
let provider = new account_appAccount.AuthorizationProvider({ bundleName: 'xxx', abilityName: 'xxx' });
let request = new account_appAccount.AccountCapabilityRequest(provider);
try {
scheduler.executeRequest(request).then((response) => {
console.log('executeRequest response: ' + JSON.stringify(response));
}).catch((err) => {
console.log('executeRequest failed, error: ' + JSON.stringify(err));
});
} catch (err) {
console.log('executeRequest exception: ' + JSON.stringify(err));
}
```
......@@ -481,7 +481,7 @@ Checks whether this OS account has been verified. This API uses an asynchronous
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. If true is returned, the current account has been verified. If false is returned, the current account has not been verified.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback invoked to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
**Error codes**
......@@ -508,6 +508,41 @@ Checks whether this OS account has been verified. This API uses an asynchronous
### checkOsAccountVerified<sup>9+</sup>
checkOsAccountVerified(): Promise&lt;boolean&gt;
Checks whether this OS account has been verified. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.OsAccount
**Return value**
| Type | Description |
| ---------------------- | ------------------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
**Error codes**
| ID| Error Message |
| -------- | ------------------- |
| 12300001 | System service exception. |
**Example**
```js
let accountManager = account_osAccount.getAccountManager();
try {
accountManager.checkOsAccountVerified().then((isVerified) => {
console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err) => {
console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
});
} catch (err) {
console.log('checkOsAccountVerified exception: ' + JSON.stringify(err));
}
```
### checkOsAccountVerified<sup>9+</sup>
checkOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether an OS account has been verified. This API uses an asynchronous callback to return the result.
......@@ -595,6 +630,41 @@ Checks whether an OS account has been verified. This API uses a promise to retur
}
```
### checkOsAccountVerified<sup>9+</sup>
checkOsAccountVerified(): Promise&lt;boolean&gt;
Checks whether this OS account has been verified. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.OsAccount
**Return value**
| Type | Description |
| ---------------------- | ----------------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the OS account has been verified; the value **false** means the opposite.|
**Error codes**
| ID| Error Message |
| -------- | ------------------- |
| 12300001 | System service exception. |
**Example**
```js
let accountManager = account_osAccount.getAccountManager();
try {
accountManager.checkOsAccountVerified().then((isVerified) => {
console.log('checkOsAccountVerified successfully, isVerified: ' + isVerified);
}).catch((err) => {
console.log('checkOsAccountVerified failed, error: ' + JSON.stringify(err));
});
} catch (err) {
console.log('checkOsAccountVerified exception: ' + JSON.stringify(err));
}
```
### removeOsAccount
removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
......@@ -1552,7 +1622,7 @@ Creates an OS account. This API uses an asynchronous callback to return the resu
| 12300002 | Invalid localName or type. |
| 12300005 | Multi-user not supported. |
| 12300006 | Unsupported account type. |
| 12300007 | The number of account reaches the upper limit. |
| 12300007 | The number of accounts reaches the upper limit. |
**Example**
......@@ -1601,7 +1671,7 @@ Creates an OS account. This API uses a promise to return the result.
| 12300002 | Invalid localName or type. |
| 12300005 | Multi-user not supported. |
| 12300006 | Unsupported account type. |
| 12300007 | The number of account reaches the upper limit. |
| 12300007 | The number of accounts reaches the upper limit. |
**Example**
......@@ -1646,7 +1716,7 @@ Creates an OS account and associates it with the specified domain account. This
| 12300002 | Invalid type or domainInfo. |
| 12300005 | Multi-user not supported. |
| 12300006 | Unsupported account type. |
| 12300007 | The number of account reaches the upper limit. |
| 12300007 | The number of accounts reaches the upper limit. |
**Example**
......@@ -1696,7 +1766,7 @@ Creates an OS account and associates it with the specified domain account. This
| 12300002 | Invalid type or domainInfo. |
| 12300005 | Multi-user not supported. |
| 12300006 | Unsupported account type. |
| 12300007 | The number of account reaches the upper limit. |
| 12300007 | The number of accounts reaches the upper limit. |
**Example**
......@@ -1720,7 +1790,7 @@ getCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
Obtains information about the OS account to which the current process belongs. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup>
**System capability**: SystemCapability.Account.OsAccount
......@@ -1756,7 +1826,7 @@ getCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
Obtains information about the OS account to which the current process belongs. This API uses a promise to return the result.
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS<sup>10+</sup>
**System capability**: SystemCapability.Account.OsAccount
......@@ -4109,8 +4179,10 @@ Performs authentication of the current user. This API uses an asynchronous callb
| 12300001 | System service exception. |
| 12300002 | Invalid challenge, authType, or authTrustLevel. |
| 12300101 | Credential is incorrect. |
| 12300102 | Credential not enrolled. |
| 12300105 | Unsupported authTrustLevel. |
| 12300106 | Unsupported authType. |
| 12300109 | Authentication is canceled. |
| 12300110 | Authentication is locked. |
| 12300111 | Authentication timeout. |
| 12300112 | Authentication service is busy. |
......@@ -4168,8 +4240,10 @@ Performs authentication of the specified user. This API uses an asynchronous cal
| 12300001 | System service exception. |
| 12300002 | Invalid userId, challenge, authType, or authTrustLevel. |
| 12300101 | Credential is incorrect. |
| 12300102 | Credential not enrolled. |
| 12300105 | Unsupported authTrustLevel. |
| 12300106 | Unsupported authType. |
| 12300109 | Authentication is canceled. |
| 12300110 | Authentication is locked. |
| 12300111 | Authentication timeout. |
| 12300112 | Authentication service is busy. |
......@@ -5319,6 +5393,9 @@ Adds credential information, including the credential type, subtype, and token (
| 12300002 | Invalid credentialInfo, i.e. authType or authSubType. |
| 12300101 | Token is invalid. |
| 12300106 | Unsupported authType. |
| 12300109 | Operation is canceled. |
| 12300111 | Operation timeout. |
| 12300115 | The number of credentials reaches the upper limit. |
**Example**
```js
......@@ -5375,7 +5452,10 @@ Updates credential information. This API uses a callback to return the result.
| 12300001 | System service exception. |
| 12300002 | Invalid credentialInfo, i.e. authType or authSubType or token. |
| 12300101 | Token is invalid. |
| 12300102 | Credential not enrolled.|
| 12300106 | Unsupported authType. |
| 12300109 | Operation is canceled. |
| 12300111 | Operation timeout. |
**Example**
```js
......@@ -5538,7 +5618,7 @@ Deletes user credential information.
| 12300001 | System service exception. |
| 12300002 | Invalid credentialId. |
| 12300101 | Token is invalid. |
| 12300102 | Credential not found. |
| 12300102 | Credential not enrolled. |
**Example**
```js
......@@ -5580,6 +5660,7 @@ Obtains authentication information. This API uses an asynchronous callback to re
| ID| Error Message |
| -------- | --------------------- |
| 12300001 | System service exception. |
| 12300102 | Credential not enrolled. |
**Example**
```js
......@@ -5619,6 +5700,7 @@ Obtains authentication information of the specified type. This API uses an async
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300002 | Invalid authType. |
| 12300102 | Credential not enrolled. |
**Example**
```js
......@@ -5663,6 +5745,7 @@ Obtains authentication information of the specified type. This API uses a promis
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300002 | Invalid authType. |
| 12300102 | Credential not enrolled. |
**Example**
```js
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册