List of usage examples for org.apache.commons.codec.digest DigestUtils sha1Hex
public static String sha1Hex(String data)
From source file:com.rabidgremlin.legalbeagle.maven.MavenJarIdentifier.java
public void identifyFiles(Report report) throws Exception { for (ReportItem reportItem : report.getReportItems()) { File f = reportItem.getFile(); String fileHash = DigestUtils.sha1Hex(new FileInputStream(f)); try {/*w w w . j a va 2s .com*/ log.info("Processing {}...", f.getAbsoluteFile()); Model mod = httpHelper.getPom(fileHash); if (mod != null) { reportItem.setReportItemStatus(ReportItemStatus.IDENTIFIED); reportItem.setDescription(mod.getName()); List<License> licenses = getLicense(httpHelper, mod); if (licenses != null) { for (License license : licenses) { // some names have spaces and CR or LF in them String licenseStr = license.getName().trim(); licenseStr = StringUtils.strip(licenseStr, "\n\r"); reportItem.addLicense(licenseStr); } } else { reportItem.setReportItemStatus(ReportItemStatus.NO_LICENSE_FOUND); } } else { reportItem.setReportItemStatus(ReportItemStatus.NOT_IDENTIFIED); } } catch (Exception e) { reportItem.setReportItemStatus(ReportItemStatus.ERR); reportItem.setError(e.getMessage()); } } }
From source file:com.machinepublishers.jbrowserdriver.HttpCache.java
/** * {@inheritDoc}/*from w w w . j a v a2s . c o m*/ */ @Override public void putEntry(String key, HttpCacheEntry entry) throws IOException { try (Lock lock = new Lock(new File(cacheDir, DigestUtils.sha1Hex(key)), false, true)) { BufferedOutputStream bufferOut = new BufferedOutputStream(lock.streamOut); try (ObjectOutputStream objectOut = new ObjectOutputStream(bufferOut)) { objectOut.writeObject(entry); } } }
From source file:com.tikinou.schedulesdirect.core.domain.Credentials.java
public void setClearPassword(String clearPassword) { this.clearPassword = clearPassword; if (clearPassword != null) password = DigestUtils.sha1Hex(clearPassword); }
From source file:com.yahoo.pulsar.client.impl.ConsumerBase.java
protected ConsumerBase(PulsarClientImpl client, String topic, String subscription, ConsumerConfiguration conf, int receiverQueueSize, ExecutorService listenerExecutor, CompletableFuture<Consumer> subscribeFuture) { super(client, topic); this.maxReceiverQueueSize = receiverQueueSize; this.subscription = subscription; this.conf = conf; this.consumerName = conf.getConsumerName() == null ? DigestUtils.sha1Hex(UUID.randomUUID().toString()).substring(0, 5) : conf.getConsumerName();/* w w w. j a va 2 s. com*/ this.subscribeFuture = subscribeFuture; this.listener = conf.getMessageListener(); if (receiverQueueSize <= 1) { this.incomingMessages = Queues.newArrayBlockingQueue(1); } else { this.incomingMessages = new GrowableArrayBlockingQueue<>(); } this.listenerExecutor = listenerExecutor; this.pendingReceives = Queues.newConcurrentLinkedQueue(); }
From source file:be.fedict.trust.repository.MemoryCertificateRepository.java
private String getFingerprint(X509Certificate certificate) { byte[] encodedCertificate; try {/*ww w .j av a 2 s. com*/ encodedCertificate = certificate.getEncoded(); } catch (CertificateEncodingException e) { throw new IllegalArgumentException("certificate encoding error: " + e.getMessage(), e); } String fingerprint = DigestUtils.sha1Hex(encodedCertificate); return fingerprint; }
From source file:com.microsoft.alm.plugin.idea.services.TelemetryContextInitializer.java
private String getUserId() { final String computerName = getComputerName(); final String userName = getSystemProperty("user.name"); //$NON-NLS-1$ final String fakeUserId = MessageFormat.format("{0}@{1}", userName, computerName); //$NON-NLS-1$ return DigestUtils.sha1Hex(fakeUserId); }
From source file:be.fedict.hsm.model.security.SecurityAuditGeneratorBean.java
private String getSubjectIdentifier(byte[] encodedSubjectCertificate) { String subjectIdentifier = DigestUtils.sha1Hex(encodedSubjectCertificate); return subjectIdentifier; }
From source file:Model.security.User.java
@PrePersist @PreUpdate private void hashPassword() { String digestPassword = DigestUtils.sha1Hex(this.password); this.password = digestPassword; }
From source file:com.kolich.blog.mappers.AbstractETagAwareResponseMapper.java
@Override public final void renderSafe(final AsyncContext context, final HttpServletResponse response, @Nonnull final T entity) throws Exception { final Utf8TextEntity rendered = renderView(entity); // Only attach an ETag response header to the response if the rendered entity indicates success. // No ETag is sent back with error pages, like a "404 Not Found" response. if (rendered.getStatus() < SC_BAD_REQUEST) { final String ifNoneMatch = getIfNoneMatchFromRequest(context); // Compute the SHA-1 hash of the response body. final String sha1 = DigestUtils.sha1Hex(rendered.getBody()); // Attach the SHA-1 hash of the response body to the outgoing response. final String eTag = String.format(STRONG_ETAG_HEADER_FORMAT, sha1); response.setHeader(ETAG, eTag); // Strong ETag! // If the If-None-Match header matches the computed SHA-1 hash of the rendered content, then we // send back "304 Not Modified" without a body. If not, then send back the rendered content. if (eTag.equals(ifNoneMatch) || "*".equals(ifNoneMatch)) { // Return a 304. Done. renderEntity(response, NOT_MODIFIED_ENTITY); return; }/*from w ww.jav a2 s .c om*/ } renderEntity(response, rendered); }
From source file:at.stefanproell.ResultSetVerification.ResultSetVerificationAPI.java
/** * Calculate SHA1 hash from input//from www . j a va 2s.c o m * * @param inputString * @return * @throws NoSuchAlgorithmException */ public String calculateHashFromString(String inputString) { try { this.crypto.update(inputString.getBytes("utf8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } String hash = DigestUtils.sha1Hex(this.crypto.digest()); return hash; }