use of org.jivesoftware.openfire.container.PluginManager in project Openfire by igniterealtime.
the class ClusterClassLoader method getResource.
public URL getResource(String name) {
URL resource = enterpriseClassloader.getResource(name);
if (resource == null) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
for (Plugin plugin : pluginManager.getPlugins()) {
String pluginName = pluginManager.getPluginDirectory(plugin).getName();
if ("clustering".equals(pluginName) || "admin".equals(pluginName)) {
continue;
}
PluginClassLoader pluginClassloader = pluginManager.getPluginClassloader(plugin);
resource = pluginClassloader.getResource(name);
if (resource != null) {
return resource;
}
}
}
return resource;
}
use of org.jivesoftware.openfire.container.PluginManager in project Openfire by igniterealtime.
the class ChatSettingsCreator method createImageSettings.
/**
* Adds the encoded imageMap to the database.
*
* @param workgroupJID - the jid of the workgroup to setup.
*/
private void createImageSettings(JID workgroupJID) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
Plugin fastpathPlugin = pluginManager.getPlugin("fastpath");
File fastpathPluginDirectory = pluginManager.getPluginDirectory(fastpathPlugin);
File imagesDir = new File(fastpathPluginDirectory, "web/images");
for (KeyEnum key : imageMap.keySet()) {
String value = imageMap.get(key);
File image = new File(imagesDir, value);
FileInputStream stream = null;
try {
stream = new FileInputStream(image);
} catch (FileNotFoundException e) {
Log.error(e.getMessage(), e);
}
if (stream != null) {
byte[] bytes;
try {
bytes = new byte[(int) image.length()];
int read = stream.read(bytes);
if (read != bytes.length) {
throw new IOException("Failed to read all image bytes.");
}
stream.close();
final String encodedFile = StringUtils.encodeBase64(bytes);
createImageChatSetting(workgroupJID, key, ChatSettings.SettingType.image_settings, encodedFile);
} catch (IOException e) {
Log.error(e.getMessage(), e);
}
}
}
}
use of org.jivesoftware.openfire.container.PluginManager 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 org.jivesoftware.openfire.container.PluginManager 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 org.jivesoftware.openfire.container.PluginManager 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