aboutsummaryrefslogtreecommitdiff
path: root/messages.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-01-21 21:24:57 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-01-21 21:24:57 +0100
commitd0cb3267a05fae23bf15adb2df80402f97f83cab (patch)
tree86e550d911e950ab6839e0970355de83a992545c /messages.go
parentac0883b44c37dac955c39e9c43b960201836da09 (diff)
Move picker into authz
Diffstat (limited to 'messages.go')
-rw-r--r--messages.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/messages.go b/messages.go
index 26caeac..0b3e4dc 100644
--- a/messages.go
+++ b/messages.go
@@ -47,6 +47,30 @@ type Authorization struct {
Combinations [][]int `json:"combinations,omitempty"`
}
+func (a Authorization) Supported(sol map[ChallengeType]Solver) []Challenge {
+ supported := func(c []int) bool {
+ for _, com := range c {
+ ch := a.Challenges[com]
+ if _, ok := sol[ch.Type]; !ok {
+ return false
+ }
+ }
+ return true
+ }
+ for _, com := range a.Combinations {
+ if supported(com) {
+ var c []Challenge
+ for _, n := range com {
+ ch := a.Challenges[n]
+ ch.Solver = sol[ch.Type]
+ c = append(c, ch)
+ }
+ return c
+ }
+ }
+ return nil
+}
+
// Identifier ...
type Identifier struct {
Type IdentType `json:"type"` // dns