第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

HttpURLConnection 中的 NTLM 身份驗(yàn)證在 JRE 中不起作用

HttpURLConnection 中的 NTLM 身份驗(yàn)證在 JRE 中不起作用

烙印99 2022-06-08 17:04:29
我正在使用 eclipse 開(kāi)發(fā)應(yīng)用程序的兩個(gè)部分。Web 部件提供 REST 服務(wù)并過(guò)濾對(duì)服務(wù)的請(qǐng)求,使用waffle.servlet.NegotiateSecurityFilter它提取 Windows 登錄信息以識(shí)別用戶??蛻舳瞬考糜贖ttpURLConnection向 Web 部件發(fā)送請(qǐng)求。據(jù)我了解,Ntlm 信息會(huì)自動(dòng)打包到請(qǐng)求中。當(dāng)我在 Eclipse 中測(cè)試它時(shí),它運(yùn)行良好。當(dāng)我部署客戶端 JAR 時(shí),它不起作用。我得到一個(gè) 401 Not Authenticated。經(jīng)過(guò)一番調(diào)查,我發(fā)現(xiàn)我可以通過(guò)將執(zhí)行環(huán)境設(shè)置為 JRE 而不是默認(rèn)的 JDK 在 eclipe 中重現(xiàn)這一點(diǎn)。我安裝了 JRE“1.8.0_201”和 JDK“1.8.0_161”。因此,只需將執(zhí)行環(huán)境從 JRE 更改為 JDK,我就可以獲得連接以進(jìn)行身份驗(yàn)證。JDK 有什么不同,我可以做些什么來(lái)讓客戶端使用 JRE?
查看完整描述

2 回答

?
慕村225694

TA貢獻(xiàn)1880條經(jīng)驗(yàn) 獲得超4個(gè)贊

我認(rèn)為如何在調(diào)用任何 url 時(shí)提供 ntlm 身份驗(yàn)證的第一個(gè)答案?可以回答這個(gè)問(wèn)題。在 Java 8u201 中,有一個(gè)新的 JRE 選項(xiàng)jdk.http.ntlm.transparentAuth,默認(rèn)設(shè)置為禁用



查看完整回答
反對(duì) 回復(fù) 2022-06-08
?
至尊寶的傳說(shuō)

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超10個(gè)贊

我沒(méi)有找到 JRE 和 JDK 之間的區(qū)別。相反,我發(fā)現(xiàn)了這個(gè)解決方法。


<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->

<dependency>

    <groupId>org.apache.httpcomponents</groupId>

    <artifactId>httpclient</artifactId>

    <version>4.5.7</version>

</dependency>


<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient-win -->

<dependency>

    <groupId>org.apache.httpcomponents</groupId>

    <artifactId>httpclient-win</artifactId>

    <version>4.5.7</version>

</dependency>

示例代碼


        if (!WinHttpClients.isWinAuthAvailable()) {

            log.warn("Integrated Win auth is not supported!!!");

        }


        // There is no need to provide user credentials

        // HttpClient will attempt to access current user security context through

        // Windows platform specific methods via JNI.

        try (CloseableHttpClient httpclient = WinHttpClients.createDefault()) {

            HttpGet httpget = new HttpGet(getRestUrl().toURI());


            log.debug("Executing request " + httpget.getRequestLine());


            try (CloseableHttpResponse response = httpclient.execute(httpget)) {

                int status = response   .getStatusLine()

                                        .getStatusCode();

                if (status != 200) {

                    log.error("HTTP error " + status);

                    throw new RuntimeException("Failed : HTTP error code : " + status);

                }


                Type listType = new TypeToken<HashMap<String, App>>() {

                }.getType();

                return new Gson().fromJson(new InputStreamReader(response   .getEntity()

                                                                            .getContent(),

                        "UTF-8"), listType);

            }

        }


查看完整回答
反對(duì) 回復(fù) 2022-06-08
  • 2 回答
  • 0 關(guān)注
  • 190 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)