// New returns a request.Authenticator that verifies client certificates using the provided
// VerifyOptions, and converts valid certificate chains into user.Info using the provided UserConversion
430233
func New(opts x509.VerifyOptions, user UserConversion) *Authenticator {
	return &Authenticator{opts, user}
}
1221399
func New(serverID string, validity time.Duration, secret secrets.Secrets) (TokenAccessor, error) {

	tokenEngine, err := tokens.NewJWT(validity, serverID, secret)
	if err != nil {
		return nil, err
	}

	return &tokenAccessor{
		tokens:   tokenEngine,
		serverID: serverID,
		validity: validity,
	}, nil
}
358074
func New(serverURL, userID string) (*Client, error) {
	if userID == "" {
		return nil, errors.New("omaha: empty user identifier")
	}

	c := &Client{
		apiClient:     newHTTPClient(),
		clientVersion: defaultClientVersion,
		userID:        userID,
		sessionID:     uuid.NewV4().String(),
		apps:          make(map[string]*AppClient),
	}

	if err := c.SetServerURL(serverURL); err != nil {
		return nil, err
	}

	return c, nil
}
818451
func New(certPEM, keyPEM []byte) (*CertAuthority, error) {
	ca := &CertAuthority{}
	var err error
	ca.Cert, err = ParseCertificatePEM(certPEM)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	if len(keyPEM) != 0 {
		ca.Signer, err = ParsePrivateKeyPEM(keyPEM)
		if err != nil {
			return nil, trace.Wrap(err)
		}
	}
	return ca, nil
}
126827
func New(backend Backend, _ facade.Resources, authorizer facade.Authorizer) (*Facade, error) {
	return &Facade{
		backend: backend,
		getCanModify: func() (common.AuthFunc, error) {
			return authorizer.AuthOwner, nil
		},
	}, nil
}
1171374
func New(endpoint, secret string, skipverify bool) *Client {
	client := &Client{
		Accept:   "application/json",
		Encoding: "identity",
		Endpoint: endpoint,
		Secret:   secret,
	}
	if skipverify {
		client.Client = &http.Client{
			CheckRedirect: func(*http.Request, []*http.Request) error {
				return http.ErrUseLastResponse
			},
			Transport: &http.Transport{
				Proxy: http.ProxyFromEnvironment,
				TLSClientConfig: &tls.Config{
					InsecureSkipVerify: true,
				},
			},
		}
	}
	return client
}
331604
func New(host, authtoken string) (*TCP, error) {
	client := &TCP{
		host:     host,
		messages: make(chan mist.Message),
		token:    authtoken,
	}

	return client, client.connect()
}
1153888
func New(authRequestHandlers ...authenticator.Request) authenticator.Request {
	if len(authRequestHandlers) == 1 {
		return authRequestHandlers[0]
	}
	return &unionAuthRequestHandler{Handlers: authRequestHandlers, FailOnError: false}
}
609151
func New(nodes []string, scheme, cert, key, caCert string, basicAuth bool, username string, password string) (*ConsulClient, error) {
	conf := api.DefaultConfig()

	conf.Scheme = scheme

	if len(nodes) > 0 {
		conf.Address = nodes[0]
	}

	if basicAuth {
		conf.HttpAuth = &api.HttpBasicAuth{
			Username: username,
			Password: password,
		}
	}

	if cert != "" && key != "" {
		conf.TLSConfig.CertFile = cert
		conf.TLSConfig.KeyFile = key
	}
	if caCert != "" {
		conf.TLSConfig.CAFile = caCert
	}

	client, err := api.NewClient(conf)
	if err != nil {
		return nil, err
	}
	return &ConsulClient{client.KV()}, nil
}
506313
func New(tritonURL string, mantaURL string, accountName string, signers ...authentication.Signer) (*Client, error) {
	if accountName == "" {
		return nil, ErrAccountName
	}

	if tritonURL == "" && mantaURL == "" {
		return nil, ErrMissingURL
	}

	cloudURL, err := url.Parse(tritonURL)
	if err != nil {
		return nil, pkgerrors.Wrapf(err, InvalidTritonURL)
	}

	storageURL, err := url.Parse(mantaURL)
	if err != nil {
		return nil, pkgerrors.Wrapf(err, InvalidMantaURL)
	}

	// Generate the Services URL (TSG) based on the current datacenter used in
	// the Triton URL (if TritonURL is available). If TRITON_TSG_URL environment
	// variable is available than override using that value instead.
	tsgURL := triton.GetEnv("TSG_URL")
	if tsgURL == "" && tritonURL != "" && !isPrivateInstall(tritonURL) {
		currentDC, isSamsung, err := parseDC(tritonURL)
		if err != nil {
			return nil, pkgerrors.Wrapf(err, InvalidDCInURL)
		}

		tsgURL = fmt.Sprintf(jpcFormatURL, currentDC)
		if isSamsung {
			tsgURL = fmt.Sprintf(spcFormatURL, currentDC)
		}
	}

	servicesURL, err := url.Parse(tsgURL)
	if err != nil {
		return nil, pkgerrors.Wrapf(err, InvalidServicesURL)
	}

	authorizers := make([]authentication.Signer, 0)
	for _, key := range signers {
		if key != nil {
			authorizers = append(authorizers, key)
		}
	}

	newClient := &Client{
		HTTPClient: &http.Client{
			Transport:     httpTransport(false),
			CheckRedirect: doNotFollowRedirects,
		},
		Authorizers: authorizers,
		TritonURL:   *cloudURL,
		MantaURL:    *storageURL,
		ServicesURL: *servicesURL,
		AccountName: accountName,
	}

	// Default to constructing an SSHAgentSigner if there are no other signers
	// passed into NewClient and there's an TRITON_KEY_ID and SSH_AUTH_SOCK
	// available in the user's environ(7).
	if len(newClient.Authorizers) == 0 {
		if err := newClient.DefaultAuth(); err != nil {
			return nil, err
		}
	}

	return newClient, nil
}
1211410
func New(httpClient *http.Client, userAgent string, caDirURL, kid string, privateKey crypto.PrivateKey) (*Core, error) {
	doer := sender.NewDoer(httpClient, userAgent)

	dir, err := getDirectory(doer, caDirURL)
	if err != nil {
		return nil, err
	}

	nonceManager := nonces.NewManager(doer, dir.NewNonceURL)

	jws := secure.NewJWS(privateKey, kid, nonceManager)

	c := &Core{doer: doer, nonceManager: nonceManager, jws: jws, directory: dir, HTTPClient: httpClient}

	c.common.core = c
	c.Accounts = (*AccountService)(&c.common)
	c.Authorizations = (*AuthorizationService)(&c.common)
	c.Certificates = (*CertificateService)(&c.common)
	c.Challenges = (*ChallengeService)(&c.common)
	c.Orders = (*OrderService)(&c.common)

	return c, nil
}
1095160
func (c Client) New(params *stripe.IssuingDisputeParams) (*stripe.IssuingDispute, error) {
	dispute := &stripe.IssuingDispute{}
	err := c.B.Call(http.MethodPost, "/v1/issuing/disputes", c.Key, params, dispute)
	return dispute, err
}
1057033
func New(host, port, username string, sams ...ssh.AuthMethod) (*Client, error) {
	config := &ssh.ClientConfig{
		User: username,
		Auth: sams,
	}
	client, err := ssh.Dial("tcp", BuildSSHURL(host, port), config)
	if err != nil {
		return nil, err
	}
	tmpSftpClient, err := sftp.NewClient(client)
	if err != nil {
		return nil, err
	}
	return (*Client)(unsafe.Pointer(tmpSftpClient)), err
}
370435
func New(options ...Options) *Secure {
	var o Options
	if len(options) == 0 {
		o = Options{}
	} else {
		o = options[0]
	}

	o.ContentSecurityPolicy = strings.Replace(o.ContentSecurityPolicy, "$NONCE", "'nonce-%[1]s'", -1)

	o.nonceEnabled = strings.Contains(o.ContentSecurityPolicy, "%[1]s")

	s := &Secure{
		opt:            o,
		badHostHandler: http.HandlerFunc(defaultBadHostHandler),
	}

	if s.opt.AllowedHostsAreRegex {
		// Test for invalid regular expressions in AllowedHosts
		for _, allowedHost := range o.AllowedHosts {
			regex, err := regexp.Compile(fmt.Sprintf("^%s$", allowedHost))
			if err != nil {
				panic(fmt.Sprintf("Error parsing AllowedHost: %s", err))
			}
			s.cRegexAllowedHosts = append(s.cRegexAllowedHosts, regex)
		}
	}

	return s
}
702826
func (c Client) New(params *stripe.LoginLinkParams) (*stripe.LoginLink, error) {
	if params.Account == nil {
		return nil, errors.New("Invalid login link params: Account must be set")
	}

	path := stripe.FormatURLPath("/v1/accounts/%s/login_links", stripe.StringValue(params.Account))
	loginLink := &stripe.LoginLink{}
	err := c.B.Call(http.MethodPost, path, c.Key, params, loginLink)
	return loginLink, err
}
1048645
func New(h hash.Hash, o Options) *Signer {
	if o.NonceParam == "" {
		o.NonceParam = "nonce"
	}
	if o.TimestampParam == "" {
		o.TimestampParam = "timestamp"
	}
	if o.SignatureParam == "" {
		o.SignatureParam = "signature"
	}
	if o.CheckNonceFunc == nil {
		o.CheckNonceFunc = defaultCheckNonceFunc
	}
	if o.MaxLife == 0 {
		o.MaxLife = defaultMaxLife
	}
	return &Signer{
		h:              h,
		nonceParam:     o.NonceParam,
		timestampParam: o.TimestampParam,
		signatureParam: o.SignatureParam,
		checkNonceFunc: o.CheckNonceFunc,
		maxLife:        o.MaxLife,
	}
}
737334
func New(accessKeyID, secretAccessKey string) (c *Config, err error) {
	c, err = NewDefault()
	if err != nil {
		c = nil
		return
	}
	c.AccessKeyID = accessKeyID
	c.SecretAccessKey = secretAccessKey

	return
}