aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/security
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-28 13:39:04 +0700
committerGravatar Alexander Alexeev2016-11-28 13:39:04 +0700
commitbc23d2d2125d2086847397e85335f29a70668f6b (patch)
tree8c4f0ce7a91763eec65ce36559b7a6c388d9c68d /juick-server/src/main/java/com/juick/server/security
parent47a285e60b0780c7d81e4e1b77736f69e0aaf761 (diff)
remember-me authorization with test; a statndard DaoAuthentication provider used
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/security')
-rw-r--r--juick-server/src/main/java/com/juick/server/security/JuickAuthenticationProvider.java50
-rw-r--r--juick-server/src/main/java/com/juick/server/security/entities/JuickUser.java2
2 files changed, 1 insertions, 51 deletions
diff --git a/juick-server/src/main/java/com/juick/server/security/JuickAuthenticationProvider.java b/juick-server/src/main/java/com/juick/server/security/JuickAuthenticationProvider.java
deleted file mode 100644
index 87908950..00000000
--- a/juick-server/src/main/java/com/juick/server/security/JuickAuthenticationProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.juick.server.security;
-
-import com.juick.User;
-import com.juick.server.security.entities.JuickUser;
-import com.juick.service.UserService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.security.authentication.AuthenticationProvider;
-import org.springframework.security.authentication.LockedException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.util.Assert;
-
-import javax.inject.Inject;
-
-/**
- * Created by vitalyster on 25.11.2016.
- */
-public class JuickAuthenticationProvider implements AuthenticationProvider {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
- private final UserService userService;
-
- @Inject
- public JuickAuthenticationProvider(UserService userService) {
- Assert.notNull(userService);
- this.userService = userService;
- }
-
- @Override
- public Authentication authenticate(Authentication authentication) throws AuthenticationException {
- String name = authentication.getName();
- String password = authentication.getCredentials().toString();
-
- User user = userService.getFullyUserByName(name);
- if (user != null) {
- if (user.isBanned())
- throw new LockedException("Username \"" + name + "\" is banned");
-
- return new UsernamePasswordAuthenticationToken(name, password, JuickUser.USER_AUTHORITY);
- }
- return null;
- }
-
- @Override
- public boolean supports(Class<?> authentication) {
- return authentication.equals(UsernamePasswordAuthenticationToken.class);
- }
-}
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 3e413bf6..f6d27ddf 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
@@ -28,7 +28,7 @@ public class JuickUser implements UserDetails {
@Override
public String getPassword() {
- return null;
+ return user.getCredentials();
}
@Override