diff options
author | Vitaly Takmazov | 2016-11-24 21:38:52 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-24 23:26:57 +0300 |
commit | d233943fc29508dc37714852b11b96b0b46b55d9 (patch) | |
tree | 129cd564c021261247e72ac70605c1e559c6dac4 /juick-server/src/main/java/com/juick/service/UserServiceImpl.java | |
parent | bcd9ae221522fa779ea1fd1ff1ab5b561ca0895f (diff) |
juick-api: now on spring-webmvc
Diffstat (limited to 'juick-server/src/main/java/com/juick/service/UserServiceImpl.java')
-rw-r--r-- | juick-server/src/main/java/com/juick/service/UserServiceImpl.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java index 8bd3adef..a84f2fc3 100644 --- a/juick-server/src/main/java/com/juick/service/UserServiceImpl.java +++ b/juick-server/src/main/java/com/juick/service/UserServiceImpl.java @@ -1,6 +1,7 @@ package com.juick.service; import com.juick.User; +import com.juick.server.UserQueries; import com.juick.server.helpers.Auth; import com.juick.server.helpers.EmailOpts; import com.juick.server.helpers.UserInfo; @@ -259,6 +260,18 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { return list.get(0); } + @Override + public int getUIDByHttpAuth(String auth) { + if (auth != null && auth.length() > 8 && auth.startsWith("Basic ")) { + Base64.Decoder dec = Base64.getDecoder(); + String loginpassw[] = new String(dec.decode(auth.substring(6))).split(":", 2); + if (loginpassw.length == 2 && loginpassw[0].length() > 1 && loginpassw[0].length() < 16 && loginpassw[0].matches("[a-zA-Z0-9\\-]+") && !loginpassw[1].isEmpty()) { + return checkPassword(loginpassw[0], loginpassw[1]); + } + } + return 0; + } + @Transactional(readOnly = true) @Override public int checkPassword(final String username, final String password) { |