Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
Paul-Christian Volkmer
ARSnova Backend
Commits
73cdd975
Commit
73cdd975
authored
11 years ago
by
Paul-Christian Volkmer
Browse files
Options
Downloads
Patches
Plain Diff
Direct use of userSessionService instead of AOP solution
parent
f9cd240f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/thm/arsnova/aop/UserSessionAspect.java
+0
-33
0 additions, 33 deletions
src/main/java/de/thm/arsnova/aop/UserSessionAspect.java
src/main/java/de/thm/arsnova/controller/LoginController.java
+9
-5
9 additions, 5 deletions
src/main/java/de/thm/arsnova/controller/LoginController.java
with
9 additions
and
38 deletions
src/main/java/de/thm/arsnova/aop/UserSessionAspect.java
+
0
−
33
View file @
73cdd975
...
...
@@ -8,8 +8,6 @@ import org.aspectj.lang.annotation.Aspect;
import
org.springframework.beans.factory.annotation.Autowired
;
import
de.thm.arsnova.entities.Session
;
import
de.thm.arsnova.events.Publisher
;
import
de.thm.arsnova.services.IUserService
;
import
de.thm.arsnova.services.UserSessionService
;
@Aspect
...
...
@@ -18,12 +16,6 @@ public class UserSessionAspect {
@Autowired
private
UserSessionService
userSessionService
;
@Autowired
private
IUserService
userService
;
@Autowired
private
Publisher
publisher
;
/** Sets current user and ARSnova session in session scoped UserSessionService
*
* @param jp
...
...
@@ -35,7 +27,6 @@ public class UserSessionAspect {
returning
=
"session"
)
public
final
void
joinSessionAdvice
(
final
JoinPoint
jp
,
final
String
keyword
,
final
Session
session
)
{
userSessionService
.
setUser
(
userService
.
getCurrentUser
());
userSessionService
.
setSession
(
session
);
}
...
...
@@ -54,28 +45,4 @@ public class UserSessionAspect {
userSessionService
.
setSession
(
session
);
userSessionService
.
setSocketId
(
socketId
);
}
/** Sets current user, ARSnova session and websocket session ID in session scoped UserSessionService
*
* @param jp
* @param keyword
* @param socketId
* @param session
*/
@AfterReturning
(
pointcut
=
"execution(public * de.thm.arsnova.controller.LoginController.doLogin(..)) "
+
"&& args(type, guestName, forcedReferer, successUrl, failureUrl, role, ..)"
)
public
final
void
doLogin
(
final
JoinPoint
jp
,
final
String
type
,
final
String
guestName
,
final
String
forcedReferer
,
final
String
successUrl
,
final
String
failureUrl
,
final
UserSessionService
.
Role
role
)
{
userSessionService
.
setRole
(
role
);
userSessionService
.
setUser
(
userService
.
getCurrentUser
());
}
}
This diff is collapsed.
Click to expand it.
src/main/java/de/thm/arsnova/controller/LoginController.java
+
9
−
5
View file @
73cdd975
...
...
@@ -94,6 +94,8 @@ public class LoginController extends AbstractController {
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
IOException
,
ServletException
{
userSessionService
.
setRole
(
role
);
String
referer
=
request
.
getHeader
(
"referer"
);
if
(
null
!=
forcedReferer
&&
null
!=
referer
&&
!
UrlUtils
.
isAbsoluteUrl
(
referer
))
{
/* Use a url from a request parameter as referer as long as the url is not absolute (to prevent
...
...
@@ -111,17 +113,19 @@ public class LoginController extends AbstractController {
null
==
failureUrl
?
referer
:
failureUrl
);
View
result
=
null
;
if
(
"cas"
.
equals
(
type
))
{
casEntryPoint
.
commence
(
request
,
response
,
null
);
}
else
if
(
"twitter"
.
equals
(
type
))
{
String
authUrl
=
twitterProvider
.
getAuthorizationUrl
(
new
HttpUserSession
(
request
));
re
turn
new
RedirectView
(
authUrl
);
re
sult
=
new
RedirectView
(
authUrl
);
}
else
if
(
"facebook"
.
equals
(
type
))
{
String
authUrl
=
facebookProvider
.
getAuthorizationUrl
(
new
HttpUserSession
(
request
));
re
turn
new
RedirectView
(
authUrl
);
re
sult
=
new
RedirectView
(
authUrl
);
}
else
if
(
"google"
.
equals
(
type
))
{
String
authUrl
=
googleProvider
.
getAuthorizationUrl
(
new
HttpUserSession
(
request
));
re
turn
new
RedirectView
(
authUrl
);
re
sult
=
new
RedirectView
(
authUrl
);
}
else
if
(
"guest"
.
equals
(
type
))
{
List
<
GrantedAuthority
>
authorities
=
new
ArrayList
<
GrantedAuthority
>();
authorities
.
add
(
new
SimpleGrantedAuthority
(
"ROLE_GUEST"
));
...
...
@@ -140,9 +144,9 @@ public class LoginController extends AbstractController {
SecurityContextHolder
.
getContext
().
setAuthentication
(
token
);
request
.
getSession
(
true
).
setAttribute
(
HttpSessionSecurityContextRepository
.
SPRING_SECURITY_CONTEXT_KEY
,
SecurityContextHolder
.
getContext
());
re
turn
new
RedirectView
(
null
==
successUrl
?
referer
+
"#auth/checkLogin"
:
successUrl
);
re
sult
=
new
RedirectView
(
null
==
successUrl
?
referer
+
"#auth/checkLogin"
:
successUrl
);
}
return
n
ul
l
;
return
res
ul
t
;
}
@RequestMapping
(
value
=
{
"/auth/"
,
"/whoami"
},
method
=
RequestMethod
.
GET
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment