FileDocCategorySizeDatePackage
ContextAccessController.javaAPI DocApache Tomcat 6.0.143659Fri Jul 20 04:20:34 BST 2007org.apache.naming

ContextAccessController

public class ContextAccessController extends Object
Handles the access control on the JNDI contexts.
author
Remy Maucherat
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
private static Hashtable
readOnlyContexts
Catalina context names on which writing is not allowed.
private static Hashtable
securityTokens
Security tokens repository.
Constructors Summary
Methods Summary
public static booleancheckSecurityToken(java.lang.Object name, java.lang.Object token)
Check a submitted security token. The submitted token must be equal to the token present in the repository. If no token is present for the context, then returns true.

param
name Name of the context
param
token Submitted security token

        Object refToken = securityTokens.get(name);
        if (refToken == null)
            return (true);
        if ((refToken != null) && (refToken.equals(token)))
            return (true);
        return (false);
    
public static booleanisWritable(java.lang.Object name)
Returns if a context is writable.

param
name Name of the context

        return !(readOnlyContexts.containsKey(name));
    
public static voidsetReadOnly(java.lang.Object name)
Set whether or not a context is writable.

param
name Name of the context

        readOnlyContexts.put(name, name);
    
public static voidsetSecurityToken(java.lang.Object name, java.lang.Object token)
Set a security token for a context. Can be set only once.

param
name Name of the context
param
token Security token



    // --------------------------------------------------------- Public Methods


                                
           
        if ((!securityTokens.containsKey(name)) && (token != null)) {
            securityTokens.put(name, token);
        }
    
public static voidsetWritable(java.lang.Object name, java.lang.Object token)
Allow writing to a context.

param
name Name of the context
param
token Security token

        if (checkSecurityToken(name, token))
            readOnlyContexts.remove(name);
    
public static voidunsetSecurityToken(java.lang.Object name, java.lang.Object token)
Remove a security token for a context.

param
name Name of the context
param
token Security token

        if (checkSecurityToken(name, token)) {
            securityTokens.remove(name);
        }