CertificateCombinedExceptionViewAdapter.java 2.8 KB

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