9,7 → 9,7 |
import javax.servlet.http.Cookie; |
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.http.HttpServletResponse; |
|
import org.apache.log4j.Logger; |
/** |
* @author Jorge Machado |
* @date 29/Fev/2008 |
18,13 → 18,15 |
*/ |
public class RequestUtils |
{ |
|
public static final Logger logger = Logger.getLogger(RequestUtils.class); |
public static String getRequester(HttpServletRequest request, HttpServletResponse response) throws NoCookiesException |
{ |
if(request == null) |
/* if(request == null) |
return "unknown"; |
if (request.getCookies() == null || request.getCookies().length == 0) |
{ |
Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE, BytesUtils.generateHexKey()); |
Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE, request.getSession().getId()); |
//Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE, request.getSession().getId()); |
response.addCookie(cookie); |
|
35,7 → 37,7 |
}catch(Throwable t){throw new NoCookiesException();} |
|
} |
else if (request.getCookies() != null && request.getCookies().length > 0) |
else |
{ |
for (Cookie cookie : request.getCookies()) |
{ |
44,38 → 46,41 |
return cookie.getValue(); |
} |
} |
Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE, BytesUtils.generateHexKey()); |
// Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE, request.getSession().getId()); |
Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE,request.getSession().getId() ); |
response.addCookie(cookie); |
|
//ONLY TO SAVE COOKIE |
try { |
UserSessionProxy.createUserSession(request,((HttpServletResponse) response),cookie.getValue()); |
return cookie.getValue(); |
}catch(Throwable t){throw new NoCookiesException();} |
}catch(Throwable t){ |
logger.error(t,t); |
throw new NoCookiesException();} |
|
} |
throw new NoCookiesException(); |
// if(request.getSession() != null) |
// return request.getSession().getId(); |
// return "unkown"; |
}*/ |
// throw new NoCookiesException(); |
if(request.getSession() != null) |
return request.getSession().getId(); |
return "unkown"; |
} |
|
public static boolean existRequester(HttpServletRequest request, HttpServletResponse response) throws NoCookiesException |
{ |
if (request.getCookies() == null || request.getCookies().length == 0) |
/* if (request.getCookies() == null || request.getCookies().length == 0) |
{ |
Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE, BytesUtils.generateHexKey()); |
Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE, request.getSession().getId()); |
response.addCookie(cookie); |
|
//ONLY TO SAVE COOKIE |
try { |
UserSessionProxy.createUserSession(request,((HttpServletResponse) response),cookie.getValue()); |
return true; |
}catch(Throwable t){throw new NoCookiesException();} |
}catch(Throwable t){ |
logger.error(t,t); |
throw new NoCookiesException();} |
|
} |
else if (request.getCookies() != null && request.getCookies().length > 0) |
else |
{ |
for (Cookie cookie : request.getCookies()) |
{ |
84,18 → 89,20 |
return true; |
} |
} |
Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE, BytesUtils.generateHexKey()); |
Cookie cookie = new Cookie(pt.estgp.estgweb.web.Globals.BACO_SESSION_COOKIE, request.getSession().getId()); |
response.addCookie(cookie); |
|
//ONLY TO SAVE COOKIE |
try { |
UserSessionProxy.createUserSession(request,((HttpServletResponse) response),cookie.getValue()); |
return true; |
}catch(Throwable t){throw new NoCookiesException();} |
}catch(Throwable t){ |
logger.error(t,t); |
throw new NoCookiesException();} |
|
} |
throw new NoCookiesException(); |
// return true; |
}*/ |
// throw new NoCookiesException(); |
return true; |
} |
|
private static final String EMPTY_STRING = ""; |