|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnl.nikhef.slcshttps.CAHttps
nl.nikhef.slcshttps.PKCS12Https
public class PKCS12Https
Implementation of the abstract
CAHttps
for importing a
PKCS12 file from disk. Typical usage consists of calling
initialize()
or initialize(String)
storeCertificate()
CAHttps.setHttpsSSLSocketFactory()
this can
be combined directly by calling storeCertificate(true)
.
CAHttps
Nested Class Summary | |
---|---|
static interface |
PKCS12Https.PKCS12Communicator
Interface for PKCS12Https communication with the user. |
(package private) static class |
PKCS12Https.StdioComm
This Implementation uses only stdio/stderr for I/O. |
Field Summary | |
---|---|
private static PKCS12Https.PKCS12Communicator |
comm
The PKCS12Https.PKCS12Communicator to be used, can be set using setCommunicator(String) . |
private static String |
COMMPROP
Name of property defining which PKCS12Https.PKCS12Communicator to use:
"nl.nikhef.slcshttps.comm". |
private static String |
commString
Contains the the value of the property "nl.nikhef.slcshttps.comm". |
private String |
fileName
filename of the PKCS12 file to be imported. |
private char[] |
pkcs12Password
password for the PKCS12 file (both for the file and privatekey). |
private KeyStore |
pkcs12Store
internal KeyStore which will hold the contents of the file. |
private static boolean |
showSuccess
Defines whether to acknowledge successful certificate import, download etc. |
Fields inherited from class nl.nikhef.slcshttps.CAHttps |
---|
cryptoStore, HTTPS_PROP, SUCCESS_PROP |
Constructor Summary | |
---|---|
PKCS12Https()
Constructs a default PKCS12Https . |
Method Summary | |
---|---|
static String |
getCommunicator()
Returns the type of PKCS12Https.PKCS12Communicator used for user interaction. |
static boolean |
getShowSuccess()
Getter method for the local private showSuccess . |
void |
initialize()
method to initialize the import: this consists of having the user pick a file, entering the password and reading in the PKCS12 file. |
void |
initialize(String path)
method to initialize the import: this consists of having the user pick a file when path denotes a directory, entering the password
and reading in the PKCS12 file. |
void |
initialize(String path,
String password)
method to initialize the import: this consists of having the user pick a file when path denotes a directory reading in the PKCS12
file using the specified password. |
static String |
setCommunicator(String commInput)
Sets the PKCS12Https.PKCS12Communicator to use for user interaction, it
checks whether the requested method is possible, otherwise use the
default. |
static void |
setShowSuccess(boolean set)
Setter method for the local private showSuccess . |
void |
storeCertificate()
method to finalize the import: this consists of getting the certificate/key from the pkcs12Store loaded in initialize() and putting it in the internal CryptoStore . |
void |
storeCertificate(boolean set)
method to finalize the import: this consists of getting the certificate/key from the pkcs12Store loaded in initialize() and putting it in the internal CryptoStore ;
it optionally sets the SSLSocketFactory . |
void |
storeCertificate(char[] passwordCharArr,
boolean set)
method to finalize the import: this consists of getting the certificate/key from the pkcs12Store loaded in initialize() and putting it in the internal CryptoStore ; it
optionally sets the SSLSocketFactory and uses
passwordCharArr for the import password. |
void |
storeCertificate(String password)
method to finalize the import: this consists of getting the certificate/key from the pkcs12Store loaded in initialize() and putting it in the
internal CryptoStore ; uses password for the
import password. |
void |
storeCertificate(String password,
boolean set)
method to finalize the import: this consists of getting the certificate/key from the pkcs12Store loaded in initialize() and putting it in the internal CryptoStore ; it
optionally sets the SSLSocketFactory and uses
password for the import password. |
Methods inherited from class nl.nikhef.slcshttps.CAHttps |
---|
getCAHttpsCertNo, getCAHttxCertNo, getCertificate, getMaskHttps, getSerialString, getUseHttps, getUseHttx, resetHttpsSSLSocketFactory, resetHttxSSLSocketFactory, resetSSLSocketFactory, setHttpsSSLSocketFactory, setHttxSSLSocketFactory, setSSLSocketFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final String COMMPROP
PKCS12Https.PKCS12Communicator
to use:
"nl.nikhef.slcshttps.comm". Valid values of this property are
"stdio"
use stdio/stderr
"popup"
use (swing) popups
setCommunicator(String)
,
Constant Field Valuesprivate String fileName
private char[] pkcs12Password
private KeyStore pkcs12Store
KeyStore
which will hold the contents of the file.
private static String commString
getCommunicator()
private static PKCS12Https.PKCS12Communicator comm
PKCS12Https.PKCS12Communicator
to be used, can be set using setCommunicator(String)
.
private static boolean showSuccess
true
or false
. Default
is same as the value in the superclass CAHttps.showSuccess
which
in turn is set by CAHttps.SUCCESS_PROP
.
getShowSuccess()
,
setShowSuccess(boolean)
Constructor Detail |
---|
public PKCS12Https() throws KeyStoreException
PKCS12Https
. The constructor for the
super class CAHttps.CAHttps(boolean)
is called with argument
false
since we don't use a CSR.
KeyStoreException
- when initialization failed.CAHttps.CAHttps(boolean)
Method Detail |
---|
public void initialize() throws IOException
IOException
- upon error, including an unreadable file.initialize(String,String)
public void initialize(String path) throws IOException
path
denotes a directory, entering the password
and reading in the PKCS12 file.
initialize
in class CAHttps
path
- either path to PKCS12 file or directory with respect to which
a file is to be chosen.
IOException
- upon error, including an unreadable file.initialize(String,String)
public void initialize(String path, String password) throws IOException
path
denotes a directory reading in the PKCS12
file using the specified password.
path
- either path to PKCS12 file or directory to start the file chooser in.password
- password to unlock PKCS12 store.
IOException
- upon error, including an unreadable file.public void storeCertificate() throws IOException, CertificateException, KeyStoreException, KeyManagementException
pkcs12Store
loaded in initialize()
and putting it in the internal CryptoStore
.
IOException
CertificateException
KeyStoreException
KeyManagementException
- never really thrown, since we don't set
the SSLSocketFactory
.storeCertificate(String,boolean)
public void storeCertificate(boolean set) throws IOException, CertificateException, KeyStoreException, KeyManagementException
pkcs12Store
loaded in initialize()
and putting it in the internal CryptoStore
;
it optionally sets the SSLSocketFactory
.
set
- boolean
whether or not to set the
SSLSocketFactory
.
IOException
CertificateException
KeyStoreException
KeyManagementException
- when setting the
SSLSocketFactory
failsstoreCertificate(String,boolean)
public void storeCertificate(String password) throws IOException, CertificateException, KeyStoreException, KeyManagementException
pkcs12Store
loaded in initialize()
and putting it in the
internal CryptoStore
; uses password
for the
import password.
storeCertificate
in class CAHttps
password
- String
representation of the pkcs12Store
password.
IOException
CertificateException
KeyStoreException
KeyManagementException
- never really thrown, since we don't set
the SSLSocketFactory
.storeCertificate(String,boolean)
public void storeCertificate(String password, boolean set) throws IOException, CertificateException, KeyStoreException, KeyManagementException
pkcs12Store
loaded in initialize()
and putting it in the internal CryptoStore
; it
optionally sets the SSLSocketFactory
and uses
password
for the import password.
password
- String
representation of the pkcs12Store
password.set
- boolean
whether or not to set the
SSLSocketFactory
.
IOException
CertificateException
KeyStoreException
KeyManagementException
- when setting the
SSLSocketFactory
failspublic void storeCertificate(char[] passwordCharArr, boolean set) throws IOException, CertificateException, KeyStoreException, KeyManagementException
pkcs12Store
loaded in initialize()
and putting it in the internal CryptoStore
; it
optionally sets the SSLSocketFactory
and uses
passwordCharArr
for the import password.
passwordCharArr
- char[]
representation of the
pkcs12Store
password.set
- boolean
if set to true
sets the
SSLSocketFactory
to use the just downloaded certificateboolean
IOException
CertificateException
KeyStoreException
KeyManagementException
- when setting the
SSLSocketFactory
failsstoreCertificate(String,boolean)
public static String setCommunicator(String commInput)
PKCS12Https.PKCS12Communicator
to use for user interaction, it
checks whether the requested method is possible, otherwise use the
default.
commInput
- String
describing which type to use, valid
values are
"stdio"
- use stdio/stderr
"popup"
- use (swing) popups
null
- use default "stdio"
getCommunicator()
public static String getCommunicator()
PKCS12Https.PKCS12Communicator
used for user interaction.
setCommunicator(String)
public static void setShowSuccess(boolean set)
showSuccess
.
set
- boolean
to put into private
showSuccess
field.CAHttps.SUCCESS_PROP
,
getShowSuccess()
public static boolean getShowSuccess()
showSuccess
.
boolean
value of private field showSuccess
CAHttps.SUCCESS_PROP
,
setShowSuccess(boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
nl.nikhef.slcshttps | Mischa Sallé - msalle(AT)nikhef.nl |