欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

convertcurlcommandintojavaHttpGet-創(chuàng)新互聯(lián)

如何把命令 convertcurlcomma
ndintojavaHttpGet

curl -k -X GET -H "Accept: Application/json" -H "Content-Type: application/json" -u username:password https://someURL/api/cusa/customer/v1/85267198615

專業(yè)從事成都網(wǎng)站設(shè)計、成都做網(wǎng)站、外貿(mào)網(wǎng)站建設(shè),高端網(wǎng)站制作設(shè)計,小程序定制開發(fā),網(wǎng)站推廣的成都做網(wǎng)站的公司。優(yōu)秀技術(shù)團(tuán)隊竭力真誠服務(wù),采用HTML5建站+CSS3前端渲染技術(shù),成都響應(yīng)式網(wǎng)站建設(shè),讓網(wǎng)站在手機(jī)、平板、PC、微信下都能呈現(xiàn)。建站過程建立專項(xiàng)小組,與您實(shí)時在線互動,隨時提供解決方案,暢聊想法和感受。

轉(zhuǎn)換為 java 程序發(fā)送 ?

--------------------------------------------------

紅色部分為關(guān)鍵代碼

先用 url 構(gòu)造一個 HttpGet , 然后加兩個 header , 注意大小寫, username 和 password 要用藍(lán)字部分的代碼加到 header 里面

--------------------------------------------------

參考文章

https://stackoverflow.com/questions/19797601/apache-http-basicscheme-authenticate-deprecated

search 關(guān)鍵字

