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


Java SessionUtils类代码示例

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


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

示例1: doGet

import com.auth0.SessionUtils; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    final String accessToken = (String) SessionUtils.get(req, "accessToken");
    final String idToken = (String) SessionUtils.get(req, "idToken");
    if (accessToken != null) {
        req.setAttribute("userId", accessToken);
    } else if (idToken != null) {
        req.setAttribute("userId", idToken);
    }
    req.getRequestDispatcher("/WEB-INF/jsp/home.jsp").forward(req, res);
}
 
开发者ID:auth0-samples,项目名称:auth0-servlet-sample,代码行数:12,代码来源:HomeServlet.java

示例2: handle

import com.auth0.SessionUtils; //导入依赖的package包/类
private void handle(HttpServletRequest req, HttpServletResponse res) throws IOException {
    try {
        Tokens tokens = authenticationController.handle(req);
        SessionUtils.set(req, "accessToken", tokens.getAccessToken());
        SessionUtils.set(req, "idToken", tokens.getIdToken());
        res.sendRedirect(redirectOnSuccess);
    } catch (IdentityVerificationException e) {
        e.printStackTrace();
        res.sendRedirect(redirectOnFail);
    }
}
 
开发者ID:auth0-samples,项目名称:auth0-servlet-sample,代码行数:12,代码来源:CallbackServlet.java

示例3: doFilter

import com.auth0.SessionUtils; //导入依赖的package包/类
/**
 * Perform filter check on this request - verify the User Id is present.
 *
 * @param request  the received request
 * @param response the response to send
 * @param next     the next filter chain
 **/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain next) throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse res = (HttpServletResponse) response;
    String accessToken = (String) SessionUtils.get(req, "accessToken");
    String idToken = (String) SessionUtils.get(req, "idToken");
    if (accessToken == null && idToken == null) {
        res.sendRedirect("/login");
        return;
    }
    next.doFilter(request, response);
}
 
开发者ID:auth0-samples,项目名称:auth0-servlet-sample,代码行数:20,代码来源:Auth0Filter.java

示例4: home

import com.auth0.SessionUtils; //导入依赖的package包/类
@RequestMapping(value = "/portal/home", method = RequestMethod.GET)
protected String home(final Map<String, Object> model, final HttpServletRequest req) {
    logger.info("Home page");
    String accessToken = (String) SessionUtils.get(req, "accessToken");
    String idToken = (String) SessionUtils.get(req, "idToken");
    if (accessToken != null) {
        model.put("userId", accessToken);
    } else if (idToken != null) {
        model.put("userId", idToken);
    }
    return "home";
}
 
开发者ID:auth0-samples,项目名称:auth0-spring-mvc-sample,代码行数:13,代码来源:HomeController.java

示例5: doFilter

import com.auth0.SessionUtils; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain next) throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse res = (HttpServletResponse) response;
    String accessToken = (String) SessionUtils.get(req, "accessToken");
    String idToken = (String) SessionUtils.get(req, "idToken");
    if (accessToken == null && idToken == null) {
        res.sendRedirect("/login");
        return;
    }
    next.doFilter(request, response);
}
 
开发者ID:auth0-samples,项目名称:auth0-spring-mvc-sample,代码行数:13,代码来源:Auth0Filter.java

示例6: handle

import com.auth0.SessionUtils; //导入依赖的package包/类
private void handle(HttpServletRequest req, HttpServletResponse res) throws IOException {
    try {
        Tokens tokens = controller.handle(req);
        SessionUtils.set(req, "accessToken", tokens.getAccessToken());
        SessionUtils.set(req, "idToken", tokens.getIdToken());
        res.sendRedirect(redirectOnSuccess);
    } catch (IdentityVerificationException e) {
        e.printStackTrace();
        res.sendRedirect(redirectOnFail);
    }
}
 
开发者ID:auth0-samples,项目名称:auth0-spring-mvc-sample,代码行数:12,代码来源:CallbackController.java

示例7: addOrReplaceToState

import com.auth0.SessionUtils; //导入依赖的package包/类
public String addOrReplaceToState( final String key, final String value )
{
    final HttpServletRequest request = portalRequestSupplier.get().getRawRequest();
    final String stateFromStorage = SessionUtils.getState( request ) != null ? SessionUtils.getState( request ) : "";
    final String updatedState = QueryParamUtils.addOrReplaceInQueryParams( stateFromStorage, key, value );
    SessionUtils.setState( request, updatedState );
    return updatedState;
}
 
开发者ID:enonic,项目名称:app-auth0-idprovider,代码行数:9,代码来源:StateScriptBean.java


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