加密为数据提供了非常安全的表示方式,而模糊处理是一种简化的安全保护方式,以防止随意查看数据库内容。缺省情况下,UltraLite Java 版数据库中存储的数据是未加密的。
必须提供自己的加密控制以对 UltraLite Java 版数据库中的数据进行加密。可使用 ConfigPersistent.setEncryption 方法设置加密控制,该方法采用 EncryptionControl object 对象对页进行加密和解密。
不可对非永久性数据库存储区进行加密。
使用 EncryptionControl 接口在 BlackBerry 应用程序中创建和自定义 UltraLite Java 版数据库加密或模糊处理 API 技术。
前提条件
实现 UltraLiteJ API 的 BlackBerry 智能手机的现有 Java 应用程序。
上下文和注释
多个。
创建一个实现 EncryptionControl 接口的类。
以下示例创建一个实现加密接口的新类 Encryptor:
static class Encryptor implements EncryptionControl { |
在新类中实现 initialize、encrypt 和 decrypt 方法。
该类应与以下所示代码类似:
static class Encryptor implements EncryptionControl { /** Decrypt a page stored in the database. * @param page_no the number of the page being decrypted * @param src the encrypted source page which was read from the database * @param tgt the decrypted page (filled in by method) */ public void decrypt( int page_no, byte[] src, byte[] tgt ) throws ULjException { // Your decryption method goes here. } /** Encrypt a page stored in the database. * @param page_no the number of the page being encrypted * @param src the unencrypted source * @param tgt the encrypted target page which will be written to the database (filled in by method) */ public void encrypt( int page_no, byte[] src, byte[] tgt ) throws ULjException { // Your encryption method goes here. } /** Initialize the encryption control with a password. * @param password the password */ public void initialize(String password) throws ULjException { // Your initialization method goes here. } } |
更新 API 代码,以便在连接到数据库之前指定新的加密控制类。
使用 Configuration.setEncryption 方法指定加密控制。以下示例假定您已拥有一个引用数据库的 Configuration 对象 config,并演示了如何设置加密控制:
config.setEncryption(new Encryptor()); |
BlackBerry 设备上的 UltraLiteJ 安全性 白皮书详述了 BlackBerry 设备上 UltraLiteJ 应用程序的安全性选项和相关事宜,包括设备的内置安全性对应用程序的影响。有关详细信息,请参见 UltraLiteJ Security on BlackBerry Devices(BlackBerry 设备上的 UltraLiteJ 安全性)。
![]() |
使用DocCommentXchange讨论此页。
|
版权 © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1 |