OC-3212: Show appropiate error messages for SslError in SSL error dialog shown by...
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / dialog / SslUntrustedCertDialogABSTRACT.java
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.dialog;
18
19 import android.net.http.SslError;
20 import android.webkit.SslErrorHandler;
21
22 import com.actionbarsherlock.app.SherlockDialogFragment;
23
24 /**
25 * Dialog to show information about an untrusted certificate and allow the user
26 * to decide trust on it or not.
27 *
28 * Abstract implementation of common functionality for different dialogs that
29 * get the information about the error and the certificate from different classes.
30 *
31 * @author masensio
32 * @author David A. Velasco
33 */
34 public abstract class SslUntrustedCertDialogABSTRACT extends SherlockDialogFragment {
35
36 //private final static String TAG = SslUntrustedCertDialogABSTRACT.class.getSimpleName();
37
38 public static SslUntrustedCertDialogABSTRACT newInstanceForEmptySslError(SslError error, SslErrorHandler handler) {
39 if (error == null) {
40 throw new IllegalArgumentException("Trying to create instance with a parameter error == null");
41 }
42 return SslUntrustedCertDialogForEmptySslError.newInstance(error, handler);
43 }
44
45 // TODO - complete when merged
46 /*
47 public static SslUntrustedCertDialogABSTRACT newInstanceForFullSslError(X509Certificate cert, SslError error, OnSslUntrustedCertListener listener, SslErrorHandler handler) {
48 if (cert == null) {
49 throw new IllegalArgumentException("Trying to create instance with a parameter error == null");
50 }
51 if (error == null) {
52 throw new IllegalArgumentException("Trying to create instance with a parameter error == null");
53 }
54 return new SslUntrustedCertDialog(cert, listener, handler);
55 }
56 */
57
58
59 public interface OnSslUntrustedCertListener {
60 public void onSavedCertificate();
61 public void onFailedSavingCertificate();
62 }
63
64 }