Created
November 3, 2011 16:44
-
-
Save andreacampi/1337016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.s*******e.sgw.be.servlet.utils; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import org.apache.log4j.Logger; | |
import com.s*******e.sgw.rest.auth.utils.AuthUtils; | |
public class CheckerUtils { | |
private static Logger logger = Logger.getLogger(CheckerUtils.class); | |
public static boolean isParameterRight(HttpServletRequest request, HttpServletResponse response) { | |
ServletAppAndDeviceInfo info = FillUtils.getAppDeviceInfoFromRequest(request, response); | |
//Controllo username e userIdentity | |
/*if(!AuthUtils.isLoginRight(info.getUsername(), info.getUserIdentity())){ | |
logger.warn("Username ["+info.getUsername()+"] or userIdentity ["+info.getUserIdentity()+"] invalid"); | |
return false; | |
}*/ | |
//Controllo gli altri parametri dell'oggetto info | |
if(!info.validate()) { | |
logger.warn("Controllo validate false"); | |
return false; | |
} | |
return true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.s******e.sgw.be.servlet.utils; | |
import static com.s******e.sgw.common.CommonConstants.*; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
public class FillUtils { | |
public static ServletAppAndDeviceInfo getAppDeviceInfoFromRequest(HttpServletRequest request, HttpServletResponse response) { | |
ServletAppAndDeviceInfo info = new ServletAppAndDeviceInfo(); | |
//Get header param | |
String appKey = request.getHeader(PARAM_HEADER_APPKEY); | |
String userIdentity = request.getHeader(PARAM_HEADER_USERIDENTITY); | |
String userAgent = request.getHeader(PARAM_HEADER_USERAGENT); | |
//Get Param | |
String appName = request.getParameter(PARAM_APP_NAME); | |
String appVersion = request.getParameter(PARAM_APP_VERSION); | |
String deviceId = request.getParameter(PARAM_DEVICE_ID); | |
String deviceType= request.getParameter(PARAM_DEVICE_TYPE); | |
String userName = request.getParameter(PARAM_USERNAME); | |
info.setAppKey(appKey); | |
info.setUserIdentity(userIdentity); | |
info.setUserAgent(userAgent); | |
info.setAppName(appName); | |
info.setAppVersion(appVersion); | |
info.setDeviceId(deviceId); | |
info.setDeviceType(deviceType); | |
return info; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment