%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="javax.servlet.ServletConfig" %>
<%@ page import="javax.servlet.ServletException" %>
<%@ page import="javax.servlet.http.HttpServlet" %>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<%@ page import="javax.servlet.http.HttpServletResponse" %>
<%@ page import="net.oauth.OAuthMessage" %>
<%@ page import="net.oauth.server.OAuthServlet" %>
<%@ page import="net.oauth.OAuthAccessor" %>
<%@ page import="net.oauth.example.provider.core.SampleOAuthProvider" %>
<%@ page import="net.oauth.OAuth" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="net.oauth.OAuthProblemException" %>
<%@ page import="java.util.Map" %>
<%
/*
* 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.
*/
/**
* A text servlet to echo incoming "echo" param along with userId
*
* @author Praveen Alavilli
* @author John Kristian
*/
try {
System.out.println("echo");
OAuthMessage requestMessage = OAuthServlet.getMessage(request, null);
OAuthAccessor accessor = SampleOAuthProvider.getAccessor(requestMessage);
SampleOAuthProvider.VALIDATOR.validateMessage(requestMessage, accessor);
String userId = (String) accessor.getProperty("user");
System.out.println("echo - requestMessage: " + requestMessage);
System.out.println("accessor: " + accessor);
System.out.println("userId: " + userId);
response.setContentType("text/plain");
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){
e.printStackTrace();
SampleOAuthProvider.handleException(e, request, response, false);
}
%>