1
/** BEGIN COPYRIGHT BLOCK
2
* Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
3
* Copyright (C) 2005 Red Hat, Inc.
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; version 2
11
* This program 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
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
* END COPYRIGHT BLOCK **/
21
package com.netscape.management.admserv;
25
import java.awt.event.*;
27
import com.netscape.management.client.*;
28
import com.netscape.management.admserv.panel.*;
29
import com.netscape.management.admserv.task.AdminTaskObject;
30
import com.netscape.management.client.console.*;
31
import com.netscape.management.client.util.*;
35
* Initializes Admin Server Config framework
37
public class AdminFrameworkInitializer extends FrameworkInitializer {
38
private static String PERMID_SECURITY = "SecurityVisibility";
39
public static boolean canAccessSecurity = false;
41
public AdminFrameworkInitializer(ConsoleInfo consoleInfo) {
42
Console.setConsoleInfo(consoleInfo); // workaround to classloading static reference problem
43
UIPermissions uip = new UIPermissions(LDAPUtil.getAdminGlobalParameterEntry());
44
canAccessSecurity = uip.hasPermission(PERMID_SECURITY);
45
TaskPage taskPage = new TaskPage(consoleInfo);
46
TaskObject root = (TaskObject) taskPage.getModel().getRoot();
49
String [] taskList = getTaskList(taskPage);
50
setTaskConsoleInfo(taskPage, consoleInfo); // override cloning of ConsoleInfo
51
addPage( new AdminResourcePage(
52
new AdminResourceModel(consoleInfo, taskList)));
53
RemoteImage imageIcon = new RemoteImage(
54
AdminServer._resource.getString("admin", "largeIcon"));
55
setMinimizedImage(imageIcon.getImage());
57
setBannerImage(getBannerImage(consoleInfo));
58
setFrameTitle(consoleInfo.getLDAPConnection(),
59
consoleInfo.getCurrentDN());
63
private Image getBannerImage(ConsoleInfo consoleInfo) {
64
String imageBase="com/netscape/management/admserv/images/";
65
return new RemoteImage(imageBase + "admin.gif").getImage();
68
private String[] getTaskList(TaskPage taskPage) {
69
TaskObject root = (TaskObject) taskPage.getModel().getRoot();
70
String[] tasks = new String[root.getChildCount()];
71
for (int i = 0; i < root.getChildCount(); i++) {
72
tasks[i] = root.getChildAt(i).getClass().getName();
78
* TaskPage clones ConsoleInfo when creating a task. We want to
79
* override that and force all Admin Server tasks to use the same
80
* adminURL as the AdminServer object. This is important as
81
* adminURL might change if the port number is changed.
83
private void setTaskConsoleInfo(TaskPage taskPage,
84
ConsoleInfo consoleInfo) {
85
TaskObject root = (TaskObject) taskPage.getModel().getRoot();
86
for (int i = 0; i < root.getChildCount(); i++) {
87
AdminTaskObject task = (AdminTaskObject) root.getChildAt(i);
88
task.setConsoleInfo( new TaskConsoleInfo(task.getConsoleInfo(),
94
* TaskConsoleInfo class overrides getAdminURL to return the
95
* value from the ConsoleInfo in the ServerNode
97
private static class TaskConsoleInfo extends ConsoleInfo {
98
private ConsoleInfo serverNodeConsoleInfo;
99
public TaskConsoleInfo(ConsoleInfo taskConsoleInfo,
100
ConsoleInfo serverNodeConsoleInfo) {
101
for (Enumeration eKey = taskConsoleInfo.keys();
102
eKey.hasMoreElements();) {
103
Object oKey = eKey.nextElement();
104
Object oValue = taskConsoleInfo.get(oKey);
107
this.serverNodeConsoleInfo = serverNodeConsoleInfo;
109
public String getAdminURL() {
110
return serverNodeConsoleInfo.getAdminURL();
112
/* We have to make sure we use the same password throughout
113
* for the main console and for the tasks - if we do not do
114
* this and we change the password, the tasks will use the
115
* wrong password. This way, if we change the password from
116
* either the Configure task, or from the Configuration tab,
117
* we will use the same password throughout.
119
public void setAuthenticationPassword(String password) {
120
serverNodeConsoleInfo.setAuthenticationPassword(password);
122
public String getAuthenticationPassword() {
123
return serverNodeConsoleInfo.getAuthenticationPassword();
127
private void removeTask(TaskObject root, String taskName) {
128
for (int i = 0; i < root.getChildCount(); i++) {
129
// can not use instanceof because of compilation dependency
130
if (root.getChildAt(i).getClass().getName().endsWith(
132
((TaskObject) root).remove(i);
140
class AdminResourcePage extends ResourcePage {
141
public AdminResourcePage(IResourceModel model) {
145
public void initialize(Framework framework) {
146
MenuItemText item = new MenuItemText(
147
AdminServer._resource.getString("menu",
148
"HelpAdminServer"), "TODO:description");
149
item.addActionListener(new HelpAction());
150
framework.addMenuItem(Framework.MENU_HELPWEBHELP, item);
153
class HelpAction implements ActionListener {
154
public void actionPerformed(ActionEvent e) {
155
Help helpSession = new Help(AdminServer._resource);
156
helpSession.contextHelp("menubar", "adminserverHelpToken");