<commit_before>package controllers;

import com.google.api.client.auth.openidconnect.IdToken;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import helpers.UserService;
import models.User;
import org.json.JSONObject;
import play.Configuration;
import play.Logger;
import play.mvc.Controller;
import play.mvc.Result;
import utils.GoogleUtility;
import views.html.error;

import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;

/**
 * https://developers.google.com/accounts/docs/OAuth2Login
 * <p>
 * For debugging purposes use: OAuth 2.0 Playground
 * https://developers.google.com/oauthplayground/?code=4/Yru2i1Y0AV8KWhteXZnUNppfLMTj.Mv2PwjP5CW0XPvB8fYmgkJyr8mc3jQI
 */
public class OAuth2 extends Controller {

    /**
     * Secrets
     */
    //private static final Map<String, String> CONF = FileUtility.getMap("/opt/ACTion/conf/secrets/googleoauth", "=");

    private static final Configuration CONF = play.Play.application().configuration();
    /**
     * A session lasts 2 hours
     */
    private static final long EXPIRATION_TIME_IN_SECONDS = 2 * 60 * 60;
    /**
     * Endpoints for authenticating users, and for requesting resources including tokens, user information, and public keys.
     */
    public static GoogleUtility.DiscoveryDocument dd;
    private static boolean update;

    public static Result login() {
        return ok(views.html.login.index.render());
    }

    /**<commit_msg>Ensure state token creation for login.<commit_after>package controllers;

import com.google.api.client.auth.openidconnect.IdToken;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import helpers.UserService;
import models.User;
import org.json.JSONObject;
import play.Configuration;
import play.Logger;
import play.mvc.Controller;
import play.mvc.Result;
import utils.GoogleUtility;
import views.html.error;

import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
import java.util.UUID;

/**
 * https://developers.google.com/accounts/docs/OAuth2Login
 * <p>
 * For debugging purposes use: OAuth 2.0 Playground
 * https://developers.google.com/oauthplayground/?code=4/Yru2i1Y0AV8KWhteXZnUNppfLMTj.Mv2PwjP5CW0XPvB8fYmgkJyr8mc3jQI
 */
public class OAuth2 extends Controller {

    /**
     * Secrets
     */
    //private static final Map<String, String> CONF = FileUtility.getMap("/opt/ACTion/conf/secrets/googleoauth", "=");

    private static final Configuration CONF = play.Play.application().configuration();
    /**
     * A session lasts 2 hours
     */
    private static final long EXPIRATION_TIME_IN_SECONDS = 2 * 60 * 60;
    /**
     * Endpoints for authenticating users, and for requesting resources including tokens, user information, and public keys.
     */
    public static GoogleUtility.DiscoveryDocument dd;
    private static boolean update;

    public static Result login() {
        try {
            createStateToken();
        } catch (NoSuchAlgorithmException e) {
            return internalServerError(error.render(e.getMessage()));
        }
        return ok(views.html.login.index.render());
    }

    /**
{'fraction_non_alphanumeric': 0.10683760683760683, 'fraction_numerical': 0.012066365007541479, 'mean_word_length': 4.235526315789474, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, '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': '785767', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1214, 'n_words': 250}