Skip to content
Snippets Groups Projects
Commit 5477ce44 authored by Julian Hochstetter's avatar Julian Hochstetter
Browse files

Task #3860: SessionService should utilize UserService

parent ceeac34d
Branches
Tags
No related merge requests found
...@@ -27,8 +27,8 @@ import java.util.HashMap; ...@@ -27,8 +27,8 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
...@@ -40,7 +40,6 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -40,7 +40,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -52,6 +51,7 @@ import com.fourspaces.couchdb.ViewResults; ...@@ -52,6 +51,7 @@ import com.fourspaces.couchdb.ViewResults;
import de.thm.arsnova.entities.Feedback; import de.thm.arsnova.entities.Feedback;
import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.User;
import de.thm.arsnova.socket.ARSnovaSocketIOServer; import de.thm.arsnova.socket.ARSnovaSocketIOServer;
@Service @Service
...@@ -380,12 +380,10 @@ public class SessionService implements ISessionService { ...@@ -380,12 +380,10 @@ public class SessionService implements ISessionService {
} }
private String actualUserName() { private String actualUserName() {
try { Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); User user = userService.getUser(authentication);
User user = (User) authentication.getPrincipal(); if(user == null) return null;
return user.getUsername(); return user.getUsername();
} catch (ClassCastException e) {}
return null;
} }
@Override @Override
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment