KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_lib > security > jacc > JPolicyConfigurationKeeper


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer: Florent BENOIT
22  * --------------------------------------------------------------------------
23  * $Id: JPolicyConfigurationKeeper.java,v 1.1 2004/07/08 13:45:47 benoitf Exp $
24  * --------------------------------------------------------------------------
25  */

26 package org.objectweb.jonas_lib.security.jacc;
27
28 import java.util.HashMap JavaDoc;
29 import java.util.Map JavaDoc;
30
31 import javax.security.jacc.PolicyContextException JavaDoc;
32
33 /**
34  * This class keep the JPolicyConfiguration. This is used when
35  * JPolicyConfigurationFactory is used as a delegate factory.
36  * @author Florent Benoit
37  */

38 public class JPolicyConfigurationKeeper {
39
40     /**
41      * Internal list of JPolicyConfiguration objects
42      */

43     private static Map JavaDoc policyConfigurations = new HashMap JavaDoc();
44
45     /**
46      * Utility class, no constructor
47      */

48     private JPolicyConfigurationKeeper() {
49     }
50
51     /**
52      * Add a JOnAS policy configuration
53      * @param config policy configuration object to add
54      */

55     public static void addConfiguration(JPolicyConfiguration config) {
56         try {
57             policyConfigurations.put(config.getContextID(), config);
58         } catch (PolicyContextException JavaDoc pce) {
59             throw new RuntimeException JavaDoc("Cannot add the policy configuration object '" + config + "'");
60         }
61     }
62
63     /**
64      * Remove a JOnAS policy configuration
65      * @param config policy configuration object to remove
66      */

67     public static void removeConfiguration(JPolicyConfiguration config) {
68         try {
69             if (policyConfigurations.containsKey(config.getContextID())) {
70                 policyConfigurations.remove(config.getContextID());
71             }
72         } catch (PolicyContextException JavaDoc pce) {
73             throw new RuntimeException JavaDoc("Cannot remove the policy configuration object '" + config + "'");
74         }
75     }
76
77     /**
78      * Gets the JOnAS policy configuration by its contextId
79      * @param contextId given ID to retrieve policy configuration object
80      * @return the JOnAS policy configuration specified by its contextId
81      */

82     public static JPolicyConfiguration getConfiguration(String JavaDoc contextId) {
83         return (JPolicyConfiguration) policyConfigurations.get(contextId);
84     }
85 }
Popular Tags