< prev index next >

src/share/classes/com/sun/security/auth/PolicyParser.java

Print this page
rev 1461 : 6987827: security/util/Resources.java needs improvement
Reviewed-by: valeriep
rev 1466 : 7019937: Translatability bug - Remove Unused String - String ID , read end of file
7019938: Translatability bug - Remove Unused String - String ID can not specify Principal with a
7019940: Translatability bug - Remove unused string - String ID: provided null name
7019942: Translatability bug - String ID: trustedCertEntry,
7019945: Translatability bug - Translatability issue - String ID: * has NOT been verified! In order to veri
7019947: Translatability bug - Translatability issue - String ID: * The integrity of the information stored i
7019949: Translatability bug - Translatability issue - String ID: * you must provide your keystore password.
Reviewed-by: weijun, wetmore

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -28,17 +28,18 @@
 import java.io.*;
 import java.lang.RuntimePermission;
 import java.net.MalformedURLException;
 import java.net.SocketPermission;
 import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.text.MessageFormat;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.LinkedList;
 import java.util.ListIterator;
 import java.util.Vector;
 import java.util.StringTokenizer;
-import java.security.GeneralSecurityException;
 import sun.security.util.PropertyExpander;
 
 /**
  * The policy for a Java runtime (specifying
  * which permissions are available for code from various principals)

@@ -298,11 +299,11 @@
 
         if (peek("\"")) {
             keyStoreType = match("quoted string");
         } else {
             throw new ParsingException(st.lineno(),
-                        rb.getString("expected keystore type"));
+                        rb.getString("expected.keystore.type"));
         }
     }
 
     /**
      * writes the (unexpanded) keystore entry

@@ -366,12 +367,12 @@
                     if (debug != null)
                         debug.println("disallowing principal that has " +
                                 "WILDCARD class but no WILDCARD name");
                     throw new ParsingException
                         (st.lineno(),
-                        rb.getString("can not specify Principal with a ") +
-                        rb.getString("wildcard class without a wildcard name"));
+                        rb.getString("can.not.specify.Principal.with.a." +
+                                     "wildcard.class.without.a.wildcard.name"));
                 }
 
                 try {
                     principalName = expand(principalName);
                     principals.add

@@ -387,19 +388,19 @@
                 }
                 peekAndMatch(",");
             } else {
                 throw new
                  ParsingException(st.lineno(),
-                        rb.getString("expected codeBase or SignedBy"));
+                        rb.getString("expected.codeBase.or.SignedBy"));
             }
         }
 
         // disallow non principal-based grant entries
         if (principals == null) {
             throw new ParsingException
                 (st.lineno(),
-                rb.getString("only Principal-based grant entries permitted"));
+                rb.getString("only.Principal.based.grant.entries.permitted"));
         }
 
         e.principals = principals;
         match("{");
 

@@ -414,11 +415,11 @@
                 }
                 match(";");
             } else {
                 throw new
                     ParsingException(st.lineno(),
-                    rb.getString("expected permission entry"));
+                    rb.getString("expected.permission.entry"));
             }
         }
         match("}");
 
         try {

@@ -520,16 +521,17 @@
         String value = null;
 
         switch (lookahead) {
         case StreamTokenizer.TT_NUMBER:
             throw new ParsingException(st.lineno(), expect,
-                                        rb.getString("number ") +
+                                        rb.getString("number.") +
                                         String.valueOf(st.nval));
         case StreamTokenizer.TT_EOF:
-           throw new ParsingException
-                (rb.getString("expected ") + expect +
-                rb.getString(", read end of file"));
+            MessageFormat form = new MessageFormat(
+                    rb.getString("expected.expect.read.end.of.file."));
+            Object[] source = {expect};
+            throw new ParsingException(form.format(source));
         case StreamTokenizer.TT_WORD:
             if (expect.equalsIgnoreCase(st.sval)) {
                 lookahead = st.nextToken();
             } else if (expect.equalsIgnoreCase("permission type")) {
                 value = st.sval;

@@ -601,15 +603,15 @@
     {
       while(lookahead != ';') {
         switch (lookahead) {
         case StreamTokenizer.TT_NUMBER:
             throw new ParsingException(st.lineno(), ";",
-                                       rb.getString("number ") +
+                                       rb.getString("number.") +
                                         String.valueOf(st.nval));
         case StreamTokenizer.TT_EOF:
           throw new ParsingException
-                (rb.getString("expected ';', read end of file"));
+                (rb.getString("expected.read.end.of.file"));
         default:
           lookahead = st.nextToken();
         }
       }
     }

@@ -940,17 +942,17 @@
         public ParsingException(String msg) {
             super(msg);
         }
 
         public ParsingException(int line, String msg) {
-            super(rb.getString("line ") + line + rb.getString(": ") + msg);
+            super(rb.getString("line.") + line + rb.getString("COLON") + msg);
         }
 
         public ParsingException(int line, String expect, String actual) {
-            super(rb.getString("line ") + line + rb.getString(": expected '") +
-                expect + rb.getString("', found '") + actual +
-                rb.getString("'"));
+            super(rb.getString("line.") + line + rb.getString(".expected.") +
+                expect + rb.getString(".found.") + actual +
+                rb.getString("QUOTE"));
         }
     }
 
     public static void main(String arg[]) throws Exception {
         PolicyParser pp = new PolicyParser(true);
< prev index next >