| java.lang.Object org.apache.harmony.security.DefaultPolicyScanner
DefaultPolicyScanner | public class DefaultPolicyScanner (Code) | | This is a basic high-level tokenizer of policy files. It takes in a stream,
analyzes data read from it and returns a set of structured tokens.
This implementation recognizes text files, consisting of clauses with the
following syntax:
keystore "some_keystore_url", "keystore_type";
grant [SignedBy "signer_names"] [, CodeBase "URL"]
[, Principal [principal_class_name] "principal_name"]
[, Principal [principal_class_name] "principal_name"] ... {
permission permission_class_name [ "target_name" ] [, "action"]
[, SignedBy "signer_names"];
permission ...
};
For semantical details of this format, see the
org.apache.harmony.security.DefaultPolicy default policy description .
Keywords are case-insensitive in contrast to quoted string literals.
Comma-separation rule is quite forgiving, most commas may be just omitted.
Whitespaces, line- and block comments are ignored. Symbol-level tokenization
is delegated to java.io.StreamTokenizer.
This implementation is effectively thread-safe, as it has no field references
to data being processed (that is, passes all the data as method parameters).
See Also: org.apache.harmony.security.fortress.DefaultPolicyParser |
Inner Class :public static class InvalidFormatException extends Exception | |
Inner Class :public static class KeystoreEntry | |
Inner Class :public static class GrantEntry | |
Inner Class :public static class PrincipalEntry | |
Inner Class :public static class PermissionEntry | |
composeStatus | protected String composeStatus(StreamTokenizer st)(Code) | | Formats a detailed description of tokenizer status: current token,
current line number, etc.
|
handleUnexpectedToken | final protected void handleUnexpectedToken(StreamTokenizer st, String message) throws InvalidFormatException(Code) | | Throws InvalidFormatException with detailed diagnostics.
Parameters: st - a tokenizer holding the erroneous token Parameters: message - a user-friendly comment, probably explaining expected syntax.Should not be null - use the overloadedsingle-parameter method instead. |
handleUnexpectedToken | final protected void handleUnexpectedToken(StreamTokenizer st) throws InvalidFormatException(Code) | | Throws InvalidFormatException with error status: which token is
unexpected on which line.
Parameters: st - a tokenizer holding the erroneous token |
readGrantEntry | protected GrantEntry readGrantEntry(StreamTokenizer st) throws IOException, InvalidFormatException(Code) | | Tries to read grant clause.
First, it reads codebase , signedby , principal
entries till the '{' (opening curly brace) symbol. Then it calls
readPermissionEntries() method to read the permissions of this clause.
Principal entries (if any) are read by invoking readPrincipalEntry()
method, obtained PrincipalEntries are accumulated.
The expected syntax is
[ [codebase "url"] | [signedby "name1,...,nameN"] |
principal ...] ]* { ... }
successfully parsed GrantEntry throws: IOException - if stream reading failed throws: InvalidFormatException - if unexpected or unknown token encountered |
readKeystoreEntry | protected KeystoreEntry readKeystoreEntry(StreamTokenizer st) throws IOException, InvalidFormatException(Code) | | Tries to read keystore clause fields. The expected syntax is
"some_keystore_url"[, "keystore_type"];
successfully parsed KeystoreEntry throws: IOException - if stream reading failed throws: InvalidFormatException - if unexpected or unknown token encountered |
readPermissionEntries | protected Collection<PermissionEntry> readPermissionEntries(StreamTokenizer st) throws IOException, InvalidFormatException(Code) | | Tries to read a list of permission entries. The expected syntax
is
permission permission_class_name
[ "target_name" ] [, "action_list"]
[, signedby "name1,name2,..."];
List is terminated by '}' (closing curly brace) symbol.
collection of successfully parsed PermissionEntries throws: IOException - if stream reading failed throws: InvalidFormatException - if unexpected or unknown token encountered |
readPrincipalEntry | protected PrincipalEntry readPrincipalEntry(StreamTokenizer st) throws IOException, InvalidFormatException(Code) | | Tries to read Principal entry fields. The expected syntax is
[ principal_class_name ] "principal_name"
Both class and name may be wildcards, wildcard names should not
surrounded by quotes.
successfully parsed PrincipalEntry throws: IOException - if stream reading failed throws: InvalidFormatException - if unexpected or unknown token encountered |
scanStream | public void scanStream(Reader r, Collection<GrantEntry> grantEntries, List<KeystoreEntry> keystoreEntries) throws IOException, InvalidFormatException(Code) | | Performs the main parsing loop. Starts with creating and configuring a
StreamTokenizer instance; then tries to recognize keystore or
grant keyword. When found, invokes read method corresponding to
the clause and collects result to the passed collection.
Parameters: r - policy stream reader Parameters: grantEntries - a collection to accumulate parsed GrantEntries Parameters: keystoreEntries - a collection to accumulate parsed KeystoreEntries throws: IOException - if stream reading failed throws: InvalidFormatException - if unexpected or unknown token encountered |
|
|