X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/53b67429ea8c97b83602cec3446a10e0b6b7ff5e..bf3cf8cdffa1f9debaaaef1da13c9b8c4b9c1bb0:/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..fad7a6f2 100644 --- a/src/com/owncloud/android/network/CertificateCombinedException.java +++ b/src/com/owncloud/android/network/CertificateCombinedException.java @@ -1,3 +1,21 @@ +/* ownCloud Android client application + * Copyright (C) 2012 Bartek Przybylski + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * 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 +26,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 */ + 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 +65,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 +117,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); } }