<commit_before>function preDrawOAuthConfigPage() {
    var clientID = "";
    var clientSecret = "";
    var isEditSP = false;
    if (appdata != null && appdata.inboundAuthenticationConfig != null
        && appdata.inboundAuthenticationConfig.inboundAuthenticationRequestConfigs != null) {
        for (var i in appdata.inboundAuthenticationConfig.inboundAuthenticationRequestConfigs) {
            var inboundConfig = appdata.inboundAuthenticationConfig.inboundAuthenticationRequestConfigs[i];
            if (inboundConfig.inboundAuthType == "oauth2" && inboundConfig.inboundAuthKey.length > 0) {
                clientID = inboundConfig.inboundAuthKey;
                if (inboundConfig.properties.constructor !== Array) {
                    var arr = [];
                    arr[0] = inboundConfig.properties;
                    inboundConfig.properties = arr;
                }
                for (var prop in inboundConfig.properties) {
                    if (inboundConfig.properties[prop].name == 'oauthConsumerSecret') {
                        clientSecret = inboundConfig.properties[prop].value;
                    }
                }
                isEditSP = true;
            }
        }
    }
    //+ "&appName=" + json.return.applicationName + "&clientID=" + clientID,
    $('#isEditOauthSP').val(isEditSP);
    if (isEditSP) {
        $('#oauthAttrIndexForm').show();
        $('#oauthConfigBtn').hide();
        $('#oauthRgsterBtn').hide();
        $('#oauthUpdtBtn').show();
        $.ajax({
            url: "/" + ADMIN_PORTAL_NAME + "/serviceproviders/custom/controllers/custom/oauthConfigHandler.jag",
            type: "GET",
            data: "&cookie=" + cookie + "&user=" + userName + "&appName=" + appdata.applicationName + "&clientID=" + clientID + "&action=getOAuthConfigs",
            success: function (data) {
                oauthClient = $.parseJSON(data);
                allowedGrantTypes = oauthClient.grantTypes;
                drawOAuthEditPage();
            },
            error: function (e) {
                message({
                    content: 'Error occurred while getting the service provider configuration.',
                    type: 'error',
                    cbk: function () {
                    }
                });
            }
        });
    } else {
        $('#oauthAttrIndexForm').hide();
        $('#oauthConfigBtn').show();
        $('#oauthRgsterBtn').show();
        $('#oauthUpdtBtn').hide();
        $.ajax({
            url: "/" + ADMIN_PORTAL_NAME + "/serviceproviders/custom/controllers/custom/oauthConfigHandler.jag",
            type: "GET",
            data: "&cookie=" + cookie + "&user=" + userName + "&action=getOAuthConfigs",
            success: function (data) {
                oauthClient = $.parseJSON(data);
                allowedGrantTypes = oauthClient.grantTypes;
                drawOAuthConfigPage();
            },
            error: function (e) {
                message({
                    content: 'Error occurred while getting the service provider configuration.',
                    type: 'error',
                    cbk: function () {
                    }
                });
            }
        });
    }
}

