KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > security > forms > ShowAvailableRolesForm


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.security.forms;
21
22 import java.util.Arrays JavaDoc;
23
24 import javax.servlet.http.HttpSession JavaDoc;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import com.sslexplorer.core.UserDatabaseManager;
30 import com.sslexplorer.security.LogonControllerFactory;
31 import com.sslexplorer.security.Role;
32 import com.sslexplorer.security.RoleItem;
33 import com.sslexplorer.security.RoleItemModel;
34 import com.sslexplorer.table.forms.AbstractPagerForm;
35
36
37 /**
38  * Implementation of {@link AbstractPagerForm} that is used to display a
39  * list of configured <i>Groups</i> (previously known as <i>Roles</i>) and
40  * to allow the administrator to create, edit and view (if the underlying
41  * user database supports it).
42  *
43  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
44  */

45 public class ShowAvailableRolesForm extends AbstractPagerForm {
46
47     static Log log = LogFactory.getLog(ShowAvailableRolesForm.class);
48
49     /**
50      * Constructor.
51      */

52     public ShowAvailableRolesForm() {
53         super(new RoleItemModel());
54     }
55
56     /**
57      * Initliase the form.
58      *
59      * @param r roles
60      * @param session session
61      * @throws Exception on any error
62      */

63     public void initialize(Role[] r, HttpSession JavaDoc session) throws Exception JavaDoc {
64         super.initialize(session, "role");
65         for (int i = 0; r != null && i < r.length; i++) {
66             getModel().addItem(
67                             new RoleItem(r[i], Arrays.asList(UserDatabaseManager.getInstance().getUserDatabase(
68                                             LogonControllerFactory.getInstance().getSessionInfo(session).getUser().getRealm()
69                                                             .getResourceId()).getUsersInRole(r[i]))));
70         }
71         getPager().rebuild(getFilterText());
72     }
73
74 }
Popular Tags