Example #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);
  }
Example #2
0
  @Override
  protected void prepareMergedOutputModel(
      final Map<String, Object> model,
      final HttpServletRequest request,
      final HttpServletResponse response)
      throws Exception {
    super.prepareMergedOutputModel(model, request, response);

    final Service service = super.getServiceFrom(model);
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);

    final Map<String, Object> attributes = new HashMap<>();
    attributes.putAll(getCasPrincipalAttributes(model, registeredService));

    if (this.releaseProtocolAttributes) {
      attributes.putAll(getCasProtocolAuthenticationAttributes(model, registeredService));
    }

    decideIfCredentialPasswordShouldBeReleasedAsAttribute(attributes, model, registeredService);
    decideIfProxyGrantingTicketShouldBeReleasedAsAttribute(attributes, model, registeredService);

    putCasResponseAttributesIntoModel(model, attributes, registeredService);
  }