aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/util/UserUtils.java
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-26 04:34:57 +0700
committerGravatar Alexander Alexeev2016-11-26 04:34:57 +0700
commit91a07facc6e4417810cebbfe017a4ac167ac13b1 (patch)
tree741b055031d63ea5ac0d4b33bc399d97e456b197 /juick-server/src/main/java/com/juick/util/UserUtils.java
parentb0d89589ae42ba9c099ef934c39bebc6b0a75f7f (diff)
some improvenments on user service
Diffstat (limited to 'juick-server/src/main/java/com/juick/util/UserUtils.java')
-rw-r--r--juick-server/src/main/java/com/juick/util/UserUtils.java5
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();
+ }
}