attributeQueryAssertion parses and validates assertionEl. receivedEl is the assertion as received (see receivedChildren), on which its signature is checked.
(assertionEl, receivedEl *etree.Element, query *AttributeQuery, now time.Time, signatureRequired bool)
| 469 | // the assertion as received (see receivedChildren), on which its signature |
| 470 | // is checked. |
| 471 | func (sp *ServiceProvider) attributeQueryAssertion(assertionEl, receivedEl *etree.Element, query *AttributeQuery, now time.Time, signatureRequired bool) (*Assertion, error) { |
| 472 | // A signature that is present must be valid even when the Response is |
| 473 | // signed (saml-core §2.3.3). |
| 474 | signed, err := sp.verifySignedElement(receivedEl, sp.attributeAuthoritySigningCerts) |
| 475 | switch err { |
| 476 | case nil: |
| 477 | // Read the assertion from what the signature covers. |
| 478 | assertionEl = signed |
| 479 | case errSignatureElementNotPresent: |
| 480 | if signatureRequired { |
| 481 | return nil, errors.New("neither the Response nor its Assertion is signed") |
| 482 | } |
| 483 | default: |
| 484 | return nil, err |
| 485 | } |
| 486 | var assertion Assertion |
| 487 | if err := unmarshalElement(assertionEl, &assertion); err != nil { |
| 488 | return nil, err |
| 489 | } |
| 490 | if err := sp.decryptEncryptedIDs(assertion.Subject); err != nil { |
| 491 | return nil, fmt.Errorf("assertion %q: %w", assertion.ID, err) |
| 492 | } |
| 493 | if err := sp.decryptEncryptedAttributes(assertionEl, &assertion); err != nil { |
| 494 | return nil, fmt.Errorf("assertion %q: %w", assertion.ID, err) |
| 495 | } |
| 496 | if err := sp.validateAttributeQueryAssertion(&assertion, query, now); err != nil { |
| 497 | return nil, fmt.Errorf("assertion %q: %w", assertion.ID, err) |
| 498 | } |
| 499 | return &assertion, nil |
| 500 | } |
| 501 | |
| 502 | // validateAttributeQueryAssertion checks assertion, apart from its signature, |
| 503 | // as an answer to query. Unlike validateAssertion, it does not require a |
no test coverage detected