KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > core > CoreJAASConfiguration


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
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. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.core;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.TreeMap JavaDoc;
25
26 import javax.security.auth.login.AppConfigurationEntry JavaDoc;
27 import javax.security.auth.login.Configuration JavaDoc;
28
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31
32 /**
33  * Extension of the standard JASS {@link javax.security.auth.login.Configuration}
34  * that allows configurations to be added programatically instead of through
35  * the configuration files.
36  *
37  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
38  */

39 public class CoreJAASConfiguration extends Configuration JavaDoc {
40     
41     TreeMap JavaDoc entries;
42     final static Log log = LogFactory.getLog(CoreJAASConfiguration.class);
43
44     /**
45      * Constructor
46      */

47     public CoreJAASConfiguration() {
48         super();
49         entries = new TreeMap JavaDoc();
50         Configuration.setConfiguration(this);
51     }
52     
53     /**
54      * Add a new configuration entry.
55      *
56      * @param name name
57      * @param entry entry
58      */

59     public void addAppConfigurationEntry(String JavaDoc name, AppConfigurationEntry JavaDoc entry) {
60         if (log.isInfoEnabled())
61             log.info("Adding new entry for '" + name + "' [" + entry.getLoginModuleName() + "' to JAAS configuration ");
62         List JavaDoc l = (List JavaDoc)entries.get(name);
63         if(l == null) {
64             l = new ArrayList JavaDoc();
65             entries.put(name, l);
66         }
67         l.add(entry);
68     }
69
70     /* (non-Javadoc)
71      * @see javax.security.auth.login.Configuration#getAppConfigurationEntry(java.lang.String)
72      */

73     public AppConfigurationEntry JavaDoc[] getAppConfigurationEntry(String JavaDoc name) {
74         List JavaDoc en = (List JavaDoc)entries.get(name);
75         if(en == null || en.size() == 0) {
76             return null;
77         }
78         else {
79             AppConfigurationEntry JavaDoc[] ena = new AppConfigurationEntry JavaDoc[en.size()];
80             en.toArray(ena);
81             return ena;
82         }
83     }
84
85     /* (non-Javadoc)
86      * @see javax.security.auth.login.Configuration#refresh()
87      */

88     public void refresh() {
89         if (log.isInfoEnabled())
90             log.info("Refreshing JAAS configuration");
91     }
92
93 }
94
Popular Tags