Ejemplo n.º 1
0
  /**
   * Put cas response attributes into model.
   *
   * @param model the model
   * @param attributes the attributes
   * @param registeredService the registered service
   */
  protected void putCasResponseAttributesIntoModel(
      final Map<String, Object> model,
      final Map<String, Object> attributes,
      final RegisteredService registeredService) {
    final Map<String, Object> encodedAttributes =
        this.casAttributeEncoder.encodeAttributes(attributes, getServiceFrom(model));
    super.putIntoModel(
        model,
        CasProtocolConstants.VALIDATION_CAS_MODEL_ATTRIBUTE_NAME_ATTRIBUTES,
        encodedAttributes);

    final List<String> formattedAttributes = new ArrayList<>(encodedAttributes.size());
    encodedAttributes.forEach(
        (k, v) -> {
          final Set<Object> values = CollectionUtils.convertValueToCollection(v);
          values.forEach(
              value -> {
                final StringBuilder builder = new StringBuilder();
                builder.append("<cas:".concat(k).concat(">"));
                builder.append(value.toString().trim());
                builder.append("</cas:".concat(k).concat(">"));
                formattedAttributes.add(builder.toString());
              });
        });
    super.putIntoModel(
        model,
        CasProtocolConstants.VALIDATION_CAS_MODEL_ATTRIBUTE_NAME_FORMATTED_ATTRIBUTES,
        formattedAttributes);
  }