Skip to content

Commit

Permalink
Add documentation to TempDirProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
vanitasvitae committed Jan 12, 2023
1 parent e72d4d4 commit bfc21ef
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions external-sop/src/main/java/sop/external/ExternalSOP.java
Expand Up @@ -38,6 +38,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.attribute.FileAttribute;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
Expand Down Expand Up @@ -281,6 +282,7 @@ public void writeTo(OutputStream outputStream) throws IOException {
throw new RuntimeException(e);
}
}

public static Ready ready(Runtime runtime, List<String> commandList, List<String> envList, InputStream standardIn) {
String[] command = commandList.toArray(new String[0]);
String[] env = envList.toArray(new String[0]);
Expand Down Expand Up @@ -316,10 +318,27 @@ public void writeTo(OutputStream outputStream) throws IOException {
}
}

/**
* 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 {
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() {
return new TempDirProvider() {
@Override
Expand Down

0 comments on commit bfc21ef

Please sign in to comment.