|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jetty.policy.loader.PolicyFileScanner
public class PolicyFileScanner
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 org.apache.harmony.security.DefaultPolicy javadoc.
Nested Class Summary | |
---|---|
static class |
PolicyFileScanner.InvalidFormatException
Specific exception class to signal policy file syntax error. |
Constructor Summary | |
---|---|
PolicyFileScanner()
|
Method Summary | |
---|---|
protected java.lang.String |
composeStatus(java.io.StreamTokenizer st)
Formats a detailed description of tokenizer status: current token, current line number, etc. |
protected java.io.StreamTokenizer |
configure(java.io.StreamTokenizer st)
Configures passed tokenizer accordingly to supported syntax. |
protected void |
handleUnexpectedToken(java.io.StreamTokenizer st)
Throws InvalidFormatException with error status: which token is unexpected on which line. |
protected void |
handleUnexpectedToken(java.io.StreamTokenizer st,
java.lang.String message)
Throws InvalidFormatException with detailed diagnostics. |
protected GrantEntry |
readGrantNode(java.io.StreamTokenizer st)
Tries to read grant clause. |
protected KeystoreEntry |
readKeystoreNode(java.io.StreamTokenizer st)
Tries to read keystore clause fields. |
protected java.util.Collection<PermissionEntry> |
readPermissionEntries(java.io.StreamTokenizer st)
Tries to read a list of permission entries. |
protected PrincipalEntry |
readPrincipalNode(java.io.StreamTokenizer st)
Tries to read Principal Node fields. |
void |
scanStream(java.io.Reader r,
java.util.Collection<GrantEntry> grantEntries,
java.util.List<KeystoreEntry> keystoreEntries)
Performs the main parsing loop. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PolicyFileScanner()
Method Detail |
---|
protected java.io.StreamTokenizer configure(java.io.StreamTokenizer st)
public void scanStream(java.io.Reader r, java.util.Collection<GrantEntry> grantEntries, java.util.List<KeystoreEntry> keystoreEntries) throws java.io.IOException, PolicyFileScanner.InvalidFormatException
r
- policy stream readergrantEntries
- a collection to accumulate parsed GrantEntrieskeystoreEntries
- a collection to accumulate parsed KeystoreEntries
java.io.IOException
- if stream reading failed
PolicyFileScanner.InvalidFormatException
- if unexpected or unknown token encounteredprotected KeystoreEntry readKeystoreNode(java.io.StreamTokenizer st) throws java.io.IOException, PolicyFileScanner.InvalidFormatException
"some_keystore_url"[, "keystore_type"];
java.io.IOException
- if stream reading failed
PolicyFileScanner.InvalidFormatException
- if unexpected or unknown token encounteredprotected GrantEntry readGrantNode(java.io.StreamTokenizer st) throws java.io.IOException, PolicyFileScanner.InvalidFormatException
[ [codebase "url"] | [signedby "name1,...,nameN"] | principal ...] ]* { ... }
java.io.IOException
- if stream reading failed
PolicyFileScanner.InvalidFormatException
- if unexpected or unknown token encounteredprotected PrincipalEntry readPrincipalNode(java.io.StreamTokenizer st) throws java.io.IOException, PolicyFileScanner.InvalidFormatException
[ principal_class_name ] "principal_name"Both class and name may be wildcards, wildcard names should not surrounded by quotes.
java.io.IOException
- if stream reading failed
PolicyFileScanner.InvalidFormatException
- if unexpected or unknown token encounteredprotected java.util.Collection<PermissionEntry> readPermissionEntries(java.io.StreamTokenizer st) throws java.io.IOException, PolicyFileScanner.InvalidFormatException
permission permission_class_name [ "target_name" ] [, "action_list"] [, signedby "name1,name2,..."];List is terminated by '}' (closing curly brace) symbol.
java.io.IOException
- if stream reading failed
PolicyFileScanner.InvalidFormatException
- if unexpected or unknown token encounteredprotected java.lang.String composeStatus(java.io.StreamTokenizer st)
protected final void handleUnexpectedToken(java.io.StreamTokenizer st, java.lang.String message) throws PolicyFileScanner.InvalidFormatException
st
- a tokenizer holding the erroneous tokenmessage
- a user-friendly comment, probably explaining expected syntax. Should not be null
- use
the overloaded single-parameter method instead.
PolicyFileScanner.InvalidFormatException
protected final void handleUnexpectedToken(java.io.StreamTokenizer st) throws PolicyFileScanner.InvalidFormatException
st
- a tokenizer holding the erroneous token
PolicyFileScanner.InvalidFormatException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |