aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/config/Defaults.java
blob: 78e203d513099f87a7ce073644f273e99a4f927a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
/* Defaults.java
   Copyright (C) 2010 Red Hat, Inc.

This file is part of IcedTea.

IcedTea 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, version 2.

IcedTea 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 IcedTea; see the file COPYING.  If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version.
*/

package net.sourceforge.jnlp.config;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import net.sourceforge.jnlp.ShortcutDesc;
import net.sourceforge.jnlp.runtime.JNLPProxySelector;

/**
 * This class stores the default configuration
 */
public class Defaults {

    /**
     * Get the default settings for deployment
     */
    public static Map<String, Setting<String>> getDefaults() {
        File userFile = new File(System.getProperty("user.home") + File.separator + DeploymentConfiguration.DEPLOYMENT_DIR
                + File.separator + DeploymentConfiguration.DEPLOYMENT_PROPERTIES);

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
            sm.checkRead(userFile.toString());
        }

        final String SYSTEM_HOME = System.getProperty("java.home");
        final String SYSTEM_SECURITY = SYSTEM_HOME + File.separator + "lib" + File.separator + "security";

        final String USER_HOME = System.getProperty("user.home") + File.separator + DeploymentConfiguration.DEPLOYMENT_DIR;
        final String USER_SECURITY = USER_HOME + File.separator + "security";

        final String LOCKS_DIR = System.getProperty("java.io.tmpdir") + File.separator
                + System.getProperty("user.name") + File.separator + "netx" + File.separator
                + "locks";

        /*
         * This is more or less a straight copy from the deployment
         * configuration page, with occasional replacements of "" or no-defaults
         * with null
         *
         * The format of this is:
         * name
         * checker (can be null or a ValueChecker)
         * value (can be null or a String)
         */

