本文整理汇总了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);
}