// IsLastModifiedBy verifies that the RootMetadataSigned is written by
// the given user and device (identified by the device verifying key),
// and returns an error if not.
437491
func (rmds *RootMetadataSigned) IsLastModifiedBy(
	uid keybase1.UID, key kbfscrypto.VerifyingKey) error {
	err := rmds.MD.IsLastModifiedBy(uid, key)
	if err != nil {
		return err
	}

	if rmds.SigInfo.VerifyingKey != key {
		return fmt.Errorf("Last modifier verifying key %v != %v",
			rmds.SigInfo.VerifyingKey, key)
	}

	writer := rmds.MD.LastModifyingWriter()
	if !rmds.MD.IsWriterMetadataCopiedSet() {
		if writer != uid {
			return fmt.Errorf("Last writer %s != %s", writer, uid)
		}
		if rmds.WriterSigInfo.VerifyingKey != key {
			return fmt.Errorf(
				"Last writer verifying key %v != %v",
				rmds.WriterSigInfo.VerifyingKey, key)
		}
	}

	return nil
}
996140
func (s *BaiduChannelResponse) SetLastModifiedBy(v string) *BaiduChannelResponse {
	s.LastModifiedBy = &v
	return s
}
1339799
func (t *TSMReader) LastModified() int64 {
	t.mu.RLock()
	lm := t.lastModified
	for _, ts := range t.tombstoner.TombstoneFiles() {
		if ts.LastModified > lm {
			lm = ts.LastModified
		}
	}
	t.mu.RUnlock()
	return lm
}
1191688
func (s *ServiceSetting) SetLastModifiedUser(v string) *ServiceSetting {
	s.LastModifiedUser = &v
	return s
}
1142043
func ValidateAPIServiceStatusUpdate(newAPIService *apiregistration.APIService, oldAPIService *apiregistration.APIService) field.ErrorList {
	allErrs := validation.ValidateObjectMetaUpdate(&newAPIService.ObjectMeta, &oldAPIService.ObjectMeta, field.NewPath("metadata"))
	allErrs = append(allErrs, ValidateAPIServiceStatus(&newAPIService.Status, field.NewPath("status"))...)
	return allErrs
}
106717
func (s *APNSVoipChannelResponse) SetLastModifiedBy(v string) *APNSVoipChannelResponse {
	s.LastModifiedBy = &v
	return s
}
709076
func (s *Object) SetLastModified(v time.Time) *Object {
	s.LastModified = &v
	return s
}
1158966
func (s *GCMChannelResponse) SetLastModifiedBy(v string) *GCMChannelResponse {
	s.LastModifiedBy = &v
	return s
}
1187400
func (md *RootMetadataV3) IsValidAndSigned(
	ctx context.Context, codec kbfscodec.Codec,
	teamMemChecker TeamMembershipChecker, extra ExtraMetadata,
	writerVerifyingKey kbfscrypto.VerifyingKey,
	offline keybase1.OfflineAvailability) error {
	if md.TypeForKeying() == tlf.PrivateKeying {
		wkb, rkb, err := md.getTLFKeyBundles(extra)
		if err != nil {
			return err
		}

		err = CheckWKBID(codec, md.GetTLFWriterKeyBundleID(), *wkb)
		if err != nil {
			return err
		}

		err = CheckRKBID(codec, md.GetTLFReaderKeyBundleID(), *rkb)
		if err != nil {
			return err
		}
	} else {
		err := md.checkNonPrivateExtra(extra)
		if err != nil {
			return err
		}
	}

	if md.IsFinal() {
		if md.Revision < RevisionInitial+1 {
			return errors.Errorf("Invalid final revision %d", md.Revision)
		}

		if md.Revision == (RevisionInitial + 1) {
			if md.PrevRoot != (ID{}) {
				return errors.Errorf("Invalid PrevRoot %s for initial final revision", md.PrevRoot)
			}
		} else {
			if md.PrevRoot == (ID{}) {
				return errors.New("No PrevRoot for non-initial final revision")
			}
		}
	} else {
		if md.Revision < RevisionInitial {
			return errors.Errorf("Invalid revision %d", md.Revision)
		}

		if md.Revision == RevisionInitial {
			if md.PrevRoot != (ID{}) {
				return errors.Errorf("Invalid PrevRoot %s for initial revision", md.PrevRoot)
			}
		} else {
			if md.PrevRoot == (ID{}) {
				return errors.New("No PrevRoot for non-initial revision")
			}
		}
	}

	if len(md.WriterMetadata.SerializedPrivateMetadata) == 0 {
		return errors.New("No private metadata")
	}

	if (md.MergedStatus() == Merged) != (md.BID() == NullBranchID) {
		return errors.Errorf("Branch ID %s doesn't match merged status %s",
			md.BID(), md.MergedStatus())
	}

	handle, err := md.MakeBareTlfHandle(extra)
	if err != nil {
		return err
	}

	writer := md.LastModifyingWriter()
	user := md.LastModifyingUser
	isWriter := false
	isReader := false
	if md.TypeForKeying() == tlf.TeamKeying {
		tid, err := md.WriterMetadata.Writers[0].AsTeam()
		if err != nil {
			return err
		}

		isWriter, err = teamMemChecker.IsTeamWriter(
			ctx, tid, writer, writerVerifyingKey, offline)
		if err != nil {
			return err
		}

		isReader, err = teamMemChecker.IsTeamReader(ctx, tid, user, offline)
		if err != nil {
			return err
		}
	} else {
		isWriter = handle.IsWriter(writer.AsUserOrTeam())
		isReader = handle.IsReader(user.AsUserOrTeam())
	}

	// Make sure the last writer is valid.
	if !isWriter {
		return errors.Errorf("Invalid modifying writer %s", writer)
	}
	// Make sure the last modifier is valid.
	if !isReader {
		return errors.Errorf("Invalid modifying user %s", user)
	}

	return nil
}
525272
func ifModifiedSince(objTime time.Time, givenTime time.Time) bool {
	// The Date-Modified header truncates sub-second precision, so
	// use mtime < t+1s instead of mtime <= t to check for unmodified.
	return objTime.After(givenTime.Add(1 * time.Second))
}
1316044
func (s *EventSourceMappingConfiguration) SetLastModified(v time.Time) *EventSourceMappingConfiguration {
	s.LastModified = &v
	return s
}
590606
func makeRootMetadataSigned(sigInfo, writerSigInfo kbfscrypto.SignatureInfo,
	md RootMetadata) (*RootMetadataSigned, error) {
	rmds := &RootMetadataSigned{
		MD:            md,
		SigInfo:       sigInfo,
		WriterSigInfo: writerSigInfo,
	}
	err := checkWriterSig(rmds)
	if err != nil {
		return nil, err
	}
	return rmds, nil
}
1224260
func (s *Part) SetLastModified(v time.Time) *Part {
	s.LastModified = &v
	return s
}
575517
func (fp *FilterPolicy) IsSatisfiedBy(msgAttrs map[string]MessageAttributeValue) bool {
	for policyAttrName, policyAttrValues := range *fp {
		attrValue, ok := msgAttrs[policyAttrName]
		if !ok {
			return false // the attribute has to be present in the message
		}

		// String, String.Array, Number data-types are allowed by SNS filter policies
		// however go-AWS currently only supports String filter policies. That feature can be added here
		// ref: https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html
		if attrValue.DataType != "String" {
			return false
		}

		if !stringInSlice(attrValue.Value, policyAttrValues) {
			return false // the attribute value has to be among filtered ones
		}
	}

	return true
}
155257
func (o *GetObjectOptions) SetUnmodified(modTime time.Time) error {
	if modTime.IsZero() {
		return ErrInvalidArgument("Modified since cannot be empty.")
	}
	o.Set("If-Unmodified-Since", modTime.Format(http.TimeFormat))
	return nil
}
1264448
func (provider *Provider) IsAuthorized(request *http.Request) (*string, error) {
	var err error
	var userParams map[string]string

	// start with the body/query params
	userParams, err = parseBody(request)
	if err != nil {
		return nil, err
	}

	// if the oauth params are in the Authorization header, grab them, and
	// let them override what's in userParams
	authHeader := request.Header.Get(HTTP_AUTH_HEADER)
	if len(authHeader) > 6 && strings.EqualFold(OAUTH_HEADER, authHeader[0:6]) {
		authHeader = authHeader[6:]
		params := strings.Split(authHeader, ",")
		for _, param := range params {
			vals := strings.SplitN(param, "=", 2)
			k := strings.Trim(vals[0], " ")
			v := strings.Trim(strings.Trim(vals[1], "\""), " ")
			if strings.HasPrefix(k, "oauth") {
				userParams[k], err = url.QueryUnescape(v)
				if err != nil {
					return nil, err
				}
			}
		}
	}

	// pop the request's signature, it's not included in our signature
	// calculation
	oauthSignature, ok := userParams[SIGNATURE_PARAM]
	if !ok {
		return nil, fmt.Errorf("no oauth signature")
	}
	delete(userParams, SIGNATURE_PARAM)

	// get the oauth consumer key
	consumerKey, ok := userParams[CONSUMER_KEY_PARAM]
	if !ok || consumerKey == "" {
		return nil, fmt.Errorf("no consumer key")
	}

	// use it to create a consumer object
	consumer, err := provider.ConsumerGetter(consumerKey, userParams)
	if err != nil {
		return nil, err
	}

	// Make sure timestamp is no more than 10 digits
	timestamp := userParams[TIMESTAMP_PARAM]
	if len(timestamp) > 10 {
		timestamp = timestamp[0:10]
	}

	// Check the timestamp
	if !consumer.serviceProvider.IgnoreTimestamp {
		oauthTimeNumber, err := strconv.Atoi(timestamp)
		if err != nil {
			return nil, err
		}

		if math.Abs(float64(int64(oauthTimeNumber)-provider.clock.Seconds())) > 5*60 {
			return nil, fmt.Errorf("too much clock skew")
		}
	}

	// Include the query string params in the base string
	if consumer.serviceProvider.SignQueryParams {
		for k, v := range request.URL.Query() {
			userParams[k] = strings.Join(v, "")
		}
	}

	// if our consumer supports bodyhash, check it
	if consumer.serviceProvider.BodyHash {
		bodyHash, err := calculateBodyHash(request, consumer.signer)
		if err != nil {
			return nil, err
		}

		sentHash, ok := userParams[BODY_HASH_PARAM]

		if bodyHash == "" && ok {
			return nil, fmt.Errorf("body_hash must not be set")
		} else if sentHash != bodyHash {
			return nil, fmt.Errorf("body_hash mismatch")
		}
	}

	allParams := NewOrderedParams()
	for key, value := range userParams {
		allParams.Add(key, value)
	}

	makeURLAbs(request.URL, request)
	baseString := consumer.requestString(request.Method, canonicalizeUrl(request.URL), allParams)
	err = consumer.signer.Verify(baseString, oauthSignature)
	if err != nil {
		return nil, err
	}

	return &consumerKey, nil
}
444185
func (s *ParameterMetadata) SetLastModifiedUser(v string) *ParameterMetadata {
	s.LastModifiedUser = &v
	return s
}