فهرست منبع

OC-3212: Show appropiate error messages for SslError in SSL error dialog shown by WebViewClient

masensio 11 سال پیش
والد
کامیت
45bc02fbe5

+ 10 - 0
res/layout/ssl_untrusted_cert_layout.xml

@@ -75,6 +75,16 @@
 		android:textAppearance="?android:attr/textAppearanceSmall"
 		 />
 	
+	<TextView
+		android:id="@+id/reason_no_info_about_error"
+		android:layout_width="wrap_content"
+		android:layout_height="wrap_content"
+		android:layout_gravity="left"
+		android:paddingLeft="20dp"
+		android:text="@string/ssl_validator_no_info_about_error"
+		android:textAppearance="?android:attr/textAppearanceSmall"
+		 />
+	
     <ScrollView 
         android:id="@+id/details_scroll"
         android:visibility="gone" 

+ 1 - 0
res/values/strings.xml

@@ -216,6 +216,7 @@
 	<string name="ssl_validator_label_signature">Signature:</string>
 	<string name="ssl_validator_label_signature_algorithm">Algorithm:</string>
 	<string name="ssl_validator_null_cert">The certificate could not be shown.</string>
+	<string name="ssl_validator_no_info_about_error">- No information about the error</string>
 			
     <string name="placeholder_sentence">This is a placeholder</string>
     <string name="placeholder_filename">placeholder.txt</string>

+ 23 - 8
src/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java

@@ -141,7 +141,7 @@ public class SslUntrustedCertDialog extends SslUntrustedCertDialogABSTRACT {
         // Create a view by inflating desired layout
         mView = inflater.inflate(R.layout.ssl_untrusted_cert_layout, container,  false);
         
-        updateException(mException);
+        updateMessageException(mException, mError);
         
         Button ok = (Button) mView.findViewById(R.id.ok);
         ok.setOnClickListener(new OnClickListener() {
@@ -224,35 +224,50 @@ public class SslUntrustedCertDialog extends SslUntrustedCertDialogABSTRACT {
     }
     
     
-    private void updateException(CertificateCombinedException exception) {
+    private void updateMessageException(CertificateCombinedException exception, SslError error) {
         
         /// clean
         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.reason_no_info_about_error).setVisibility(View.GONE);
         mView.findViewById(R.id.details_scroll).setVisibility(View.GONE);
         
-        
-        if (mException != null) {
+       
+        if (exception != null) {
             
             /// refresh
-            if (mException.getCertPathValidatorException() != null) {
+            if (exception.getCertPathValidatorException() != null) {
                 ((TextView)mView.findViewById(R.id.reason_cert_not_trusted)).setVisibility(View.VISIBLE);
             }
             
-            if (mException.getCertificateExpiredException() != null) {
+            if (exception.getCertificateExpiredException() != null) {
                 ((TextView)mView.findViewById(R.id.reason_cert_expired)).setVisibility(View.VISIBLE);
             }
             
-            if (mException.getCertificateNotYetValidException() != null) {
+            if (exception.getCertificateNotYetValidException() != null) {
                 ((TextView)mView.findViewById(R.id.reason_cert_not_yet_valid)).setVisibility(View.VISIBLE);
             } 
 
-            if (mException.getSslPeerUnverifiedException() != null ) {
+            if (exception.getSslPeerUnverifiedException() != null) {
                 ((TextView)mView.findViewById(R.id.reason_hostname_not_verified)).setVisibility(View.VISIBLE);
             }
             
+        } else if ( error != null) {
+            /// refresh
+            if (error.getPrimaryError() == SslError.SSL_UNTRUSTED) {
+                ((TextView)mView.findViewById(R.id.reason_cert_not_trusted)).setVisibility(View.VISIBLE);
+                
+            } else if (error.getPrimaryError() == SslError.SSL_EXPIRED) {
+                ((TextView)mView.findViewById(R.id.reason_cert_expired)).setVisibility(View.VISIBLE);
+                
+            } else if (error.getPrimaryError() == SslError.SSL_NOTYETVALID) {
+                ((TextView)mView.findViewById(R.id.reason_cert_not_yet_valid)).setVisibility(View.VISIBLE);
+                
+            } else if (error.getPrimaryError() == SslError.SSL_IDMISMATCH) {
+                ((TextView)mView.findViewById(R.id.reason_hostname_not_verified)).setVisibility(View.VISIBLE);
+            }
         }
         
     }

+ 13 - 0
src/com/owncloud/android/ui/dialog/SslUntrustedCertDialogForEmptySslError.java

@@ -114,6 +114,8 @@ public class SslUntrustedCertDialogForEmptySslError extends SslUntrustedCertDial
             ((ViewGroup)mView.getParent()).removeView(mView);
         }
         
+        showNoMessageError();
+        
         Button ok = (Button) mView.findViewById(R.id.ok);
         ok.setOnClickListener(new OnClickListener() {
             
@@ -247,4 +249,15 @@ public class SslUntrustedCertDialogForEmptySslError extends SslUntrustedCertDial
         ((TextView)mView.findViewById(R.id.value_signature)).setVisibility(View.GONE);
     }
 
+    private void showNoMessageError() {
+        /// clean
+        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);
+        
+        mView.findViewById(R.id.reason_no_info_about_error).setVisibility(View.VISIBLE);
+        
+    }
 }