| 21577 |
ashik.ali |
1 |
package com.spice.profitmandi.web.util;
|
|
|
2 |
|
|
|
3 |
import javax.servlet.http.Cookie;
|
|
|
4 |
import javax.servlet.http.HttpServletRequest;
|
|
|
5 |
|
|
|
6 |
import org.slf4j.Logger;
|
|
|
7 |
import org.slf4j.LoggerFactory;
|
|
|
8 |
import org.springframework.stereotype.Component;
|
|
|
9 |
|
|
|
10 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
11 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
12 |
import com.spice.profitmandi.web.model.FofoDetails;
|
|
|
13 |
|
|
|
14 |
@Component
|
|
|
15 |
public class CookiesFetcher {
|
|
|
16 |
|
|
|
17 |
private static final Logger LOGGER = LoggerFactory.getLogger(CookiesFetcher.class);
|
|
|
18 |
|
|
|
19 |
public FofoDetails getCookiesObject(HttpServletRequest request) throws ProfitMandiBusinessException{
|
|
|
20 |
Cookie[] cookies = request.getCookies();
|
|
|
21 |
if(cookies == null || cookies.length != 2 || !(cookies[0].getName().equals(ProfitMandiConstants.FOFO_ID) && cookies[1].getName().equals(ProfitMandiConstants.EMAIL_ID))){
|
|
|
22 |
LOGGER.error("Requested session is not valid");
|
|
|
23 |
throw new ProfitMandiBusinessException("", "", "");
|
|
|
24 |
}else{
|
|
|
25 |
FofoDetails fofoDetails = new FofoDetails();
|
|
|
26 |
fofoDetails.setFofoId(Integer.parseInt(cookies[0].getValue()));
|
|
|
27 |
fofoDetails.setEmailId(cookies[1].getValue());
|
|
|
28 |
return fofoDetails;
|
|
|
29 |
}
|
|
|
30 |
}
|
|
|
31 |
}
|