Java Code Examples for org.jivesoftware.openfire.XMPPServer

The following examples show how to use org.jivesoftware.openfire.XMPPServer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Openfire   Source File: GetBasicStatistics.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    SessionManager manager = SessionManager.getInstance();
    values = new HashMap<>();
    values.put(NODE, CacheFactory.getClusterMemberID());
    // Collect number of authenticated users
    values.put(CLIENT, manager.getUserSessionsCount(true));
    // Collect number of incoming server connections
    values.put(INCOMING, manager.getIncomingServerSessionsCount(true));
    // Collect number of outgoing server connections
    values.put(OUTGOING, XMPPServer.getInstance().getRoutingTable().getServerSessionsCount());
    // Calculate free and used memory
    Runtime runtime = Runtime.getRuntime();
    double freeMemory = (double) runtime.freeMemory() / (1024 * 1024);
    double maxMemory = (double) runtime.maxMemory() / (1024 * 1024);
    double totalMemory = (double) runtime.totalMemory() / (1024 * 1024);
    double usedMemory = totalMemory - freeMemory;
    values.put(MEMORY_CURRENT, usedMemory);
    values.put(MEMORY_MAX, maxMemory);
}
 
Example 2
Source Project: Openfire   Source File: IQDiscoInfoHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Removes a feature from the information returned whenever a disco for information is
 * made against the server.
 *
 * @param namespace the namespace of the feature to be removed.
 */
public void removeServerFeature(String namespace) {
    if (localServerFeatures.remove(namespace)) {
        Lock lock = CacheFactory.getLock(namespace, serverFeatures);
        try {
            lock.lock();
            HashSet<NodeID> nodeIDs = serverFeatures.get(namespace);
            if (nodeIDs != null) {
                nodeIDs.remove(XMPPServer.getInstance().getNodeID());
                if (nodeIDs.isEmpty()) {
                    serverFeatures.remove(namespace);
                }
                else {
                    serverFeatures.put(namespace, nodeIDs);
                }
            }
        }
        finally {
            lock.unlock();
        }
    }
}
 
Example 3
Source Project: Openfire   Source File: IQPEPHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    // Send the last published items for the contacts on availableSessionJID's roster.
    try {
        final XMPPServer server = XMPPServer.getInstance();
        final Roster roster = server.getRosterManager().getRoster(availableSessionJID.getNode());
        for (final RosterItem item : roster.getRosterItems()) {
            if (server.isLocal(item.getJid()) && (item.getSubStatus() == RosterItem.SUB_BOTH ||
                    item.getSubStatus() == RosterItem.SUB_TO)) {
                PEPService pepService = pepServiceManager.getPEPService(item.getJid().asBareJID());
                if (pepService != null) {
                    pepService.sendLastPublishedItems(availableSessionJID);
                }
            }
        }
    }
    catch (UserNotFoundException e) {
        // Do nothing
    }
}
 
Example 4
Source Project: Openfire   Source File: IdentityStore.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Generates an alias that is currently unused in this store.
 *
 * @return An alias (never null).
 * @throws CertificateStoreConfigException if a unique alias could not be generated
 */
protected synchronized String generateUniqueAlias() throws CertificateStoreConfigException
{
    final String domain = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
    int index = 1;
    String alias = domain + "_" + index;
    try
    {
        while ( store.containsAlias( alias ) )
        {
            index = index + 1;
            alias = domain + "_" + index;
        }
        return alias;
    }
    catch ( KeyStoreException e )
    {
        throw new CertificateStoreConfigException( "Unable to generate a unique alias for this identity store.", e );
    }
}
 
Example 5
Source Project: Openfire   Source File: MultiUserChatServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Accessor uses the "double-check idiom" for proper lazy instantiation.
 * @return An Archiver instance, never null.
 */
