1 /*
2 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
31 package sun.security.krb5;
32
33 import java.io.*;
34 import java.nio.file.DirectoryStream;
35 import java.nio.file.Files;
36 import java.nio.file.Paths;
37 import java.nio.file.Path;
38 import java.security.PrivilegedAction;
39 import java.util.*;
40 import java.net.InetAddress;
41 import java.net.UnknownHostException;
42 import java.security.AccessController;
43 import java.security.PrivilegedExceptionAction;
44 import java.util.regex.Matcher;
45 import java.util.regex.Pattern;
46
47 import sun.net.dns.ResolverConfiguration;
48 import sun.security.action.GetPropertyAction;
49 import sun.security.krb5.internal.crypto.EType;
50 import sun.security.krb5.internal.Krb5;
51
52 /**
53 * This class maintains key-value pairs of Kerberos configurable constants
54 * from configuration file or from user specified system properties.
55 */
56
57 public class Config {
58
59 /*
60 * Only allow a single instance of Config.
61 */
62 private static Config singleton = null;
63
64 /*
65 * Hashtable used to store configuration information.
66 */
67 private Hashtable<String,Object> stanzaTable = new Hashtable<>();
68
69 private static boolean DEBUG = sun.security.krb5.internal.Krb5.DEBUG;
70
71 // these are used for hexdecimal calculation.
72 private static final int BASE16_0 = 1;
73 private static final int BASE16_1 = 16;
74 private static final int BASE16_2 = 16 * 16;
75 private static final int BASE16_3 = 16 * 16 * 16;
76
77 /**
|
1 /*
2 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
31 package sun.security.krb5;
32
33 import java.io.*;
34 import java.nio.file.DirectoryStream;
35 import java.nio.file.Files;
36 import java.nio.file.Paths;
37 import java.nio.file.Path;
38 import java.security.PrivilegedAction;
39 import java.util.*;
40 import java.net.InetAddress;
41 import java.net.UnknownHostException;
42 import java.security.AccessController;
43 import java.security.PrivilegedExceptionAction;
44 import java.util.regex.Matcher;
45 import java.util.regex.Pattern;
46
47 import sun.net.dns.ResolverConfiguration;
48 import sun.security.action.GetPropertyAction;
49 import sun.security.krb5.internal.crypto.EType;
50 import sun.security.krb5.internal.Krb5;
51 import sun.security.util.SecurityProperties;
52
53 /**
54 * This class maintains key-value pairs of Kerberos configurable constants
55 * from configuration file or from user specified system properties.
56 */
57
58 public class Config {
59
60 /**
61 * {@systemProperty sun.security.krb5.disableReferrals} property
62 * indicating whether or not cross-realm referrals (RFC 6806) are
63 * enabled.
64 */
65 public static final boolean DISABLE_REFERRALS;
66
67 /**
68 * {@systemProperty sun.security.krb5.maxReferrals} property
69 * indicating the maximum number of cross-realm referral
70 * hops allowed.
71 */
72 public static final int MAX_REFERRALS;
73
74 static {
75 String disableReferralsProp =
76 SecurityProperties.privilegedGetOverridable(
77 "sun.security.krb5.disableReferrals");
78 if (disableReferralsProp != null) {
79 DISABLE_REFERRALS = "true".equalsIgnoreCase(disableReferralsProp);
80 } else {
81 DISABLE_REFERRALS = false;
82 }
83
84 int maxReferralsValue = 5;
85 String maxReferralsProp =
86 SecurityProperties.privilegedGetOverridable(
87 "sun.security.krb5.maxReferrals");
88 try {
89 maxReferralsValue = Integer.parseInt(maxReferralsProp);
90 } catch (NumberFormatException e) {
91 }
92 MAX_REFERRALS = maxReferralsValue;
93 }
94
95 /*
96 * Only allow a single instance of Config.
97 */
98 private static Config singleton = null;
99
100 /*
101 * Hashtable used to store configuration information.
102 */
103 private Hashtable<String,Object> stanzaTable = new Hashtable<>();
104
105 private static boolean DEBUG = sun.security.krb5.internal.Krb5.DEBUG;
106
107 // these are used for hexdecimal calculation.
108 private static final int BASE16_0 = 1;
109 private static final int BASE16_1 = 16;
110 private static final int BASE16_2 = 16 * 16;
111 private static final int BASE16_3 = 16 * 16 * 16;
112
113 /**
|