~juju-qa/juju-core/1.16-packaging

« back to all changes in this revision

Viewing changes to src/launchpad.net/goose/identity/identity.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-10-10 18:07:45 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20131010180745-wuo0vv7hq7faavdk
Tags: 1.16.0-0ubuntu1
New upstream stable release (LP: #1219879).

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
        "fmt"
7
7
        "os"
8
8
        "reflect"
 
9
 
 
10
        goosehttp "launchpad.net/goose/http"
9
11
)
10
12
 
11
13
// AuthMode defines the authentication method to use (see Auth*
97
99
        }
98
100
        return
99
101
}
 
102
 
 
103
// NewAuthenticator creates an authenticator matching the supplied AuthMode.
 
104
// The httpclient is allowed to be nil, the Authenticator will just use the
 
105
// default http.Client
 
106
func NewAuthenticator(authMode AuthMode, httpClient *goosehttp.Client) Authenticator {
 
107
        if httpClient == nil {
 
108
                httpClient = goosehttp.New()
 
109
        }
 
110
        switch authMode {
 
111
        default:
 
112
                panic(fmt.Errorf("Invalid identity authorisation mode: %d", authMode))
 
113
        case AuthLegacy:
 
114
                return &Legacy{client: httpClient}
 
115
        case AuthUserPass:
 
116
                return &UserPass{client: httpClient}
 
117
        case AuthKeyPair:
 
118
                return &KeyPair{client: httpClient}
 
119
        }
 
120
}