1
0
mirror of https://github.com/docker/docker-credential-helpers.git synced 2026-06-14 08:21:28 +05:30

Cleanup imports and vendor dependencies.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera
2016-02-22 18:00:05 -05:00
parent b643be2751
commit 0c4810e01f
10 changed files with 345 additions and 15 deletions
+69
View File
@@ -0,0 +1,69 @@
package wincred
import (
"syscall"
)
// Get the generic credential with the given name from Windows credential manager
func GetGenericCredential(targetName string) (*GenericCredential, error) {
cred, err := nativeCredRead(targetName, naCRED_TYPE_GENERIC)
if cred != nil {
return &GenericCredential{*cred}, err
}
return nil, err
}
// Create a new generic credential with the given name
func NewGenericCredential(targetName string) (result *GenericCredential) {
result = new(GenericCredential)
result.TargetName = targetName
result.Persist = PersistLocalMachine
return
}
// Persist the credential to Windows credential manager
func (t *GenericCredential) Write() (err error) {
err = nativeCredWrite(&t.Credential, naCRED_TYPE_GENERIC)
return
}
// Delete the credential from Windows credential manager
func (t *GenericCredential) Delete() (err error) {
err = nativeCredDelete(&t.Credential, naCRED_TYPE_GENERIC)
return
}
// Get the domain password credential with the given target host name
func GetDomainPassword(targetName string) (*DomainPassword, error) {
cred, err := nativeCredRead(targetName, naCRED_TYPE_DOMAIN_PASSWORD)
if cred != nil {
return &DomainPassword{*cred}, err
}
return nil, err
}
// Create a new domain password credential used for login to the given target host name
func NewDomainPassword(targetName string) (result *DomainPassword) {
result = new(DomainPassword)
result.TargetName = targetName
result.Persist = PersistLocalMachine
return
}
// Persist the domain password credential to Windows credential manager
func (t *DomainPassword) Write() (err error) {
err = nativeCredWrite(&t.Credential, naCRED_TYPE_DOMAIN_PASSWORD)
return
}
// Delete the domain password credential from Windows credential manager
func (t *DomainPassword) Delete() (err error) {
err = nativeCredDelete(&t.Credential, naCRED_TYPE_DOMAIN_PASSWORD)
return
}
// Set the CredentialBlob field of a domain password credential
// using an UTF16 encoded password string
func (t *DomainPassword) SetPassword(pw string) {
t.CredentialBlob = utf16ToByte(syscall.StringToUTF16(pw))
}