Search in sources :

Example 1 with BaseTransport

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");
    }
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) Registration(net.sf.kraken.registration.Registration) RegistrationHandler(net.sf.kraken.registration.RegistrationHandler) NotFoundException(org.jivesoftware.util.NotFoundException) GroupNotFoundException(org.jivesoftware.openfire.group.GroupNotFoundException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) BaseTransport(net.sf.kraken.BaseTransport) KrakenPlugin(net.sf.kraken.KrakenPlugin)

Example 2 with BaseTransport

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

Aggregations

BaseTransport (net.sf.kraken.BaseTransport)2 KrakenPlugin (net.sf.kraken.KrakenPlugin)2 RegistrationHandler (net.sf.kraken.registration.RegistrationHandler)2 PluginManager (org.jivesoftware.openfire.container.PluginManager)2 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)2 Registration (net.sf.kraken.registration.Registration)1 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)1 NotFoundException (org.jivesoftware.util.NotFoundException)1 JID (org.xmpp.packet.JID)1