am 4e45d392
: Add certificate to keystore for the ADD intent
Merge commit '4e45d392ada4e84fbeed06874caebfd3c7759073' * commit '4e45d392ada4e84fbeed06874caebfd3c7759073': Add certificate to keystore for the ADD intent
This commit is contained in:
committed by
The Android Open Source Project
commit
acedb4b501
@@ -81,9 +81,9 @@ public class SecuritySettings extends PreferenceActivity implements
|
||||
private static final String ASSISTED_GPS = "assisted_gps";
|
||||
|
||||
// Credential storage
|
||||
private static final String ACTION_ADD_CREDENTIAL =
|
||||
public static final String ACTION_ADD_CREDENTIAL =
|
||||
"android.security.ADD_CREDENTIAL";
|
||||
private static final String ACTION_UNLOCK_CREDENTIAL_STORAGE =
|
||||
public static final String ACTION_UNLOCK_CREDENTIAL_STORAGE =
|
||||
"android.security.UNLOCK_CREDENTIAL_STORAGE";
|
||||
private static final String KEY_CSTOR_TYPE_NAME = "typeName";
|
||||
private static final String KEY_CSTOR_ITEM = "item";
|
||||
@@ -526,7 +526,10 @@ public class SecuritySettings extends PreferenceActivity implements
|
||||
}
|
||||
|
||||
private void addCredential() {
|
||||
String message = String.format(getString(R.string.cstor_is_added),
|
||||
String formatString = mCstorAddCredentialHelper.saveToStorage() < 0
|
||||
? getString(R.string.cstor_add_error)
|
||||
: getString(R.string.cstor_is_added);
|
||||
String message = String.format(formatString,
|
||||
mCstorAddCredentialHelper.getName());
|
||||
Toast.makeText(SecuritySettings.this, message, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
@@ -877,14 +880,6 @@ public class SecuritySettings extends PreferenceActivity implements
|
||||
return mTypeName;
|
||||
}
|
||||
|
||||
byte[] getItem(int i) {
|
||||
return mItemList.get(i);
|
||||
}
|
||||
|
||||
String getNamespace(int i) {
|
||||
return mNamespaceList.get(i);
|
||||
}
|
||||
|
||||
CharSequence getDescription() {
|
||||
return Html.fromHtml(mDescription);
|
||||
}
|
||||
@@ -897,6 +892,16 @@ public class SecuritySettings extends PreferenceActivity implements
|
||||
return mName;
|
||||
}
|
||||
|
||||
int saveToStorage() {
|
||||
Keystore ks = Keystore.getInstance();
|
||||
for (int i = 0, count = mItemList.size(); i < count; i++) {
|
||||
byte[] blob = mItemList.get(i);
|
||||
int ret = ks.put(mNamespaceList.get(i), mName, new String(blob));
|
||||
if (ret < 0) return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void parse(Intent intent) {
|
||||
mTypeName = intent.getStringExtra(KEY_CSTOR_TYPE_NAME);
|
||||
mItemList = new ArrayList<byte[]>();
|
||||
|
Reference in New Issue
Block a user