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 Loggerloggercreate a static logger.static StringUSER_FACTORY_KEYprotected 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 voidaddOrModifyUserInfo(IUserInfo userInfo)if user info found, update datavoidaddUserInfo(IUserInfo userInfo)UseradminFakeLogin(javax.servlet.http.HttpServletRequest request, String login)UserautoLogin(javax.servlet.http.HttpServletRequest request, String login)StringcheckUserAviability(ContentContext ctx, String login)check the login is availablevoidclearUserInfoList()StringcreatePasswordChangeKey(IUserInfo user)protected UsercreateUser(String login, Set<String> roles)static IUserFactorycreateUserFactory(javax.servlet.http.HttpServletRequest request)static IUserFactorycreateUserFactory(GlobalContext globalContext, javax.servlet.http.HttpSession session)UserInfocreateUserInfos()voiddeleteUser(String login)Set<String>getAllRoles(GlobalContext globalContext, javax.servlet.http.HttpSession session)get all roles of the user.UsergetCurrentUser(GlobalContext globalContext, javax.servlet.http.HttpSession session)protected StringgetFileName()static javax.mail.internet.InternetAddressgetInternetAddress(IUserInfo userinfo)static javax.mail.internet.InternetAddressgetInternetAddress(User user)IUserInfogetPasswordChangeWidthKey(String passwordChangeCode)retrieve user for change password width special code.protected Set<String>getRoleList(ContentContext ctx)RoleWrappergetRoleWrapper(ContentContext ctx, User user)StringgetSessionKey()StringgetTokenCreateIfNotExist(User user)UsergetUser(String login)UsergetUserByEmail(String email)List<IUserInfo>getUserInfoForRoles(String[] inRoles)List<IUserInfo>getUserInfoList()IUserInfogetUserInfos(String id)voidinit(GlobalContext globalContext, javax.servlet.http.HttpSession newSession)booleanisStandardStorage()check if the user system use standard storage system of wcmsstatic List<IUserInfo>load(File file)Userlogin(javax.servlet.http.HttpServletRequest request, String token)Userlogin(javax.servlet.http.HttpServletRequest request, String login, String password)voidlogout(javax.servlet.http.HttpSession session)voidmergeUserInfo(IUserInfo userInfo)voidreleaseUserInfoList()voidreload(GlobalContext globalContext, javax.servlet.http.HttpSession session)voidstore()static voidstore(List<IUserInfo> userInfoList, File userInfoFile)voidupdateUserInfo(IUserInfo userInfo)static voiduploadNewAvatar(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:
addUserInfoin interfaceIUserFactory- Throws:
UserAllreadyExistException
-
addOrModifyUserInfo
public void addOrModifyUserInfo(IUserInfo userInfo) throws UserAllreadyExistException
Description copied from interface:IUserFactoryif user info found, update data- Specified by:
addOrModifyUserInfoin interfaceIUserFactory- Throws:
UserAllreadyExistException
-
adminFakeLogin
public User adminFakeLogin(javax.servlet.http.HttpServletRequest request, String login)
- Specified by:
adminFakeLoginin interfaceIUserFactory
-
autoLogin
public User autoLogin(javax.servlet.http.HttpServletRequest request, String login)
- Specified by:
autoLoginin interfaceIUserFactory
-
clearUserInfoList
public void clearUserInfoList()
- Specified by:
clearUserInfoListin interfaceIUserFactory
-
createUserInfos
public UserInfo createUserInfos()
- Specified by:
createUserInfosin interfaceIUserFactory
-
deleteUser
public void deleteUser(String login)
- Specified by:
deleteUserin interfaceIUserFactory
-
getAllRoles
public Set<String> getAllRoles(GlobalContext globalContext, javax.servlet.http.HttpSession session)
Description copied from interface:IUserFactoryget all roles of the user.- Specified by:
getAllRolesin interfaceIUserFactory- Returns:
-
getCurrentUser
public User getCurrentUser(GlobalContext globalContext, javax.servlet.http.HttpSession session)
- Specified by:
getCurrentUserin interfaceIUserFactory
-
getFileName
protected String getFileName()
-
getUser
public User getUser(String login)
- Specified by:
getUserin interfaceIUserFactory
-
getUserByEmail
public User getUserByEmail(String email)
- Specified by:
getUserByEmailin interfaceIUserFactory
-
login
public User login(javax.servlet.http.HttpServletRequest request, String token)
- Specified by:
loginin interfaceIUserFactory
-
getUserInfoForRoles
public List<IUserInfo> getUserInfoForRoles(String[] inRoles)
- Specified by:
getUserInfoForRolesin interfaceIUserFactory
-
load
public static final List<IUserInfo> load(File file) throws IOException, SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
-
getUserInfoList
public List<IUserInfo> getUserInfoList()
- Specified by:
getUserInfoListin interfaceIUserFactory
-
getUserInfos
public IUserInfo getUserInfos(String id)
- Specified by:
getUserInfosin interfaceIUserFactory
-
init
public void init(GlobalContext globalContext, javax.servlet.http.HttpSession newSession)
- Specified by:
initin interfaceIUserFactory
-
isStandardStorage
public boolean isStandardStorage()
Description copied from interface:IUserFactorycheck if the user system use standard storage system of wcms- Specified by:
isStandardStoragein interfaceIUserFactory- Returns:
- true if standard system is used, false else a external system is used.
-
getSessionKey
public String getSessionKey()
- Specified by:
getSessionKeyin interfaceIUserFactory
-
login
public User login(javax.servlet.http.HttpServletRequest request, String login, String password)
- Specified by:
loginin interfaceIUserFactory
-
logout
public void logout(javax.servlet.http.HttpSession session)
- Specified by:
logoutin interfaceIUserFactory
-
mergeUserInfo
public void mergeUserInfo(IUserInfo userInfo) throws IOException
- Specified by:
mergeUserInfoin interfaceIUserFactory- Throws:
IOException
-
releaseUserInfoList
public void releaseUserInfoList()
- Specified by:
releaseUserInfoListin interfaceIUserFactory
-
reload
public void reload(GlobalContext globalContext, javax.servlet.http.HttpSession session)
- Specified by:
reloadin interfaceIUserFactory
-
store
public void store() throws IOException- Specified by:
storein 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:
updateUserInfoin 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:
getRoleWrapperin interfaceIUserFactory
-
getTokenCreateIfNotExist
public String getTokenCreateIfNotExist(User user) throws IOException
- Specified by:
getTokenCreateIfNotExistin 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:IUserFactorycheck the login is available- Specified by:
checkUserAviabilityin interfaceIUserFactory- Returns:
- null if ok, error message otherwise
-
-