function drawOAuthConfigPage() {
    var page = "";
    var applicationSPName = appdata.applicationName;
    if (applicationSPName != null && applicationSPName.length > 0) {
        $('#application').val(applicationSPName);
        $('#application').hide();
    } else {
        $('#application').show();
        $('#appnamehid').show();
    }
    var versionRow = '<label for="oauthVersion">OAuth Version' +
        '<span class="required">*</span>' +
        '</label>' +
        '<div class="">' +
        '<label class="radio-inline">'+
        '<input id="oauthVersion10a" type="radio" value="OAuth-1.0a" name="oauthVersion"> 1.0a' +
        '</label>' +
        '<label class="radio-inline">' +
        '<input id="oauthVersion20" type="radio" checked="" value="OAuth-2.0" name="oauthVersion"> 2.0' +
        '</label>'+
        '</div>';
    $('#versionRow').empty();
    $('#versionRow').append(versionRow);
    var grantRow = '<label for="grantTypes">Allowed Grant Types </label>' +
        '<div>';
    if ($.inArray('authorization_code', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_code" name="grant_code" value="authorization_code" checked="checked" onclick="togglePKCE()"/>Code</label></div>';
    }
    if ($.inArray('implicit', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_implicit" name="grant_implicit" value="implicit" checked="checked"/>Implicit</label></div>';
    }
    if ($.inArray('password', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_password" name="grant_password" value="password" checked="checked"/>Password</lable></div>';
    }
    if ($.inArray('client_credentials', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_client" name="grant_client" value="client_credentials" checked="checked"/>Client Credential</label></div>';
    }
    if ($.inArray('refresh_token', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_refresh" name="grant_refresh" value="refresh_token" checked="checked"/>Refresh Token</label></div>';
    }
    if ($.inArray('urn:ietf:params:oauth:grant-type:saml1-bearer', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_saml1" name="grant_saml1" value="urn:ietf:params:oauth:grant-type:saml1-bearer" checked="checked"/>SAML1</label></div>';
    }
    if ($.inArray('urn:ietf:params:oauth:grant-type:saml2-bearer', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_saml2" name="grant_saml2" value="urn:ietf:params:oauth:grant-type:saml2-bearer" checked="checked"/>SAML2</label></div>';
    }
    if ($.inArray('iwa:ntlm', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox hide"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_ntlm" name="grant_ntlm" value="iwa:ntlm"/>IWA-NTLM</label></div>';
    }

    grantRow = grantRow + '</div>';
    $('#grant_row').empty();
    $('#grant_row').append(grantRow);
    if (oauthClient.isPKCESupportEnabled == 'true') {
        $('#pkce_enable').show();
        $('#pkce_support_plain').show();
    }
    $('#oauthRgsterBtn').show();
    $('#oauthUpdtBtn').hide();
    $('#oauthHiddenFields').empty();
//TODO : check the following condition if needed for cancel button
//
//        <%
//
//        boolean applicationComponentFound = CarbonUIUtil.isContextRegistered(config, "/application/");
//    if (applicationComponentFound) {
//    %>
//    <input type="button" class="button"
//        onclick="javascript:location.href='../application/configure-service-provider.jsp?spName=<%=Encode.forUriComponent(applicationSPName)%>'"
//        value="<fmt:message key='cancel'/>"/>
//            <% } else { %>
//
//    <input type="button" class="button"
//        onclick="javascript:location.href='index.jsp?region=region1&item=oauth_menu&ordinal=0'"
//        value="<fmt:message key='cancel'/>"/>
//            <%} %>
//</td>
//    </tr>
//    </tbody>
//    </table>
//
//    </form>
//    </div>
//    </div>

    jQuery(document).ready(function () {
        //on load adjust the form based on the current settings
        adjustForm();
        $(jQuery("#addAppForm input")).change(adjustForm);
    })

}

function drawOAuthEditPage() {
    var VERSION_2 = 'OAuth-2.0';
    var VERSION_1 = 'OAuth-1.0a';
    var app = oauthClient.app;
    var applicationSPName = appdata.applicationName;
    var codeGrant = false;
    var implicitGrant = false;
    var passowrdGrant = false;
    var clientCredGrant = false;
    var refreshGrant = false;
    var samlGrant1 = false;
    var samlGrant2 = false;
    var ntlmGrant = false;
    if (VERSION_2 == app.OAuthVersion) {
        var grants = app.grantTypes;
        if (grants != null) {
            codeGrant = grants.indexOf("authorization_code") > -1 ? true : false;
            implicitGrant = grants.indexOf("implicit") > -1 ? true : false;
            passowrdGrant = grants.indexOf("password") > -1 ? true : false;
            clientCredGrant = grants.indexOf("client_credentials") > -1 ? true : false;
            refreshGrant = grants.indexOf("refresh_token") > -1 ? true : false;
            samlGrant1 = grants.indexOf("urn:ietf:params:oauth:grant-type:saml1-bearer") > -1 ? true : false;
            samlGrant2 = grants.indexOf("urn:ietf:params:oauth:grant-type:saml2-bearer") > -1 ? true : false;
            ntlmGrant = grants.indexOf("iwa:ntlm") > -1 ? true : false;
        }
    }
    var hiddenFields = '<input id="consumerkey" name="consumerkey" type="hidden" />'+
        '<input id="consumersecret" name="consumersecret" type="hidden" />'+
        '<input id="oauthVersion" name="oauthVersion" type="hidden" />';
    $('#oauthHiddenFields').empty();
    $('#oauthHiddenFields').append(hiddenFields);
    $('#consumerID').val(app.oauthConsumerKey);
    $('#consumerSecret').val(app.oauthConsumerSecret);
    //$('#addAppForm h4').html('View/Update application settings');
    //$('#addAppForm h5').html('Application Settings');
    $('#consumerkey').val(app.oauthConsumerKey);
    $('#consumersecret').val(app.oauthConsumerSecret);
    $('#oauthVersion').val(app.OAuthVersion);
    var versionRow = '<label for="oauthVersion">OAuth Version' +
        '<span class="required">*</span>' +
        '</label>' +
        '<div class="col-sm-10">' +
        '<label class="col-sm-2 control-label">' + app.OAuthVersion +'</label>'+
        '</div>';
    $('#versionRow').empty();
    $('#versionRow').append(versionRow);

    if (applicationSPName == null) {
        $('#application').val(app.applicationName);
        $('#appnamehid').show();
    } else {
        $('#application').val(applicationSPName);
        $('#appnamehid').hide();
    }
    $('#callback').val(app.callbackUrl);
    var body = "";
    if (app.OAuthVersion == VERSION_1 || codeGrant || implicitGrant) {
        $(jQuery('#callback_row')).attr('style', '');<commit_msg>Set autocomplete off in password fields.<commit_after>function preDrawOAuthConfigPage() {
    var clientID = "";
    var clientSecret = "";
    var isEditSP = false;
    if (appdata != null && appdata.inboundAuthenticationConfig != null
        && appdata.inboundAuthenticationConfig.inboundAuthenticationRequestConfigs != null) {
        for (var i in appdata.inboundAuthenticationConfig.inboundAuthenticationRequestConfigs) {
            var inboundConfig = appdata.inboundAuthenticationConfig.inboundAuthenticationRequestConfigs[i];
            if (inboundConfig.inboundAuthType == "oauth2" && inboundConfig.inboundAuthKey.length > 0) {
                clientID = inboundConfig.inboundAuthKey;
                if (inboundConfig.properties.constructor !== Array) {
                    var arr = [];
                    arr[0] = inboundConfig.properties;
                    inboundConfig.properties = arr;
                }
                for (var prop in inboundConfig.properties) {
                    if (inboundConfig.properties[prop].name == 'oauthConsumerSecret') {
                        clientSecret = inboundConfig.properties[prop].value;
                    }
                }
                isEditSP = true;
            }
        }
    }
    //+ "&appName=" + json.return.applicationName + "&clientID=" + clientID,
    $('#isEditOauthSP').val(isEditSP);
    if (isEditSP) {
        $('#oauthAttrIndexForm').show();
        $('#oauthConfigBtn').hide();
        $('#oauthRgsterBtn').hide();
        $('#oauthUpdtBtn').show();
        $.ajax({
            url: "/" + ADMIN_PORTAL_NAME + "/serviceproviders/custom/controllers/custom/oauthConfigHandler.jag",
            type: "GET",
            data: "&cookie=" + cookie + "&user=" + userName + "&appName=" + appdata.applicationName + "&clientID=" + clientID + "&action=getOAuthConfigs",
            success: function (data) {
                oauthClient = $.parseJSON(data);
                allowedGrantTypes = oauthClient.grantTypes;
                drawOAuthEditPage();
            },
            error: function (e) {
                message({
                    content: 'Error occurred while getting the service provider configuration.',
                    type: 'error',
                    cbk: function () {
                    }
                });
            }
        });
    } else {
        $('#oauthAttrIndexForm').hide();
        $('#oauthConfigBtn').show();
        $('#oauthRgsterBtn').show();
        $('#oauthUpdtBtn').hide();
        $.ajax({
            url: "/" + ADMIN_PORTAL_NAME + "/serviceproviders/custom/controllers/custom/oauthConfigHandler.jag",
            type: "GET",
            data: "&cookie=" + cookie + "&user=" + userName + "&action=getOAuthConfigs",
            success: function (data) {
                oauthClient = $.parseJSON(data);
                allowedGrantTypes = oauthClient.grantTypes;
                drawOAuthConfigPage();
            },
            error: function (e) {
                message({
                    content: 'Error occurred while getting the service provider configuration.',
                    type: 'error',
                    cbk: function () {
                    }
                });
            }
        });
    }
}

function drawOAuthConfigPage() {
    var page = "";
    var applicationSPName = appdata.applicationName;
    if (applicationSPName != null && applicationSPName.length > 0) {
        $('#application').val(applicationSPName);
        $('#application').hide();
    } else {
        $('#application').show();
        $('#appnamehid').show();
    }
    var versionRow = '<label for="oauthVersion">OAuth Version' +
        '<span class="required">*</span>' +
        '</label>' +
        '<div class="">' +
        '<label class="radio-inline">'+
        '<input id="oauthVersion10a" type="radio" value="OAuth-1.0a" name="oauthVersion"> 1.0a' +
        '</label>' +
        '<label class="radio-inline">' +
        '<input id="oauthVersion20" type="radio" checked="" value="OAuth-2.0" name="oauthVersion"> 2.0' +
        '</label>'+
        '</div>';
    $('#versionRow').empty();
    $('#versionRow').append(versionRow);
    var grantRow = '<label for="grantTypes">Allowed Grant Types </label>' +
        '<div>';
    if ($.inArray('authorization_code', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_code" name="grant_code" value="authorization_code" checked="checked" onclick="togglePKCE()"/>Code</label></div>';
    }
    if ($.inArray('implicit', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_implicit" name="grant_implicit" value="implicit" checked="checked"/>Implicit</label></div>';
    }
    if ($.inArray('password', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_password" name="grant_password" value="password" checked="checked"/>Password</lable></div>';
    }
    if ($.inArray('client_credentials', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_client" name="grant_client" value="client_credentials" checked="checked"/>Client Credential</label></div>';
    }
    if ($.inArray('refresh_token', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_refresh" name="grant_refresh" value="refresh_token" checked="checked"/>Refresh Token</label></div>';
    }
    if ($.inArray('urn:ietf:params:oauth:grant-type:saml1-bearer', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_saml1" name="grant_saml1" value="urn:ietf:params:oauth:grant-type:saml1-bearer" checked="checked"/>SAML1</label></div>';
    }
    if ($.inArray('urn:ietf:params:oauth:grant-type:saml2-bearer', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_saml2" name="grant_saml2" value="urn:ietf:params:oauth:grant-type:saml2-bearer" checked="checked"/>SAML2</label></div>';
    }
    if ($.inArray('iwa:ntlm', allowedGrantTypes) > 0) {
        grantRow = grantRow + '<div class="checkbox hide"><label><input class="custom-checkbox custom-checkbox-white" type="checkbox" id="grant_ntlm" name="grant_ntlm" value="iwa:ntlm"/>IWA-NTLM</label></div>';
    }

    grantRow = grantRow + '</div>';
    $('#grant_row').empty();
    $('#grant_row').append(grantRow);
    if (oauthClient.isPKCESupportEnabled == 'true') {
        $('#pkce_enable').show();
        $('#pkce_support_plain').show();
    }
    $('#oauthRgsterBtn').show();
    $('#oauthUpdtBtn').hide();
    $('#oauthHiddenFields').empty();
//TODO : check the following condition if needed for cancel button
//
//        <%
//
//        boolean applicationComponentFound = CarbonUIUtil.isContextRegistered(config, "/application/");
//    if (applicationComponentFound) {
//    %>
//    <input type="button" class="button"
//        onclick="javascript:location.href='../application/configure-service-provider.jsp?spName=<%=Encode.forUriComponent(applicationSPName)%>'"
//        value="<fmt:message key='cancel'/>"/>
//            <% } else { %>
//
//    <input type="button" class="button"
//        onclick="javascript:location.href='index.jsp?region=region1&item=oauth_menu&ordinal=0'"
//        value="<fmt:message key='cancel'/>"/>
//            <%} %>
//</td>
//    </tr>
//    </tbody>
//    </table>
//
//    </form>
//    </div>
//    </div>

    jQuery(document).ready(function () {
        //on load adjust the form based on the current settings
        adjustForm();
        $(jQuery("#addAppForm input")).change(adjustForm);
    })

}

function drawOAuthEditPage() {
    var VERSION_2 = 'OAuth-2.0';
    var VERSION_1 = 'OAuth-1.0a';
    var app = oauthClient.app;
    var applicationSPName = appdata.applicationName;
    var codeGrant = false;
    var implicitGrant = false;
    var passowrdGrant = false;
    var clientCredGrant = false;
    var refreshGrant = false;
    var samlGrant1 = false;
    var samlGrant2 = false;
    var ntlmGrant = false;
    if (VERSION_2 == app.OAuthVersion) {
        var grants = app.grantTypes;
        if (grants != null) {
            codeGrant = grants.indexOf("authorization_code") > -1 ? true : false;
            implicitGrant = grants.indexOf("implicit") > -1 ? true : false;
            passowrdGrant = grants.indexOf("password") > -1 ? true : false;
            clientCredGrant = grants.indexOf("client_credentials") > -1 ? true : false;
            refreshGrant = grants.indexOf("refresh_token") > -1 ? true : false;
            samlGrant1 = grants.indexOf("urn:ietf:params:oauth:grant-type:saml1-bearer") > -1 ? true : false;
            samlGrant2 = grants.indexOf("urn:ietf:params:oauth:grant-type:saml2-bearer") > -1 ? true : false;
            ntlmGrant = grants.indexOf("iwa:ntlm") > -1 ? true : false;
        }
    }
    var hiddenFields = '<input id="consumerkey" name="consumerkey" type="hidden" />'+
        '<input id="consumersecret" name="consumersecret" type="hidden" autocomplete="off"/>'+
        '<input id="oauthVersion" name="oauthVersion" type="hidden" />';
    $('#oauthHiddenFields').empty();
    $('#oauthHiddenFields').append(hiddenFields);
    $('#consumerID').val(app.oauthConsumerKey);
    $('#consumerSecret').val(app.oauthConsumerSecret);
    //$('#addAppForm h4').html('View/Update application settings');
    //$('#addAppForm h5').html('Application Settings');
    $('#consumerkey').val(app.oauthConsumerKey);
    $('#consumersecret').val(app.oauthConsumerSecret);
    $('#oauthVersion').val(app.OAuthVersion);
    var versionRow = '<label for="oauthVersion">OAuth Version' +
        '<span class="required">*</span>' +
        '</label>' +
        '<div class="col-sm-10">' +
        '<label class="col-sm-2 control-label">' + app.OAuthVersion +'</label>'+
        '</div>';
    $('#versionRow').empty();
    $('#versionRow').append(versionRow);

    if (applicationSPName == null) {
        $('#application').val(app.applicationName);
        $('#appnamehid').show();
    } else {
        $('#application').val(applicationSPName);
        $('#appnamehid').hide();
    }
    $('#callback').val(app.callbackUrl);
    var body = "";
    if (app.OAuthVersion == VERSION_1 || codeGrant || implicitGrant) {
        $(jQuery('#callback_row')).attr('style', '');
{'fraction_non_alphanumeric': 0.17138372039336996, 'fraction_numerical': 0.005817443095249088, 'mean_word_length': 2.8397447261123916, 'pattern_counts': {'":': 0, '<': 167, '<?xml version=': 0, '>': 203, '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': '5525046', 'n_tokens_mistral': 6437, 'n_tokens_neox': 6314, 'n_words': 1084}