1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.core.deploy;
17
18 import java.io.File;
19 import java.io.IOException;
20
21 import org.argeo.slc.SlcException;
22 import org.springframework.core.io.Resource;
23 import org.springframework.util.DigestUtils;
24
25
26 public class DigestCheck extends DigestUtils {
27 public static String digest(String algorithm, Resource resource) {
28 try {
29 File file = resource.getFile();
30 return org.argeo.util.DigestUtils.digest(algorithm, file);
31 } catch (IOException e) {
32 try {
33 return org.argeo.util.DigestUtils.digest(algorithm,
34 resource.getInputStream());
35 } catch (IOException e1) {
36 throw new SlcException("Cannot digest " + resource
37 + " with algorithm " + algorithm, e);
38 }
39 }
40 }
41 }