addHeader(BasicScheme.authenticate

java httpget authen

java httpget set parameters

  public String authenticate(String strRequest) {

        CloseableHttpResponse httpResponse= null;
        CloseableHttpClient httpClient= null;
        JSONObject requestJson= null;

try {

            requestJson= new JSONObject(strRequest);

if (Utility.validateMsisdn(requestJson.getString("b_party")) == false) {
                requestJson.put("status", ServiceAuthentication.Incomplete_Msisdn);
return requestJson.toString();
            }

            PoolingHttpClientConnectionManager cm= new PoolingHttpClientConnectionManager();
            cm.setMaxTotal(200);
            cm.setDefaultMaxPerRoute(20);

            RequestConfig defaultRequestConfig= RequestConfig.custom()
                    .setSocketTimeout(Configuration.get("service.timeout.socket", 20000))
                    .setConnectTimeout(Configuration.get("service.timeout.connect", 20000))
                    .setConnectionRequestTimeout(Configuration.get("service.timeout.connectrequest", 20000)).build();

            JSONObject responseJson= new JSONObject();
            ContentBasedRetryStrategy retryStrategy= new ContentBasedRetryStrategy();
            httpClient= HttpClients.custom().setServiceUnavailableRetryStrategy(retryStrategy)
                    .setDefaultRequestConfig(defaultRequestConfig).setConnectionManager(cm).build();
       //*************************重要
            HttpGet request= new HttpGet(
                    Configuration.get("service.authentication.url", "") + requestJson.getString("b_party"));
            request.addHeader("Content-type", "application/json");
            request.addHeader("Accept", "application/json");

            UsernamePasswordCredentials creds = new UsernamePasswordCredentials(Configuration.get("service.username", ""),Configuration.get("service.password", ""));

            Header header = new BasicScheme(StandardCharsets.UTF_8).authenticate(creds , request, null);
            request.addHeader( header); 
            //************************************
            
    
this.logger.info(String.format(Configuration.get("service.authentication.url", "") + requestJson.getString("b_party")));
            
            Header [] headers= request.getAllHeaders();
for (int i = 0;i < headers.length; i++ ) {
                Header tmp= headers[i];
this.logger.info(String.format("Headers Name: %s Value:%s
", tmp.getName(), tmp.getValue()));
            }
            
            
//////////////////  temp
            
//            JSONObject subscriberProfileNode = new JSONObject();
//            
//            subscriberProfileNode.put("type", 8);
//            subscriberProfileNode.put("is_allowed", true);
//            requestJson.getJSONObject("function").put("subscriber_profile", subscriberProfileNode);
//            
//            requestJson.put("status", ServiceAuthentication.Success);
//            
//            JSONObject operatorProfileNode = new JSONObject();
//            operatorProfileNode.put("operator", "hkg.csl");
//            requestJson.getJSONObject("function").put("operator_profile", operatorProfileNode);
//            
//            return requestJson.toString();            
            
 //////////////////// end temp            
            
            httpResponse= httpClient.execute(request);

            responseJson= retryStrategy.getResponseObject();
this.logger.info(String.format("HTTP Response: %d, Body: %s", httpResponse.getStatusLine().getStatusCode(),
                    responseJson.toString()));

if (responseJson != null) {
if (responseJson.getJSONObject("status") != null                        && responseJson.getJSONObject("status").getInt("code") == 0) {

int subType = 99;

                    subType= responseJson.getJSONObject("profile").getInt("brand");

                    JSONObject subscriberProfileNode= new JSONObject();
                    subscriberProfileNode.put("type", subType);
                    subscriberProfileNode.put("is_allowed", subType == 8 ? true : false);

boolean bSaved = true;

if (bSaved) {
if (subType != 8) {
                            requestJson.put("status", ServiceAuthentication.Subscriber_Is_Postpaid);
                        }else {
                            requestJson.put("status", ServiceAuthentication.Success);
                        }
                    }

                    requestJson.getJSONObject("function").put("subscriber_profile", subscriberProfileNode);

                    JSONObject operatorProfileNode= new JSONObject();
                    operatorProfileNode.put("operator", "hk.csl");
                    requestJson.getJSONObject("function").put("operator_profile", operatorProfileNode);

                }else if (responseJson.getJSONObject("status") != null                        && responseJson.getJSONObject("status").getInt("code") == 1002) {
                    JSONObject operatorProfileNode= new JSONObject();
                    operatorProfileNode.put("operator", "hk.csl");
                    requestJson.getJSONObject("function").put("operator_profile", operatorProfileNode);

                    requestJson.put("status", ServiceAuthentication.Subscriber_Not_Found);
                }

return requestJson.toString();
            }            

        }catch (Exception e) {
            logger.error("Failed to complete ServiceAuthen request: " + e.getMessage(), e);
        }finally {
try {
                httpClient.close();
            }catch (Exception e) {
            }
        }

return getSubcriberInfoFromCache(requestJson, requestJson.getString("b_party"));
    }

private String getSubcriberInfoFromCache(JSONObject requestJson, String msisdn) {
return "";
    }
}

文章標(biāo)題:convertcurlcommandintojavaHttpGet-創(chuàng)新互聯(lián)
鏈接分享:http://chinadenli.net/article8/djjiop.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈網(wǎng)站設(shè)計公司、靜態(tài)網(wǎng)站搜索引擎優(yōu)化、網(wǎng)站改版、關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)
九九热精品视频免费观看| 久久精品国产第一区二区三区 | 国产欧美一区二区另类精品| 人妻内射精品一区二区| 午夜成年人黄片免费观看| 亚洲高清中文字幕一区二三区| 好东西一起分享老鸭窝| 中文字幕中文字幕在线十八区| 老司机精品视频在线免费看| 成年人视频日本大香蕉久久| 国产中文字幕一二三区| 日韩精品视频免费观看| 亚洲高清一区二区高清| 黄色激情视频中文字幕| 俄罗斯胖女人性生活视频| 国产一区二区三区精品免费| 色婷婷日本视频在线观看| 久久热在线免费视频精品| 91精品国产综合久久精品| 91精品国产综合久久精品| 中国日韩一级黄色大片| 日本人妻精品有码字幕| 国产精品久久精品毛片| 亚洲中文字幕三区四区| 国产又粗又猛又大爽又黄同志| 成人精品一区二区三区综合| 婷婷激情四射在线观看视频 | 国产精品第一香蕉视频| 亚洲日本加勒比在线播放| 男女午夜福利院在线观看| 亚洲国产综合久久天堂| 国产又爽又猛又粗又色对黄| 日韩免费午夜福利视频| 日本和亚洲的香蕉视频| 久久大香蕉精品在线观看| 成人精品网一区二区三区| 国产免费一区二区三区av大片| 黄色国产精品一区二区三区| 精品熟女少妇av免费久久野外| 成人午夜免费观看视频| 日本不卡在线视频你懂的|