Commit fee20c43 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Added adhoc commands to determine current status of HTTP binding

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6407 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1cb16dbc
......@@ -629,6 +629,16 @@ public class HttpServerManager {
}
}
public String getHttpBindUnsecureAddress() {
return "http://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
bindPort + "/http-bind/";
}
public String getHttpBindSecureAddress() {
return "https://" + XMPPServer.getInstance().getServerInfo().getName() + ":" +
bindSecurePort + "/http-bind/";
}
private class CertificateListener implements CertificateEventListener {
public void certificateCreated(KeyStore keyStore, String alias, X509Certificate cert) {
......
......@@ -203,6 +203,7 @@ public class AdHocCommandHandler extends IQHandler
addCommand(new UserProperties());
addCommand(new PacketsNotification());
addCommand(new GetServerStats());
addCommand(new HttpBindStatus());
}
private void startCommand(AdHocCommand command) {
......
/**
* $RCSfile: $
* $Revision: $
* $Date: $
*
* Copyright (C) 2006 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.wildfire.commands.admin;
import org.jivesoftware.wildfire.commands.AdHocCommand;
import org.jivesoftware.wildfire.commands.SessionData;
import org.jivesoftware.wildfire.HttpServerManager;
import org.dom4j.Element;
import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField;
import java.util.List;
import java.util.Collections;
/**
* AdHoc command to return the current status of the HTTP-bind service. The command returns whether
* or not the service is currently enabled, if it is enabled it will return the HTTP address on
* which the service can be reached.
*
* @author Alexander Wenckus
*/
public class HttpBindStatus extends AdHocCommand {
public String getCode() {
return "http://jabber.org/protocol/admin#status-http-bind";
}
public String getDefaultLabel() {
return "Current Http Bind Status";
}
public int getMaxStages(SessionData data) {
return 0;
}
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");
HttpServerManager manager = HttpServerManager.getInstance();
boolean isEnabled = manager.isHttpBindEnabled();
field = form.addField();
field.setLabel("Http Bind Enabled");
field.setVariable("httpbindenabled");
field.addValue(isEnabled);
if(isEnabled) {
field = form.addField();
field.setLabel("Http Bind Address");
field.setVariable("httpbindaddress");
field.addValue(manager.getHttpBindUnsecureAddress());
field = form.addField();
field.setLabel("Http Bind Secure Address");
field.setVariable("httpbindsecureaddress");
field.addValue(manager.getHttpBindSecureAddress());
}
command.add(form.getElement());
}
protected void addStageInformation(SessionData data, Element command) {
// no stages, do nothing.
}
protected List<Action> getActions(SessionData data) {
return Collections.emptyList();
}
protected Action getExecuteAction(SessionData data) {
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment