<%@ 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.OAuth" %> <%@ page import="net.oauth.OAuthAccessor" %> <%@ page import="net.oauth.OAuthMessage" %> <%@ page import="net.oauth.OAuthConsumer" %> <%@ page import="net.oauth.example.provider.core.SampleOAuthProvider" %> <%@ page import="net.oauth.server.OAuthServlet" %> <%@ page import="java.io.OutputStream" %> <%@ page import="net.oauth.OAuthProblemException" %> System.out.println("request_token"); <%! static { try { SampleOAuthProvider.loadConsumers(null); } catch (Exception e) { e.printStackTrace(); } } %> <% /* * 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. */ /** * Request token request handler * * @author Praveen Alavilli */ try { System.out.println("request_token"); OAuthMessage requestMessage = OAuthServlet.getMessage(request, null); System.out.println("request_token - requestMessage: " + requestMessage); OAuthConsumer consumer = SampleOAuthProvider.getConsumer(requestMessage); System.out.println("consumer: " + consumer); OAuthAccessor accessor = new OAuthAccessor(consumer); SampleOAuthProvider.VALIDATOR.validateMessage(requestMessage, accessor); { // Support the 'Variable Accessor Secret' extension // described in http://oauth.pbwiki.com/AccessorSecret String secret = requestMessage.getParameter("oauth_accessor_secret"); if (secret != null) { accessor.setProperty(OAuthConsumer.ACCESSOR_SECRET, secret); } } // generate request_token and secret SampleOAuthProvider.generateRequestToken(accessor); response.setContentType("text/plain"); OutputStream myOut = response.getOutputStream(); OAuth.formEncode(OAuth.newList("oauth_token", accessor.requestToken, "oauth_token_secret", accessor.tokenSecret), myOut); myOut.close(); } catch (Exception e){ e.printStackTrace(); SampleOAuthProvider.handleException(e, request, response, true); } %>