Ahoj,

na zjisteni prave prihlaseneho uzivatele v Acegi 0.83 pouzivam statickou metodu

public static User getLoggedUser() {

          Context context = ContextHolder.getContext();
          if (context != null) {
              if (context instanceof SecureContext) {
                  SecureContext secureContext = (SecureContext)context;
Authentication authentication = secureContext.getAuthentication();

                      if (authentication!=null) {
                          return (User)authentication.getPrincipal();
                      }
              }
          }
          return null;
  }

, kde trida User implementuje net.sf.acegisecurity.UserDetails

Hezky den

Petr



Burdik Petr napsal(a):

Ahojas,
resim problemek viz subjekt. Potrebuji v servletu zjistit jaky uzivatel prave v tu chvili provadi danou operaci. Jak to prosim resite - jestli to resite? Potrebuji jenom poresit prava k objektum ke kterym zrovna pristupuje. Uz jsem to mel vyresene jinak, ale rad bych pouzil acegi.

Pekne odpoledne
Pet


Odpovedet emailem