当前位置: 首页>>代码示例>>Java>>正文


Java CookieHelper类代码示例

本文整理汇总了Java中net.ymate.platform.webmvc.util.CookieHelper的典型用法代码示例。如果您正苦于以下问题:Java CookieHelper类的具体用法?Java CookieHelper怎么用?Java CookieHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CookieHelper类属于net.ymate.platform.webmvc.util包,在下文中一共展示了CookieHelper类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getToken

import net.ymate.platform.webmvc.util.CookieHelper; //导入依赖的package包/类
@Override
public ISSOToken getToken() {
    ISSOToken _token = null;
    try {
        // 优先从Cookie中获取Token数据
        String _tokenStr = CookieHelper.bind(WebContext.getContext().getOwner())
                .getCookie(__owner.getModuleCfg().getTokenCookieName())
                .toStringValue();
        _token = decryptToken(_tokenStr);
        if (_token == null) {
            // 尝试从请求头中获取Token数据
            _token = decryptToken(WebContext.getRequest().getHeader(__owner.getModuleCfg().getTokenHeaderName()));
            //
            if (_token == null && __owner.getModuleCfg().isClientMode()) {
                // 若当前为客户端模式,则尝试从请求参数中获取Token数据
                _token = decryptToken(WebContext.getRequest().getParameter(__owner.getModuleCfg().getTokenParamName()));
            }
        }
    } catch (Exception e) {
        _LOG.warn("An exception occurred while getting token for current user", RuntimeUtils.unwrapThrow(e));
    }
    return _token;
}
 
开发者ID:suninformation,项目名称:ymate-module-sso,代码行数:24,代码来源:DefaultSSOTokenAdapter.java

示例2: onLocale

import net.ymate.platform.webmvc.util.CookieHelper; //导入依赖的package包/类
public Locale onLocale() {
    String _langStr = null;
    // 先尝试取URL参数变量
    if (WebContext.getContext() != null) {
        _langStr = WebContext.getRequestContext().getAttribute(I18N_LANG_KEY);
        if (StringUtils.trimToNull(_langStr) == null) {
            // 再尝试从请求参数中获取
            _langStr = WebContext.getRequest().getParameter(I18N_LANG_KEY);
            if (StringUtils.trimToNull(_langStr) == null) {
                // 最后一次机会,尝试读取Cookies
                _langStr = CookieHelper.bind(WebContext.getContext().getOwner()).getCookie(I18N_LANG_KEY).toStringValue();
            }
        }
    }
    Locale _locale = null;
    try {
        _locale = LocaleUtils.toLocale(StringUtils.trimToNull(_langStr));
    } catch (IllegalArgumentException e) {
        _locale = WebContext.getContext().getLocale();
    }
    return _locale;
}
 
开发者ID:suninformation,项目名称:ymate-platform-v2,代码行数:23,代码来源:I18NWebEventHandler.java

示例3: setToken

import net.ymate.platform.webmvc.util.CookieHelper; //导入依赖的package包/类
@Override
public void setToken(ISSOToken token) throws Exception {
    CookieHelper _cookieHelper = CookieHelper.bind(WebContext.getContext().getOwner());
    String _tokenStr = encryptToken(token);
    String _tokenCookieName = __owner.getModuleCfg().getTokenCookieName();
    int _maxAge = __owner.getModuleCfg().getTokenMaxage();
    if (_maxAge > 0) {
        _cookieHelper.setCookie(_tokenCookieName, _tokenStr, _maxAge);
    } else {
        _cookieHelper.setCookie(_tokenCookieName, _tokenStr);
    }
}
 
开发者ID:suninformation,项目名称:ymate-module-sso,代码行数:13,代码来源:DefaultSSOTokenAdapter.java

示例4: handle

import net.ymate.platform.webmvc.util.CookieHelper; //导入依赖的package包/类
@Override
public IView handle(String connectName, OAuthConnectUser connectUser, String state) throws Exception {
    CookieHelper _helper = CookieHelper.bind(WebContext.getContext().getOwner());
    try {
        String _cookieState = _helper.getCookie(__cookieName).toStringValue();
        if (__doEncryptState(connectName, state).equals(_cookieState)) {
            return __doHandle(connectName, connectUser, state);
        }
        return View.httpStatusView(HttpServletResponse.SC_BAD_REQUEST);
    } finally {
        _helper.removeCookie(__cookieName);
    }
}
 
开发者ID:suninformation,项目名称:ymate-module-oauth-connector,代码行数:14,代码来源:DefaultConnectCallbackHandler.java

示例5: cleanToken

import net.ymate.platform.webmvc.util.CookieHelper; //导入依赖的package包/类
@Override
public void cleanToken() {
    CookieHelper.bind(WebContext.getContext().getOwner()).removeCookie(__owner.getModuleCfg().getTokenCookieName());
}
 
开发者ID:suninformation,项目名称:ymate-module-sso,代码行数:5,代码来源:DefaultSSOTokenAdapter.java

示例6: connect

import net.ymate.platform.webmvc.util.CookieHelper; //导入依赖的package包/类
@Override
public IView connect(String connectName, String state) throws Exception {
    CookieHelper.bind(WebContext.getContext().getOwner()).setCookie(__cookieName, __doEncryptState(connectName, state));
    return null;
}
 
开发者ID:suninformation,项目名称:ymate-module-oauth-connector,代码行数:6,代码来源:DefaultConnectCallbackHandler.java

示例7: onChanged

import net.ymate.platform.webmvc.util.CookieHelper; //导入依赖的package包/类
public void onChanged(Locale locale) {
    if (WebContext.getContext() != null && locale != null) {
        CookieHelper.bind(WebContext.getContext().getOwner()).setCookie(I18N_LANG_KEY, locale.toString());
    }
}
 
开发者ID:suninformation,项目名称:ymate-platform-v2,代码行数:6,代码来源:I18NWebEventHandler.java


注:本文中的net.ymate.platform.webmvc.util.CookieHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。