CertificateCombinedExceptionViewAdapter.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. import android.view.View;
  23. import com.owncloud.android.databinding.SslUntrustedCertLayoutBinding;
  24. import com.owncloud.android.lib.common.network.CertificateCombinedException;
  25. import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
  26. /**
  27. * TODO
  28. */
  29. public class CertificateCombinedExceptionViewAdapter implements SslUntrustedCertDialog.ErrorViewAdapter {
  30. //private final static String TAG = CertificateCombinedExceptionViewAdapter.class.getSimpleName();
  31. private CertificateCombinedException mSslException;
  32. public CertificateCombinedExceptionViewAdapter(CertificateCombinedException sslException) {
  33. mSslException = sslException;
  34. }
  35. @Override
  36. public void updateErrorView(SslUntrustedCertLayoutBinding binding) {
  37. /// clean
  38. binding.reasonNoInfoAboutError.setVisibility(View.GONE);
  39. /// refresh
  40. if (mSslException.getCertPathValidatorException() != null) {
  41. binding.reasonCertNotTrusted.setVisibility(View.VISIBLE);
  42. } else {
  43. binding.reasonCertNotTrusted.setVisibility(View.GONE);
  44. }
  45. if (mSslException.getCertificateExpiredException() != null) {
  46. binding.reasonCertExpired.setVisibility(View.VISIBLE);
  47. } else {
  48. binding.reasonCertExpired.setVisibility(View.GONE);
  49. }
  50. if (mSslException.getCertificateNotYetValidException() != null) {
  51. binding.reasonCertNotYetValid.setVisibility(View.VISIBLE);
  52. } else {
  53. binding.reasonCertNotYetValid.setVisibility(View.GONE);
  54. }
  55. if (mSslException.getSslPeerUnverifiedException() != null) {
  56. binding.reasonHostnameNotVerified.setVisibility(View.VISIBLE);
  57. } else {
  58. binding.reasonHostnameNotVerified.setVisibility(View.GONE);
  59. }
  60. }
  61. }