本文整理汇总了Java中com.sap.security.auth.login.LoginContextFactory类的典型用法代码示例。如果您正苦于以下问题:Java LoginContextFactory类的具体用法?Java LoginContextFactory怎么用?Java LoginContextFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoginContextFactory类属于com.sap.security.auth.login包,在下文中一共展示了LoginContextFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGet
import com.sap.security.auth.login.LoginContextFactory; //导入依赖的package包/类
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String user = request.getRemoteUser();
if (user != null)
{
response.getWriter().println("Hello, " + user);
}
else
{
LoginContext loginContext;
try
{
loginContext = LoginContextFactory.createLoginContext("FORM");
loginContext.login();
response.getWriter().println("Hello, " + request.getRemoteUser());
}
catch (LoginException ex)
{
ex.printStackTrace();
}
}
}
示例2: logoutUser
import com.sap.security.auth.login.LoginContextFactory; //导入依赖的package包/类
@POST
@Path("logout")
public Response logoutUser() {
logger.debug("Logging out current user...");
try {
LoginContext loginContext = LoginContextFactory.createLoginContext();
loginContext.logout();
return Response.status(Response.Status.OK).build();
} catch (LoginException e) {
logger.error("Problem occured while logging out the current user.", e);
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
示例3: logoutUser
import com.sap.security.auth.login.LoginContextFactory; //导入依赖的package包/类
public static void logoutUser(HttpServletRequest httpRequest) throws UserServiceException {
if (httpRequest.getRemoteUser() != null) {
try {
LoginContext loginContext = LoginContextFactory.createLoginContext();
loginContext.logout();
} catch (LoginException e) {
String errorMessage = "Unsuccessful logout.";
LOGGER.error(errorMessage, e);
throw new UserServiceException(errorMessage, e);
}
}
}
示例4: doGet
import com.sap.security.auth.login.LoginContextFactory; //导入依赖的package包/类
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Call logout if the user is logged in
LoginContext loginContext = null;
if (request.getRemoteUser() != null) {
try {
loginContext = LoginContextFactory.createLoginContext();
loginContext.logout();
} catch (LoginException e) {
response.sendRedirect("/");
}
}
response.sendRedirect("/");
}
示例5: logout
import com.sap.security.auth.login.LoginContextFactory; //导入依赖的package包/类
/**
* Used to logout the authenticated user.
*
* @param request
* the request for the authenticated user
* @throws AuthenticatedUserException
*/
public static void logout(HttpServletRequest request) throws AuthenticatedUserException {
if (request.getUserPrincipal() != null) {
try {
LoginContext loginContext = LoginContextFactory.createLoginContext();
loginContext.logout();
} catch (LoginException e) {
LOGGER.error(ERROR_LOGOUT_FAILED_MESSAGE, e);
throw new AuthenticatedUserException();
}
}
}
示例6: logout
import com.sap.security.auth.login.LoginContextFactory; //导入依赖的package包/类
private void logout() throws LoginException {
LoginContext loginContext = LoginContextFactory.createLoginContext();
loginContext.logout();
}