use of lucee.runtime.type.scope.CookieImpl 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;
}
Aggregations