// Validate validates a token and returns its signature or an error if the token is not valid.
341147
func (j *RS256JWTStrategy) Validate(ctx context.Context, token string) (string, error) {
	if _, err := j.Decode(ctx, token); err != nil {
		return "", errors.WithStack(err)
	}

	return j.GetSignature(ctx, token)
}
232820
func Validate(validators ...Validatable) error {
	for i := range validators {
		if err := validators[i](); err != nil {
			return err
		}
	}
	return nil
}
1166421
func (c Flags) Validate() error {
	var notFilled []string
	for _, v := range c {
		// if no value given (nil) for required flag then it is not valid
		isRequired := v.Default == nil
		val := reflect.ValueOf(v.Value).Elem().String()
		if isRequired && val == "" {
			notFilled = append(notFilled, v.Name)
		}
	}

	if len(notFilled) > 0 {
		if len(notFilled) == 1 {
			return errFlagMissing.Format(notFilled[0])
		}
		return errFlagMissing.Format(strings.Join(notFilled, ","))

	}
	return nil

}
932703
func (p *JWT) Validate(token, dsecs string) (map[string]interface{}, error) {
	jp := new(jwtgo.Parser)
	jp.ValidMethods = []string{"RS256", "RS384", "RS512", "ES256", "ES384", "ES512"}

	keyFuncCallback := func(jwtToken *jwtgo.Token) (interface{}, error) {
		kid, ok := jwtToken.Header["kid"].(string)
		if !ok {
			return nil, fmt.Errorf("Invalid kid value %v", jwtToken.Header["kid"])
		}
		return p.args.publicKeys[kid], nil
	}

	var claims jwtgo.MapClaims
	jwtToken, err := jp.ParseWithClaims(token, &claims, keyFuncCallback)
	if err != nil {
		if err = p.args.PopulatePublicKey(); err != nil {
			return nil, err
		}
		jwtToken, err = jwtgo.ParseWithClaims(token, &claims, keyFuncCallback)
		if err != nil {
			return nil, err
		}
	}

	if !jwtToken.Valid {
		return nil, ErrTokenExpired
	}

	expAt, err := expToInt64(claims["exp"])
	if err != nil {
		return nil, err
	}

	defaultExpiryDuration, err := GetDefaultExpiration(dsecs)
	if err != nil {
		return nil, err
	}

	if time.Unix(expAt, 0).UTC().Sub(time.Now().UTC()) < defaultExpiryDuration {
		defaultExpiryDuration = time.Unix(expAt, 0).UTC().Sub(time.Now().UTC())
	}

	expiry := time.Now().UTC().Add(defaultExpiryDuration).Unix()
	if expAt < expiry {
		claims["exp"] = strconv.FormatInt(expAt, 64)
	}

	return claims, nil

}
650865
func (e ValidationError) Error() string {
	if e.Inner != nil {
		return e.Inner.Error()
	} else if e.text != "" {
		return e.text
	} else {
		return "token is invalid"
	}
}
515700
func (op *OpenIDProvider) Validate(token string) (bool, error) {
	jws, err := jose.ParseSigned(token)
	if err != nil {
		return false, errors.NewNotValid(err, "Couldn't parse the token")
	}

	for _, sig := range jws.Signatures {
		keyID := sig.Header.KeyID
		opKeys := op.Keys.Key(keyID)
		if len(opKeys) < 1 {
			// Can't find the server key that this token claims to be signed with
			return false, errors.NotFoundf("Couldn't find KeyID %s in the server's keys", keyID)
		}
		opKey := opKeys[0]
		_, err = jws.Verify(opKey.Key)
		if err != nil {
			// Couldn't verify the signature
			return false, errors.NotValidf("Signature failed validation")
		}
	}
	return true, nil
}
225743
func (m *Lua) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetInlineCode()) < 1 {
		return LuaValidationError{
			field:  "InlineCode",
			reason: "value length must be at least 1 bytes",
		}
	}

	return nil
}
849694
func (i *I) Validate(ctx *Context) error {
	_, err := i.template(ctx)
	return err
}
604290
func (t *JSONToken) Validate(validators ...Validator) error {
	var err error
	if len(validators) == 0 {
		validators = append(validators, ValidAt(time.Now()))
	}
	for _, validator := range validators {
		if err = validator(t); err != nil {
			return err
		}
	}
	return nil
}
621278
func (pTypeDef *StringTest) Validate() error {
	if pTypeDef.Name == "" {
		return fmt.Errorf("StringTest: Missing required field: name")
	}
	if pTypeDef.Parent == "" {
		return fmt.Errorf("StringTest: Missing required field: parent")
	}
	return nil
}
157414
func (constraints *tokenConstraints) validate() (err error) {
	keys := 0
	if constraints.key != nil {
		keys++
	}
	if constraints.secret != "" {
		keys++
	}
	if keys > 1 {
		err = fmt.Errorf("duplicate key constraints")
		return
	}
	if keys < 1 {
		err = fmt.Errorf("no key constraint")
		return
	}
	return
}
10294
func (a *ACLToken) Validate() error {
	var mErr multierror.Error
	if len(a.Name) > maxTokenNameLength {
		mErr.Errors = append(mErr.Errors, fmt.Errorf("token name too long"))
	}
	switch a.Type {
	case ACLClientToken:
		if len(a.Policies) == 0 {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("client token missing policies"))
		}
	case ACLManagementToken:
		if len(a.Policies) != 0 {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("management token cannot be associated with policies"))
		}
	default:
		mErr.Errors = append(mErr.Errors, fmt.Errorf("token type must be client or management"))
	}
	return mErr.ErrorOrNil()
}
526134
func (srv *Server) Validate() bool {
	if srv.debug {
		return true
	}
	timestamp := srv.Query("timestamp")
	nonce := srv.Query("nonce")
	signature := srv.Query("signature")
	return signature == util.Signature(srv.Token, timestamp, nonce)
}
903220
func Validate(passcode string, counter uint64, secret string) bool {
	rv, _ := ValidateCustom(
		passcode,
		counter,
		secret,
		ValidateOpts{
			Digits:    otp.DigitsSix,
			Algorithm: otp.AlgorithmSHA1,
		},
	)
	return rv
}
521001
func (o *CSRSigningControllerOptions) Validate() []error {
	if o == nil {
		return nil
	}

	errs := []error{}
	return errs
}
227674
func (m *Swaggeroauth2TokenParameters) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateGrantType(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
327475
func (e *RequiredValidator) Validate(s interface{}) error {
	if e.TagName == "" {
		e.TagName = "required"
	}

	if e.TagValue == "" {
		e.TagValue = "true"
	}

	for _, field := range structs.Fields(s) {
		if err := e.processField("", field); err != nil {
			return err
		}
	}

	return nil
}