Example usage for org.bouncycastle.tsp.cms CMSTimeStampedData CMSTimeStampedData

List of usage examples for org.bouncycastle.tsp.cms CMSTimeStampedData CMSTimeStampedData

Introduction

In this page you can find the example usage for org.bouncycastle.tsp.cms CMSTimeStampedData CMSTimeStampedData.

Prototype

public CMSTimeStampedData(byte[] baseData) throws IOException 

Source Link

Usage

From source file:org.apache.tika.parser.crypto.TSDParser.java

License:Apache License

private List<TSDMetas> extractMetas(InputStream stream) {
    List<TSDMetas> tsdMetasList = new ArrayList<>();

    try {//from   w ww  .  ja va  2s .  co  m
        CMSTimeStampedData cmsTimeStampedData = new CMSTimeStampedData(stream);

        TimeStampToken[] tokens = cmsTimeStampedData.getTimeStampTokens();

        for (int i = 0; i < tokens.length; i++) {
            TSDMetas tsdMetas = new TSDMetas(true, tokens[i].getTimeStampInfo().getGenTime(),
                    tokens[i].getTimeStampInfo().getPolicy().getId(),
                    tokens[i].getTimeStampInfo().getSerialNumber(), tokens[i].getTimeStampInfo().getTsa(),
                    tokens[i].getTimeStampInfo().getHashAlgorithm().getAlgorithm().getId());

            tsdMetasList.add(tsdMetas);
        }

    } catch (Exception ex) {
        LOG.error("Error in TSDParser.buildMetas {}", ex.getMessage());
        tsdMetasList.clear();
    }

    return tsdMetasList;
}