Skip to content

Commit 9ebea34

Browse files
committed
Support XEP-0070 Verifying HTTP Requests via XMPP.
TODO: testing
1 parent ac5b066 commit 9ebea34

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

stanza/httauth.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package stanza
2+
3+
import (
4+
"encoding/xml"
5+
)
6+
7+
// XEP-0070: Verifying HTTP Requests via XMPP
8+
type ConfirmPayload struct {
9+
XMLName xml.Name `xml:"http://jabber.org/protocol/http-auth confirm"`
10+
ID string `xml:"id,attr"`
11+
Method string `xml:"method,attr"`
12+
URL string `xml:"url,attr"`
13+
}
14+
15+
func (c ConfirmPayload) Namespace() string {
16+
return c.XMLName.Space
17+
}
18+
19+
func (c ConfirmPayload) GetSet() *ResultSet {
20+
return nil
21+
}
22+
23+
// ---------------
24+
// Builder helpers
25+
26+
// Confirm builds a default confirm payload
27+
func (iq *IQ) Confirm() *ConfirmPayload {
28+
d := ConfirmPayload{
29+
XMLName: xml.Name{Space: "http://jabber.org/protocol/http-auth", Local: "confirm"},
30+
}
31+
iq.Payload = &d
32+
return &d
33+
}
34+
35+
// Set all confirm info
36+
func (v *ConfirmPayload) SetConfirm(id, method, url string) *ConfirmPayload {
37+
v.ID = id
38+
v.Method = method
39+
v.URL = url
40+
return v
41+
}
42+
43+
func init() {
44+
TypeRegistry.MapExtension(PKTMessage,
45+
xml.Name{Space: "http://jabber.org/protocol/http-auth", Local: "confirm"},
46+
ConfirmPayload{})
47+
TypeRegistry.MapExtension(PKTIQ,
48+
xml.Name{Space: "http://jabber.org/protocol/http-auth", Local: "confirm"},
49+
ConfirmPayload{})
50+
}

0 commit comments

Comments
 (0)