Example #1
0
  zlib.inflateRaw(data, function(err, inflated) {
    if (err) {
      return next(err);
    }

    var xml;
    try {
      xml = (new xmldom.DOMParser()).parseFromString(inflated.toString("utf8"));
    } catch (e) {
      return next(e);
    }

    if (!xml) {
      return next(Error("couldn't parse XML"));
    }

    if (this.idp.certificate) {
      var valid;
      try {
        valid = this.idp.verify(xml);
      } catch (e) {
        return next(e);
      }

      if (!valid) {
        return next(Error("signature for IDP response was invalid"));
      }
    }

    var message;
    try {
      message = saml2.Protocol.fromXML(xml.documentElement);
    } catch (e) {
      return next(e);
    }

    if (!message) {
      return next(Error("couldn't construct message from tag: " + xml.documentElement.localName));
    }

    req.samlMessage = message;

    return next();
  });
Example #2
0
  return this.idp.verify(xml.documentElement, function(err) {
    if (err) {
      return next(err);
    }

    var message;
    try {
      message = saml2.Protocol.fromXML(xml.documentElement);
    } catch (e) {
      return next(e);
    }

    if (!message) {
      return next(Error("couldn't construct message from tag: " + xml.documentElement.localName));
    }

    req.samlMessage = message;

    return next();
  });