mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
86 lines
1.6 KiB
Java
86 lines
1.6 KiB
Java
|
|
/*
|
||
|
|
* To change this template, choose Tools | Templates
|
||
|
|
* and open the template in the editor.
|
||
|
|
*/
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
package sonia.scm.web.security;
|
||
|
|
|
||
|
|
//~--- non-JDK imports --------------------------------------------------------
|
||
|
|
|
||
|
|
import com.google.inject.Inject;
|
||
|
|
import com.google.inject.servlet.SessionScoped;
|
||
|
|
|
||
|
|
import sonia.scm.User;
|
||
|
|
|
||
|
|
//~--- JDK imports ------------------------------------------------------------
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
|
||
|
|
/**
|
||
|
|
*
|
||
|
|
* @author Sebastian Sdorra
|
||
|
|
*/
|
||
|
|
@SessionScoped
|
||
|
|
public class BasicSecurityContext implements SecurityContext
|
||
|
|
{
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Method description
|
||
|
|
*
|
||
|
|
*
|
||
|
|
* @param request
|
||
|
|
* @param response
|
||
|
|
* @param username
|
||
|
|
* @param password
|
||
|
|
*
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public User authenticate(HttpServletRequest request,
|
||
|
|
HttpServletResponse response, String username,
|
||
|
|
String password)
|
||
|
|
{
|
||
|
|
user = authenticator.authenticate(request, response, username, password);
|
||
|
|
|
||
|
|
return user;
|
||
|
|
}
|
||
|
|
|
||
|
|
//~--- get methods ----------------------------------------------------------
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Method description
|
||
|
|
*
|
||
|
|
*
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public User getUser()
|
||
|
|
{
|
||
|
|
return user;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Method description
|
||
|
|
*
|
||
|
|
*
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
@Override
|
||
|
|
public boolean isAuthenticated()
|
||
|
|
{
|
||
|
|
return user != null;
|
||
|
|
}
|
||
|
|
|
||
|
|
//~--- fields ---------------------------------------------------------------
|
||
|
|
|
||
|
|
/** Field description */
|
||
|
|
@Inject
|
||
|
|
private Authenticator authenticator;
|
||
|
|
|
||
|
|
/** Field description */
|
||
|
|
private User user;
|
||
|
|
}
|