Alexandre Savard | f7f9e0b | 2012-10-15 17:24:07 -0400 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. |
| 3 | * |
| 4 | * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation, either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * If you own a pjsip commercial license you can also redistribute it |
| 11 | * and/or modify it under the terms of the GNU Lesser General Public License |
| 12 | * as an android library. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | */ |
| 22 | package com.savoirfairelinux.sflphone.utils; |
| 23 | |
| 24 | import com.savoirfairelinux.sflphone.R; |
| 25 | import com.savoirfairelinux.sflphone.utils.AccountDetail; |
| 26 | |
Alexandre Savard | ae99293 | 2012-10-17 10:26:12 -0400 | [diff] [blame] | 27 | import java.util.ArrayList; |
Alexandre Savard | f7f9e0b | 2012-10-15 17:24:07 -0400 | [diff] [blame] | 28 | import java.util.Collection; |
| 29 | import java.util.Set; |
| 30 | import java.util.HashMap; |
| 31 | |
| 32 | public class AccountDetailTls implements AccountDetail { |
| 33 | |
| 34 | public static final String CONFIG_TLS_LISTENER_PORT = "TLS.listenerPort"; |
| 35 | public static final String CONFIG_TLS_ENABLE = "TLS.enable"; |
| 36 | public static final String CONFIG_TLS_CA_LIST_FILE = "TLS.certificateListFile"; |
| 37 | public static final String CONFIG_TLS_CERTIFICATE_FILE = "TLS.certificateFile"; |
| 38 | public static final String CONFIG_TLS_PRIVATE_KEY_FILE = "TLS.privateKeyFile"; |
| 39 | public static final String CONFIG_TLS_PASSWORD = "TLS.password"; |
| 40 | public static final String CONFIG_TLS_METHOD = "TLS.method"; |
| 41 | public static final String CONFIG_TLS_CIPHERS = "TLS.ciphers"; |
| 42 | public static final String CONFIG_TLS_SERVER_NAME = "TLS.serverName"; |
| 43 | public static final String CONFIG_TLS_VERIFY_SERVER = "TLS.verifyServer"; |
| 44 | public static final String CONFIG_TLS_VERIFY_CLIENT = "TLS.verifyClient"; |
| 45 | public static final String CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE = "TLS.requireClientCertificate"; |
| 46 | public static final String CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC = "TLS.negotiationTimeoutSec"; |
| 47 | public static final String CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC = "TLS.negotiationTimemoutMsec"; |
| 48 | |
| 49 | private HashMap<String, AccountDetail.PreferenceEntry> privateMap; |
| 50 | |
Alexandre Savard | ae99293 | 2012-10-17 10:26:12 -0400 | [diff] [blame] | 51 | public static ArrayList<AccountDetail.PreferenceEntry> getPreferenceEntries() |
| 52 | { |
| 53 | ArrayList<AccountDetail.PreferenceEntry> preference = new ArrayList<AccountDetail.PreferenceEntry>(); |
| 54 | |
| 55 | preference.add(new PreferenceEntry(CONFIG_TLS_LISTENER_PORT, R.string.account_listener_port_label)); |
| 56 | preference.add(new PreferenceEntry(CONFIG_TLS_ENABLE, R.string.account_tls_enabled_label, true)); |
| 57 | preference.add(new PreferenceEntry(CONFIG_TLS_CA_LIST_FILE, R.string.account_tls_certificate_list_label)); |
| 58 | preference.add(new PreferenceEntry(CONFIG_TLS_CERTIFICATE_FILE, R.string.account_tls_certificate_file_label)); |
| 59 | preference.add(new PreferenceEntry(CONFIG_TLS_PRIVATE_KEY_FILE, R.string.account_tls_private_key_file_label)); |
| 60 | preference.add(new PreferenceEntry(CONFIG_TLS_PASSWORD, R.string.account_tls_password_label)); |
| 61 | preference.add(new PreferenceEntry(CONFIG_TLS_METHOD, R.string.account_tls_method_label)); |
| 62 | preference.add(new PreferenceEntry(CONFIG_TLS_CIPHERS, R.string.account_tls_ciphers_label)); |
| 63 | preference.add(new PreferenceEntry(CONFIG_TLS_SERVER_NAME, R.string.account_tls_server_name_label)); |
| 64 | preference.add(new PreferenceEntry(CONFIG_TLS_VERIFY_SERVER, R.string.account_tls_verify_label, true)); |
| 65 | preference.add(new PreferenceEntry(CONFIG_TLS_VERIFY_CLIENT, R.string.account_tls_verify_client_label, true)); |
| 66 | preference.add(new PreferenceEntry(CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, R.string.account_tls_require_client_certificat_label, true)); |
| 67 | preference.add(new PreferenceEntry(CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, R.string.account_tls_negotiation_timeout_sec)); |
| 68 | preference.add(new PreferenceEntry(CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC, R.string.account_tls_negotiation_timeout_msec)); |
| 69 | |
| 70 | return preference; |
| 71 | } |
| 72 | |
Alexandre Savard | f7f9e0b | 2012-10-15 17:24:07 -0400 | [diff] [blame] | 73 | public AccountDetailTls() |
| 74 | { |
| 75 | privateMap = new HashMap<String, AccountDetail.PreferenceEntry>(); |
| 76 | |
| 77 | privateMap.put(CONFIG_TLS_LISTENER_PORT, |
| 78 | new PreferenceEntry(CONFIG_TLS_LISTENER_PORT, R.string.account_listener_port_label)); |
| 79 | privateMap.put(CONFIG_TLS_ENABLE, |
Alexandre Savard | 20d0de0 | 2012-10-16 14:05:44 -0400 | [diff] [blame] | 80 | new PreferenceEntry(CONFIG_TLS_ENABLE, R.string.account_tls_enabled_label, true)); |
Alexandre Savard | f7f9e0b | 2012-10-15 17:24:07 -0400 | [diff] [blame] | 81 | privateMap.put(CONFIG_TLS_CA_LIST_FILE, |
| 82 | new PreferenceEntry(CONFIG_TLS_CA_LIST_FILE, R.string.account_tls_certificate_list_label)); |
| 83 | privateMap.put(CONFIG_TLS_CERTIFICATE_FILE, |
| 84 | new PreferenceEntry(CONFIG_TLS_CERTIFICATE_FILE, R.string.account_tls_certificate_file_label)); |
| 85 | privateMap.put(CONFIG_TLS_PRIVATE_KEY_FILE, |
| 86 | new PreferenceEntry(CONFIG_TLS_PRIVATE_KEY_FILE, R.string.account_tls_private_key_file_label)); |
| 87 | privateMap.put(CONFIG_TLS_PASSWORD, |
| 88 | new PreferenceEntry(CONFIG_TLS_PASSWORD, R.string.account_tls_password_label)); |
| 89 | privateMap.put(CONFIG_TLS_METHOD, |
| 90 | new PreferenceEntry(CONFIG_TLS_METHOD, R.string.account_tls_method_label)); |
| 91 | privateMap.put(CONFIG_TLS_CIPHERS, |
| 92 | new PreferenceEntry(CONFIG_TLS_CIPHERS, R.string.account_tls_ciphers_label)); |
| 93 | privateMap.put(CONFIG_TLS_SERVER_NAME, |
| 94 | new PreferenceEntry(CONFIG_TLS_SERVER_NAME, R.string.account_tls_server_name_label)); |
| 95 | privateMap.put(CONFIG_TLS_VERIFY_SERVER, |
Alexandre Savard | 20d0de0 | 2012-10-16 14:05:44 -0400 | [diff] [blame] | 96 | new PreferenceEntry(CONFIG_TLS_VERIFY_SERVER, R.string.account_tls_verify_label, true)); |
Alexandre Savard | f7f9e0b | 2012-10-15 17:24:07 -0400 | [diff] [blame] | 97 | privateMap.put(CONFIG_TLS_VERIFY_CLIENT, |
Alexandre Savard | 20d0de0 | 2012-10-16 14:05:44 -0400 | [diff] [blame] | 98 | new PreferenceEntry(CONFIG_TLS_VERIFY_CLIENT, R.string.account_tls_verify_client_label, true)); |
Alexandre Savard | f7f9e0b | 2012-10-15 17:24:07 -0400 | [diff] [blame] | 99 | privateMap.put(CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, |
Alexandre Savard | 20d0de0 | 2012-10-16 14:05:44 -0400 | [diff] [blame] | 100 | new PreferenceEntry(CONFIG_TLS_REQUIRE_CLIENT_CERTIFICATE, R.string.account_tls_require_client_certificat_label, true)); |
Alexandre Savard | f7f9e0b | 2012-10-15 17:24:07 -0400 | [diff] [blame] | 101 | privateMap.put(CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, |
| 102 | new PreferenceEntry(CONFIG_TLS_NEGOTIATION_TIMEOUT_SEC, R.string.account_tls_negotiation_timeout_sec)); |
| 103 | privateMap.put(CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC, |
| 104 | new PreferenceEntry(CONFIG_TLS_NEGOTIATION_TIMEOUT_MSEC, R.string.account_tls_negotiation_timeout_msec)); |
| 105 | } |
| 106 | |
| 107 | public Set<String> getDetailKeys() |
| 108 | { |
| 109 | return privateMap.keySet(); |
| 110 | } |
| 111 | |
| 112 | public Collection<AccountDetail.PreferenceEntry> getDetailValues() |
| 113 | { |
| 114 | return privateMap.values(); |
| 115 | } |
| 116 | } |