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