Example usage for org.apache.shiro.subject.support DisabledSessionException DisabledSessionException

List of usage examples for org.apache.shiro.subject.support DisabledSessionException DisabledSessionException

Introduction

In this page you can find the example usage for org.apache.shiro.subject.support DisabledSessionException DisabledSessionException.

Prototype

public DisabledSessionException(String message) 

Source Link

Usage

From source file:com.caricah.iotracah.bootstrap.security.realm.state.IOTSubject.java

License:Apache License

public Session getSession(boolean create) {
    if (log.isTraceEnabled()) {
        log.trace("attempting to get session; create = " + create + "; session is null = "
                + (this.session == null) + "; session has id = "
                + (this.session != null && session.getId() != null));
    }//from  w  w  w  .j ava 2 s  .co  m

    if (this.session == null && create) {

        //added in 1.2:
        if (!isSessionCreationEnabled()) {
            String msg = "Session creation has been disabled for the current subject.  This exception indicates "
                    + "that there is either a programming error (using a session when it should never be "
                    + "used) or that Shiro's configuration needs to be adjusted to allow Sessions to be created "
                    + "for the current Subject.  See the " + DisabledSessionException.class.getName()
                    + " JavaDoc " + "for more.";
            throw new DisabledSessionException(msg);
        }

        log.trace("Starting session for host {}", getHost());
        this.session = this.securityManager.start(sessionContext);
    }
    return this.session;
}