am 6b1b36a8
: Merge change 7687 into donut
Merge commit '6b1b36a832943126d19a21dcadda11cc75c3a9b6' * commit '6b1b36a832943126d19a21dcadda11cc75c3a9b6': Add UI to handle PKCS12 cert.
This commit is contained in:
committed by
Android Git Automerger
commit
2fab4ab09c
@@ -46,6 +46,22 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="True"/>
|
||||
|
||||
<LinearLayout android:id="@+id/cstor_credential_password_container"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="0dip">
|
||||
<TextView android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cstor_credential_password" />
|
||||
<EditText android:id="@+id/cstor_credential_password"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:password="True"
|
||||
android:singleLine="True"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/cstor_credential_info_title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@@ -1976,6 +1976,8 @@ found in the list of installed applications.</string>
|
||||
<!-- Description for the credential name input box -->
|
||||
<string name="cstor_credential_name">Certificate name:</string>
|
||||
<!-- Title of the credential info -->
|
||||
<!-- Description for the credential password input box -->
|
||||
<string name="cstor_credential_password">Password to extract the certificate:</string>
|
||||
<string name="cstor_credential_info">Certificate details:</string>
|
||||
<string name="cstor_name_credential_hint">The name can contain only letters and numbers.</string>
|
||||
|
||||
|
@@ -37,6 +37,7 @@ import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
import android.security.CertTool;
|
||||
import android.security.Keystore;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
@@ -630,6 +631,17 @@ public class SecuritySettings extends PreferenceActivity implements
|
||||
}
|
||||
|
||||
mCstorAddCredentialHelper.setName(name);
|
||||
|
||||
if (mCstorAddCredentialHelper.isPkcs12Keystore()) {
|
||||
String password = getText(R.id.cstor_credential_password);
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
showError(R.string.cstor_password_empty_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
mCstorAddCredentialHelper.setPassword(password);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -881,6 +893,9 @@ public class SecuritySettings extends PreferenceActivity implements
|
||||
mView = View.inflate(SecuritySettings.this,
|
||||
R.layout.cstor_name_credential_dialog_view, null);
|
||||
hideError();
|
||||
if (!mCstorAddCredentialHelper.isPkcs12Keystore()) {
|
||||
hide(R.id.cstor_credential_password_container);
|
||||
}
|
||||
|
||||
setText(R.id.cstor_credential_name_title,
|
||||
R.string.cstor_credential_name);
|
||||
@@ -907,6 +922,7 @@ public class SecuritySettings extends PreferenceActivity implements
|
||||
private List<String> mNamespaceList;
|
||||
private String mDescription;
|
||||
private String mName;
|
||||
private String mPassword;
|
||||
|
||||
CstorAddCredentialHelper(Intent intent) {
|
||||
parse(intent);
|
||||
@@ -916,6 +932,10 @@ public class SecuritySettings extends PreferenceActivity implements
|
||||
return mTypeName;
|
||||
}
|
||||
|
||||
boolean isPkcs12Keystore() {
|
||||
return CertTool.TITLE_PKCS12_KEYSTORE.equals(mTypeName);
|
||||
}
|
||||
|
||||
CharSequence getDescription() {
|
||||
return Html.fromHtml(mDescription);
|
||||
}
|
||||
@@ -928,12 +948,26 @@ public class SecuritySettings extends PreferenceActivity implements
|
||||
return mName;
|
||||
}
|
||||
|
||||
void setPassword(String password) {
|
||||
mPassword = password;
|
||||
}
|
||||
|
||||
String getPassword() {
|
||||
return mPassword;
|
||||
}
|
||||
|
||||
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;
|
||||
if (isPkcs12Keystore()) {
|
||||
return CertTool.getInstance().addPkcs12Keystore(
|
||||
mItemList.get(0), mPassword, mName);
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user