|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.container.imp.AbstractParseListener
public abstract class AbstractParseListener
Skeleton of policy file parse listener.
It provides default implementation of all parsing callback events including keystore URL resolving, protection domains creation and etc.
If provides with getter methods getAllKeyStores()
and
getProtectionDomains()
to obtain all parsed keystores and
protection domains.
One has to implement PolicyParseListener.getContainerFactory()
in order to complete the interfaces.
created on August 8, 2005
AbstractPolicyFactory
Nested Class Summary | |
---|---|
class |
AbstractParseListener.GrantEntry
grant entry : temporary data object used to store grant information during the parsing process created on August 8, 2005 |
Constructor Summary | |
---|---|
AbstractParseListener()
|
Method Summary | |
---|---|
void |
beginParsing()
callback to indicate that parsing process begins initialize the vectors |
void |
endGrant()
callback when grant definition is over add last grant to the collection of protection domains |
void |
endParsing()
callback to indicate that parsing process is over builds the list of protection domains out all parsed grant entries |
void |
endPolicyFile()
callback when policy file parsing is over clear the url |
protected java.util.Vector |
getAllKeyStores()
|
protected java.util.Vector |
getAllPolicies()
|
java.security.KeyStore[] |
getKeyStores()
|
java.security.ProtectionDomain[] |
getProtectionDomains()
|
protected java.security.cert.Certificate |
lookupCertificate(java.lang.String alias)
search all currently known keystores for certificate with given alias returns null if does not exists |
protected java.security.cert.Certificate[] |
lookupCertificatesList(java.lang.String aliases)
search all currently known keystores for certificates with given aliases returns empty array if no matching found |
void |
newGrant(java.lang.String signedbyAliases,
java.lang.String codebaseUrl)
callback when new grant definition is encountered |
void |
newKeystore(java.lang.String ksUrl,
java.lang.String ksType)
callback when new keystore definition is encountered instantiate the keystore and add it to the collection of keystores Treats ksUrl as following:
relative URL, adds it to the policy file's URL in place of
last component name
absolute URL, tries to instantiate a new URL from that string
relative file path, tries to instantiate parent File out of
policy file URL and add ksUrl as child to it
absolute file path, tries to instantiate new File out of ksUrl
If all this fails it will throw FileNotFoundException . |
void |
newPermission(java.lang.String className,
java.lang.String target,
java.lang.String action,
java.lang.String signedbyAliases)
callback when new permission grant is encountered signedbyAliases is ignored |
void |
newPolicyFile(java.net.URL url)
callback when new policy file parsing starts remember the url |
protected java.io.InputStream |
newUrlInputSteam(java.lang.String strUrl)
instantiates new InputStream out of given URL |
protected java.lang.String |
parseEnvVars(java.lang.String str)
parse given text and substitute all environment variables with their values (marked in in the format ${env-name} ). |
protected java.lang.String |
replaceCurrentUrlPosition(java.net.URL url,
java.lang.String newFile)
replace last file position in the given URL with new file |
protected java.io.InputStream |
resolveKsInputSteam(java.lang.String ksUrl)
locate keystore's input stream or throw FileNotFoundException . |
protected void |
spreadDefaultGrants()
this method is called after the parse of a policy file to kind of "spread" default permissions to all grant entries (i.e. protection domains) |
protected java.lang.String |
toExternalForm(java.net.URL u,
java.lang.String newPath)
Converts a URL of a specific protocol to a
String . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.container.PolicyParseListener |
---|
getContainerFactory |
Constructor Detail |
---|
public AbstractParseListener()
Method Detail |
---|
protected java.util.Vector getAllPolicies()
protected java.util.Vector getAllKeyStores()
public java.security.ProtectionDomain[] getProtectionDomains()
endParsing()
has been calledpublic java.security.KeyStore[] getKeyStores()
endParsing()
has been calledprotected java.io.InputStream newUrlInputSteam(java.lang.String strUrl)
strUrl
-
protected java.lang.String toExternalForm(java.net.URL u, java.lang.String newPath)
URL
of a specific protocol to a
String
.
u
- the URL.
URL
argument.protected java.lang.String replaceCurrentUrlPosition(java.net.URL url, java.lang.String newFile)
url
- newFile
-
protected java.io.InputStream resolveKsInputSteam(java.lang.String ksUrl) throws java.io.FileNotFoundException
FileNotFoundException
.
Treats ksUrl
as following:
FileNotFoundException
.
ksUrl
-
java.io.FileNotFoundException
public void beginParsing()
initialize the vectors
beginParsing
in interface PolicyParseListener
public void endParsing()
builds the list of protection domains out all parsed grant entries
endParsing
in interface PolicyParseListener
public void newPolicyFile(java.net.URL url)
remember the url
newPolicyFile
in interface PolicyParseListener
url
- of the policy filepublic void endPolicyFile()
clear the url
endPolicyFile
in interface PolicyParseListener
public void newKeystore(java.lang.String ksUrl, java.lang.String ksType) throws java.io.FileNotFoundException, java.security.KeyStoreException, java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
instantiate the keystore and add it to the collection of keystores
Treats ksUrl
as following:
FileNotFoundException
.
newKeystore
in interface PolicyParseListener
ksUrl
- is mandatory, url is relative to the policy file locationksType
- is optional, null if not present in the policy file
java.io.FileNotFoundException
- if the keystore does not exists
java.security.KeyStoreException
- while opening the keystore
java.io.IOException
- while reading the keystore
java.security.NoSuchAlgorithmException
- while reading the certificates
java.security.cert.CertificateException
- while reading the certificatespublic void newGrant(java.lang.String signedbyAliases, java.lang.String codebaseUrl) throws java.net.MalformedURLException, java.security.KeyStoreException
newGrant
in interface PolicyParseListener
signedbyAliases
- is optional, list of certificate aliases separated by semicoloncodebaseUrl
- is optional, url pattern compatible with Policy File specification
java.net.MalformedURLException
java.security.KeyStoreException
public void endGrant()
add last grant to the collection of protection domains
endGrant
in interface PolicyParseListener
public void newPermission(java.lang.String className, java.lang.String target, java.lang.String action, java.lang.String signedbyAliases) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
signedbyAliases is ignored
newPermission
in interface PolicyParseListener
className
- is mandatory, fully qualified class nametarget
- is mandatory depending on the permission typeaction
- is mandatory depending on the permission typesignedbyAliases
- is optional, a list of certificate aliased separated by semicolon
java.lang.ClassNotFoundException
- if the permission class if not found
java.lang.NoSuchMethodException
- if the permission class does not have
suitable constructor
java.lang.SecurityException
- while instantiating a new permission
java.lang.InstantiationException
- while instantiating a new permission
java.lang.IllegalAccessException
- while instantiating a new permission
java.lang.IllegalArgumentException
- while instantiating a new permission
java.lang.reflect.InvocationTargetException
- while instantiating a new permissionprotected java.security.cert.Certificate lookupCertificate(java.lang.String alias) throws java.security.KeyStoreException
alias
-
java.security.KeyStoreException
protected java.security.cert.Certificate[] lookupCertificatesList(java.lang.String aliases) throws java.security.KeyStoreException
aliases
-
java.security.KeyStoreException
- if keystore not initialized or no alias by given nameprotected java.lang.String parseEnvVars(java.lang.String str)
${env-name}
).
str
-
protected void spreadDefaultGrants()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |