本文整理汇总了Java中net.ymate.platform.webmvc.view.impl.HttpStatusView类的典型用法代码示例。如果您正苦于以下问题:Java HttpStatusView类的具体用法?Java HttpStatusView怎么用?Java HttpStatusView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpStatusView类属于net.ymate.platform.webmvc.view.impl包,在下文中一共展示了HttpStatusView类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: userinfo
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的package包/类
/**
* @param accountToken 网页授权接口调用凭证
* @param openId 用户的唯一标识
* @return 返回用户信息 (OAuth2授权需scope=snsapi_userinfo)
* @throws Exception 可能产生的任何异常
*/
@RequestMapping("/userinfo")
@Before(SnsAccessTokenCheckInterceptor.class)
@ContextParam(@ParamItem(key = IOAuth.Const.SCOPE, value = IOAuth.Scope.SNSAPI_USERINFO))
public IView userinfo(@RequestParam(IOAuth.Const.ACCESS_TOKEN) String accountToken, @RequestParam(IOAuth.Const.OPEN_ID) String openId) throws Exception {
OAuthResponse _response = null;
try {
if (StringUtils.isBlank(openId)) {
_response = OAuthResponseUtils.badRequest(IOAuth.Const.INVALID_USER);
}
IOAuthUserInfoAdapter _adapter = OAuth.get().getModuleCfg().getUserInfoAdapter();
if (_adapter != null) {
return View.jsonView(_adapter.getUserInfo(OAuth.get().resourceHelper(accountToken, openId).getOAuthClientUser().getUid()));
}
_response = OAuthResponseUtils.unauthorizedClient(OAuthError.ResourceResponse.INVALID_REQUEST);
} catch (Exception e) {
_response = OAuthResponseUtils.badRequest(IOAuth.Const.INVALID_USER);
}
return new HttpStatusView(_response.getResponseStatus(), false).writeBody(_response.getBody());
}
示例2: __doJsApi
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的package包/类
/**
* @param appId 微信公众号应用ID
* @param openId 微信用户身份唯一标识
* @param state 商品或订单ID
* @param attach 附加信息
* @return 微信支付 -- JS_API模式
* @throws Exception 可能产生的任何异常
*/
@RequestMapping(value = "/jsapi/{app_id}", method = {Type.HttpMethod.GET, Type.HttpMethod.POST})
public IView __doJsApi(@PathVariable("app_id") String appId,
@VRequried @RequestParam("open_id") String openId,
@VRequried @RequestParam String state,
@RequestParam String attach,
@RequestParam boolean debug) throws Exception {
IWxPayEventHandler _eventHandler = WxPay.get().getModuleCfg().getEventHandler();
if (_eventHandler != null) {
WxPayAccountMeta _meta = WxPay.get().getModuleCfg().getAccountProvider().getAccount(appId);
if (_meta != null) {
WxPayUnifiedOrder _request = _eventHandler.buildUnifiedOrderRequest(_meta, IWxPay.TradeType.JSAPI, state, attach).openId(openId);
WxPayUnifiedOrder.Response _response = _request.execute();
//
if (_response.checkReturnCode() && _response.checkResultCode() && (WxPay.get().getModuleCfg().isSignCheckDisabled() || _response.checkSignature(_meta.getMchKey()))) {
// 封装JSAPI初始化相关参数
String _queryStr = StringUtils.trimToNull(WebContext.getRequest().getQueryString());
String _currentURL = WebUtils.buildURL(WebContext.getRequest(), "payment/wxpay/jsapi/" + appId + (_queryStr == null ? "" : "?" + _queryStr), true);
//
String _timestamp = DateTimeUtils.currentTimeUTC() + "";
String _nonceStr = WxPayBaseData.__doCreateNonceStr();
String _config = __buildJsApiConfigStr(_meta.getAppId(), _eventHandler.getJsApiTicket(_meta.getAppId()), StringUtils.substringBefore(_currentURL, "#"), _timestamp, _nonceStr, debug);
// 封装基于JSAPI的支付调用相关参数
Map<String, Object> _paramMap = new HashMap<String, Object>();
_paramMap.put("appId", _meta.getAppId());
_paramMap.put("timeStamp", _timestamp);
_paramMap.put("nonceStr", _nonceStr);
_paramMap.put("package", "prepay_id=" + _response.prepayId());
_paramMap.put("signType", IWxPay.Const.SIGN_TYPE_MD5);
_paramMap.put("paySign", WxPayBaseData.__doCreateSignature(_paramMap, _meta.getMchKey()));
//
return View.jspView(WxPay.get().getModuleCfg().getJsApiView())
.addAttribute("_config", _config)
.addAttribute("_data", _paramMap)
.addAttribute("_trade_no", state);
}
}
}
return HttpStatusView.bind(HttpServletResponse.SC_BAD_REQUEST);
}
示例3: __doMWeb
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的package包/类
@RequestMapping(value = "{app_id}/mweb", method = {Type.HttpMethod.GET, Type.HttpMethod.POST})
public IView __doMWeb(@PathVariable("app_id") String appId,
@VRequried @RequestParam String state,
@RequestParam String attach,
@RequestParam("redirect_url") String redirectUrl) throws Exception {
IWxPayEventHandler _eventHandler = WxPay.get().getModuleCfg().getEventHandler();
if (_eventHandler != null) {
WxPayAccountMeta _meta = WxPay.get().getModuleCfg().getAccountProvider().getAccount(appId);
if (_meta != null) {
WxPayUnifiedOrder _request = _eventHandler.buildUnifiedOrderRequest(_meta, IWxPay.TradeType.MWEB, state, attach);
WxPayUnifiedOrder.Response _response = _request.execute();
//
if (_response.checkReturnCode() && _response.checkResultCode() && (WxPay.get().getModuleCfg().isSignCheckDisabled() || _response.checkSignature(_meta.getMchKey()))) {
if (StringUtils.isNotBlank(redirectUrl)) {
return View.redirectView(_response.mwebUrl() + "&redirect_url=" + WebUtils.encodeURL(redirectUrl));
}
return View.redirectView(_response.mwebUrl());
}
}
}
return HttpStatusView.bind(HttpServletResponse.SC_BAD_REQUEST);
}
示例4: __doNativeStatic
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的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);
}
示例5: __doNativeDynamic
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的package包/类
@RequestMapping(value = "{app_id}/native/dynamic", method = {Type.HttpMethod.GET, Type.HttpMethod.POST})
public IView __doNativeDynamic(@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) {
WxPayUnifiedOrder _request = _eventHandler.buildUnifiedOrderRequest(_meta, IWxPay.TradeType.NATIVE, state, attach);
WxPayUnifiedOrder.Response _response = _request.execute();
//
if (_response.checkReturnCode() && _response.checkResultCode() && (WxPay.get().getModuleCfg().isSignCheckDisabled() || _response.checkSignature(_meta.getMchKey()))) {
String _qrCodeData = WebUtils.encryptStr(WebContext.getRequest(), _response.codeUrl());
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);
}
示例6: __doSignCheck
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的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;
}
示例7: auth
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的package包/类
/**
* @return 验证访问凭证是否有效
* @throws Exception 可能产生的任何异常
*/
@RequestMapping("/auth")
@Before(SnsAccessTokenCheckInterceptor.class)
public IView auth() throws Exception {
OAuthResponse _response = OAuthASResponse.errorResponse(HttpServletResponse.SC_OK).setError("ok").buildJSONMessage();
return new HttpStatusView(_response.getResponseStatus(), false).writeBody(_response.getBody());
}
示例8: __doCallback
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的package包/类
/**
* @param appId 微信公众号应用ID
* @param state 商品或订单ID
* @return 同步回调(订单状态主动检查)
* @throws Exception 可能产生的任何异常
*/
@RequestMapping(value = "{app_id}/callback", method = {Type.HttpMethod.GET, Type.HttpMethod.POST})
public IView __doCallback(@PathVariable("app_id") String appId, @VRequried @RequestParam String state) throws Exception {
IWxPayEventHandler _eventHandler = WxPay.get().getModuleCfg().getEventHandler();
if (_eventHandler != null) {
if (_eventHandler.onReturnCallback(state)) {
WxPayOrderQuery _query = WxPay.get().orderQuery(appId, null, state);
WxPayOrderQuery.Response _response = _query.execute();
_eventHandler.onNotifyReceived(_response);
//
return WebResult.SUCCESS().dataAttr("trade_state", _response.tradeState()).dataAttr("trade_state_desc", _response.tradeStateDesc()).toJSON();
}
}
return HttpStatusView.bind(HttpServletResponse.SC_BAD_REQUEST);
}
示例9: __callback
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的package包/类
@RequestMapping("/callback")
public IView __callback(@ModelBind AliPayBaseReturn baseReturn) throws Exception {
IView _view = AliPay.get().onReturnCallback(baseReturn);
if (_view == null) {
return HttpStatusView.METHOD_NOT_ALLOWED;
}
return _view;
}
示例10: __doAuthorize
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的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();
}
示例11: __doNotify
import net.ymate.platform.webmvc.view.impl.HttpStatusView; //导入依赖的package包/类
/**
* @param notify 微信支付异步通知对象
* @return 接收微信异步通知
* @throws Exception 可能产生的任何异常
*/
@RequestMapping(value = "/notify", method = Type.HttpMethod.POST)
@RequestProcessor(WxPayRequestProcessor.class)
public IView __doNotify(@RequestParam WxPayNotifyResponse notify) throws Exception {
IWxPayEventHandler _eventHandler = WxPay.get().getModuleCfg().getEventHandler();
if (_eventHandler != null) {
//
Map<String, Object> _returnValues = new HashMap<String, Object>();
//
WxPayAccountMeta _meta = WxPay.get().getModuleCfg().getAccountProvider().getAccount(notify.appId());
if (_meta != null) {
try {
if (!WxPay.get().getModuleCfg().isSignCheckDisabled() || notify.checkSignature(_meta.getMchKey())) {
if (StringUtils.isNotBlank(notify.productId())) {
WxPayUnifiedOrder _request = _eventHandler.buildUnifiedOrderRequest(_meta, IWxPay.TradeType.NATIVE, notify.productId(), notify.attach());
WxPayUnifiedOrder.Response _response = _request.execute();
if (_response.checkReturnCode() && _response.checkResultCode()) {
if (WxPay.get().getModuleCfg().isSignCheckDisabled() || _response.checkSignature(_meta.getMchKey())) {
_returnValues.put(IWxPay.Const.RETURN_CODE, IWxPay.ReturnCode.SUCCESS.name());
_returnValues.put(IWxPay.Const.RESULT_CODE, IWxPay.ResultCode.SUCCESS.name());
_returnValues.put(IWxPay.Const.APP_ID, _meta.getAppId());
_returnValues.put(IWxPay.Const.MCH_ID, _meta.getMchId());
_returnValues.put(IWxPay.Const.NONCE_STR, WxPayBaseData.__doCreateNonceStr());
_returnValues.put("prepay_id", _response.prepayId());
_returnValues.put("trade_type", IWxPay.TradeType.NATIVE.name());
_returnValues.put(IWxPay.Const.SIGN, WxPayBaseData.__doCreateSignature(_returnValues, _meta.getMchKey()));
} else {
_returnValues.put(IWxPay.Const.RETURN_CODE, IWxPay.ReturnCode.FAIL.name());
_returnValues.put(IWxPay.Const.RETURN_MSG, IWxPay.ErrCode.SIGNERROR.desc());
}
}
} else {
_eventHandler.onNotifyReceived(notify);
//
_returnValues.put(IWxPay.Const.RETURN_CODE, IWxPay.ReturnCode.SUCCESS.name());
}
} else {
_returnValues.put(IWxPay.Const.RETURN_CODE, IWxPay.ReturnCode.FAIL.name());
_returnValues.put(IWxPay.Const.RETURN_MSG, IWxPay.ErrCode.SIGNERROR.desc());
}
} catch (Exception e) {
_returnValues.put(IWxPay.Const.RETURN_CODE, IWxPay.ReturnCode.FAIL.name());
if (e instanceof WxPayException) {
_returnValues.put(IWxPay.Const.RETURN_MSG, ((WxPayException) e).getErrMsg());
} else {
_eventHandler.onExceptionCaught(RuntimeUtils.unwrapThrow(e));
_returnValues.put(IWxPay.Const.RETURN_MSG, IWxPay.ErrCode.SYSTEMERROR);
}
}
String _returnStr = WxPayBaseData.__doBuildXML(_returnValues);
_LOG.debug("WxPay Notify Response: [" + _returnStr + "]");
return new TextView(_returnStr, "text/xml");
}
}
return HttpStatusView.bind(HttpServletResponse.SC_BAD_REQUEST);
}