@Override
public Archiver getArchiver() {
    Archiver result = this.archiver;
    if (result == null) {
        synchronized (this) {
            result = this.archiver;
            if (result == null) {
                result = new ConversationLogEntryArchiver("MUC Service " + this.getAddress().toString(), logMaxConversationBatchSize, logMaxBatchInterval, logBatchGracePeriod);
                XMPPServer.getInstance().getArchiveManager().add(result);
                this.archiver = result;
            }
        }
    }

    return result;
}
 
Example 6
Source Project: Openfire   Source File: MultiUserChatServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void start() {
    XMPPServer.getInstance().addServerListener( this );

    // Run through the users every 5 minutes after a 5 minutes server startup delay (default values)
    userTimeoutTask = new UserTimeoutTask();
    TaskEngine.getInstance().schedule(userTimeoutTask, user_timeout, user_timeout);

    // Remove unused rooms from memory
    long cleanupFreq = JiveGlobals.getLongProperty("xmpp.muc.cleanupFrequency.inMinutes", CLEANUP_FREQUENCY) * 60 * 1000;
    TaskEngine.getInstance().schedule(new CleanupTask(), cleanupFreq, cleanupFreq);

    // Set us up to answer disco item requests
    XMPPServer.getInstance().getIQDiscoItemsHandler().addServerItemsProvider(this);
    XMPPServer.getInstance().getIQDiscoInfoHandler().setServerNodeInfoProvider(this.getServiceDomain(), this);

    Log.info(LocaleUtils.getLocalizedString("startup.starting.muc", Collections.singletonList(getServiceDomain())));

    // Load all the persistent rooms to memory
    for (final LocalMUCRoom room : MUCPersistenceManager.loadRoomsFromDB(this, this.getCleanupDate(), router)) {
        localMUCRoomManager.addRoom(room.getName().toLowerCase(),room);
    }
}
 
Example 7
Source Project: Openfire   Source File: GetNewMemberRoomsRequest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    rooms = new ArrayList<>();
    // Get all services that have local occupants and include them in the reply
    for (MultiUserChatService mucService : XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatServices()) {
        // Get rooms that have local occupants and include them in the reply
        for (MUCRoom room : mucService.getChatRooms()) {
            LocalMUCRoom localRoom = (LocalMUCRoom) room;
            Collection<MUCRole> localOccupants = new ArrayList<>();
            for (MUCRole occupant : room.getOccupants()) {
                if (occupant.isLocal()) {
                    localOccupants.add(occupant);
                }
            }
            if (!localOccupants.isEmpty()) {
                rooms.add(new RoomInfo(localRoom, localOccupants));
            }
        }
    }
}
 
Example 8
Source Project: Openfire   Source File: StanzaHandler.java    License: Apache License 2.0 6 votes vote down vote up
private String getStreamHeader() {
    StringBuilder sb = new StringBuilder(200);
    sb.append("<?xml version='1.0' encoding='");
    sb.append(CHARSET);
    sb.append("'?>");
    if (connection.isFlashClient()) {
        sb.append("<flash:stream xmlns:flash=\"http://www.jabber.com/streams/flash\" ");
    }
    else {
        sb.append("<stream:stream ");
    }
    sb.append("xmlns:stream=\"http://etherx.jabber.org/streams\" xmlns=\"");
    sb.append(getNamespace());
    sb.append("\" from=\"");
    sb.append(XMPPServer.getInstance().getServerInfo().getXMPPDomain());
    sb.append("\" id=\"");
    sb.append(session.getStreamID());
    sb.append("\" xml:lang=\"");
    sb.append(session.getLanguage().toLanguageTag());
    sb.append("\" version=\"");
    sb.append(Session.MAJOR_VERSION).append('.').append(Session.MINOR_VERSION);
    sb.append("\">");
    return sb.toString();
}
 
Example 9
Source Project: Openfire   Source File: IQDiscoItemsHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Removes a disco item for a component that has been removed from the server.
 *
 * @param jid the jid of the component being removed.
 */
