List of usage examples for org.apache.commons.codec.digest DigestUtils shaHex
@Deprecated public static String shaHex(String data)
From source file:com.ge.research.semtk.load.transform.HashTransform.java
@Override public String applyTransform(String input) { // use 128 bit SHA-1. // prepends "z" as a convenience so that the hash is a legal URI fragment String retval = "z" + DigestUtils.shaHex(input); return retval; }
From source file:net.orpiske.ssps.common.digest.Sha1Digest.java
public String calculate(final InputStream inputStream) throws IOException { logger.info("Calculating message digest"); return DigestUtils.shaHex(inputStream); }
From source file:cz.muni.pa165.carparkapp.dto.EmployeeDTO.java
public void setPassword(String password) { if (password.equals(this.password)) { return;//from w w w . j a v a2 s . c om } this.password = DigestUtils.shaHex(password); }
From source file:com.enonic.cms.core.xslt.XsltResource.java
/** * Return the digest.//from ww w. jav a 2 s .com */ public String getDigest() { if (this.digest == null) { this.digest = DigestUtils.shaHex(this.content); } return this.digest; }
From source file:controller.action.postactions.Login.java
/** * Log in/* www .ja va2 s. c o m*/ * @return property key value * @throws ServletException * @throws IOException */ @Override public void doExecute() throws ServletException, IOException { String email = request.getParameter("email"); String password = request.getParameter("password"); if (isEmpty(email) || isEmpty(password)) { sendRedirect(null, "login.errormessage.empty", "link.loginrequest"); return; // setMessages(null, "login.errormessage.empty"); // return ConfigManager.getProperty("path.page.loginrequest"); } String hexPassword = DigestUtils.shaHex(password); if (!userAuthorization(email, hexPassword)) { if (!adminAuthorization(email, hexPassword)) { if (!kitchenAuthorization(email, hexPassword)) { sendRedirect(null, "login.errormessage.nosuchuser", "link.loginrequest"); // setMessages(null, "login.errormessage.nosuchuser"); // return ConfigManager.getProperty("path.page.loginrequest"); } } } }
From source file:com.thinkberg.webdav.Util.java
public static String getETag(FileObject object) { String fileName = object.getName().getPath(); String lastModified = ""; try {//from w ww . j a v a 2 s . co m lastModified = String.valueOf(object.getContent().getLastModifiedTime()); } catch (FileSystemException e) { // ignore error here } return DigestUtils.shaHex(fileName + lastModified); }
From source file:com.ebay.pulsar.analytics.metricstore.druid.filter.FilterTest.java
public void testAndFilter() { List<BaseFilter> fields = new ArrayList<BaseFilter>(); String dim1 = "Dimension1"; String dim2 = "Dimension2"; String val1 = "Value1"; String val2 = "Value1"; SelectorFilter filter1 = new SelectorFilter(dim1, val1); SelectorFilter filter2 = new SelectorFilter(dim2, val2); fields.add(filter1);/*from w ww .ja v a2s . co m*/ fields.add(filter2); AndFilter andFilter = new AndFilter(fields); byte[] cacheKey = andFilter.cacheKey(); String hashCacheKeyExpected = "7a7b8cb35c7169441f07a4d2dd306dcc570d03ba"; String hashCacheKeyGot = DigestUtils.shaHex(cacheKey); assertEquals("Hash of cacheKey NOT Equals", hashCacheKeyExpected, hashCacheKeyGot); List<BaseFilter> fieldZ = andFilter.getFields(); SelectorFilter filter01 = (SelectorFilter) fieldZ.get(0); SelectorFilter filter02 = (SelectorFilter) fieldZ.get(1); assertEquals("Filter1 dimensions NOT Equals", filter1.getDimension(), filter01.getDimension()); assertEquals("Filter1 values NOT Equals", filter1.getValue(), filter01.getValue()); assertEquals("Filter2 dimensions NOT Equals", filter2.getDimension(), filter02.getDimension()); assertEquals("Filter2 values NOT Equals", filter2.getValue(), filter02.getValue()); FilterType type = andFilter.getType(); assertEquals("AndFilter type NOT Equals", FilterType.and, type); // Nothing to do for FilterCacheHelper //FilterCacheHelper cacheHelper = new FilterCacheHelper(); List<BaseFilter> fields2 = new ArrayList<BaseFilter>(); String dim21 = "Dimension1"; String dim22 = "Dimension2"; String val21 = "Value1"; String val22 = "Value1"; SelectorFilter filter21 = new SelectorFilter(dim21, val21); SelectorFilter filter22 = new SelectorFilter(dim22, val22); fields2.add(filter21); fields2.add(filter22); AndFilter filter_2 = new AndFilter(fields2); AndFilter filter_3 = new AndFilter(fields2); assertTrue(filter_2.equals(filter_2)); assertTrue(filter_2.equals(filter_3)); assertTrue(filter_2.hashCode() == filter_3.hashCode()); assertTrue(!filter_2.equals(null)); AndFilter filter_4 = new AndFilter(null); assertTrue(!filter_2.equals(filter_4)); assertTrue(!filter_4.equals(filter_2)); }
From source file:cz.muni.pa165.carparkapp.configuration.MyAuthenticationProvider.java
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { String username = authentication.getName(); String password = (String) authentication.getCredentials(); password = DigestUtils.shaHex(password); Employee user = null;/*w ww .j ava 2 s. c o m*/ for (Employee e : dao.getAllEmployees()) { //System.out.println(e); if (e.getUserName().equals(username)) { user = e; break; } } if (user == null) { throw new BadCredentialsException("Username not found."); } if (!password.equals(user.getPassword())) { throw new BadCredentialsException("Wrong password."); } List<GrantedAuthority> authorities = new ArrayList<>(); authorities.add(new SimpleGrantedAuthority("ROLE_" + user.getRole())); return new UsernamePasswordAuthenticationToken(username, password, authorities); }
From source file:com.ebay.pulsar.analytics.metricstore.druid.metric.MetricTest.java
public void testAlphaNumericMetric() { String previousStop = "AlphaNumericTest"; AlphaNumericMetric alphaNumericMetric = new AlphaNumericMetric(previousStop); String previousStopGot = alphaNumericMetric.getPreviousStop(); assertEquals("FieldName must be 'FieldName'", previousStop, previousStopGot); byte[] cacheKey = alphaNumericMetric.cacheKey(); String hashCacheKeyExpected = "3c5a495be73819bae712180d05433563229190df"; String hashCacheKeyGot = DigestUtils.shaHex(cacheKey); assertEquals("Hash of cacheKey NOT Equals", hashCacheKeyExpected, hashCacheKeyGot); MetricType type = alphaNumericMetric.getType(); assertEquals("Type NOT Equals", MetricType.alphaNumeric, type); String previousStop2 = "AlphaNumericTest2"; AlphaNumericMetric metric2 = new AlphaNumericMetric(null); assertTrue(!metric2.equals(alphaNumericMetric)); assertTrue(!alphaNumericMetric.equals(metric2)); metric2 = new AlphaNumericMetric(previousStop2); assertTrue(!metric2.equals(alphaNumericMetric)); assertTrue(!alphaNumericMetric.equals(metric2)); // metric2 = new AlphaNumericMetric (previousStop); // assertTrue(metric2.equals(alphaNumericMetric)); // assertTrue(alphaNumericMetric.equals(metric2)); // //w ww .ja va 2 s . co m // assertTrue(alphaNumericMetric.hashCode()==metric2.hashCode()); // // assertTrue(!metric2.equals(new NumericMetric("abc"){ // // })); }
From source file:controller.action.postactions.personal.ChangePassword.java
/** * Perform password changing//from w w w .j av a 2 s .co m * * @throws ServletException * @throws IOException */ @Override protected void doExecute() throws ServletException, IOException { Person person = getPersonFromSession(); if (person == null) { sendRedirect(null, "login.errormessage.loginplease"); return; } String oldPassword = request.getParameter("oldPassword"); String newPassword = request.getParameter("newPassword"); String confirmPassword = request.getParameter("confirmPassword"); if (!checkForNotNull(oldPassword, newPassword, confirmPassword)) { sendRedirect(null, "settings.errormessage.easypasword", "link.settings"); return; // setMessages(null, "settings.errormessage.easypasword"); // return ConfigManager.getProperty("path.page.settings"); } if (!isValid(newPassword)) { sendRedirect(null, "settings.errormessage.easypasword", "link.settings"); return; // setMessages(null, "settings.errormessage.easypasword"); // return ConfigManager.getProperty("path.page.settings"); } String hexOldPassword = DigestUtils.shaHex(oldPassword); String hexNewPassword = DigestUtils.shaHex(newPassword); String hexConfirmPassword = DigestUtils.shaHex(confirmPassword); if (!checkPasswords(person, hexOldPassword, hexNewPassword, hexConfirmPassword) || !changePassword(person, hexNewPassword)) { return; } sendRedirect("settings.message.passwordchanged", null, "link.settings"); // setMessages("settings.message.passwordchanged", null); // return ConfigManager.getProperty("path.page.settings"); }