uk.me.nxg.xoxa.gpg
Class GPGConnection

java.lang.Object
  extended by uk.me.nxg.xoxa.gpg.GPGConnection
Direct Known Subclasses:
GPGSigner, GPGVerifier

public class GPGConnection
extends Object

Manages a connection to a GPG executable.

This class is designed to be extended. To use, create a new instance, and call run(java.lang.String[], java.lang.String, uk.me.nxg.xoxa.gpg.ReaderProcessor).


Nested Class Summary
static interface GPGConnection.Result<T>
          Represents the result of an interaction with GPG
 
Constructor Summary
GPGConnection()
          Create a new GPGConnection, using the default keychain.
GPGConnection(File home)
          Create a new GPGConnection with the gpg home in the given directory.
 
Method Summary
 boolean completedOK()
           
 String getStderr()
          Retrieve any error information from the process.
protected  void run(String[] arguments, String input, uk.me.nxg.xoxa.gpg.ReaderProcessor outProcessor)
          Runs the GPG command with the given arguments.
protected  void run(String[] arguments, String input, uk.me.nxg.xoxa.gpg.ReaderProcessor outProcessor, uk.me.nxg.xoxa.gpg.ReaderProcessor errProcessor)
          Runs the GPG command with the given arguments.
protected  void setStderr(String s)
           
 boolean waitFor()
          Waits for the process to complete, and indicates its success
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GPGConnection

public GPGConnection()
Create a new GPGConnection, using the default keychain. The GPG command is either gpg or else the value of the gpg.binary system property.


GPGConnection

public GPGConnection(File home)
Create a new GPGConnection with the gpg home in the given directory.

The gpg binary is obtained from the system property gpg.binary, or /usr/bin/gpg if that property isn't defined.

Parameters:
home - the location of the pubring.gpg to be used (or null for default)
Method Detail

getStderr

public String getStderr()
Retrieve any error information from the process.

Returns:
error information, or null if none is available

setStderr

protected void setStderr(String s)

run

protected void run(String[] arguments,
                   String input,
                   uk.me.nxg.xoxa.gpg.ReaderProcessor outProcessor)
Runs the GPG command with the given arguments. The stdout and stderr from the command (FD 1 and FD2) are processed by the corresponding ReaderProcessor objects. The input string is sent to the command as soon as it starts.

Parameters:
arguments - the arguments to be given to the process, including the command to be run in arguments[0]
input - the standard-input to be sent to the process
outProcessor - a reader processor to gather anything written to stdout

run

protected void run(String[] arguments,
                   String input,
                   uk.me.nxg.xoxa.gpg.ReaderProcessor outProcessor,
                   uk.me.nxg.xoxa.gpg.ReaderProcessor errProcessor)
Runs the GPG command with the given arguments. The stdout and stderr from the command (FD 1 and FD2) are processed by the corresponding ReaderProcessor objects. The input string is sent to the command as soon as it starts.

Parameters:
arguments - the arguments to be given to the process, including the command to be run in arguments[0]
input - the standard-input to be sent to the process
outProcessor - a reader processor to gather anything written to stdout
errProcessor - a reader processor to gather anything written to stderr

completedOK

public boolean completedOK()

waitFor

public boolean waitFor()
Waits for the process to complete, and indicates its success

Returns:
true if the GPG process completed successfully


Copyright © 2015. All rights reserved.