uk.me.nxg.enormity.gpg
Class GPGConnection

java.lang.Object
  extended by uk.me.nxg.enormity.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.enormity.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.enormity.gpg.ReaderProcessor outProcessor)
           
protected  void run(String[] arguments, String input, uk.me.nxg.enormity.gpg.ReaderProcessor outProcessor, uk.me.nxg.enormity.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

run

protected void run(String[] arguments,
                   String input,
                   uk.me.nxg.enormity.gpg.ReaderProcessor outProcessor)

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.enormity.gpg.ReaderProcessor outProcessor,
                   uk.me.nxg.enormity.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.


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 © 2012. All Rights Reserved.