|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnl.nikhef.slcshttps.CAConnection
public class CAConnection
This class provides methods to post data to a (CA) website and retrieve and
store the response. Its behaviour is similar to HttpsURLConnection
,
but not similar enough to make it an extension of it.
HttpsURLConnection
Field Summary | |
---|---|
private HttpsURLConnection |
connection
the actual connection to the CA. |
protected String |
POST_CONTENT_TYPE
mime-type of HTTP POST contents is "application/x-www-form-urlencoded". |
protected String |
RESP_CONTENT_TYPE
expected mime-type for a correct response type is "application/pkix-cert". |
private StringBuffer |
response
response is filled by storeResponse() when getCert() fails and can be retrieved using getResponse() . |
private int |
responseCode
responseCode is set after posting data by
postString(String) . |
private String |
responseMessage
responseMessage is set after posting data by
postString(String) . |
Constructor Summary | |
---|---|
CAConnection()
Default constructor to force handling of calling without arguments. |
|
CAConnection(String CA_URL)
Constructs a CAConnection to the url specified by
String CA_URL . |
Method Summary | |
---|---|
X509Certificate |
getCert()
Tries to retrieve a X509Certificate from the open connection,
expecting content-type "application/pkix-cert". |
String |
getResponse()
returns the CA output in String form, note that the output
is only stored when it couldn't be interpreted as X509Certificate . |
int |
getResponseCode()
returns the HTTP POST response code. |
String |
getResponseMessage()
returns the HTTP POST response message, belonging to responseCode . |
int |
postString(String string)
Sends String string to the opened URL using a HTTP POST with
content-type "application/x-www-form-urlencoded". |
private int |
storeResponse()
Stores the response from the server into the internal String
field response . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private HttpsURLConnection connection
private int responseCode
responseCode
is set after posting data by
postString(String)
.
private String responseMessage
responseMessage
is set after posting data by
postString(String)
.
private StringBuffer response
response
is filled by storeResponse()
when getCert()
fails and can be retrieved using getResponse()
.
protected final String POST_CONTENT_TYPE
protected final String RESP_CONTENT_TYPE
Constructor Detail |
---|
public CAConnection() throws IOException
IOException
CAConnection(String)
public CAConnection(String CA_URL) throws IOException
CAConnection
to the url specified by
String CA_URL
.
CA_URL
- String
representation of the URL to talk to.
IOException
- for any error, including emptry URL.Method Detail |
---|
public int postString(String string) throws IOException
String
string to the opened URL using a HTTP POST with
content-type "application/x-www-form-urlencoded".
string
- data to send
getResponseCode()
.
IOException
- for any error.HttpURLConnection.getResponseCode()
public X509Certificate getCert() throws CertificateException, IOException
X509Certificate
from the open connection,
expecting content-type "application/pkix-cert". Upon failure the
response is stored in response
and can be retrieved using getResponse()
.
X509Certificate
.
IOException
- if we couldn't get a response from the server.
CertificateException
- if the server responded but not with a valid
certificate.public int getResponseCode()
getResponseMessage()
,
HttpURLConnection.getResponseCode()
public String getResponseMessage()
responseCode
.
getResponseCode()
public String getResponse()
String
form, note that the output
is only stored when it couldn't be interpreted as X509Certificate
.
private int storeResponse() throws IOException
String
field response
.
IOException
|
|||||||||
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 |