<commit_before>package com.belladati.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.belladati.sdk.auth.OAuthRequest;

/**
 * Controller handling logic related to authorization.
 * 
 * @author <NAME>
 */
@Controller
public class AuthorizationController {

	@Autowired
	private ServiceManager serviceManager;

	@Value("${consumer.key}")
	private String key;

	@Value("${consumer.secret}")
	private String secret;

	/**
	 * Shows the login page.
	 */
	@RequestMapping(value = "/login", method = RequestMethod.GET)
	public ModelAndView showLogin() {
		return new ModelAndView("login");
	}

	/**
	 * Redirects the user to BellaDati for OAuth authorization.
	 */
	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public ModelAndView login() {
		// replace key and secret by your domain's key/secret
		OAuthRequest request = serviceManager.initiateOAuth(key, secret);
		return new ModelAndView("redirect:" + request.getAuthorizationUrl());
	}

	/**
	 * Landing page after OAuth authorization. Completes OAuth.
	 */
	@RequestMapping(value = "/authorize", method = RequestMethod.GET)
	public ModelAndView getAccessToken() {
		// here we should catch AuthorizationExceptions and show an error
		serviceManager.completeOAuth();
		return new ModelAndView("redirect:/");
	}

	/**
	 * Logs out.
	 */
	@RequestMapping(value = "/logout", method = RequestMethod.GET)
	public ModelAndView doLogout() {
		serviceManager.logout();
		return new ModelAndView("redirect:/");
	}

}<commit_msg>passing dynamic callback URL during authorization<commit_after>package com.belladati.demo.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.belladati.sdk.auth.OAuthRequest;

/**
 * Controller handling logic related to authorization.
 * 
 * @author <NAME>
 */
@Controller
public class AuthorizationController {

	@Autowired
	private ServiceManager serviceManager;

	@Value("${consumer.key}")
	private String key;

	@Value("${consumer.secret}")
	private String secret;

	/**
	 * Shows the login page.
	 */
	@RequestMapping(value = "/login", method = RequestMethod.GET)
	public ModelAndView showLogin() {
		return new ModelAndView("login");
	}

	/**
	 * Redirects the user to BellaDati for OAuth authorization.
	 */
	@RequestMapping(value = "/login", method = RequestMethod.POST)
	public ModelAndView login(HttpServletRequest request) {
		// replace key and secret by your domain's key/secret
		OAuthRequest oAuthRequest = serviceManager.initiateOAuth(key, secret);
		return new ModelAndView("redirect:" + oAuthRequest.getAuthorizationUrl() + "?callbackUrl=" + getDeploymentUrl(request)
			+ "/authorize");
	}

	/**
	 * Landing page after OAuth authorization. Completes OAuth.
	 */
	@RequestMapping(value = "/authorize", method = RequestMethod.GET)
	public ModelAndView getAccessToken() {
		// here we should catch AuthorizationExceptions and show an error
		serviceManager.completeOAuth();
		return new ModelAndView("redirect:/");
	}

	/**
	 * Logs out.
	 */
	@RequestMapping(value = "/logout", method = RequestMethod.GET)
	public ModelAndView doLogout() {
		serviceManager.logout();
		return new ModelAndView("redirect:/");
	}

	/**
	 * Finds the root URL of the current deployment based on the user's request.
	 * 
	 * @param request request from the user
	 * @return the deployment root, including scheme, server, port, and path
	 */
	private String getDeploymentUrl(HttpServletRequest request) {
		String requestUrl = request.getRequestURL().toString();
		String servletPath = request.getServletPath();
		return requestUrl.substring(0, requestUrl.length() - servletPath.length());
	}
}
{'fraction_non_alphanumeric': 0.11552853133769879, 'fraction_numerical': 0.00023386342376052386, 'mean_word_length': 4.948539638386648, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2651912', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1195, 'n_words': 304}