Exemplo n.º 1
0
  /**
   * Checks for permission and throw an exception if not allowed. May block to ask the user a
   * question.
   *
   * @param permission ID of the permission to check for, the ID must be from {@link Permissions}
   * @param name name of the suite
   * @param resource string to insert into the question, can be null
   * @exception SecurityException if the permission is not allowed by this token
   * @exception InterruptedException if another thread interrupts the calling thread while this
   *     method is waiting to preempt the display.
   */
  protected void checkForPermission(int permission, String name, String resource)
      throws InterruptedException {
    String protocolName = null;

    try {
      int colon = resource.indexOf(':');

      if (colon != -1) {
        protocolName = resource.substring(0, colon);
      }
    } catch (Exception e) {
      // ignore
    }

    securityToken.checkForPermission(
        permission,
        Permissions.getTitle(permission),
        Permissions.getQuestion(permission),
        name,
        resource,
        protocolName);
  }