@@ -12,10 +12,10 @@ import (
1212
1313// Structs
1414
15- // FileAuthenticator contains file based authentication
15+ // File contains file based authentication
1616// information including the in-memory map of username to
1717// password mapping.
18- type FileAuthenticator struct {
18+ type File struct {
1919 Users []User
2020}
2121
@@ -28,20 +28,20 @@ type User struct {
2828
2929// Functions
3030
31- // NewFileAuthenticator takes in a file name and a separator,
31+ // NewFile takes in a file name and a separator,
3232// reads in specified file and parses it line by line as
3333// username - password elements separated by the separator.
3434// At the end, the returned struct contains the information
3535// and an in-memory map of username mapped to password.
36- func NewFileAuthenticator (file string , sep string ) (* FileAuthenticator , error ) {
36+ func NewFile (file string , sep string ) (* File , error ) {
3737
3838 // Reserve space for the ordered users list in memory.
3939 users := make ([]User , 0 , 50 )
4040
4141 // Open file with authentication information.
4242 handle , err := os .Open (file )
4343 if err != nil {
44- return nil , fmt .Errorf ("[auth.NewFileAuthenticator ] Could not open supplied authentication file: %v" , err )
44+ return nil , fmt .Errorf ("[auth.NewFile ] Could not open supplied authentication file: %v" , err )
4545 }
4646 defer handle .Close ()
4747
@@ -71,22 +71,22 @@ func NewFileAuthenticator(file string, sep string) (*FileAuthenticator, error) {
7171
7272 // If the scanner ended with an error, report it.
7373 if err := scanner .Err (); err != nil {
74- return nil , fmt .Errorf ("[auth.NewFileAuthenticator ] Experienced error while scanning authentication file: %v" , err )
74+ return nil , fmt .Errorf ("[auth.NewFile ] Experienced error while scanning authentication file: %v" , err )
7575 }
7676
7777 // Sort users list to search it efficiently later on.
7878 sort .Slice (users , func (i , j int ) bool {
7979 return users [i ].Name < users [j ].Name
8080 })
8181
82- return & FileAuthenticator {
82+ return & File {
8383 Users : users ,
8484 }, nil
8585}
8686
8787// GetWorkerForUser returns the name of the worker node
8888// that is responsible for handling the user's mailbox.
89- func (f * FileAuthenticator ) GetWorkerForUser (workers map [string ]config.Worker , id int ) (string , error ) {
89+ func (f * File ) GetWorkerForUser (workers map [string ]config.Worker , id int ) (string , error ) {
9090
9191 for name , worker := range workers {
9292
@@ -105,7 +105,7 @@ func (f *FileAuthenticator) GetWorkerForUser(workers map[string]config.Worker, i
105105// process by taking supplied credentials and attempting
106106// to find a matching entry the in-memory list taken from
107107// the authentication file.
108- func (f * FileAuthenticator ) AuthenticatePlain (username string , password string , clientAddr string ) (int , string , error ) {
108+ func (f * File ) AuthenticatePlain (username string , password string , clientAddr string ) (int , string , error ) {
109109
110110 // Search in user list for user matching supplied name.
111111 i := sort .Search (len (f .Users ), func (i int ) bool {
0 commit comments