use of org.jivesoftware.openfire.container.AdminConsolePlugin in project Openfire by igniterealtime.
the class XMPPServer method finishSetup.
/**
* Finish the setup process. Because this method is meant to be called from inside
* the Admin console plugin, it spawns its own thread to do the work so that the
* class loader is correct.
*/
public void finishSetup() {
if (!setupMode) {
return;
}
// Make sure that setup finished correctly.
if ("true".equals(JiveGlobals.getXMLProperty("setup"))) {
// already been touched by setup prior to this method being called.
for (String propName : JiveGlobals.getXMLPropertyNames()) {
if (JiveGlobals.getProperty(propName) == null) {
JiveGlobals.setProperty(propName, JiveGlobals.getXMLProperty(propName));
}
}
// Set default SASL SCRAM-SHA-1 iteration count
JiveGlobals.setProperty("sasl.scram-sha-1.iteration-count", Integer.toString(ScramUtils.DEFAULT_ITERATION_COUNT));
// Check if keystore (that out-of-the-box is a fallback for all keystores) already has certificates for current domain.
// Will be a module after finishing setup.
CertificateStoreManager certificateStoreManager = null;
try {
certificateStoreManager = new CertificateStoreManager();
certificateStoreManager.initialize(this);
certificateStoreManager.start();
final IdentityStore identityStore = certificateStoreManager.getIdentityStore(ConnectionType.SOCKET_C2S);
identityStore.ensureDomainCertificates("DSA", "RSA");
} catch (Exception e) {
logger.error("Error generating self-signed certificates", e);
} finally {
if (certificateStoreManager != null) {
certificateStoreManager.stop();
certificateStoreManager.destroy();
}
}
// Initialize list of admins now (before we restart Jetty)
AdminManager.getInstance().getAdminAccounts();
Thread finishSetup = new Thread() {
@Override
public void run() {
try {
if (isStandAlone()) {
// Always restart the HTTP server manager. This covers the case
// of changing the ports, as well as generating self-signed certificates.
// Wait a short period before shutting down the admin console.
// Otherwise, the page that requested the setup finish won't
// render properly!
Thread.sleep(1000);
((AdminConsolePlugin) pluginManager.getPlugin("admin")).restart();
// ((AdminConsolePlugin) pluginManager.getPlugin("admin")).shutdown();
// ((AdminConsolePlugin) pluginManager.getPlugin("admin")).startup();
}
verifyDataSource();
// First load all the modules so that modules may access other modules while
// being initialized
loadModules();
// Initize all the modules
initModules();
// Start all the modules
startModules();
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
shutdownServer();
}
}
};
// Use the correct class loader.
finishSetup.setContextClassLoader(loader);
finishSetup.start();
// We can now safely indicate that setup has finished
setupMode = false;
}
}
use of org.jivesoftware.openfire.container.AdminConsolePlugin 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.setType(FormField.Type.text_single);
field.setLabel("Bind interface");
field.setVariable("bindInterface");
field.addValue(bindInterface);
// Add the port
field = form.addField();
field.setType(FormField.Type.text_single);
field.setLabel("Port");
field.setVariable("adminPort");
field.addValue(adminPort);
// Add the secure port
field = form.addField();
field.setType(FormField.Type.text_single);
field.setLabel("Secure port");
field.setVariable("adminSecurePort");
field.addValue(adminSecurePort);
command.add(form.getElement());
}
Aggregations