/
Configuration.java
790 lines (629 loc) · 18 KB
/
Configuration.java
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
/*
* © 2016 AgNO3 Gmbh & Co. KG
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package jcifs;
import java.net.InetAddress;
import java.security.SecureRandom;
import java.util.List;
import java.util.TimeZone;
/**
*
*
* Implementors of this interface should extend {@link jcifs.config.BaseConfiguration} or
* {@link jcifs.config.DelegatingConfiguration} to get forward compatibility.
*
* @author mbechler
*
*/
public interface Configuration {
/**
*
* @return random source to use
*/
SecureRandom getRandom ();
/**
*
*
* Property <tt>jcifs.smb.client.dfs.ttl</tt> (int, default 300)
*
* @return title to live, in seconds, for DFS cache entries
*/
long getDfsTtl ();
/**
*
* Property <tt>jcifs.smb.client.dfs.strictView</tt> (boolean, default false)
*
* @return whether a authentication failure during DFS resolving will throw an exception
*/
boolean isDfsStrictView ();
/**
*
* Property <tt>jcifs.smb.client.dfs.disabled</tt> (boolean, default false)
*
* @return whether DFS lookup is disabled
*/
boolean isDfsDisabled ();
/**
* Enable hack to make kerberos auth work with DFS sending short names
*
* This works by appending the domain name to the netbios short name and will fail horribly if this mapping is not
* correct for your domain.
*
* Property <tt>jcifs.smb.client.dfs.convertToFQDN</tt> (boolean, default false)
*
* @return whether to convert NetBIOS names returned by DFS to FQDNs
*/
boolean isDfsConvertToFQDN ();
/**
* Minimum protocol version
*
* Property <tt>jcifs.smb.client.minVersion</tt> (string, default SMB1)
*
* @see DialectVersion
* @return minimum protocol version to use/allow
* @since 2.1
*/
DialectVersion getMinimumVersion ();
/**
* Maximum protocol version
*
* Property <tt>jcifs.smb.client.maxVersion</tt> (string, default SMB210)
*
* @see DialectVersion
* @return maximum protocol version to use/allow
* @since 2.1
*/
DialectVersion getMaximumVersion ();
/**
* Use SMB2 non-backward compatible negotiation style
*
* Property <tt>jcifs.smb.client.useSMB2Negotiation</tt> (boolean, default false)
*
* @return whether to use non-backward compatible protocol negotiation
*/
boolean isUseSMB2OnlyNegotiation ();
/**
* Enforce secure negotiation
*
* Property <tt>jcifs.smb.client.requireSecureNegotiate</tt> (boolean, default true)
*
* This does not provide any actual downgrade protection if SMB1 is allowed.
*
* It will also break connections with SMB2 servers that do not properly sign error responses.
*
* @return whether to enforce the use of secure negotiation.
*/
boolean isRequireSecureNegotiate ();
/**
* Enable port 139 failover
*
* Property <tt>jcifs.smb.client.port139.enabled</tt> (boolean, default false)
*
* @return whether to failover to legacy transport on port 139
*/
boolean isPort139FailoverEnabled ();
/**
*
* Property <tt>jcifs.smb.client.useUnicode</tt> (boolean, default true)
*
* @return whether to announce support for unicode
*/
boolean isUseUnicode ();
/**
*
* Property <tt>jcifs.smb.client.forceUnicode</tt> (boolean, default false)
*
* @return whether to use unicode, even if the server does not announce it
*/
boolean isForceUnicode ();
/**
*
* Property <tt>jcifs.smb.client.useBatching</tt> (boolean, default false)
*
* @return whether to enable support for SMB1 AndX command batching
*/
boolean isUseBatching ();
/**
*
* Property <tt>jcifs.smb.client.nativeOs</tt> (string, default <tt>os.name</tt>)
*
* @return OS string to report
*/
String getNativeOs ();
/**
*
* Property <tt>jcifs.smb.client.nativeLanMan</tt> (string, default <tt>jCIFS</tt>)
*
* @return Lanman string to report
*/
String getNativeLanman ();
/**
*
* Property <tt>jcifs.smb.client.rcv_buf_size</tt> (int, default 65535)
*
* @return receive buffer size, in bytes
* @deprecated use getReceiveBufferSize instead
*/
@Deprecated
int getRecieveBufferSize ();
/**
*
* Property <tt>jcifs.smb.client.rcv_buf_size</tt> (int, default 65535)
*
* @return receive buffer size, in bytes
*/
int getReceiveBufferSize ();
/**
*
* Property <tt>jcifs.smb.client.snd_buf_size</tt> (int, default 65535)
*
* @return send buffer size, in bytes
*/
int getSendBufferSize ();
/**
*
* Property <tt>jcifs.smb.client.soTimeout</tt> (int, default 35000)
*
* @return socket timeout, in milliseconds
*/
int getSoTimeout ();
/**
*
* Property <tt>jcifs.smb.client.connTimeout</tt> (int, default 35000)
*
* @return timeout for establishing a socket connection, in milliseconds
*/
int getConnTimeout ();
/**
* Property <tt>jcifs.smb.client.sessionTimeout</tt> (int, default 35000)
*
*
* @return timeout for SMB sessions, in milliseconds
*/
int getSessionTimeout ();
/**
*
* Property <tt>jcifs.smb.client.responseTimeout</tt> (int, default 30000)
*
* @return timeout for SMB responses, in milliseconds
*/
int getResponseTimeout ();
/**
*
* Property <tt>jcifs.smb.client.lport</tt> (int)
*
* @return local port to use for outgoing connections
*/
int getLocalPort ();
/**
*
* Property <tt>jcifs.smb.client.laddr</tt> (string)
*
* @return local address to use for outgoing connections
*/
InetAddress getLocalAddr ();
/**
*
* Property <tt>jcifs.netbios.hostname</tt> (string)
*
* @return local NETBIOS/short name to announce
*/
String getNetbiosHostname ();
/**
*
* Property <tt>jcifs.smb.client.logonShare</tt>
*
* @return share to connect to during authentication, if unset connect to IPC$
*/
String getLogonShare ();
/**
*
*
* Property <tt>jcifs.smb.client.domain</tt>
*
* @return default credentials, domain name
*/
String getDefaultDomain ();
/**
*
* Property <tt>jcifs.smb.client.username</tt>
*
* @return default credentials, user name
*/
String getDefaultUsername ();
/**
*
* Property <tt>jcifs.smb.client.password</tt>
*
* @return default credentials, password
*/
String getDefaultPassword ();
/**
* Lanman compatibility level
*
* {@href https://technet.microsoft.com/en-us/library/cc960646.aspx}
*
*
* <table>
* <tr>
* <td>0 or 1</td>
* <td>LM and NTLM</td>
* </tr>
* <tr>
* <td>2</td>
* <td>NTLM only</td>
* </tr>
* <tr>
* <td>3-5</td>
* <td>NTLMv2 only</td>
* </tr>
* </table>
*
*
* Property <tt>jcifs.smb.lmCompatibility</tt> (int, default 3)
*
* @return lanman compatibility level, defaults to 3 i.e. NTLMv2 only
*/
int getLanManCompatibility ();
/**
*
* Property <tt>jcifs.smb.allowNTLMFallback</tt> (boolean, default true)
*
* @return whether to allow fallback from kerberos to NTLM
*/
boolean isAllowNTLMFallback ();
/**
* Property <tt>jcifs.smb.useRawNTLM</tt> (boolean, default false)
*
* @return whether to use raw NTLMSSP tokens instead of SPNEGO wrapped ones
* @since 2.1
*/
boolean isUseRawNTLM ();
/**
*
* Property <tt>jcifs.smb.client.disablePlainTextPasswords</tt> (boolean, default true)
*
* @return whether the usage of plaintext passwords is prohibited, defaults to false
*/
boolean isDisablePlainTextPasswords ();
/**
*
*
* Property <tt>jcifs.resolveOrder</tt> (string, default <tt>LMHOSTS,DNS,WINS,BCAST</tt>)
*
* @return order and selection of resolver modules, see {@link ResolverType}
*/
List<ResolverType> getResolveOrder ();
/**
*
* Property <tt>jcifs.netbios.baddr</tt> (string, default <tt>255.255.255.255</tt>)
*
* @return broadcast address to use
*/
InetAddress getBroadcastAddress ();
/**
*
*
* Property <tt>jcifs.netbios.wins</tt> (string, comma separated)
*
* @return WINS server to use
*/
InetAddress[] getWinsServers ();
/**
*
* Property <tt>jcifs.netbios.lport</tt> (int)
*
* @return local bind port for nebios connections
*/
int getNetbiosLocalPort ();
/**
*
* Property <tt>jcifs.netbios.laddr</tt> (string)
*
* @return local bind address for netbios connections
*/
InetAddress getNetbiosLocalAddress ();
/**
*
*
* Property <tt>jcifs.netbios.soTimeout</tt> (int, default 5000)
*
* @return socket timeout for netbios connections, in milliseconds
*/
int getNetbiosSoTimeout ();
/**
*
*
* @return virtual circuit number to use
*/
int getVcNumber ();
/**
*
* Property <tt>jcifs.smb.client.capabilities</tt> (int)
*
* @return custom capabilities
*/
int getCapabilities ();
/**
*
*
* Property <tt>jcifs.smb.client.flags2</tt> (int)
*
* @return custom flags2
*/
int getFlags2 ();
/**
*
* Property <tt>jcifs.smb.client.ssnLimit</tt> (int, 250)
*
* @return maximum number of sessions on a single connection
*/
int getSessionLimit ();
/**
*
* Property <tt>jcifs.encoding</tt> (string, default <tt>Cp850</tt>)
*
* @return OEM encoding to use
*/
String getOemEncoding ();
/**
* @return local timezone
*/
TimeZone getLocalTimezone ();
/**
* @return Process id to send, randomized if unset
*/
int getPid ();
/**
*
* Property <tt>jcifs.smb.client.maxMpxCount</tt> (int, default 10)
*
* @return maximum count of concurrent commands to announce
*/
int getMaxMpxCount ();
/**
*
* Property <tt>jcifs.smb.client.signingPreferred</tt> (boolean, default false)
*
* @return whether to enable SMB signing (for everything), if available
*/
boolean isSigningEnabled ();
/**
*
* Property <tt>jcifs.smb.client.ipcSigningEnforced</tt> (boolean, default true)
*
* @return whether to enforce SMB signing for IPC connections
*/
boolean isIpcSigningEnforced ();
/**
*
* Property <tt>jcifs.smb.client.signingEnforced</tt> (boolean, default false)
*
* @return whether to enforce SMB signing (for everything)
*/
boolean isSigningEnforced ();
/**
* Property <tt>jcifs.smb.client.encryptionEnabled</tt> (boolean, default false)
*
* This is an experimental option allowing to indicate support during protocol
* negotiation, SMB encryption is not implemented yet.
*
* @return whether SMB encryption is enabled
* @since 2.1
*/
boolean isEncryptionEnabled ();
/**
*
* Property <tt>jcifs.smb.client.forceExtendedSecurity</tt> (boolean, default false)
*
* @return whether to force extended security usage
*/
boolean isForceExtendedSecurity ();
/**
*
*
* Property <tt>jcifs.netbios.lmhosts</tt> (string)
*
* @return lmhosts file to use
*/
String getLmHostsFileName ();
/**
*
* Property <tt>jcifs.netbios.scope</tt> (string)
*
* @return default netbios scope to set in requests
*/
String getNetbiosScope ();
/**
*
* Property <tt>jcifs.netbios.snd_buf_size</tt> (int, default 576)
*
* @return netbios send buffer size
*/
int getNetbiosSndBufSize ();
/**
*
* Property <tt>jcifs.netbios.rcv_buf_size</tt> (int, default 576)
*
* @return netbios recieve buffer size
*/
int getNetbiosRcvBufSize ();
/**
*
* Property <tt>jcifs.netbios.retryTimeout</tt> (int, default 3000)
*
* @return timeout of retry requests, in milliseconds
*/
int getNetbiosRetryTimeout ();
/**
*
* Property <tt>jcifs.netbios.retryCount</tt> (int, default 2)
*
* @return maximum number of retries for netbios requests
*/
int getNetbiosRetryCount ();
/**
*
*
* Property <tt>jcifs.netbios.cachePolicy</tt> in minutes (int, default 600)
*
* @return netbios cache timeout, in seconds, 0 - disable caching, -1 - cache forever
*/
int getNetbiosCachePolicy ();
/**
*
* @return the maximum size of IO buffers, limits the maximum message size
*/
int getMaximumBufferSize ();
/**
*
* Property <tt>jcifs.smb.client.transaction_buf_size</tt> (int, default 65535)
*
* @return maximum data size for SMB transactions
*/
int getTransactionBufferSize ();
/**
*
* Property <tt>jcifs.smb.maxBuffers</tt> (int, default 16)
*
* @return number of buffers to keep in cache
*/
int getBufferCacheSize ();
/**
*
* Property <tt>jcifs.smb.client.listCount</tt> (int, default 200)
*
* @return maxmimum number of elements to request in a list request
*/
int getListCount ();
/**
*
* Property <tt>jcifs.smb.client.listSize</tt> (int, default 65435)
*
* @return maximum data size for list/info requests (known overhead is subtracted)
*/
int getListSize ();
/**
*
*
* Property <tt>jcifs.smb.client.attrExpirationPeriod</tt> (int, 5000)
*
* @return timeout of file attribute cache
*/
long getAttributeCacheTimeout ();
/**
*
*
* Property <tt>jcifs.smb.client.ignoreCopyToException</tt> (boolean, false)
*
* @return whether to ignore exceptions that occur during file copy
*/
boolean isIgnoreCopyToException ();
/**
* @param cmd
* @return the batch limit for the given command
*/
int getBatchLimit ( String cmd );
/**
*
* Property <tt>jcifs.smb.client.notify_buf_size</tt> (int, default 1024)
*
* @return the size of the requested server notify buffer
*/
int getNotifyBufferSize ();
/**
*
*
* Property <tt>jcifs.smb.client.maxRequestRetries</tt> (int, default 2)
*
* @return retry SMB requests on failure up to n times
*/
int getMaxRequestRetries ();
/**
* Property <tt>jcifs.smb.client.strictResourceLifecycle</tt> (bool, default false)
*
* If enabled, SmbFile instances starting with their first use will hold a reference to their tree.
* This means that trees/sessions/connections won't be idle-disconnected even if there are no other active
* references (currently executing code, file descriptors).
*
* Depending on the usage scenario, this may have some benefit as there won't be any delays for restablishing these
* resources, however comes at the cost of having to properly release all SmbFile instances you no longer need.
*
* @return whether to use strict resource lifecycle
*/
boolean isStrictResourceLifecycle ();
/**
* This is solely intended for debugging
*
* @return whether to track the locations from which resources were created
*/
boolean isTraceResourceUsage ();
/**
* @param command
* @return whether to allow creating compound requests with that command
*/
boolean isAllowCompound ( String command );
/**
* Machine identifier
*
* ClientGuid, ... are derived from this value.
*
* Normally this should be randomly assigned for each client instance/configuration.
*
* @return machine identifier (32 byte)
*/
byte[] getMachineId ();
/**
*
*
* Property <tt>jcifs.smb.client.disableSpnegoIntegrity</tt> (boolean, false)
*
* @return whether to disable sending/verifying SPNEGO mechanismListMIC
*/
boolean isDisableSpnegoIntegrity ();
/**
*
* Property <tt>jcifs.smb.client.enforceSpnegoIntegrity</tt> (boolean, false)
*
* @return whether to enforce verifying SPNEGO mechanismListMIC
*/
boolean isEnforceSpnegoIntegrity ();
/**
* Property <tt>jcifs.smb.client.SendNTLMTargetName</tt> (boolean, true)
*
* @return whether to send an AvTargetName with the NTLM exchange
*/
boolean isSendNTLMTargetName ();
/**
* Property <tt>jcifs.smb.client.guestPassword</tt>, defaults to empty string
*
* @return password used when guest authentication is requested
*/
String getGuestPassword ();
/**
* Property <tt>jcifs.smb.client.guestUsername</tt>, defaults to GUEST
*
* @return username used when guest authentication is requested
*/
String getGuestUsername ();
/**
* Property <tt>jcifs.smb.client.allowGuestFallback</tt>, defaults to false
*
* @return whether to permit guest logins when user authentication is requested
*/
boolean isAllowGuestFallback ();
}