Java Code Examples for com.alipay.api.internal.util.WebUtils#buildQuery()
The following examples show how to use
com.alipay.api.internal.util.WebUtils#buildQuery() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractAlipayClient.java From alipay-sdk-java-all with Apache License 2.0 | 6 votes |
/** * 获取POST请求的base url * * @param requestHolder * @return * @throws AlipayApiException */ private String getRequestUrl(RequestParametersHolder requestHolder) throws AlipayApiException { StringBuilder urlSb = new StringBuilder(serverUrl); try { String sysMustQuery = WebUtils.buildQuery(loadTest ? LoadTestUtil.getParamsWithLoadTestFlag(requestHolder.getProtocalMustParams()) : requestHolder.getProtocalMustParams(), charset); String sysOptQuery = WebUtils.buildQuery(requestHolder.getProtocalOptParams(), charset); urlSb.append("?"); urlSb.append(sysMustQuery); if (sysOptQuery != null && sysOptQuery.length() > 0) { urlSb.append("&"); urlSb.append(sysOptQuery); } } catch (IOException e) { throw new AlipayApiException(e); } return urlSb.toString(); }
Example 2
Source File: DefaultAlipayClient.java From alipay-sdk with Apache License 2.0 | 6 votes |
/** * 获取POST请求的base url * * @param requestHolder * @return * @throws AlipayApiException */ private String getRequestUrl(RequestParametersHolder requestHolder) throws AlipayApiException { StringBuffer urlSb = new StringBuffer(serverUrl); try { String sysMustQuery = WebUtils.buildQuery(requestHolder.getProtocalMustParams(), charset); String sysOptQuery = WebUtils.buildQuery(requestHolder.getProtocalOptParams(), charset); urlSb.append("?"); urlSb.append(sysMustQuery); if (sysOptQuery != null & sysOptQuery.length() > 0) { urlSb.append("&"); urlSb.append(sysOptQuery); } } catch (IOException e) { throw new AlipayApiException(e); } return urlSb.toString(); }
Example 3
Source File: DefaultAlipayClient.java From pay with Apache License 2.0 | 6 votes |
/** * 获取POST请求的base url * * @param requestHolder * @return * @throws AlipayApiException */ private String getRequestUrl(RequestParametersHolder requestHolder) throws AlipayApiException { StringBuffer urlSb = new StringBuffer(serverUrl); try { String sysMustQuery = WebUtils.buildQuery(requestHolder.getProtocalMustParams(), charset); String sysOptQuery = WebUtils.buildQuery(requestHolder.getProtocalOptParams(), charset); urlSb.append("?"); urlSb.append(sysMustQuery); if (sysOptQuery != null & sysOptQuery.length() > 0) { urlSb.append("&"); urlSb.append(sysOptQuery); } } catch (IOException e) { throw new AlipayApiException(e); } return urlSb.toString(); }
Example 4
Source File: DefaultAlipayClient.java From pay with Apache License 2.0 | 6 votes |
/** * GET模式下获取跳转链接 * * @param requestHolder * @return * @throws AlipayApiException */ private String getRedirectUrl(RequestParametersHolder requestHolder) throws AlipayApiException { StringBuffer urlSb = new StringBuffer(serverUrl); try { Map<String, String> sortedMap = AlipaySignature.getSortedMap(requestHolder); String sortedQuery = WebUtils.buildQuery(sortedMap, charset); String sign = requestHolder.getProtocalMustParams().get(AlipayConstants.SIGN); urlSb.append("?"); urlSb.append(sortedQuery); if (sign != null & sign.length() > 0) { Map<String, String> signMap = new HashMap<String, String>(); signMap.put(AlipayConstants.SIGN, sign); String signQuery = WebUtils.buildQuery(signMap, charset); urlSb.append("&"); urlSb.append(signQuery); } } catch (IOException e) { throw new AlipayApiException(e); } return urlSb.toString(); }
Example 5
Source File: AbstractAlipayClient.java From alipay-sdk-java-all with Apache License 2.0 | 5 votes |
/** * GET模式下获取跳转链接 * * @param requestHolder * @return * @throws AlipayApiException */ private String getRedirectUrl(RequestParametersHolder requestHolder) throws AlipayApiException { StringBuilder urlSb = new StringBuilder(serverUrl); try { Map<String, String> sortedMap = AlipaySignature.getSortedMap(requestHolder); String sortedQuery = WebUtils.buildQuery(loadTest ? LoadTestUtil.getParamsWithLoadTestFlag(sortedMap) : sortedMap, charset); urlSb.append("?"); urlSb.append(sortedQuery); } catch (IOException e) { throw new AlipayApiException(e); } return urlSb.toString(); }
Example 6
Source File: AbstractAlipayClient.java From alipay-sdk-java-all with Apache License 2.0 | 5 votes |
/** * 拼装sdk调用时所传参数 * * @param requestHolder * @return * @throws AlipayApiException */ private String getSdkParams(RequestParametersHolder requestHolder) throws AlipayApiException { StringBuilder urlSb = new StringBuilder(); try { Map<String, String> sortedMap = AlipaySignature.getSortedMap(requestHolder); String sortedQuery = WebUtils.buildQuery(loadTest ? LoadTestUtil.getParamsWithLoadTestFlag(sortedMap) : sortedMap, charset); urlSb.append(sortedQuery); } catch (IOException e) { throw new AlipayApiException(e); } return urlSb.toString(); }
Example 7
Source File: DefaultAlipayClient.java From alipay-sdk with Apache License 2.0 | 5 votes |
/** * GET模式下获取跳转链接 * * @param requestHolder * @return * @throws AlipayApiException */ private String getRedirectUrl(RequestParametersHolder requestHolder) throws AlipayApiException { StringBuffer urlSb = new StringBuffer(serverUrl); try { Map<String, String> sortedMap = AlipaySignature.getSortedMap(requestHolder); String sortedQuery = WebUtils.buildQuery(sortedMap, charset); urlSb.append("?"); urlSb.append(sortedQuery); } catch (IOException e) { throw new AlipayApiException(e); } return urlSb.toString(); }
Example 8
Source File: DefaultAlipayClient.java From alipay-sdk with Apache License 2.0 | 5 votes |
/** * 拼装sdk调用时所传参数 * * @param requestHolder * @return * @throws AlipayApiException */ private String getSdkParams(RequestParametersHolder requestHolder) throws AlipayApiException { StringBuffer urlSb = new StringBuffer(); try { Map<String, String> sortedMap = AlipaySignature.getSortedMap(requestHolder); String sortedQuery = WebUtils.buildQuery(sortedMap, charset); urlSb.append(sortedQuery); } catch (IOException e) { throw new AlipayApiException(e); } return urlSb.toString(); }
Example 9
Source File: DefaultAlipayClient.java From pay with Apache License 2.0 | 5 votes |
/** * 拼装sdk调用时所传参数 * * @param requestHolder * @return * @throws AlipayApiException */ private String getSdkParams(RequestParametersHolder requestHolder) throws AlipayApiException { StringBuffer urlSb = new StringBuffer(); try { Map<String, String> sortedMap = AlipaySignature.getSortedMap(requestHolder); String sortedQuery = WebUtils.buildQuery(sortedMap, charset); urlSb.append(sortedQuery); } catch (IOException e) { throw new AlipayApiException(e); } return urlSb.toString(); }
Example 10
Source File: AlipayMsgClient.java From alipay-sdk-java-all with Apache License 2.0 | 4 votes |
private void doConnect() throws Exception { if (isConnected()) { return; } synchronized (this) { if (isConnected()) { return; } RegisterResponse regResp = register(); Map<String, String> httpHeaders = new HashMap<String, String>(1); if (regResp.getZone() != null && regResp.getZone().length() > 0) { httpHeaders.put("cookie", "zone=" + regResp.getZone() + ";"); } if (loadTest) { httpHeaders.put("LoadTest", "true"); } httpHeaders.put("Content-Type", "application/x-www-form-urlencoded;charset=" + charset); Map<String, String> params = new HashMap<String, String>(5); params.put("app_id", appId); params.put("charset", charset); params.put("link_token", regResp.getLinkToken()); params.put("timestamp", String.valueOf(System.currentTimeMillis())); params.put("sign_type", signType); params.put("sdk_version", AlipayConstants.SDK_VERSION); String signContent = AlipaySignature.getSignCheckContentV2(params); String sign = AlipaySignature.rsaSign(signContent, appPrivateKey, charset, signType); params.put("sign", sign); String query = WebUtils.buildQuery(params, charset); String urlStr = "ws" + (isSSL ? "s" : "") + "://" + serverHost + "/websocket?" + query; webSocketConnector = new MsgConnector(new URI(urlStr), httpHeaders, this, charset); if (!webSocketConnector.connectBlocking(10L, TimeUnit.SECONDS)) { throw new RuntimeException("connect timeout(10s)!"); } if (AlipayLogger.isBizDebugEnabled()) { AlipayLogger.logBizDebug("connected"); } } }
Example 11
Source File: AlipayMsgClient.java From alipay-sdk-java-all with Apache License 2.0 | 4 votes |
private RegisterResponse register() throws Exception { Map<String, String> params = new HashMap<String, String>(4); params.put("timestamp", String.valueOf(System.currentTimeMillis())); params.put("sign_type", signType); params.put("app_id", appId); params.put("charset", charset); params.put("sdk_version", AlipayConstants.SDK_VERSION); params.put("nonce", UUID.randomUUID().toString().replace("-", "")); String signContent = AlipaySignature.getSignCheckContentV2(params); String sign = AlipaySignature.rsaSign(signContent, appPrivateKey, charset, signType); params.put("sign", sign); String query = WebUtils.buildQuery(params, charset); String urlStr = "http" + (isSSL ? "s" : "") + "://" + serverHost + "/websocket/register.do?" + query; URL url = new URL(urlStr); HttpURLConnection conn = null; InputStream stream = null; String rsp = null; try { conn = WebUtils.getConnection(url, "GET", "application/x-www-form-urlencoded;charset=" + charset); if (loadTest) { conn.setRequestProperty("LoadTest", "true"); } InputStream es = conn.getErrorStream(); stream = es == null ? conn.getInputStream() : es; BufferedReader reader = new BufferedReader(new InputStreamReader(stream, charset)); StringWriter writer = new StringWriter(); char[] chars = new char[256]; int count = 0; while ((count = reader.read(chars)) > 0) { writer.write(chars, 0, count); } rsp = writer.toString(); } finally { if (stream != null) { stream.close(); } if (conn != null) { conn.disconnect(); } } RegisterResponse res = new RegisterResponse(); res.setLinkToken(parseRegResp(rsp)); res.setZone(parseRegRespHeader(conn.getHeaderFields())); return res; }