package nl.vpro.poel;

import nl.vpro.poel.domain.CurrentUser;
import org.springframework.security.cas.authentication.CasAuthenticationToken;
import org.springframework.security.core.userdetails.UserDetails;

import java.security.Principal;
import java.util.Optional;

public class UserUtil {

    public static Optional<CurrentUser> getCurrentUser(Principal principal) {
        if (principal instanceof CasAuthenticationToken) {
            UserDetails userDetails = ((CasAuthenticationToken)principal).getUserDetails();
            if (userDetails instanceof CurrentUser) {
                return Optional.of((CurrentUser) userDetails);
            }
        }
        return Optional.empty();
    }
}

@@ -16,16 +16,57 @@
 .poel;%0A%0A
+import lombok.experimental.UtilityClass;%0A
 import n
@@ -303,16 +303,30 @@
 ional;%0A%0A
+@UtilityClass%0A
 public c
@@ -357,15 +357,8 @@
 lic 
-static 
 Opti

Use Lombok's UtilityClass.