KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > xml > mbeanserver > AuthenticationInfo


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.xml.mbeanserver;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.Arrays JavaDoc;
26 import java.util.Map JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import javax.security.auth.login.AppConfigurationEntry JavaDoc;
29
30 /**
31  * @author Scott.Stark@jboss.org
32  * @version $Revision: 37406 $
33  */

34 public class AuthenticationInfo
35 {
36    private String JavaDoc name;
37    private ArrayList JavaDoc loginModules = new ArrayList JavaDoc();
38
39    public AuthenticationInfo()
40    {
41       //System.out.println("AuthenticationInfo");
42
}
43    public AuthenticationInfo(String JavaDoc name)
44    {
45       this.name = name;
46       //System.out.println("AuthenticationInfo.ctor, name="+name);
47
}
48
49    public String JavaDoc getName()
50    {
51       return name;
52    }
53    public void setName(String JavaDoc name)
54    {
55       //System.out.println("AuthenticationInfo, name="+name);
56
this.name = name;
57    }
58
59    /** Get a copy of the application authentication configuration. This requires
60     an AuthPermission("getLoginConfiguration") access.
61     */

62    public AppConfigurationEntry JavaDoc[] copyAppConfigurationEntry()
63    {
64       AppConfigurationEntry JavaDoc[] copy = new AppConfigurationEntry JavaDoc[loginModules.size()];
65       for(int i = 0; i < copy.length; i ++)
66       {
67          AppConfigurationEntry JavaDoc entry = (AppConfigurationEntry JavaDoc) loginModules.get(i);
68          copy[i] = new AppConfigurationEntry JavaDoc(entry.getLoginModuleName(),
69                                 entry.getControlFlag(), entry.getOptions());
70       }
71       return copy;
72    }
73
74    public void addAppConfigurationEntry(AppConfigurationEntry JavaDoc entry)
75    {
76       //System.out.println("AuthenticationInfo, addAppConfigurationEntry="+name);
77
loginModules.add(entry);
78    }
79    /** Get an application authentication configuration. This requires an
80     AuthPermission("getLoginConfiguration") access.
81     */

82    public AppConfigurationEntry JavaDoc[] getAppConfigurationEntry()
83    {
84       AppConfigurationEntry JavaDoc[] entries = new AppConfigurationEntry JavaDoc[loginModules.size()];
85       loginModules.toArray(entries);
86       return entries;
87    }
88    /** Set an application authentication configuration. This requires an
89     AuthPermission("setLoginConfiguration") access.
90     */

91    public void setAppConfigurationEntry(AppConfigurationEntry JavaDoc[] loginModules)
92    {
93       this.loginModules.addAll(Arrays.asList(loginModules));
94    }
95
96    public String JavaDoc toString()
97    {
98       StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("AppConfigurationEntry[]:\n");
99       for(int i = 0; i < loginModules.size(); i ++)
100       {
101          AppConfigurationEntry JavaDoc entry = (AppConfigurationEntry JavaDoc) loginModules.get(i);
102          buffer.append("["+i+"]");
103          buffer.append("\nLoginModule Class: "+entry.getLoginModuleName());
104          buffer.append("\nControlFlag: "+entry.getControlFlag());
105          buffer.append("\nOptions:");
106          Map JavaDoc options = entry.getOptions();
107          Iterator JavaDoc iter = options.entrySet().iterator();
108          while( iter.hasNext() )
109          {
110             Map.Entry JavaDoc e = (Map.Entry JavaDoc) iter.next();
111             buffer.append("name="+e.getKey());
112             buffer.append(", value="+e.getValue());
113             buffer.append("\n");
114          }
115       }
116       return buffer.toString();
117    }
118
119 }
120
Popular Tags