forked from Cloud-Foundations/Dominator
/
api.go
32 lines (27 loc) · 1.08 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
Package x509util provides utility functions to process X509 certificates.
*/
package x509util
import (
"crypto/x509"
"github.com/Cloud-Foundations/Dominator/lib/constants"
)
// GetGroupList decodes the list of groups in the certificate.
// The group names are returned as keys in a map. An empty map indicates no
// group listed. If there is a problem parsing the information an error is
// returned.
func GetGroupList(cert *x509.Certificate) (map[string]struct{}, error) {
return getList(cert, constants.GroupListOID)
}
// GetPermittedMethods decodes the list of permitted methods in the certificate.
// The permitted methods are returned as keys in a map. An empty map indicates
// no methods are permitted. If there is a problem parsing the information an
// error is returned.
func GetPermittedMethods(cert *x509.Certificate) (map[string]struct{}, error) {
return getPermittedMethods(cert)
}
// GetUsername decodes the username for whom the certificate was granted. It
// attests the identity of the user.
func GetUsername(cert *x509.Certificate) (string, error) {
return getUsername(cert)
}