public static void main(String arg[]) throws Exception { try (FileReader fileReader = new FileReader(arg[0]); FileWriter fr = new FileWriter(arg[1])) { PolicyParser pp = new PolicyParser(true); pp.read(fileReader); pp.write(fr); } } }
/** * parse a Permission entry */ private PermissionEntry parsePermissionEntry() throws ParsingException, IOException, PropertyExpander.ExpandException { PermissionEntry e = new PermissionEntry(); // Permission match("Permission"); e.permission = match("permission type"); if (peek("\"")) { // Permission name e.name = expand(match("quoted string")); } if (!peek(",")) { return e; } match(","); if (peek("\"")) { e.action = expand(match("quoted string")); if (!peek(",")) { return e; } match(","); } if (peekAndMatch("SignedBy")) { e.signedBy = expand(match("quoted string")); } return e; }
match("grant"); while(!peek("{")) { if (peekAndMatch("Codebase")) { if (e.codeBase != null) throw new ParsingException( ResourcesMgr.getString ("multiple Codebase expressions")); e.codeBase = match("quoted string"); peekAndMatch(","); } else if (peekAndMatch("SignedBy")) { if (e.signedBy != null) throw new ParsingException( ResourcesMgr.getString( "multiple SignedBy expressions")); e.signedBy = match("quoted string"); peekAndMatch(","); } else if (peekAndMatch("Principal")) { if (principals == null) { principals = new LinkedList(); if (peek("\"")) { principalName = match("principal type"); } else {
if (peek("grant")) { GrantEntry ge = parseGrantEntry(); add(ge); } else if (peek("keystore") && keyStoreUrlString==null) { parseKeyStoreEntry(); } else if (peek("keystorePasswordURL") && storePassURL==null) { parseStorePassURL(); } else { match(";");
/** * write out the policy */ public void write(Writer policy) { PrintWriter out = new PrintWriter(new BufferedWriter(policy)); Enumeration enum_ = grantElements(); out.println("/* AUTOMATICALLY GENERATED ON "+ (new java.util.Date()) + "*/"); out.println("/* DO NOT EDIT */"); out.println(); // write the (unexpanded) keystore entry as the first entry of the // policy file if (keyStoreUrlString != null) { writeKeyStoreEntry(out); } if (storePassURL != null) { writeStorePassURL(out); } // write "grant" entries while (enum_.hasMoreElements()) { GrantEntry ge = (GrantEntry) enum_.nextElement(); ge.write(out); out.println(); } out.flush(); }
String name = getPolicyFileName(false); FileReader reader = null; PolicyParser parser = new PolicyParser(false); try { captureFileTime(false); reader = new FileReader(name); parser.read(reader); } catch (java.io.FileNotFoundException fnf) { Enumeration grants = parser.grantElements(); while (grants.hasMoreElements()) { GrantEntry grant = (GrantEntry) grants.nextElement();
PolicyParser parser = new PolicyParser(false); grant.add(entry); parser.add(grant); grant.add(permEntry); parser.add(grant); PolicyParser excludedParser = new PolicyParser(false); grant.add(entry); excludedParser.add(grant);
private String expand(String value) throws PropertyExpander.ExpandException { return expand(value, false); }
match("grant"); while(!peek("{")) { if (peekAndMatch("Codebase")) { if (e.codeBase != null) throw new ParsingException( ResourcesMgr.getString ("multiple Codebase expressions")); e.codeBase = match("quoted string"); peekAndMatch(","); } else if (peekAndMatch("SignedBy")) { if (e.signedBy != null) throw new ParsingException( ResourcesMgr.getString( "multiple SignedBy expressions")); e.signedBy = match("quoted string"); peekAndMatch(","); } else if (peekAndMatch("Principal")) { if (principals == null) { principals = new LinkedList(); if (peek("\"")) { principalName = match("principal type"); } else {
if (peek("grant")) { GrantEntry ge = parseGrantEntry(); add(ge); } else if (peek("keystore") && keyStoreUrlString==null) { parseKeyStoreEntry(); } else if (peek("keystorePasswordURL") && storePassURL==null) { parseStorePassURL(); } else { match(";");
/** * write out the policy */ public void write(Writer policy) { PrintWriter out = new PrintWriter(new BufferedWriter(policy)); Enumeration enum_ = grantElements(); out.println("/* AUTOMATICALLY GENERATED ON "+ (new java.util.Date()) + "*/"); out.println("/* DO NOT EDIT */"); out.println(); // write the (unexpanded) keystore entry as the first entry of the // policy file if (keyStoreUrlString != null) { writeKeyStoreEntry(out); } if (storePassURL != null) { writeStorePassURL(out); } // write "grant" entries while (enum_.hasMoreElements()) { GrantEntry ge = (GrantEntry) enum_.nextElement(); ge.write(out); out.println(); } out.flush(); }
String name = getPolicyFileName(false); FileReader reader = null; PolicyParser parser = new PolicyParser(false); try { captureFileTime(false); reader = new FileReader(name); parser.read(reader); } catch (java.io.FileNotFoundException fnf) { Enumeration grants = parser.grantElements(); while (grants.hasMoreElements()) { GrantEntry grant = (GrantEntry) grants.nextElement();
PolicyParser parser = new PolicyParser(false); grant.add(entry); parser.add(grant); grant.add(permEntry); parser.add(grant); grant.add(permEntry); parser.add(grant); if(logger.isLoggable (Level.FINE)){ logger.fine("JACC Policy Provider: added role grant for any authenticated user"); PolicyParser excludedParser = new PolicyParser(false); grant.add(entry); excludedParser.add(grant);
private String expand(String value) throws PropertyExpander.ExpandException { return expand(value, false); }
/** * parse a Permission entry */ private PermissionEntry parsePermissionEntry() throws ParsingException, IOException, PropertyExpander.ExpandException { PermissionEntry e = new PermissionEntry(); // Permission match("Permission"); e.permission = match("permission type"); if (peek("\"")) { // Permission name e.name = expand(match("quoted string")); } if (!peek(",")) { return e; } match(","); if (peek("\"")) { e.action = expand(match("quoted string")); if (!peek(",")) { return e; } match(","); } if (peekAndMatch("SignedBy")) { e.signedBy = expand(match("quoted string")); } return e; }
public static void main(String arg[]) throws Exception { PolicyParser pp = new PolicyParser(true); pp.read(new FileReader(arg[0])); FileWriter fr = new FileWriter(arg[1]); pp.write(fr); fr.close(); } }