當前位置: 首頁>>代碼示例>>Java>>正文


Java IHttpResponse類代碼示例

本文整理匯總了Java中net.ymate.framework.commons.IHttpResponse的典型用法代碼示例。如果您正苦於以下問題:Java IHttpResponse類的具體用法?Java IHttpResponse怎麽用?Java IHttpResponse使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IHttpResponse類屬於net.ymate.framework.commons包,在下文中一共展示了IHttpResponse類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
/**
 * @return 提交請求並返回回應結果
 * @throws Exception 可能產生的任何異常
 */
public RESPONSE execute() throws Exception {
    Map<String, Object> _params = buildSignatureParams();
    _params.put(IWxPay.Const.SIGN, __doCreateSignature(_params, __accountMeta.getMchKey()));
    // 處理沙箱URL地址
    String _requestURL = __doGetRequestURL();
    if (!StringUtils.startsWithIgnoreCase(_requestURL, "http")) {
        _requestURL = "https://api.mch.weixin.qq.com/" + __accountMeta.getSandboxPrefix() + _requestURL;
    }
    IHttpResponse _response = HttpClientHelper.create()
            .customSSL(__accountMeta.getConnectionSocketFactory())
            .post(_requestURL, __doBuildXML(_params));
    if (_response != null) {
        if (_response.getStatusCode() == 200) {
            return __doParseResponse(_response);
        } else if (_LOG.isDebugEnabled()) {
            _LOG.debug("ResponseBody: " + _response.toString());
        }
    }
    return null;
}
 
開發者ID:suninformation,項目名稱:ymate-payment-v2,代碼行數:25,代碼來源:WxPayBaseRequest.java

