@SuppressWarnings("serial") public class LoginTwitterCallbackServlet extends HttpServlet {
private static Logger log = Logger.getLogger(LoginTwitterCallbackServlet.class.getName());
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
Twitter twitter = new TwitterFactory().getInstance();
String key = AuthenticationProvider.getProp("twitter-consumer-key");
String secret = AuthenticationProvider.getProp("twitter-consumer-secret");
RequestToken token = (RequestToken) request.getSession().getAttribute("requestToken");
String verifier = request.getParameter("oauth_verifier");
twitter.setOAuthConsumer(key, secret);
try {
twitter.getOAuthAccessToken(token, verifier);
User user = twitter.verifyCredentials();
log.info("Twitter user found:" + user.getName());
request.getSession().removeAttribute("requestToken");
String sid = ((Integer) user.getId()).toString();
UserAccount u = new UserAccount(sid, AuthenticationProvider.TWITTER);