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