Author: vjrj_ Date: 2012-04-09 09:04:40 +0200 (Mon, 09 Apr 2012) New Revision: 1828 Added: trunk/src/main/java/cc/kune/core/server/UserSessionMonitor.java Modified: trunk/TODO trunk/debian/changelog trunk/debian/files trunk/src/main/java/cc/kune/core/client/actions/ActionRegistryByType.java trunk/src/main/java/cc/kune/core/server/KuneContainerListener.java trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java trunk/src/main/java/cc/kune/core/server/UserSession.java trunk/src/main/java/cc/kune/core/server/UserSessionManager.java trunk/src/main/java/cc/kune/core/server/auth/AuthenticatedMethodInterceptor.java trunk/src/main/java/cc/kune/core/server/manager/impl/GroupManagerDefault.java trunk/src/main/java/cc/kune/core/server/state/StateServiceDefault.java trunk/src/main/java/cc/kune/wave/client/WaveStatusIndicator.java Log: Works about session expiration Modified: trunk/TODO =================================================================== --- trunk/TODO 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/TODO 2012-04-09 07:04:40 UTC (rev 1828) @@ -12,6 +12,22 @@ nick == assigned to * SHORT-TERM (URGENT) +** Session expired +12-04-09 00:14:29 GWTServiceFilter [INFO] -------------------------------------------------------------------------------- +2012-04-09 00:14:29 GWTServiceFilter [DEBUG] SERVICE: /ws/UserService - UserService +2012-04-09 00:14:29 AuthenticatedMethodInterceptor [INFO] Method: onlyCheckSession +2012-04-09 00:14:29 AuthenticatedMethodInterceptor [INFO] Userhash received: null +-------------------------------- +2012-04-09 00:14:24 AuthenticatedMethodInterceptor [INFO] Session expired (not logged in server) +2012-04-09 00:14:25 RackServletFilter [DEBUG] REQUEST: /ws/ContentService +2012-04-09 00:14:25 LogFilter [DEBUG] REQUEST: /ws/ContentService +2012-04-09 00:14:25 GWTServiceFilter [INFO] -------------------------------------------------------------------------------- +------------------ +2012-04-09 00:14:34 GWTServiceFilter [DEBUG] SERVICE: /ws/UserService - UserService +2012-04-09 00:14:34 AuthenticatedMethodInterceptor [INFO] Method: onlyCheckSession +2012-04-09 00:14:34 AuthenticatedMethodInterceptor [INFO] Userhash received: null +2012-04-09 00:14:34 AuthenticatedMethodInterceptor [INFO] -------------------------------------------------------------------------------- + ** Permission tables |---------------------------+-------------+--------------| @@ -62,7 +78,6 @@ | New folder | | | | | |------------+--------+---------+---------+-----------| - ** setui/root/port 80 [ ] http://wiki.eclipse.org/Jetty/Howto/Port80#Configuring_Jetty.27s_SetUID_Feat... [ ] https://github.com/disconnect/apache-websocket Modified: trunk/debian/changelog =================================================================== --- trunk/debian/changelog 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/debian/changelog 2012-04-09 07:04:40 UTC (rev 1828) @@ -1,3 +1,9 @@ +kune (0.1.0+b8) oneiric; urgency=low + + * Perms in Events fixed. Wave updated. Lists deletion by admin. + + -- Vicente J. Ruiz Jurado <[email protected]> Sun, 08 Apr 2012 21:31:33 +0200 + kune (0.1.0+b7) oneiric; urgency=low * Improved openfire connection, debian init and wave offline render and cache. Modified: trunk/debian/files =================================================================== --- trunk/debian/files 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/debian/files 2012-04-09 07:04:40 UTC (rev 1828) @@ -1 +1 @@ -kune_0.1.0+b7_all.deb java optional +kune_0.1.0+b8_all.deb java optional Modified: trunk/src/main/java/cc/kune/core/client/actions/ActionRegistryByType.java =================================================================== --- trunk/src/main/java/cc/kune/core/client/actions/ActionRegistryByType.java 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/src/main/java/cc/kune/core/client/actions/ActionRegistryByType.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -29,6 +29,7 @@ import cc.kune.common.client.actions.ui.descrip.GuiActionDescCollection; import cc.kune.common.client.actions.ui.descrip.GuiActionDescProviderCollection; import cc.kune.common.client.actions.ui.descrip.GuiActionDescrip; +import cc.kune.common.client.log.Log; import cc.kune.core.client.registry.IdGenerator; import cc.kune.core.shared.domain.ContentStatus; import cc.kune.core.shared.domain.utils.AccessRights; @@ -122,8 +123,7 @@ final GuiActionDescrip descrip = descripProv.get(); final AbstractAction action = descrip.getAction(); if (action instanceof RolAction) { - // Log.debug("Must add action?: " + action + ", isLogged: " + isLogged + - // ", r: " + rights); + Log.debug("Must add action?: " + action + ", isLogged: " + isLogged + ", r: " + rights); if (mustAdd((RolAction) action, isLogged, rights)) { add(collection, descrip, targetItem); } Modified: trunk/src/main/java/cc/kune/core/server/KuneContainerListener.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/KuneContainerListener.java 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/src/main/java/cc/kune/core/server/KuneContainerListener.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -43,29 +43,12 @@ this.logger = logger; } - // - // private void configureLog4j() { - // try { - // final Properties properties = new Properties(); - // // FIXME this should be optional - // final InputStream input = - // Thread.currentThread().getContextClassLoader().getResourceAsStream( - // "log4j.properties"); - // // "log4j.dev.properties"); - // properties.load(input); - // PropertyConfigurator.configure(properties); - // } catch (final IOException e) { - // e.printStackTrace(); - // } - // } - public Logger getLogger() { return logger; } @Override public void start() { - // configureLog4j(); logger.log(Level.INFO, "Kune persistence starting"); persistenceService.start(); logger.log(Level.INFO, "Kune persistence started"); Modified: trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -188,7 +188,7 @@ bind(EntityLogoUploadManager.class).in(Singleton.class); bind(EntityLogoDownloadManager.class).in(Singleton.class); bind(ParticipantUtils.class).in(Singleton.class); - bind(UsersOnline.class).to(UserSessionManager.class).in(Singleton.class); + bind(UsersOnline.class).to(UserSessionManager.class).asEagerSingleton(); requestStaticInjection(AccessRightsUtils.class); bind(WaveEmailNotifier.class).in(Singleton.class); bind(PendingNotificationSender.class).in(Singleton.class); Modified: trunk/src/main/java/cc/kune/core/server/UserSession.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/UserSession.java 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/src/main/java/cc/kune/core/server/UserSession.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -30,6 +30,7 @@ private String userHash; private Long userId; + @Deprecated private String userName; public UserSession() { @@ -43,6 +44,7 @@ return userId; } + @Deprecated public String getUserName() { return userName; } @@ -55,6 +57,7 @@ this.userId = userId; } + @Deprecated public void setUserName(final String userName) { this.userName = userName; } Modified: trunk/src/main/java/cc/kune/core/server/UserSessionManager.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/UserSessionManager.java 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/src/main/java/cc/kune/core/server/UserSessionManager.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -22,6 +22,9 @@ import java.util.HashSet; import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.eclipse.jetty.server.SessionManager; import org.eclipse.jetty.server.session.HashSessionManager; import cc.kune.core.server.manager.UserManager; @@ -32,23 +35,29 @@ import com.google.inject.Provider; import com.google.inject.Singleton; +@LogThis @Singleton public class UserSessionManager implements UsersOnline { + public static final Log LOG = LogFactory.getLog(UserSessionManager.class); + private final Set<String> logins; private final UserManager manager; private final Provider<UserSession> userSessionProv; @Inject public UserSessionManager(final UserManager manager, final Provider<UserSession> userSessionProv, - final org.eclipse.jetty.server.SessionManager jettySessionManager) { + final SessionManager jettySessionManager, final UserSessionMonitor userSessionMonitor) { this.manager = manager; this.userSessionProv = userSessionProv; final HashSessionManager hSessionManager = (HashSessionManager) jettySessionManager; - // hSessionManager.setMaxInactiveInterval(-1); + hSessionManager.setMaxInactiveInterval(-1); + hSessionManager.setSavePeriod(5); + hSessionManager.addEventListener(userSessionMonitor); + LOG.debug(String.format("User sessions: %d", hSessionManager.getSessions())); + LOG.debug(String.format("User sessions total: %d", hSessionManager.getSessionsTotal())); // this prevent saving the session?? // hSessionManager.setUsingCookies(true); - hSessionManager.setSavePeriod(5); // For now the implementation of this can be very inaccurate (if we // login/logout several times with different clients) and not scalable // (stored in a MAP). Possible fix, to use jabber status @@ -100,7 +109,6 @@ logins.remove(getUserLoggedShortName()); } getUserSession().setUserId(null); - getUserSession().setUserName(null); getUserSession().setHash(null); } Added: trunk/src/main/java/cc/kune/core/server/UserSessionMonitor.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/UserSessionMonitor.java (rev 0) +++ trunk/src/main/java/cc/kune/core/server/UserSessionMonitor.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -0,0 +1,49 @@ +/* + * + * Copyright (C) 2007-2012 The kune development team (see CREDITS for details) + * This file is part of kune. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +package cc.kune.core.server; + +import javax.servlet.http.HttpSessionEvent; +import javax.servlet.http.HttpSessionListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.google.inject.Singleton; + +@Singleton +public class UserSessionMonitor implements HttpSessionListener { + public static final Log LOG = LogFactory.getLog(UserSessionMonitor.class); + + @Override + public void sessionCreated(final HttpSessionEvent event) { + LOG.debug(String.format("Session created (with max inactive: %d)", + event.getSession().getMaxInactiveInterval()), new Throwable()); + // event.getSession().getServletContext().getContextPath(), + } + + @Override + public void sessionDestroyed(final HttpSessionEvent event) { + LOG.debug(String.format("Session destroyed (with max inactive: %d)", + event.getSession().getMaxInactiveInterval()), new Throwable()); + // event.getSession().getServletContext().getContextPath(), + } + +} Modified: trunk/src/main/java/cc/kune/core/server/auth/AuthenticatedMethodInterceptor.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/auth/AuthenticatedMethodInterceptor.java 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/src/main/java/cc/kune/core/server/auth/AuthenticatedMethodInterceptor.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -51,34 +51,46 @@ final String userHash = arguments[0] == null || arguments[0].equals("null") ? null : (String) arguments[0]; - LOG.info("Method: " + invocation.getMethod().getName()); + final String method = invocation.getMethod().getName(); + logLine(method, userHash, true); + LOG.info("Method: " + method); LOG.info("Userhash received: " + userHash); - LOG.info("--------------------------------------------------------------------------------"); final Authenticated authAnnotation = invocation.getStaticPart().getAnnotation(Authenticated.class); final boolean mandatory = authAnnotation.mandatory(); if (userHash == null && mandatory) { + LOG.info("Not logged in server and mandatory"); + logLine(method, userHash, false); throw new UserMustBeLoggedException(); } else if (userSessionManager.isUserNotLoggedIn() && mandatory) { LOG.info("Session expired (not logged in server and mandatory)"); + logLine(method, userHash, false); throw new SessionExpiredException(); } else if (userSessionManager.isUserNotLoggedIn() && userHash == null) { // Ok, do nothing } else if (userSessionManager.isUserNotLoggedIn() && userHash != null) { LOG.info("Session expired (not logged in server)"); + logLine(method, userHash, false); throw new SessionExpiredException(); } else if (!userSessionManager.getHash().equals(userHash)) { final String serverHash = userSessionManager.getHash(); userSessionManager.logout(); LOG.info("Session expired (userHash: " + userHash + " different from server hash: " + serverHash + ")"); + logLine(method, userHash, false); throw new SessionExpiredException(); } final Object result = invocation.proceed(); + logLine(method, userHash, false); return result; } finally { } } + private void logLine(final String method, final String userHash, final boolean start) { + LOG.info(new StringBuffer().append("----- ").append(start ? "Starting" : "Ending").append( + " method: ").append(method).append("- userhash: ").append(userHash).append(" -----")); + } + } Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/GroupManagerDefault.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/manager/impl/GroupManagerDefault.java 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/src/main/java/cc/kune/core/server/manager/impl/GroupManagerDefault.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -284,6 +284,7 @@ final SocialNetwork network = setSocialNetwork(group, publicVisibility, snVisibility); if (!group.getGroupType().equals(GroupType.ORPHANED_PROJECT)) { network.addAdmin(userGroup); + network.getAccessLists().getEditors().setMode(GroupListMode.NOBODY); } } @@ -346,7 +347,6 @@ final SocialNetworkVisibility snVisibility) { final SocialNetwork network = group.getSocialNetwork(); final AccessLists lists = network.getAccessLists(); - lists.getEditors().setMode(GroupListMode.NOBODY); lists.getViewers().setMode(publicVisibility); network.setVisibility(snVisibility); return network; Modified: trunk/src/main/java/cc/kune/core/server/state/StateServiceDefault.java =================================================================== --- trunk/src/main/java/cc/kune/core/server/state/StateServiceDefault.java 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/src/main/java/cc/kune/core/server/state/StateServiceDefault.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -133,7 +133,8 @@ String waveUrl = null; try { waveUrl = TextUtils.generateHtmlLink( - JavaWaverefEncoder.encodeToUriPathSegment(JavaWaverefEncoder.decodeWaveRefFromPath(waveRef)), + "#" + + JavaWaverefEncoder.encodeToUriPathSegment(JavaWaverefEncoder.decodeWaveRefFromPath(waveRef)), waveRef, false); } catch (final InvalidWaveRefException invalidEx) { } Modified: trunk/src/main/java/cc/kune/wave/client/WaveStatusIndicator.java =================================================================== --- trunk/src/main/java/cc/kune/wave/client/WaveStatusIndicator.java 2012-04-08 19:05:06 UTC (rev 1827) +++ trunk/src/main/java/cc/kune/wave/client/WaveStatusIndicator.java 2012-04-09 07:04:40 UTC (rev 1828) @@ -56,13 +56,14 @@ public void onNetworkStatus(final NetworkStatusEvent event) { switch (event.getStatus()) { case CONNECTED: + break; + case RECONNECTED: session.check(new AsyncCallbackSimple<Void>() { @Override public void onSuccess(final Void result) { goOnline(); } }); - case RECONNECTED: break; case DISCONNECTED: NotifyUser.showProgress(i18n.t("Connecting"));