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

!13687 [翻译完成】#I69L89

Merge pull request !13687 from Annie_wang/PR13321
......@@ -196,21 +196,22 @@
- Security
- [@ohos.abilityAccessCtrl (Ability Access Control)](js-apis-abilityAccessCtrl.md)
- [@ohos.privacyManager (Privacy Management)](js-apis-privacyManager.md)
- [@ohos.security.cert (Certificate)](js-apis-cert.md)
- [@ohos.security.cryptoFramework (Crypto Framework)](js-apis-cryptoFramework.md)
- [@ohos.security.huks (HUKS)](js-apis-huks.md)
- [@ohos.userIAM.faceAuth (Facial Authentication)](js-apis-useriam-faceauth.md)
- [@ohos.userIAM.userAuth (User Authentication)](js-apis-useriam-userauth.md)
- [@system.cipher (Cipher Algorithm)](js-apis-system-cipher.md)
- Data Management
- [@ohos.data.dataAbility ](js-apis-data-ability.md)
- [@ohos.data.dataShare](js-apis-data-dataShare.md)
- [@ohos.data.dataSharePredicates](js-apis-data-dataSharePredicates.md)
- [@ohos.data.dataShareResultSet](js-apis-data-DataShareResultSet.md)
- [@ohos.data.distributedDataObject](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore](js-apis-distributedKVStore.md)
- [@ohos.data.preferences](js-apis-data-preferences.md)
- [@ohos.data.rdb](js-apis-data-rdb.md)
- [@ohos.data.ValuesBucket](js-apis-data-valuesBucket.md)
- [@ohos.data.dataAbility (DataAbility Predicates)](js-apis-data-ability.md)
- [@ohos.data.dataShare (DataShare)](js-apis-data-dataShare.md)
- [@ohos.data.dataSharePredicates (DataShare Predicates)](js-apis-data-dataSharePredicates.md)
- [@ohos.data.dataShareResultSet (DataShare Result Set)](js-apis-data-DataShareResultSet.md)
- [@ohos.data.distributedDataObject (Distributed Data Object)](js-apis-data-distributedobject.md)
- [@ohos.data.distributedKVStore (Distributed KV Store)](js-apis-distributedKVStore.md)
- [@ohos.data.preferences (Preferences)](js-apis-data-preferences.md)
- [@ohos.data.rdb (RDB)](js-apis-data-rdb.md)
- [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md)
- data/rdb
- [resultSet](js-apis-data-resultset.md)
- File Management
......
# @ohos.security.cert (Certificate)
The **certificate** module provides APIs for performing certificate operations. For details about the APIs for implementing the basic algorithm capabilities based on the cryptographic (crypto) framework, see [Crypto Framework](js-apis-cryptoFramework.md).
> **NOTE**
>
> The initial APIs of this module are supported since API version 9.
## Modules to Import
```javascript
import cryptoCert from '@ohos.security.cert';
import cryptoFramework from "@ohos.security.cryptoFramework"
```
## CertResult
Enumerates the error codes.
**System capability**: SystemCapability.Security.Cert
| Name | Value | Description |
| --------------------------------------| -------- | -----------------------------|
| INVALID_PARAMS | 401 | Invalid parameters. |
| NOT_SUPPORT | 801 | This operation is not supported. |
| ERR_OUT_OF_MEMORY | 19020001 | Memory error. |
| ERR_RUNTIME_ERROR | 19020002 | Runtime error. |
| ERR_CRYPTO_OPERATION | 19030001 | Crypto operation error. |
| ERR_CERT_SIGNATURE_FAILURE | 19030002 | The certificate signature verification failed. |
| ERR_CERT_NOT_YET_VALID | 19030003 | The certificate has not taken effect. |
| ERR_CERT_HAS_EXPIRED | 19030004 | The certificate has expired. |
| ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY | 19030005 | Failed to obtain the certificate issuer. |
| ERR_KEYUSAGE_NO_CERTSIGN | 19030006 | The key cannot be used for signing a certificate. |
| ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE | 19030007 | The key cannot be used for digital signature. |
## DataBlob
Defines a binary data array.
**System capability**: SystemCapability.Security.Cert
| Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | ---- | ----------------|
| data | Uint8Array | Yes | Yes | Data. |
## DataArray
Defines a list of data arrays.
**System capability**: SystemCapability.Security.Cert
| Name | Type | Readable| Writable| Description |
| -------------- | -------------- | ---- | ---- | ----------------|
| data | Uint8Array | Yes | Yes | Data list. |
## EncodingFormat
Enumerates the certificate encoding formats.
**System capability**: SystemCapability.Security.Cert
| Name | Value| Description |
| ---------- | ------ | --------- |
| FORMAT_DER | 0 | Distinguished Encoding Rules (DER) format.|
| FORMAT_PEM | 1 | Privacy-Enhanced Mail (PEM) format.|
## EncodingBlob
Defines a certificate binary array in encoding format.
### Attributes
**System capability**: SystemCapability.Security.Cert
| Name | Type | Readable| Writable| Description |
| -------------- | --------------------------------- | ---- | ---- | ------------------------------ |
| data | Uint8Array | Yes | Yes | Certificate data.|
| encodingFormat | [EncodingFormat](#encodingformat) | Yes | Yes | Certificate encoding format. |
## CertChainData
Defines the certificate chain data, which is passed in as input parameters during certificate chain verification.
### Attributes
**System capability**: SystemCapability.Security.Cert
| Name | Type | Readable| Writable| Description |
| -------------- | --------------------------------- | ---- | ---- | ------------------------------------------------------------ |
| data | Uint8Array | Yes | Yes | Certificate data, in the *length* (2 bytes) + *data* format. For example, **08ABCDEFGH07ABCDEFG**. The first two bytes indicate the length of the first certificate is eight bytes, and the following eight bytes indicate the certificate data. Then, the next two bytes indicate the length of another certificate is seven bytes, and the seven bytes followed indicate the certificate data.|
| count | number | Yes | Yes | Number of certificates contained in the input data. |
| encodingFormat | [EncodingFormat](#encodingformat) | Yes | Yes | Certificate encoding format. |
## cryptoCert.createX509Cert
createX509Cert(inStream : EncodingBlob, callback : AsyncCallback\<X509Cert>) : void
Creates an **X509Cert** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | -------------------------- |
| inStream | [EncodingBlob](#encodingblob) | Yes | X.509 certificate serialization data. |
| callback | AsyncCallback\<X509Cert> | Yes | Callback invoked to return the result. **X509Cer** instance created.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoFramework.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
}
});
```
## cryptoCert.createX509Cert
createX509Cert(inStream : EncodingBlob) : Promise\<X509Cert>
Creates an **X509Cert** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ------------------ |
| inStream | [EncodingBlob](#encodingblob) | Yes | X.509 certificate serialization data.|
**Return value**
| Type | Description |
| ------- | ---------------- |
| Promise\<X509Cert> | **X509Cer** instance created.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob).then(x509Cert => {
console.log("createX509Cert success");
}, error => {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
});
```
## X509Cert
Provides APIs for X.509 certificate operations.
### verify
verify(key : cryptoFramework.PubKey, callback : AsyncCallback\<void>) : void
Verifies the certificate signature. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------------------------------ |
| key | cryptoFramework.PubKey | Yes | Public key used for signature verification. |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If **error** is **null**, the signature verification is successful. If **error** is not **null**, the signature verification fails.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
import cryptoFramework from "@ohos.security.cryptoFramework"
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
// Generate a public key by AsyKeyGenerator or obtain the public key by using getPublicKey() of the X509Cert instance.
let pubKey = null;
x509Cert.verify(pubKey, function (error, data) {
if (error != null) {
console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("verify success");
}
});
}
});
```
### verify
verify(key : cryptoFramework.PubKey) : Promise\<void>
Verifies the certificate signature. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.|
**Return value**
| Type | Description |
| -------------- | ----------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob).then(x509Cert => {
console.log("createX509Cert success");
// Generate a public key by AsyKeyGenerator or obtain the public key by using getPublicKey() of the X509Cert instance.
let pubKey = null;
x509Cert.verify(pubKey).then(result => {
console.log("verify success");
}, error => {
console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message);
});
}, error => {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
});
```
### getEncoded
getEncoded(callback : AsyncCallback\<EncodingBlob>) : void
Obtains the serialized X.509 certificate data. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | Yes | Callback invoked to return the result. Promise used to return the serialized X.509 certificate data obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
x509Cert.getEncoded(function (error, data) {
if (error != null) {
console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("getEncoded success");
}
});
}
});
```
### getEncoded
getEncoded() : Promise\<EncodingBlob>
Obtains the serialized X.509 certificate data. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------------------------- | ---------------------- |
| Promise\<[EncodingBlob](#encodingblob)> | Promise used to return the serialized X.509 certificate data obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob).then(x509Cert => {
console.log("createX509Cert success");
x509Cert.getEncoded().then(result => {
console.log("getEncoded success");
}, error => {
console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message);
});
}, error => {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
});
```
### getPublicKey
getPublicKey() : cryptoFramework.PubKey
Obtains the public key of this X.509 certificate. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ---------------- |
| cryptoFramework.PubKey | X.509 certificate public key obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
import cryptoFramework from "@ohos.security.cryptoFramework"
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let pubKey = null;
try {
pubKey = x509Cert.getPublicKey();
} catch (error) {
console.log("getPublicKey failed, errCode: " + error.code + ", errMsg: " + error.message);
}
}
});
```
### checkValidityWithDate
checkValidityWithDate(date: string) : void
Checks the validity period of this X.509 certificate. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------- | ---- | ---------- |
| date | string | Yes | Date of the certificate to check. |
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let date = "150527000001Z";
// Verify the certificate validity period.
try {
x509Cert.checkValidityWithDate(date);
} catch (error) {
console.log("checkValidityWithDate failed, errCode: " + error.code + ", errMsg: " + error.message);
}
}
});
```
### getVersion
getVersion() : number
Obtains the X.509 certificate version.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ---------------- |
| number | X.509 certificate version obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let version = x509Cert.getVersion();
}
});
```
### getSerialNumber
getSerialNumber() : number
Obtains the X.509 certificate serial number.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ------------------ |
| number | X.509 certificate serial number obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let serialNumber = x509Cert.getSerialNumber();
}
});
```
### getIssuerName
getIssuerName() : DataBlob
Obtains the X.509 certificate issuer.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | ---------------------- |
| [DataBlob](#datablob) | X.509 certificate issuer obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let issuerName = x509Cert.getIssuerName();
}
});
```
### getSubjectName
getSubjectName() : DataBlob
Obtains the subject of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | -------------------- |
| [DataBlob](#datablob) | Subject name obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let subjectName = x509Cert.getSubjectName();
}
});
```
### getNotBeforeTime
getNotBeforeTime() : string
Obtains the start time of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | -------------------------- |
| string | Start time of the X.509 certificate obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let notBefore = x509Cert.getNotBeforeTime();
}
});
```
### getNotAfterTime
getNotAfterTime() : string
Obtains the expiration time of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | -------------------------- |
| string | Expiration time of the X.509 certificate obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let notAfter = x509Cert.getNotAfterTime();
}
});
```
### getSignature
getSignature() : DataBlob
Obtains the signature data of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | -------------------- |
| [DataBlob](#datablob) | Signature data obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let signature = x509Cert.getSignature();
}
});
```
### getSignatureAlgName
getSignatureAlgName() : string
Obtains the signing algorithm of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ------------------------ |
| string | X.509 certificate signing algorithm obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let sigAlgName = x509Cert.getSignatureAlgName();
}
});
```
### getSignatureAlgOid
getSignatureAlgOid() : string
Obtains the object identifier (OID) of the X.509 certificate signing algorithm. OIDs are allocated by the International Organization for Standardization (ISO).
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | --------------------------------- |
| string | OID obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let sigAlgOid = x509Cert.getSignatureAlgOid();
}
});
```
### getSignatureAlgParams
getSignatureAlgParams() : DataBlob
Obtains the signing algorithm parameters of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | ------------------------ |
| [DataBlob](#datablob) | X.509 certificate signing algorithm parameters obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let sigAlgParams = x509Cert.getSignatureAlgParams();
}
});
```
### getKeyUsage
getKeyUsage() : DataBlob
Obtains the key usage of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | -------------------- |
| [DataBlob](#datablob) | Key usage of the X.509 certificate obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let keyUsage = x509Cert.getKeyUsage();
}
});
```
### getExtKeyUsage
getExtKeyUsage() : DataArray
Obtains the usage of the extended key of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ----------------------- | ------------------------ |
| [DataArray](#dataarray) | Usage of the extended key obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let extKeyUsage = x509Cert.getExtKeyUsage();
}
});
```
### getBasicConstraints
getBasicConstraints() : number
Obtains the basic constraints for obtaining this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | -------------------- |
| number | Basic constraints obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let basicConstraints = x509Cert.getBasicConstraints();
}
});
```
### getSubjectAltNames
getSubjectAltNames() : DataArray
Obtains the Subject Alternative Names (SANs) of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ----------------------- | ------------------------ |
| [DataArray](#dataarray) | SANs obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let subjectAltNames = x509Cert.getSubjectAltNames();
}
});
```
### getIssuerAltNames
getIssuerAltNames() : DataArray
Obtains the Issuer Alternative Names (IANs) of this X.509 certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ----------------------- | -------------------------- |
| [DataArray](#dataarray) | IANs obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Certificate binary data, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Cert(encodingBlob, function (error, x509Cert) {
if (error != null) {
console.log("createX509Cert failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Cert success");
let issuerAltNames = x509Cert.getIssuerAltNames();
}
});
```
## cryptoCert.createX509Crl
createX509Crl(inStream : EncodingBlob, callback : AsyncCallback\<X509Crl>) : void
Creates an **X509Crl** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ------------------------------ |
| inStream | [EncodingBlob](#encodingblob) | Yes | Serialized certificate revocation list (CRL) data. |
| callback | AsyncCallback\<X509Crl> | Yes | Callback invoked to return the result. Promise used to return the **X509Crl** instance created.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
}
});
```
## cryptoCert.createX509Crl
createX509Crl(inStream : EncodingBlob) : Promise\<X509Crl>
Creates an **X509Crl** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | -------------------------- |
| inStream | [EncodingBlob](#encodingblob) | Yes | Serialized CRL data.|
**Return value**
| Type | Description |
| ----------------- | -------------------- |
| Promise\<X509Crl> | Promise used to return the **X509Crl** instance created.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob).then(x509Crl => {
console.log("createX509Crl success");
}, error => {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
});
```
## X509Crl
Provides APIs for X.509 certificate CRL operations.
### isRevoked
isRevoked(cert : X509Cert) : boolean
Checks whether an X.509 certificate is revoked. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | -------- | ---- | -------------------- |
| cert | X509Cert | Yes | X.509 certificate to check.|
**Return value**
| Type | Description |
| --------- | --------------------------------------------- |
| boolean | Promise used to return the result. The value **true** indicates the certificate is revoked; the value **false** indicates the opposite.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
// Create an X509Cert instance.
let x509Cert = null;
try {
let revokedFlag = x509Crl.isRevoked(x509Cert);
} catch (error) {
console.log("isRevoked failed, errCode: " + error.code + ", errMsg: " + error.message);
}
}
});
```
### getType
getType() : string
Obtains the CRL type.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | -------------------- |
| string | CRL type obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
let type = x509Crl.getType();
}
});
```
### getEncoded
getEncoded(callback : AsyncCallback\<EncodingBlob>) : void
Obtains the serialized X.509 CRL data. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback\<EncodingBlob> | Yes | Callback invoked to return the serialized X.509 CRL data obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
x509Crl.getEncoded(function (error, data) {
if (error != null) {
console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("getEncoded success");
}
});
}
});
```
### getEncoded
getEncoded() : Promise\<EncodingBlob>
Obtains the serialized X.509 CRL data. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ---------------------- | -------------------------------- |
| Promise\<EncodingBlob> | Promise used to return the serialized X.509 CRL data obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob).then(x509Crl => {
console.log("createX509Crl success");
x509Crl.getEncoded().then(result => {
console.log("getEncoded success");
}, error => {
console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message);
});
}, error => {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
});
```
### verify
verify(key : cryptoFramework.PubKey, callback : AsyncCallback\<void>) : void
Verifies the signature of the X.509 CRL. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------------------------------------ |
| key | cryptoFramework.PubKey | Yes | Public key used for signature verification. |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If **error** is **null**, the signature verification is successful. If **error** is not **null**, the signature verification fails.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
import cryptoFramework from "@ohos.security.cryptoFramework"
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
// Generate the public key by AsyKeyGenerator.
let pubKey = null;
x509Crl.verify(pubKey, function (error, data) {
if (error != null) {
console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("verify success");
}
});
}
});
```
### verify
verify(key : cryptoFramework.PubKey) : Promise\<void>
Verifies the signature of the X.509 CRL. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------- |
| key | cryptoFramework.PubKey | Yes | Public key used for signature verification.|
**Return value**
| Type| Description |
| ---- | ------------------------------------------------------------ |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
import cryptoFramework from "@ohos.security.cryptoFramework"
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob).then(x509Crl => {
console.log("createX509Crl success");
// Generate the public key by AsyKeyGenerator.
let pubKey = null;
x509Crl.verify(pubKey).then(result => {
console.log("verify success");
}, error => {
console.log("verify failed, errCode: " + error.code + ", errMsg: " + error.message);
});
}, error => {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
});
```
### getVersion
getVersion() : number
Obtains the version of the X.509 CRL.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | -------------------------------- |
| number | Version of the X.509 CRL obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
let version = x509Crl.getVersion();
}
});
```
### getIssuerName
getIssuerName() : DataBlob
Obtains the issuer of the X.509 CRL.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | ------------------------------ |
| [DataBlob](#datablob) | Issuer of the X.509 CRL obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
let issuerName = x509Crl.getIssuerName();
}
});
```
### getLastUpdate
getLastUpdate() : string
Obtains the date when the X.509 CRL was last updated.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ------------------------------------ |
| string | Last update date of the X.509 CRL.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
let lastUpdate = x509Crl.getLastUpdate();
}
});
```
### getNextUpdate
getNextUpdate() : string
Obtains the date when the CRL will be updated the next time.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ------------------------------------ |
| string | Next update date obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
let nextUpdate = x509Crl.getNextUpdate();
}
});
```
### getRevokedCert
getRevokedCert(serialNumber : number) : X509CrlEntry
Obtains the revoked X.509 certificate based on the specified serial number of the certificate. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | ------ | ---- | -------------- |
| serialNumber | number | Yes | Serial number of the certificate.|
**Return value**
| Type | Description |
| ---------------------- | --------------------- |
| X509CrlEntry | Promise used to return the revoked X.509 certificate obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
// Set the serial number of the corresponding certificate.
let serialNumber = 1000;
try {
let entry = x509Crl.getRevokedCert(serialNumber);
} catch (error) {
console.log("getRevokedCert failed, errCode: " + error.code + ", errMsg: " + error.message);
}
}
});
```
### getRevokedCertWithCert
getRevokedCertWithCert(cert : X509Cert) : X509CrlEntry
Obtains the revoked X.509 certificate based on the specified certificate. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | -------- | ---- | ------------ |
| cert | X509Cert | Yes | Certificate based on which the revoked certificate is obtained.|
**Return value**
| Type | Description |
| ------------ | -------------------- |
| X509CrlEntry | Promise used to return the revoked X.509 certificate obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
// Create an X509Cert instance.
let x509Cert = null;
try {
let entry = x509Crl.getRevokedCertWithCert(x509Cert);
} catch (error) {
console.log("getRevokedCertWithCert failed, errCode: " + error.code + ", errMsg: " + error.message);
}
}
});
```
### getRevokedCerts
getRevokedCerts(callback : AsyncCallback<Array\<X509CrlEntry>>) : void
Obtains all the revoked X.509 certificates. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback<Array\<X509CrlEntry>> | Yes | Callback invoked to return the result. Promise used to return a list of revoked X.509 certificates.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
x509Crl.getRevokedCerts(function (error, array) {
if (error != null) {
console.log("getRevokedCerts failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("getRevokedCerts success");
}
});
}
});
```
### getRevokedCerts
getRevokedCerts() : Promise<Array\<X509CrlEntry>>
Obtains all the revoked X.509 certificates. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ----------------------------- | ---------------------- |
| Promise<Array\<X509CrlEntry>> | Promise used to return a list of revoked X.509 certificates.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob).then(x509Crl => {
console.log("createX509Crl success");
x509Crl.getRevokedCerts().then(array => {
console.log("getRevokedCerts success");
}, error => {
console.log("getRevokedCerts failed, errCode: " + error.code + ", errMsg: " + error.message);
});
}, error => {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
});
```
### getTbsInfo
getTbsInfo() : DataBlob
Obtains the DER-encoded CRL information, the **tbsCertList** from this CRL. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | ------------------------------- |
| [DataBlob](#datablob) | Promise used to return the **tbsCertList** information obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
try {
let tbsInfo = x509Crl.getTbsInfo();
} catch (error) {
console.log("getTbsInfo failed, errCode: " + error.code + ", errMsg: " + error.message);
}
}
});
```
### getSignature
getSignature() : DataBlob
Obtains the signature data of the X.509 CRL.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | ------------------------------ |
| [DataBlob](#datablob) | Signature data of the X.509 CRL obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
let signature = x509Crl.getSignature();
}
});
```
### getSignatureAlgName
getSignatureAlgName() : string
Obtains the signing algorithm of the X.509 CRL.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | -------------------------------- |
| string | Signing algorithm obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
let sigAlgName = x509Crl.getSignatureAlgName();
}
});
```
### getSignatureAlgOid
getSignatureAlgOid() : string
Obtains the OID of the X.509 CRL signing algorithm. OIDs are allocated by the International Organization for Standardization (ISO).
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | --------------------------------------------- |
| string | OID of the X.509 CRL signing algorithm obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
let sigAlgOid = x509Crl.getSignatureAlgOid();
}
});
```
### getSignatureAlgParams
getSignatureAlgParams() : DataBlob
Obtains the parameters of the X.509 CRL signing algorithm.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | ---------------------------------- |
| [DataBlob](#datablob) | Algorithm parameters obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Binary data of the CRL, which must be set based on the service.
let encodingData = null;
let encodingBlob = {
data: encodingData,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
cryptoCert.createX509Crl(encodingBlob, function (error, x509Crl) {
if (error != null) {
console.log("createX509Crl failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("createX509Crl success");
let sigAlgParams = x509Crl.getSignatureAlgParams();
}
});
```
## cryptoCert.createCertChainValidator
createCertChainValidator(algorithm :string) : CertChainValidator
Creates a **CertChainValidator** object.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ------------------------------------------ |
| algorithm | string | Yes | Certificate chain validator algorithm. Currently, only **PKIX** is supported.|
**Return value**
| Type | Description |
| ------------------ | -------------------- |
| CertChainValidator | **CertChainValidator** object created.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
let validator = cryptoCert.createCertChainValidator("PKIX");
```
## CertChainValidator
Provides APIs for certificate chain validator operations.
### Attributes
**System capability**: SystemCapability.Security.CryptoFramework
| Name | Type | Readable| Writable| Description |
| ------- | ------ | ---- | ---- | -------------------------- |
| algorithm | string | Yes | No | Algorithm used by the X509 certificate chain validator.|
### validate
validate(certChain : CertChainData, callback : AsyncCallback\<void>) : void
Validates the X.509 certificate chain. This API uses an asynchronous callback to return the result.
The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](../../security/cert-overview.md#certificate-specifications).
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| certChain | [CertChainData](#certchaindata) | Yes | Serialized X.509 certificate chain data. |
| callback | AsyncCallback\<void> | Yes | Callback invoked to return the result. If **error** is **null**, the X.509 certificate chain is valid. If **error** is not **null**, the X.509 certificate chain is not valid.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
let validator = cryptoCert.createCertChainValidator("PKIX");
// Certificate chain binary data, which must be set based on the service.
let encodingData = null;
// Number of certificates in the certificate chain. It must be set based on the service.
let certCount = 2;
let certChainData = {
data: encodingData,
count: certCount,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
validator.validate(certChainData, function (error, data) {
if (error != null) {
console.log("validate failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("validate success");
}
});
```
### validate
validate(certChain : CertChainData) : Promise\<void>
Validates the X.509 certificate chain. This API uses a promise to return the result.
The certificate chain validator does not verify the certificate validity period because the system time on the device is untrusted. To check the validity period of a certificate, use the [checkValidityWithDate()](#checkvaliditywithdate) API of the **X509Cert** class. For details, see [Certificate Specifications](../../security/cert-overview.md#certificate-specifications).
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------- | ---- | -------------------------- |
| certChain | [CertChainData](#certchaindata) | Yes | Serialized X.509 certificate chain data.|
**Return value**
| Type | Description |
| -------------- | ----------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
let validator = cryptoCert.createCertChainValidator("PKIX");
// Certificate chain binary data, which must be set based on the service.
let encodingData = null;
// Number of certificates in the certificate chain. It must be set based on the service.
let certCount = 2;
let certChainData = {
data: encodingData,
count: certCount,
// Set the encoding format, which can be FORMAT_PEM or FORMAT_DER.
encodingFormat: cryptoCert.EncodingFormat.FORMAT_PEM
};
validator.validate(certChainData).then(result => {
console.log("validate success");
}, error => {
console.log("validate failed, errCode: " + error.code + ", errMsg: " + error.message);
});
```
### algorithm
algorithm : string
Obtains the algorithm of the X.509 certificate chain validator.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ------------------------ |
| string | Algorithm of the X.509 certificate chain validator obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
let validator = cryptoCert.createCertChainValidator("PKIX");
let algorithm = validator.algorithm;
```
## X509CrlEntry
Provides APIs for operating the revoked certificates.
### getEncoded
getEncoded(callback : AsyncCallback\<EncodingBlob>) : void
Obtains the serialized data of this revoked certificate. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback\<[EncodingBlob](#encodingblob)> | Yes | Callback invoked to return the result. Promise used to return the serialized data of the revoked certificate obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Obtain X509CrlEntry by using getRevokedCert() of X509Crl.
let x509CrlEntry = null;
x509CrlEntry.getEncoded(function (error, data) {
if (error != null) {
console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message);
} else {
console.log("getEncoded success");
}
});
```
### getEncoded
getEncoded() : Promise\<EncodingBlob>
Obtains the serialized data of this revoked certificate. This API uses a promise to return the result.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------------------------- | -------------------------- |
| Promise\<[EncodingBlob](#encodingblob)> | Promise used to return the serialized data of the revoked certificate obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Obtain X509CrlEntry by using getRevokedCert() of X509Crl.
let x509CrlEntry = null;
x509CrlEntry.getEncoded().then(result => {
console.log("getEncoded success");
}, error => {
console.log("getEncoded failed, errCode: " + error.code + ", errMsg: " + error.message);
});
```
### getSerialNumber
getSerialNumber() : number
Obtains the serial number of this revoked certificate.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ---------------------- |
| number | Serial number of the revoked certificate obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Obtain X509CrlEntry by using getRevokedCert() of X509Crl.
let x509CrlEntry = null;
let serialNumber = x509CrlEntry.getSerialNumber();
```
### getCertIssuer
getCertIssuer() : DataBlob
Obtains the issuer of this revoked certificate. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| --------------------- | ---------------------- - |
| [DataBlob](#datablob) | Promise used to return the issuer of the revoked certificate obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Obtain X509CrlEntry by using getRevokedCert() of X509Crl.
let x509CrlEntry = null;
try {
let issuer = x509CrlEntry.getCertIssuer();
} catch (error) {
console.log("getCertIssuer failed, errCode: " + error.code + ", errMsg: " + error.message);
}
```
### getRevocationDate
getRevocationDate() : string
Obtains the date when the certificate was revoked. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Security.Cert
**Return value**
| Type | Description |
| ------ | ------------------ |
| string | Promise used to return the certificate revocation date obtained.|
**Example**
```js
import cryptoCert from '@ohos.security.cert';
// Obtain X509CrlEntry by using getRevokedCert() of X509Crl.
let x509CrlEntry = null;
try {
let date = x509CrlEntry.getRevocationDate();
} catch (error) {
console.log("getRevocationDate failed, errCode: " + error.code + ", errMsg: " + error.message);
}
```
# @ohos.data.dataShareResultSet
# @ohos.data.dataShareResultSet (DataShare Result Set)
The **DataShareResultSet** module provides APIs for accessing the result set obtained from the database. You can access the values in the specified rows or the value of the specified data type.
......
# DataAbilityPredicates
# @ohos.data.dataAbility (DataAbility Predicates)
**DataAbility** provides APIs for creating predicates, which implement different query methods for relational database (RDB) stores.
......@@ -23,16 +23,16 @@ Creates an **RdbPredicates** object from a **DataAbilityPredicates** object.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of a database table.|
| dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of a database table.|
| dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object. |
**Return value**
| Type| Description|
| -------- | -------- |
| rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created.|
| Type| Description|
| -------- | -------- |
| rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created.|
**Example**
......@@ -56,16 +56,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -83,16 +83,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -110,9 +110,9 @@ Adds a left parenthesis to this **DataAbilityPredicates**.
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis.|
**Example**
......@@ -135,9 +135,9 @@ Adds a right parenthesis to this **DataAbilityPredicates**.
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis.|
**Example**
......@@ -160,9 +160,9 @@ Adds the OR condition to this **DataAbilityPredicates**.
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition.|
**Example**
......@@ -182,9 +182,9 @@ Adds the AND condition to this **DataAbilityPredicates**.
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition.|
**Example**
......@@ -204,16 +204,16 @@ Sets a **DataAbilityPredicates** object to match a string containing the specifi
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -231,16 +231,16 @@ Sets a **DataAbilityPredicates** object to match a string that starts with the s
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -258,16 +258,16 @@ Sets a **DataAbilityPredicates** object to match a string that ends with the spe
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -285,15 +285,15 @@ Sets a **DataAbilityPredicates** object to match the field whose value is null.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -311,15 +311,15 @@ Sets a **DataAbilityPredicates** object to match the field whose value is not nu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -337,16 +337,16 @@ Sets a **DataAbilityPredicates** object to match a string that is similar to the
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -364,16 +364,16 @@ Sets a **DataAbilityPredicates** object to match the specified string.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | string | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -391,17 +391,17 @@ Sets a **DataAbilityPredicates** object to match a field whose data type is **Va
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.|
| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.|
| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -419,17 +419,17 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.|
| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.|
| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -447,16 +447,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -474,16 +474,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -501,16 +501,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -528,16 +528,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -555,15 +555,15 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -581,15 +581,15 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -607,9 +607,9 @@ Sets a **DataAbilityPredicates** object to filter out duplicate records.
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records.|
**Example**
......@@ -627,15 +627,15 @@ Set a **DataAbilityPredicates** object to specify the maximum number of records.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | number | Yes| Maximum number of records.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | number | Yes| Maximum number of records.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records.|
**Example**
......@@ -653,15 +653,15 @@ Sets a **DataAbilityPredicates** object to specify the start position of the ret
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result.|
**Example**
......@@ -680,15 +680,15 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fields | Array&lt;string&gt; | Yes| Names of columns to group.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fields | Array&lt;string&gt; | Yes| Names of columns to group.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value.|
**Example**
......@@ -706,15 +706,15 @@ Sets a **DataAbilityPredicates** object to specify the index column.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| indexName | string | Yes| Name of the index column.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| indexName | string | Yes| Name of the index column.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column.|
**Example**
......@@ -732,17 +732,17 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | Array&lt;[ValueType](#valuetype)&gt; | Yes| Array of **ValueType**s to match.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | Array&lt;[ValueType](#valuetype)&gt; | Yes| Array of **ValueType**s to match.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......@@ -760,16 +760,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array\
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | Array&lt;[ValueType](#valuetype)&gt; | Yes| Array of **ValueType**s to match.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| field | string | Yes| Column name in the table.|
| value | Array&lt;[ValueType](#valuetype)&gt; | Yes| Array of **ValueType**s to match.|
**Return value**
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
| Type| Description|
| -------- | -------- |
| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.|
**Example**
......
# @ohos.data.dataShare
# @ohos.data.dataShare (DataShare)
The **DataShare** module allows an application to manage its own data and share data with other applications on the same device.
......
# Data Share Predicates
# @ohos.data.dataSharePredicates (DataShare Predicates)
You can use **DataSharePredicates** to specify conditions for [updating](js-apis-data-dataShare.md#update), [deleting](js-apis-data-dataShare.md#delete), and [querying](js-apis-data-dataShare.md#query) data when **DataShare** is used to manage data.
......@@ -35,7 +35,7 @@ Currently, only the relational database (RDB) and key-value database (KVDB, sche
| Name| Type | Mandatory| Description |
| ------ | --------------------------------------------------- | ---- | ---------------------- |
| field | string | Yes | Column name in the database table. |
| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.|
| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.|
**Return value**
......@@ -65,7 +65,7 @@ Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** o
| Name| Type | Mandatory| Description |
| ------ | --------------------------------------------------- | ---- | ---------------------- |
| field | string | Yes | Column name in the database table. |
| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.|
| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.|
**Return value**
......@@ -439,8 +439,8 @@ Currently, only the RDB supports this **DataSharePredicates** object.
| Name| Type | Mandatory| Description |
| ------ | --------------------------------------------------- | ---- | ------------------------ |
| field | string | Yes | Column name in the database table. |
| low | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | The lowest value of the range.|
| high | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | The highest value of the range.|
| low | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | The lowest value of the range.|
| high | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | The highest value of the range.|
**Return value**
......@@ -470,8 +470,8 @@ Currently, only the RDB supports this **DataSharePredicates** object.
| Name| Type | Mandatory| Description |
| ------ | --------------------------------------------------- | ---- | ------------------------ |
| field | string | Yes | Column name in the database table. |
| low | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | The lowest value of the range.|
| high | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | The highest value of the range.|
| low | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | The lowest value of the range.|
| high | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | The highest value of the range.|
**Return value**
......@@ -501,7 +501,7 @@ Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** o
| Name | Type | Mandatory| Description |
| ------- | --------- | ---- | ---------------------- |
| field | string | Yes | Column name in the database table. |
| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.|
| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.|
**Return value**
......@@ -531,7 +531,7 @@ Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** o
| Name| Type | Mandatory| Description |
| ------ | --------------------------------------------------- | ---- | ---------------------- |
| field | string | Yes | Column name in the database table. |
| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.|
| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.|
**Return value**
......@@ -561,7 +561,7 @@ Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** o
| Name | Type | Mandatory| Description |
| ------- | --------- | ---- | ---------------------- |
| field | string | Yes | Column name in the database table. |
| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.|
| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.|
**Return value**
......@@ -591,7 +591,7 @@ Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** o
| Name | Type | Mandatory| Description |
| ------- | --------- | ---- | ---------------------- |
| field | string | Yes | Column name in the database table. |
| value | [ValueType](js-apis-data-ValuesBucket.md#valuetype) | Yes | Value to match.|
| value | [ValueType](js-apis-data-valuesBucket.md#valuetype) | Yes | Value to match.|
**Return value**
......@@ -790,7 +790,7 @@ Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** o
| Name | Type | Mandatory| Description |
| ------- | ---------------- | ---- | --------------------------------------- |
| field | string | Yes| Column name in the database table. |
| value | Array&lt;[ValueType](js-apis-data-ValuesBucket.md#valuetype)&gt; | Yes | Array of the values to match.|
| value | Array&lt;[ValueType](js-apis-data-valuesBucket.md#valuetype)&gt; | Yes | Array of the values to match.|
**Return value**
......@@ -820,7 +820,7 @@ Currently, only the RDB and KVDB (schema) support this **DataSharePredicates** o
| Name | Type | Mandatory| Description |
| ------- | ---------------- | ---- | --------------------------------------- |
| field | string | Yes | Column name in the database table. |
| value | Array&lt;[ValueType](js-apis-data-ValuesBucket.md#valuetype)&gt; | Yes | Array of the values to match.|
| value | Array&lt;[ValueType](js-apis-data-valuesBucket.md#valuetype)&gt; | Yes | Array of the values to match.|
**Return value**
......
# Distributed Data Object
# @ohos.data.distributedDataObject (Distributed Data Object)
The **distributedDataObject** module provides basic data object management, including creating, querying, deleting, modifying, and subscribing to data objects, and distributed data object collaboration for the same application among multiple devices.
......@@ -23,9 +23,9 @@ Creates a distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| source | object | Yes| Attribute of the distributed data object to create.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| source | object | Yes| Attribute of the distributed data object to create.|
**Return value**
| Type| Description|
......@@ -49,9 +49,9 @@ Creates a random session ID.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Return value**
| Type| Description|
| -------- | -------- |
| string | Session ID created.|
| Type| Description|
| -------- | -------- |
| string | Session ID created.|
**Example**
```js
......@@ -97,15 +97,15 @@ Sets a session ID for synchronization. Automatic synchronization is performed fo
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| sessionId | string | No| ID of a distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. |
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the session ID is set successfully;<br>returns **false** otherwise. |
**Example**
......@@ -128,10 +128,10 @@ Subscribes to the changes of this distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback used to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | Yes| Callback used to return the changes of the distributed data object.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example**
```js
......@@ -157,10 +157,10 @@ Unsubscribes from the changes of this distributed data object.
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback to be unregistered. If this parameter is not set, all data change callbacks of the object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **change**, which indicates data changes.|
| callback | Callback<{ sessionId: string, fields: Array&lt;string&gt; }> | No| Callback to be unregistered. If this parameter is not set, all data change callbacks of the object will be unregistered.<br>**sessionId** indicates the session ID of the distributed data object.<br>**fields** indicates the changed attributes of the distributed data object.|
**Example**
......@@ -182,10 +182,10 @@ Subscribes to the status change (online or offline) of this distributed data obj
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the status change.<br>**sessionId**: session ID of the distributed data object.<br>**networkId**: object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to subscribe to. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }> | Yes| Callback used to return the status change.<br>**sessionId**: session ID of the distributed data object.<br>**networkId**: object device ID, that is, **deviceId**.<br>**status** indicates the object status, which can be online or offline.|
**Example**
```js
......@@ -207,10 +207,10 @@ Unsubscribes from the status change (online or offline) of this distributed data
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status change. If this parameter is not specified, this API unsubscribes from all callbacks of this distributed data object.<br>**sessionId**: session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the status, which can be online or offline.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **status**, which indicates the status change (online or offline) of the distributed data object.|
| callback | Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }> | No| Callback used to return the status change. If this parameter is not specified, this API unsubscribes from all callbacks of this distributed data object.<br>**sessionId**: session ID of the distributed data object.<br>**deviceId** indicates the device ID of the distributed data object.<br>**status** indicates the status, which can be online or offline.|
**Example**
......@@ -243,10 +243,10 @@ The saved data will be released in the following cases:
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.|
| callback | AsyncCallback&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Yes| Callback used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where data is stored. The value **local** indicates the local device.|
| callback | AsyncCallback&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Yes| Callback used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
**Example**
```js
......@@ -279,15 +279,15 @@ The saved data will be released in the following cases:
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| ID of the device where the data is saved. The default value is **local**, which indicates the local device. |
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[SaveSuccessResponse](#savesuccessresponse9)&gt; | Promise used to return **SaveSuccessResponse**, which contains information such as session ID, version, and device ID.|
**Example**
......@@ -317,9 +317,9 @@ If the object is stored on another device, the data on the local device will be
**System capability**: SystemCapability.DistributedDataManager.DataObject.DistributedObject
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | No| Callback used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | No| Callback used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
**Example**
......@@ -345,9 +345,9 @@ If the object is stored on another device, the data on the local device will be
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[RevokeSaveSuccessResponse](#revokesavesuccessresponse9)&gt; | Promise used to return **RevokeSaveSuccessResponse**, which contains the session ID.|
**Example**
......
# Preferences
# @ohos.data.preferences (Preferences)
The **Preferences** module provides APIs for processing data in the form of key-value (KV) pairs and supports persistence of the KV pairs when required.
......@@ -497,7 +497,7 @@ Obtains the value of a key. This API uses a promise to return the result. If the
**System capability**: SystemCapability.DistributedDataManager.Preferences.Core
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
| key | string | Yes | Key of the data to obtain. It cannot be empty. |
......
# @ohos.data.rdb
# @ohos.data.rdb (RDB)
The relational database (RDB) manages data based on relational models. With the underlying SQLite database, the RDB provides a complete mechanism for managing local databases. To satisfy different needs in complicated scenarios, the RDB offers a series of methods for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements.
......
# @ohos.data.ValuesBucket
# @ohos.data.ValuesBucket (Value Bucket)
The **ValueBucket** module holds data in key-value (KV) pairs. You can use it to insert data into a database.
......@@ -34,6 +34,6 @@ Defines the types of the key and value in a KV pair.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Core
| Key Type | Value Type |
| ------------- | --------------------------------------------- |
| string | [ValueType](#valuetype)\| Uint8Array \| null |
| Key Type | Value Type |
| ------------- | --------------------------------------------- |
| string | [ValueType](#valuetype)\| Uint8Array \| null |
# Distributed KV Store
# @ohos.data.distributedKVStore (Distributed KV Store)
The **distributedKVStore** module implements collaboration between databases for different devices that forms a Super Device. The APIs provided by this module can be used to save data to a distributed key-value (KV) store and perform operations, such as adding, deleting, modifying, querying, and synchronizing data in distributed KV stores.
......@@ -2395,7 +2395,7 @@ Writes data to this single KV store. This API uses an asynchronous callback to r
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------ |
| value | Array&lt;[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)&gt; | Yes | Data to write.|
| value | Array&lt;[ValuesBucket](js-apis-data-valuesBucket.md#valuesbucket)&gt; | Yes | Data to write.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. |
**Error codes**
......@@ -2447,7 +2447,7 @@ Write data to this KV store. This API uses a promise to return the result.
| Name| Type | Mandatory| Description |
| ------ | ------------------------------------------------------------ | ---- | ------------------ |
| value | Array&lt;[ValuesBucket](js-apis-data-ValuesBucket.md#valuesbucket)&gt; | Yes | Data to write. |
| value | Array&lt;[ValuesBucket](js-apis-data-valuesBucket.md#valuesbucket)&gt; | Yes | Data to write. |
**Return value**
......
......@@ -186,7 +186,7 @@ Allows an application to publish sticky common events.
## ohos.permission.SYSTEM_FLOAT_WINDOW
Allows an application to be displayed in a floating window on top of other apps.
Allows an application to be displayed in a floating window on top of other applications.
**Permission level**: system_basic
......@@ -406,7 +406,7 @@ Allows an application to call the API for restoring factory settings.
## ohos.permission.GRANT_SENSITIVE_PERMISSIONS
Allows an application to grant sensitive permissions to other apps.
Allows an application to grant sensitive permissions to other applications.
**Permission level**: system_core
......@@ -416,7 +416,7 @@ Allows an application to grant sensitive permissions to other apps.
## ohos.permission.REVOKE_SENSITIVE_PERMISSIONS
Allows an application to revoke sensitive permissions granted to other apps.
Allows an application to revoke sensitive permissions granted to other applications.
**Permission level**: system_core
......@@ -426,7 +426,7 @@ Allows an application to revoke sensitive permissions granted to other apps.
## ohos.permission.GET_SENSITIVE_PERMISSIONS
Allows an application to obtain the sensitive permissions that have been granted to other apps.
Allows an application to obtain the sensitive permissions that have been granted to other applications.
**Permission level**: system_core
......@@ -436,7 +436,7 @@ Allows an application to obtain the sensitive permissions that have been granted
## ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
Allows an application to set the attributes of apps of other users.
Allows an application to set the attributes of applications of other users.
**Permission level**: system_core
......@@ -506,7 +506,7 @@ Allows an application to install and uninstall other applications.
## ohos.permission.MANAGE_SHORTCUTS
Allows an application to query and start shortcuts of other apps.
Allows an application to query and start shortcuts of other applications.
**Permission level**: system_core
......@@ -546,7 +546,7 @@ Allows an application to start Feature abilities in the background.
## ohos.permission.BUNDLE_ACTIVE_INFO
Allows an application to obtain how long other apps have been running in the foreground or background.
Allows an application to obtain how long other applications have been running in the foreground or background.
**Permission level**: system_basic
......@@ -606,7 +606,7 @@ Allows an application to use agent-powered reminders.
## ohos.permission.CONTROL_TASK_SYNC_ANIMATOR
Allows apps to use sync task animations.
Allows applications to use sync task animations.
**Permission level**: system_core
......@@ -616,7 +616,7 @@ Allows apps to use sync task animations.
## ohos.permission.INPUT_MONITORING
Allows an application to listen for input events. Only the system signature apps can apply for this permission.
Allows an application to listen for input events. Only the system signed applications can apply for this permission.
**Permission level**: system_core
......@@ -1216,7 +1216,7 @@ Allows an application to read the health data of the user.
## ohos.permission.GET_DEFAULT_APPLICATION
Allows an application to query default apps.
Allows an application to query default applications.
**Permission level**: system_core
......@@ -1226,7 +1226,7 @@ Allows an application to query default apps.
## ohos.permission.SET_DEFAULT_APPLICATION
Allows an application to set and reset default apps.
Allows an application to set and reset default applications.
**Permission level**: system_core
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册