List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex
public static String md5Hex(String data)
From source file:com.teamj.arquitectura.subscripcion.services.AdministradorServicio.java
public Administrador ingresar(String emailAdministrador, String password) { Administrador tempAdm = new Administrador(); tempAdm.setEmail(emailAdministrador); List<Administrador> tempList = this.administradorDAO.find(tempAdm); if (tempList != null && tempList.size() == 1) { System.out.println("" + DigestUtils.md5Hex(password)); if (DigestUtils.md5Hex(password).equals(tempList.get(0).getPassword())) { return tempList.get(0); }/* w w w . ja v a2 s.c om*/ } return null; }
From source file:net.lshift.diffa.adapter.scanning.DigestBuilderTest.java
@Test public void shouldObserveAllAggregationFactors() { DigestBuilder builder = new DigestBuilder(aggregations); builder.add("id1", createAttrMap(JUN_6_2009_1, "a"), "vsn1"); builder.add("id2", createAttrMap(JUN_7_2009_1, "b"), "vsn2"); builder.add("id3", createAttrMap(JUN_6_2009_2, "c"), "vsn3"); builder.add("id4", createAttrMap(JUN_6_2009_2, "a"), "vsn4"); assertEquals(/*from ww w.j av a2 s . c om*/ new HashSet<ScanResultEntry>(Arrays.asList( ScanResultEntry.forAggregate(DigestUtils.md5Hex("vsn1" + "vsn4"), createAttrMap("2009-06-06", "a")), ScanResultEntry.forAggregate(DigestUtils.md5Hex("vsn2"), createAttrMap("2009-06-07", "b")), ScanResultEntry.forAggregate(DigestUtils.md5Hex("vsn3"), createAttrMap("2009-06-06", "c")))), new HashSet<ScanResultEntry>(builder.toDigests())); }
From source file:com.eviware.loadui.impl.conversion.FileToReferenceConverter.java
private synchronized String getHash(File file) { String key = file.getAbsolutePath(); if (!cache.containsKey(key) || cache.get(key).modified != file.lastModified()) { try {//w ww . j ava 2s . c o m String hash = DigestUtils.md5Hex(new FileInputStream(file)); cache.put(key, new FileStruct(hash, file.lastModified())); lookupTable.put(hash, file); } catch (IOException e) { throw new RuntimeException("Error calculating hash of file [" + file.getName() + "].", e); } } return cache.get(key).hash; }
From source file:com.cosmosource.common.service.UserMgrManager.java
/** * ?/*from w w w. j a v a 2 s . c o m*/ * * @param entity */ public void saveUser(TAcUser entity) { if (StringUtil.isBlank(entity.getPassword())) { entity.setPassword(DigestUtils.md5Hex(PropertiesUtil.getResourcesProperty("default.user.loginname"))); entity.setPlainpassword(PropertiesUtil.getResourcesProperty("default.user.loginname")); entity.setPwdModifyTime(new Date()); entity.setPwdWrongCount(0L); } dao.saveOrUpdate(entity); }
From source file:com.redhat.red.build.koji.model.xmlrpc.messages.KojiImportTest.java
@Test public void xmlRpcRender() throws Exception { ProjectVersionRef gav = new SimpleProjectVersionRef("org.foo", "bar", "1.1"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); Date start = sdf.parse("2017-08-01 12:23:00 UTC"); Date end = sdf.parse("2017-08-01 12:38:00 UTC"); KojiImport.Builder importBuilder = new KojiImport.Builder(); int brId = 1; String pomPath = "org/foo/bar/1.1/bar-1.1.pom"; byte[] pomBytes = readTestResourceBytes("import-data/" + pomPath); KojiImport importMetadata = importBuilder.withNewBuildDescription(gav).withStartTime(start).withEndTime(end) .withBuildSource("http://builder.foo.com", "1.0").parent().withNewBuildRoot(brId) .withContentGenerator("test-cg", "1.0") .withContainer(//from w w w. jav a 2 s.co m new BuildContainer(StandardBuildType.maven.name(), StandardArchitecture.noarch.name())) .withHost("linux", StandardArchitecture.x86_64).parent() .withNewOutput(1, new File(pomPath).getName()).withFileSize(pomBytes.length) .withChecksum(StandardChecksum.md5.name(), DigestUtils.md5Hex(pomBytes)).withOutputType("pom") .parent().build(); String rendered = new RWXMapper().render(importMetadata); assertEquals(getFormalizeXMLStringFromFile("struct-KojiImport.xml"), formalizeXMLString(rendered)); }
From source file:com.googlecode.fascinator.portal.quartz.ExternalJob.java
/** * This method will be called by quartz when the job trigger fires. * * @param context The execution context of this job, including data. *///from w w w. j a va 2 s .com @Override public void execute(JobExecutionContext context) throws JobExecutionException { broken = false; // Get data about our job name = context.getJobDetail().getName(); JobDataMap dataMap = context.getJobDetail().getJobDataMap(); // Make sure the URL is valid String urlString = dataMap.getString("url"); try { url = new URL(urlString); } catch (MalformedURLException ex) { // This should never fail, we validated the // url back in housekeeping broken = true; log.error("URL is invalid: ", ex); } token = dataMap.getString("token"); // MD5 hash our token if we have it if (token != null) { token = DigestUtils.md5Hex(token); } if (!broken) { runJob(); } }
From source file:br.com.jsf.cd.dao.UsuarioDao.java
public void adicionarUsuarioBanco(Usuario u) { try {/* w w w. jav a 2s. co m*/ sessao = HibernateUtil.getSessionFactory().openSession(); tr = sessao.beginTransaction(); Usuario usuario = new Usuario(); usuario.setNomeUsuario(u.getNomeUsuario()); usuario.setLoginUsuario(u.getLoginUsuario()); usuario.setEmailUsuario(u.getEmailUsuario()); /* add senha criptografada */ String encript = DigestUtils.md5Hex(u.getSenhaUsuario()); usuario.setSenhaUsuario(encript); sessao.save(usuario); tr.commit(); } catch (Exception e) { System.out.println("" + e); } finally { sessao.close(); } }
From source file:com.trilemon.boss.infra.base.util.TopApiUtils.java
/** * session key/* w w w . ja v a 2 s . com*/ * * * @param appKey app key * @param appSecret app secret * @param sessionKey session key * @param refreshToken refresh token * @return {@link TaobaoSession} * @throws java.io.IOException ?{@link TaobaoSession}? */ public static TaobaoSession refreshSessionKey(String appKey, String appSecret, String sessionKey, String refreshToken) throws IOException { Map<String, String> signParams = Maps.newTreeMap(); signParams.put("appkey", appKey); signParams.put("refresh_token", refreshToken); signParams.put("sessionkey", sessionKey); StringBuilder params = new StringBuilder(); for (Map.Entry paramEntry : signParams.entrySet()) { params.append(paramEntry.getKey()).append(paramEntry.getValue()); } String sign = DigestUtils.md5Hex((params.toString() + appSecret).getBytes("utf-8")).toUpperCase(); String signEncoder = URLEncoder.encode(sign, "utf-8"); String appkeyEncoder = URLEncoder.encode(appKey, "utf-8"); String refreshTokenEncoder = URLEncoder.encode(refreshToken, "utf-8"); String sessionKeyEncoder = URLEncoder.encode(sessionKey, "utf-8"); String freshUrl = "http://container.api.taobao.com/container/refresh?appkey=" + appkeyEncoder + "&refresh_token=" + refreshTokenEncoder + "&sessionkey=" + sessionKeyEncoder + "&sign=" + signEncoder; String topParametersJson = WebUtils.doPost(freshUrl, null, "utf-8", 30 * 1000 * 60, 30 * 1000 * 60); TaobaoSession taobaoSession = JsonMapper.nonEmptyMapper().fromJson(topParametersJson, TaobaoSession.class); return taobaoSession; }
From source file:de.uzk.hki.da.cb.ShortenFileNamesAction.java
@Override public boolean implementation() throws FileNotFoundException, IOException { String metadataFile = o.getMetadata_file(); // rename results of conversions for (Event e : o.getLatestPackage().getEvents()) { logger.debug("checking if event is CONVERT for {}", e); if (!"CONVERT".equals(e.getType())) continue; logger.debug("event is CONVERT: {}", e); DAFile daFile = e.getTarget_file(); if (!daFile.getRep_name().startsWith(WorkArea.TMP_PIPS)) continue; final File file = wa.toFile(daFile); final String filePath = daFile.getRelative_path(); logger.debug("filePath: " + filePath); String extension = FilenameUtils.getExtension(filePath); logger.debug("extension: " + extension); String newFilePath;/* ww w . j a v a 2 s . co m*/ if (filePath.equals(metadataFile)) { logger.warn("Metadata file should not be subject to a conversion!"); continue; } else { final String hash = DigestUtils.md5Hex(filePath); logger.debug("hash: " + hash); newFilePath = "_" + hash + "." + extension; } logger.debug("newFilePath: " + newFilePath); File newFile = new File(file.getAbsolutePath().replaceAll(Pattern.quote(filePath) + "$", newFilePath)); logger.debug("newFile: " + newFile.getAbsolutePath()); daFile.setRelative_path(newFilePath); FileUtils.moveFile(file, newFile); map.put(newFilePath, filePath); deleteEmptyDirsRecursively(file.getAbsolutePath()); } return true; }
From source file:gov.guilin.controller.shop.CartController.java
/** * /* ww w. ja v a 2 s . com*/ */ @RequestMapping(value = "/add", method = RequestMethod.POST) public @ResponseBody Message add(Long id, Integer quantity, HttpServletRequest request, HttpServletResponse response) { if (quantity == null || quantity < 1) { return ERROR_MESSAGE; } Product product = productService.find(id); if (product == null) { return Message.warn("shop.cart.productNotExsit"); } if (!product.getIsMarketable()) { return Message.warn("shop.cart.productNotMarketable"); } if (product.getIsGift()) { return Message.warn("shop.cart.notForSale"); } Cart cart = cartService.getCurrent(); Member member = memberService.getCurrent(); if (cart == null) { cart = new Cart(); cart.setKey(UUID.randomUUID().toString() + DigestUtils.md5Hex(RandomStringUtils.randomAlphabetic(30))); cart.setMember(member); cartService.save(cart); } if (Cart.MAX_PRODUCT_COUNT != null && cart.getCartItems().size() >= Cart.MAX_PRODUCT_COUNT) { return Message.warn("shop.cart.addCountNotAllowed", Cart.MAX_PRODUCT_COUNT); } if (cart.contains(product)) { CartItem cartItem = cart.getCartItem(product); if (CartItem.MAX_QUANTITY != null && cartItem.getQuantity() + quantity > CartItem.MAX_QUANTITY) { return Message.warn("shop.cart.maxCartItemQuantity", CartItem.MAX_QUANTITY); } if (product.getStock() != null && cartItem.getQuantity() + quantity > product.getAvailableStock()) { return Message.warn("shop.cart.productLowStock"); } cartItem.add(quantity); cartItemService.update(cartItem); } else { if (CartItem.MAX_QUANTITY != null && quantity > CartItem.MAX_QUANTITY) { return Message.warn("shop.cart.maxCartItemQuantity", CartItem.MAX_QUANTITY); } if (product.getStock() != null && quantity > product.getAvailableStock()) { return Message.warn("shop.cart.productLowStock"); } CartItem cartItem = new CartItem(); cartItem.setQuantity(quantity); cartItem.setProduct(product); cartItem.setCart(cart); cartItemService.save(cartItem); cart.getCartItems().add(cartItem); } if (member == null) { WebUtils.addCookie(request, response, Cart.ID_COOKIE_NAME, cart.getId().toString(), Cart.TIMEOUT); WebUtils.addCookie(request, response, Cart.KEY_COOKIE_NAME, cart.getKey(), Cart.TIMEOUT); } return Message.success("shop.cart.addSuccess", cart.getQuantity(), currency(cart.getEffectivePrice(), true, false)); }