Search in sources :

Example 6 with SessionCookieConfig

use of javax.servlet.SessionCookieConfig in project ma-core-public by infiniteautomation.

the class M2M2ContextListener method constantsInitialize.

// 
// 
// Constants
// 
private void constantsInitialize(ServletContext ctx) {
    ctx.setAttribute("constants.Common.NEW_ID", Common.NEW_ID);
    ctx.setAttribute("constants.DataTypes.BINARY", DataTypes.BINARY);
    ctx.setAttribute("constants.DataTypes.MULTISTATE", DataTypes.MULTISTATE);
    ctx.setAttribute("constants.DataTypes.NUMERIC", DataTypes.NUMERIC);
    ctx.setAttribute("constants.DataTypes.ALPHANUMERIC", DataTypes.ALPHANUMERIC);
    ctx.setAttribute("constants.DataTypes.IMAGE", DataTypes.IMAGE);
    ctx.setAttribute("constants.Permissions.DataPointAccessTypes.NONE", Permissions.DataPointAccessTypes.NONE);
    ctx.setAttribute("constants.Permissions.DataPointAccessTypes.READ", Permissions.DataPointAccessTypes.READ);
    ctx.setAttribute("constants.Permissions.DataPointAccessTypes.SET", Permissions.DataPointAccessTypes.SET);
    ctx.setAttribute("constants.Permissions.DataPointAccessTypes.DATA_SOURCE", Permissions.DataPointAccessTypes.DATA_SOURCE);
    ctx.setAttribute("constants.Permissions.DataPointAccessTypes.ADMIN", Permissions.DataPointAccessTypes.ADMIN);
    ctx.setAttribute("constants.EventType.EventTypeNames.DATA_POINT", EventType.EventTypeNames.DATA_POINT);
    ctx.setAttribute("constants.EventType.EventTypeNames.DATA_SOURCE", EventType.EventTypeNames.DATA_SOURCE);
    ctx.setAttribute("constants.EventType.EventTypeNames.SYSTEM", EventType.EventTypeNames.SYSTEM);
    ctx.setAttribute("constants.EventType.EventTypeNames.PUBLISHER", EventType.EventTypeNames.PUBLISHER);
    ctx.setAttribute("constants.EventType.EventTypeNames.AUDIT", EventType.EventTypeNames.AUDIT);
    ctx.setAttribute("constants.SystemEventType.TYPE_SYSTEM_STARTUP", SystemEventType.TYPE_SYSTEM_STARTUP);
    ctx.setAttribute("constants.SystemEventType.TYPE_SYSTEM_SHUTDOWN", SystemEventType.TYPE_SYSTEM_SHUTDOWN);
    ctx.setAttribute("constants.SystemEventType.TYPE_MAX_ALARM_LEVEL_CHANGED", SystemEventType.TYPE_MAX_ALARM_LEVEL_CHANGED);
    ctx.setAttribute("constants.SystemEventType.TYPE_USER_LOGIN", SystemEventType.TYPE_USER_LOGIN);
    ctx.setAttribute("constants.SystemEventType.TYPE_SET_POINT_HANDLER_FAILURE", SystemEventType.TYPE_SET_POINT_HANDLER_FAILURE);
    ctx.setAttribute("constants.SystemEventType.TYPE_EMAIL_SEND_FAILURE", SystemEventType.TYPE_EMAIL_SEND_FAILURE);
    ctx.setAttribute("constants.SystemEventType.TYPE_PROCESS_FAILURE", SystemEventType.TYPE_PROCESS_FAILURE);
    ctx.setAttribute("constants.SystemEventType.TYPE_LICENSE_CHECK", SystemEventType.TYPE_LICENSE_CHECK);
    ctx.setAttribute("constants.SystemEventType.TYPE_UPGRADE_CHECK", SystemEventType.TYPE_UPGRADE_CHECK);
    ctx.setAttribute("constants.AuditEventType.TYPE_DATA_SOURCE", AuditEventType.TYPE_DATA_SOURCE);
    ctx.setAttribute("constants.AuditEventType.TYPE_DATA_POINT", AuditEventType.TYPE_DATA_POINT);
    ctx.setAttribute("constants.AuditEventType.TYPE_EVENT_DETECTOR", AuditEventType.TYPE_EVENT_DETECTOR);
    ctx.setAttribute("constants.AuditEventType.TYPE_EVENT_HANDLER", AuditEventType.TYPE_EVENT_HANDLER);
    ctx.setAttribute("constants.UserComment.TYPE_EVENT", UserCommentVO.TYPE_EVENT);
    ctx.setAttribute("constants.UserComment.TYPE_POINT", UserCommentVO.TYPE_POINT);
    String[] codes = { "common.access.read", "common.access.set", "common.alarmLevel.none", "common.alarmLevel.info", "common.alarmLevel.important", "common.alarmLevel.warning", "common.alarmLevel.urgent", "common.alarmLevel.critical", "common.alarmLevel.lifeSafety", "common.alarmLevel.doNotLog", "common.alarmLevel.ignore", "common.disabled", "common.administrator", "common.user", "common.disabledToggle", "common.enabledToggle", "common.maximize", "common.minimize", "common.loading", "js.help.error", "js.help.related", "js.help.lastUpdated", "common.sendTestEmail", "js.email.noRecipients", "js.email.addMailingList", "js.email.addUser", "js.email.addAddress", "js.email.noRecipForEmail", "js.email.testSent", "events.silence", "events.unsilence", "header.mute", "header.unmute" };
    Map<String, TranslatableMessage> messages = new HashMap<>();
    for (String code : codes) messages.put(code, new TranslatableMessage(code));
    ctx.setAttribute("clientSideMessages", messages);
    SessionCookieConfig sessionCookieConfig = ctx.getSessionCookieConfig();
    sessionCookieConfig.setHttpOnly(true);
    sessionCookieConfig.setName(Common.getCookieName());
}
Also used : HashMap(java.util.HashMap) SessionCookieConfig(javax.servlet.SessionCookieConfig) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage)

