Web : correction de la generation des droits pour les utilisateur dans UserDetails.
Rafraichissement des credentials lors du changement de conference Integration d'Acegi dans la gestion de l'utilisateur courant de SessionService
This commit is contained in:
@@ -96,7 +96,7 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schem
|
||||
<value>
|
||||
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
|
||||
PATTERN_TYPE_APACHE_ANT
|
||||
/secure/**=ROLE_ADMIN,ROLE_AUTHOR,ROLE_MEMBER
|
||||
/secure/**=ROLE_ADMIN,ROLE_AUTHOR,ROLE_PCMEMBER
|
||||
/secure/**=IS_AUTHENTICATED_REMEMBERED
|
||||
/**=IS_AUTHENTICATED_ANONYMOUSLY
|
||||
</value>
|
||||
|
||||
@@ -18,6 +18,10 @@ menu.pcmember.title=PC Member
|
||||
menu.referee.title=Referee
|
||||
menu.author.title=Author
|
||||
menu.anonymous.title=Menu
|
||||
CHAIRMAN=Chairman
|
||||
PCMEMBER=PC Member
|
||||
REFEREE=Referee
|
||||
AUTHOR=Author
|
||||
|
||||
###################
|
||||
# REGISTRATION USER
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- AUTHOR MENU : ROLE_CHAIRMAN -->
|
||||
<!-- AUTHOR MENU : CHAIRMAN -->
|
||||
<authz:authorize ifAllGranted="ROLE_CHAIRMAN">
|
||||
<div id="mainmenubloc">
|
||||
<h4><fmt:message key="menu.chairman.title" /></h4>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<head></head>
|
||||
<body>
|
||||
|
||||
Firstname Lastname <b>(<authz:authentication operation="username"></authz:authentication>)</b><br />
|
||||
${ currentUser.firstName } ${ currentUser.lastName } <b>(<authz:authentication operation="username"></authz:authentication>)</b><br />
|
||||
You currently follow <b>4</b> conferences<br />
|
||||
You have the following rights : <b>Author, Chairman, PC Member</b><br />
|
||||
<a href="#">Change my profile</a><br />
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
maxime=maxime,ROLE_AUTHOR,ROLE_PCMEMBER,ROLE_CHAIRMAN,ROLE_REFEREE
|
||||
fred=fred,ROLE_MEMBER
|
||||
jialin=jialin,ROLE_ADMIN
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.yacos.auth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.acegisecurity.GrantedAuthority;
|
||||
import org.acegisecurity.GrantedAuthorityImpl;
|
||||
@@ -57,7 +56,7 @@ public class UserDetails implements org.acegisecurity.userdetails.UserDetails {
|
||||
}
|
||||
|
||||
for(int i=0;i<rolesList.size();i++){
|
||||
authorities[i] = new GrantedAuthorityImpl(rolesList.get(i).getType().name());
|
||||
authorities[i] = new GrantedAuthorityImpl("ROLE_"+rolesList.get(i).getType().name());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,11 @@ import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.acegisecurity.Authentication;
|
||||
import org.acegisecurity.context.SecurityContextHolder;
|
||||
import org.acegisecurity.providers.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
import org.yacos.auth.UserDetailsService;
|
||||
import org.yacos.core.conferences.Conference;
|
||||
import org.yacos.core.conferences.IConferenceManager;
|
||||
import org.yacos.core.users.IUserManager;
|
||||
@@ -101,6 +105,11 @@ public class SessionService {
|
||||
WebUtils.setSessionAttribute(request, "currentConferenceId", currentConferenceId);
|
||||
currentConference = conferenceManager.getConference(currentConferenceId);
|
||||
request.setAttribute("currentConference", currentConference);
|
||||
// Refreshing user credentials
|
||||
Authentication currentAuthentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
|
||||
authProvider.setUserDetailsService(new UserDetailsService());
|
||||
SecurityContextHolder.getContext().setAuthentication(authProvider.authenticate(currentAuthentication));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,6 +146,7 @@ public class SessionService {
|
||||
* @param request The current HTTP request object, necessary for session operations
|
||||
* @param currentUser The new current user to set
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCurrentUser(User currentUser) {
|
||||
this.currentUser = currentUser;
|
||||
this.setCurrentUserLogin(currentUser.getLogin());
|
||||
@@ -147,6 +157,7 @@ public class SessionService {
|
||||
* @param request The current HTTP request object, necessary for session operations
|
||||
* @param login The new current user login
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCurrentUserLogin(String login) {
|
||||
WebUtils.setSessionAttribute(request, "currentUserLogin", login);
|
||||
currentUser = userManager.getUser(login);
|
||||
@@ -161,9 +172,8 @@ public class SessionService {
|
||||
* @return The current user login
|
||||
*/
|
||||
public String getCurrentUserLogin(){
|
||||
// Retrieve the login from the session
|
||||
String login = (String) WebUtils.getSessionAttribute(request, "currentUserLogin");
|
||||
return login;
|
||||
// Retrieve the login from the acegi security session
|
||||
return SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +190,7 @@ public class SessionService {
|
||||
}
|
||||
|
||||
// Check if the user object is already in cache
|
||||
if(currentUser == null || (this.getCurrentUser().getLogin().equals(login)) ){
|
||||
if(currentUser == null || (currentUser.getLogin().equals(login)) ){
|
||||
// Checks login for validity
|
||||
if(login == null || login.equals("")){
|
||||
currentUser = null;
|
||||
|
||||
Reference in New Issue
Block a user