How to securely share data between two or more applications in android?

徘徊边缘 提交于 2019-12-05 22:58:31

问题


I am making an application framework for the enterprise environment which involves data sharing between two or more applications from the device memory. This data needs to be stored on the device and accessible to only a few applications (which can be identified by the certificates used to install them). Also, it needs to be stored in a secure way so as to be not accessible to other third party applications . Which is the best way to implement this functionality ?

I have read up about ContentProviders and ContentResolvers which to my understanding only facilitate this process . The actual storage of data is what is more important .I have also looked into the Keychain API of Android which seems to be the closest to what I need to achieve.

Is there a way to integrate ContentProviders and ContentResolvers with Keychain APIs ? Is this the correct way to do so ? If not , what is the best way to achieve the same? Also, I haven't been able to find good code samples to completely understand the functioning of the Keychain API. Please Help!

Edit :
I've also looked at the Keystore API. This internally uses the Keychain API and for sharing data between applications, Keychain should be used. Though I haven't been able to find code samples for the same or a detailed documentation or API guide on how to use the Keychain API. I am looking for an android equivalent of the iOS Keychain.

Something known as managed profiles has also been introduced in Android 5 . Is this the correct way to acheive what I am trying to do ?


回答1:


You have to declare your applications with the same sharedUserId, like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mydomains.myapp"
    android:sharedUserId="com.mydomains.shared.user.id"
    android:sharedUserLabel="@string/appName">

In this case all data stored in private storage of both apps will be available to each other (supposed they have signed with the same signature)

As read manual:

sharedUserId: The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process.



来源:https://stackoverflow.com/questions/36302597/how-to-securely-share-data-between-two-or-more-applications-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!