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;
}
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;
}
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;
}
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);
}
Aggregations