mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
SSL warning with more information about certificate, accessible through a new 'Details' button
This commit is contained in:
parent
47acd9b4c3
commit
cc1eb7a352
3 changed files with 516 additions and 21 deletions
|
@ -71,17 +71,328 @@
|
|||
android:text="@string/ssl_validator_reason_hostname_not_verified"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subject"
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/details_scroll"
|
||||
android:visibility="gone"
|
||||
android:padding="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:text="@string/text_placeholder"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
android:layout_height="180dp">
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/details_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_subject"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="@string/ssl_validator_label_subject"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_subject_CN"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_CN"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_subject_CN"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_subject_O"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_O"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_subject_O"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_subject_OU"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_OU"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_subject_OU"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_subject_ST"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_ST"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_subject_ST"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_subject_C"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_C"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_subject_C"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_subject_L"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_L"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_subject_L"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_issuer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="@string/ssl_validator_label_issuer"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_issuer_CN"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_CN"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_issuer_CN"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_issuer_O"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_O"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_issuer_O"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_issuer_OU"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_OU"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_issuer_OU"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_issuer_ST"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_ST"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_issuer_ST"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_issuer_C"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_C"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_issuer_C"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_issuer_L"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_L"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_issuer_L"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_validity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="@string/ssl_validator_label_validity"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_validity_from"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_validity_from"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_validity_from"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_validity_to"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_validity_to"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_validity_to"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_signature"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text="@string/ssl_validator_label_signature"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label_signature_algorithm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssl_validator_label_signature_algorithm"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_signature_algorithm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value_signature"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/question"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -104,6 +415,13 @@
|
|||
android:layout_weight="1"
|
||||
android:text="@string/common_cancel" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/details_btn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/ssl_validator_btn_details_see" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/ok"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -196,7 +196,22 @@
|
|||
<string name="ssl_validator_certificate_not_available">The server certificate could not be obtained</string>
|
||||
<string name="ssl_validator_question">Do you want to trust this certificate anyway?</string>
|
||||
<string name="ssl_validator_not_saved">The certificate could not be saved</string>
|
||||
|
||||
<string name="ssl_validator_btn_details_see">View details</string>
|
||||
<string name="ssl_validator_btn_details_hide">Hide details</string>
|
||||
<string name="ssl_validator_label_subject">Issued to:</string>
|
||||
<string name="ssl_validator_label_issuer">Issued by:</string>
|
||||
<string name="ssl_validator_label_CN">Common name:</string>
|
||||
<string name="ssl_validator_label_O">Organization:</string>
|
||||
<string name="ssl_validator_label_OU">Organizational unit:</string>
|
||||
<string name="ssl_validator_label_C">Country:</string>
|
||||
<string name="ssl_validator_label_ST">State:</string>
|
||||
<string name="ssl_validator_label_L">Location:</string>
|
||||
<string name="ssl_validator_label_validity">Validity:</string>
|
||||
<string name="ssl_validator_label_validity_from">From:</string>
|
||||
<string name="ssl_validator_label_validity_to">To:</string>
|
||||
<string name="ssl_validator_label_signature">Signature:</string>
|
||||
<string name="ssl_validator_label_signature_algorithm">Algorithm:</string>
|
||||
|
||||
<string name="text_placeholder">This is a placeholder</string>
|
||||
|
||||
<string name="instant_upload_on_wifi">Upload pictures via WiFi only</string>
|
||||
|
|
|
@ -22,6 +22,11 @@ import java.security.KeyStoreException;
|
|||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
|
@ -29,6 +34,7 @@ import android.os.Bundle;
|
|||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
|
@ -121,6 +127,22 @@ public class SslValidatorDialog extends Dialog {
|
|||
cancel();
|
||||
}
|
||||
});
|
||||
|
||||
mView.findViewById(R.id.details_btn).setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
View detailsScroll = findViewById(R.id.details_scroll);
|
||||
if (detailsScroll.getVisibility() == View.VISIBLE) {
|
||||
detailsScroll.setVisibility(View.GONE);
|
||||
((Button)v).setText(R.string.ssl_validator_btn_details_see);
|
||||
|
||||
} else {
|
||||
detailsScroll.setVisibility(View.VISIBLE);
|
||||
((Button)v).setText(R.string.ssl_validator_btn_details_hide);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,11 +151,11 @@ public class SslValidatorDialog extends Dialog {
|
|||
mException = (CertificateCombinedException) result.getException();
|
||||
|
||||
/// clean
|
||||
((TextView)mView.findViewById(R.id.reason_cert_not_trusted)).setVisibility(View.GONE);
|
||||
((TextView)mView.findViewById(R.id.reason_cert_expired)).setVisibility(View.GONE);
|
||||
((TextView)mView.findViewById(R.id.reason_cert_not_yet_valid)).setVisibility(View.GONE);
|
||||
((TextView)mView.findViewById(R.id.reason_hostname_not_verified)).setVisibility(View.GONE);
|
||||
((TextView)mView.findViewById(R.id.subject)).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.reason_cert_expired).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.reason_hostname_not_verified).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.details_scroll).setVisibility(View.GONE);
|
||||
|
||||
/// refresh
|
||||
if (mException.getCertPathValidatorException() != null) {
|
||||
|
@ -159,20 +181,160 @@ public class SslValidatorDialog extends Dialog {
|
|||
}
|
||||
|
||||
private void showCertificateData(X509Certificate cert) {
|
||||
TextView subject = (TextView)mView.findViewById(R.id.subject);
|
||||
|
||||
if (cert != null) {
|
||||
String text = cert.getSubjectDN().getName();
|
||||
text = text.substring(text.indexOf(",") + 1);
|
||||
subject.setVisibility(View.VISIBLE);
|
||||
subject.setText(text);
|
||||
showSubject(cert.getSubjectX500Principal());
|
||||
showIssuer(cert.getIssuerX500Principal());
|
||||
showValidity(cert.getNotBefore(), cert.getNotAfter());
|
||||
showSignature(cert);
|
||||
|
||||
} else {
|
||||
// this should not happen
|
||||
subject.setText(R.string.ssl_validator_certificate_not_available);
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
private void showSignature(X509Certificate cert) {
|
||||
TextView sigView = ((TextView)mView.findViewById(R.id.value_signature));
|
||||
TextView algorithmView = ((TextView)mView.findViewById(R.id.value_signature_algorithm));
|
||||
sigView.setText(getHex(cert.getSignature()));
|
||||
algorithmView.setText(cert.getSigAlgName());
|
||||
}
|
||||
|
||||
public String getHex(final byte [] raw) {
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
final StringBuilder hex = new StringBuilder(2 * raw.length);
|
||||
for (final byte b : raw) {
|
||||
final int hiVal = (b & 0xF0) >> 4;
|
||||
final int loVal = b & 0x0F;
|
||||
hex.append((char) ('0' + (hiVal + (hiVal / 10 * 7))));
|
||||
hex.append((char) ('0' + (loVal + (loVal / 10 * 7))));
|
||||
}
|
||||
return hex.toString();
|
||||
}
|
||||
|
||||
private void showValidity(Date notBefore, Date notAfter) {
|
||||
TextView fromView = ((TextView)mView.findViewById(R.id.value_validity_from));
|
||||
TextView toView = ((TextView)mView.findViewById(R.id.value_validity_to));
|
||||
fromView.setText(notBefore.toLocaleString());
|
||||
toView.setText(notAfter.toLocaleString());
|
||||
}
|
||||
|
||||
private void showSubject(X500Principal subject) {
|
||||
Map<String, String> s = parsePrincipal(subject);
|
||||
TextView cnView = ((TextView)mView.findViewById(R.id.value_subject_CN));
|
||||
TextView oView = ((TextView)mView.findViewById(R.id.value_subject_O));
|
||||
TextView ouView = ((TextView)mView.findViewById(R.id.value_subject_OU));
|
||||
TextView cView = ((TextView)mView.findViewById(R.id.value_subject_C));
|
||||
TextView stView = ((TextView)mView.findViewById(R.id.value_subject_ST));
|
||||
TextView lView = ((TextView)mView.findViewById(R.id.value_subject_L));
|
||||
|
||||
if (s.get("CN") != null) {
|
||||
cnView.setText(s.get("CN"));
|
||||
cnView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
cnView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("O") != null) {
|
||||
oView.setText(s.get("O"));
|
||||
oView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
oView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("OU") != null) {
|
||||
ouView.setText(s.get("OU"));
|
||||
ouView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
ouView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("C") != null) {
|
||||
cView.setText(s.get("C"));
|
||||
cView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
cView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("ST") != null) {
|
||||
stView.setText(s.get("ST"));
|
||||
stView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
stView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("L") != null) {
|
||||
lView.setText(s.get("L"));
|
||||
lView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
lView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void showIssuer(X500Principal issuer) {
|
||||
Map<String, String> s = parsePrincipal(issuer);
|
||||
TextView cnView = ((TextView)mView.findViewById(R.id.value_issuer_CN));
|
||||
TextView oView = ((TextView)mView.findViewById(R.id.value_issuer_O));
|
||||
TextView ouView = ((TextView)mView.findViewById(R.id.value_issuer_OU));
|
||||
TextView cView = ((TextView)mView.findViewById(R.id.value_issuer_C));
|
||||
TextView stView = ((TextView)mView.findViewById(R.id.value_issuer_ST));
|
||||
TextView lView = ((TextView)mView.findViewById(R.id.value_issuer_L));
|
||||
|
||||
if (s.get("CN") != null) {
|
||||
cnView.setText(s.get("CN"));
|
||||
cnView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
cnView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("O") != null) {
|
||||
oView.setText(s.get("O"));
|
||||
oView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
oView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("OU") != null) {
|
||||
ouView.setText(s.get("OU"));
|
||||
ouView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
ouView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("C") != null) {
|
||||
cView.setText(s.get("C"));
|
||||
cView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
cView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("ST") != null) {
|
||||
stView.setText(s.get("ST"));
|
||||
stView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
stView.setVisibility(View.GONE);
|
||||
}
|
||||
if (s.get("L") != null) {
|
||||
lView.setText(s.get("L"));
|
||||
lView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
lView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> parsePrincipal(X500Principal principal) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
String toParse = principal.getName();
|
||||
String[] pieces = toParse.split(",");
|
||||
String[] tokens = {"CN", "O", "OU", "C", "ST", "L"};
|
||||
for (int i=0; i < pieces.length ; i++) {
|
||||
for (int j=0; j<tokens.length; j++) {
|
||||
if (pieces[i].startsWith(tokens[j] + "=")) {
|
||||
result.put(tokens[j], pieces[i].substring(tokens[j].length()+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void saveServerCert() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
|
||||
if (mException.getServerCertificate() != null) {
|
||||
// TODO make this asynchronously, it can take some time
|
||||
OwnCloudClientUtils.addCertToKnownServersStore(mException.getServerCertificate(), getContext());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue