📄 sessioninterceptor.java
字号:
/* * Copyright 2005-2007 WSO2, Inc. (http://wso2.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.wso2.solutions.identity.user.ui.interceptor;import org.apache.struts2.StrutsStatics;import org.wso2.solutions.identity.IdentityConstants;import org.wso2.solutions.identity.user.ui.UIConstants;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionInvocation;import com.opensymphony.xwork2.interceptor.AbstractInterceptor;public class SessionInterceptor extends AbstractInterceptor { private static final long serialVersionUID = -998579259074120645L; public String intercept(ActionInvocation invocation) throws Exception { final ActionContext context = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) context .get(StrutsStatics.HTTP_REQUEST); StringBuffer requestURL = request.getRequestURL(); if (requestURL.indexOf(IdentityConstants.USER_VERIFICATION_PAGE) > 0) { return invocation.invoke(); } else if (requestURL.indexOf(UIConstants.LOGIN_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.INFOCARD_SUBMIT_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.USER_REGISTRATION_FORM_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.USER_REGISTRATION_FORM_SUBMIT_ACTION) < 0 && requestURL.toString().indexOf(UIConstants.SHOW_LOGIN_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.USER_REGISTRATION_CARD_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.USER_REGISTRATION_CARD_SUBMIT_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.OPENID_SUBMIT_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.OPENID_INFO_CARD__SUBMIT_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.ADD_USER_PROFILE_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.EDIT_USER_PROFILE_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.ADD_USER_PROFILE_SUBMIT_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.EDIT_USER_PROFILE_SUBMIT_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.OPENDID_CALLBACK_ACTION) < 0 && requestURL.indexOf(UIConstants.OPENID_AUTH_ACTION) < 0 && requestURL .indexOf(UIConstants.OPENID_AUTH_VERIFICATION_ACTION) < 0 && requestURL.indexOf(UIConstants.OPENID_USER_APPROVAL_ACTION) < 0 && requestURL.indexOf(UIConstants.UPDATE_OPENID_USER_RP_ACTION) < 0 && requestURL.indexOf(UIConstants.OPENID_REDIRECT_ACTION) < 0 && requestURL.toString().indexOf( UIConstants.OPENID_LOGIN_ACTION) < 0) { // If the request is not Login.action HttpSession session = request.getSession(true); Object user = session.getAttribute(UIConstants.USER); if (user == null) { // If there is no session return "login"; } else { // Existing session if (requestURL.toString().indexOf(UIConstants.LOGIN_JSP) > 0) { // If an already logged in used is trying to access the // login.jsp return "showMain"; } else { return invocation.invoke(); } } } else { // If the request is for the Login.action then simply do it return invocation.invoke(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -