FileDocCategorySizeDatePackage
ContextAccessController.javaAPI DocGlassfish v2 API4734Fri May 04 22:33:00 BST 2007org.apache.naming

ContextAccessController

public class ContextAccessController extends Object
Handles the access control on the JNDI contexts.
author
Remy Maucherat
version
$Revision: 1.3 $ $Date: 2007/05/05 05:32:59 $

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
context 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
context 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
context Security token

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