use of org.apache.shiro.session.Session in project shiro by apache.
the class DefaultSampleManager method setValue.
public void setValue(String newValue) {
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
if (log.isDebugEnabled()) {
log.debug("saving session key [" + VALUE_KEY + "] with value [" + newValue + "] on session with id [" + session.getId() + "]");
}
session.setAttribute(VALUE_KEY, newValue);
}
use of org.apache.shiro.session.Session in project shiro by apache.
the class JnlpController method handleRequestInternal.
/*--------------------------------------------
| M E T H O D S |
============================================*/
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Subject subject = SecurityUtils.getSubject();
Session session = null;
if (subject != null) {
session = subject.getSession();
}
if (session == null) {
String msg = "Expected a non-null Shiro session.";
throw new IllegalArgumentException(msg);
}
StringBuilder sb = new StringBuilder();
sb.append("http://");
sb.append(request.getServerName());
if (request.getServerPort() != 80) {
sb.append(":");
sb.append(request.getServerPort());
}
sb.append(request.getContextPath());
// prevent JNLP caching by setting response headers
response.setHeader("cache-control", "no-cache");
response.setHeader("pragma", "no-cache");
Map<String, Object> model = new HashMap<String, Object>();
model.put("codebaseUrl", sb.toString());
model.put("sessionId", session.getId());
return new ModelAndView(jnlpView, model);
}
use of org.apache.shiro.session.Session in project killbill by killbill.
the class KillBillWebSessionManager method start.
@Override
public Session start(final SessionContext context) {
final Session session = createSession(context);
// See above
// applyGlobalSessionTimeout(session);
onStart(session, context);
notifyStart(session);
return createExposedSession(session, context);
}
use of org.apache.shiro.session.Session in project killbill by killbill.
the class KillBillWebSessionManager method newSessionInstance.
@Override
protected Session newSessionInstance(final SessionContext context) {
final Session session = super.newSessionInstance(context);
// DefaultWebSessionManager will call applyGlobalSessionTimeout() in
// start() below instead, which in turn calls onChange() and triggers a DAO UPDATE call
session.setTimeout(getGlobalSessionTimeout());
return session;
}
use of org.apache.shiro.session.Session in project killbill by killbill.
the class KillBillSubjectDAO method saveToSession.
@Override
protected void saveToSession(final Subject subject) {
boolean updatesDisabled = false;
Session session = subject.getSession(false);
if (session == null && !CollectionUtils.isEmpty(subject.getPrincipals())) {
// Force the creation of the session here to get the id
session = subject.getSession();
// Optimize the session creation path: the default saveToSession implementation
// will call setAttribute() several times in a row, causing unnecessary DAO UPDATE queries
updatesDisabled = disableUpdatesForSession(subject, session);
}
super.saveToSession(subject);
if (updatesDisabled) {
enableUpdatesForSession(subject, session);
}
}
Aggregations