黑莓:如何使用 PersistableRIMKeyStore?

发布于 2024-09-16 03:18:09 字数 709 浏览 3 评论 0原文

我需要安全地存储私人用户数据,以便它可以在我的应用程序启动以及设备重置时持续存在。

我猜这将是一个最多 1000 个字符的字符串。

有人告诉我可以使用 RIM KeyStore API 来实现此目的。

好吧,我花了几个小时在谷歌上搜索有关 RIM KeyStore API 使用的任何提示。 JDE 示例不包含任何对此有用的内容。

看起来这在 BB 开发中很少见,所以几乎没有这方面的官方信息。

我读了 这个这个。从这些我了解到,对我来说最好的选择是使用 PersistableRIMKeyStore (它在设备重置后仍然存在)。但是我无法弄清楚具体的实施应该是什么。

任何人都可以帮助提供示例代码或为我提供一些指南吗?另外,也许我的任务有更好/更简单的方法/方法,所以请让我知道。

非常感谢!

I need to securely store private user data so it can persist across my app starts as well as device resets.

This will be a String I guess about 1000 chars at maximum.

I was told I can use RIM KeyStore API for this.

Well, I spent hours googling out any gide on RIM KeyStore API usage. JDE samples do not contain anything useful on this.

Looks like this is a rare thing in BB development, so there's almost no official info on this.

I read this and this. From those I understood the best choice for me is to use PersistableRIMKeyStore (it persists across device resets). However I am not able to figure out what exactly should the implementation be.

Can anyone help with sample code or point me to some guide? Also maybe there's a better/simpler way/approach for my task, so, please, let me know about it.

Thanks a lot in advance!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一紙繁鸢 2024-09-23 03:18:09

如果您使用的商店与“PersistentStoreDemo”相同,如果您不知道,可以通过转到“文件”->“PersistentStoreDemo”来获取该商店。导入-> Blackberry Samples,您可以对商店中的信息进行加密。除此之外,如果用户启用了内容保护,您可以使用 ContentProtectedHashtable 自动知道该信息将被加密。因此,如果没有内容保护,信息将被加密一次,启用后,它将被双重加密,并以难以猜测的应用程序名称空间的长哈希值存储(显然,因为要注册您需要它的商店)。下面是我使用的:

package ca.dftr.phillyd.lib.persistables;

import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.util.ContentProtectedHashtable;
import net.rim.device.api.util.Persistable;

/**
 * Basic class for storing application specific information. 
 * Information such as application settings or whether the license agreement was accepted.
 * For more complex and specific classes they should be implemented separately and implement persistable 
 * @author deforbes
 */
public class AppInfo extends ContentProtectedHashtable  implements Persistable {

    private String _appName = null;
    private String _version = null;

    /**
     * Constructs the application info, creates and persists a hashtable for application settings.
     * @param uniqueHexAppIdentifier Can be automatically created in resource class (BUNDLE_ID) or generated using other unique information.
     */
    public AppInfo() {    
        ApplicationDescriptor appDesc = ApplicationDescriptor.currentApplicationDescriptor();
        _appName = appDesc.getName();
        _version = appDesc.getVersion();
    }

    /**
     * Get the Name of the application
     * @return The application name from the app descriptor
     */
    public String getName()
    {
        return _appName;
    }

    /**
     * Get the Version of the application
     * @return The application version from the app descriptor
     */
    public String getVersion()
    {
        return _version;
    }
}

以及一类常量(如果需要,可以将其包含在上面)。例如,从我的 PhillyD 应用程序:

package ca.dftr.phillyd.lib.persistables;

/**
 * Keys for the AppInfo array
 * @author deforbes
 */
public class AppInfoKeys {
    public static final String QUALITY = "Quality";
    public static final String CHANNEL = "Channel";
    public static final String CHANNEL_NAME = "Channel_Name";
    public static final String SEARCH = "Search";
    public static final String LICENSE_ACCEPTED = "isLicenseAccepted";
    public static final String VIDEOS_PER_PAGE = "NumPerPage";
    public static final Boolean DOWNLOAD_THUMBS = new Boolean(true);
}

If you use the store in the same was as the "PersistentStoreDemo" which if you don't know you can get by going to File -> Import -> Blackberry Samples, you can encrypt the info in the store. On top of this, if the user has content protection on, you can use a ContentProtectedHashtable to automatically know that that information would be encrypted. So, without content protection, the info would be encrypted once, with it on, it would be doubly encrypted as well as stored with a hard to guess long hash of the app namespace (obviously, since to register the store you need it). Below is what I use:

package ca.dftr.phillyd.lib.persistables;

import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.util.ContentProtectedHashtable;
import net.rim.device.api.util.Persistable;

/**
 * Basic class for storing application specific information. 
 * Information such as application settings or whether the license agreement was accepted.
 * For more complex and specific classes they should be implemented separately and implement persistable 
 * @author deforbes
 */
public class AppInfo extends ContentProtectedHashtable  implements Persistable {

    private String _appName = null;
    private String _version = null;

    /**
     * Constructs the application info, creates and persists a hashtable for application settings.
     * @param uniqueHexAppIdentifier Can be automatically created in resource class (BUNDLE_ID) or generated using other unique information.
     */
    public AppInfo() {    
        ApplicationDescriptor appDesc = ApplicationDescriptor.currentApplicationDescriptor();
        _appName = appDesc.getName();
        _version = appDesc.getVersion();
    }

    /**
     * Get the Name of the application
     * @return The application name from the app descriptor
     */
    public String getName()
    {
        return _appName;
    }

    /**
     * Get the Version of the application
     * @return The application version from the app descriptor
     */
    public String getVersion()
    {
        return _version;
    }
}

Along with a class of constants (which could be included in the above if you want). For example, From my PhillyD app:

package ca.dftr.phillyd.lib.persistables;

/**
 * Keys for the AppInfo array
 * @author deforbes
 */
public class AppInfoKeys {
    public static final String QUALITY = "Quality";
    public static final String CHANNEL = "Channel";
    public static final String CHANNEL_NAME = "Channel_Name";
    public static final String SEARCH = "Search";
    public static final String LICENSE_ACCEPTED = "isLicenseAccepted";
    public static final String VIDEOS_PER_PAGE = "NumPerPage";
    public static final Boolean DOWNLOAD_THUMBS = new Boolean(true);
}
七七 2024-09-23 03:18:09

PersistableRIMKeyStore 用于持久保存 RIM 密钥存储。要在重置期间保留用户数据,您只需要使用 PersistentStore,如果您希望保护数据,您可以使用 ContentProtectedHashtable 或 ContentProtectedVector。

The PersistableRIMKeyStore is used to persist the RIM Key Store. To persist user data accross resets you only need to use the PersistentStore, if you want the deta to be protected you could use the ContentProtectedHashtable or ContentProtectedVector.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文