SignAttributeQuery adds an enveloped `Signature` element to the `AttributeQuery`, replacing any it already has. It signs with SignatureMethod or, when that is empty, with SHA-256 for the type of Key.
(req *AttributeQuery)
| 147 | // `AttributeQuery`, replacing any it already has. It signs with |
| 148 | // SignatureMethod or, when that is empty, with SHA-256 for the type of Key. |
| 149 | func (sp *ServiceProvider) SignAttributeQuery(req *AttributeQuery) error { |
| 150 | signatureMethod := sp.SignatureMethod |
| 151 | if signatureMethod == "" && !signerutil.IsNil(sp.Key) { |
| 152 | signatureMethod = defaultSignatureMethod(sp.Key.Public()) |
| 153 | } |
| 154 | signingContext, err := sp.signingContext(signatureMethod) |
| 155 | if err != nil { |
| 156 | return err |
| 157 | } |
| 158 | |
| 159 | req.Signature = nil |
| 160 | signedRequestEl, err := signingContext.SignEnveloped(req.Element()) |
| 161 | if err != nil { |
| 162 | return err |
| 163 | } |
| 164 | sigEl, ok := signedRequestEl.Child[len(signedRequestEl.Child)-1].(*etree.Element) |
| 165 | if !ok { |
| 166 | return errors.New("cannot sign attribute query: no Signature element") |
| 167 | } |
| 168 | req.Signature = sigEl |
| 169 | return nil |
| 170 | } |
| 171 | |
| 172 | // QueryAttributes asks the IdP's attribute authority for the attributes of |
| 173 | // the subject identified by nameID, and returns them once the response has |