use of lucee.runtime.listener.ApplicationContext in project Lucee by lucee.
the class Application method doStartTag.
@Override
public int doStartTag() throws PageException {
ApplicationContext ac;
boolean initORM;
if (action == ACTION_CREATE) {
ac = new ClassicApplicationContext(pageContext.getConfig(), name, false, pageContext.getCurrentPageSource().getResourceTranslated(pageContext));
initORM = set(ac, false);
pageContext.setApplicationContext(ac);
} else {
ac = pageContext.getApplicationContext();
initORM = set(ac, true);
}
// scope cascading
if (((UndefinedImpl) pageContext.undefinedScope()).getScopeCascadingType() != ac.getScopeCascading()) {
pageContext.undefinedScope().initialize(pageContext);
}
// ORM
if (initORM)
ORMUtil.resetEngine(pageContext, false);
return SKIP_BODY;
}
use of lucee.runtime.listener.ApplicationContext in project Lucee by lucee.
the class Cookie method doStartTag.
@Override
public int doStartTag() throws PageException {
Key key = KeyImpl.getInstance(name);
String appName = Login.getApplicationName(pageContext.getApplicationContext());
boolean isAppName = false;
if (KeyConstants._CFID.equalsIgnoreCase(key) || KeyConstants._CFTOKEN.equalsIgnoreCase(key) || (isAppName = key.equals(appName))) {
ApplicationContext ac = pageContext.getApplicationContext();
if (ac instanceof ApplicationContextSupport) {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
CookieData data = isAppName ? acs.getAuthCookie() : acs.getSessionCookie();
if (data != null && data.isDisableUpdate())
throw new ExpressionException("customize " + key + " is disabled!");
}
}
pageContext.cookieScope().setCookie(key, value, expires, secure, path, domain, httponly, preservecase, encode);
return SKIP_BODY;
}
use of lucee.runtime.listener.ApplicationContext in project Lucee by lucee.
the class Loginuser method doStartTag.
@Override
public int doStartTag() throws PageException {
Resource rolesDir = pageContext.getConfig().getConfigDir().getRealResource("roles");
CredentialImpl login = new CredentialImpl(name, password, roles, rolesDir);
pageContext.setRemoteUser(login);
Tag parent = getParent();
while (parent != null && !(parent instanceof Login)) {
parent = parent.getParent();
}
ApplicationContext appContext = pageContext.getApplicationContext();
if (parent != null) {
int loginStorage = appContext.getLoginStorage();
String name = Login.getApplicationName(appContext);
if (loginStorage == Scope.SCOPE_SESSION && pageContext.getApplicationContext().isSetSessionManagement())
pageContext.sessionScope().set(KeyImpl.init(name), login.encode());
else {
ApplicationContext ac = pageContext.getApplicationContext();
TimeSpan tsExpires = AuthCookieDataImpl.DEFAULT.getTimeout();
if (ac instanceof ApplicationContextSupport) {
ApplicationContextSupport acs = (ApplicationContextSupport) ac;
AuthCookieData data = acs.getAuthCookie();
if (data != null) {
TimeSpan tmp = data.getTimeout();
if (tmp != null)
tsExpires = tmp;
}
}
int expires;
long tmp = tsExpires.getSeconds();
if (Integer.MAX_VALUE < tmp)
expires = Integer.MAX_VALUE;
else
expires = (int) tmp;
((CookieImpl) pageContext.cookieScope()).setCookie(KeyImpl.init(name), login.encode(), expires, false, "/", Login.getCookieDomain(appContext));
}
}
return SKIP_BODY;
}
use of lucee.runtime.listener.ApplicationContext in project Lucee by lucee.
the class JSession method touchBeforeRequest.
@Override
public void touchBeforeRequest(PageContext pc) {
ApplicationContext appContext = pc.getApplicationContext();
timespan = appContext.getSessionTimeout().getMillis();
this.name = appContext.getName();
HttpSession hs = pc.getSession();
String id = "";
try {
if (hs != null)
this.httpSession = hs;
if (httpSession != null) {
id = httpSession.getId();
int timeoutInSeconds = ((int) (timespan / 1000)) + 60;
if (httpSession.getMaxInactiveInterval() < timeoutInSeconds)
httpSession.setMaxInactiveInterval(timeoutInSeconds);
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
lastAccess = System.currentTimeMillis();
setEL(KeyConstants._sessionid, id);
setEL(KeyConstants._urltoken, "CFID=" + pc.getCFID() + "&CFTOKEN=" + pc.getCFToken() + "&jsessionid=" + id);
}
use of lucee.runtime.listener.ApplicationContext in project Lucee by lucee.
the class ScopeContext method removeJSessionScope.
public void removeJSessionScope(PageContext pc) throws PageException {
HttpSession httpSession = pc.getSession();
if (httpSession != null) {
ApplicationContext appContext = pc.getApplicationContext();
httpSession.removeAttribute(appContext.getName());
}
}
Aggregations