Skip to content

Commit 7475674

Browse files
committed
Our own parser
1 parent 507cab5 commit 7475674

File tree

6 files changed

+249
-458
lines changed

6 files changed

+249
-458
lines changed

libs/agent-sm/agent-policy/src/main/java/org/opensearch/secure_sm/policy/PolicyFile.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ private boolean init(URL policy, PolicyInfo newInfo) {
198198

199199
try (InputStreamReader isr = getInputStreamReader(getInputStream(policy))) {
200200

201-
PolicyParser pp = new PolicyParser(expandProperties);
201+
PolicyParser pp = new PolicyParser();
202202
pp.read(isr);
203203

204-
Enumeration<PolicyParser.GrantEntry> enum_ = pp.grantElements();
204+
Enumeration<PolicyParser.GrantNode> enum_ = pp.grantElements();
205205
while (enum_.hasMoreElements()) {
206-
PolicyParser.GrantEntry ge = enum_.nextElement();
206+
PolicyParser.GrantNode ge = enum_.nextElement();
207207
addGrantEntry(ge, newInfo);
208208
}
209209
return true;
@@ -249,7 +249,7 @@ private void initStaticPolicy(final PolicyInfo newInfo) {
249249
*
250250
* @return null if signedBy alias is not recognized
251251
*/
252-
private CodeSource getCodeSource(PolicyParser.GrantEntry ge, PolicyInfo newInfo) throws java.net.MalformedURLException {
252+
private CodeSource getCodeSource(PolicyParser.GrantNode ge, PolicyInfo newInfo) throws java.net.MalformedURLException {
253253
Certificate[] certs = null;
254254
URL location;
255255

@@ -262,17 +262,17 @@ private CodeSource getCodeSource(PolicyParser.GrantEntry ge, PolicyInfo newInfo)
262262
/**
263263
* Add one policy entry to the list.
264264
*/
265-
private void addGrantEntry(PolicyParser.GrantEntry ge, PolicyInfo newInfo) {
265+
private void addGrantEntry(PolicyParser.GrantNode ge, PolicyInfo newInfo) {
266266

267267
try {
268268
CodeSource codesource = getCodeSource(ge, newInfo);
269269
// skip if signedBy alias was unknown...
270270
if (codesource == null) return;
271271

272272
PolicyEntry entry = new PolicyEntry(codesource);
273-
Enumeration<PolicyParser.PermissionEntry> enum_ = ge.permissionElements();
273+
Enumeration<PolicyParser.PermissionNode> enum_ = ge.permissionElements();
274274
while (enum_.hasMoreElements()) {
275-
PolicyParser.PermissionEntry pe = enum_.nextElement();
275+
PolicyParser.PermissionNode pe = enum_.nextElement();
276276

277277
try {
278278
// perform ${{ ... }} expansions within permission name
@@ -617,7 +617,7 @@ private static String canonPath(String path) throws IOException {
617617
}
618618
}
619619

620-
private void expandPermissionName(PolicyParser.PermissionEntry pe) throws Exception {
620+
private void expandPermissionName(PolicyParser.PermissionNode pe) throws Exception {
621621
// short cut the common case
622622
if (pe.name == null || pe.name.indexOf("${{", 0) == -1) {
623623
return;

0 commit comments

Comments
 (0)