public void removeComponentItem(String jid) {
    if (serverItems == null) {
        // Safety check
        return;
    }
    Lock lock = CacheFactory.getLock(jid, serverItems);
    try {
        lock.lock();
        ClusteredServerItem item = serverItems.get(jid);
        if (item != null && item.nodes.remove(XMPPServer.getInstance().getNodeID())) {
            // Update the cache with latest info
            if (item.nodes.isEmpty()) {
                serverItems.remove(jid);
            }
            else {
                serverItems.put(jid, item);
            }
        }
    }
    finally {
        lock.unlock();
    }
    // Remove locally added server item
    localServerItems.remove(jid);
}
 
Example 10
Source Project: Openfire   Source File: PublishedItem.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the {@link LeafNode} where this item was published.
 *
 * @return the leaf node where this item was published.
 */
public LeafNode getNode() {
    if (node == null) {
        synchronized (this) {
            if (node == null) {
                if (XMPPServer.getInstance().getPubSubModule().getServiceID().equals(serviceId))
                {
                    node = (LeafNode) XMPPServer.getInstance().getPubSubModule().getNode(nodeId);
                }
                else
                {
                    PEPServiceManager serviceMgr = XMPPServer.getInstance().getIQPEPHandler().getServiceManager();
                    JID service = new JID( serviceId );
                    node = serviceMgr.hasCachedService(service) ? (LeafNode) serviceMgr.getPEPService(service).getNode(nodeId) : null;
                }
            }
        }
    }
    return node;
}
 
Example 11
@Override
public PEPService loadPEPServiceFromDB(JID jid)
{
    final PubSubService.UniqueIdentifier id = new PubSubService.UniqueIdentifier( jid.toString() );
    final Lock lock = serviceIdToNodesCache.getLock( id );
    lock.lock();
    try {
        if ( serviceIdToNodesCache.containsKey( id ) ) {
            final PEPService pepService = new PEPService( XMPPServer.getInstance(), jid );
            pepService.initialize();

            // The JDBC variant stores subscriptions in the database. The in-memory variant cannot rely on this.
            // Subscriptions have to be repopulated from the roster instead.
            XMPPServer.getInstance().getIQPEPHandler().addSubscriptionForRosterItems( pepService );

            return pepService;
        } else {
            return null;
        }
    } finally {
        lock.unlock();
    }
}
 
Example 12
Source Project: openfire-ofmeet-plugin   Source File: ConfigServlet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Generates an URL on which client / BOSH connections are expected.
 *
 * This method will verify if the websocket plugin is available. If it is, the websocket endpoint is returned. When
 * websocket is not available, the http-bind endpoint is returned.
 *
 * Since Openfire version 4.2.0 (OF-1339) the websocket functionality that was previously provided by a plugin, was
 * merged with the core Openfire code. After version 4.2.1, there is no need to check for the presence of the
 * plugin.
 *
 * The request that is made to this servlet is used to determine if the client prefers secure/encrypted connections
 * (https, wss) over plain ones (http, ws), and to determine what the server address and port is.
 *
 * @param request the request to this servlet.
 * @return An URI (never null).
 * @throws URISyntaxException When an URI could not be constructed.
 */
public static URI getMostPreferredConnectionURL( HttpServletRequest request ) throws URISyntaxException
{
    Log.debug( "[{}] Generating BOSH URL based on {}", request.getRemoteAddr(), request.getRequestURL() );
    final String preferredMechanism = JiveGlobals.getProperty( "ofmeet.connection.mechanism.preferred" );
    final boolean webSocketInCore = !new Version(4, 2, 0, null, -1 ).isNewerThan( XMPPServer.getInstance().getServerInfo().getVersion() );
    if ( !"http-bind".equalsIgnoreCase( preferredMechanism ) && (webSocketInCore || XMPPServer.getInstance().getPluginManager().getPlugin( "websocket" ) != null ) )
    {
        Log.debug( "[{}] Websocket functionality is available. Returning a websocket address.", request.getRemoteAddr() );
        final String websocketScheme;
        if ( request.getScheme().endsWith( "s" ) )
        {
            websocketScheme = "wss";
        }
        else
        {
            websocketScheme = "ws";
        }

        return new URI( websocketScheme, null, request.getServerName(), request.getServerPort(), "/ws/", null, null);
    }
    else
    {
        Log.debug( "[{}] No Websocket functionality available. Returning an HTTP-BIND address.", request.getRemoteAddr() );
        return new URI( request.getScheme(), null, request.getServerName(), request.getServerPort(), "/http-bind/", null, null);
    }
}
 
