diff --git a/src/main/java/cokr/xit/base/security/SecuredUserInfo.java b/src/main/java/cokr/xit/base/security/SecuredUserInfo.java index 0c67f63..8696e2a 100644 --- a/src/main/java/cokr/xit/base/security/SecuredUserInfo.java +++ b/src/main/java/cokr/xit/base/security/SecuredUserInfo.java @@ -60,6 +60,20 @@ public class SecuredUserInfo extends UserInfo implements UserDetails { private List authorities; private boolean sealed; + @Override + public String getId(Object auth) { + UserInfo userInfo = null; + if (auth instanceof Authentication) { + Object obj = ((Authentication)auth).getPrincipal(); + if (obj instanceof UserInfo) + userInfo = (UserInfo)obj; + } + if (userInfo == null) + throw new RuntimeException(String.format("Unable to get a UserInfo from %s", auth)); + + return userInfo.getId(); + } + @Override public List getAuthorities() { return authorities != null ? authorities : Collections.emptyList();