Search in sources :

Example 11 with ApplicationContext

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;
}
Also used : ModernApplicationContext(lucee.runtime.listener.ModernApplicationContext) ClassicApplicationContext(lucee.runtime.listener.ClassicApplicationContext) ApplicationContext(lucee.runtime.listener.ApplicationContext) ClassicApplicationContext(lucee.runtime.listener.ClassicApplicationContext)

Example 12 with ApplicationContext

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;
}
Also used : CookieData(lucee.runtime.listener.CookieData) ApplicationContextSupport(lucee.runtime.listener.ApplicationContextSupport) ApplicationContext(lucee.runtime.listener.ApplicationContext) Key(lucee.runtime.type.Collection.Key) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 13 with ApplicationContext

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;
}
Also used : TimeSpan(lucee.runtime.type.dt.TimeSpan) ApplicationContextSupport(lucee.runtime.listener.ApplicationContextSupport) ApplicationContext(lucee.runtime.listener.ApplicationContext) CredentialImpl(lucee.runtime.security.CredentialImpl) CookieImpl(lucee.runtime.type.scope.CookieImpl) Resource(lucee.commons.io.res.Resource) Tag(javax.servlet.jsp.tagext.Tag) AuthCookieData(lucee.runtime.listener.AuthCookieData)

Example 14 with ApplicationContext

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);
}
Also used : ApplicationContext(lucee.runtime.listener.ApplicationContext) HttpSession(javax.servlet.http.HttpSession)

Example 15 with ApplicationContext

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());
    }
}
Also used : ApplicationContext(lucee.runtime.listener.ApplicationContext) HttpSession(javax.servlet.http.HttpSession)

Aggregations

ApplicationContext (lucee.runtime.listener.ApplicationContext)28 MemoryScope (lucee.runtime.type.scope.storage.MemoryScope)10 StorageScope (lucee.runtime.type.scope.storage.StorageScope)10 HttpSession (javax.servlet.http.HttpSession)6 DataSource (lucee.runtime.db.DataSource)4 ApplicationContextSupport (lucee.runtime.listener.ApplicationContextSupport)4 Key (lucee.runtime.type.Collection.Key)4 CacheConnection (lucee.runtime.cache.CacheConnection)3 ExpressionException (lucee.runtime.exp.ExpressionException)3 PageException (lucee.runtime.exp.PageException)3 TimeSpan (lucee.runtime.type.dt.TimeSpan)3 IKHandlerCache (lucee.runtime.type.scope.storage.IKHandlerCache)3 IKHandlerDatasource (lucee.runtime.type.scope.storage.IKHandlerDatasource)3 IOException (java.io.IOException)2 Map (java.util.Map)2 Resource (lucee.commons.io.res.Resource)2 RefBooleanImpl (lucee.commons.lang.types.RefBooleanImpl)2 ApplicationException (lucee.runtime.exp.ApplicationException)2 ClassicApplicationContext (lucee.runtime.listener.ClassicApplicationContext)2 ModernApplicationContext (lucee.runtime.listener.ModernApplicationContext)2