use of org.jivesoftware.openfire.container.PluginManager in project Openfire by igniterealtime.
the class GetAdminConsoleInfo method execute.
@Override
public void execute(SessionData data, Element command) {
DataForm form = new DataForm(DataForm.Type.result);
FormField field = form.addField();
field.setType(FormField.Type.hidden);
field.setVariable("FORM_TYPE");
field.addValue("http://jabber.org/protocol/admin");
// Gets a valid bind interface
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
AdminConsolePlugin adminConsolePlugin = ((AdminConsolePlugin) pluginManager.getPlugin("admin"));
String bindInterface = adminConsolePlugin.getBindInterface();
int adminPort = adminConsolePlugin.getAdminUnsecurePort();
int adminSecurePort = adminConsolePlugin.getAdminSecurePort();
if (bindInterface == null) {
Enumeration<NetworkInterface> nets = null;
try {
nets = NetworkInterface.getNetworkInterfaces();
} catch (SocketException e) {
// We failed to discover a valid IP address where the admin console is running
return;
}
for (NetworkInterface netInterface : Collections.list(nets)) {
boolean found = false;
Enumeration<InetAddress> addresses = netInterface.getInetAddresses();
for (InetAddress address : Collections.list(addresses)) {
if ("127.0.0.1".equals(address.getHostAddress()) || "0:0:0:0:0:0:0:1".equals(address.getHostAddress())) {
continue;
}
Socket socket = new Socket();
InetSocketAddress remoteAddress = new InetSocketAddress(address, adminPort > 0 ? adminPort : adminSecurePort);
try {
socket.connect(remoteAddress);
bindInterface = address.getHostAddress();
found = true;
break;
} catch (IOException e) {
// Ignore this address. Let's hope there is more addresses to validate
}
}
if (found) {
break;
}
}
}
// If there is no valid bind interface, return an error
if (bindInterface == null) {
Element note = command.addElement("note");
note.addAttribute("type", "error");
note.setText("Couldn't find a valid interface.");
return;
}
// Add the bind interface
field = form.addField();
field.setLabel("Bind interface");
field.setVariable("bindInterface");
field.addValue(bindInterface);
// Add the port
field = form.addField();
field.setLabel("Port");
field.setVariable("adminPort");
field.addValue(adminPort);
// Add the secure port
field = form.addField();
field.setLabel("Secure port");
field.setVariable("adminSecurePort");
field.addValue(adminSecurePort);
command.add(form.getElement());
}
use of org.jivesoftware.openfire.container.PluginManager in project Openfire by igniterealtime.
the class LocaleUtils method getPluginResourceBundle.
/**
* Retrieve the <code>ResourceBundle</code> that is used with this plugin.
*
* @param pluginName the name of the plugin.
* @return the ResourceBundle used with this plugin.
* @throws Exception thrown if an exception occurs.
*/
public static ResourceBundle getPluginResourceBundle(String pluginName) throws Exception {
final Locale locale = JiveGlobals.getLocale();
String i18nFile = getI18nFile(pluginName);
// Retrieve classloader from pluginName.
final XMPPServer xmppServer = XMPPServer.getInstance();
PluginManager pluginManager = xmppServer.getPluginManager();
Plugin plugin = pluginManager.getPlugin(pluginName);
if (plugin == null) {
throw new NullPointerException("Plugin could not be located.");
}
ClassLoader pluginClassLoader = pluginManager.getPluginClassloader(plugin);
return ResourceBundle.getBundle(i18nFile, locale, pluginClassLoader);
}
use of org.jivesoftware.openfire.container.PluginManager in project Openfire by igniterealtime.
the class ClusterClassLoader method getResources.
public Enumeration<URL> getResources(String name) throws IOException {
Enumeration<URL> answer = null;
try {
answer = enterpriseClassloader.getResources(name);
} catch (IOException e) {
// Ignore
}
if (answer == null || !answer.hasMoreElements()) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
for (Plugin plugin : pluginManager.getPlugins()) {
String pluginName = pluginManager.getPluginDirectory(plugin).getName();
if ("clustering".equals(pluginName) || "admin".equals(pluginName)) {
continue;
}
PluginClassLoader pluginClassloader = pluginManager.getPluginClassloader(plugin);
try {
answer = pluginClassloader.getResources(name);
} catch (IOException e) {
// Ignore
}
if (answer != null && answer.hasMoreElements()) {
return answer;
}
}
}
return answer;
}
use of org.jivesoftware.openfire.container.PluginManager in project Openfire by igniterealtime.
the class ConfigManager method saveSettings.
/**
* Saves settings from options screen.
*
* @param transportName Name of the transport to have it's options saved (type of transport)
* @param options Options passed from options form.
*/
public void saveSettings(String transportName, HashMap<String, String> options) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
KrakenPlugin plugin = (KrakenPlugin) pluginManager.getPlugin("kraken");
Document optConfig = plugin.getOptionsConfig(TransportType.valueOf(transportName));
Element leftPanel = optConfig.getRootElement().element("leftpanel");
if (leftPanel != null && leftPanel.nodeCount() > 0) {
for (Object nodeObj : leftPanel.elements("item")) {
Element node = (Element) nodeObj;
saveOptionSetting(node, options);
}
}
Element rightPanel = optConfig.getRootElement().element("rightpanel");
if (rightPanel != null && rightPanel.nodeCount() > 0) {
for (Object nodeObj : rightPanel.elements("item")) {
Element node = (Element) nodeObj;
saveOptionSetting(node, options);
}
}
Element bottomPanel = optConfig.getRootElement().element("bottompanel");
if (bottomPanel != null && bottomPanel.nodeCount() > 0) {
for (Object nodeObj : bottomPanel.elements("item")) {
Element node = (Element) nodeObj;
saveOptionSetting(node, options);
}
}
}
use of org.jivesoftware.openfire.container.PluginManager in project Openfire by igniterealtime.
the class ConfigManager method logoutSession.
/**
* Logs out session via the web interface.
*
*
* @param registrationID ID number associated with registration to log off.
* @return registration ID on success, -1 on failure (-1 so that js cb_logoutSession knows which Div to edit)
*/
public Integer logoutSession(Integer registrationID) {
try {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
KrakenPlugin plugin = (KrakenPlugin) pluginManager.getPlugin("kraken");
Registration registration = new Registration(registrationID);
if (!plugin.getTransportInstance(registration.getTransportType().toString()).isEnabled()) {
return -1;
}
JID jid = registration.getJID();
TransportSession session = plugin.getTransportInstance(registration.getTransportType().toString()).getTransport().getSessionManager().getSession(jid);
plugin.getTransportInstance(registration.getTransportType().toString()).getTransport().registrationLoggedOut(session);
return registrationID;
} catch (NotFoundException e) {
return -1;
}
}
Aggregations