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