public byte[] readContent() throws IOException { if (binary != null) { return binary; } return IoUtil.read(file); }
public ImportOcspFromCaDb(DataSourceFactory datasourceFactory, PasswordResolver passwordResolver, String dbConfFile, String publisherName, boolean resume, String srcFolder, int batchEntriesPerCommit, boolean evaluateOnly) throws PasswordResolverException, IOException { super(datasourceFactory, passwordResolver, dbConfFile); this.publisherName = publisherName; this.resume = resume; this.srcFolder = IoUtil.expandFilepath(srcFolder); this.batchEntriesPerCommit = batchEntriesPerCommit; }
public static void save(String fileName, byte[] encoded) throws IOException { save(new File(expandFilepath(fileName)), encoded); }
public static void save(File file, byte[] content) throws IOException { File tmpFile = expandFilepath(file); mkdirsParent(tmpFile.toPath()); Files.copy(new ByteArrayInputStream(content), tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING); }
private byte[] send(byte[] request) throws IOException { Args.notNull(request, "request"); HttpURLConnection httpUrlConnection = IoUtil.openHttpConn(serverUrl); if (httpUrlConnection instanceof HttpsURLConnection) { if (sslSocketFactory != null) { return IoUtil.read(inputStream);
public CaManagerImpl() { this.datasourceFactory = new DataSourceFactory(); String calockId = null; File caLockFile = new File("calock"); if (caLockFile.exists()) { try { calockId = new String(IoUtil.read(caLockFile)); } catch (IOException ex) { LOG.error("could not read {}: {}", caLockFile.getName(), ex.getMessage()); } } if (calockId == null) { calockId = UUID.randomUUID().toString(); try { IoUtil.save(caLockFile, calockId.getBytes()); } catch (IOException ex) { LOG.error("could not save {}: {}", caLockFile.getName(), ex.getMessage()); } } String hostAddress = null; try { hostAddress = IoUtil.getHostAddress(); } catch (SocketException ex) { LOG.warn("could not get host address: {}", ex.getMessage()); } this.lockInstanceId = (hostAddress == null) ? calockId : hostAddress + "/" + calockId; this.restResponder = new RestResponder(this); } // constructor
new X509AttributeCertificateHolder(IoUtil.read(certFile)); byte[] encodedCert = IoUtil.read(certFile); encodedCerts.put(sn, encodedCert); byte[] bytes = reqResp.getRequest(); if (bytes != null) { IoUtil.save(reqout, bytes); byte[] bytes = reqResp.getResponse(); if (bytes != null) { IoUtil.save(respout, bytes);
private void createExampleRepository(File dir, int numSlots) throws IOException { for (int i = 0; i < numSlots; i++) { File slotDir = new File(dir, i + "-" + (800000 + i)); slotDir.mkdirs(); File slotInfoFile = new File(slotDir, "slot.info"); IoUtil.save(slotInfoFile, "namedCurveSupported=true\n".getBytes()); } }
protected FileOrValue buildFileOrValue(String content, String fileName) throws IOException { if (content == null) { return null; } Args.notNull(fileName, "fileName"); FileOrValue ret = new FileOrValue(); if (content.length() < 256) { ret.setValue(content); return ret; } File file = new File(baseDir, fileName); IoUtil.mkdirsParent(file.toPath()); IoUtil.save(file, content.getBytes("UTF-8")); ret.setFile(fileName); return ret; }
protected byte[] send(byte[] request) throws IOException { Args.notNull(request, "request"); HttpURLConnection httpUrlConnection = IoUtil.openHttpConn(serverUrl);
@Override protected Object execute0() throws Exception { source = expandFilepath(source); dest = expandFilepath(dest); File sourceFile = new File(source); if (!sourceFile.exists()) { throw new IllegalCmdParamException(source + " does not exist"); } if (!sourceFile.isFile()) { throw new IllegalCmdParamException(source + " is not a file"); } File destFile = new File(dest); if (destFile.exists()) { if (!destFile.isFile()) { throw new IllegalCmdParamException("cannot override an existing directory by a file"); } else { if (!force.booleanValue() && !confirm("Do you want to override the file " + dest, 3)) { return null; } } } else { IoUtil.mkdirsParent(destFile.toPath()); } FileUtils.copyFile(sourceFile, destFile, true); sourceFile.delete(); return null; }
httpUrlConnection = IoUtil.openHttpConn(newUrl); httpUrlConnection.setRequestMethod("GET"); } else { httpUrlConnection = IoUtil.openHttpConn(responderUrl); httpUrlConnection.setDoOutput(true); httpUrlConnection.setUseCaches(false); return IoUtil.read(inputstream);
new X509AttributeCertificateHolder(IoUtil.read(certFile)); byte[] encodedCert = IoUtil.read(certFile); encodedCerts.put(sn, encodedCert); byte[] bytes = reqResp.getRequest(); if (bytes != null) { IoUtil.save(reqout, bytes); byte[] bytes = reqResp.getResponse(); if (bytes != null) { IoUtil.save(respout, bytes);
public DigestDiffReporter(String reportDirname, byte[] caCertBytes) throws IOException { this.reportDirname = ParamUtil.requireNonBlank("reportDirname", reportDirname); File dir = new File(reportDirname); dir.mkdirs(); IoUtil.save(new File(dir, "ca.der"), caCertBytes); this.missingWriter = new BufferedWriter(new FileWriter(new File(dir, "missing"))); this.unexpectedWriter = new BufferedWriter(new FileWriter(new File(dir, "unexpected"))); this.diffWriter = new BufferedWriter(new FileWriter(new File(dir, "diff"))); this.goodWriter = new BufferedWriter(new FileWriter(new File(dir, "good"))); this.errorWriter = new BufferedWriter(new FileWriter(new File(dir, "error"))); start(); }
public static void save(File file, byte[] content) throws IOException { File tmpFile = expandFilepath(file); mkdirsParent(tmpFile.toPath()); Files.copy(new ByteArrayInputStream(content), tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING); }
protected FileOrBinary buildFileOrBinary(byte[] content, String fileName) throws IOException { if (content == null) { return null; } Args.notNull(fileName, "fileName"); FileOrBinary ret = new FileOrBinary(); if (content.length < 256) { ret.setBinary(content); return ret; } File file = new File(baseDir, fileName); IoUtil.mkdirsParent(file.toPath()); IoUtil.save(file, content); ret.setFile(fileName); return ret; }
@Override protected Object execute0() throws Exception { source = expandFilepath(source); dest = expandFilepath(dest); File sourceFile = new File(source); if (!sourceFile.exists()) { throw new IllegalCmdParamException(source + " does not exist"); } if (!sourceFile.isFile()) { throw new IllegalCmdParamException(source + " is not a file"); } File destFile = new File(dest); if (destFile.exists()) { if (!destFile.isFile()) { throw new IllegalCmdParamException("cannot override an existing directory by a file"); } else { if (!force.booleanValue() && !confirm("Do you want to override the file " + dest, 3)) { return null; } } } else { IoUtil.mkdirsParent(destFile.toPath()); } FileUtils.copyFile(sourceFile, destFile, true); return null; }
public byte[] readContent() throws IOException { if (binary != null) { return binary; } return IoUtil.read(file); }
public ImportCaDb(DataSourceFactory datasourceFactory, PasswordResolver passwordResolver, String dbConfFile, boolean resume, String srcFolder, int batchEntriesPerCommit) throws PasswordResolverException, IOException { super(datasourceFactory, passwordResolver, dbConfFile); this.resume = resume; this.srcFolder = IoUtil.expandFilepath(srcFolder); this.batchEntriesPerCommit = batchEntriesPerCommit; }
HttpURLConnection httpUrlConnection = IoUtil.openHttpConn(url); } else { inClosed = true; return IoUtil.read(httpUrlConnection.getInputStream());