mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 12:57:57 +01:00
Add documentation to TempDirProvider
This commit is contained in:
parent
909e28432d
commit
9c27141c00
1 changed files with 19 additions and 0 deletions
|
@ -38,6 +38,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.attribute.FileAttribute;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -281,6 +282,7 @@ public class ExternalSOP implements SOP {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ready ready(Runtime runtime, List<String> commandList, List<String> envList, InputStream standardIn) {
|
public static Ready ready(Runtime runtime, List<String> commandList, List<String> envList, InputStream standardIn) {
|
||||||
String[] command = commandList.toArray(new String[0]);
|
String[] command = commandList.toArray(new String[0]);
|
||||||
String[] env = envList.toArray(new String[0]);
|
String[] env = envList.toArray(new String[0]);
|
||||||
|
@ -316,10 +318,27 @@ public class ExternalSOP implements SOP {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface can be used to provide a directory in which external SOP binaries can temporarily store
|
||||||
|
* additional results of OpenPGP operations such that the binding classes can parse them out from there.
|
||||||
|
* Unfortunately, on Java you cannot open {@link java.io.FileDescriptor FileDescriptors} arbitrarily, so we
|
||||||
|
* have to rely on temporary files to pass results.
|
||||||
|
* An example:
|
||||||
|
* <pre>sop decrypt</pre> can emit signature verifications via <pre>--verify-out=/path/to/tempfile</pre>.
|
||||||
|
* {@link DecryptExternal} will then parse the temp file to make the result available to consumers.
|
||||||
|
* Temporary files are deleted after being read, yet creating temp files for sensitive information on disk
|
||||||
|
* might pose a security risk. Use with care!
|
||||||
|
*/
|
||||||
public interface TempDirProvider {
|
public interface TempDirProvider {
|
||||||
File provideTempDirectory() throws IOException;
|
File provideTempDirectory() throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementation of the {@link TempDirProvider} which stores temporary files in the systems temp dir
|
||||||
|
* ({@link Files#createTempDirectory(String, FileAttribute[])}).
|
||||||
|
*
|
||||||
|
* @return default implementation
|
||||||
|
*/
|
||||||
public static TempDirProvider defaultTempDirProvider() {
|
public static TempDirProvider defaultTempDirProvider() {
|
||||||
return new TempDirProvider() {
|
return new TempDirProvider() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue