credentials.go 688 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package credentials
  2. import "github.com/jcmturner/gokrb5/keytab"
  3. type Credentials struct {
  4. Username string
  5. Keytab keytab.Keytab
  6. Password string
  7. }
  8. func NewCredentials(username string) Credentials {
  9. return Credentials{
  10. Username: username,
  11. Keytab: keytab.NewKeytab(),
  12. }
  13. }
  14. func (c *Credentials) WithKeytab(kt keytab.Keytab) *Credentials {
  15. c.Keytab = kt
  16. return c
  17. }
  18. func (c *Credentials) WithPassword(password string) *Credentials {
  19. c.Password = password
  20. return c
  21. }
  22. func (c *Credentials) HasKeytab() bool {
  23. if len(c.Keytab.Entries) > 0 {
  24. return true
  25. }
  26. return false
  27. }
  28. func (c *Credentials) HasPassword() bool {
  29. if c.Password != "" {
  30. return true
  31. }
  32. return false
  33. }