From 55b09a6a3bc4a21201189d855e140308f05016fb Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 25 Nov 2016 13:20:15 +0300 Subject: juick-api: security WIP --- juick-spring-www/build.gradle | 3 -- .../juick/www/configuration/WebSecurityConfig.java | 2 +- .../main/java/com/juick/www/entity/JuickUser.java | 62 ---------------------- 3 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 juick-spring-www/src/main/java/com/juick/www/entity/JuickUser.java (limited to 'juick-spring-www') diff --git a/juick-spring-www/build.gradle b/juick-spring-www/build.gradle index 593deb55..14b3bb9c 100644 --- a/juick-spring-www/build.gradle +++ b/juick-spring-www/build.gradle @@ -20,7 +20,6 @@ apply plugin: 'com.github.ben-manes.versions' def springFrameworkVersion = "4.3.4.RELEASE" def thymeleafVersion = "3.0.2.RELEASE" -def springSecurityVersion = "4.2.0.RELEASE" dependencies { compile project(':juick-server') @@ -32,8 +31,6 @@ dependencies { compile "org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.0.RELEASE" compile "org.thymeleaf.extras:thymeleaf-extras-springsecurity4:3.0.1.RELEASE" compile "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:2.1.1" - compile "org.springframework.security:spring-security-web:${springSecurityVersion}" - compile "org.springframework.security:spring-security-config:${springSecurityVersion}" testCompile "junit:junit:4.12" testCompile "org.mockito:mockito-core:1.+" diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java index dcbd5459..3753a4aa 100644 --- a/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java +++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java @@ -1,7 +1,7 @@ package com.juick.www.configuration; import com.juick.service.UserService; -import com.juick.www.entity.JuickUser; +import com.juick.server.security.entities.JuickUser; import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.PropertySource; 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 deleted file mode 100644 index 20d7889d..00000000 --- a/juick-spring-www/src/main/java/com/juick/www/entity/JuickUser.java +++ /dev/null @@ -1,62 +0,0 @@ -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 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; - } -} -- cgit v1.2.3