Example usage for org.apache.shiro.session UnknownSessionException UnknownSessionException

List of usage examples for org.apache.shiro.session UnknownSessionException UnknownSessionException

Introduction

In this page you can find the example usage for org.apache.shiro.session UnknownSessionException UnknownSessionException.

Prototype

public UnknownSessionException(Throwable cause) 

Source Link

Document

Constructs a new UnknownSessionException.

Usage

From source file:cn.dreampie.common.plugin.shiro.MyAuthenticatingFilter.java

License:Apache License

protected void doCaptchaValidate(CaptchaUsernamePasswordToken token) {
    Session session = SecurityUtils.getSubject().getSession();
    if (session == null) {
        throw new UnknownSessionException("Unable found required Session");
    } else {/* ww  w.  j av  a  2  s.  c o  m*/
        if (session.getAttribute(AppConstants.CAPTCHA_NAME) != null) {
            String captcha = session.getAttribute(AppConstants.CAPTCHA_NAME).toString();
            // String captcha = CookieUtils.getCookie(request, AppConstants.CAPTCHA_NAME);
            if (token.getCaptcha() != null
                    && captcha.equalsIgnoreCase(EncriptionUtils.encrypt(token.getCaptcha()))) {
                return;
            }
        }
        throw new IncorrectCaptchaException();
    }
}

From source file:cn.dreampie.shiro.ShiroAuthenticatingFilter.java

License:Apache License

protected void doCaptchaValidate(CaptchaUsernamePasswordToken token) {
    Session session = SecurityUtils.getSubject().getSession();
    if (session == null) {
        throw new UnknownSessionException("Unable found required Session");
    } else {//from w w w. j  a  va  2s  .  c  om
        if (session.getAttribute(DEFAULT_CAPTCHA_PARAM) != null) {
            String captcha = session.getAttribute(DEFAULT_CAPTCHA_PARAM).toString();
            // String captcha = CookieUtils.getCookie(request, AppConstants.CAPTCHA_NAME);
            if (token.getCaptcha() != null
                    && captcha.equalsIgnoreCase(EncriptionKit.encrypt(token.getCaptcha().toLowerCase()))) {
                return;
            }
        }
        throw new IncorrectCaptchaException();
    }
}

From source file:com.dbumama.market.web.core.plugin.shiro.ShiroKit.java

License:Apache License

public static Session getSession() {
    Subject subject = SecurityUtils.getSubject();
    Session session = subject.getSession();
    if (session == null) {
        throw new UnknownSessionException("Unable found required Session");
    } else {/*from ww  w  . j  a va 2 s  .c o m*/
        return session;
    }
}

From source file:com.github.richardwilly98.esdms.shiro.EsSessionDAO.java

License:Open Source License

@Override
public void update(Session session) throws UnknownSessionException {
    try {//  w ww .  j a va  2 s .  co m
        if (session == null || session.getId() == null) {
            log.warn("Session id is null.");
            return;
        }
        SessionImpl s = authenticationService.get(session.getId().toString());
        if (s != null) {
            if (session.getAttribute(AuthenticationProvider.ES_DMS_ID_ATTRIBUTE) != null) {
                s.setUserId(session.getAttribute(AuthenticationProvider.ES_DMS_ID_ATTRIBUTE).toString());
            }
            authenticationService.update(s);
        } else {
            throw new UnknownSessionException(String.format("update session failed for %s", session.getId()));
        }
    } catch (ServiceException ex) {
        log.error("update failed", ex);
    }
}

From source file:com.parallax.server.blocklyprop.security.BlocklyPropSessionDao.java

/**
 * Updates (persists) data from a previously created Session instance in the EIS identified
 * by {@link Session#getId() session.getId()}. This effectively propagates the data in the
 * argument to the EIS record previously saved.
 *
 * @param session/*from   w w w .j  av a 2s . com*/
 * session - the Session to update
 *
 * @throws UnknownSessionException
 * if no existing EIS session record exists with the identifier of session.getSessionId()
 *
 * @implNote
 * In addition to UnknownSessionException, implementations are free to throw any other
 * exceptions that might occur due to integrity violation constraints or other EIS related
 * errors.
 */
@Override
public void update(Session session) throws UnknownSessionException {

    LOG.trace("Update session: {}", session.getId());

    try {
        // updateSession() can throw a NullPointerException if something goes wrong
        SessionServiceImpl.getSessionService().updateSession(convert(session));
    } catch (NullPointerException npe) {
        LOG.error("Unable to update the session. Error message: {}", npe.getMessage());
        throw new UnknownSessionException("Unable to update the session");
    }
}