@Override
public void service(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
String pathInfo = request.getPathInfo();
Endpoint endpoint = EndpointFactory.getEndpoint(getEndpointName(pathInfo)); //remove hardcoded name ..get second token from path info
BasicEndpoint basicendpoint = null;
if(endpoint instanceof BasicEndpoint )
{
basicendpoint = (BasicEndpoint)endpoint;
String user = request.getParameter(USER_NAME);
String pswd = request.getParameter(PASSWORD);
//test if auth info is okay ...we need to check if user/password are valid.
try {
if(basicendpoint.login(user, pswd, false))
{
basicendpoint.setUser(user);
basicendpoint.setPassword(pswd);
basicendpoint.writeToStore();
if(getCallerType(pathInfo).equals(JS_APP)){
generateCloseScript(request, response, AUTH_ACCEPTED);
}else if(getCallerType(pathInfo).equals(JAVA_APP)){
redirectToJavaApp(request, response, AUTH_ACCEPTED );
}