/** * Blocks an external component from connecting to the local server. If the component was * * <p>connected when the permission was revoked then the connection of the entity will be closed. * * @param subdomain the subdomain of the external component that is not allowed to connect. */ public static void blockAccess(String subdomain) { // Remove any previous configuration for this external component deleteConfiguration(subdomain); // Update the database with the new revoked permission ExternalComponentConfiguration config = new ExternalComponentConfiguration(subdomain); config.setPermission(Permission.blocked); addConfiguration(config); // Check if the component was connected and proceed to close the connection String domain = subdomain + "." + XMPPServer.getInstance().getServerInfo().getDefaultName(); Session session = SessionManager.getInstance().getComponentSession(domain); if (session != null) { session.getConnection().close(); } }
/** * Deletes a user from all the groups where he/she belongs. The most probable cause for this * request is that the user has been deleted from the system. * * <p>TODO: remove this method and use events isntead. * * @param user the deleted user from the system. */ public void deleteUser(User user) { JID userJID = XMPPServer.getInstance().createJID(user.getUsername(), null); for (Group group : getGroups(userJID)) { if (group.getAdmins().contains(userJID)) { group.getAdmins().remove(userJID); } else { group.getMembers().remove(userJID); } } }