From d0cb3267a05fae23bf15adb2df80402f97f83cab Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 21 Jan 2016 21:24:57 +0100 Subject: Move picker into authz --- messages.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'messages.go') 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 -- cgit v1.2.3