Search in sources :

Example 1 with Registration

use of net.sf.kraken.registration.Registration in project Openfire by igniterealtime.

the class PseudoRosterManager method getPseudoRoster.

/**
     * Retrieves a pseudo roster based off of a registration.
     *
     * @param jid To retrieve the roster for.
     * @param type TransportType the roster is for.
     * @return A Pseudo roster
     * @throws UserNotFoundException if the user is not actually registered.
     */
public PseudoRoster getPseudoRoster(JID jid, TransportType type) throws UserNotFoundException {
    Collection<Registration> registrations = RegistrationManager.getInstance().getRegistrations(jid, type);
    if (registrations.isEmpty()) {
        // User is not registered with us.
        throw new UserNotFoundException("Unable to find registration.");
    }
    Registration registration = registrations.iterator().next();
    return getPseudoRoster(registration);
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) Registration(net.sf.kraken.registration.Registration)

Example 2 with Registration

use of net.sf.kraken.registration.Registration in project Openfire by igniterealtime.

the class XMLRPCConduit method updateRegistration.

/**
     * Updates a registration.
     *
     * @param password Auth password for making changes
     * @param user Username or full JID of user who is getting an account updated.
     * @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 "Success" on success.
     */
public String updateRegistration(String password, String user, String transportType, String legacyUsername, String legacyPassword, String legacyNickname) {
    if (!verifyPassword(password)) {
        return "Authorization failed!";
    }
    JID jid;
    if (user.contains("@")) {
        jid = new JID(user);
    } else {
        jid = new JID(user, XMPPServer.getInstance().getServerInfo().getXMPPDomain(), null);
    }
    Collection<Registration> registrations = RegistrationManager.getInstance().getRegistrations(jid, TransportType.valueOf(transportType));
    if (registrations.isEmpty()) {
        // User is not registered with us.
        return "Unable to find registration to update.";
    }
    Registration registration = registrations.iterator().next();
    String results = configManager.updateRegistration((int) registration.getRegistrationID(), legacyUsername, legacyPassword, legacyNickname);
    if (results == null) {
        return "Success";
    } else {
        return results;
    }
}
Also used : JID(org.xmpp.packet.JID) Registration(net.sf.kraken.registration.Registration)

Example 3 with Registration

use of net.sf.kraken.registration.Registration in project Openfire by igniterealtime.

the class XMLRPCConduit method getRegistrations.

/**
    * Lists  the currently registered transports for a given User.
    * @param password Auth password for making changes
    * @param user Username or full JID of user whose registrations should be listed
    * @return a Collection of RegistrationBeans. In XML-RPC, this will convert into an array of structs.
    */
public Collection<RegistrationBean> getRegistrations(String password, String user) {
    /*
          * the redstone xml-rpc library can convert collections into xml-rpc arrays and
          * load all properties from a java bean into an xml-rpc struct
          */
    if (!verifyPassword(password)) {
        return Collections.emptyList();
    }
    JID jid;
    if (user.contains("@")) {
        jid = new JID(user);
    } else {
        jid = new JID(user, XMPPServer.getInstance().getServerInfo().getXMPPDomain(), null);
    }
    Collection<Registration> registrations = RegistrationManager.getInstance().getRegistrations(jid);
    Collection<RegistrationBean> result = new LinkedList<RegistrationBean>();
    /*
          * copy the values of Registration objects
          * into RegistrationBean objects. Unfortunately the Registration bean is too complex to send
          * it directly.  There is also a bug in redstone xml-rpc, it assumes that there is a getter for
          * a property if there is a setter, too.
          */
    for (Registration r : registrations) {
        result.add(new RegistrationBean(r));
    }
    return result;
}
Also used : JID(org.xmpp.packet.JID) Registration(net.sf.kraken.registration.Registration)

Example 4 with Registration

use of net.sf.kraken.registration.Registration in project Openfire by igniterealtime.

the class XMLRPCConduit method getAllRegistrations.

/**
     * Lists  the currently registered transports for all Users.
     * @param password Auth password for making changes
     * @return a Map of <user,Collection of RegistrationBeans>. In XML-RPC, this will convert into an array of structs.
     */
public Map<String, Collection<RegistrationBean>> getAllRegistrations(String password) {
    /*
           * the redstone xml-rpc library can convert collections into xml-rpc arrays and
           * load all properties from a java bean into an xml-rpc struct
           */
    if (!verifyPassword(password)) {
        return null;
    }
    Collection<Registration> registrations = RegistrationManager.getInstance().getRegistrations();
    Map<String, Collection<RegistrationBean>> result = new HashMap<String, Collection<RegistrationBean>>();
    for (Registration reg : registrations) {
        Collection<RegistrationBean> coll = result.get(reg.getJID().getNode());
        if (coll == null) {
            coll = new LinkedList<RegistrationBean>();
            result.put(reg.getJID().getNode(), coll);
        }
        coll.add(new RegistrationBean(reg));
    }
    return result;
}
Also used : Registration(net.sf.kraken.registration.Registration)

Example 5 with Registration

use of net.sf.kraken.registration.Registration 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;
    }
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) JID(org.xmpp.packet.JID) Registration(net.sf.kraken.registration.Registration) NotFoundException(org.jivesoftware.util.NotFoundException) GroupNotFoundException(org.jivesoftware.openfire.group.GroupNotFoundException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) TransportSession(net.sf.kraken.session.TransportSession) KrakenPlugin(net.sf.kraken.KrakenPlugin)

Aggregations

Registration (net.sf.kraken.registration.Registration)9 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)5 NotFoundException (org.jivesoftware.util.NotFoundException)4 JID (org.xmpp.packet.JID)4 KrakenPlugin (net.sf.kraken.KrakenPlugin)3 PluginManager (org.jivesoftware.openfire.container.PluginManager)3 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)3 TransportSession (net.sf.kraken.session.TransportSession)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Lock (java.util.concurrent.locks.Lock)1 BaseTransport (net.sf.kraken.BaseTransport)1 RegistrationHandler (net.sf.kraken.registration.RegistrationHandler)1 TransportBuddy (net.sf.kraken.roster.TransportBuddy)1 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)1 UserAlreadyExistsException (org.jivesoftware.openfire.user.UserAlreadyExistsException)1