//Add credential to given domain, creds must be struct which is parsable to xml
558239
func (cm CredentialsManager) Add(domain string, creds interface{}) error {
	return cm.postCredsXML(cm.fillURL(createCredentialsURL, domain), creds)
}
1329071
func (st *State) AllCloudCredentials(user names.UserTag) ([]Credential, error) {
	coll, cleanup := st.db().GetCollection(cloudCredentialsC)
	defer cleanup()

	// There are 2 ways of getting a credential for a user:
	// 1. user name stored in the credential tag (aka doc id);
	// 2. look up using Owner field.
	// We use Owner field below as credential tag or doc ID may be changed
	// in the future to be a real Primary Key that has nothing to do with
	// the data it identifies, i.e. no business meaning.
	clause := bson.D{{"owner", user.Id()}}

	var docs []cloudCredentialDoc
	err := coll.Find(clause).Sort("cloud").All(&docs)
	if err != nil {
		return nil, errors.Annotatef(err, "getting cloud credentials for %q", user.Id())
	}

	if len(docs) == 0 {
		return nil, errors.NotFoundf("cloud credentials for %q", user.Id())
	}

	credentials := make([]Credential, len(docs))
	for i, doc := range docs {
		credentials[i] = Credential{doc}
	}
	return credentials, nil
}
1042995
func NewCredential(authType AuthType, attributes map[string]string) Credential {
	return Credential{authType: authType, attributes: copyStringMap(attributes)}
}
849535
func (ch *CredHub) SetCredential(name, credType string, value interface{}) (credentials.Credential, error) {
	var cred credentials.Credential
	err := ch.setCredential(name, credType, value, &cred)

	return cred, err
}
44301
func (i *TeleInstance) AddUser(username string, mappings []string) *User {
	log.Infof("teleInstance.AddUser(%v) mapped to %v", username, mappings)
	if mappings == nil {
		mappings = make([]string, 0)
	}
	user := &User{
		Username:      username,
		AllowedLogins: mappings,
	}
	i.Secrets.Users[username] = user
	return user
}
72468
func (s *store) CredentialForCloud(cloudName string) (*cloud.CloudCredential, error) {
	cloudCredentials, err := s.AllCredentials()
	if err != nil {
		return nil, errors.Trace(err)
	}
	credentials, ok := cloudCredentials[cloudName]
	if !ok {
		return nil, errors.NotFoundf("credentials for cloud %s", cloudName)
	}
	return &credentials, nil
}
783955
func (c *Client) SetCredentials(username, password string) *Client {
	c.creds = Credentials{
		Username: username,
		Password: password,
	}

	return c
}
1280566
func NewNamedCredential(name string, authType AuthType, attributes map[string]string, revoked bool) Credential {
	return Credential{
		Label:      name,
		authType:   authType,
		attributes: copyStringMap(attributes),
		Revoked:    revoked,
	}
}
1307891
func (s *RegistrarService) RegisterDomain(accountID string, domainName string, request *DomainRegisterRequest) (*domainRegistrationResponse, error) {
	path := versioned(fmt.Sprintf("/%v/registrar/domains/%v/registrations", accountID, domainName))
	registrationResponse := &domainRegistrationResponse{}

	// TODO: validate mandatory attributes RegistrantID

	resp, err := s.client.post(path, request, registrationResponse)
	if err != nil {
		return nil, err
	}

	registrationResponse.HttpResponse = resp
	return registrationResponse, nil
}
33770
func (r *PCPRegistry) AddInstanceDomainByName(name string, instances []string) (InstanceDomain, error) {
	if r.HasInstanceDomain(name) {
		return nil, errors.New("The InstanceDomain already exists for this registry")
	}

	indom, err := NewPCPInstanceDomain(name, instances)
	if err != nil {
		return nil, err
	}

	err = r.AddInstanceDomain(indom)
	if err != nil {
		return nil, err
	}

	return indom, nil
}
637913
func (c credentialSet) Add(cred apitypes.CredentialEnvelope) error {
	if (*cred.Body).GetValue() == nil {
		return errors.New("Cannot add an unset credential")
	}

	name := (*cred.Body).GetName()
	if existing, ok := c[name]; ok {
		// The new credential is either as specific, or less specific than
		// the existing one. Keep the existing one.
		eBody := *existing.Body
		if (*cred.Body).GetPathExp().CompareSpecificity(eBody.GetPathExp()) != 1 {
			return nil
		}
	}

	c[name] = &cred
	return nil
}
989782
func (c *client) Add(s interface{}, cert *ssh.Certificate, comment string) error {
	if cert == nil {
		return c.insertKey(s, comment)
	} else {
		return c.insertCert(s, cert, comment)
	}
}
191669
func CredChain(cfg *aws.Config, handlers request.Handlers) *credentials.Credentials {
	return credentials.NewCredentials(&credentials.ChainProvider{
		VerboseErrors: aws.BoolValue(cfg.CredentialsChainVerboseErrors),
		Providers:     CredProviders(cfg, handlers),
	})
}
747592
func (c *Client) Credentials(tags ...names.CloudCredentialTag) ([]params.CloudCredentialResult, error) {
	if len(tags) == 0 {
		return []params.CloudCredentialResult{}, nil
	}
	var results params.CloudCredentialResults
	args := params.Entities{
		Entities: make([]params.Entity, len(tags)),
	}
	for i, tag := range tags {
		args.Entities[i].Tag = tag.String()
	}
	if err := c.facade.FacadeCall("Credential", args, &results); err != nil {
		return nil, errors.Trace(err)
	}
	return results.Results, nil
}
190724
func NewCredential(auth types.AuthConfig) Credential {
	// TODO 这里可以组装其他的方法
	return simple.NewBasicCredential(auth.Username, auth.Password)
}
282182
func (r Dns_Domain_Registration) AddNameserversToDomain(nameservers []string) (resp bool, err error) {
	params := []interface{}{
		nameservers,
	}
	err = r.Session.DoRequest("SoftLayer_Dns_Domain_Registration", "addNameserversToDomain", params, &r.Options, &resp)
	return
}
440197
func (ssa *SQLStorageAuthority) addCertificatesPerName(
	ctx context.Context,
	db dbSelectExecer,
	names []string,
	timeToTheHour time.Time,
) error {
	if !features.Enabled(features.FasterRateLimit) {
		return nil
	}
	// De-duplicate the base domains.
	baseDomainsMap := make(map[string]bool)
	var qmarks []string
	var values []interface{}
	for _, name := range names {
		base := baseDomain(name)
		if !baseDomainsMap[base] {
			baseDomainsMap[base] = true
			values = append(values, base, timeToTheHour, 1)
			qmarks = append(qmarks, "(?, ?, ?)")
		}
	}

	_, err := db.Exec(`INSERT INTO certificatesPerName (eTLDPlusOne, time, count) VALUES `+
		strings.Join(qmarks, ", ")+` ON DUPLICATE KEY UPDATE count=count+1;`,
		values...)
	if err != nil {
		return err
	}

	return nil
}