コード例 #1
0
  @Override
  public boolean onHttpRequestSend(HttpMessage message) {
    if (isActive() && SAMLUtils.hasSAMLMessage(message)) {
      try {
        SAMLMessage samlMessage = new SAMLMessage(message);

        // change the params
        for (Attribute attribute : configuration.getAutoChangeAttributes()) {
          String value = attribute.getValue().toString();
          boolean changed = samlMessage.changeAttributeValueTo(attribute.getName(), value);
          if (changed) {
            log.debug(attribute.getName() + ": value changed to " + value);
          }
        }

        // change the original message
        HttpMessage changedMessege = samlMessage.getChangedMessage();
        if (changedMessege != message) {
          // check for reference, if they are same the message is already changed,
          // else the header and body are changed
          message.setRequestBody(changedMessege.getRequestBody());
          message.setRequestHeader(changedMessege.getRequestHeader());
        }

      } catch (SAMLException ignored) {
      }
    }
    return true;
  }