
com.evasion.plugin.security.dao.AuthorityDAO Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Plugin-Security Show documentation
Show all versions of Plugin-Security Show documentation
API de l'application modulaire evasion-en-ligne
The newest version!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.evasion.plugin.security.dao;
import com.evasion.dao.api.AbstractJPAGenericDAO;
import com.evasion.entity.security.Authority;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Query;
/**
*
* @author sebastien
*/
public class AuthorityDAO extends AbstractJPAGenericDAO {
/**
* Renvoi l'ensemble des roles affecté à l'utilisateur,
* ainsi que ceux affecté au groupe dont il dépend.
* @param userName identifant de l'utilisateur.
* @return listes des roles lui étant affecté .
*/
public List getAllAuthorityByUser(String userName) {
List resultGroups;
List
resultUser;
Query queryGroups = getEntityManager().createQuery("select distinct a "
+ "FROM User u join u.groupsInternal g join g.authoritiesInternal a "
+ "where u.username=:username "
);
queryGroups.setParameter("username", userName);
resultGroups = queryGroups.getResultList();
Query queryUser = getEntityManager().createQuery("select distinct a "
+ "FROM User u join u.authoritiesInternal a "
+ "where u.username=:username"
);
queryUser.setParameter("username", userName);
resultUser = queryUser.getResultList();
List result = new ArrayList();
result.addAll(resultGroups);
result.addAll(resultUser);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy