extending userHelper by method to access the current user
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Mon, 19 Mar 2018 11:27:10 +0000 (12:27 +0100)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Mon, 19 Mar 2018 11:27:10 +0000 (12:27 +0100)
src/main/java/eu/etaxonomy/cdm/service/CdmUserHelper.java
src/main/java/eu/etaxonomy/cdm/vaadin/security/UserHelper.java

index 734639943b0ce89b5aff1e0bb61ee8b9441e55df..27e60bc12dd6e4fb86e993e8dea493659d823ce8 100644 (file)
@@ -93,6 +93,15 @@ public class CdmUserHelper extends VaadinUserHelper implements Serializable {
                 && authentication instanceof AnonymousAuthenticationToken;
     }
 
+    @Override
+    public User user() {
+        Authentication authentication = getAuthentication();
+        if(authentication != null && authentication.getPrincipal() != null) {
+            return (User) authentication.getPrincipal();
+        }
+        return null;
+    }
+
     @Override
     public String userName() {
         Authentication authentication = getAuthentication();
index cfd4ecff334c5ee8281f9bb469162327699d983f..c66d5e194e762aeeff175349ec6a7cdf4e5db281 100644 (file)
@@ -13,6 +13,7 @@ import java.util.EnumSet;
 import com.vaadin.server.VaadinSession;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
 
@@ -48,6 +49,8 @@ public interface UserHelper {
 
     boolean userIsAdmin();
 
+    User user();
+
     String userName();
 
     boolean userIsAnnonymous();