package jwt

import (
	
	
	
	// "fmt"
)

// MapClaims is a claims type that uses the map[string]interface{} for JSON decoding.
// This is the default claims type if you don't supply one
type MapClaims map[string]interface{}

// VerifyAudience Compares the aud claim against cmp.
// If required is false, this method will return true if the value matches or is unset
func ( MapClaims) ( string,  bool) bool {
	var  []string
	switch v := ["aud"].(type) {
	case string:
		 = append(, )
	case []string:
		 = 
	case []interface{}:
		for ,  := range  {
			,  := .(string)
			if ! {
				return false
			}
			 = append(, )
		}
	}
	return verifyAud(, , )
}

// VerifyExpiresAt compares the exp claim against cmp (cmp <= exp).
// If req is false, it will return true, if exp is unset.
func ( MapClaims) ( int64,  bool) bool {
	 := time.Unix(, 0)

	,  := ["exp"]
	if ! {
		return !
	}

	switch exp := .(type) {
	case float64:
		if  == 0 {
			return verifyExp(nil, , )
		}

		return verifyExp(&newNumericDateFromSeconds().Time, , )
	case json.Number:
		,  := .Float64()

		return verifyExp(&newNumericDateFromSeconds().Time, , )
	}

	return false
}

// VerifyIssuedAt compares the exp claim against cmp (cmp >= iat).
// If req is false, it will return true, if iat is unset.
func ( MapClaims) ( int64,  bool) bool {
	 := time.Unix(, 0)

	,  := ["iat"]
	if ! {
		return !
	}

	switch iat := .(type) {
	case float64:
		if  == 0 {
			return verifyIat(nil, , )
		}

		return verifyIat(&newNumericDateFromSeconds().Time, , )
	case json.Number:
		,  := .Float64()

		return verifyIat(&newNumericDateFromSeconds().Time, , )
	}

	return false
}

// VerifyNotBefore compares the nbf claim against cmp (cmp >= nbf).
// If req is false, it will return true, if nbf is unset.
func ( MapClaims) ( int64,  bool) bool {
	 := time.Unix(, 0)

	,  := ["nbf"]
	if ! {
		return !
	}

	switch nbf := .(type) {
	case float64:
		if  == 0 {
			return verifyNbf(nil, , )
		}

		return verifyNbf(&newNumericDateFromSeconds().Time, , )
	case json.Number:
		,  := .Float64()

		return verifyNbf(&newNumericDateFromSeconds().Time, , )
	}

	return false
}

// VerifyIssuer compares the iss claim against cmp.
// If required is false, this method will return true if the value matches or is unset
func ( MapClaims) ( string,  bool) bool {
	,  := ["iss"].(string)
	return verifyIss(, , )
}

// Valid validates time based claims "exp, iat, nbf".
// There is no accounting for clock skew.
// As well, if any of the above claims are not in the token, it will still
// be considered a valid claim.
func ( MapClaims) () error {
	 := new(ValidationError)
	 := TimeFunc().Unix()

	if !.VerifyExpiresAt(, false) {
		// TODO(oxisto): this should be replaced with ErrTokenExpired
		.Inner = errors.New("Token is expired")
		.Errors |= ValidationErrorExpired
	}

	if !.VerifyIssuedAt(, false) {
		// TODO(oxisto): this should be replaced with ErrTokenUsedBeforeIssued
		.Inner = errors.New("Token used before issued")
		.Errors |= ValidationErrorIssuedAt
	}

	if !.VerifyNotBefore(, false) {
		// TODO(oxisto): this should be replaced with ErrTokenNotValidYet
		.Inner = errors.New("Token is not valid yet")
		.Errors |= ValidationErrorNotValidYet
	}

	if .valid() {
		return nil
	}

	return 
}