本文整理匯總了Java中net.ymate.framework.commons.ParamUtils類的典型用法代碼示例。如果您正苦於以下問題:Java ParamUtils類的具體用法?Java ParamUtils怎麽用?Java ParamUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ParamUtils類屬於net.ymate.framework.commons包,在下文中一共展示了ParamUtils類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: __doNativeStatic
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
@RequestMapping(value = "{app_id}/native/static", method = {Type.HttpMethod.GET, Type.HttpMethod.POST})
public IView __doNativeStatic(@PathVariable("app_id") String appId,
@VRequried @RequestParam String state,
@RequestParam String attach) throws Exception {
IWxPayEventHandler _eventHandler = WxPay.get().getModuleCfg().getEventHandler();
if (_eventHandler != null) {
WxPayAccountMeta _meta = WxPay.get().getModuleCfg().getAccountProvider().getAccount(appId);
if (_meta != null) {
Map<String, Object> _paramMap = new HashMap<String, Object>();
_paramMap.put(IWxPay.Const.APP_ID, _meta.getAppId());
_paramMap.put(IWxPay.Const.MCH_ID, _meta.getMchId());
_paramMap.put("time_stamp", DateTimeUtils.currentTimeUTC() + "");
_paramMap.put(IWxPay.Const.NONCE_STR, WxPayBaseData.__doCreateNonceStr());
_paramMap.put("product_id", state);
_paramMap.put("sign", WxPayBaseData.__doCreateSignature(_paramMap, _meta.getMchKey()));
//
String _qrCodeData = WebUtils.encryptStr(WebContext.getRequest(), "weixin://wxpay/bizpayurl?".concat(ParamUtils.buildQueryParamStr(_paramMap, false, null)));
return View.jspView(WxPay.get().getModuleCfg().getNativeView())
.addAttribute("_qrcode_data", _qrCodeData)
.addAttribute("_state", state)
.addAttribute("_attach", attach).addAttribute("_app_id", appId);
}
}
return HttpStatusView.bind(HttpServletResponse.SC_BAD_REQUEST);
}
示例2: __doSignCheck
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
private IView __doSignCheck(InterceptContext context) throws Exception {
String _accountId = WebContext.getRequest().getParameter(IAliPay.Const.APP_ID);
String _sign = WebContext.getRequest().getParameter(IAliPay.Const.SIGN);
//
if (StringUtils.isNotBlank(_accountId) && StringUtils.isNotBlank(_sign)) {
AliPayAccountMeta _meta = AliPay.get().getModuleCfg().getAccountProvider().getAccount(_accountId);
if (_meta != null) {
Map<String, Object> _params = new HashMap<String, Object>(WebContext.getContext().getParameters());
_params.remove(IAliPay.Const.SIGN_TYPE);
_params.remove(IAliPay.Const.SIGN);
//
String _paramsStr = ParamUtils.buildQueryParamStr(_params, false, _meta.getCharset());
if (SignatureUtils.verify(_paramsStr, _sign, _meta.getPublicKey(), _meta.getCharset(), _meta.getSignType())) {
return null;
} else if (_LOG.isDebugEnabled()) {
_LOG.debug("Signature verification failed: " + _paramsStr);
}
}
}
return HttpStatusView.METHOD_NOT_ALLOWED;
}
示例3: toString
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
@Override
public String toString() {
Map<String, String> _params = new HashMap<String, String>();
_params.put("posttime", postTime);
_params.put("mobile", mobile);
_params.put("deviceid", deviceId);
_params.put("clientversion", clientVersion);
//
try {
return URLEncoder.encode(ParamUtils.buildQueryParamStr(_params, false, null), "UTF-8");
} catch (UnsupportedEncodingException e) {
_LOG.warn("", e);
}
return null;
}
示例4: executeActionForm
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
public String executeActionForm() {
// 此處在網關URL地址中添加字符集配置參數,主要為解決中文亂碼問題
if (!StringUtils.containsIgnoreCase(this.gatewayUrl, "charset=")) {
Map<String, String> _params = new HashMap<String, String>();
_params.put(IAliPay.Const.CHARSET, charset);
//
this.gatewayUrl = ParamUtils.appendQueryParamValue(this.gatewayUrl, _params, false, null);
}
return ParamUtils.buildActionForm(this.gatewayUrl, true, false, true, charset, requestParameters);
}
示例5: __toConnect
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
/**
* @param connectName 連接器名稱
* @param state 自定義狀態值(用於防CSRF攻擊)
* @return 跳轉至獲取第三方授權碼的URL地址
* @throws Exception 可能產生的任何異常
*/
@RequestMapping("/{connectName}")
public IView __toConnect(@PathVariable String connectName, @RequestParam String state) throws Exception {
IOAuthConnectProcessor _processor = OAuthConnector.get().getConnectProcessor(connectName);
if (_processor != null) {
state = StringUtils.defaultIfBlank(state, ParamUtils.createNonceStr());
IView _view = OAuthConnector.get().getModuleCfg().getConnectCallbackHandler().connect(connectName, state);
//
if (_view == null) {
return View.redirectView(_processor.getAuthorizeUrl(state));
}
return _view;
}
return View.httpStatusView(HttpServletResponse.SC_BAD_REQUEST);
}
示例6: getRedirectUri
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
public String getRedirectUri() {
if (StringUtils.isBlank(redirectUri)) {
redirectUri = WebUtils.buildURL(WebContext.getRequest(), "/oauth2/connect/" + name + "/redirect", true);
}
String _redirectUrl = WebContext.getRequest().getParameter(Optional.REDIRECT_URL);
if (StringUtils.isNotBlank(_redirectUrl)) {
Map<String, String> _params = new HashMap<String, String>();
_params.put(Optional.REDIRECT_URL, _redirectUrl);
return ParamUtils.appendQueryParamValue(redirectUri, _params, true, "UTF-8");
}
return redirectUri;
}
示例7: __doBuildAuthzUrl
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
protected String __doBuildAuthzUrl(String scope, String state, boolean code) {
Map<String, String> _params = new HashMap<String, String>();
_params.put(__clientParamName, __initCfg.getClientId());
_params.put("redirect_uri", __initCfg.getRedirectUri());
if (code) {
_params.put("response_type", "code");
}
if (StringUtils.isNotBlank(scope)) {
_params.put("scope", scope);
}
if (StringUtils.isNotBlank(state)) {
_params.put("state", state);
}
return ParamUtils.buildQueryParamStr(_params, true, "UTF-8");
}
開發者ID:suninformation,項目名稱:ymate-module-oauth-connector,代碼行數:16,代碼來源:AbstractOAuthConnectProcessor.java
示例8: __doAuthorize
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
/**
* @param tokenId 令牌唯一標識
* @param uid 用戶唯一標識
* @param remoteAddr 用戶IP地址
* @param sign 參數簽名
* @return 驗證客戶端令牌有效性及狀態
* @throws Exception 可能產生的任何異常
*/
@RequestMapping(value = "/authorize", method = Type.HttpMethod.POST)
public IView __doAuthorize(@VRequired @RequestParam("token_id") String tokenId,
@VRequired @RequestParam String uid,
@VRequired @RequestParam("remote_addr") String remoteAddr,
@VRequired @RequestParam String sign) throws Exception {
if (SSO.get().getModuleCfg().isClientMode()) {
return HttpStatusView.METHOD_NOT_ALLOWED;
}
//
Map<String, String> _params = new HashMap<String, String>();
_params.put("token_id", tokenId);
_params.put("uid", uid);
_params.put("remote_addr", remoteAddr);
//
String _sign = ParamUtils.createSignature(_params, false, SSO.get().getModuleCfg().getServiceAuthKey());
if (StringUtils.equals(sign, _sign)) {
ISSOTokenStorageAdapter _storageAdapter = SSO.get().getModuleCfg().getTokenStorageAdapter();
// 嘗試從存儲中加載原始令牌數據並進行有效性驗證
ISSOToken _token = _storageAdapter.load(uid, tokenId);
if (_token != null) {
boolean _ipCheck = (SSO.get().getModuleCfg().isIpCheckEnabled() && !StringUtils.equals(remoteAddr, _token.getRemoteAddr()));
if (_token.timeout() || !_token.verified() || _ipCheck) {
_storageAdapter.remove(_token.getUid(), _token.getId());
return WebResult.CODE(ErrorCode.USER_SESSION_INVALID_OR_TIMEOUT).toJSON();
} else {
WebResult _result = WebResult.SUCCESS();
// 嘗試加載令牌自定義屬性
ISSOTokenAttributeAdapter _attributeAdapter = SSO.get().getModuleCfg().getTokenAttributeAdapter();
if (_attributeAdapter != null) {
_attributeAdapter.loadAttributes(_token);
if (!_token.getAttributes().isEmpty()) {
_result.data(_token.getAttributes());
}
}
return _result.toJSON();
}
}
}
return WebResult.CODE(ErrorCode.INVALID_PARAMS_VALIDATION).toJSON();
}
示例9: __doValidateToken
import net.ymate.framework.commons.ParamUtils; //導入依賴的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;
}
示例10: __doCreateSignature
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
/**
* @param paramMap 請求協議參數對象映射
* @param mchKey 商戶密鑰
* @return 返回最終生成的簽名
*/
public static String __doCreateSignature(Map<String, Object> paramMap, String mchKey) {
String _queryParamStr = ParamUtils.buildQueryParamStr(paramMap, false, null);
_queryParamStr += "&key=" + mchKey;
return DigestUtils.md5Hex(_queryParamStr).toUpperCase();
}
示例11: sign
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
/**
* @param params 待簽名參數映射
* @param privateKey 私鑰
* @param charset 字符編碼
* @param signType 簽名類型
* @return 簽名字符串
* @throws Exception 可能產生的異常
*/
public static String sign(Map<String, String> params, String privateKey, String charset, IAliPay.SignType signType) throws Exception {
String _content = ParamUtils.buildQueryParamStr(params, false, charset);
return sign(_content, privateKey, charset, signType);
}
示例12: verify
import net.ymate.framework.commons.ParamUtils; //導入依賴的package包/類
/**
* @param params 待簽名參數映射
* @param sign 簽名字符串
* @param publicKey 公鑰
* @param charset 字符編碼
* @param signType 簽名類型
* @return 簽名是否匹配
* @throws Exception 可能產生的異常
*/
public static boolean verify(Map<String, String> params, String sign, String publicKey, String charset, IAliPay.SignType signType) throws Exception {
String _content = ParamUtils.buildQueryParamStr(params, false, charset);
return verify(_content, sign, publicKey, charset, signType);
}