import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import com.hyperion.css.CSSSecurityAgentIF; /** * Responsible for dealing with parsing the username from HTTP header. * Providers are always treated as trusted with the Custom Header option, * therefore the getPassword method will always return null. */ public class CustomLoginSample implements CSSSecurityAgentIF { static Logger logger = Logger.getLogger("CustomLoginSample"); //private CustomServletRequest customServletRequest = null; //private final static String LOGIN_KEY = "username"; //private final static String PASSWORD_KEY = "password"; /** * Handles the logic to get the password from the request. */ public String getPassword(HttpServletRequest req, HttpServletResponse res) throws Exception { //customServletRequest = new CustomServletRequest(req); //return customServletRequest.getValue(PASSWORD_KEY); return "password";// for now returns hard-coded password } /** * Handles the logic to parse the username from the request. */ public String getUserName(HttpServletRequest req, HttpServletResponse res) throws Exception { //customServletRequest = new CustomServletRequest(req); //return customServletRequest.getValue(LOGIN_KEY); return "admin";// for now returns hard-coded username } public static void main (String args[]) { System.out.println("This test cannot be run standalone." + " It needs a web environment from where the HTTP request can be passed."); System.out.println("It can be used when CSS is configured for authentication with a security agent." + " This class needs to be in the classpath of CSS."); } }