author | mullan |
Mon, 12 Aug 2013 09:03:51 -0400 | |
changeset 19385 | a7b34a4b1fcb |
parent 15649 | jdk/src/share/classes/sun/security/provider/ConfigSpiFile.java@f6bd3d34f844 |
child 25402 | 0c24d9aa8fb9 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
2 |
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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 |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.security.provider; |
|
27 |
||
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
28 |
import java.io.*; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
29 |
import java.net.MalformedURLException; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
30 |
import java.net.URI; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
31 |
import java.net.URL; |
2 | 32 |
import java.security.AccessController; |
33 |
import java.security.PrivilegedAction; |
|
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
34 |
import java.security.PrivilegedActionException; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
35 |
import java.security.PrivilegedExceptionAction; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
36 |
import java.security.Security; |
2 | 37 |
import java.security.URIParameter; |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
38 |
import java.text.MessageFormat; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
39 |
import java.util.*; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
40 |
import javax.security.auth.AuthPermission; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
41 |
import javax.security.auth.login.AppConfigurationEntry; |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
42 |
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag; |
2 | 43 |
import javax.security.auth.login.Configuration; |
44 |
import javax.security.auth.login.ConfigurationSpi; |
|
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
45 |
import sun.security.util.Debug; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
46 |
import sun.security.util.PropertyExpander; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
47 |
import sun.security.util.ResourcesMgr; |
2 | 48 |
|
49 |
/** |
|
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
50 |
* This class represents a default implementation for |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
51 |
* {@code javax.security.auth.login.Configuration}. |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
52 |
* |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
53 |
* <p> This object stores the runtime login configuration representation, |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
54 |
* and is the amalgamation of multiple static login configurations that |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
55 |
* resides in files. The algorithm for locating the login configuration |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
56 |
* file(s) and reading their information into this {@code Configuration} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
57 |
* object is: |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
58 |
* |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
59 |
* <ol> |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
60 |
* <li> |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
61 |
* Loop through the security properties, |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
62 |
* <i>login.config.url.1</i>, <i>login.config.url.2</i>, ..., |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
63 |
* <i>login.config.url.X</i>. |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
64 |
* Each property value specifies a {@code URL} pointing to a |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
65 |
* login configuration file to be loaded. Read in and load |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
66 |
* each configuration. |
2 | 67 |
* |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
68 |
* <li> |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
69 |
* The {@code java.lang.System} property |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
70 |
* <i>java.security.auth.login.config</i> |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
71 |
* may also be set to a {@code URL} pointing to another |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
72 |
* login configuration file |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
73 |
* (which is the case when a user uses the -D switch at runtime). |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
74 |
* If this property is defined, and its use is allowed by the |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
75 |
* security property file (the Security property, |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
76 |
* <i>policy.allowSystemProperty</i> is set to <i>true</i>), |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
77 |
* also load that login configuration. |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
78 |
* |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
79 |
* <li> |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
80 |
* If the <i>java.security.auth.login.config</i> property is defined using |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
81 |
* "==" (rather than "="), then ignore all other specified |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
82 |
* login configurations and only load this configuration. |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
83 |
* |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
84 |
* <li> |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
85 |
* If no system or security properties were set, try to read from the file, |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
86 |
* ${user.home}/.java.login.config, where ${user.home} is the value |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
87 |
* represented by the "user.home" System property. |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
88 |
* </ol> |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
89 |
* |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
90 |
* <p> The configuration syntax supported by this implementation |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
91 |
* is exactly that syntax specified in the |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
92 |
* {@code javax.security.auth.login.Configuration} class. |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
93 |
* |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
94 |
* @see javax.security.auth.login.LoginContext |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
95 |
* @see java.security.Security security properties |
2 | 96 |
*/ |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
97 |
public final class ConfigFile extends Configuration { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
98 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
99 |
private final Spi spi; |
2 | 100 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
101 |
public ConfigFile() { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
102 |
spi = new Spi(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
103 |
} |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
104 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
105 |
@Override |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
106 |
public AppConfigurationEntry[] getAppConfigurationEntry(String appName) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
107 |
return spi.engineGetAppConfigurationEntry(appName); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
108 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
109 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
110 |
@Override |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
111 |
public synchronized void refresh() { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
112 |
spi.engineRefresh(); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
113 |
} |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
114 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
115 |
public final static class Spi extends ConfigurationSpi { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
116 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
117 |
private URL url; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
118 |
private boolean expandProp = true; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
119 |
private Map<String, List<AppConfigurationEntry>> configuration; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
120 |
private int linenum; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
121 |
private StreamTokenizer st; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
122 |
private int lookahead; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
123 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
124 |
private static Debug debugConfig = Debug.getInstance("configfile"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
125 |
private static Debug debugParser = Debug.getInstance("configparser"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
126 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
127 |
/** |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
128 |
* Creates a new {@code ConfigurationSpi} object. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
129 |
* |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
130 |
* @throws SecurityException if the {@code ConfigurationSpi} can not be |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
131 |
* initialized |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
132 |
*/ |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
133 |
public Spi() { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
134 |
try { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
135 |
init(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
136 |
} catch (IOException ioe) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
137 |
throw new SecurityException(ioe); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
138 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
139 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
140 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
141 |
/** |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
142 |
* Creates a new {@code ConfigurationSpi} object from the specified |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
143 |
* {@code URI}. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
144 |
* |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
145 |
* @param uri the {@code URI} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
146 |
* @throws SecurityException if the {@code ConfigurationSpi} can not be |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
147 |
* initialized |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
148 |
* @throws NullPointerException if {@code uri} is null |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
149 |
*/ |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
150 |
public Spi(URI uri) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
151 |
// only load config from the specified URI |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
152 |
try { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
153 |
url = uri.toURL(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
154 |
init(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
155 |
} catch (IOException ioe) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
156 |
throw new SecurityException(ioe); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
157 |
} |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
158 |
} |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
159 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
160 |
public Spi(final Configuration.Parameters params) throws IOException { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
161 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
162 |
// call in a doPrivileged |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
163 |
// |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
164 |
// we have already passed the Configuration.getInstance |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
165 |
// security check. also this class is not freely accessible |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
166 |
// (it is in the "sun" package). |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
167 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
168 |
try { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
169 |
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
170 |
public Void run() throws IOException { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
171 |
if (params == null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
172 |
init(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
173 |
} else { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
174 |
if (!(params instanceof URIParameter)) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
175 |
throw new IllegalArgumentException |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
176 |
("Unrecognized parameter: " + params); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
177 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
178 |
URIParameter uriParam = (URIParameter)params; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
179 |
url = uriParam.getURI().toURL(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
180 |
init(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
181 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
182 |
return null; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
183 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
184 |
}); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
185 |
} catch (PrivilegedActionException pae) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
186 |
throw (IOException)pae.getException(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
187 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
188 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
189 |
// if init() throws some other RuntimeException, |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
190 |
// let it percolate up naturally. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
191 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
192 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
193 |
/** |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
194 |
* Read and initialize the entire login Configuration from the |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
195 |
* configured URL. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
196 |
* |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
197 |
* @throws IOException if the Configuration can not be initialized |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
198 |
* @throws SecurityException if the caller does not have permission |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
199 |
* to initialize the Configuration |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
200 |
*/ |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
201 |
private void init() throws IOException { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
202 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
203 |
boolean initialized = false; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
204 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
205 |
// For policy.expandProperties, check if either a security or system |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
206 |
// property is set to false (old code erroneously checked the system |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
207 |
// prop so we must check both to preserve compatibility). |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
208 |
String expand = Security.getProperty("policy.expandProperties"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
209 |
if (expand == null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
210 |
expand = System.getProperty("policy.expandProperties"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
211 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
212 |
if ("false".equals(expand)) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
213 |
expandProp = false; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
214 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
215 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
216 |
// new configuration |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
217 |
Map<String, List<AppConfigurationEntry>> newConfig = new HashMap<>(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
218 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
219 |
if (url != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
220 |
/** |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
221 |
* If the caller specified a URI via Configuration.getInstance, |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
222 |
* we only read from that URI |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
223 |
*/ |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
224 |
if (debugConfig != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
225 |
debugConfig.println("reading " + url); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
226 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
227 |
init(url, newConfig); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
228 |
configuration = newConfig; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
229 |
return; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
230 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
231 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
232 |
/** |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
233 |
* Caller did not specify URI via Configuration.getInstance. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
234 |
* Read from URLs listed in the java.security properties file. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
235 |
*/ |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
236 |
String allowSys = Security.getProperty("policy.allowSystemProperty"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
237 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
238 |
if ("true".equalsIgnoreCase(allowSys)) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
239 |
String extra_config = System.getProperty |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
240 |
("java.security.auth.login.config"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
241 |
if (extra_config != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
242 |
boolean overrideAll = false; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
243 |
if (extra_config.startsWith("=")) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
244 |
overrideAll = true; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
245 |
extra_config = extra_config.substring(1); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
246 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
247 |
try { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
248 |
extra_config = PropertyExpander.expand(extra_config); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
249 |
} catch (PropertyExpander.ExpandException peee) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
250 |
throw ioException("Unable.to.properly.expand.config", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
251 |
extra_config); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
252 |
} |
2 | 253 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
254 |
URL configURL = null; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
255 |
try { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
256 |
configURL = new URL(extra_config); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
257 |
} catch (MalformedURLException mue) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
258 |
File configFile = new File(extra_config); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
259 |
if (configFile.exists()) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
260 |
configURL = configFile.toURI().toURL(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
261 |
} else { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
262 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
263 |
"extra.config.No.such.file.or.directory.", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
264 |
extra_config); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
265 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
266 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
267 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
268 |
if (debugConfig != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
269 |
debugConfig.println("reading "+configURL); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
270 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
271 |
init(configURL, newConfig); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
272 |
initialized = true; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
273 |
if (overrideAll) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
274 |
if (debugConfig != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
275 |
debugConfig.println("overriding other policies!"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
276 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
277 |
configuration = newConfig; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
278 |
return; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
279 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
280 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
281 |
} |
2 | 282 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
283 |
int n = 1; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
284 |
String config_url; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
285 |
while ((config_url = Security.getProperty |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
286 |
("login.config.url."+n)) != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
287 |
try { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
288 |
config_url = PropertyExpander.expand |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
289 |
(config_url).replace(File.separatorChar, '/'); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
290 |
if (debugConfig != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
291 |
debugConfig.println("\tReading config: " + config_url); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
292 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
293 |
init(new URL(config_url), newConfig); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
294 |
initialized = true; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
295 |
} catch (PropertyExpander.ExpandException peee) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
296 |
throw ioException("Unable.to.properly.expand.config", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
297 |
config_url); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
298 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
299 |
n++; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
300 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
301 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
302 |
if (initialized == false && n == 1 && config_url == null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
303 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
304 |
// get the config from the user's home directory |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
305 |
if (debugConfig != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
306 |
debugConfig.println("\tReading Policy " + |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
307 |
"from ~/.java.login.config"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
308 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
309 |
config_url = System.getProperty("user.home"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
310 |
String userConfigFile = config_url + File.separatorChar + |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
311 |
".java.login.config"; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
312 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
313 |
// No longer throws an exception when there's no config file |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
314 |
// at all. Returns an empty Configuration instead. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
315 |
if (new File(userConfigFile).exists()) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
316 |
init(new File(userConfigFile).toURI().toURL(), newConfig); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
317 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
318 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
319 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
320 |
configuration = newConfig; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
321 |
} |
2 | 322 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
323 |
private void init(URL config, |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
324 |
Map<String, List<AppConfigurationEntry>> newConfig) |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
325 |
throws IOException { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
326 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
327 |
try (InputStreamReader isr |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
328 |
= new InputStreamReader(getInputStream(config), "UTF-8")) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
329 |
readConfig(isr, newConfig); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
330 |
} catch (FileNotFoundException fnfe) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
331 |
if (debugConfig != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
332 |
debugConfig.println(fnfe.toString()); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
333 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
334 |
throw new IOException(ResourcesMgr.getString |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
335 |
("Configuration.Error.No.such.file.or.directory", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
336 |
"sun.security.util.AuthResources")); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
337 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
338 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
339 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
340 |
/** |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
341 |
* Retrieve an entry from the Configuration using an application name |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
342 |
* as an index. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
343 |
* |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
344 |
* @param applicationName the name used to index the Configuration. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
345 |
* @return an array of AppConfigurationEntries which correspond to |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
346 |
* the stacked configuration of LoginModules for this |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
347 |
* application, or null if this application has no configured |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
348 |
* LoginModules. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
349 |
*/ |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
350 |
@Override |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
351 |
public AppConfigurationEntry[] engineGetAppConfigurationEntry |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
352 |
(String applicationName) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
353 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
354 |
List<AppConfigurationEntry> list = null; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
355 |
synchronized (configuration) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
356 |
list = configuration.get(applicationName); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
357 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
358 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
359 |
if (list == null || list.size() == 0) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
360 |
return null; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
361 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
362 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
363 |
AppConfigurationEntry[] entries = |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
364 |
new AppConfigurationEntry[list.size()]; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
365 |
Iterator<AppConfigurationEntry> iterator = list.iterator(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
366 |
for (int i = 0; iterator.hasNext(); i++) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
367 |
AppConfigurationEntry e = iterator.next(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
368 |
entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
369 |
e.getControlFlag(), |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
370 |
e.getOptions()); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
371 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
372 |
return entries; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
373 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
374 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
375 |
/** |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
376 |
* Refresh and reload the Configuration by re-reading all of the |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
377 |
* login configurations. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
378 |
* |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
379 |
* @throws SecurityException if the caller does not have permission |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
380 |
* to refresh the Configuration. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
381 |
*/ |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
382 |
@Override |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
383 |
public synchronized void engineRefresh() { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
384 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
385 |
SecurityManager sm = System.getSecurityManager(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
386 |
if (sm != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
387 |
sm.checkPermission( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
388 |
new AuthPermission("refreshLoginConfiguration")); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
389 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
390 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
391 |
AccessController.doPrivileged(new PrivilegedAction<Void>() { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
392 |
public Void run() { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
393 |
try { |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
394 |
init(); |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
395 |
} catch (IOException ioe) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
396 |
throw new SecurityException(ioe.getLocalizedMessage(), |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
397 |
ioe); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
398 |
} |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
399 |
return null; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
400 |
} |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
401 |
}); |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
402 |
} |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
403 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
404 |
private void readConfig(Reader reader, |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
405 |
Map<String, List<AppConfigurationEntry>> newConfig) |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
406 |
throws IOException { |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
407 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
408 |
linenum = 1; |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
409 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
410 |
if (!(reader instanceof BufferedReader)) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
411 |
reader = new BufferedReader(reader); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
412 |
} |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
413 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
414 |
st = new StreamTokenizer(reader); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
415 |
st.quoteChar('"'); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
416 |
st.wordChars('$', '$'); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
417 |
st.wordChars('_', '_'); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
418 |
st.wordChars('-', '-'); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
419 |
st.wordChars('*', '*'); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
420 |
st.lowerCaseMode(false); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
421 |
st.slashSlashComments(true); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
422 |
st.slashStarComments(true); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
423 |
st.eolIsSignificant(true); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
424 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
425 |
lookahead = nextToken(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
426 |
while (lookahead != StreamTokenizer.TT_EOF) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
427 |
parseLoginEntry(newConfig); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
428 |
} |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
429 |
} |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
430 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
431 |
private void parseLoginEntry( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
432 |
Map<String, List<AppConfigurationEntry>> newConfig) |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
433 |
throws IOException { |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
434 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
435 |
List<AppConfigurationEntry> configEntries = new LinkedList<>(); |
2 | 436 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
437 |
// application name |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
438 |
String appName = st.sval; |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
439 |
lookahead = nextToken(); |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
440 |
|
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
441 |
if (debugParser != null) { |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
442 |
debugParser.println("\tReading next config entry: " + appName); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
443 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
444 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
445 |
match("{"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
446 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
447 |
// get the modules |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
448 |
while (peek("}") == false) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
449 |
// get the module class name |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
450 |
String moduleClass = match("module class name"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
451 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
452 |
// controlFlag (required, optional, etc) |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
453 |
LoginModuleControlFlag controlFlag; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
454 |
String sflag = match("controlFlag").toUpperCase(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
455 |
switch (sflag) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
456 |
case "REQUIRED": |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
457 |
controlFlag = LoginModuleControlFlag.REQUIRED; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
458 |
break; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
459 |
case "REQUISITE": |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
460 |
controlFlag = LoginModuleControlFlag.REQUISITE; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
461 |
break; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
462 |
case "SUFFICIENT": |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
463 |
controlFlag = LoginModuleControlFlag.SUFFICIENT; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
464 |
break; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
465 |
case "OPTIONAL": |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
466 |
controlFlag = LoginModuleControlFlag.OPTIONAL; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
467 |
break; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
468 |
default: |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
469 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
470 |
"Configuration.Error.Invalid.control.flag.flag", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
471 |
sflag); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
472 |
} |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
473 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
474 |
// get the args |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
475 |
Map<String, String> options = new HashMap<>(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
476 |
while (peek(";") == false) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
477 |
String key = match("option key"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
478 |
match("="); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
479 |
try { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
480 |
options.put(key, expand(match("option value"))); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
481 |
} catch (PropertyExpander.ExpandException peee) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
482 |
throw new IOException(peee.getLocalizedMessage()); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
483 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
484 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
485 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
486 |
lookahead = nextToken(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
487 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
488 |
// create the new element |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
489 |
if (debugParser != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
490 |
debugParser.println("\t\t" + moduleClass + ", " + sflag); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
491 |
for (String key : options.keySet()) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
492 |
debugParser.println("\t\t\t" + key + |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
493 |
"=" + options.get(key)); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
494 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
495 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
496 |
configEntries.add(new AppConfigurationEntry(moduleClass, |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
497 |
controlFlag, |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
498 |
options)); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
499 |
} |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
500 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
501 |
match("}"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
502 |
match(";"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
503 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
504 |
// add this configuration entry |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
505 |
if (newConfig.containsKey(appName)) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
506 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
507 |
"Configuration.Error.Can.not.specify.multiple.entries.for.appName", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
508 |
appName); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
509 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
510 |
newConfig.put(appName, configEntries); |
2 | 511 |
} |
512 |
||
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
513 |
private String match(String expect) throws IOException { |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
514 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
515 |
String value = null; |
2 | 516 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
517 |
switch(lookahead) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
518 |
case StreamTokenizer.TT_EOF: |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
519 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
520 |
"Configuration.Error.expected.expect.read.end.of.file.", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
521 |
expect); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
522 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
523 |
case '"': |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
524 |
case StreamTokenizer.TT_WORD: |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
525 |
if (expect.equalsIgnoreCase("module class name") || |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
526 |
expect.equalsIgnoreCase("controlFlag") || |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
527 |
expect.equalsIgnoreCase("option key") || |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
528 |
expect.equalsIgnoreCase("option value")) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
529 |
value = st.sval; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
530 |
lookahead = nextToken(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
531 |
} else { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
532 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
533 |
"Configuration.Error.Line.line.expected.expect.found.value.", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
534 |
new Integer(linenum), expect, st.sval); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
535 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
536 |
break; |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
537 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
538 |
case '{': |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
539 |
if (expect.equalsIgnoreCase("{")) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
540 |
lookahead = nextToken(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
541 |
} else { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
542 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
543 |
"Configuration.Error.Line.line.expected.expect.", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
544 |
new Integer(linenum), expect, st.sval); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
545 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
546 |
break; |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
547 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
548 |
case ';': |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
549 |
if (expect.equalsIgnoreCase(";")) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
550 |
lookahead = nextToken(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
551 |
} else { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
552 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
553 |
"Configuration.Error.Line.line.expected.expect.", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
554 |
new Integer(linenum), expect, st.sval); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
555 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
556 |
break; |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
557 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
558 |
case '}': |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
559 |
if (expect.equalsIgnoreCase("}")) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
560 |
lookahead = nextToken(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
561 |
} else { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
562 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
563 |
"Configuration.Error.Line.line.expected.expect.", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
564 |
new Integer(linenum), expect, st.sval); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
565 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
566 |
break; |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
567 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
568 |
case '=': |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
569 |
if (expect.equalsIgnoreCase("=")) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
570 |
lookahead = nextToken(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
571 |
} else { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
572 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
573 |
"Configuration.Error.Line.line.expected.expect.", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
574 |
new Integer(linenum), expect, st.sval); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
575 |
} |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
576 |
break; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
577 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
578 |
default: |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
579 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
580 |
"Configuration.Error.Line.line.expected.expect.found.value.", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
581 |
new Integer(linenum), expect, st.sval); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
582 |
} |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
583 |
return value; |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
584 |
} |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
585 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
586 |
private boolean peek(String expect) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
587 |
switch (lookahead) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
588 |
case ',': |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
589 |
return expect.equalsIgnoreCase(","); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
590 |
case ';': |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
591 |
return expect.equalsIgnoreCase(";"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
592 |
case '{': |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
593 |
return expect.equalsIgnoreCase("{"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
594 |
case '}': |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
595 |
return expect.equalsIgnoreCase("}"); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
596 |
default: |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
597 |
return false; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
598 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
599 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
600 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
601 |
private int nextToken() throws IOException { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
602 |
int tok; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
603 |
while ((tok = st.nextToken()) == StreamTokenizer.TT_EOL) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
604 |
linenum++; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
605 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
606 |
return tok; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
607 |
} |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
608 |
|
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
609 |
private InputStream getInputStream(URL url) throws IOException { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
610 |
if ("file".equalsIgnoreCase(url.getProtocol())) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
611 |
// Compatibility notes: |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
612 |
// |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
613 |
// Code changed from |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
614 |
// String path = url.getFile().replace('/', File.separatorChar); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
615 |
// return new FileInputStream(path); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
616 |
// |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
617 |
// The original implementation would search for "/tmp/a%20b" |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
618 |
// when url is "file:///tmp/a%20b". This is incorrect. The |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
619 |
// current codes fix this bug and searches for "/tmp/a b". |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
620 |
// For compatibility reasons, when the file "/tmp/a b" does |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
621 |
// not exist, the file named "/tmp/a%20b" will be tried. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
622 |
// |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
623 |
// This also means that if both file exists, the behavior of |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
624 |
// this method is changed, and the current codes choose the |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
625 |
// correct one. |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
626 |
try { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
627 |
return url.openStream(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
628 |
} catch (Exception e) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
629 |
String file = url.getPath(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
630 |
if (url.getHost().length() > 0) { // For Windows UNC |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
631 |
file = "//" + url.getHost() + file; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
632 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
633 |
if (debugConfig != null) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
634 |
debugConfig.println("cannot read " + url + |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
635 |
", try " + file); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
636 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
637 |
return new FileInputStream(file); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
638 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
639 |
} else { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
640 |
return url.openStream(); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
641 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
642 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
643 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
644 |
private String expand(String value) |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
645 |
throws PropertyExpander.ExpandException, IOException { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
646 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
647 |
if (value.isEmpty()) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
648 |
return value; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
649 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
650 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
651 |
if (!expandProp) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
652 |
return value; |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
653 |
} |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
654 |
String s = PropertyExpander.expand(value); |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
655 |
if (s == null || s.length() == 0) { |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
656 |
throw ioException( |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
657 |
"Configuration.Error.Line.line.system.property.value.expanded.to.empty.value", |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
658 |
new Integer(linenum), value); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
659 |
} |
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
660 |
return s; |
19385
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
661 |
} |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
662 |
|
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
663 |
private IOException ioException(String resourceKey, Object... args) { |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
664 |
MessageFormat form = new MessageFormat(ResourcesMgr.getString |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
665 |
(resourceKey, "sun.security.util.AuthResources")); |
a7b34a4b1fcb
8016848: javax_security/auth/login tests fail in compact 1 and 2 profiles
mullan
parents:
15649
diff
changeset
|
666 |
return new IOException(form.format(args)); |
14923
189882d66a51
8005117: Eliminate dependency from ConfigSpiFile to com.sun.security.auth.login.ConfigFile
mullan
parents:
5506
diff
changeset
|
667 |
} |
2 | 668 |
} |
669 |
} |