| .. | .. |
|---|
| 1 | 1 | package net.curisit.securis; |
|---|
| 2 | 2 | |
|---|
| 3 | +import java.io.File; |
|---|
| 3 | 4 | import java.io.IOException; |
|---|
| 4 | 5 | import java.io.InputStream; |
|---|
| 5 | 6 | import java.io.UnsupportedEncodingException; |
|---|
| 7 | +import java.nio.file.Files; |
|---|
| 8 | +import java.nio.file.Paths; |
|---|
| 9 | +import java.nio.file.StandardOpenOption; |
|---|
| 6 | 10 | |
|---|
| 7 | 11 | import net.curisit.securis.beans.RequestBean; |
|---|
| 12 | +import net.curisit.securis.utils.JsonUtils; |
|---|
| 8 | 13 | import net.curisit.securis.utils.LicUtils; |
|---|
| 9 | 14 | |
|---|
| 10 | 15 | import org.apache.commons.io.IOUtils; |
|---|
| .. | .. |
|---|
| 45 | 50 | return req; |
|---|
| 46 | 51 | } |
|---|
| 47 | 52 | |
|---|
| 53 | + /** |
|---|
| 54 | + * Generate a request file using a {@link RequestBean} |
|---|
| 55 | + * |
|---|
| 56 | + * @param req |
|---|
| 57 | + * @param file |
|---|
| 58 | + * @throws SeCurisException |
|---|
| 59 | + */ |
|---|
| 60 | + public void save(RequestBean req, File file) throws SeCurisException { |
|---|
| 61 | + byte[] json; |
|---|
| 62 | + try { |
|---|
| 63 | + json = JsonUtils.toJSON(req, true).getBytes("utf-8"); |
|---|
| 64 | + Files.write(Paths.get(file.toURI()), json, StandardOpenOption.CREATE); |
|---|
| 65 | + } catch (UnsupportedEncodingException e) { |
|---|
| 66 | + log.error("Error creating json doc from request: " + req, e); |
|---|
| 67 | + throw new SeCurisException("Error creating json doc from request: " + req, e); |
|---|
| 68 | + } catch (IOException e) { |
|---|
| 69 | + log.error("Error creating request file: " + file, e); |
|---|
| 70 | + throw new SeCurisException("Error creating request file: " + file, e); |
|---|
| 71 | + } |
|---|
| 72 | + |
|---|
| 73 | + log.info("License saved in {}", file); |
|---|
| 74 | + |
|---|
| 75 | + } |
|---|
| 76 | + |
|---|
| 48 | 77 | private String getCrcLogo() { |
|---|
| 49 | 78 | String logResource = "images/logo_customer.png"; |
|---|
| 50 | 79 | InputStream is = getClass().getClassLoader().getResourceAsStream(logResource); |
|---|