Search in sources :

Example 6 with KrakenPlugin

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");
    }
}
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 7 with KrakenPlugin

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

Example 8 with KrakenPlugin

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

Aggregations

KrakenPlugin (net.sf.kraken.KrakenPlugin)8 PluginManager (org.jivesoftware.openfire.container.PluginManager)7 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 JID (org.xmpp.packet.JID)3 BaseTransport (net.sf.kraken.BaseTransport)2 RegistrationHandler (net.sf.kraken.registration.RegistrationHandler)2 Map (java.util.Map)1 Lock (java.util.concurrent.locks.Lock)1 TransportInstance (net.sf.kraken.TransportInstance)1 TransportSession (net.sf.kraken.session.TransportSession)1 Document (org.dom4j.Document)1 Element (org.dom4j.Element)1 ClientSession (org.jivesoftware.openfire.session.ClientSession)1