github.com/Cloud-Foundations/Dominator@v0.3.4/lib/x509util/api.go (about)

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