func (c *Credentials) DisplayName() string {
	return c.displayName
}
DisplayName returns the credential's display name.
package credentials
import (
	"bytes"
	"encoding/gob"
	"encoding/json"
	"time"
	"github.com/hashicorp/go-uuid"
	"github.com/jcmturner/gokrb5/v8/iana/nametype"
	"github.com/jcmturner/gokrb5/v8/keytab"
	"github.com/jcmturner/gokrb5/v8/types"
)
const (
	AttributeKeyADCredentials = "gokrb5AttributeKeyADCredentials"
)
type Credentials struct {
	username        string
	displayName     string
	realm           string
	cname           types.PrincipalName
	keytab          *keytab.Keytab
	password        string
	attributes      map[string]interface{}
	validUntil      time.Time
	authenticated   bool
	human           bool
	authTime        time.Time
	groupMembership map[string]bool
	sessionID       string
}
type marshalCredentials struct {
	Username        string
	DisplayName     string
	Realm           string
	CName           types.PrincipalName `json:"-"`
	Keytab          bool
	Password        bool
	Attributes      map[string]interface{} `json:"-"`
	ValidUntil      time.Time
	Authenticated   bool
	Human           bool
	AuthTime        time.Time
	GroupMembership map[string]bool `json:"-"`
	SessionID       string
}
type ADCredentials struct {
	EffectiveName       string
	FullName            string
	UserID              int
	PrimaryGroupID      int
	LogOnTime           time.Time
	LogOffTime          time.Time
	PasswordLastSet     time.Time
	GroupMembershipSIDs []string
	LogonDomainName     string
	LogonDomainID       string
	LogonServer         string
}
func New(username string, realm string) *Credentials {
	uid, err := uuid.GenerateUUID()
	if err != nil {
		uid = "00unique-sess-ions-uuid-unavailable0"
	}
	return &Credentials{
		username:        username,
		displayName:     username,
		realm:           realm,
		cname:           types.NewPrincipalName(nametype.KRB_NT_PRINCIPAL, username),
		keytab:          keytab.New(),
		attributes:      make(map[string]interface{}),
		groupMembership: make(map[string]bool),
		sessionID:       uid,
		human:           true,
	}
}
func NewFromPrincipalName(cname types.PrincipalName, realm string) *Credentials {
	c := New(cname.PrincipalNameString(), realm)
	c.cname = cname
	return c
}
func (c *Credentials) WithKeytab(kt *keytab.Keytab) *Credentials {
	c.keytab = kt
	c.password = ""
	return c
}
func (c *Credentials) Keytab() *keytab.Keytab {
	return c.keytab
}
func (c *Credentials) HasKeytab() bool {
	if c.keytab != nil && len(c.keytab.Entries) > 0 {
		return true
	}
	return false
}
func (c *Credentials) WithPassword(password string) *Credentials {
	c.password = password
	c.keytab = keytab.New()  
	return c
}
func (c *Credentials) Password() string {
	return c.password
}
func (c *Credentials) HasPassword() bool {
	if c.password != "" {
		return true
	}
	return false
}
func (c *Credentials) SetValidUntil(t time.Time) {
	c.validUntil = t
}
func (c *Credentials) SetADCredentials(a ADCredentials) {
	c.SetAttribute(AttributeKeyADCredentials, a)
	if a.FullName != "" {
		c.SetDisplayName(a.FullName)
	}
	if a.EffectiveName != "" {
		c.SetUserName(a.EffectiveName)
	}
	for i := range a.GroupMembershipSIDs {
		c.AddAuthzAttribute(a.GroupMembershipSIDs[i])
	}
}
func (c *Credentials) GetADCredentials() ADCredentials {
	if a, ok := c.attributes[AttributeKeyADCredentials].(ADCredentials); ok {
		return a
	}
	return ADCredentials{}
}
func (c *Credentials) UserName() string {
	return c.username
}
func (c *Credentials) SetUserName(s string) {
	c.username = s
}
func (c *Credentials) CName() types.PrincipalName {
	return c.cname
}
func (c *Credentials) SetCName(pn types.PrincipalName) {
	c.cname = pn
}
func (c *Credentials) Domain() string {
	return c.realm
}
func (c *Credentials) SetDomain(s string) {
	c.realm = s
}
func (c *Credentials) Realm() string {
	return c.Domain()
}
func (c *Credentials) SetRealm(s string) {
	c.SetDomain(s)
}