List of usage examples for org.apache.commons.codec.digest DigestUtils shaHex
@Deprecated public static String shaHex(String data)
From source file:org.geowebcache.storage.blobstore.file.FilePathGenerator.java
protected static String buildKey(String parametersKvp) { return DigestUtils.shaHex(parametersKvp); }
From source file:org.g_node.micro.commons.AppUtils.java
/** * Method converts a List of Strings to upper case, joins the individual entries by a blank space * and retrieves a hexadecimal String from the resulting input String using the SHA-1 hash algorithm. * @param valueList List of Strings./*from w w w .j a v a 2s . c om*/ * @return Hexadecimal String of the SHA-1 encoded input Strings. */ public static String getHashSHA(final List<String> valueList) { final String collectListValues = valueList.stream().map(s -> s.toUpperCase(Locale.ENGLISH)) .collect(Collectors.joining(" ")); return DigestUtils.shaHex(collectListValues); }
From source file:org.j2free.security.SecurityUtils.java
/** * Yea, this isn't the prettiest code, but compared to a version that uses * Integer.toHexString() it's roughly two seconds faster at 1,000,000 reps * @param text//from ww w .ja v a 2s . c om * @return * @deprecated */ // private static String convertToHex(byte[] digest) { // StringBuffer hex = new StringBuffer(); // // for (int i = 0; i < digest.length; i++) { // int halfbyte = (digest[i] >>> 4) & 0x0F; // int two_halfs = 0; // do { // if ((0 <= halfbyte) && (halfbyte <= 9)) { // hex.append((char) ('0' + halfbyte)); // } else { // hex.append((char) ('a' + (halfbyte - 10))); // } // halfbyte = digest[i] & 0x0F; // } while (two_halfs++ < 1); // } // return hex.toString(); // } @Deprecated public static String SHA1(String text) { return DigestUtils.shaHex(text); // try { // MessageDigest md = MessageDigest.getInstance("SHA-1"); // md.update(text.getBytes("iso-8859-1"), 0, text.length()); // return convertToHex(md.digest()); // } catch (Exception e) { // throw LaunderThrowable.launderThrowable(e); // } }
From source file:org.jnap.core.assets.StaticAssetsHandler.java
public void handle() { try {/* ww w . j a va 2 s . c om*/ Resource[] resources = this.resourceResolver.getResources(source); if (destination != null) { Resource destRes = new ServletContextResource(servletContext, destination); resetResource(destRes); BufferedWriter writer = new BufferedWriter( new FileWriterWithEncoding(destRes.getFile(), this.encoding, true)); for (Resource resource : resources) { IOUtils.copy(resource.getInputStream(), writer); } IOUtils.closeQuietly(writer); resources = new Resource[1]; resources[0] = destRes; } for (Resource resource : resources) { // doHandle(resource); // File file = resource.getFile(); String digest = DigestUtils.shaHex(resource.getInputStream()); availableStaticAssets.put(resource.getFilename(), digest); if (compress) { Resource compressedResource = doCompression(resource); digest = DigestUtils.shaHex(compressedResource.getInputStream()); availableStaticAssets.put(compressedResource.getFilename(), digest); } } } catch (Exception e) { logger.error(e.getMessage(), e); } }
From source file:org.kontalk.util.XMPPUtils.java
public static String phoneNumberToKontalkLocal(String number) { PhoneNumberUtil pnUtil = PhoneNumberUtil.getInstance(); PhoneNumber n;/* w w w . ja v a 2s .c o m*/ try { n = pnUtil.parse(number, null); } catch (NumberParseException ex) { return ""; } if (!pnUtil.isValidNumber(n)) return ""; return DigestUtils.shaHex(PhoneNumberUtil.getInstance().format(n, PhoneNumberUtil.PhoneNumberFormat.E164)); }
From source file:org.lexevs.tree.dao.hierarchy.CachingHierarchyResolver.java
/** * Gets the cache key./*from ww w.j av a 2 s . com*/ * * @param obj the obj * * @return the cache key */ protected String getCacheKey(Object... obj) { StringBuffer sb = new StringBuffer(256); for (Object o : obj) { sb.append("::").append(o instanceof Object[] ? getCacheKey((Object[]) o) : ObjectToString.toString(o)); } return DigestUtils.shaHex(sb.toString()); }
From source file:org.LexGrid.LexBIG.Impl.Extensions.GenericExtensions.LexBIGServiceConvenienceMethodsImpl.java
/** * Return a cache key based on the given items. * /* w w w. j a va2s . c om*/ * @param basis * @return Object */ @LgClientSideSafe protected Object getCacheKey(Object[] basis) { StringBuffer sb = new StringBuffer(256); for (Object o : basis) sb.append("::").append(o instanceof Object[] ? getCacheKey((Object[]) o) : ObjectToString.toString(o)); return DigestUtils.shaHex(sb.toString()); }
From source file:org.matonto.catalog.impl.SimpleCatalogManager.java
@Override public Commit createCommit(@Nonnull InProgressCommit inProgressCommit, Set<Commit> parents, @Nonnull String message) { IRI associatedWith = vf.createIRI(Activity.wasAssociatedWith_IRI); IRI informedBy = vf.createIRI(Activity.wasInformedBy_IRI); OffsetDateTime now = OffsetDateTime.now(); Value user = inProgressCommit.getProperty(associatedWith).get(); String metadata = now.toString() + user.stringValue(); IRI generatedIRI = vf.createIRI(Activity.generated_IRI); if (parents != null) { metadata += parents.stream()//from w w w. j a v a 2 s.c o m .sorted(Comparator.comparing(commit2 -> commit2.getResource().stringValue())) .map(commit -> commit.getResource().stringValue()).collect(Collectors.joining("")); } Commit commit = commitFactory.createNew(vf.createIRI(COMMIT_NAMESPACE + DigestUtils.shaHex(metadata))); commit.setProperty(inProgressCommit.getProperty(generatedIRI).get(), generatedIRI); commit.setProperty(vf.createLiteral(now), vf.createIRI(PROV_AT_TIME)); commit.setProperty(vf.createLiteral(message), vf.createIRI(DCTERMS.TITLE.stringValue())); commit.setProperty(user, associatedWith); Model revisionModel = mf.createModel(inProgressCommit.getModel()); revisionModel.remove(inProgressCommit.getResource(), null, null); Revision revision = revisionFactory.getExisting((Resource) inProgressCommit.getProperty(generatedIRI).get(), revisionModel); if (parents != null) { revision.setProperties(parents.stream().map(parent -> parent.getProperty(generatedIRI).get()) .collect(Collectors.toSet()), vf.createIRI(Entity.wasDerivedFrom_IRI)); commit.setProperties(parents.stream().map(Commit::getResource).collect(Collectors.toSet()), informedBy); } commit.getModel().addAll(revisionModel); return commit; }
From source file:org.mule.module.pubsubhubbub.PuSHSubscriberModule.java
public String getVerifyToken() { return DigestUtils.shaHex(hubUrl + topic); }
From source file:org.nuxeo.utils.GetBlobDigest.java
@OperationMethod(collector = BlobCollector.class) public Blob run(Blob input) throws IOException, Exception { digestKind = digestKind.toLowerCase().trim(); if (digestKind == "") { digestKind = "md5"; }/* ww w . j av a2 s . c o m*/ switch (digestKind) { case "md5": ctx.put(contextVarName, DigestUtils.md5Hex(input.getByteArray())); break; case "sha": ctx.put(contextVarName, DigestUtils.shaHex(input.getByteArray())); break; case "sha256": ctx.put(contextVarName, DigestUtils.sha256Hex(input.getByteArray())); break; case "sha384": ctx.put(contextVarName, DigestUtils.sha384Hex(input.getByteArray())); break; case "sha512": ctx.put(contextVarName, DigestUtils.sha512Hex(input.getByteArray())); break; default: throw (new Exception("Unhandled digest kind: " + digestKind)); //break; } return input; }