use of net.sf.kraken.KrakenPlugin in project Openfire by igniterealtime.
the class ConfigManager method addRegistration.
/**
* Adds a new registration via the web interface.
*
* @param user Username or full JID of user who is getting an account registered.
* @param transportType Type of transport to add user to.
* @param legacyUsername User's username on the legacy service.
* @param legacyPassword User's password on the legacy service.
* @param legacyNickname User's nickname on the legacy service.
* @return Error message or null on success.
*/
public String addRegistration(String user, String transportType, String legacyUsername, String legacyPassword, String legacyNickname) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
KrakenPlugin plugin = (KrakenPlugin) pluginManager.getPlugin("kraken");
JID jid;
if (user.contains("@")) {
jid = new JID(user);
} else {
jid = new JID(user, XMPPServer.getInstance().getServerInfo().getXMPPDomain(), null);
}
if (!plugin.getTransportInstance(transportType).isEnabled()) {
return LocaleUtils.getLocalizedString("gateway.web.registrations.notenabled", "kraken");
}
try {
final BaseTransport transport = plugin.getTransportInstance(transportType).getTransport();
new RegistrationHandler(transport).addNewRegistration(jid, legacyUsername, legacyPassword, legacyNickname, false);
return null;
} catch (UserNotFoundException e) {
Log.error("Not found while adding account for " + jid.toString());
return LocaleUtils.getLocalizedString("gateway.web.registrations.xmppnotfound", "kraken");
} catch (IllegalAccessException e) {
Log.error("Domain of JID specified for registration is not on this server: " + jid.toString());
return LocaleUtils.getLocalizedString("gateway.web.registrations.illegaldomain", "kraken");
} catch (IllegalArgumentException e) {
Log.error("Username specified for registration is not valid.");
return LocaleUtils.getLocalizedString("gateway.web.registrations.invaliduser", "kraken");
}
}
use of net.sf.kraken.KrakenPlugin in project Openfire by igniterealtime.
the class ConfigManager method toggleTransport.
/**
* Toggles whether a transport is enabled or disabled.
*
* @param transportName Name of the transport to be enabled or disabled (type of transport)
* @return True or false if the transport is enabled after this call.
*/
public boolean toggleTransport(String transportName) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
KrakenPlugin plugin = (KrakenPlugin) pluginManager.getPlugin("kraken");
if (!plugin.serviceEnabled(transportName)) {
plugin.enableService(transportName);
return true;
} else {
plugin.disableService(transportName);
return false;
}
}
use of net.sf.kraken.KrakenPlugin in project Openfire by igniterealtime.
the class XMLRPCConduit method getActiveTransports.
/**
* Retrieve a list of all active/enabled transports.
*
* @param password Auth password for making changes
* @return List of active transports.
*/
public List<String> getActiveTransports(String password) {
if (!verifyPassword(password)) {
return Arrays.asList("Authorization failed!");
}
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
KrakenPlugin plugin = (KrakenPlugin) pluginManager.getPlugin("kraken");
List<String> activeTransports = new ArrayList<String>();
for (String transport : plugin.getTransports()) {
if (plugin.serviceEnabled(transport)) {
activeTransports.add(transport);
}
}
return activeTransports;
}
Aggregations