title: How to decode SAML Response and get the attribute values sent by Idp in PHP
body: <p>I am implementing SAML Single Sign-On and using idp initiated method for login request. After login it redirect users on the login url defined on the request with the base64 encoded SAML Response.</p>
  
  <p>Now, I have extract to this response, validate it and get the attribute value sent by the Idp like email address, name etc.</p>
  
  <p>I have decoded from base64 and got the following XML. This XML have encrypted Signature, CipherData, Certificate etc.. but don't know how to validate and decode/extract the attribute values so that we can use it further.</p>
  
  <p>I search for it and fond the <a href="https://www.samltool.com/attributes.php" rel="nofollow">online tool</a>  which is decoding it, by providing the private key. I tried it and got the attribute values.</p>
  
  <p>The same thing I have to do in our application using PHP and have to use this attributes value. If any one have did the same thing and can put some light on it then it will be really appreciated.</p>
  
  <p>Pleas Check the SAML Response below.</p>
  
  <pre><code>&lt;samlp:Response Version="2.0" ID="vafmraxdfkermx" IssueInstant="2015-07-31T07:26:00.180Z" Destination="http://domain.com/saml/SSO" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"&gt;
  &lt;saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"&gt;MI-TEST-SAML2-EntityID&lt;/saml:Issuer&gt;
  &lt;ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
      &lt;ds:SignedInfo&gt;
          &lt;ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
          &lt;ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/&gt;
          &lt;ds:Reference URI="#DLSr8z03t7WZ-F7ZFwbxUw91vQF"&gt;
              &lt;ds:Transforms&gt;
                  &lt;ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/&gt;
                  &lt;ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/&gt;
              &lt;/ds:Transforms&gt;
              &lt;ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/&gt;
              &lt;ds:DigestValue&gt;gnvnDwu/eDBpLnPtiaHeOI7UCD4=&lt;/ds:DigestValue&gt;
          &lt;/ds:Reference&gt;
      &lt;/ds:SignedInfo&gt;
      &lt;ds:SignatureValue&gt;
          Signature Value
      &lt;/ds:SignatureValue&gt;
      &lt;ds:KeyInfo&gt;
          &lt;ds:X509Data&gt;
              &lt;ds:X509Certificate&gt;
                  Certifivate Contents
              &lt;/ds:X509Certificate&gt;
          &lt;/ds:X509Data&gt;
      &lt;/ds:KeyInfo&gt;
  &lt;/ds:Signature&gt;
  &lt;samlp:Status&gt;
      &lt;samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/&gt;
  &lt;/samlp:Status&gt;
  &lt;saml:EncryptedAssertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"&gt;
      &lt;xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"&gt;
          &lt;xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/&gt;
          &lt;ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
              &lt;xenc:EncryptedKey&gt;
                  &lt;xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/&gt;
                  &lt;xenc:CipherData&gt;
                      &lt;xenc:CipherValue&gt;CIPHER VALUE&lt;/xenc:CipherValue&gt;
                  &lt;/xenc:CipherData&gt;
              &lt;/xenc:EncryptedKey&gt;
          &lt;/ds:KeyInfo&gt;
          &lt;xenc:CipherData&gt;
              &lt;xenc:CipherValue&gt;CIPHER CONTETNS&lt;/xenc:CipherValue&gt;
          &lt;/xenc:CipherData&gt;
      &lt;/xenc:EncryptedData&gt;
  &lt;/saml:EncryptedAssertion&gt;
  </code></pre>
  
  <p></p>