use of net.sf.kraken.KrakenPlugin in project Openfire by igniterealtime.
the class TransportSessionRouter method leftCluster.
/**
* @see org.jivesoftware.openfire.cluster.ClusterEventListener#leftCluster(byte[])
*/
public void leftCluster(byte[] leavingNodeID) {
KrakenPlugin plugin = getPlugin();
// TODO: Is this correct? Lets say another node updates an entry before I get to it, will I see the update?
for (Map.Entry<String, byte[]> entry : sessionLocations.entrySet()) {
if (Arrays.equals(entry.getValue(), leavingNodeID)) {
Lock l = CacheFactory.getLock(entry.getKey() + "lc", sessionLocations);
try {
l.lock();
String jid = entry.getKey().substring(0, entry.getKey().lastIndexOf("@"));
String trType = entry.getKey().substring(entry.getKey().lastIndexOf("@") + 1);
Log.debug("Kraken: Node handling session " + jid + " on " + trType + " lost, taking over session...");
sessionLocations.remove(jid + "@" + trType);
TransportInstance trInstance = plugin.getTransportInstance(trType);
if (trInstance != null) {
BaseTransport<? extends TransportBuddy> transport = trInstance.getTransport();
if (transport != null) {
Collection<ClientSession> sessions = XMPPServer.getInstance().getSessionManager().getSessions(new JID(jid).getNode());
for (ClientSession session : sessions) {
transport.processPacket(session.getPresence());
}
}
}
} finally {
l.unlock();
}
}
}
}
use of net.sf.kraken.KrakenPlugin 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 net.sf.kraken.KrakenPlugin 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;
}
}
use of net.sf.kraken.KrakenPlugin in project Openfire by igniterealtime.
the class ConfigManager method updateRegistration.
/**
* Updates a registration via the web interface.
*
*
* @param registrationID ID number associated with registration to modify.
* @param legacyUsername User's updated username on the legacy service.
* @param legacyPassword User's updated password on the legacy service, null if no change.
* @param legacyNickname User's updated nickname on the legacy service.
* @return Error message or null on success.
*/
public String updateRegistration(Integer registrationID, String legacyUsername, String legacyPassword, String legacyNickname) {
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");
}
reg.setUsername(legacyUsername);
if (legacyPassword != null) {
reg.setPassword(legacyPassword);
}
reg.setNickname(legacyNickname);
return null;
} catch (NotFoundException e) {
// Ok, nevermind.
Log.error("Not found while editing id " + registrationID, e);
return LocaleUtils.getLocalizedString("gateway.web.registrations.regnotfound", "kraken");
}
}
use of net.sf.kraken.KrakenPlugin 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");
}
}
Aggregations