Merge remote-tracking branch 'remotes/upstream/master' into beta
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / adapter / CertificateCombinedExceptionViewAdapter.java
1 /**
2 * ownCloud Android client application
3 *
4 * @author masensio
5 * @author David A. Velasco
6 * Copyright (C) 2015 ownCloud Inc.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2,
10 * as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21 package com.owncloud.android.ui.adapter;
22
23 import com.owncloud.android.R;
24 import com.owncloud.android.lib.common.network.CertificateCombinedException;
25 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
26
27 import android.view.View;
28 import android.widget.TextView;
29
30 /**
31 * TODO
32 *
33 */
34 public class CertificateCombinedExceptionViewAdapter implements SslUntrustedCertDialog.ErrorViewAdapter {
35
36 //private final static String TAG = CertificateCombinedExceptionViewAdapter.class.getSimpleName();
37
38 private CertificateCombinedException mSslException = null;
39
40 public CertificateCombinedExceptionViewAdapter(CertificateCombinedException sslException) {
41 mSslException = sslException;
42 }
43
44 @Override
45 public void updateErrorView(View dialogView) {
46 /// clean
47 dialogView.findViewById(R.id.reason_no_info_about_error).setVisibility(View.GONE);
48
49 /// refresh
50 if (mSslException.getCertPathValidatorException() != null) {
51 ((TextView)dialogView.findViewById(R.id.reason_cert_not_trusted)).setVisibility(View.VISIBLE);
52 } else {
53 dialogView.findViewById(R.id.reason_cert_not_trusted).setVisibility(View.GONE);
54 }
55
56 if (mSslException.getCertificateExpiredException() != null) {
57 ((TextView)dialogView.findViewById(R.id.reason_cert_expired)).setVisibility(View.VISIBLE);
58 } else {
59 dialogView.findViewById(R.id.reason_cert_expired).setVisibility(View.GONE);
60 }
61
62 if (mSslException.getCertificateNotYetValidException() != null) {
63 ((TextView)dialogView.findViewById(R.id.reason_cert_not_yet_valid)).setVisibility(View.VISIBLE);
64 } else {
65 dialogView.findViewById(R.id.reason_cert_not_yet_valid).setVisibility(View.GONE);
66 }
67
68 if (mSslException.getSslPeerUnverifiedException() != null) {
69 ((TextView)dialogView.findViewById(R.id.reason_hostname_not_verified)).setVisibility(View.VISIBLE);
70 } else {
71 dialogView.findViewById(R.id.reason_hostname_not_verified).setVisibility(View.GONE);
72 }
73
74 }
75 }