Example 7 with SessionCookieConfig

use of javax.servlet.SessionCookieConfig in project scout.rt by eclipse.

the class UiSession method storeHttpSessionIdInCookie.

protected void storeHttpSessionIdInCookie(HttpServletResponse resp, HttpSession httpSession, UserAgent userAgent) {
    if (!(userAgent.getUiSystem().equals(UiSystem.IOS) && userAgent.isStandalone())) {
        // Special handling is only required for standalone mode in iOS ("home screen mode")
        return;
    }
    SessionCookieConfig cookieConfig = httpSession.getServletContext().getSessionCookieConfig();
    if (cookieConfig.getMaxAge() > 0) {
        // Container will create the persistent cookie, no need to do it by ourselves.
        LOG.info("Using persistent session cookie from container, maxAge is {} s", cookieConfig.getMaxAge());
    } else {
        // Replace the session cookie with a persistent cookie.
        // If the session expires or the user logs out the session will be invalidated normally.
        Cookie cookie = createPersistentSessionCookie(cookieConfig, httpSession);
        resp.addCookie(cookie);
        LOG.info("Created persistent session cookie, maxAge is {} s", cookie.getMaxAge());
    }
    // Mark session as persistent so that client session won't be disposed on an unload request
    m_persistent = true;
}
Also used : Cookie(javax.servlet.http.Cookie) SessionCookieConfig(javax.servlet.SessionCookieConfig)

Example 8 with SessionCookieConfig

use of javax.servlet.SessionCookieConfig in project tomcat70 by apache.

the class SessionConfig method getConfiguredSessionCookieName.

private static String getConfiguredSessionCookieName(Context context) {
    // 3. Default defined by spec
    if (context != null) {
        String cookieName = context.getSessionCookieName();
        if (cookieName != null && cookieName.length() > 0) {
            return cookieName;
        }
        SessionCookieConfig scc = context.getServletContext().getSessionCookieConfig();
        cookieName = scc.getName();
        if (cookieName != null && cookieName.length() > 0) {
            return cookieName;
        }
    }
    return null;
}
Also used : SessionCookieConfig(javax.servlet.SessionCookieConfig)

Example 9 with SessionCookieConfig

use of javax.servlet.SessionCookieConfig in project gocd by gocd.

the class Jetty9ServerTest method shouldSetSessionCookieConfig.

@Test
public void shouldSetSessionCookieConfig() throws Exception {
    when(systemEnvironment.isSessionCookieSecure()).thenReturn(true);
    jetty9Server.configure();
    jetty9Server.setSessionConfig();
    jetty9Server.startHandlers();
    WebAppContext webAppContext = (WebAppContext) getLoadedHandlers().get(WebAppContext.class);
    SessionCookieConfig sessionCookieConfig = webAppContext.getSessionHandler().getSessionCookieConfig();
    assertThat(sessionCookieConfig.isHttpOnly(), is(true));
    assertThat(sessionCookieConfig.isSecure(), is(true));
    assertThat(sessionCookieConfig.getMaxAge(), is(5678));
    when(systemEnvironment.isSessionCookieSecure()).thenReturn(false);
    jetty9Server.setSessionConfig();
    assertThat(sessionCookieConfig.isSecure(), is(false));
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) SessionCookieConfig(javax.servlet.SessionCookieConfig) Test(org.junit.jupiter.api.Test)

Example 10 with SessionCookieConfig

use of javax.servlet.SessionCookieConfig in project gocd by gocd.

the class Jetty9Server method setSessionConfig.

@Override
public void setSessionConfig() {
    SessionHandler sessionHandler = webAppContext.getSessionHandler();
    SessionCookieConfig sessionCookieConfig = sessionHandler.getSessionCookieConfig();
    sessionCookieConfig.setHttpOnly(true);
    sessionCookieConfig.setSecure(systemEnvironment.isSessionCookieSecure());
    sessionCookieConfig.setMaxAge(systemEnvironment.sessionCookieMaxAgeInSeconds());
    sessionHandler.setMaxInactiveInterval(systemEnvironment.sessionTimeoutInSeconds());
}
Also used : SessionHandler(org.eclipse.jetty.server.session.SessionHandler) SessionCookieConfig(javax.servlet.SessionCookieConfig)

Aggregations

SessionCookieConfig (javax.servlet.SessionCookieConfig)20 HashMap (java.util.HashMap)4 SessionHandler (org.eclipse.jetty.server.session.SessionHandler)4 ServletContext (javax.servlet.ServletContext)3 Field (java.lang.reflect.Field)2 Map (java.util.Map)2 JspPropertyGroupDescriptor (javax.servlet.descriptor.JspPropertyGroupDescriptor)2 TaglibDescriptor (javax.servlet.descriptor.TaglibDescriptor)2 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)1 WebSessionCookieConfig (com.sun.enterprise.web.session.WebSessionCookieConfig)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 StringReader (java.io.StringReader)1 Writer (java.io.Writer)1 ManagementFactory (java.lang.management.ManagementFactory)1