示例2: getConnectUser

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
@Override
public OAuthConnectUser getConnectUser(String code) throws Exception {
    OAuthConnectUser _connectUser = __doGetAccessToken(code, __TOKEN_URL, true);
    if (_connectUser != null) {
        if (StringUtils.isNotBlank(_connectUser.getAccessToken())) {
            IHttpResponse _response = HttpClientHelper.create().get(__USERINFO_URL.concat(_connectUser.getAccessToken()), __doGetRequestHeaders());
            JSONObject _result = __doParseConnectResponseBody(_response);
            if (_result != null) {
                _connectUser.setOpenId(_result.getString("id"))
                        .setNickName(_result.getString("login"))
                        .setPhotoUrl(_result.getString("avatar_url"));
            }
        }
    }
    return _connectUser;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:17,代碼來源:GitOSCConnectProcessor.java

示例3: getConnectUser

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
@Override
public OAuthConnectUser getConnectUser(String code) throws Exception {
    OAuthConnectUser _connectUser = __doGetAccessToken(code, __TOKEN_URL);
    if (_connectUser != null) {
        if (StringUtils.isNotBlank(_connectUser.getAccessToken())) {
            IHttpResponse _response = HttpClientHelper.create().get(__USERINFO_URL.concat(_connectUser.getAccessToken()), __doGetRequestHeaders());
            JSONObject _result = __doParseConnectResponseBody(_response);
            if (_result != null) {
                _connectUser.setOpenId(_result.getString("id"))
                        .setNickName(_result.getString("login"))
                        .setPhotoUrl(_result.getString("avatar_url"));
            }
        }
    }
    return _connectUser;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:17,代碼來源:GitHubConnectProcessor.java

示例4: getConnectUser

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
@Override
public OAuthConnectUser getConnectUser(String code) throws Exception {
    OAuthConnectUser _connectUser = __doGetAccessToken(code, __TOKEN_URL);
    if (_connectUser != null) {
        if (StringUtils.isNotBlank(_connectUser.getAccessToken())) {
            IHttpResponse _response = HttpClientHelper.create().get(__USERINFO_URL.concat(_connectUser.getAccessToken()), __doGetRequestHeaders());
            JSONObject _result = __doParseConnectResponseBody(_response);
            if (_result != null) {
                _connectUser.setOpenId(_result.getString("id"))
                        .setNickName(_result.getString("name"))
                        .setPhotoUrl(_result.getString("avatar"));
                String _gender = _result.getString("gender");
                if (StringUtils.isNotBlank(_gender)) {
                    _connectUser.setGender(OAuthConnectUser.Gender.valueOf(_gender.toUpperCase()));
                } else {
                    _connectUser.setGender(OAuthConnectUser.Gender.UNKNOW);
                }
            }
        }
    }
    return _connectUser;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:23,代碼來源:OSChinaConnectProcessor.java

示例5: getConnectUser

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
@Override
public OAuthConnectUser getConnectUser(String code) throws Exception {
    OAuthConnectUser _connectUser = __doGetAccessToken(code, __TOKEN_URL);
    if (_connectUser != null) {
        if (StringUtils.isNotBlank(_connectUser.getAccessToken())) {
            IHttpResponse _response = HttpClientHelper.create().get(__USERINFO_URL.concat(_connectUser.getAccessToken()), __doGetRequestHeaders());
            JSONObject _result = __doParseConnectResponseBody(_response);
            if (_result != null) {
                _connectUser.setOpenId(_result.getString("uid"))
                        .setNickName(_result.getString("uname"))
                        .setPhotoUrl(_result.getString("portrait"));
                String _photoUrl = _result.getString("portrait");
                if (StringUtils.isNotBlank(_photoUrl)) {
                    _connectUser.setPhotoUrl("http://tb.himg.baidu.com/sys/portrait/item/" + _photoUrl);
                }
                _connectUser.setGender(OAuthConnectUser.Gender.UNKNOW);
            }
        }
    }
    return _connectUser;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:22,代碼來源:BaiduConnectProcessor.java

示例6: __doParseResponse

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
protected Response __doParseResponse(IHttpResponse httpResponse) {
    try {
        XPathHelper _xpath = new XPathHelper(httpResponse.getContent());
        return new Response(null, _xpath.getStringValue("//return_code"), _xpath.getStringValue("//return_msg"));
    } catch (Exception e) {
        // Nothing..
    }
    return new Response(httpResponse.getContent(), "SUCCESS", null);
}
 
開發者ID:suninformation,項目名稱:ymate-payment-v2,代碼行數:10,代碼來源:WxPayDownloadBill.java

示例7: execute

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
public RESPONSE execute() throws Exception {
    IHttpResponse _response = HttpClientHelper.create().post(this.gatewayUrl, this.requestParameters);
    if (_response != null) {
        if (_response.getStatusCode() == 200) {
            return this.responseParser.parserResponse(_response.getContent());
        } else if (_LOG.isDebugEnabled()) {
            _LOG.debug("ResponseBody: " + _response.toString());
        }
    }
    return null;
}
 
開發者ID:suninformation,項目名稱:ymate-payment-v2,代碼行數:12,代碼來源:DefaultAliPayRequestSender.java

示例8: getConnectUser

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
@Override
public OAuthConnectUser getConnectUser(String code) throws Exception {
    OAuthConnectUser _connectUser = __doGetAccessToken(code, __TOKEN_URL);
    if (_connectUser != null) {
        if (StringUtils.isNotBlank(_connectUser.getAccessToken()) && StringUtils.isNotBlank(_connectUser.getOpenId())) {
            Map<String, String> _params = new HashMap<String, String>();
            _params.put("access_token", _connectUser.getAccessToken());
            _params.put("openid", _connectUser.getOpenId());
            //
            IHttpResponse _response = HttpClientHelper.create().get(__USERINFO_URL, _params);
            JSONObject _result = __doParseConnectResponseBody(_response);
            if (_result != null) {
                _connectUser.setNickName(_result.getString("nickname"))
                        .setPhotoUrl(_result.getString("headimgurl"))
                        .setUnionId(_result.getString("unionid"));
                switch (_result.getIntValue("sex")) {
                    case 1:
                        _connectUser.setGender(OAuthConnectUser.Gender.MALE);
                        break;
                    case 2:
                        _connectUser.setGender(OAuthConnectUser.Gender.FEMALE);
                        break;
                    default:
                        _connectUser.setGender(OAuthConnectUser.Gender.UNKNOW);
                }
                //
                _connectUser.putAttribute("country", _result.getString("country"));
                _connectUser.putAttribute("province", _result.getString("province"));
                _connectUser.putAttribute("city", _result.getString("city"));
            }
        }
    }
    return _connectUser;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:35,代碼來源:WeChatConnectProcessor.java

示例9: __doGetAccessToken

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
@Override
protected OAuthConnectUser __doGetAccessToken(String code, String tokenUrl) throws Exception {
    OAuthConnectUser _connectUser = super.__doGetAccessToken(code, tokenUrl);
    if (_connectUser != null) {
        IHttpResponse _response = HttpClientHelper.create().get(__OPEN_ID_URL.concat(_connectUser.getAccessToken()), __doGetRequestHeaders());
        JSONObject _result = __doParseConnectResponseBody(_response);
        if (_result != null) {
            _connectUser.setOpenId(_result.getString("openid"));
        }
    }
    return _connectUser;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:13,代碼來源:QQConnectProcessor.java

示例10: getConnectUser

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
@Override
public OAuthConnectUser getConnectUser(String code) throws Exception {
    OAuthConnectUser _connectUser = __doGetAccessToken(code, __TOKEN_URL);
    if (_connectUser != null) {
        if (StringUtils.isNotBlank(_connectUser.getAccessToken()) && StringUtils.isNotBlank(_connectUser.getOpenId())) {
            Map<String, String> _params = new HashMap<String, String>();
            _params.put("access_token", _connectUser.getAccessToken());
            _params.put("oauth_consumer_key", __initCfg.getClientId());
            _params.put("openid", _connectUser.getOpenId());
            //
            IHttpResponse _response = HttpClientHelper.create().get(__USERINFO_URL, _params);
            JSONObject _result = super.__doParseConnectResponseBody(_response);
            if (_result != null) {
                int _ret = _result.getIntValue("ret");
                if (_ret == 0) {
                    _connectUser.setNickName(_result.getString("nickname"))
                            .setPhotoUrl(_result.getString("figureurl_qq_2"));
                    if (StringUtils.isBlank(_connectUser.getPhotoUrl())) {
                        _connectUser.setPhotoUrl(_result.getString("figureurl_qq_1"));
                    }
                    String _gender = _result.getString("gender");
                    if (StringUtils.equals(_gender, "女")) {
                        _connectUser.setGender(OAuthConnectUser.Gender.FEMALE);
                    } else if (StringUtils.equals(_gender, "男")) {
                        _connectUser.setGender(OAuthConnectUser.Gender.MALE);
                    } else {
                        _connectUser.setGender(OAuthConnectUser.Gender.UNKNOW);
                    }
                } else {
                    throw new RuntimeException(_result.toJSONString());
                }
            }
        }
    }
    return _connectUser;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:37,代碼來源:QQConnectProcessor.java

示例11: getConnectUser

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
@Override
public OAuthConnectUser getConnectUser(String code) throws Exception {
    OAuthConnectUser _connectUser = __doGetAccessToken(code, __TOKEN_URL, true);
    if (_connectUser != null) {
        if (StringUtils.isNotBlank(_connectUser.getAccessToken())) {
            Map<String, String> _params = new HashMap<String, String>();
            _params.put("access_token", _connectUser.getAccessToken());
            _params.put("uid", _connectUser.getOpenId());
            //
            IHttpResponse _response = HttpClientHelper.create().get(__USERINFO_URL, _params, __doGetRequestHeaders());
            JSONObject _result = __doParseConnectResponseBody(_response);
            if (_result != null) {
                _connectUser.setNickName(_result.getString("screen_name"))
                        .setPhotoUrl(_result.getString("avatar_large"));
                String _gender = _result.getString("gender");
                if (StringUtils.equals(_gender, "f")) {
                    _connectUser.setGender(OAuthConnectUser.Gender.FEMALE);
                } else if (StringUtils.equals(_gender, "m")) {
                    _connectUser.setGender(OAuthConnectUser.Gender.MALE);
                } else {
                    _connectUser.setGender(OAuthConnectUser.Gender.UNKNOW);
                }
                //
                _connectUser.putAttribute("province", _result.getString("province"));
                _connectUser.putAttribute("city", _result.getString("city"));
                //
                return _connectUser;
            }
        }
    }
    return null;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:33,代碼來源:WeiboConnectProcessor.java

示例12: __doGetAccessToken

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
protected OAuthConnectUser __doGetAccessToken(String code, String tokenUrl, boolean usePost) throws Exception {
    Map<String, String> _params = new HashMap<String, String>();
    _params.put(__clientParamName, __initCfg.getClientId());
    _params.put(__secretParamName, __initCfg.getClientSecret());
    if (__needRedirectUri) {
        _params.put("redirect_uri", __initCfg.getRedirectUri());
    }
    _params.put("code", code);
    _params.put("grant_type", "authorization_code");
    //
    IHttpResponse _response = null;
    if (usePost) {
        _response = HttpClientHelper.create().post(tokenUrl, _params, __doGetRequestHeaders());
    } else {
        _response = HttpClientHelper.create().get(tokenUrl, _params, __doGetRequestHeaders());
    }
    JSONObject _result = __doParseConnectResponseBody(_response);
    if (_result != null) {
        return new OAuthConnectUser()
                .setAccessToken(_result.getString("access_token"))
                .setRefreshToken(_result.getString("refresh_token"))
                .setExpiresIn(_result.getIntValue("expires_in"))
                .setOpenId(StringUtils.isBlank(__openIdParamName) ? null : _result.getString(__openIdParamName))
                .setScope(_result.getString("scope"));
    }
    return null;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:28,代碼來源:AbstractOAuthConnectProcessor.java

示例13: __doParseConnectResponseBody

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
/**
 * @param response 回應對象
 * @return 解析請求回應結果,存在異常信息則直接拋出異常
 * @throws Exception 可能產生的任何異常
 */
protected JSONObject __doParseConnectResponseBody(IHttpResponse response) throws Exception {
    if (response != null) {
        if (response.getStatusCode() == 200) {
            JSONObject _result = JSON.parseObject(response.getContent());
            if (_result.containsKey(__errorFlag)) {
                throw new RuntimeException(_result.toJSONString());
            }
            return _result;
        } else if (_LOG.isDebugEnabled()) {
            _LOG.debug("ResponseBody: " + response.toString());
        }
    }
    return null;
}
 
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:20,代碼來源:AbstractOAuthConnectProcessor.java

示例14: __doValidateToken

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
private boolean __doValidateToken(ISSOToken token) {
    try {
        if (SSO.get().getModuleCfg().isClientMode()) {
            Map<String, String> _params = new HashMap<String, String>();
            _params.put("token_id", token.getId());
            _params.put("uid", token.getUid());
            _params.put("remote_addr", token.getRemoteAddr());
            _params.put("sign", ParamUtils.createSignature(_params, false, SSO.get().getModuleCfg().getServiceAuthKey()));
            IHttpResponse _result = HttpClientHelper.create().post(SSO.get().getModuleCfg().getServiceBaseUrl().concat("sso/authorize"), _params, new Header[]{new BasicHeader("User-Agent", WebContext.getRequest().getHeader("User-Agent"))});
            if (_result != null && _result.getStatusCode() == 200) {
                JSONObject _resultObj = JSON.parseObject(_result.getContent());
                if (_resultObj.getIntValue("ret") == ErrorCode.SUCCESSED) {
                    // 令牌驗證通過,則進行本地Cookie存儲
                    SSO.get().getModuleCfg().getTokenAdapter().setToken(token);
                    // 嘗試從響應報文中提取並追加token屬性數據
                    JSONObject _dataObj = _resultObj.getJSONObject("data");
                    if (_dataObj != null && !_dataObj.isEmpty()) {
                        for (Map.Entry<String, Object> _attr : _dataObj.entrySet()) {
                            token.getAttributes().put(_attr.getKey(), BlurObject.bind(_attr.getValue()).toStringValue());
                        }
                    }
                    //
                    return true;
                }
            }
        } else {
            ISSOTokenStorageAdapter _storageAdapter = SSO.get().getModuleCfg().getTokenStorageAdapter();
            // 嘗試從存儲中加載原始令牌數據並進行有效性驗證
            ISSOToken _originalToken = _storageAdapter.load(token.getUid(), token.getId());
            if (_originalToken != null) {
                boolean _ipCheck = (SSO.get().getModuleCfg().isIpCheckEnabled() && !StringUtils.equals(token.getRemoteAddr(), _originalToken.getRemoteAddr()));
                if (_originalToken.timeout() || !_originalToken.verified() || _ipCheck) {
                    _storageAdapter.remove(_originalToken.getUid(), _originalToken.getId());
                } else {
                    // 嘗試加載令牌自定義屬性
                    ISSOTokenAttributeAdapter _attributeAdapter = SSO.get().getModuleCfg().getTokenAttributeAdapter();
                    if (_attributeAdapter != null) {
                        _attributeAdapter.loadAttributes(token);
                    }
                    return true;
                }
            }
        }
    } catch (Exception e) {
        _LOG.warn("An exception occurred while validate token '" + token.getId() + "' for user '" + token.getUid() + "'", RuntimeUtils.unwrapThrow(e));
    }
    return false;
}
 
開發者ID:suninformation,項目名稱:ymate-module-sso,代碼行數:49,代碼來源:SSOUserSessionHandler.java

示例15: __doParseResponse

import net.ymate.framework.commons.IHttpResponse; //導入依賴的package包/類
protected Response __doParseResponse(IHttpResponse httpResponse) throws Exception {
    return new Response(httpResponse.getContent());
}
 
開發者ID:suninformation,項目名稱:ymate-payment-v2,代碼行數:4,代碼來源:WxPayReverse.java


注:本文中的net.ymate.framework.commons.IHttpResponse類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。