aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-12-12 20:58:12 +0700
committerGravatar Vitaly Takmazov2016-12-12 22:49:47 +0300
commit415b0ec7da02c07aad8fe85cfe0610ba9f4e5bd4 (patch)
treeb7de01f7925a65a6b569da5e8036552cc31a470c /juick-server/src/main
parent59fd361edab0f28991e9ded0c87ed70b7011001c (diff)
using thymeleaf spring security extension
Diffstat (limited to 'juick-server/src/main')
-rw-r--r--juick-server/src/main/java/com/juick/server/security/entities/AnonymUser.java (renamed from juick-server/src/main/java/com/juick/entity/AnonymUser.java)3
-rw-r--r--juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java18
-rw-r--r--juick-server/src/main/java/com/juick/util/UserUtils.java2
3 files changed, 17 insertions, 6 deletions
diff --git a/juick-server/src/main/java/com/juick/entity/AnonymUser.java b/juick-server/src/main/java/com/juick/server/security/entities/AnonymUser.java
index ad14dd30..2cc692a2 100644
--- a/juick-server/src/main/java/com/juick/entity/AnonymUser.java
+++ b/juick-server/src/main/java/com/juick/server/security/entities/AnonymUser.java
@@ -1,4 +1,4 @@
-package com.juick.entity;
+package com.juick.server.security.entities;
import com.juick.User;
@@ -8,7 +8,6 @@ import com.juick.User;
public final class AnonymUser extends User {
public static final AnonymUser INSTANCE = new AnonymUser();
-
private AnonymUser() {
super.setUid(getUid());
super.setName(getName());
diff --git a/juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java b/juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java
index f6d27ddf..596c95d1 100644
--- a/juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java
+++ b/juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java
@@ -7,23 +7,35 @@ import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
/**
* Created by aalexeev on 11/21/16.
*/
public class JuickUser implements UserDetails {
- public static final GrantedAuthority ROLE_USER = new SimpleGrantedAuthority("ROLE_USER");
- public static final Collection<? extends GrantedAuthority> USER_AUTHORITY = Collections.singletonList(ROLE_USER);
+ static final GrantedAuthority ROLE_USER = new SimpleGrantedAuthority("ROLE_USER");
+ static final GrantedAuthority ROLE_ANONYM = new SimpleGrantedAuthority("ROLE_ANONYM");
+
+ public static final List<GrantedAuthority> USER_AUTHORITY = Collections.singletonList(ROLE_USER);
+ public static final List<GrantedAuthority> ANONYM_AUTHORITY = Collections.singletonList(ROLE_ANONYM);
+
+ public static final JuickUser ANONYM_USER = new JuickUser(AnonymUser.INSTANCE, ANONYM_AUTHORITY);
private final com.juick.User user;
+ private final Collection<? extends GrantedAuthority> authorities;
public JuickUser(com.juick.User user) {
+ this(user, USER_AUTHORITY);
+ }
+
+ public JuickUser(com.juick.User user, Collection<? extends GrantedAuthority> authorities) {
this.user = user;
+ this.authorities = authorities;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
- return USER_AUTHORITY;
+ return authorities;
}
@Override
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 ddeedbbd..8be415c9 100644
--- a/juick-server/src/main/java/com/juick/util/UserUtils.java
+++ b/juick-server/src/main/java/com/juick/util/UserUtils.java
@@ -1,7 +1,7 @@
package com.juick.util;
import com.juick.User;
-import com.juick.entity.AnonymUser;
+import com.juick.server.security.entities.AnonymUser;
import com.juick.server.security.entities.JuickUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;