Example 13
Source Project: openfire-ofmeet-plugin   Source File: JigasiWrapper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Attemt to create an XMPP user that will represent the SIP contact that is pulled into a Meet.
 */
private static void ensureJigasiUser()
{
    final OFMeetConfig config = new OFMeetConfig();

    final String userId = config.getJigasiXmppUserId().get();

    // Ensure that the user exists.
    final UserManager userManager = XMPPServer.getInstance().getUserManager();
    if ( !userManager.isRegisteredUser( userId ) )
    {
        Log.info( "No pre-existing jigasi user '{}' detected. Generating one.", userId );

        if ( UserManager.getUserProvider().isReadOnly() ) {
            Log.info( "The user provider on this system is read only. Cannot create a Jigasi user account." );
            return;
        }

        String password = config.getJigasiXmppPassword().get();
        if ( password == null || password.isEmpty() )
        {
            password = StringUtils.randomString( 40 );
        }

        try
        {
            userManager.createUser(
                userId,
                password,
                "Jigasi User (generated)",
                null
            );
            config.getJigasiXmppPassword().set( password );
        }
        catch ( Exception e )
        {
            Log.error( "Unable to provision a jigasi user.", e );
        }
    }
}
 
Example 14
Source Project: Openfire   Source File: IQPrivateHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException, PacketException {
    IQ replyPacket = IQ.createResultIQ(packet);

    Element child = packet.getChildElement();
    Element dataElement = child.elementIterator().next();

    if ( !XMPPServer.getInstance().isLocal( packet.getFrom()) || !UserManager.getInstance().isRegisteredUser( packet.getFrom()) ) {
        replyPacket.setChildElement(packet.getChildElement().createCopy());
        replyPacket.setError(PacketError.Condition.service_unavailable);
        replyPacket.getError().setText( "Service available only to locally registered users." );
        return replyPacket;
    }

    if (dataElement != null) {
        if (IQ.Type.get.equals(packet.getType())) {
            Element dataStored = privateStorage.get(packet.getFrom().getNode(), dataElement);
            dataStored.setParent(null);

            child.remove(dataElement);
            child.setParent(null);
            replyPacket.setChildElement(child);
            child.add(dataStored);
        }
        else {
            if (privateStorage.isEnabled()) {
                privateStorage.add(packet.getFrom().getNode(), dataElement);
            } else {
                replyPacket.setChildElement(packet.getChildElement().createCopy());
                replyPacket.setError(PacketError.Condition.service_unavailable);
            }
        }
    }
    else {
        replyPacket.setChildElement("query", "jabber:iq:private");
    }
    return replyPacket;
}
 
Example 15
Source Project: Openfire   Source File: SystemPropertyTest.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"deprecation", "ResultOfMethodCallIgnored"})
@Before
public void setUp() {
    Fixtures.clearExistingProperties();
    doReturn(pluginManager).when(xmppServer).getPluginManager();
    XMPPServer.setInstance(xmppServer);
}
 
Example 16
Source Project: Openfire   Source File: ClientSessionConnection.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ConnectionConfiguration getConfiguration()
{
    // Here, a client-to-server configuration is mocked. It is likely not used, as actual connection handling takes
    // place at the connection manager.
    final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
    return connectionManager.getListener( ConnectionType.SOCKET_C2S, true ).generateConnectionConfiguration();
}
 
Example 17
Source Project: Openfire   Source File: ArchiveManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the manager, by instantiating a thread pool that is used to process archiving tasks.
 */
