Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: tokenserver/appengine/utils/identityset/identityset.go

Issue 2413683004: token-server: Delegation config import, validation and evaluation. (Closed)
Patch Set: also check validity_duration Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tokenserver/appengine/utils/identityset/identityset.go
diff --git a/tokenserver/appengine/utils/identityset/identityset.go b/tokenserver/appengine/utils/identityset/identityset.go
index d37476987e3f4ef8cd2a3a4669dc8363e5c51f26..f126e296c8b584969a1db87fbe311a392bdf19e6 100644
--- a/tokenserver/appengine/utils/identityset/identityset.go
+++ b/tokenserver/appengine/utils/identityset/identityset.go
@@ -7,6 +7,7 @@ package identityset
import (
"fmt"
+ "sort"
"strings"
"golang.org/x/net/context"
@@ -151,6 +152,27 @@ func (s *Set) IsSuperset(subset *Set) bool {
return subset.IsSubset(s)
}
+// ToStrings returns a sorted list of strings representing this set.
+//
+// See 'FromStrings' for the format of this list.
+func (s *Set) ToStrings() []string {
+ if s.IsEmpty() {
+ return []string{}
+ }
+ if s.All {
+ return []string{"*"}
+ }
+ out := make([]string, 0, len(s.IDs)+len(s.Groups))
+ for ident := range s.IDs {
+ out = append(out, string(ident))
+ }
+ for group := range s.Groups {
+ out = append(out, "group:"+group)
+ }
+ sort.Strings(out)
+ return out
+}
+
// FromStrings constructs a Set by parsing a slice of strings.
//
// Each string is either:

Powered by Google App Engine
This is Rietveld 408576698