<commit_before>package com.atlassian.jira.plugins.dvcs.spi.github.webwork;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.atlassian.jira.plugins.dvcs.spi.github.GithubOAuth;
import com.atlassian.jira.security.xsrf.RequiresXsrfCheck;
import com.atlassian.jira.web.action.JiraWebActionSupport;
import com.atlassian.sal.api.ApplicationProperties;

public class ConfigureGithubOAuth extends JiraWebActionSupport
{
	private static final long serialVersionUID = 1L;

	final Logger logger = LoggerFactory.getLogger(ConfigureGithubOAuth.class);
   
	private final GithubOAuth githubOAuth;
    private final ApplicationProperties applicationProperties;
    
    // Client ID (from GitHub OAuth Application)
    private String clientID = "";
    // Client Secret (from GitHub OAuth Application)
    private String clientSecret = "";
    // Confirmation Messages
    private String messages = "";
    
    private String forceClear = "";


    public ConfigureGithubOAuth(GithubOAuth githubOAuth, ApplicationProperties applicationProperties)
    {
        this.githubOAuth = githubOAuth;
        this.applicationProperties = applicationProperties;
    }

    @Override
    protected void doValidation()
    {
    	if (StringUtils.isNotBlank(forceClear)) {
    		return;
    	}
  
        if (StringUtils.isBlank(clientSecret) || StringUtils.isBlank(clientID))
        {
            addErrorMessage("Please enter both the GitHub OAuth Client ID and Client Secret.");
        }
    }

    @Override
    @RequiresXsrfCheck
    protected String doExecute() throws Exception
    {
        if (!getHasErrorMessages())
        {
            addClientIdentifiers();
        }

        return INPUT;
    }

    private void addClientIdentifiers()
    {
        githubOAuth.setClient(clientID, clientSecret);
        messages = "GitHub Client Identifiers Set Correctly";
    }

    public String getSavedClientSecret()
    {<commit_msg>BBC-224: Trim client_id and client_secret values<commit_after>package com.atlassian.jira.plugins.dvcs.spi.github.webwork;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.atlassian.jira.plugins.dvcs.spi.github.GithubOAuth;
import com.atlassian.jira.security.xsrf.RequiresXsrfCheck;
import com.atlassian.jira.web.action.JiraWebActionSupport;
import com.atlassian.sal.api.ApplicationProperties;

public class ConfigureGithubOAuth extends JiraWebActionSupport
{
	private static final long serialVersionUID = 1L;

	final Logger logger = LoggerFactory.getLogger(ConfigureGithubOAuth.class);
   
	private final GithubOAuth githubOAuth;
    private final ApplicationProperties applicationProperties;
    
    // Client ID (from GitHub OAuth Application)
    private String clientID = "";
    // Client Secret (from GitHub OAuth Application)
    private String clientSecret = "";
    // Confirmation Messages
    private String messages = "";
    
    private String forceClear = "";


    public ConfigureGithubOAuth(GithubOAuth githubOAuth, ApplicationProperties applicationProperties)
    {
        this.githubOAuth = githubOAuth;
        this.applicationProperties = applicationProperties;
    }

    @Override
    protected void doValidation()
    {
    	if (StringUtils.isNotBlank(forceClear)) {
    		return;
    	}
  
        if (StringUtils.isBlank(clientSecret) || StringUtils.isBlank(clientID))
        {
            addErrorMessage("Please enter both the GitHub OAuth Client ID and Client Secret.");
        }
    }

    @Override
    @RequiresXsrfCheck
    protected String doExecute() throws Exception
    {
        if (!getHasErrorMessages())
        {
            addClientIdentifiers();
        }

        return INPUT;
    }

    private void addClientIdentifiers()
    {
        githubOAuth.setClient(StringUtils.trim(clientID), StringUtils.trim(clientSecret));
        messages = "GitHub Client Identifiers Set Correctly";
    }

    public String getSavedClientSecret()
    {
{'fraction_non_alphanumeric': 0.08079306071871127, 'fraction_numerical': 0.0022304832713754648, 'mean_word_length': 3.3165775401069517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4160336', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1131, 'n_words': 247}