<commit_before>package com.venky.swf.extensions;

import com.venky.core.util.ObjectHolder;
import com.venky.core.util.ObjectUtil;
import com.venky.extension.Extension;
import com.venky.extension.Registry;
import com.venky.swf.db.JdbcTypeHelper.TypeConverter;
import com.venky.swf.db.model.User;
import com.venky.swf.path.Path;

import java.math.BigDecimal;

public class RequestAuthenticator implements Extension {
    static{
        Registry.instance().registerExtension(Path.REQUEST_AUTHENTICATOR,new RequestAuthenticator());
    }
    @Override
    public void invoke(Object... context) {
        Path path = (Path)context[0];
        ObjectHolder<User> userObjectHolder = (ObjectHolder<User>)context[1];

        String apiKey = getHeader(path,"ApiKey");
        String lat = getHeader( path,"Lat");
        String lng = getHeader( path, "Lng");



        if (!ObjectUtil.isVoid(apiKey)){
            User user = path.getUser("api_key",apiKey);
            if (user == null) {
                path.addErrorMessage("Invalid Api Key");
            }else if (userObjectHolder.get() != null){
                User alreadySet = userObjectHolder.get();
                if (alreadySet.getId() != user.getId()){
                    userObjectHolder.set(null);
                    path.addErrorMessage("User not identifiable");
                }
            }else {
                userObjectHolder.set(user);
            }
            if (user != null){
                TypeConverter<BigDecimal> tc = user.getReflector().getJdbcTypeHelper().getTypeRef(BigDecimal.class).getTypeConverter();
                if (!ObjectUtil.isVoid(lat)){
                    user.setLat(tc.valueOf(lat));
                }
                if (!ObjectUtil.isVoid(lng)){
                    user.setLng(tc.valueOf(lng));
                }
            }
        }
    }

    public String getHeader(Path path, String key){
        String value = path.getRequest().getHeader("X-"+key);

        if (ObjectUtil.isVoid(value)){
            value = path.getRequest().getHeader(key);
        }

        if (ObjectUtil.isVoid(value)){
            value = path.getRequest().getParameter(key);
        }
        return value;
    }
}
<commit_msg>Don't read parameter. Input stream of request beccomes 0 bytes<commit_after>package com.venky.swf.extensions;

import com.venky.core.util.ObjectHolder;
import com.venky.core.util.ObjectUtil;
import com.venky.extension.Extension;
import com.venky.extension.Registry;
import com.venky.swf.db.JdbcTypeHelper.TypeConverter;
import com.venky.swf.db.model.User;
import com.venky.swf.integration.api.Call;
import com.venky.swf.integration.api.HttpMethod;
import com.venky.swf.path.Path;

import java.math.BigDecimal;

public class RequestAuthenticator implements Extension {
    static{
        Registry.instance().registerExtension(Path.REQUEST_AUTHENTICATOR,new RequestAuthenticator());
    }
    @Override
    public void invoke(Object... context) {
        Path path = (Path)context[0];
        ObjectHolder<User> userObjectHolder = (ObjectHolder<User>)context[1];

        String apiKey = getHeader(path,"ApiKey");
        String lat = getHeader( path,"Lat");
        String lng = getHeader( path, "Lng");



        if (!ObjectUtil.isVoid(apiKey)){
            User user = path.getUser("api_key",apiKey);
            if (user == null) {
                path.addErrorMessage("Invalid Api Key");
            }else if (userObjectHolder.get() != null){
                User alreadySet = userObjectHolder.get();
                if (alreadySet.getId() != user.getId()){
                    userObjectHolder.set(null);
                    path.addErrorMessage("User not identifiable");
                }
            }else {
                userObjectHolder.set(user);
            }
            if (user != null){
                TypeConverter<BigDecimal> tc = user.getReflector().getJdbcTypeHelper().getTypeRef(BigDecimal.class).getTypeConverter();
                if (!ObjectUtil.isVoid(lat)){
                    user.setLat(tc.valueOf(lat));
                }
                if (!ObjectUtil.isVoid(lng)){
                    user.setLng(tc.valueOf(lng));
                }
            }
        }
    }

    public String getHeader(Path path, String key){
        String value = path.getRequest().getHeader("X-"+key);

        if (ObjectUtil.isVoid(value)){
            value = path.getRequest().getHeader(key);
        }

        if (ObjectUtil.isVoid(value)){
            value = path.getRequest().getMethod().equalsIgnoreCase(HttpMethod.GET.toString()) ? path.getRequest().getParameter(key) : null ;
        }
        return value;
    }
}

{'fraction_non_alphanumeric': 0.12486567805716742, 'fraction_numerical': 0.001074575542660649, 'mean_word_length': 2.2207612456747405, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5147329', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1305, 'n_words': 229}