use of net.sf.kraken.BaseTransport in project Openfire by igniterealtime.
the class ConfigManager method deleteRegistration.
/**
* Deletes a registration via the web interface.
*
* @param registrationID ID number associated with registration to delete.
* @return Error message or null on success.
*/
public String deleteRegistration(Integer registrationID) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
KrakenPlugin plugin = (KrakenPlugin) pluginManager.getPlugin("kraken");
try {
Registration reg = new Registration(registrationID);
if (!plugin.getTransportInstance(reg.getTransportType().toString()).isEnabled()) {
return LocaleUtils.getLocalizedString("gateway.web.registrations.notenabled", "kraken");
}
final BaseTransport transport = plugin.getTransportInstance(reg.getTransportType().toString()).getTransport();
new RegistrationHandler(transport).deleteRegistration(reg.getJID());
return null;
} catch (NotFoundException e) {
// Ok, nevermind.
Log.error("Not found while deleting id " + registrationID, e);
return LocaleUtils.getLocalizedString("gateway.web.registrations.xmppnotfound", "kraken");
} catch (UserNotFoundException e) {
// Ok, nevermind.
Log.error("Not found while deleting id " + registrationID, e);
return LocaleUtils.getLocalizedString("gateway.web.registrations.regnotfound", "kraken");
}
}
use of net.sf.kraken.BaseTransport 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");
}
}
Aggregations