        Object[][] defaults = new Object[][] {
                /* infrastructure */
                {
                        DeploymentConfiguration.KEY_USER_CACHE_DIR,
                        BasicValueValidators.getFilePathValidator(),
                        USER_HOME + File.separator + "cache"
                },
                {
                        DeploymentConfiguration.KEY_USER_PERSISTENCE_CACHE_DIR,
                        BasicValueValidators.getFilePathValidator(),
                        USER_HOME + File.separator + "pcache"
                },
                {
                        DeploymentConfiguration.KEY_SYSTEM_CACHE_DIR,
                        BasicValueValidators.getFilePathValidator(),
                        null
                },
                {
                        DeploymentConfiguration.KEY_USER_LOG_DIR,
                        BasicValueValidators.getFilePathValidator(),
                        USER_HOME + File.separator + "log"
                },
                {
                        DeploymentConfiguration.KEY_USER_TMP_DIR,
                        BasicValueValidators.getFilePathValidator(),
                        USER_HOME + File.separator + "tmp"
                },
                {
                        DeploymentConfiguration.KEY_USER_LOCKS_DIR,
                        BasicValueValidators.getFilePathValidator(),
                        LOCKS_DIR
                },
                {
                        DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE,
                        BasicValueValidators.getFilePathValidator(),
                        LOCKS_DIR + File.separator + "netx_running"
                },
                /* certificates and policy files */
                {
                        DeploymentConfiguration.KEY_USER_SECURITY_POLICY,
                        BasicValueValidators.getUrlValidator(),
                        "file://" + USER_SECURITY + File.separator + "java.policy"
                },
                {
                        DeploymentConfiguration.KEY_USER_TRUSTED_CA_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        USER_SECURITY + File.separator + "trusted.cacerts"
                },
                {
                        DeploymentConfiguration.KEY_USER_TRUSTED_JSSE_CA_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        USER_SECURITY + File.separator + "trusted.jssecacerts"
                },
                {
                        DeploymentConfiguration.KEY_USER_TRUSTED_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        USER_SECURITY + File.separator + "trusted.certs"
                },
                {
                        DeploymentConfiguration.KEY_USER_TRUSTED_JSSE_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        USER_SECURITY + File.separator + "trusted.jssecerts"
                },
                {
                        DeploymentConfiguration.KEY_USER_TRUSTED_CLIENT_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        USER_SECURITY + File.separator + "trusted.clientcerts"
                },
                {
                        DeploymentConfiguration.KEY_SYSTEM_SECURITY_POLICY,
                        BasicValueValidators.getUrlValidator(),
                        null
                },
                {
                        DeploymentConfiguration.KEY_SYSTEM_TRUSTED_CA_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        SYSTEM_SECURITY + File.separator + "cacerts"
                },
                {
                        DeploymentConfiguration.KEY_SYSTEM_TRUSTED_JSSE_CA_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        SYSTEM_SECURITY + File.separator + "jssecacerts"
                },
                {
                        DeploymentConfiguration.KEY_SYSTEM_TRUSTED_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        SYSTEM_SECURITY + File.separator + "trusted.certs"
                },
                {
                        DeploymentConfiguration.KEY_SYSTEM_TRUSTED_JSSE_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        SYSTEM_SECURITY + File.separator + "trusted.jssecerts"
                },
                {
                        DeploymentConfiguration.KEY_SYSTEM_TRUSTED_CLIENT_CERTS,
                        BasicValueValidators.getFilePathValidator(),
                        SYSTEM_SECURITY + File.separator + "trusted.clientcerts"
                },
                /* security access and control */
                {
                        DeploymentConfiguration.KEY_SECURITY_PROMPT_USER,
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(true)
                },
                {
                        "deployment.security.askgrantdialog.notinca",
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(true)
                },
                {
                        "deployment.security.notinca.warning",
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(true)
                },
                {
                        "deployment.security.expired.warning",
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(true)
                },
                {
                        "deployment.security.jsse.hostmismatch.warning",
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(true)
                },
                {
                        "deployment.security.trusted.policy",
                        BasicValueValidators.getFilePathValidator(),
                        null
                },
                {
                        DeploymentConfiguration.KEY_SECURITY_ALLOW_HIDE_WINDOW_WARNING,
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(true)
                },
                {
                        DeploymentConfiguration.KEY_SECURITY_PROMPT_USER_FOR_JNLP,
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(true)
                },
                {
                        DeploymentConfiguration.KEY_SECURITY_INSTALL_AUTHENTICATOR,
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(true)
                },
                /* networking */
                {
                        DeploymentConfiguration.KEY_PROXY_TYPE,
                        BasicValueValidators.getRangedIntegerValidator(JNLPProxySelector.PROXY_TYPE_UNKNOWN, JNLPProxySelector.PROXY_TYPE_BROWSER),
                        String.valueOf(JNLPProxySelector.PROXY_TYPE_BROWSER)
                },
                {
                        DeploymentConfiguration.KEY_PROXY_SAME,
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(false)
                },
                {
                        DeploymentConfiguration.KEY_PROXY_AUTO_CONFIG_URL,
                        BasicValueValidators.getUrlValidator(),
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_BYPASS_LIST,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_BYPASS_LOCAL,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_HTTP_HOST,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_HTTP_PORT,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_HTTPS_HOST,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_HTTPS_PORT,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_FTP_HOST,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_FTP_PORT,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_SOCKS4_HOST,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_SOCKS4_PORT,
                        null,
                        null
                },
                {
                        DeploymentConfiguration.KEY_PROXY_OVERRIDE_HOSTS,
                        null,
                        null
                },
                /* cache and optional package repository */
                {
                        "deployment.cache.max.size",
                        BasicValueValidators.getRangedIntegerValidator(-1, Integer.MAX_VALUE),
                        String.valueOf("-1")
                },
                {
                        "deployment.cache.jarcompression",
                        BasicValueValidators.getRangedIntegerValidator(0, 10),
                        String.valueOf(0)
                },
                {
                        "deployment.javapi.cache.enabled",
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(false)
                },
                /* java console */
                {
                        DeploymentConfiguration.KEY_CONSOLE_STARTUP_MODE,
                        BasicValueValidators.getStringValidator(new String[] {
                                DeploymentConfiguration.CONSOLE_DISABLE,
                                DeploymentConfiguration.CONSOLE_HIDE,
                                DeploymentConfiguration.CONSOLE_SHOW
                        }),
                        DeploymentConfiguration.CONSOLE_HIDE
                },
                /* tracing and logging */
                {
                        DeploymentConfiguration.KEY_ENABLE_TRACING,
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(false)
                },
                {
                        DeploymentConfiguration.KEY_ENABLE_LOGGING,
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(false)
                },
                /* JNLP association */
                {
                        DeploymentConfiguration.KEY_JNLP_ASSOCIATIONS,
                        BasicValueValidators.getRangedIntegerValidator(DeploymentConfiguration.JNLP_ASSOCIATION_NEVER,
                                DeploymentConfiguration.JNLP_ASSOCIATION_REPLACE_ASK),
                        String.valueOf(DeploymentConfiguration.JNLP_ASSOCIATION_ASK_USER)
                },
                /* desktop integration */
                {
                        DeploymentConfiguration.KEY_CREATE_DESKTOP_SHORTCUT,
                        BasicValueValidators.getStringValidator(new String[] {
                                ShortcutDesc.CREATE_ALWAYS,
                                ShortcutDesc.CREATE_ALWAYS_IF_HINTED,
                                ShortcutDesc.CREATE_ASK_USER,
                                ShortcutDesc.CREATE_ASK_USER_IF_HINTED,
                                ShortcutDesc.CREATE_NEVER
                        }),
                        ShortcutDesc.CREATE_ASK_USER_IF_HINTED
                },
                /* jre selection */
                {
                        DeploymentConfiguration.KEY_JRE_INTSTALL_URL,
                        BasicValueValidators.getUrlValidator(),
                        null
                },
                /* jre management */
                {
                        DeploymentConfiguration.KEY_AUTO_DOWNLOAD_JRE,
                        BasicValueValidators.getBooleanValidator(),
                        String.valueOf(false)
                },
                /* browser selection */
                {
                        DeploymentConfiguration.KEY_BROWSER_PATH,
                        BasicValueValidators.getFilePathValidator(),
                        null
                },
                /* check for update timeout */
                {
                        DeploymentConfiguration.KEY_UPDATE_TIMEOUT,
                        BasicValueValidators.getRangedIntegerValidator(0, 10000),
                        String.valueOf(500)
                }
        };

        HashMap<String, Setting<String>> result = new HashMap<String, Setting<String>>();
        for (int i = 0; i < defaults.length; i++) {
            String name = (String) defaults[i][0];
            ValueValidator checker = (ValueValidator) defaults[i][1];
            String actualValue = (String) defaults[i][2];
            boolean locked = false;
            Setting<String> value = new Setting<String>(name, name, locked, checker, actualValue, actualValue, "<internal>");
            result.put(name, value);
        }

        return result;
    }
}