Search in sources :

Example 6 with ApplicationContextSupport

use of lucee.runtime.listener.ApplicationContextSupport 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 7 with ApplicationContextSupport

use of lucee.runtime.listener.ApplicationContextSupport in project Lucee by lucee.

the class Mail method doEndTag.

@Override
public int doEndTag() throws PageException {
    if (listener == null) {
        ApplicationContextSupport acs = (ApplicationContextSupport) pageContext.getApplicationContext();
        listener = acs.getMailListener();
    }
    if (listener != null)
        smtp.setListener(listener);
    smtp.setTimeZone(pageContext.getTimeZone());
    try {
        smtp.send(pageContext, sendTime != null ? sendTime.getTime() : 0);
    } catch (MailException e) {
        throw Caster.toPageException(e);
    }
    return EVAL_PAGE;
}
Also used : ApplicationContextSupport(lucee.runtime.listener.ApplicationContextSupport) MailException(lucee.runtime.net.mail.MailException)

Example 8 with ApplicationContextSupport

use of lucee.runtime.listener.ApplicationContextSupport in project Lucee by lucee.

the class PageContextImpl method getCacheConnection.

public CacheConnection getCacheConnection(String cacheName) throws CacheException {
    cacheName = cacheName.toLowerCase().trim();
    CacheConnection cc = null;
    if (getApplicationContext() != null)
        cc = ((ApplicationContextSupport) getApplicationContext()).getCacheConnection(cacheName, null);
    if (cc == null)
        cc = config.getCacheConnections().get(cacheName);
    if (cc == null)
        throw CacheUtil.noCache(config, cacheName);
    return cc;
}
Also used : ApplicationContextSupport(lucee.runtime.listener.ApplicationContextSupport) CacheConnection(lucee.runtime.cache.CacheConnection)

Example 9 with ApplicationContextSupport

use of lucee.runtime.listener.ApplicationContextSupport in project Lucee by lucee.

the class PageContextImpl method setClientCookies.

private void setClientCookies() {
    TimeSpan tsExpires = SessionCookieDataImpl.DEFAULT.getTimeout();
    String domain = PageContextUtil.getCookieDomain(this);
    boolean httpOnly = SessionCookieDataImpl.DEFAULT.isHttpOnly();
    boolean secure = SessionCookieDataImpl.DEFAULT.isSecure();
    ApplicationContext ac = getApplicationContext();
    if (ac instanceof ApplicationContextSupport) {
        ApplicationContextSupport acs = (ApplicationContextSupport) ac;
        SessionCookieData data = acs.getSessionCookie();
        if (data != null) {
            // expires
            TimeSpan ts = data.getTimeout();
            if (ts != null)
                tsExpires = ts;
            // httpOnly
            httpOnly = data.isHttpOnly();
            // secure
            secure = data.isSecure();
            // domain
            String tmp = data.getDomain();
            if (!StringUtil.isEmpty(tmp, true))
                domain = tmp.trim();
        }
    }
    int expires;
    long tmp = tsExpires.getSeconds();
    if (Integer.MAX_VALUE < tmp)
        expires = Integer.MAX_VALUE;
    else
        expires = (int) tmp;
    cookieScope().setCookieEL(KeyConstants._cfid, cfid, expires, secure, "/", domain, httpOnly, true, false);
    cookieScope().setCookieEL(KeyConstants._cftoken, cftoken, expires, secure, "/", domain, httpOnly, true, false);
}
Also used : TimeSpan(lucee.runtime.type.dt.TimeSpan) ApplicationContextSupport(lucee.runtime.listener.ApplicationContextSupport) ClassicApplicationContext(lucee.runtime.listener.ClassicApplicationContext) ApplicationContext(lucee.runtime.listener.ApplicationContext) SessionCookieData(lucee.runtime.listener.SessionCookieData)

Aggregations

ApplicationContextSupport (lucee.runtime.listener.ApplicationContextSupport)9 CacheConnection (lucee.runtime.cache.CacheConnection)4 ApplicationContext (lucee.runtime.listener.ApplicationContext)4 Key (lucee.runtime.type.Collection.Key)4 Entry (java.util.Map.Entry)3 Struct (lucee.runtime.type.Struct)3 StructImpl (lucee.runtime.type.StructImpl)3 Map (java.util.Map)2 Resource (lucee.commons.io.res.Resource)2 ExpressionException (lucee.runtime.exp.ExpressionException)2 PageException (lucee.runtime.exp.PageException)2 ClassicApplicationContext (lucee.runtime.listener.ClassicApplicationContext)2 TimeSpan (lucee.runtime.type.dt.TimeSpan)2 StringReader (java.io.StringReader)1 TimeZone (java.util.TimeZone)1 Vector (java.util.Vector)1 Tag (javax.servlet.jsp.tagext.Tag)1 Binding (javax.wsdl.Binding)1 Operation (javax.wsdl.Operation)1 Port (javax.wsdl.Port)1