コード例 #1
0
// Get retrieves credentials from the windows credentials manager.
func (h Wincred) Get(serverURL string) (string, string, error) {
	g, _ := winc.GetGenericCredential(serverURL)
	if g == nil {
		return "", "", credentials.NewErrCredentialsNotFound()
	}
	return g.UserName, string(g.CredentialBlob), nil
}
コード例 #2
0
// Load the server related configuration data from the Windows registry and Windows credential store.
// Returns a ServerConfiguration object.
func LoadServerConfiguration() *ServerConfiguration {
	ret := new(ServerConfiguration)
	ret.Port = binary.LittleEndian.Uint64(w32.RegGetRaw(w32.HKEY_CURRENT_USER, SERVER_CONFIGURATION_KEY, SERVER_CONFIGURATION_PORT))
	cred, err := wincred.GetGenericCredential(SERVER_CONFIGURATION_SECRET)
	if err == nil {
		ret.Secret = cred.CredentialBlob
	}
	return ret
}
コード例 #3
0
// Delete removes credentials from the windows credentials manager.
func (h Wincred) Delete(serverURL string) error {
	g, err := winc.GetGenericCredential(serverURL)
	if g == nil {
		return nil
	}
	if err != nil {
		return err
	}
	return g.Delete()
}
コード例 #4
0
// Returns a new ClientConfiguration object, filled with the configuration data, loaded from the
// Windows registry (Hostname, Port, ForwardedKeys) and Windows credential store (encryption secret).
func LoadClientConfiguration() *ClientConfiguration {
	ret := new(ClientConfiguration)
	ret.Hostname = w32.RegGetString(w32.HKEY_CURRENT_USER, CLIENT_CONFIGURATION_KEY, CLIENT_CONFIGURATION_HOSTNAME)
	ret.Port = binary.LittleEndian.Uint64(w32.RegGetRaw(w32.HKEY_CURRENT_USER, CLIENT_CONFIGURATION_KEY, CLIENT_CONFIGURATION_PORT))
	json.Unmarshal([]byte(w32.RegGetString(w32.HKEY_CURRENT_USER, CLIENT_CONFIGURATION_KEY, CLIENT_CONFIGURATION_FORWARDED_KEYS)), &ret.ForwardedKeys)
	cred, err := wincred.GetGenericCredential(CLIENT_CONFIGURATION_SECRET)
	if err == nil {
		ret.Secret = cred.CredentialBlob
	}
	return ret
}