@Override
public void initialize( final XMPPServer server )
{
    if ( executor != null )
    {
        throw new IllegalStateException( "Already initialized." );
    }
    executor = Executors.newCachedThreadPool( new NamedThreadFactory( "archive-service-worker-", null, null, null ) );
}
 
Example 18
Source Project: Openfire   Source File: ChangeUserPassword.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void execute(SessionData data, Element command) {
    Element note = command.addElement("note");
    // Check if groups cannot be modified (backend is read-only)
    if (UserManager.getUserProvider().isReadOnly()) {
        note.addAttribute("type", "error");
        note.setText("Users are read only. Changing password is not allowed.");
        return;
    }
    JID account = new JID(data.getData().get("accountjid").get(0));
    String newPassword = data.getData().get("password").get(0);
    if (!XMPPServer.getInstance().isLocal(account)) {
        note.addAttribute("type", "error");
        note.setText("Cannot change password of remote user.");
        return;
    }
    // Get requested group
    User user;
    try {
        user = UserManager.getInstance().getUser(account.getNode());
    } catch (UserNotFoundException e) {
        // Group not found
        note.addAttribute("type", "error");
        note.setText("User does not exists.");
        return;
    }
    // Set the new passowrd of the user
    user.setPassword(newPassword);
    // Answer that the operation was successful
    note.addAttribute("type", "info");
    note.setText("Operation finished successfully");
}
 
Example 19
Source Project: Openfire   Source File: UpdateManager.java    License: Apache License 2.0 5 votes vote down vote up
private String getServerUpdateRequest() {
    XMPPServer server = XMPPServer.getInstance();
    Element xmlRequest = docFactory.createDocument().addElement("version");
    // Add current openfire version
    Element openfire = xmlRequest.addElement("openfire");
    openfire.addAttribute("current", server.getServerInfo().getVersion().getVersionString());
    return xmlRequest.asXML();
}
 
Example 20
Source Project: Openfire   Source File: ExternalComponentManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param enabled enables or disables the service
 * @deprecated Obtain and use the corresponding {@link org.jivesoftware.openfire.spi.ConnectionListener} instead.
 * @throws ModificationNotAllowedException if the status of the service cannot be changed
 */
@Deprecated
public static void setServiceEnabled(boolean enabled) throws ModificationNotAllowedException {
    // Alert listeners about this event
    for (ExternalComponentManagerListener listener : listeners) {
        try {
            listener.serviceEnabled(enabled);
        } catch (Exception e) {
            Log.warn("An exception occurred while dispatching a 'serviceEnabled' event!", e);
        }
    }
    ConnectionManager connectionManager = XMPPServer.getInstance().getConnectionManager();
    connectionManager.enableComponentListener(enabled);
}
 
Example 21
Source Project: Openfire   Source File: MultiUserChatServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void stop() {
    XMPPServer.getInstance().getIQDiscoItemsHandler().removeServerItemsProvider(this);
    XMPPServer.getInstance().getIQDiscoInfoHandler().removeServerNodeInfoProvider(this.getServiceDomain());
    // Remove the route to this service
    routingTable.removeComponentRoute(getAddress());
    broadcastShutdown();
    XMPPServer.getInstance().removeServerListener( this );
    if (archiver != null) {
        XMPPServer.getInstance().getArchiveManager().remove(archiver);
    }
}
 
Example 22
Source Project: Openfire   Source File: RemoteMUCRole.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void send(Packet packet) {
    if (this.isRemoteFmuc()) {
        // Sending stanzas to individual occupants that are on remote FMUC nodes defeats the purpose of FMUC, which is to reduce message. This reduction is based on sending data just once, and have it 'fan out' on the remote node (as opposed to sending each occupant on that node a distinct stanza from this node).
        Log.warn( "Sending data directly to an entity ({}) on a remote FMUC node. Instead of individual messages, we expect data to be sent just once (and be fanned out locally by the remote node).", this, new Throwable() );

        // Check if stanza needs to be enriched with FMUC metadata.
        augmentOutboundStanzaWithFMUCData(packet);
    }

    XMPPServer.getInstance().getRoutingTable().routePacket(userAddress, packet, false);
}
 
