org.metastatic.callbacks

Class CertificateCallback

Implemented Interfaces:
Callback

public class CertificateCallback
extends java.lang.Object
implements Callback

A callback for determining whether or not a certificate chain, the trust of which could not be established, should be accepted by an application.

The questionable certificate chain is included in this callback, and handlers that accept this callback should provide some mechanism for displaying these certificates when asking for confirmation. When the user allows the certificates, the callback handler should set the selected index to ACCEPT. Otherwise, REJECT.

Field Summary

static int
ACCEPT
Index for when the certificates in question should be accepted.
static int
REJECT
Index for when the certificates in question should be rejected.

Constructor Summary

CertificateCallback(String prompt, Certificate[] certs)
Create a new callback with the given prompt and certificates.
CertificateCallback(String prompt, Certificate[] certs, int defaultIndex)
Create a new callback with the given prompt, certificates, and default index.

Method Summary

Certificate[]
getCertificates()
Returns the certificate chain as an array of certificates.
int
getDefaultIndex()
Returns the default index.
String
getPrompt()
Returns the prompt.
int
getSelectedIndex()
Returns the selected index, or -1 if this value has not been set.
void
setSelectedIndex(int index)
Sets the selected index.

Field Details

ACCEPT

public static final int ACCEPT
Index for when the certificates in question should be accepted.
Field Value:
0

REJECT

public static final int REJECT
Index for when the certificates in question should be rejected.
Field Value:
1

Constructor Details

CertificateCallback

public CertificateCallback(String prompt,
                           Certificate[] certs)
Parameters:
prompt - The prompt.
certs - The certificates.

CertificateCallback

public CertificateCallback(String prompt,
                           Certificate[] certs,
                           int defaultIndex)
Create a new callback with the given prompt, certificates, and default index.
Parameters:
prompt - The prompt.
certs - The certificates.
defaultIndex - The default index.

Method Details

getCertificates

public Certificate[] getCertificates()
Returns the certificate chain as an array of certificates. The certificate array is cloned to prevent susequent modification.
Returns:
The certificate chain.

getDefaultIndex

public int getDefaultIndex()
Returns the default index.
Returns:
The default index.

getPrompt

public String getPrompt()
Returns the prompt.
Returns:
The prompt.

getSelectedIndex

public int getSelectedIndex()
Returns the selected index, or -1 if this value has not been set.
Returns:
The selected index.

setSelectedIndex

public void setSelectedIndex(int index)
Sets the selected index.
Parameters:
index - The selected index.