001
014
015 package com.liferay.portal.kernel.security.auth.session;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019 import com.liferay.registry.Registry;
020 import com.liferay.registry.RegistryUtil;
021 import com.liferay.registry.ServiceTracker;
022
023 import javax.servlet.http.HttpServletRequest;
024 import javax.servlet.http.HttpServletResponse;
025 import javax.servlet.http.HttpSession;
026
027
030 public class AuthenticatedSessionManagerUtil {
031
032 public static AuthenticatedSessionManager getAuthenticatedSessionManager() {
033 PortalRuntimePermission.checkGetBeanProperty(
034 AuthenticatedSessionManagerUtil.class);
035
036 return _instance._serviceTracker.getService();
037 }
038
039 public static long getAuthenticatedUserId(
040 HttpServletRequest request, String login, String password,
041 String authType)
042 throws PortalException {
043
044 return getAuthenticatedSessionManager().getAuthenticatedUserId(
045 request, login, password, authType);
046 }
047
048 public static void login(
049 HttpServletRequest request, HttpServletResponse response,
050 String login, String password, boolean rememberMe, String authType)
051 throws Exception {
052
053 getAuthenticatedSessionManager().login(
054 request, response, login, password, rememberMe, authType);
055 }
056
057 public static void logout(
058 HttpServletRequest request, HttpServletResponse response)
059 throws Exception {
060
061 getAuthenticatedSessionManager().logout(request, response);
062 }
063
064 public static HttpSession renewSession(
065 HttpServletRequest request, HttpSession session)
066 throws Exception {
067
068 return getAuthenticatedSessionManager().renewSession(request, session);
069 }
070
071 public static void signOutSimultaneousLogins(long userId) throws Exception {
072 getAuthenticatedSessionManager().signOutSimultaneousLogins(userId);
073 }
074
075 private AuthenticatedSessionManagerUtil() {
076 Registry registry = RegistryUtil.getRegistry();
077
078 _serviceTracker = registry.trackServices(
079 AuthenticatedSessionManager.class);
080
081 _serviceTracker.open();
082 }
083
084 private static final AuthenticatedSessionManagerUtil _instance =
085 new AuthenticatedSessionManagerUtil();
086
087 private final ServiceTracker<?, AuthenticatedSessionManager>
088 _serviceTracker;
089
090 }