Commit 392bebc5 authored by Bruno Nocera Zanette's avatar Bruno Nocera Zanette
Browse files

Added methods to get logged-in user ID

Added methods to get logged-in user ID based on user's username that was used at log-in.
Signed-off-by: Bruno Nocera Zanette's avatarBruno Nocera Zanette <>
parent 0e450ce2
package br.ufpr.c3sl.sapos.models.util;
import br.ufpr.c3sl.sapos.models.scholar.Registration;
import br.ufpr.c3sl.sapos.models.util.LdapAttrProvider;
import java.util.Collection;
......@@ -45,6 +46,19 @@ public class KerberosAuthProvider implements UserDetailsService {
public static Collection<? extends GrantedAuthority> authAluno = AuthorityUtils
public static String getIdFromLoggedInStudent(){
return Registration.entityManager().createNativeQuery(
"SELECT from registration r, person p"+
" WHERE r.student ="+
" and p.user_name ="+"'"+getPersonUsername()+"'").getSingleResult().toString();
public static String getIdFromLoggedInProfessor(){
return Registration.entityManager().createNativeQuery(
"SELECT from person p"+
" WHERE p.user_name ="+"'"+getPersonUsername()+"'").getSingleResult().toString();
// This method is used to remove the suffix added by Kerberos
// By Kerberos's definition: krbPrincipalName = Username@Server
private static String removeKrbSuffix(String username){
Markdown is supported
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