Examples of ForbiddenException


Examples of org.jivesoftware.openfire.muc.ForbiddenException

                Element metaData;
                if ("outcast".equals(affiliation)) {
                    // The client is requesting the list of outcasts
                    if (MUCRole.Affiliation.admin != senderRole.getAffiliation()
                            && MUCRole.Affiliation.owner != senderRole.getAffiliation()) {
                        throw new ForbiddenException();
                    }
                    for (String jid : room.getOutcasts()) {
                        metaData = result.addElement("item", "http://jabber.org/protocol/muc#admin");
                        metaData.addAttribute("affiliation", "outcast");
                        metaData.addAttribute("jid", jid);
                    }

                } else if ("member".equals(affiliation)) {
                    // The client is requesting the list of members
                    // In a members-only room members can get the list of members
                    if (!room.isMembersOnly()
                            && MUCRole.Affiliation.admin != senderRole.getAffiliation()
                            && MUCRole.Affiliation.owner != senderRole.getAffiliation()) {
                        throw new ForbiddenException();
                    }
                    for (String jid : room.getMembers()) {
                        metaData = result.addElement("item", "http://jabber.org/protocol/muc#admin");
                        metaData.addAttribute("affiliation", "member");
                        metaData.addAttribute("jid", jid);
                        try {
                            List<MUCRole> roles = room.getOccupantsByBareJID(jid);
                            MUCRole role = roles.get(0);
                            metaData.addAttribute("role", role.getRole().toString());
                            metaData.addAttribute("nick", role.getNickname());
                        }
                        catch (UserNotFoundException e) {
                            // Do nothing
                        }
                    }
                } else if ("moderator".equals(roleAttribute)) {
                    // The client is requesting the list of moderators
                    if (MUCRole.Affiliation.admin != senderRole.getAffiliation()
                            && MUCRole.Affiliation.owner != senderRole.getAffiliation()) {
                        throw new ForbiddenException();
                    }
                    for (MUCRole role : room.getModerators()) {
                        metaData = result.addElement("item", "http://jabber.org/protocol/muc#admin");
                        metaData.addAttribute("role", "moderator");
                        metaData.addAttribute("jid", role.getUserAddress().toString());
                        metaData.addAttribute("nick", role.getNickname());
                        metaData.addAttribute("affiliation", role.getAffiliation().toString());
                    }
                } else if ("participant".equals(roleAttribute)) {
                    // The client is requesting the list of participants
                    if (MUCRole.Role.moderator != senderRole.getRole()) {
                        throw new ForbiddenException();
                    }
                    for (MUCRole role : room.getParticipants()) {
                        metaData = result.addElement("item", "http://jabber.org/protocol/muc#admin");
                        metaData.addAttribute("role", "participant");
                        metaData.addAttribute("jid", role.getUserAddress().toString());
                        metaData.addAttribute("nick", role.getNickname());
                        metaData.addAttribute("affiliation", role.getAffiliation().toString());
                    }
                } else {
                    reply.setError(PacketError.Condition.bad_request);
                }
            }
        }
        else {
            // The client is modifying the list of moderators/members/participants/outcasts
            JID jid;
            String nick;
            String target;
            boolean hasAffiliation = ((Element) itemsList.get(0)).attributeValue("affiliation") !=
                    null;

            // Keep a registry of the updated presences
            List<Presence> presences = new ArrayList<Presence>(itemsList.size());

            // Collect the new affiliations or roles for the specified jids
            for (Object anItem : itemsList) {
                try {
                    item = (Element) anItem;
                    target = (hasAffiliation ? item.attributeValue("affiliation") : item
                            .attributeValue("role"));
                    // jid could be of the form "full JID" or "bare JID" depending if we are
                    // going to change a role or an affiliation
                    if (hasJID) {
                        jid = new JID(item.attributeValue("jid"));
                        nick = null;
                    } else {
                        // Get the JID based on the requested nick
                        nick = item.attributeValue("nick");
                        jid = room.getOccupant(nick).getUserAddress();
                    }

                    if ("moderator".equals(target)) {
                        // Add the user as a moderator of the room based on the full JID
                        presences.add(room.addModerator(jid, senderRole));
                    } else if ("participant".equals(target)) {
                        // Add the user as a participant of the room based on the full JID
                        presences.add(room.addParticipant(jid,
                                item.elementTextTrim("reason"),
                                senderRole));
                    } else if ("visitor".equals(target)) {
                        // Add the user as a visitor of the room based on the full JID
                        presences.add(room.addVisitor(jid, senderRole));
                    } else if ("member".equals(target)) {
                        // Add the user as a member of the room based on the bare JID
                        boolean hadAffiliation = room.getAffiliation(jid.toBareJID()) != MUCRole.Affiliation.none;
                        presences.addAll(room.addMember(jid, nick, senderRole));
                        // If the user had an affiliation don't send an invitation. Otherwise
                        // send an invitation if the room is members-only and skipping invites
                       // are not disabled system-wide xmpp.muc.skipInvite
                        if (!skipInvite && !hadAffiliation && room.isMembersOnly()) {
                            room.sendInvitation(jid, null, senderRole, null);
                        }
                    } else if ("outcast".equals(target)) {
                        // Add the user as an outcast of the room based on the bare JID
                        presences.addAll(room.addOutcast(jid, item.elementTextTrim("reason"), senderRole));
                    } else if ("none".equals(target)) {
                        if (hasAffiliation) {
                            // Set that this jid has a NONE affiliation based on the bare JID
                            presences.addAll(room.addNone(jid, senderRole));
                        } else {
                            // Kick the user from the room
                            if (MUCRole.Role.moderator != senderRole.getRole()) {
                                throw new ForbiddenException();
                            }
                            presences.add(room.kickOccupant(jid, senderRole.getUserAddress(),
                                    item.elementTextTrim("reason")));
                        }
                    } else {
View Full Code Here

Examples of org.jivesoftware.openfire.muc.ForbiddenException

     */
    @SuppressWarnings("unchecked")
  public void handleIQ(IQ packet, MUCRole role) throws ForbiddenException, ConflictException, CannotBeInvitedException {
        // Only owners can send packets with the namespace "http://jabber.org/protocol/muc#owner"
        if (MUCRole.Affiliation.owner != role.getAffiliation()) {
            throw new ForbiddenException();
        }

        IQ reply = IQ.createResultIQ(packet);
        Element element = packet.getChildElement();

        // Analyze the action to perform based on the included element
        Element formElement = element.element(QName.get("x", "jabber:x:data"));
        if (formElement != null) {
            handleDataFormElement(role, formElement);
        }
        else {
            Element destroyElement = element.element("destroy");
            if (destroyElement != null) {
                if (((MultiUserChatServiceImpl)room.getMUCService()).getMUCDelegate() != null) {
                    if (!((MultiUserChatServiceImpl)room.getMUCService()).getMUCDelegate().destroyingRoom(room.getName(), role.getUserAddress())) {
                        // Delegate said no, reject destroy request.
                        throw new ForbiddenException();
                    }
                }

                room.destroyRoom(destroyElement.attributeValue("jid"), destroyElement
                        .elementTextTrim("reason"));
View Full Code Here

Examples of org.keycloak.services.ForbiddenException

    @Path("register-node")
    @POST
    @Produces("application/json")
    public Response registerNode(@HeaderParam(HttpHeaders.AUTHORIZATION) String authorizationHeader, final MultivaluedMap<String, String> formData) {
        if (!checkSsl()) {
            throw new ForbiddenException("HTTPS required");
        }

        event.event(EventType.REGISTER_NODE);

        if (!realm.isEnabled()) {
View Full Code Here

Examples of org.sonar.server.exceptions.ForbiddenException

    currentSession.checkLoggedIn();
    if (componentKey == null) {
      currentSession.checkGlobalPermission(GlobalPermissions.SYSTEM_ADMIN);
    } else {
      if (!currentSession.hasGlobalPermission(GlobalPermissions.SYSTEM_ADMIN) && !currentSession.hasProjectPermission(UserRole.ADMIN, componentKey)) {
        throw new ForbiddenException("Insufficient privileges");
      }
    }
  }
View Full Code Here

Examples of org.tamacat.httpd.exception.ForbiddenException

          response.setStatusCode(HttpStatus.SC_OK);
          ResponseUtils.setEntity(response, getEntity(html));
        } else {
          ///// 403 FORBIDDEN /////
          LOG.trace("Cannot read file " + fs);
          throw new ForbiddenException();
        }
      }
      ///// FOR FILE /////
      else {
        LOG.trace("File " + fs + " found");
        response.setStatusCode(HttpStatus.SC_OK);
        ResponseUtils.setEntity(response, getFileEntity(fs, p));
      }
    } catch (IOException e) {
      throw new ForbiddenException(e);
    }
  }
View Full Code Here

Examples of org.tamacat.httpd.exception.ForbiddenException

//            ReverseUrl reverseUrl = serviceUrl.getReverseUrl();
//            accessUrl = reverseUrl.getServiceUrl().getPath();
//          } else {
//            accessUrl = serviceUrl.getPath();
//          }
          if (StringUtils.isEmpty(accessUrl)) throw new ForbiddenException();
         
          if (isSuccess(remoteUser, accessUrl) == false) {
            throw new ForbiddenException();
          }
        }
  }
View Full Code Here

Examples of org.tamacat.httpd.exception.ForbiddenException

      }
    }
    if (isAllow == false) {
      //allows only -> denied all.
      if (denies.size() == 0) {
        throw new ForbiddenException();
      }
      //match denies -> denied.
      for (Entry<String, Integer> entry : denies.entrySet()) {
        String address = entry.getKey();
        int octet = entry.getValue();
        if (address.equals(matcher[octet-1]) || "*".equals(address)) {
          throw new ForbiddenException();
        }
      }
    }
  }
View Full Code Here

Examples of org.tamacat.httpd.exception.ForbiddenException

            request, response, file);
        response.setStatusCode(HttpStatus.SC_OK);
        ResponseUtils.setEntity(response, getEntity(html));
      } else {
        LOG.trace("Cannot read file " + file.getPath());
        throw new ForbiddenException();
      }
    }
    ///// 200 OK /////
    else {
      LOG.trace("File " + file.getPath() + " found");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.