<commit_before>/*
 * Copyright 2007 AOL, LLC.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.oauth.example.provider.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.oauth.OAuthAccessor;
import net.oauth.OAuthMessage;
import net.oauth.example.provider.core.SampleOAuthProvider;
import net.oauth.server.OAuthServlet;

/**
 * A text servlet to echo incoming "echo" param along with userId
 *
 * @author <NAME>
 */
public class EchoServlet extends HttpServlet {
    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        
        String param = request.getParameter("echo");
        
        try{
            OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
            
            OAuthAccessor accessor = SampleOAuthProvider.getAccessor(requestMessage);
            
            String userId = (String) accessor.getProperty("user");
            // verify the signature
            requestMessage.validateSignature(accessor);
            
            response.setContentType("text/plain");
            PrintWriter out = response.getWriter();
            // Try it twice:
            out.println(param + " [Your UserId:" + userId + "]");
            out.close();
            
        } catch (Exception e){
            SampleOAuthProvider.handleException(e, request, response);
        }
        
    }

    private static final long serialVersionUID = 1L;

}
<commit_msg>echo all the request parameters<commit_after>/*
 * Copyright 2007 AOL, LLC.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.oauth.example.provider.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.oauth.OAuthAccessor;
import net.oauth.OAuthMessage;
import net.oauth.example.provider.core.SampleOAuthProvider;
import net.oauth.server.OAuthServlet;

/**
 * A text servlet to echo incoming "echo" param along with userId
 *
 * @author <NAME>
 * @author <NAME>
 */
public class EchoServlet extends HttpServlet {
    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        try{
            OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
            OAuthAccessor accessor = SampleOAuthProvider.getAccessor(requestMessage);
            requestMessage.validateSignature(accessor);
            String userId = (String) accessor.getProperty("user");
            
            response.setContentType("text/plain");
            PrintWriter out = response.getWriter();
            out.println("[Your UserId:" + userId + "]");
            for (Object item : request.getParameterMap().entrySet()) {
                Map.Entry parameter = (Map.Entry) item;
                String[] values = (String[]) parameter.getValue();
                for (String value : values) {
                    out.println(parameter.getKey() + ": " + value);
                }
            }
            out.close();
            
        } catch (Exception e){
            SampleOAuthProvider.handleException(e, request, response);
        }
    }

    private static final long serialVersionUID = 1L;

}

{'fraction_non_alphanumeric': 0.08736133122028526, 'fraction_numerical': 0.0035657686212361333, 'mean_word_length': 2.8395437262357413, 'pattern_counts': {'":': 1, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4233311', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1264, 'n_words': 392}