X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/261aaf50019732a4e766d6b3e9e07576a64f5504..0dbb1876fafaa8a1ed8d17d85aec4b29c46d7aab:/src/com/owncloud/android/network/CertificateCombinedException.java diff --git a/src/com/owncloud/android/network/CertificateCombinedException.java b/src/com/owncloud/android/network/CertificateCombinedException.java index 644c7359..e96d9dc6 100644 --- a/src/com/owncloud/android/network/CertificateCombinedException.java +++ b/src/com/owncloud/android/network/CertificateCombinedException.java @@ -1,3 +1,20 @@ +/* ownCloud Android client application + * Copyright (C) 2012-2013 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.network; import java.security.cert.CertPathValidatorException; @@ -8,9 +25,31 @@ import java.security.cert.X509Certificate; import javax.net.ssl.SSLPeerUnverifiedException; -public class CertificateCombinedException extends CertificateException { - +/** + * Exception joining all the problems that {@link AdvancedX509TrustManager} can find in + * a certificate chain for a server. + * + * This was initially created as an extension of CertificateException, but some + * implementations of the SSL socket layer in existing devices are REPLACING the CertificateException + * instances thrown by {@link javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[], String)} + * with SSLPeerUnverifiedException FORGETTING THE CAUSING EXCEPTION instead of wrapping it. + * + * Due to this, extending RuntimeException is necessary to get that the CertificateCombinedException + * instance reaches {@link AdvancedSslSocketFactory#verifyPeerIdentity}. + * + * BE CAREFUL. As a RuntimeException extensions, Java compilers do not require to handle it + * in client methods. Be sure to use it only when you know exactly where it will go. + * + * @author David A. Velasco + */ +public class CertificateCombinedException extends RuntimeException { + + /** Generated - to refresh every time the class changes */ + private static final long serialVersionUID = -8875782030758554999L; + private X509Certificate mServerCert = null; + private String mHostInUrl; + private CertificateExpiredException mCertificateExpiredException = null; private CertificateNotYetValidException mCertificateNotYetValidException = null; private CertPathValidatorException mCertPathValidatorException = null; @@ -25,6 +64,14 @@ public class CertificateCombinedException extends CertificateException { return mServerCert; } + public String getHostInUrl() { + return mHostInUrl; + } + + public void setHostInUrl(String host) { + mHostInUrl = host; + } + public CertificateExpiredException getCertificateExpiredException() { return mCertificateExpiredException; } @@ -69,13 +116,15 @@ public class CertificateCombinedException extends CertificateException { return (mCertificateExpiredException != null || mCertificateNotYetValidException != null || mCertPathValidatorException != null || - mOtherCertificateException != null); + mOtherCertificateException != null || + mSslPeerUnverifiedException != null); } public boolean isRecoverable() { return (mCertificateExpiredException != null || mCertificateNotYetValidException != null || - mCertPathValidatorException != null); + mCertPathValidatorException != null || + mSslPeerUnverifiedException != null); } }