fixed most compilation errors
This commit is contained in:
parent
cd24ee74e3
commit
de503bd441
23 changed files with 208 additions and 475 deletions
|
|
@ -10,9 +10,12 @@ import zutil.db.DBConnection;
|
|||
import zutil.log.LogUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static zall.ZalleryConstant.SESSION_KEY_USER;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
@ -38,6 +41,19 @@ public class AuthenticationManager {
|
|||
return authenticatedUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the User associated with the provided session.
|
||||
*/
|
||||
public static User getUserSession(HttpSession session) {
|
||||
return (User) session.getAttribute(SESSION_KEY_USER);
|
||||
}
|
||||
public static void setUserSession(User user, HttpSession session) {
|
||||
session.setAttribute(SESSION_KEY_USER, user);
|
||||
}
|
||||
public static void rmUserSession(HttpSession session) {
|
||||
session.removeAttribute(SESSION_KEY_USER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the user has a valid authentication session
|
||||
*/
|
||||
|
|
@ -49,13 +65,13 @@ public class AuthenticationManager {
|
|||
if(user.getSessionHash() == null || user.getSessionHash().isEmpty() )
|
||||
return false;
|
||||
|
||||
switch( user.getAuthBy() ){
|
||||
switch(user.getAuthBy()){
|
||||
case USER_INPUT:
|
||||
if (!user.isEmailVerified()) return false;
|
||||
case COOKIE:
|
||||
String cookieHash = Zallery.getCookieValue(request.getCookies(), ZalleryConstant.SESSION_KEY_AUTH_HASH);
|
||||
return user.getSessionHash().equals(cookieHash) &&
|
||||
user.getIpHost().equals( request.getRemoteAddr() );
|
||||
user.getIpHost().equals(request.getRemoteAddr());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -87,4 +103,5 @@ public class AuthenticationManager {
|
|||
user.setSessionHash(null);
|
||||
user.save(db);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue