@@ -27,19 +27,6 @@ public class PolicyParser {
27
27
28
28
private StreamTokenizer streamTokenizer ;
29
29
private int nextToken ;
30
- private boolean expandProp = false ;
31
-
32
- private String expand (String value ) throws PropertyExpander .ExpandException {
33
- return expand (value , false );
34
- }
35
-
36
- private String expand (String value , boolean encodeURL ) throws PropertyExpander .ExpandException {
37
- if (!expandProp ) {
38
- return value ;
39
- } else {
40
- return PropertyExpander .expand (value , encodeURL );
41
- }
42
- }
43
30
44
31
/**
45
32
* Creates a PolicyParser object.
@@ -49,22 +36,17 @@ public PolicyParser() {
49
36
grantEntries = new Vector <>();
50
37
}
51
38
52
- public PolicyParser (boolean expandProp ) {
53
- this ();
54
- this .expandProp = expandProp ;
55
- }
56
-
57
39
/**
58
40
* Reads a policy configuration into the Policy object using a
59
41
* Reader object.
60
42
*
61
43
* @param policy the policy Reader object.
62
44
*
63
45
* @exception ParsingException if the policy configuration contains
64
- * a syntax error.
46
+ * a syntax error.
65
47
*
66
- * @exception IOException if an error occurs while reading the policy
67
- * configuration.
48
+ * @exception IOException if an error occurs while reading the policy
49
+ * configuration.
68
50
*/
69
51
70
52
public void read (Reader policy ) throws ParsingException , IOException {
@@ -74,17 +56,17 @@ public void read(Reader policy) throws ParsingException, IOException {
74
56
75
57
/*
76
58
* Configure the stream tokenizer:
77
- * Recognize strings between "..."
78
- * Don't convert words to lowercase
79
- * Recognize both C-style and C++-style comments
80
- * Treat end-of-line as white space, not as a token
59
+ * Recognize strings between "..."
60
+ * Don't convert words to lowercase
61
+ * Recognize both C-style and C++-style comments
62
+ * Treat end-of-line as white space, not as a token
81
63
*/
82
64
streamTokenizer = Tokenizer .configureTokenizer (policy );
83
65
84
66
/*
85
- * The main parsing loop. The loop is executed once
86
- * for each entry in the config file. The entries
87
- * are delimited by semicolons. Once we've read in
67
+ * The main parsing loop. The loop is executed once
68
+ * for each entry in the config file. The entries
69
+ * are delimited by semicolons. Once we've read in
88
70
* the information for an entry, go ahead and try to
89
71
* add it to the policy vector.
90
72
*
@@ -94,7 +76,6 @@ public void read(Reader policy) throws ParsingException, IOException {
94
76
while (nextToken != StreamTokenizer .TT_EOF ) {
95
77
if (peekTokenOnMatch ("grant" )) {
96
78
ge = parseGrantEntry ();
97
- // could be null if we couldn't expand a property
98
79
if (ge != null ) add (ge );
99
80
} else {
100
81
// error?
@@ -226,7 +207,7 @@ private GrantEntry parseGrantEntry() throws ParsingException, IOException {
226
207
try {
227
208
PermissionEntry pe = parsePermissionEntry ();
228
209
e .add (pe );
229
- } catch (PropertyExpander . ExpandException peee ) {
210
+ } catch (ParsingException parseException ) {
230
211
skipEntry (); // BugId 4219343
231
212
}
232
213
consumeTokenOnMatch (";" );
@@ -236,12 +217,8 @@ private GrantEntry parseGrantEntry() throws ParsingException, IOException {
236
217
}
237
218
consumeTokenOnMatch ("}" );
238
219
239
- try {
240
- if (e .codeBase != null ) {
241
- e .codeBase = expand (e .codeBase , true ).replace (File .separatorChar , '/' );
242
- }
243
- } catch (PropertyExpander .ExpandException peee ) {
244
- return null ;
220
+ if (e .codeBase != null ) {
221
+ e .codeBase = e .codeBase .replace (File .separatorChar , '/' );
245
222
}
246
223
247
224
return (ignoreEntry ) ? null : e ;
@@ -250,7 +227,7 @@ private GrantEntry parseGrantEntry() throws ParsingException, IOException {
250
227
/**
251
228
* parse a Permission entry
252
229
*/
253
- private PermissionEntry parsePermissionEntry () throws ParsingException , IOException , PropertyExpander . ExpandException {
230
+ private PermissionEntry parsePermissionEntry () throws ParsingException , IOException {
254
231
PermissionEntry e = new PermissionEntry ();
255
232
256
233
// Permission
@@ -259,7 +236,7 @@ private PermissionEntry parsePermissionEntry() throws ParsingException, IOExcept
259
236
260
237
if (peekTokenOnMatch ("\" " )) {
261
238
// Permission name
262
- e .name = expand ( consumeTokenOnMatch ("quoted string" ) );
239
+ e .name = consumeTokenOnMatch ("quoted string" );
263
240
}
264
241
265
242
if (!peekTokenOnMatch ("," )) {
@@ -268,7 +245,7 @@ private PermissionEntry parsePermissionEntry() throws ParsingException, IOExcept
268
245
consumeTokenOnMatch ("," );
269
246
270
247
if (peekTokenOnMatch ("\" " )) {
271
- e .action = expand ( consumeTokenOnMatch ("quoted string" ) );
248
+ e .action = consumeTokenOnMatch ("quoted string" );
272
249
if (!peekTokenOnMatch ("," )) {
273
250
return e ;
274
251
}
0 commit comments