List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex
public static String md5Hex(String data)
From source file:com.glaf.core.util.RequestUtils.java
private static Map<String, String> decodeValues(String ip, String value) { Map<String, String> cookieMap = new java.util.HashMap<String, String>(); if (StringUtils.isNotEmpty(value)) { String c_x = decodeString(value); c_x = StringUtils.replace(c_x, DigestUtils.md5Hex(ip), ""); JSONObject jsonObject = null;//from w ww . j a v a 2 s.co m try { jsonObject = JSON.parseObject(c_x); } catch (Exception ex) { // Ignore Exception } if (jsonObject != null) { Iterator<Entry<String, Object>> iterator = jsonObject.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); String key = (String) entry.getKey(); Object val = entry.getValue(); if (val != null) { cookieMap.put(key, val.toString()); } } } } return cookieMap; }
From source file:de.tsystems.mms.apm.performancesignature.PerfSigProjectAction.java
public void doSummarizerGraph(final StaplerRequest request, final StaplerResponse response) throws IOException, InterruptedException { if (ChartUtil.awtProblemCause != null) { // not available. send out error message response.sendRedirect2(request.getContextPath() + "/images/headless.png"); return;//from www . ja v a 2 s.co m } final String id = request.getParameter("id"); final JSONArray jsonArray = JSONArray.fromObject(getDashboardConfiguration()); if (request.getParameterMap().get("customName") == null && request.getParameterMap().get("customBuildCount") == null) { for (int i = 0; i < jsonArray.size(); i++) { final JSONObject obj = jsonArray.getJSONObject(i); if (obj.getString("id").equals(id)) { //for json version < 2.1 put a empty aggregation value to avoid missing json object if (!obj.has("aggregation")) obj.put("aggregation", ""); ChartUtil.generateGraph(request, response, createChart(obj, buildDataSet(obj)), PerfSigUtils.calcDefaultSize()); return; } } } else { for (DashboardReport dashboardReport : getLastDashboardReports()) for (ChartDashlet chartDashlet : dashboardReport.getChartDashlets()) for (Measure measure : chartDashlet.getMeasures()) if (id.equals(DigestUtils .md5Hex(dashboardReport.getName() + chartDashlet.getName() + measure.getName()))) { final JSONObject jsonObject = new JSONObject(); jsonObject.put("id", id); jsonObject.put("dashboard", dashboardReport.getName()); jsonObject.put("chartDashlet", chartDashlet.getName()); jsonObject.put("measure", measure.getName()); jsonObject.put("customName", request.getParameter("customName")); jsonObject.put("customBuildCount", request.getParameter("customBuildCount")); jsonObject.put("aggregation", request.getParameter("aggregation")); ChartUtil.generateGraph(request, response, createChart(jsonObject, buildDataSet(jsonObject)), PerfSigUtils.calcDefaultSize()); return; } } }
From source file:io.stallion.assets.FileSystemAssetBundleRenderer.java
public String renderProductionHtml() { String content = renderProductionContent(); String hash = DigestUtils.md5Hex(content); String tag = "<script src=\"{0}\" type=\"text/javascript\"></script>"; String url = Settings.instance().getCdnUrl() + "/st-assets/" + bundleRelativePath + extension + "?isConcatenatedFileBundle=true&hash=" + hash; if (".css".equals(extension)) { tag = "<link rel=\"stylesheet\" href=\"{0}\">"; }/*from ww w .j a v a 2 s. com*/ return MessageFormat.format(tag, url); }
From source file:net.oauth.example.provider.core.ExoOAuth3LeggedProviderService.java
/** * Generate a fresh access token and secret for a consumer. and clear request token * @param accessor object will contain token * @throws OAuthException//from ww w.jav a 2 s . c om */ public synchronized void generateAccessToken(OAuthAccessor accessor) throws OAuthException { // generate oauth_token and oauth_secret String consumer_key = (String) accessor.consumer.getProperty("name"); // generate token and secret based on consumer_key // for now use md5 of name + current time as token String token_data = consumer_key + System.nanoTime(); String token = DigestUtils.md5Hex(token_data); // first remove the accessor from cache // ALL_TOKENS.remove(accessor); tokens.remove(accessor.requestToken); accessor.requestToken = null; accessor.accessToken = token; // update token in local cache tokens.put(accessor.accessToken, accessor); }
From source file:net.shopxx.plugin.ccbPayment.CcbPaymentPlugin.java
private String generateSign(Map<String, ?> parameterMap) { return DigestUtils.md5Hex( joinKeyValue(new LinkedHashMap<String, Object>(parameterMap), null, null, "&", false, "MAC")); }
From source file:com.edgenius.wiki.security.acegi.TokenBasedRememberMeServices.java
/** * Calculates the digital signature to be put in the cookie. Default value * is MD5 ("username:tokenExpiryTime:password:key") *///w ww .j a v a2 s . co m protected String makeTokenSignature(long tokenExpiryTime, String username, String password, String key) { return DigestUtils.md5Hex(username + ":" + tokenExpiryTime + ":" + password + ":" + key); }
From source file:eionet.cr.dao.readers.FactsheetReader.java
/** * * @param objectData/*from www. j a v a 2 s .com*/ * @return */ private ObjectDTO parseObjectData(String objectData, String predUri) { if (StringUtils.isBlank(objectData)) { return null; } String[] split = StringUtils.splitByWholeSeparatorPreserveAllTokens(objectData, OBJECT_DATA_SPLITTER); if (split == null || split.length > 8) { throw new CRRuntimeException("Was expecting a length <=8 for the split array"); } String label = StringUtils.isBlank(split[0]) ? "" : split[0].trim(); String language = StringUtils.isBlank(split[1]) ? null : split[1].trim(); URI datatype = StringUtils.isBlank(split[2]) ? null : new URIImpl(split[2].trim()); String objectUri = StringUtils.isBlank(split[3]) ? null : split[3].trim(); boolean isLiteral = objectUri == null; boolean isAnonymous = StringUtils.isBlank(split[4]) ? false : split[4].trim().equals("1") || split[4].trim().equals("true"); String graphUri = StringUtils.isBlank(split[5]) ? null : split[5].trim(); int objectLength = StringUtils.isBlank(split[6]) ? 0 : Integer.parseInt(split[6].trim()); String objectMD5 = StringUtils.isBlank(split[7]) ? "" : split[7].trim(); ObjectDTO objectDTO = null; if (isLiteral) { objectDTO = new ObjectDTO(label, language, true, false, datatype); } else { objectDTO = new ObjectDTO(objectUri, null, false, isAnonymous); if (!StringUtils.isBlank(label) && !label.equals(objectUri)) { ObjectDTO labelObjectDTO = new ObjectDTO(label, language, true, false, datatype); objectDTO.setLabelObject(labelObjectDTO); } } objectDTO.setSourceUri(graphUri); // If literal object and its length in the database is actually bigger than the length // of the value we retrieved (because the query asks only for the N first characters), // then set the object's database-calculated MD5 hash, so that we can later retrieve the // full object value on the factsheet page. As a double measure, make also sure that the // database-calculated hash differs indeed from the Java-calculated hash of the first N // characters that we got here. if (isLiteral) { String value = objectDTO.getValue(); if (objectLength > WebConstants.MAX_OBJECT_LENGTH && !DigestUtils.md5Hex(value).equalsIgnoreCase(objectMD5)) { objectDTO.setObjectMD5(objectMD5); LOGGER.trace("Object's database-calculated length is " + objectLength); } } return objectDTO; }
From source file:com.openthinks.webscheduler.controller.ProfileController.java
@Mapping("/pwd/edit") public String editPwd(WebAttributers was) { String oldPwd = was.get(StaticDict.PAGE_PARAM_USER_OLD_PWD); String newPwd = was.get(StaticDict.PAGE_PARAM_USER_NEW_PWD); String newPwdAgain = was.get(StaticDict.PAGE_PARAM_USER_NEW_PWD_AGAIN); try {/* w ww .java 2 s.c o m*/ Checker.require(oldPwd).notEmpty("Old user password can not be empty."); Checker.require(newPwd).notEmpty("New user password can not be empty."); Checker.require(newPwdAgain).notEmpty("New user password again can not be empty."); } catch (Exception e) { was.addError(StaticDict.PAGE_ATTRIBUTE_ERROR_1, e.getMessage(), WebScope.REQUEST); return StaticUtils.errorPage(was, PageMap.build()); } Optional<User> currentUser = getCurrentUser(was); if (!currentUser.isPresent()) { was.addError(StaticDict.PAGE_ATTRIBUTE_ERROR_1, "Session timeout, please login again.", WebScope.REQUEST); return StaticUtils.errorPage(was, PageMap.build()); } User user = currentUser.get(); if (!user.getPass().equals(DigestUtils.md5Hex(oldPwd))) { was.addError(StaticDict.PAGE_ATTRIBUTE_ERROR_1, "Invalid old password.", WebScope.REQUEST); return StaticUtils.errorPage(was, PageMap.build()); } if (!newPwd.equals(newPwdAgain)) { was.addError(StaticDict.PAGE_ATTRIBUTE_ERROR_1, "The twice new password are not same, please check.", WebScope.REQUEST); return StaticUtils.errorPage(was, PageMap.build()); } user.setPass(DigestUtils.md5Hex(newPwd)); securityService.saveToDisk(); return WebUtils.redirect("/security/logout"); }
From source file:io.stallion.assets.ResourceAssetBundleRenderer.java
public String renderProductionHtml() { String content = renderProductionContent(); String hash = DigestUtils.md5Hex(content); String tag = "<script src=\"{0}\" type=\"text/javascript\"></script>"; String url = Settings.instance().getCdnUrl() + "/st-resource/" + plugin + path + extension + "?isFullResourceBundle=true&hash=" + hash; if (".css".equals(extension)) { tag = "<link rel=\"stylesheet\" href=\"{0}\">"; }//from w w w.j ava2 s . c o m return MessageFormat.format(tag, url); }