Example 23
Source Project: openfireLBS   Source File: OpenfireLBSPlugin.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initializePlugin(PluginManager manager, File pluginDirectory) {
	try {
		openfireDBConn = DbConnectionManager.getConnection();
	} catch (SQLException e) {
		e.printStackTrace();
	}
	
	server = XMPPServer.getInstance();
	
	server.getIQRouter().addHandler(new LocationHandler(MODULE_NAME_LOCATION));
}
 
Example 24
Source Project: Openfire   Source File: MUCRoomTask.java    License: Apache License 2.0 5 votes vote down vote up
public LocalMUCRoom getRoom() {
    MultiUserChatService mucService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(subdomain);
    if (mucService == null) {
        throw new IllegalArgumentException("MUC service not found for subdomain: "+subdomain);
    }
    LocalMUCRoom room = (LocalMUCRoom) mucService.getChatRoom(roomName);
    if (room == null) {
        throw new IllegalArgumentException("Room not found: " + roomName);
    }
    return room;
}
 
Example 25
Source Project: Openfire   Source File: IQOfflineMessagesHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(XMPPServer server) {
    super.initialize(server);
    infoHandler = server.getIQDiscoInfoHandler();
    itemsHandler = server.getIQDiscoItemsHandler();
    messageStore = server.getOfflineMessageStore();
    userManager = server.getUserManager();
    routingTable = server.getRoutingTable();
}
 
Example 26
Source Project: Openfire   Source File: GetNumberConnectedUsers.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    count = 0;
    for (MultiUserChatService mucService : XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatServices()) {
        count += mucService.getNumberConnectedUsers(true);
    }
}
 
Example 27
Source Project: Openfire   Source File: ServiceAddedEvent.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    // If it's registered already, no need to create it.  Most likely this is because the service
    // is provided by an internal component that registered at startup.  This scenario, however,
    // should really never occur.
    if (!XMPPServer.getInstance().getMultiUserChatManager().isServiceRegistered(subdomain)) {
        MultiUserChatService service = new MultiUserChatServiceImpl(subdomain, description, isHidden);
        XMPPServer.getInstance().getMultiUserChatManager().registerMultiUserChatService(service, false);
    }
}
 
Example 28
Source Project: Openfire   Source File: FileTransferProxy.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void stop() {
    super.stop();

    XMPPServer.getInstance().getIQDiscoItemsHandler()
            .removeComponentItem(getAddress().toString());
    routingTable.removeComponentRoute(getAddress());
    connectionManager.disable();
}
 
Example 29
Source Project: Openfire   Source File: AdminManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Adds a new account to the list of Admin accounts, based off a username, which will be converted
 * into a JID.
 *
 * @param username Username of account to add to list of admins.
 */
public void addAdminAccount(String username) {
    if (adminList == null) {
        loadAdminList();
    }
    JID userJID = XMPPServer.getInstance().createJID(username, null);
    if (adminList.contains(userJID)) {
        // Already have them.
        return;
    }
    // Add new admin to cache.
    adminList.add(userJID);
    // Store updated list of admins with provider.
    provider.setAdmins(adminList);
}
 
Example 30
Source Project: Openfire   Source File: AdminManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Removes an account from the list of Admin accounts, based off username, which will be converted
 * to a JID.
 *
 * @param username Username of user to remove from admin list.
 */
public void removeAdminAccount(String username) {
    if (adminList == null) {
        loadAdminList();
    }
    JID userJID = XMPPServer.getInstance().createJID(username, null);
    if (!adminList.contains(userJID)) {
        return;
    }
    // Remove user from admin list cache.
    adminList.remove(userJID);
    // Store updated list of admins with provider.
    provider.setAdmins(adminList);
}