KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > security > propagation > SSHandlerFactory


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 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(s): ____________________________________.
22  * Contributor(s): ______________________________________.
23  *
24  * --------------------------------------------------------------------------
25  * $Id: SSHandlerFactory.java,v 1.7 2004/05/17 07:22:36 durieuxp Exp $
26  * --------------------------------------------------------------------------
27  */

28
29 package org.objectweb.security.propagation;
30
31 import org.objectweb.jonathan.apis.kernel.Context;
32 import org.objectweb.jonathan.apis.kernel.InternalException;
33 import org.objectweb.jonathan.apis.kernel.JonathanException;
34 import org.objectweb.jonathan.presentation.api.MarshallerFactory;
35 import org.objectweb.jonathan.libs.kernel.GenericFactory;
36
37
38 /**
39  * {@link SSHandler SSHandler}
40  */

41 public class SSHandlerFactory extends GenericFactory {
42
43     /**
44      * Name used to designate the context containing the SSHandler components.
45      */

46     static public final String JavaDoc jonasss_context_name = "/jonas/security/SSHandler";
47
48     /**
49      * Returns the components required to create a new
50      * {@link SSHandler SSHandler} instance.
51      * <p>
52      * <code>c</code> must contain a (non null) component of name
53      * "MarshallerFactory" of type {@link MarshallerFactory MarshallerFactory}.
54      * <p>
55      * It may contain a component of name "id", of type Integer; this id
56      * should then represent the service id to use for the created service.
57      * <p>
58      * It may contain a component of name "sender", of type {@link Sender Sender},
59      * and a component of name "receiver", of type {@link Receiver Receiver}.
60      *
61      * @param c a {@link Context Context} instance;
62      * @return the components needed to create an SSHandler instance.
63      */

64     protected Object JavaDoc[] getUsedComponents(Context c) {
65       
66         Object JavaDoc[] used_components = {
67             Context.NO_VALUE, Context.NO_VALUE, Context.NO_VALUE, Context.NO_VALUE
68         };
69
70         if (c != null) {
71             used_components[0] = c.getValue("id", (char) 0);
72             used_components[1] = c.getValue("sender", (char) 0);
73             used_components[2] = c.getValue("receiver", (char) 0);
74             used_components[3] = c.getValue("MarshallerFactory", (char) 0);
75         }
76         if (! (used_components[0] instanceof Integer JavaDoc)) {
77             used_components[0] = new Integer JavaDoc(Integer.MAX_VALUE);
78         }
79         if (! (used_components[1] instanceof SecuritySender)) {
80             used_components[1] = null;
81         }
82         if (! (used_components[2] instanceof SecurityReceiver)) {
83             used_components[2] = null;
84         }
85         if (! (used_components[3] instanceof MarshallerFactory)) {
86             throw new InternalException("Component MarshallerFactory of type MarshallerFactory is required by SSHandler.");
87         }
88         return used_components;
89     }
90    
91     /**
92      * Returns a new SSHandler instance created using the provided
93      * components.
94      *
95      * @param c a context;
96      * @param components components to be used to create a new SSHandler instance;
97      * @return a new SSHandler instance;
98      * @exception JonathanException if something goes wrong.
99      */

100     protected Object JavaDoc newInstance(Context c, Object JavaDoc[] components) throws JonathanException {
101         return new SSHandler(c, components);
102     }
103 }
104
Popular Tags