aboutsummaryrefslogtreecommitdiff
path: root/provider.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-01-12 13:41:36 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-01-12 13:41:36 +0100
commitab44298d0c23c02d4c4736073be86bcffb669a7b (patch)
treed25c3258083c8a228fe7743fd19f19252087d760 /provider.go
parent178685b0659c01dffb253bb40a506b54795a2c98 (diff)
Move solver into challenge
Diffstat (limited to 'provider.go')
-rw-r--r--provider.go27
1 files changed, 3 insertions, 24 deletions
diff --git a/provider.go b/provider.go
index dc53abd..4e69783 100644
--- a/provider.go
+++ b/provider.go
@@ -188,28 +188,6 @@ func (p *Provider) Register(s Signer, c Contacts) error {
return err
}
-func canSatisfice(d *Desire, com []int, c []Challenge) bool {
- for _, n := range com {
- if _, ok := d.solver[c[n].Type]; !ok {
- return false
- }
- }
- return true
-}
-
-func (a Authorization) pick(d *Desire) (c []Challenge) {
- for _, com := range a.Combinations {
- if canSatisfice(d, com, a.Challenges) {
- for _, n := range com {
- c = append(c, a.Challenges[n])
- }
- return
- }
- }
- log.Println("cannot solve any challenges")
- return
-}
-
func (p *Provider) Authorize(s ThumbSigner, d *Desire) error {
for _, domain := range d.altnames {
r := &Authorization{
@@ -222,7 +200,7 @@ func (p *Provider) Authorize(s ThumbSigner, d *Desire) error {
return err
}
- for _, ch := range r.pick(d) {
+ for _, ch := range d.Pick(r) {
ka, _ := KeyAuthorization(s, ch.Token)
ans := &Challenge{
@@ -236,7 +214,8 @@ func (p *Provider) Authorize(s ThumbSigner, d *Desire) error {
return err
}
- err = d.solver[ch.Type].Solve(ch.Token, ka)
+ //err = d.solver[ch.Type].Solve(ch.Token, ka)
+ err = ch.Solve(ch.Token, ka)
if err != nil {
return err
}