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
d6c72aec
Commit
d6c72aec
authored
10 years ago
by
Paul-Christian Volkmer
Browse files
Options
Downloads
Patches
Plain Diff
Explicit handling of OAuth accounts
parent
f9288e34
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/thm/arsnova/security/ApplicationPermissionEvaluator.java
+26
-0
26 additions, 0 deletions
.../thm/arsnova/security/ApplicationPermissionEvaluator.java
with
26 additions
and
0 deletions
src/main/java/de/thm/arsnova/security/ApplicationPermissionEvaluator.java
+
26
−
0
View file @
d6c72aec
...
...
@@ -2,13 +2,19 @@ package de.thm.arsnova.security;
import
java.io.Serializable
;
import
org.scribe.up.profile.facebook.FacebookProfile
;
import
org.scribe.up.profile.google.Google2Profile
;
import
org.scribe.up.profile.twitter.TwitterProfile
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.PermissionEvaluator
;
import
org.springframework.security.authentication.AnonymousAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
com.github.leleuj.ss.oauth.client.authentication.OAuthAuthenticationToken
;
import
de.thm.arsnova.dao.IDatabaseDao
;
import
de.thm.arsnova.entities.Session
;
import
de.thm.arsnova.entities.User
;
import
de.thm.arsnova.exceptions.ForbiddenException
;
import
de.thm.arsnova.exceptions.UnauthorizedException
;
...
...
@@ -52,6 +58,26 @@ public class ApplicationPermissionEvaluator implements PermissionEvaluator {
throw
new
UnauthorizedException
();
}
if
(
authentication
instanceof
OAuthAuthenticationToken
)
{
User
user
=
null
;
OAuthAuthenticationToken
token
=
(
OAuthAuthenticationToken
)
authentication
;
if
(
token
.
getUserProfile
()
instanceof
Google2Profile
)
{
Google2Profile
profile
=
(
Google2Profile
)
token
.
getUserProfile
();
user
=
new
User
(
profile
);
}
else
if
(
token
.
getUserProfile
()
instanceof
TwitterProfile
)
{
TwitterProfile
profile
=
(
TwitterProfile
)
token
.
getUserProfile
();
user
=
new
User
(
profile
);
}
else
if
(
token
.
getUserProfile
()
instanceof
FacebookProfile
)
{
FacebookProfile
profile
=
(
FacebookProfile
)
token
.
getUserProfile
();
user
=
new
User
(
profile
);
}
if
(
user
!=
null
)
{
return
user
.
getUsername
();
}
}
return
authentication
.
getName
();
}
}
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