Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 294487e8
authored
Apr 15, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sessionlist with invalidated sessions
1 parent
b10e766e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
75 deletions
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/HttpSessionWrapper.java
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/HttpSessionWrapper.java
View file @
294487e
...
@@ -26,14 +26,12 @@ import java.util.Enumeration;
...
@@ -26,14 +26,12 @@ import java.util.Enumeration;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
import
javax.servlet.ServletContext
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSessionContext
;
import
fi.codecrew.moya.beans.SessionMgmtBeanLocal
;
import
fi.codecrew.moya.beans.SessionMgmtBeanLocal
;
import
fi.codecrew.moya.beans.SessionMgmtBeanLocal.UserContainer
;
import
fi.codecrew.moya.beans.SessionMgmtBeanLocal.UserContainer
;
public
class
HttpSessionWrapper
implements
HttpSession
public
class
HttpSessionWrapper
{
{
private
final
HttpSession
session
;
private
final
HttpSession
session
;
private
final
String
hostname
;
private
final
String
hostname
;
...
@@ -46,113 +44,82 @@ public class HttpSessionWrapper implements HttpSession
...
@@ -46,113 +44,82 @@ public class HttpSessionWrapper implements HttpSession
this
.
session
=
session
;
this
.
session
=
session
;
}
}
@Override
public
Object
getAttribute
(
String
attr
)
{
public
Object
getAttribute
(
String
attr
)
{
return
session
.
getAttribute
(
attr
);
try
{
return
session
.
getAttribute
(
attr
);
}
catch
(
Exception
e
)
{
// Invalidated session;
}
return
null
;
}
}
@Override
public
Enumeration
<
String
>
getAttributeNames
()
{
public
Enumeration
<
String
>
getAttributeNames
()
{
return
session
.
getAttributeNames
();
try
{
return
session
.
getAttributeNames
();
}
catch
(
Exception
e
)
{
// Invalidated session;
}
return
null
;
}
}
@Override
public
Long
getCreationTime
()
{
public
long
getCreationTime
()
{
try
{
return
session
.
getCreationTime
();
return
session
.
getCreationTime
();
}
catch
(
Exception
e
)
{
// Invalidated session;
}
return
null
;
}
}
public
Date
getCreationDateTime
()
{
public
Date
getCreationDateTime
()
{
Date
ret
=
null
;
try
{
try
{
ret
=
new
Date
(
session
.
getCreationTime
());
ret
urn
new
Date
(
session
.
getCreationTime
());
}
catch
(
Exception
t
)
{
}
catch
(
Exception
t
)
{
ret
=
null
;
}
}
return
ret
;
return
null
;
}
}
@Override
public
String
getId
()
{
public
String
getId
()
{
return
session
.
getId
();
return
session
.
getId
();
}
}
@Override
public
Long
getLastAccessedTime
()
{
public
long
getLastAccessedTime
()
{
return
session
.
getLastAccessedTime
();
Long
ret
=
null
;
try
{
ret
=
session
.
getLastAccessedTime
();
}
catch
(
Exception
e
)
{
ret
=
null
;
}
return
ret
;
}
}
public
Date
getLastAccessedDateTime
()
{
public
Date
getLastAccessedDateTime
()
{
Date
ret
=
null
;
Date
ret
=
null
;
try
{
try
{
ret
=
new
Date
(
session
.
getLastAccessedTime
());
Long
t
=
session
.
getLastAccessedTime
();
if
(
t
!=
null
)
{
ret
=
new
Date
(
t
);
}
}
catch
(
Exception
t
)
{
}
catch
(
Exception
t
)
{
ret
=
null
;
ret
=
null
;
}
}
return
ret
;
return
ret
;
}
}
@Override
public
int
getMaxInactiveInterval
()
{
public
int
getMaxInactiveInterval
()
{
return
session
.
getMaxInactiveInterval
();
return
session
.
getMaxInactiveInterval
();
}
}
@Override
public
ServletContext
getServletContext
()
{
return
session
.
getServletContext
();
}
@Override
public
HttpSessionContext
getSessionContext
()
{
return
session
.
getSessionContext
();
}
@Override
public
Object
getValue
(
String
arg0
)
{
return
session
.
getValue
(
arg0
);
}
@Override
public
String
[]
getValueNames
()
{
return
session
.
getValueNames
();
}
@Override
public
void
invalidate
()
{
public
void
invalidate
()
{
session
.
invalidate
();
session
.
invalidate
();
}
}
@Override
public
boolean
isNew
()
{
public
boolean
isNew
()
{
return
session
.
isNew
();
return
session
.
isNew
();
}
}
@Override
public
void
putValue
(
String
arg0
,
Object
arg1
)
{
session
.
putValue
(
arg0
,
arg1
);
}
@Override
public
void
removeAttribute
(
String
arg0
)
{
session
.
removeAttribute
(
arg0
);
}
@Override
public
void
removeValue
(
String
arg0
)
{
session
.
removeValue
(
arg0
);
}
@Override
public
void
setAttribute
(
String
arg0
,
Object
arg1
)
{
session
.
setAttribute
(
arg0
,
arg1
);
}
@Override
public
void
setMaxInactiveInterval
(
int
arg0
)
{
session
.
setMaxInactiveInterval
(
arg0
);
}
public
static
List
<
HttpSessionWrapper
>
wrap
(
Set
<
HttpSession
>
sessions
,
SessionMgmtBeanLocal
sessionMgmt
)
{
public
static
List
<
HttpSessionWrapper
>
wrap
(
Set
<
HttpSession
>
sessions
,
SessionMgmtBeanLocal
sessionMgmt
)
{
List
<
HttpSessionWrapper
>
ret
=
new
ArrayList
<>();
List
<
HttpSessionWrapper
>
ret
=
new
ArrayList
<>();
for
(
HttpSession
s
:
sessions
)
{
for
(
HttpSession
s
:
sessions
)
{
...
@@ -178,12 +145,15 @@ public class HttpSessionWrapper implements HttpSession
...
@@ -178,12 +145,15 @@ public class HttpSessionWrapper implements HttpSession
return
hostname
;
return
hostname
;
}
}
private
static
class
LastSeenComparator
implements
Comparator
<
HttpSessionWrapper
>
private
static
class
LastSeenComparator
implements
Comparator
<
HttpSessionWrapper
>
{
{
@Override
public
int
compare
(
HttpSessionWrapper
o1
,
HttpSessionWrapper
o2
)
{
public
int
compare
(
HttpSessionWrapper
o1
,
HttpSessionWrapper
o2
)
{
return
Long
.
compare
(
o2
.
getLastAccessedTime
(),
o1
.
getLastAccessedTime
());
Long
t2
=
o2
.
getLastAccessedTime
();
Long
t1
=
o1
.
getLastAccessedTime
();
if
(
t2
==
t1
)
{
return
0
;
}
return
(
t2
==
null
||
t1
==
null
)
?
(
t2
==
null
?
-
1
:
1
)
:
Long
.
compare
(
t2
,
t1
);
}
}
}
}
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
View file @
294487e
...
@@ -541,6 +541,7 @@ global.notauthorized = You don't have enough rights to enter this site.
...
@@ -541,6 +541,7 @@ global.notauthorized = You don't have enough rights to enter this site.
global.save
=
Save
global.save
=
Save
httpsession.creationTime
=
Created
httpsession.creationTime
=
Created
httpsession.hostname
=
Hostname
httpsession.invalidate
=
Invalidate
httpsession.invalidate
=
Invalidate
imagefile.description
=
Description
imagefile.description
=
Description
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
View file @
294487e
...
@@ -543,11 +543,12 @@ global.notauthorized = Sinulla ei ole riitt\u00E4vi\u00E4 oikeuksia t\u00E4lle s
...
@@ -543,11 +543,12 @@ global.notauthorized = Sinulla ei ole riitt\u00E4vi\u00E4 oikeuksia t\u00E4lle s
global.save
=
Tallenna
global.save
=
Tallenna
httpsession.creationTime
=
Luotu
httpsession.creationTime
=
Luotu
httpsession.hostname
=
Hostname
httpsession.id
=
ID
httpsession.id
=
ID
httpsession.invalidate
=
Mit
\u
00E4t
\u
00F6i
httpsession.invalidate
=
Mit
\u
00E4t
\u
00F6i
httpsession.invalidateSuccessfull
=
Sessio onnistuneesti mit
\u
FFFDt
\u
FFFD
ity
httpsession.invalidateSuccessfull
=
Sessio onnistuneesti mit
\u
00F6t
\u
00F6
ity
httpsession.isSessionNew
=
Uusi sessio
httpsession.isSessionNew
=
Uusi sessio
httpsession.lastAccessedTime
=
Viimeksi n
\u
FFFD
hty
httpsession.lastAccessedTime
=
Viimeksi n
\u
00E4
hty
httpsession.maxInactiveInterval
=
Aikakatkaisu (s)
httpsession.maxInactiveInterval
=
Aikakatkaisu (s)
httpsession.sessionHasExisted
=
Ollut elossa (s)
httpsession.sessionHasExisted
=
Ollut elossa (s)
httpsession.user
=
Tunnus
httpsession.user
=
Tunnus
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment