use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.
the class IQQueryHandler method handleIQ.
public IQ handleIQ(IQ packet) throws UnauthorizedException {
Session session = sessionManager.getSession(packet.getFrom());
// If no session was found then answer with an error (if possible)
if (session == null) {
Log.error("Error during resource binding. Session not found in " + sessionManager.getPreAuthenticatedKeys() + " for key " + packet.getFrom());
return buildErrorResponse(packet);
}
if (packet.getType().equals(IQ.Type.get)) {
return buildSupportedFieldsResult(packet, session);
}
// Default to user's own archive
JID archiveJid = packet.getTo();
if (archiveJid == null) {
archiveJid = packet.getFrom().asBareJID();
}
Log.debug("Archive requested is {}", archiveJid);
// Now decide the type.
boolean muc = false;
if (!XMPPServer.getInstance().isLocal(archiveJid)) {
Log.debug("Archive is not local (user)");
if (XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(archiveJid) == null) {
Log.debug("No chat service for this domain");
return buildErrorResponse(packet);
} else {
muc = true;
Log.debug("MUC");
}
}
JID requestor = packet.getFrom().asBareJID();
Log.debug("Requestor is {} for muc=={}", requestor, muc);
// Auth checking.
if (muc) {
MultiUserChatService service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(archiveJid);
MUCRoom room = service.getChatRoom(archiveJid.getNode());
if (room == null) {
return buildErrorResponse(packet);
}
boolean pass = false;
if (service.isSysadmin(requestor)) {
pass = true;
}
MUCRole.Affiliation aff = room.getAffiliation(requestor);
if (aff != MUCRole.Affiliation.outcast) {
if (aff == MUCRole.Affiliation.owner || aff == MUCRole.Affiliation.admin) {
pass = true;
} else if (room.isMembersOnly()) {
if (aff == MUCRole.Affiliation.member) {
pass = true;
}
} else {
pass = true;
}
}
if (!pass) {
return buildForbiddenResponse(packet);
}
} else if (!archiveJid.equals(requestor)) {
// ... disallow unless admin.
if (!XMPPServer.getInstance().getAdmins().contains(requestor)) {
return buildForbiddenResponse(packet);
}
}
sendMidQuery(packet, session);
final QueryRequest queryRequest = new QueryRequest(packet.getChildElement(), archiveJid);
Collection<ArchivedMessage> archivedMessages = retrieveMessages(queryRequest);
for (ArchivedMessage archivedMessage : archivedMessages) {
sendMessageResult(session, queryRequest, archivedMessage);
}
sendEndQuery(packet, session, queryRequest);
return null;
}
use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.
the class RoomAvailableEvent method run.
@Override
public void run() {
MultiUserChatService mucService = room.getMUCService();
mucService.chatRoomAdded(room);
}
use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.
the class OccupantKickedForNicknameTask method run.
@Override
public void run() {
final MultiUserChatService multiUserChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(subdomain);
((MultiUserChatServiceImpl) multiUserChatService).getOccupantManager().process(this);
}
use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.
the class OccupantAddedTask method run.
@Override
public void run() {
final MultiUserChatService multiUserChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(subdomain);
((MultiUserChatServiceImpl) multiUserChatService).getOccupantManager().process(this);
}
use of org.jivesoftware.openfire.muc.MultiUserChatService in project Openfire by igniterealtime.
the class OccupantRemovedTask method run.
@Override
public void run() {
final MultiUserChatService multiUserChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(subdomain);
((MultiUserChatServiceImpl) multiUserChatService).getOccupantManager().process(this);
}
Aggregations