Package org.javlo.user
Class UserFactory
- java.lang.Object
-
- org.javlo.user.UserFactory
-
- All Implemented Interfaces:
Serializable
,IUserFactory
- Direct Known Subclasses:
AbstractDBUserFactory
,AdminUserFactory
,InternalDBUserFactory
,MapDbUserFactory
public class UserFactory extends Object implements IUserFactory, Serializable
- Author:
- pvandermaesen
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Logger
logger
create a static logger.static String
USER_FACTORY_KEY
protected List<IUserInfo>
userInfoList
-
Fields inherited from interface org.javlo.user.IUserFactory
AUTO_LOGIN_AGE_SEC, TOKEN_PARAM
-
-
Constructor Summary
Constructors Constructor Description UserFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOrModifyUserInfo(IUserInfo userInfo)
if user info found, update datavoid
addUserInfo(IUserInfo userInfo)
User
adminFakeLogin(javax.servlet.http.HttpServletRequest request, String login)
User
autoLogin(javax.servlet.http.HttpServletRequest request, String login)
String
checkUserAviability(ContentContext ctx, String login)
check the login is availablevoid
clearUserInfoList()
String
createPasswordChangeKey(IUserInfo user)
protected User
createUser(String login, Set<String> roles)
static IUserFactory
createUserFactory(javax.servlet.http.HttpServletRequest request)
static IUserFactory
createUserFactory(GlobalContext globalContext, javax.servlet.http.HttpSession session)
UserInfo
createUserInfos()
void
deleteUser(String login)
Set<String>
getAllRoles(GlobalContext globalContext, javax.servlet.http.HttpSession session)
get all roles of the user.User
getCurrentUser(GlobalContext globalContext, javax.servlet.http.HttpSession session)
protected String
getFileName()
static javax.mail.internet.InternetAddress
getInternetAddress(IUserInfo userinfo)
static javax.mail.internet.InternetAddress
getInternetAddress(User user)
IUserInfo
getPasswordChangeWidthKey(String passwordChangeCode)
retrieve user for change password width special code.protected Set<String>
getRoleList(ContentContext ctx)
RoleWrapper
getRoleWrapper(ContentContext ctx, User user)
String
getSessionKey()
String
getTokenCreateIfNotExist(User user)
User
getUser(String login)
User
getUserByEmail(String email)
List<IUserInfo>
getUserInfoForRoles(String[] inRoles)
List<IUserInfo>
getUserInfoList()
IUserInfo
getUserInfos(String id)
void
init(GlobalContext globalContext, javax.servlet.http.HttpSession newSession)
boolean
isStandardStorage()
check if the user system use standard storage system of wcmsstatic List<IUserInfo>
load(File file)
User
login(javax.servlet.http.HttpServletRequest request, String token)
User
login(javax.servlet.http.HttpServletRequest request, String login, String password)
void
logout(javax.servlet.http.HttpSession session)
void
mergeUserInfo(IUserInfo userInfo)
void
releaseUserInfoList()
void
reload(GlobalContext globalContext, javax.servlet.http.HttpSession session)
void
store()
static void
store(List<IUserInfo> userInfoList, File userInfoFile)
void
updateUserInfo(IUserInfo userInfo)
static void
uploadNewAvatar(ContentContext ctx, String userName, InputStream in)
static List<javax.mail.internet.InternetAddress>
userListAsInternetAddressList(ContentContext ctx, List<String> users)
-
-
-
Field Detail
-
logger
public static Logger logger
create a static logger.
-
USER_FACTORY_KEY
public static final String USER_FACTORY_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
createUserFactory
public static IUserFactory createUserFactory(GlobalContext globalContext, javax.servlet.http.HttpSession session)
-
createUserFactory
public static final IUserFactory createUserFactory(javax.servlet.http.HttpServletRequest request)
- Parameters:
request
-- Returns:
-
addUserInfo
public void addUserInfo(IUserInfo userInfo) throws UserAllreadyExistException
- Specified by:
addUserInfo
in interfaceIUserFactory
- Throws:
UserAllreadyExistException
-
addOrModifyUserInfo
public void addOrModifyUserInfo(IUserInfo userInfo) throws UserAllreadyExistException
Description copied from interface:IUserFactory
if user info found, update data- Specified by:
addOrModifyUserInfo
in interfaceIUserFactory
- Throws:
UserAllreadyExistException
-
adminFakeLogin
public User adminFakeLogin(javax.servlet.http.HttpServletRequest request, String login)
- Specified by:
adminFakeLogin
in interfaceIUserFactory
-
autoLogin
public User autoLogin(javax.servlet.http.HttpServletRequest request, String login)
- Specified by:
autoLogin
in interfaceIUserFactory
-
clearUserInfoList
public void clearUserInfoList()
- Specified by:
clearUserInfoList
in interfaceIUserFactory
-
createUserInfos
public UserInfo createUserInfos()
- Specified by:
createUserInfos
in interfaceIUserFactory
-
deleteUser
public void deleteUser(String login)
- Specified by:
deleteUser
in interfaceIUserFactory
-
getAllRoles
public Set<String> getAllRoles(GlobalContext globalContext, javax.servlet.http.HttpSession session)
Description copied from interface:IUserFactory
get all roles of the user.- Specified by:
getAllRoles
in interfaceIUserFactory
- Returns:
-
getCurrentUser
public User getCurrentUser(GlobalContext globalContext, javax.servlet.http.HttpSession session)
- Specified by:
getCurrentUser
in interfaceIUserFactory
-
getFileName
protected String getFileName()
-
getUser
public User getUser(String login)
- Specified by:
getUser
in interfaceIUserFactory
-
getUserByEmail
public User getUserByEmail(String email)
- Specified by:
getUserByEmail
in interfaceIUserFactory
-
login
public User login(javax.servlet.http.HttpServletRequest request, String token)
- Specified by:
login
in interfaceIUserFactory
-
getUserInfoForRoles
public List<IUserInfo> getUserInfoForRoles(String[] inRoles)
- Specified by:
getUserInfoForRoles
in interfaceIUserFactory
-
load
public static final List<IUserInfo> load(File file) throws IOException, SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
-
getUserInfoList
public List<IUserInfo> getUserInfoList()
- Specified by:
getUserInfoList
in interfaceIUserFactory
-
getUserInfos
public IUserInfo getUserInfos(String id)
- Specified by:
getUserInfos
in interfaceIUserFactory
-
init
public void init(GlobalContext globalContext, javax.servlet.http.HttpSession newSession)
- Specified by:
init
in interfaceIUserFactory
-
isStandardStorage
public boolean isStandardStorage()
Description copied from interface:IUserFactory
check if the user system use standard storage system of wcms- Specified by:
isStandardStorage
in interfaceIUserFactory
- Returns:
- true if standard system is used, false else a external system is used.
-
getSessionKey
public String getSessionKey()
- Specified by:
getSessionKey
in interfaceIUserFactory
-
login
public User login(javax.servlet.http.HttpServletRequest request, String login, String password)
- Specified by:
login
in interfaceIUserFactory
-
logout
public void logout(javax.servlet.http.HttpSession session)
- Specified by:
logout
in interfaceIUserFactory
-
mergeUserInfo
public void mergeUserInfo(IUserInfo userInfo) throws IOException
- Specified by:
mergeUserInfo
in interfaceIUserFactory
- Throws:
IOException
-
releaseUserInfoList
public void releaseUserInfoList()
- Specified by:
releaseUserInfoList
in interfaceIUserFactory
-
reload
public void reload(GlobalContext globalContext, javax.servlet.http.HttpSession session)
- Specified by:
reload
in interfaceIUserFactory
-
store
public void store() throws IOException
- Specified by:
store
in interfaceIUserFactory
- Throws:
IOException
-
store
public static void store(List<IUserInfo> userInfoList, File userInfoFile) throws IOException
- Throws:
IOException
-
updateUserInfo
public void updateUserInfo(IUserInfo userInfo) throws IOException
- Specified by:
updateUserInfo
in interfaceIUserFactory
- Throws:
IOException
-
getPasswordChangeWidthKey
public IUserInfo getPasswordChangeWidthKey(String passwordChangeCode)
retrieve user for change password width special code. Used when user had forget password.- Parameters:
passwordChangeCode
-- Returns:
-
getRoleList
protected Set<String> getRoleList(ContentContext ctx)
-
getRoleWrapper
public RoleWrapper getRoleWrapper(ContentContext ctx, User user)
- Specified by:
getRoleWrapper
in interfaceIUserFactory
-
getTokenCreateIfNotExist
public String getTokenCreateIfNotExist(User user) throws IOException
- Specified by:
getTokenCreateIfNotExist
in interfaceIUserFactory
- Throws:
IOException
-
getInternetAddress
public static javax.mail.internet.InternetAddress getInternetAddress(User user)
-
getInternetAddress
public static javax.mail.internet.InternetAddress getInternetAddress(IUserInfo userinfo)
-
userListAsInternetAddressList
public static List<javax.mail.internet.InternetAddress> userListAsInternetAddressList(ContentContext ctx, List<String> users)
-
uploadNewAvatar
public static void uploadNewAvatar(ContentContext ctx, String userName, InputStream in) throws IOException
- Throws:
IOException
-
checkUserAviability
public String checkUserAviability(ContentContext ctx, String login)
Description copied from interface:IUserFactory
check the login is available- Specified by:
checkUserAviability
in interfaceIUserFactory
- Returns:
- null if ok, error message otherwise
-
-