aboutsummaryrefslogtreecommitdiff
path: root/juick-spring-www/src/main/java/com/juick/www/entity
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-21 13:38:27 +0700
committerGravatar Vitaly Takmazov2016-11-23 13:03:05 +0300
commit771c27021c033f5b6b9a3d9fdcd4048f9d8023af (patch)
tree558442fc7e5244953a8acc7444fb5c9a764f646a /juick-spring-www/src/main/java/com/juick/www/entity
parente9aa20922c82bfad64adbcb6466ebdac23a84244 (diff)
spring-www project skeleton
Diffstat (limited to 'juick-spring-www/src/main/java/com/juick/www/entity')
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/entity/JuickUser.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/entity/JuickUser.java b/juick-spring-www/src/main/java/com/juick/www/entity/JuickUser.java
new file mode 100644
index 00000000..20d7889d
--- /dev/null
+++ b/juick-spring-www/src/main/java/com/juick/www/entity/JuickUser.java
@@ -0,0 +1,62 @@
+package com.juick.www.entity;
+
+import com.juick.User;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Created by aalexeev on 11/21/16.
+ */
+public class JuickUser implements UserDetails {
+ private static final GrantedAuthority ROLE_USER = new SimpleGrantedAuthority("ROLE_USER");
+
+ private final com.juick.User user;
+
+
+ public JuickUser(com.juick.User user) {
+ this.user = user;
+ }
+
+ @Override
+ public Collection<? extends GrantedAuthority> getAuthorities() {
+ return Collections.singletonList(ROLE_USER);
+ }
+
+ @Override
+ public String getPassword() {
+ return null;
+ }
+
+ @Override
+ public String getUsername() {
+ return user.getName();
+ }
+
+ @Override
+ public boolean isAccountNonExpired() {
+ return true;
+ }
+
+ @Override
+ public boolean isAccountNonLocked() {
+ return false;
+ }
+
+ @Override
+ public boolean isCredentialsNonExpired() {
+ return true;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return !user.isBanned();
+ }
+
+ public User getUser() {
+ return user;
+ }
+}