diff options
Diffstat (limited to 'juick-server/src/main/java/com/juick/util')
-rw-r--r-- | juick-server/src/main/java/com/juick/util/UserUtils.java | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/util/UserUtils.java b/juick-server/src/main/java/com/juick/util/UserUtils.java index 611a3b15..372dd502 100644 --- a/juick-server/src/main/java/com/juick/util/UserUtils.java +++ b/juick-server/src/main/java/com/juick/util/UserUtils.java @@ -1,5 +1,6 @@ package com.juick.util; +import java.security.Principal; import java.util.Random; /** @@ -24,4 +25,8 @@ public class UserUtils { public static boolean checkUserNameValid(final String uname) { return uname != null && uname.length() >= 2 && uname.length() <= 16 && uname.matches("[a-zA-Z0-9\\-]+"); } + + public static String getUsername(final Principal principal, final String defaultUsername) { + return principal == null ? defaultUsername : principal.getName(); + } } |