List of usage examples for javax.servlet.http HttpServletRequest getParameter
public String getParameter(String name);
String
, or null
if the parameter does not exist. From source file:org.jasig.cas.authentication.principal.GoogleAccountsService.java
public static GoogleAccountsService createServiceFrom(final HttpServletRequest request, final PrivateKey privateKey, final PublicKey publicKey, final String alternateUserName) { final String relayState = request.getParameter(CONST_RELAY_STATE); final String xmlRequest = decodeAuthnRequestXML(request.getParameter(CONST_PARAM_SERVICE)); if (!StringUtils.hasText(xmlRequest)) { return null; }//www . j ava 2 s. co m final Document document = SamlUtils.constructDocumentFromXmlString(xmlRequest); if (document == null) { return null; } final String assertionConsumerServiceUrl = document.getRootElement() .getAttributeValue("AssertionConsumerServiceURL"); final String requestId = document.getRootElement().getAttributeValue("ID"); return new GoogleAccountsService(assertionConsumerServiceUrl, relayState, requestId, privateKey, publicKey, alternateUserName); }
From source file:com.bacic5i5j.framework.toolbox.web.WebUtils.java
/** * ?/*from w ww .j a v a2 s. c o m*/ * * @param request * @param name * @param def * @return */ public static String getStringParameter(HttpServletRequest request, String name, String def) { if (request == null) { return def == null ? null : def; } String value = request.getParameter(name); if (value == null || "".equals(value)) { return def == null ? null : def; } return value; }
From source file:com.bluepandora.therap.donatelife.service.UserRegistrationService.java
public static void userRegistrationCheck(HttpServletRequest request, HttpServletResponse response) throws JSONException { DatabaseService dbService = new DatabaseService(DRIVER_NAME, DATABASE_URL, USERNAME, PASSWORD); JSONObject jsonObject;//from w w w. ja va 2 s . c om String requestName = request.getParameter("requestName"); if (request.getParameter("mobileNumber") != null) { String mobileNumber = request.getParameter("mobileNumber"); if (DataValidation.isValidMobileNumber(mobileNumber)) { dbService.databaseOpen(); boolean mobileNumberTaken = isMobileNumberTaken(mobileNumber, dbService); if (mobileNumberTaken) { jsonObject = LogMessageJson.getLogMessageJson("requestName", requestName, "reg", Enum.CORRECT, "done", Enum.CORRECT); Debug.debugLog("MOBILE NUMBER: ", mobileNumber, " REG CHECKING SUCCESS"); } else { jsonObject = LogMessageJson.getLogMessageJson("requestName", requestName, "reg", Enum.ERROR, "done", Enum.CORRECT); } dbService.databaseClose(); } else { jsonObject = LogMessageJson.getLogMessageJson("requestName", requestName, "done", Enum.ERROR, "message", Enum.MESSAGE_INVALID_VALUE); } } else { jsonObject = LogMessageJson.getLogMessageJson("requestName", requestName, "done", Enum.ERROR, "message", Enum.MESSAGE_LESS_PARAMETER); } jsonObject = RequestNameAdderJson.setRequestNameInJson(jsonObject, requestName); SendJsonData.sendJsonData(request, response, jsonObject); }
From source file:com.redhat.rhn.frontend.action.systems.monitoring.BaseProbeAction.java
private static String paramValue(CommandParameter cp, HttpServletRequest req) { String requestParamName = paramName(cp); String value = req.getParameter(requestParamName); return cp.getValidator().normalize(value); }
From source file:com.gtwm.pb.servlets.ServletUtilMethods.java
public static AppUserInfo getPublicUserForRequest(HttpServletRequest request, AuthenticatorInfo authenticator) throws MissingParametersException, ObjectNotFoundException { String internalCompanyName = request.getParameter("c"); if (internalCompanyName == null) { throw new MissingParametersException("c needed to identify company"); }/* w ww .j ava2s . c o m*/ String userName = "public"; String forename = "Host " + request.getRemoteHost(); String surname = "Addr " + request.getRemoteAddr(); return new PublicUser(authenticator, internalCompanyName, userName, surname, forename); }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.AuthorizeTools.java
/** * Check if the request was triggered by an Ajax call. * @param request the request//from ww w . ja va 2 s .c o m * @return <code>true</code> if Ajax */ public static boolean isAjax(final HttpServletRequest request) { // look for an ajax=true parameter if ("true".equals(request.getParameter("ajax"))) { return true; } // check the current request's headers if (request.getHeader(_ajaxHeaderName) != null) { return true; } // check the SavedRequest's headers SavedRequest savedRequest = (SavedRequest) request.getSession() .getAttribute(AbstractProcessingFilter.SPRING_SECURITY_SAVED_REQUEST_KEY); if (savedRequest != null) { return savedRequest.getHeaderValues(_ajaxHeaderName).hasNext(); } return false; }
From source file:com.ikon.util.WebUtils.java
/** * Extrae un parmetro de tipo String del request. Si el parmetro no existe devuelve * el valor por defecto especificado./* w w w.j a v a 2s .c om*/ * @param request Peticin de la que extraer el parmetro. * @param name Nombre del parmetro * @param Valor per defecto del parmetro. * @return El valor String del parmetro o el valor por defecto si no existe. */ public static final String getString(HttpServletRequest request, String name, String defaultValue) { String value = request.getParameter(name); String stringValue = defaultValue; if (value != null) { try { return new String(value.getBytes("ISO-8859-1"), "UTF-8"); } catch (UnsupportedEncodingException e) { // Ignore } } return stringValue; }
From source file:com.ikon.util.WebUtils.java
/** * Extrae un parmetro de tipo entero del request. * Si el parmetro no existe o no es valido devuelve el valor por defecto especificado. * @param request Peticin de la que extraer el parmetro. * @param name Nombre del parmetro/*from ww w .j a va 2s .com*/ * @param defaultValue Valor per defecto * @return El valor int del parmetro o el valor por defecto especificado si no existe o no es valido. */ public static final int getInt(HttpServletRequest request, String name, int defaultValue) { String strValue = request.getParameter(name); int intValue = defaultValue; if (strValue != null && !EMPTY_STRING.equals(strValue)) { try { intValue = Integer.parseInt(strValue); } catch (Throwable t) { // Ignore } } return intValue; }
From source file:com.openkm.util.WebUtils.java
/** * Extrae un parmetro de tipo String del request. Si el parmetro no existe devuelve * un String vacio./*from w w w .j a v a2s. c o m*/ * @param request Peticin de la que extraer el parmetro. * @param name Nombre del parmetro * @return El valor String del parmetro o un String vacio si no existe. */ public static final String getString(HttpServletRequest request, String name) { String value = request.getParameter(name); String stringValue = EMPTY_STRING; if (value != null) { try { return new String(value.getBytes(Config.TOMCAT_CONNECTOR_URI_ENCODING), "UTF-8").trim(); } catch (UnsupportedEncodingException e) { // Ignore } } return stringValue; }
From source file:com.bluepandora.therap.donatelife.adminpanel.AdminService.java
public static void removeHospital(HttpServletRequest request, HttpServletResponse response) throws JSONException { DatabaseService dbService = new DatabaseService(DRIVER_NAME, DATABASE_URL, USERNAME, PASSWORD); dbService.databaseOpen();//from w ww.j av a2 s .c o m String requestName = request.getParameter("requestName"); JSONObject jsonObject = null; if (request.getParameter("hospitalId") != null) { String hospitalId = request.getParameter("hospitalId"); String query = AdminQuery.removeHospitalQuery(hospitalId); boolean done = dbService.queryExcute(query); if (done) { jsonObject = LogMessageJson.getLogMessageJson(Enum.CORRECT, Enum.MESSAGE_HOSPITAL_REMOVED, requestName); } else { jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_ERROR, requestName); } } else { jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_LESS_PARAMETER, requestName); } SendJsonData.sendJsonData(request, response, jsonObject); dbService.databaseClose(); }