Search in sources :

Example 16 with PluginManager

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;
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) URL(java.net.URL) Plugin(org.jivesoftware.openfire.container.Plugin) PluginClassLoader(org.jivesoftware.openfire.container.PluginClassLoader)

Example 17 with PluginManager

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);
            }
        }
    }
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) Plugin(org.jivesoftware.openfire.container.Plugin)

Example 18 with PluginManager

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");
    }
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) JID(org.xmpp.packet.JID) RegistrationHandler(net.sf.kraken.registration.RegistrationHandler) BaseTransport(net.sf.kraken.BaseTransport) KrakenPlugin(net.sf.kraken.KrakenPlugin)

Example 19 with PluginManager

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;
    }
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) KrakenPlugin(net.sf.kraken.KrakenPlugin)

Example 20 with PluginManager

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;
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) KrakenPlugin(net.sf.kraken.KrakenPlugin)

Aggregations

PluginManager (org.jivesoftware.openfire.container.PluginManager)20 Plugin (org.jivesoftware.openfire.container.Plugin)8 KrakenPlugin (net.sf.kraken.KrakenPlugin)7 IOException (java.io.IOException)5 URL (java.net.URL)5 PluginClassLoader (org.jivesoftware.openfire.container.PluginClassLoader)5 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)4 Registration (net.sf.kraken.registration.Registration)3 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)3 NotFoundException (org.jivesoftware.util.NotFoundException)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 Locale (java.util.Locale)2 BaseTransport (net.sf.kraken.BaseTransport)2 RegistrationHandler (net.sf.kraken.registration.RegistrationHandler)2 Element (org.dom4j.Element)2 XMPPServer (org.jivesoftware.openfire.XMPPServer)2 JID (org.xmpp.packet.JID)2 InputStream (java.io.InputStream)1