1package dbus
2
3import (
4	"encoding/hex"
5)
6
7// AuthExternal returns an Auth that authenticates as the given user with the
8// EXTERNAL mechanism.
9func AuthExternal(user string) Auth {
10	return authExternal{user}
11}
12
13// AuthExternal implements the EXTERNAL authentication mechanism.
14type authExternal struct {
15	user string
16}
17
18func (a authExternal) FirstData() ([]byte, []byte, AuthStatus) {
19	b := make([]byte, 2*len(a.user))
20	hex.Encode(b, []byte(a.user))
21	return []byte("EXTERNAL"), b, AuthOk
22}
23
24func (a authExternal) HandleData(b []byte) ([]byte, AuthStatus) {
25	return nil, AuthError
26}
27