<commit_before>package main

import (
	"crypto/tls"
	"errors"
	"fmt"
	"github.com/Comcast/webpa-common/concurrent"
	"github.com/Comcast/webpa-common/secure"
	"github.com/Comcast/webpa-common/secure/handler"
	"github.com/Comcast/webpa-common/secure/key"
	"github.com/Comcast/webpa-common/server"
	"github.com/Comcast/webpa-common/webhook"
	"github.com/gorilla/mux"
	"github.com/justinas/alice"
	"github.com/SermoDigital/jose/jwt"
	"github.com/spf13/pflag"
	"github.com/spf13/viper"
	"net/http"
	"net/url"
	"os"
	"os/signal"
	"time"
)

const (
	applicationName = "caduceus"
	DEFAULT_KEY_ID = "current"
)


// getValidator returns validator for JWT tokens
func getValidator(v *viper.Viper) (validator secure.Validator, err error) {
	no_validators := make(secure.Validators, 0, 0)
	var jwtVals []JWTValidator
	
	// obtain valid jwtValidator from configuration
	if jwtVals, ok := v.Get("jwtValidators").([]JWTValidator); !ok {
		validator = no_validators
		err = errors.New("Unable to cast \"jwtValidators\" value as type []JWTValidator")
		return
	}

	// make sure there is at least one jwtValidator supplied
	if len(jwtVals) < 1 {
		validator = no_validators
		err = errors.New("Supplied jwtValidator list size is less than 1")
		return
	}

	// if a JWTKeys section was supplied, configure a JWS validator
	// and append it to the chain of validators
	validators := make(secure.Validators, 0, len(jwtVals))
	
	for _, validatorDescriptor := range jwtVals {
		var keyResolver key.Resolver
		keyResolver, err = validatorDescriptor.Keys.NewResolver()
		if err != nil {
			validator = validators
			return 
		}

		validators = append(
			validators,
			secure.JWSValidator{
				DefaultKeyId:  DEFAULT_KEY_ID,<commit_msg>build fix<commit_after>package main

import (
	"crypto/tls"
	"errors"
	"fmt"
	"github.com/Comcast/webpa-common/concurrent"
	"github.com/Comcast/webpa-common/secure"
	"github.com/Comcast/webpa-common/secure/handler"
	"github.com/Comcast/webpa-common/secure/key"
	"github.com/Comcast/webpa-common/server"
	"github.com/Comcast/webpa-common/webhook"
	"github.com/gorilla/mux"
	"github.com/justinas/alice"
	"github.com/SermoDigital/jose/jwt"
	"github.com/spf13/pflag"
	"github.com/spf13/viper"
	"net/http"
	"net/url"
	"os"
	"os/signal"
	"time"
)

const (
	applicationName = "caduceus"
	DEFAULT_KEY_ID = "current"
)


// getValidator returns validator for JWT tokens
func getValidator(v *viper.Viper) (validator secure.Validator, err error) {
	no_validators := make(secure.Validators, 0, 0)
	var jwtVals []JWTValidator
	var ok bool
	
	// obtain valid jwtValidator from configuration
	if jwtVals, ok = v.Get("jwtValidators").([]JWTValidator); !ok {
		validator = no_validators
		err = errors.New("Unable to cast \"jwtValidators\" value as type []JWTValidator")
		return
	}

	// make sure there is at least one jwtValidator supplied
	if len(jwtVals) < 1 {
		validator = no_validators
		err = errors.New("Supplied jwtValidator list size is less than 1")
		return
	}

	// if a JWTKeys section was supplied, configure a JWS validator
	// and append it to the chain of validators
	validators := make(secure.Validators, 0, len(jwtVals))
	
	for _, validatorDescriptor := range jwtVals {
		var keyResolver key.Resolver
		keyResolver, err = validatorDescriptor.Keys.NewResolver()
		if err != nil {
			validator = validators
			return 
		}

		validators = append(
			validators,
			secure.JWSValidator{
				DefaultKeyId:  DEFAULT_KEY_ID,
{'fraction_non_alphanumeric': 0.11975524475524475, 'fraction_numerical': 0.005244755244755245, 'mean_word_length': 4.170180722891566, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '629209', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1234, 'n_words': 277}