121 |
super(name); |
super(name); |
122 |
if (actions == null) |
if (actions == null) |
123 |
throw new IllegalArgumentException(); |
throw new IllegalArgumentException(); |
124 |
setActions(actions.toLowerCase()); |
setActions(actions); |
125 |
} |
} |
126 |
|
|
127 |
/** |
/** |
134 |
*/ |
*/ |
135 |
private void setActions(String str) |
private void setActions(String str) |
136 |
{ |
{ |
137 |
|
// Initialising the class java.util.Locale ... |
138 |
|
// tries to initialise the Locale.defaultLocale static |
139 |
|
// which calls System.getProperty, |
140 |
|
// which calls SecurityManager.checkPropertiesAccess, |
141 |
|
// which creates a PropertyPermission with action "read,write", |
142 |
|
// which calls setActions("read,write"). |
143 |
|
// If we now were to call toLowerCase on 'str', |
144 |
|
// this would call Locale.getDefault() which returns null |
145 |
|
// because Locale.defaultLocale hasn't been set yet |
146 |
|
// then toLowerCase will fail with a null pointer exception. |
147 |
|
// |
148 |
|
// The solution is to take a punt on 'str' being lower case, and |
149 |
|
// test accordingly. If that fails, we convert 'str' to lower case |
150 |
|
// and try the tests again. |
151 |
if ("read".equals(str)) |
if ("read".equals(str)) |
152 |
actions = READ; |
actions = READ; |
153 |
else if ("write".equals(str)) |
else if ("write".equals(str)) |
154 |
actions = WRITE; |
actions = WRITE; |
155 |
else if ("read,write".equals(str) || "write,read".equals(str)) |
else if ("read,write".equals(str) || "write,read".equals(str)) |
156 |
actions = READ | WRITE; |
actions = READ | WRITE; |
157 |
else |
else { |
158 |
throw new IllegalArgumentException("illegal action " + str); |
String lstr = str.toLowerCase(); |
159 |
|
if ("read".equals(lstr)) |
160 |
|
actions = READ; |
161 |
|
else if ("write".equals(lstr)) |
162 |
|
actions = WRITE; |
163 |
|
else if ("read,write".equals(lstr) || "write,read".equals(lstr)) |
164 |
|
actions = READ | WRITE; |
165 |
|
else |
166 |
|
throw new IllegalArgumentException("illegal action " + str); |
167 |
|
} |
168 |
} |
} |
169 |
|
|
170 |
/** |
/** |