コード例 #1
0
  /**
   * Returns a map with the requested attributes.
   *
   * @param required If set to true the list of 'required' attributes is returned, otherwise the
   *     list of 'optional' attributes.
   * @return List of attribute names.
   */
  public List getAttributes(boolean required) {
    List attributes = new ArrayList();

    String level = required ? "required" : "optional";

    Parameter param = _parameters.getParameter(level);
    if (param != null) {
      String[] values = param.getValue().split(",");
      for (int i = 0; i < values.length; i++) {
        String attr = multivalDecode(values[i]);
        attributes.add(attr);
      }
    }

    return attributes;
  }
コード例 #2
0
  /**
   * Adds an attribute to the SReg request.
   *
   * @param attr A requested attribute name.
   * @param required If true, marks the attribute as 'required'; 'if_available' otherwise.
   */
  public void addAttribute(String attr, boolean required) {
    String level = required ? "required" : "optional";

    Parameter levelParam = _parameters.getParameter(level);
    Parameter newParam;

    if (levelParam == null) {
      newParam = new Parameter(level, multivalEncode(attr));
    } else {
      newParam = new Parameter(level, levelParam.getValue() + "," + multivalEncode(attr));
      _parameters.removeParameters(level);
    }

    _parameters.set(newParam);

    if (DEBUG)
      _log.debug("Added new attribute to SReg request: " + attr + " required: " + required);
  }