View Javadoc

1   /**
2    * Copyright 2005-2007 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.control.config;
16  
17  import java.util.HashMap;
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.io.Serializable;
21  /**
22   * A JavaBean representing security constraints on an <code>&lt;action&gt;</code>
23   * element from a Struts application module configuration file.<br/>
24   * This JavaBean can have a set of security roles allowed to request the corresponding
25   * action. Because most of the actions in Join are entries to business operations,
26   * action may have no roles directly associated but instead provides security to its
27   * operations.<br/>
28   * In this later case, roles associated with operation overrides roles associated
29   * with the action. 
30   * @author  <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
31   * @version $Revision: 1.1 $
32   */
33  public class ActionConstraintConfig implements Serializable{
34     
35     // Attributes ---------------------------------------------------------------
36     
37     /** The set of associated roles handling configurations for this action, if any.  */
38     private ArrayList roles = new ArrayList();
39     
40     /** The set of operaton handling configurations for this action, if any. */
41     private HashMap operationConstraints = new HashMap();
42     
43     /**
44      * The path of this action constraint applies to. Context-relative path
45      * of the submitted request, starting with a slash ("/") character, and
46      * omitting any filename extension if extension mapping is being used.
47      */
48     private String path;
49     
50     
51     // Constructors -------------------------------------------------------------
52     
53     /** Creates a new instance of ActionConstraintConfig */
54     public ActionConstraintConfig(){
55        super();
56     }
57     
58     
59     // Public -------------------------------------------------------------------
60     
61     /** @return The path this action constraint applies to */
62     public String getPath(){
63        return path;
64     }
65     /** @param path The path this action constraint applies to */
66     public void setPath(String path){
67        this.path = path;
68     }
69     
70     /**
71      * Add a new <code>RoleConfig</code> instance to the set associated.
72      * @param role The new role configuration instance to be added
73      */
74     public void addRole(RoleConfig role){
75        roles.add(role);
76     }
77     
78     /**
79      * Return the list of security roles allowed to request the associated action
80      * if any; otherwise return an empty collection.
81      * @return Collection of <code>RoleConfig</code>
82      */
83     public Collection getRoles(){
84       return roles;  
85     }
86     
87     /**
88      * Add a new <code>OperationConstraintConfig</code> instance to the set associated.
89      * @param constraint The new constraint configuration instance to be added
90      */
91     public void addOperationConstraint(OperationConstraintConfig constraint){
92        operationConstraints.put(constraint.getName(), constraint);
93     }
94     
95     /**
96      * Return the operation constraint configuration for the specified operation name,
97      * if any; otherwise return <code>null</code>.
98      * @param name Name of the operation constraint configuration to return
99      * @return The corresponding OperationConstraintConfig
100     */
101    public OperationConstraintConfig findOperationConstraint(String name){
102       return (OperationConstraintConfig)operationConstraints.get(name);
103    }
104 }