FileDocCategorySizeDatePackage
SecurityCollection.javaAPI DocGlassfish v2 API9206Fri May 04 22:32:08 BST 2007org.apache.catalina.deploy

SecurityCollection

public class SecurityCollection extends Object implements Serializable
Representation of a web resource collection for a web application's security constraint, as represented in a <web-resource-collection> element in the deployment descriptor.

WARNING: It is assumed that instances of this class will be created and modified only within the context of a single thread, before the instance is made visible to the remainder of the application. After that, only read access is expected. Therefore, none of the read and write access within this class is synchronized.

author
Craig R. McClanahan
version
$Revision: 1.3 $ $Date: 2007/05/05 05:32:08 $

Fields Summary
private String
description
Description of this web resource collection.
private String[]
methods
The HTTP methods covered by this web resource collection.
private String
name
The name of this web resource collection.
private String[]
patterns
The URL patterns protected by this security collection.
Constructors Summary
public SecurityCollection()
Construct a new security collection instance with default values.


        this(null, null);

    
public SecurityCollection(String name)
Construct a new security collection instance with specified values.

param
name Name of this security collection


        this(name, null);

    
public SecurityCollection(String name, String description)
Construct a new security collection instance with specified values.

param
name Name of this security collection
param
description Description of this security collection


        super();
        setName(name);
        setDescription(description);

    
Methods Summary
public voidaddMethod(java.lang.String method)
Add an HTTP request method to be part of this web resource collection.


        if (method == null)
            return;
        String results[] = new String[methods.length + 1];
        for (int i = 0; i < methods.length; i++)
            results[i] = methods[i];
        results[methods.length] = method;
        methods = results;

    
public voidaddPattern(java.lang.String pattern)
Add a URL pattern to be part of this web resource collection.


        if (pattern == null)
            return;
        pattern = RequestUtil.URLDecode(pattern);
        String results[] = new String[patterns.length + 1];
        for (int i = 0; i < patterns.length; i++)
            results[i] = patterns[i];
        results[patterns.length] = pattern;
        patterns = results;

    
public booleanfindMethod(java.lang.String method)
Return true if the specified HTTP request method is part of this web resource collection.

param
method Request method to check


        if (methods.length == 0)
            return (true);
        for (int i = 0; i < methods.length; i++) {
            if (methods[i].equals(method))
                return (true);
        }
        return (false);

    
public java.lang.String[]findMethods()
Return the set of HTTP request methods that are part of this web resource collection, or a zero-length array if all request methods are included.


        return (methods);

    
public booleanfindPattern(java.lang.String pattern)
Is the specified pattern part of this web resource collection?

param
pattern Pattern to be compared


        for (int i = 0; i < patterns.length; i++) {
            if (patterns[i].equals(pattern))
                return (true);
        }
        return (false);

    
public java.lang.String[]findPatterns()
Return the set of URL patterns that are part of this web resource collection. If none have been specified, a zero-length array is returned.


        return (patterns);

    
public java.lang.StringgetDescription()
Return the description of this web resource collection.



    // ------------------------------------------------------------- Properties


                 
       

        return (this.description);

    
public java.lang.StringgetName()
Return the name of this web resource collection.


        return (this.name);

    
public voidremoveMethod(java.lang.String method)
Remove the specified HTTP request method from those that are part of this web resource collection.

param
method Request method to be removed


        if (method == null)
            return;
        int n = -1;
        for (int i = 0; i < methods.length; i++) {
            if (methods[i].equals(method)) {
                n = i;
                break;
            }
        }
        if (n >= 0) {
            int j = 0;
            String results[] = new String[methods.length - 1];
            for (int i = 0; i < methods.length; i++) {
                if (i != n)
                    results[j++] = methods[i];
            }
            methods = results;
        }

    
public voidremovePattern(java.lang.String pattern)
Remove the specified URL pattern from those that are part of this web resource collection.

param
pattern Pattern to be removed


        if (pattern == null)
            return;
        int n = -1;
        for (int i = 0; i < patterns.length; i++) {
            if (patterns[i].equals(pattern)) {
                n = i;
                break;
            }
        }
        if (n >= 0) {
            int j = 0;
            String results[] = new String[patterns.length - 1];
            for (int i = 0; i < patterns.length; i++) {
                if (i != n)
                    results[j++] = patterns[i];
            }
            patterns = results;
        }

    
public voidsetDescription(java.lang.String description)
Set the description of this web resource collection.

param
description The new description


        this.description = description;

    
public voidsetName(java.lang.String name)
Set the name of this web resource collection

param
name The new name


        this.name = name;

    
public java.lang.StringtoString()
Return a String representation of this security collection.


        StringBuffer sb = new StringBuffer("SecurityCollection[");
        sb.append(name);
        if (description != null) {
            sb.append(", ");
            sb.append(description);
        }
        sb.append("]");
        return (sb.toString());