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:com.bluepandora.therap.donatelife.adminpanel.AdminService.java
public static void removeFeedBack(HttpServletRequest request, HttpServletResponse response) throws JSONException { DatabaseService dbService = new DatabaseService(DRIVER_NAME, DATABASE_URL, USERNAME, PASSWORD); dbService.databaseOpen();/*from w w w. j a v a 2 s. co m*/ String requestName = request.getParameter("requestName"); JSONObject jsonObject = null; if (request.getParameter("idUser") != null && request.getParameter("reqTime") != null) { String idUser = request.getParameter("idUser"); String reqTime = request.getParameter("reqTime"); String query = AdminQuery.removeFeedBackQuery(idUser, reqTime); boolean done = dbService.queryExcute(query); if (done) { jsonObject = LogMessageJson.getLogMessageJson(Enum.CORRECT, Enum.MESSAGE_FEEDBACK_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(); }
From source file:com.orchestra.portale.externalauth.FbAuthenticationManager.java
public static User fbLoginJs(HttpServletRequest request, HttpServletResponse response, UserRepository userRepository) { //Get access_token from request String access_token = request.getParameter("access_token"); User user = null;//from ww w .j a va 2 s .co m if (StringUtils.isNotEmpty(access_token)) { try { Boolean validity = FacebookUtils.ifTokenValid(access_token); //if token is valid, retrieve userid and email from Facebook if (validity) { Map<String, String> userId_mail = FacebookUtils.getUserIDMail(access_token); String id = userId_mail.get("id"); String email = userId_mail.get("email"); try { user = fbUserCheck(id, email, userRepository); } catch (UserNotFoundException ioex) { /*Retrieve User Data to Registration*/ Map<String, String> userData = FacebookUtils.getUserData(access_token); /*Create User*/ com.orchestra.portale.persistence.sql.entities.User new_user = new com.orchestra.portale.persistence.sql.entities.User(); new_user.setFbEmail(userData.get("email")); new_user.setFbUser(userData.get("id")); new_user.setUsername(userData.get("email")); new_user.setFirstName(userData.get("firstName")); new_user.setLastName(userData.get("lastName")); new_user.setPassword(new BigInteger(130, new SecureRandom()).toString(32)); /*Create Role*/ com.orchestra.portale.persistence.sql.entities.Role new_user_role = new com.orchestra.portale.persistence.sql.entities.Role(); new_user_role.setRole("ROLE_USER"); new_user_role.setUser(new_user); ArrayList<com.orchestra.portale.persistence.sql.entities.Role> new_user_roles = new ArrayList<com.orchestra.portale.persistence.sql.entities.Role>(); new_user_roles.add(new_user_role); new_user.setRoles(new_user_roles); /*Save User*/ userRepository.save(new_user); //Save user image try { String img_url = userData.get("img"); String user_id_img = userRepository.findByUsername(new_user.getUsername()).getId() .toString(); HttpSession session = request.getSession(); ServletContext sc = session.getServletContext(); String destination = sc.getRealPath("/") + "dist" + File.separator + "user" + File.separator + "img" + File.separator + user_id_img + File.separator; NetworkUtils.saveImageFromURL(img_url, destination, "avatar.jpg"); } catch (MalformedURLException ex) { throw new FacebookException(); } catch (IOException ioexc) { ioexc.getMessage(); } /*Create Spring User*/ boolean enabled = true; boolean accountNonExpired = true; boolean credentialsNonExpired = true; boolean accountNonLocked = true; user = new User(new_user.getUsername(), new_user.getPassword().toLowerCase(), enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, getAuthorities(new_user.getRoles())); } } } catch (FacebookException ioex) { ioex.printStackTrace(); } } return user; }
From source file:com.bluepandora.therap.donatelife.service.BloodRequestService.java
public static void removePersonBloodRequestTracker(HttpServletRequest request, HttpServletResponse response) throws JSONException { DatabaseService dbService = new DatabaseService(DRIVER_NAME, DATABASE_URL, USERNAME, PASSWORD); JSONObject jsonObject;/*from w w w . j a v a 2 s . co m*/ String requestName = request.getParameter("requestName"); if (request.getParameter("mobileNumber") != null) { String mobileNumber = request.getParameter("mobileNumber"); if (DataValidation.isValidMobileNumber(mobileNumber)) { dbService.databaseOpen(); String query = GetQuery.removePersonBloodRequestTrackerQuery(mobileNumber); dbService.queryExcute(query); jsonObject = LogMessageJson.getLogMessageJson(Enum.CORRECT, mobileNumber + Enum.MESSAGE_BLOOD_REQUEST_TRACKER_REMOVED, requestName); Debug.debugLog("MOBILE NUMBER: ", mobileNumber, " REMOVE TRACKER SUCCESS"); dbService.databaseClose(); } else { jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_INVALID_VALUE, requestName); } } else { jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_LESS_PARAMETER, requestName); } SendJsonData.sendJsonData(request, response, jsonObject); }
From source file:com.github.thorqin.webapi.oauth2.OAuthServer.java
public static RefreshTokenRequest getRefreshTokenRequest(HttpServletRequest request) { if (getGrantType(request).equalsIgnoreCase("authorization_code")) { RefreshTokenRequest codeRequest = new RefreshTokenRequest(); codeRequest.clientId = request.getParameter("client_id"); codeRequest.scope = request.getParameter("scope"); String auth = request.getHeader("Authorization"); if (auth != null) { auth = getBasicAuth(auth);/*ww w . ja v a2s. c o m*/ if (auth == null) { codeRequest.clientId = null; codeRequest.clientSecret = null; } else { auth = new String(Base64.decodeBase64(auth)); String[] parts = auth.split(":"); if (parts.length < 2) { codeRequest.clientId = null; codeRequest.clientSecret = null; } else { codeRequest.clientId = parts[0]; codeRequest.clientSecret = parts[1]; } } } else { codeRequest.clientSecret = request.getParameter("client_secret"); } codeRequest.refreshToken = request.getParameter("refresh_token"); return codeRequest; } else return null; }
From source file:com.bluepandora.therap.donatelife.service.DataService.java
public static void getUserProfile(HttpServletRequest request, HttpServletResponse response) throws JSONException { DatabaseService dbService = new DatabaseService(DRIVER_NAME, DATABASE_URL, USERNAME, PASSWORD); if (request.getParameter("mobileNumber") != null && request.getParameter("keyWord") != null) { String mobileNumber = request.getParameter("mobileNumber"); String keyWord = request.getParameter("keyWord"); if (DataValidation.isValidMobileNumber(mobileNumber) && DataValidation.isValidKeyWord(keyWord)) { String hashKey = DataValidation.encryptTheKeyWord(keyWord); String query = GetQuery.getUserProfileQuery(mobileNumber, hashKey); dbService.databaseOpen();/*w ww. j a va 2s . c om*/ ResultSet result = dbService.getResultSet(query); JSONObject jsonObject = UserProfileJson.getUserProfileJson(result); jsonObject = RequestNameAdderJson.setRequestNameInJson(jsonObject, request.getParameter("requestName")); SendJsonData.sendJsonData(request, response, jsonObject); dbService.databaseClose(); } else { JSONObject jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_INVALID_VALUE); jsonObject = RequestNameAdderJson.setRequestNameInJson(jsonObject, request.getParameter("requestName")); SendJsonData.sendJsonData(request, response, jsonObject); } } else { JSONObject jsonObject = LogMessageJson.getLogMessageJson(Enum.ERROR, Enum.MESSAGE_LESS_PARAMETER); jsonObject = RequestNameAdderJson.setRequestNameInJson(jsonObject, request.getParameter("requestName")); SendJsonData.sendJsonData(request, response, jsonObject); } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.externalServices.OAuthAction.java
private static String getDeviceId(HttpServletRequest request) { String deviceId = request.getParameter("device_id"); if (StringUtils.isBlank(deviceId)) { UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader(HttpHeaders.USER_AGENT)); String browserName = userAgent.getBrowser().getName(); String osName = userAgent.getOperatingSystem().getName(); deviceId = BundleUtil.getString(Bundle.APPLICATION, "oauthapps.label.device.type", browserName, osName); }//from w ww.j a v a 2s . c om return deviceId; }
From source file:com.github.thorqin.webapi.oauth2.OAuthServer.java
public static AccessTokenByCodeRequest getAccessTokenByCodeRequest(HttpServletRequest request) { if (getGrantType(request).equalsIgnoreCase("authorization_code")) { AccessTokenByCodeRequest codeRequest = new AccessTokenByCodeRequest(); codeRequest.clientId = request.getParameter("client_id"); codeRequest.redirectUri = request.getParameter("redirect_uri"); String auth = request.getHeader("Authorization"); if (auth != null) { auth = getBasicAuth(auth);//from ww w.j a v a 2s . co m if (auth == null) { codeRequest.clientId = null; codeRequest.clientSecret = null; } else { auth = new String(Base64.decodeBase64(auth)); String[] parts = auth.split(":"); if (parts.length < 2) { codeRequest.clientId = null; codeRequest.clientSecret = null; } else { codeRequest.clientId = parts[0]; codeRequest.clientSecret = parts[1]; } } } else { codeRequest.clientSecret = request.getParameter("client_secret"); } codeRequest.code = request.getParameter("code"); return codeRequest; } else return null; }
From source file:fr.mby.saml2.sp.impl.helper.SamlHelper.java
/** * Retrieve a SAML request from http request. * /* www . jav a 2s .co m*/ * @param request * the http request * @return the SAML request. */ public static String getSamlRequest(final HttpServletRequest request) { return request.getParameter(SamlHelper.SAML_REQUEST_PARAM_KEY); }
From source file:fr.mby.saml2.sp.impl.helper.SamlHelper.java
/** * Retrieve a SAML response from http request. * /*from ww w. j a v a 2 s.c o m*/ * @param request * the http request * @return the SAML response. */ public static String getSamlResponse(final HttpServletRequest request) { return request.getParameter(SamlHelper.SAML_RESPONSE_PARAM_KEY); }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.App.Usuario.Read.java
protected static void leerTaller(HttpServletRequest request, HttpServletResponse response) throws IOException { TallerEntity e = CtrlUsuario.leerTaller(request.getParameter("1")); // id de la taller response.setContentType("application/json;charset=UTF-8"); PrintWriter out = response.getWriter(); if (e.getNombre().isEmpty()) { JSONObject obj = new JSONObject(); obj.put("isError", true); obj.put("errorDescrip", "El taller ya no esta disponible"); out.print(obj);/* w ww . j a va 2 s.co m*/ } else { JSONObject obj = new JSONObject(); obj.put("id", e.getIdTaller()); obj.put("nombre", e.getNombre()); obj.put("descripcion", e.getDescripcion()); obj.put("cupos", e.getCupos()); obj.put("costo", e.getCosto()); obj.put("fechaFin", "" + e.getFechaFinRegistro()); obj.put("fechaInicio", "" + e.getFechaInicio()); out.print(obj); } }