本文整理汇总了Java中org.apache.shiro.session.SessionException类的典型用法代码示例。如果您正苦于以下问题:Java SessionException类的具体用法?Java SessionException怎么用?Java SessionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionException类属于org.apache.shiro.session包,在下文中一共展示了SessionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSession
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
public Session getSession(SessionKey key) throws SessionException {
if (!WebUtils.isHttp(key)) {
String msg = "SessionKey must be an HTTP compatible implementation.";
throw new IllegalArgumentException(msg);
}
HttpServletRequest request = WebUtils.getHttpRequest(key);
Session session = null;
HttpSession httpSession = request.getSession(false);
if (httpSession != null) {
session = createSession(httpSession, request.getRemoteHost());
}
return session;
}
示例2: preHandle
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
@Override
protected boolean preHandle(ServletRequest request, ServletResponse response)
throws Exception {
Subject subject = getSubject(request, response);
String redirectUrl = getRedirectUrl(request, response, subject);
try {
if(null != subject.getPrincipal()) {
subject.logout();
issueRedirect(request, response, redirectUrl);
return false;
} else {
return true;
}
} catch (SessionException ise) {
log.debug("Encountered session exception during login.", ise);
return false;
}
}
示例3: preHandle
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
@Override
protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
Subject subject = getSubject(request, response);
String redirectUrl = getRedirectUrl(request, response, subject);
//try/catch added for SHIRO-298:
try {
subject.logout();
} catch (SessionException ise) {
log.debug("Encountered session exception during logout. This can generally safely be ignored.", ise);
}
issueRedirect(request, response, redirectUrl);
return false;
}
示例4: onPreHandle
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
@Override
protected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception {
Subject subject = SecurityUtils.getSubject();
try {
subject.logout();
} catch (SessionException ise) {
LOGGER.info("Encountered session exception during logout. This can generally safely be ignored.", ise);
}
HTTP.writeAsJSON(response,
MessageBean.STATUS, HTTP.Status.OK.toInt(),
MessageBean.MESSAGE, Messages.Status.OK.toString()) ;
return false;
}
示例5: clearRunAsIdentitiesInternal
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
private void clearRunAsIdentitiesInternal() {
//try/catch added for SHIRO-298
try {
clearRunAsIdentities();
} catch (SessionException se) {
log.debug("Encountered session exception trying to clear 'runAs' identities during logout. This " +
"can generally safely be ignored.", se);
}
}
示例6: preHandle
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
/**
* Acquires the currently executing {@link #getSubject(javax.servlet.ServletRequest, javax.servlet.ServletResponse) subject},
* a potentially Subject or request-specific
* {@link #getRedirectUrl(javax.servlet.ServletRequest, javax.servlet.ServletResponse, org.apache.shiro.subject.Subject) redirectUrl},
* and redirects the end-user to that redirect url.
*
* @param request the incoming ServletRequest
* @param response the outgoing ServletResponse
* @return {@code false} always as typically no further interaction should be done after user logout.
* @throws Exception if there is any error.
*/
@Override
protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
Subject subject = getSubject(request, response);
String redirectUrl = getRedirectUrl(request, response, subject);
//try/catch added for SHIRO-298:
try {
subject.logout();
} catch (SessionException ise) {
log.debug("Encountered session exception during logout. This can generally safely be ignored.", ise);
}
issueRedirect(request, response, redirectUrl);
return false;
}
示例7: lookupRequiredSession
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
private Session lookupRequiredSession(SessionKey key) throws SessionException {
Session session = lookupSession(key);
if (session == null) {
String msg = "Unable to locate required Session instance based on SessionKey [" + key + "].";
throw new UnknownSessionException(msg);
}
return session;
}
示例8: lookupRequiredSession
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
private Session lookupRequiredSession(SessionKey key) throws SessionException {
Session session = lookupSession(key);
if (session == null) {
String msg = "Unable to locate required Session instance based on SessionKey [" + key + "].";
throw new UnknownSessionException(msg);
}
return session;
}
示例9: preHandle
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
@Override
protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
//在这里执行退出系统前需要清空的数据
Subject subject = getSubject(request, response);
String redirectUrl = getRedirectUrl(request, response, subject);
try {
subject.logout();
} catch (SessionException ise) {
ise.printStackTrace();
}
issueRedirect(request, response, redirectUrl);
//返回false表示不执行后续的过滤器,直接返回跳转到登录页面
return false;
}
示例10: getSession
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
@Override
public Session getSession(SessionKey key) throws SessionException {
// The SessionKey can be used to look up sessions
// These sessions might be saved somehow, e.g. in a database,
// but in a web environment they are probably better of being
// maintained by the servlet container
JWebSessionKey k = (JWebSessionKey) key;
SessionFacade session = k.getContext().getSession(false);
if (session != null)
return createSession(session, k.getContext().remoteHost());
return null;
}
示例11: getSession
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
public Session getSession(SessionKey key) throws SessionException {
if (key == null) {
throw new NullPointerException("SessionKey argument cannot be null.");
}
IOTClient session = (IOTClient) doGetSession(key);
session.setSessionManager(this);
return session;
}
示例12: preHandle
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
@Override
protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
Subject subject = SecurityUtils.getSubject();
try {
subject.logout();
} catch (SessionException ise) {
log.debug("Encountered session exception during logout. This can generally safely be ignored.", ise);
}
return false;
}
示例13: getSession
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
@Nullable
Session getSession(String sessionId) {
if(sessionId != null) {
SessionKey key = new DefaultSessionKey(sessionId);
try {
return SecurityUtils.getSecurityManager().getSession(key);
} catch(SessionException e) {
// Means that the session does not exist or has expired.
}
}
return null;
}
示例14: preHandle
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
@Override
protected boolean preHandle(RequestWrapper requestWrapper, ResponseWrapper responseWrapper) {
Subject subject = getSubject(requestWrapper);
String redirectUrl = getRedirectUrl();
try {
subject.logout();
} catch (SessionException ise) {
LOGGER.debug("Encountered session exception during logout. This can generally safely be ignored.", ise);
}
issueRedirect(requestWrapper, responseWrapper, redirectUrl);
return false;
}
示例15: getSession
import org.apache.shiro.session.SessionException; //导入依赖的package包/类
@Override
public Session getSession( SessionKey key ) throws SessionException {
if ( !WebUtils.isHttp( key ) ) {
String msg = "SessionKey must be an HTTP compatible implementation.";
throw new IllegalArgumentException( msg );
}
HttpServletRequest request = WebUtils.getHttpRequest( key );
return ( Session ) request.getAttribute( REQUEST_ATTRIBUTE_KEY );
}