Example usage for org.apache.commons.codec.digest DigestUtils sha1Hex

List of usage examples for org.apache.commons.codec.digest DigestUtils sha1Hex

Introduction

In this page you can find the example usage for org.apache.commons.codec.digest DigestUtils sha1Hex.

Prototype

public static String sha1Hex(String data) 

Source Link

Usage

From source file:org.bonitasoft.web.designer.rendering.DirectiveFileGenerator.java

public String generateAllDirectivesFilesInOne(Previewable previewable, Path path) {
    List<Path> filename = getWidgetsFilesUsedInPage(previewable);
    byte[] content = concatenate(filename);
    content = minify(content);/*  w  ww .j a  v  a  2s  .co m*/
    String fileHash = DigestUtils.sha1Hex(content);
    WidgetFileHelper.deleteOldConcatenateFiles(path, fileHash);
    Path file = WidgetFileHelper.writeFile(content, path, fileHash + ".min");
    return file.getFileName().toString();
}

From source file:org.bonitasoft.web.designer.visitor.HtmlBuilderVisitor.java

private String getHash(Asset asset, AssetRepository<?> assetRepository, String previewableId) {
    try {// w ww.java 2  s.  c om
        byte[] content = asset.getComponentId() == null ? assetRepository.readAllBytes(previewableId, asset)
                : assetRepository.readAllBytes(asset);
        return DigestUtils.sha1Hex(content);
    } catch (Exception e) {
        logger.warn("Failure to generate hash for asset " + asset.getName(), e);
        return UUID.randomUUID().toString();
    }
}

From source file:org.bonitasoft.web.designer.visitors.HtmlBuilderVisitorTest.java

@Before
public void setUp() throws Exception {
    initMocks(this);
    visitor = new HtmlBuilderVisitor(asList(pageFactory), requiredModulesVisitor, assetVisitor,
            directivesCollector, pageAssetRepository, widgetAssetRepository);
    when(requiredModulesVisitor.visit(any(Page.class))).thenReturn(Collections.<String>emptySet());
    when(pageAssetRepository.readAllBytes(anyString(), any(Asset.class))).thenReturn(assetsContent);
    when(widgetAssetRepository.readAllBytes(any(Asset.class))).thenReturn(assetsContent);
    assetSHA1 = DigestUtils.sha1Hex(assetsContent);
}

From source file:org.cidte.sii.negocio.LogInManager.java

public String encriptarContrasena(String s) {
    return DigestUtils.sha1Hex(s);
}

From source file:org.cidte.sii.negocio.LogInManager.java

public boolean compararContrasena(String plain, String encripted) {
    String s = DigestUtils.sha1Hex(plain);

    return s.equalsIgnoreCase(encripted);
}

From source file:org.codice.ddf.catalog.content.monitor.AbstractDurableFileConsumer.java

private String getShaFor(String value) {
    return DigestUtils.sha1Hex(value);
}

From source file:org.codice.ddf.catalog.content.monitor.DurableFileAlterationListener.java

private String getMetacardIdFromReference(String referenceKey, String catalogOperation,
        FileSystemPersistenceProvider productToMetacardIdMap) {
    String ref = DigestUtils.sha1Hex(referenceKey);
    if (!productToMetacardIdMap.loadAllKeys().contains(ref)) {
        LOGGER.debug("Received a [{}] operation, but no mapped metacardIds were available for product [{}].",
                catalogOperation, referenceKey);
        return null;
    }//  w  w w.  j av  a2 s .  c om

    return (String) productToMetacardIdMap.loadFromPersistence(ref);
}

From source file:org.codice.ddf.catalog.content.monitor.DurableFileSystemFileConsumer.java

private boolean isOldVersion(String fileName) {
    String sha1 = DigestUtils.sha1Hex(fileName);
    return fileSystemPersistenceProvider.loadAllKeys().contains(sha1);
}

From source file:org.codice.ddf.catalog.content.monitor.DurableFileSystemFileConsumer.java

private AsyncFileAlterationObserver backwardsCompatibility(String fileName) {

    String sha1 = DigestUtils.sha1Hex(fileName);
    AsyncFileAlterationObserver newObserver = new AsyncFileAlterationObserver(new File(fileName),
            jsonSerializer);/*from  w ww .  j av  a2 s  .c  o  m*/
    FileAlterationObserver oldObserver = (FileAlterationObserver) fileSystemPersistenceProvider
            .loadFromPersistence(sha1);

    try {
        newObserver.initialize();
    } catch (IllegalStateException e) {
        //  There was an IO error setting up the initial state of the observer
        LOGGER.info("Error initializing the new state of the CDM. retrying on next poll");
        return null;
    }
    oldObserver.addListener(listener);
    oldObserver.checkAndNotify();
    oldObserver.removeListener(listener);

    return newObserver;
}

From source file:org.codice.ddf.catalog.content.monitor.DurableWebDavFileConsumer.java

@Override
protected boolean doPoll(String fileName) {
    if (observer != null) {
        observer.addListener(listener);//from  w  ww .  j av a2 s .  co m
        observer.checkAndNotify(sardine);
        observer.removeListener(listener);
        String sha1 = DigestUtils.sha1Hex(fileName);
        fileSystemPersistenceProvider.store(sha1, observer);
        return true;
    } else {
        return isMatched(null, null, null);
    }
}