ch.othello.openscep
Class ScepClient

java.lang.Object
  |
  +--ch.othello.openscep.ScepClient
All Implemented Interfaces:
Serializable

public class ScepClient
extends Object
implements Serializable

Scep Client

 $Id: ScepClient.java,v 1.54 2002/02/28 01:22:16 urut Exp $
 $Log: ScepClient.java,v $
 Revision 1.54  2002/02/28 01:22:16  urut
 debug info

 Revision 1.53  2002/02/27 06:53:19  urut
 modified setting of subject in Signed structure

 Revision 1.52  2002/02/27 04:21:27  urut
 first working spkac version

 Revision 1.51  2002/02/27 04:11:09  alani
 loadCA now only accepts a String

 Revision 1.50  2002/02/25 04:45:35  urut
 set subjectScep from cmd line to test out various effects

 Revision 1.49  2002/02/25 04:23:39  urut
 first working version for MS browsers
 there is still a problem in here as subjectSCEP needs to be set to the subject
 of the actual PKCS#10 request. seems to be a bug in OpenScep.

 Revision 1.48  2002/02/24 22:30:57  alani
 added reconstruction of certReq to setCertReqOrig if
 the type is pkcs10

 Revision 1.47  2002/02/24 06:42:17  urut
 extracting of public key from pkcs#10 changed (only for v1!)

 Revision 1.46  2002/02/23 22:59:42  alani
 added extraction of subject to setCertReq

 Revision 1.44  2002/02/22 12:38:55  urut
 modifications to process SUCCESS response to v2 request

 Revision 1.43  2002/02/22 10:35:31  urut
 first v2 working release (pkcs#10 only)
 major mods,in particular:
 - md5 hash calculation for proxyIdentifier
 - requestPayload, Attributes is tagged object

 Revision 1.42  2002/02/22 07:34:37  alani
 refactored setCaCert and fixed get & set StateData

 Revision 1.41  2002/02/22 03:18:07  urut
 adjusted scep library to openscep 0.4.0:
 -proxyIdentification Envelope Removed
 -calculation of hash for requestPayload changed
 -messageTyp in v2 is different

 Revision 1.40  2002/02/22 01:31:38  alani
 added new methods setSubject(String) and setScepSubject(String)

 Revision 1.39  2002/02/16 01:14:45  urut
 replaced all read-only accessed files with URL's file:///......
 removed option caCert , only caCertURL is available now

 Revision 1.38  2002/02/16 00:40:20  urut
 awfull lot of fixes,among them:
 - computation of transactionID for v2
 - spkac processing in cmd line client
 - new filetyp unknown for debug files
 - subject in cmd client
 - lots of fixes for v2 protocoll handling

 Revision 1.37  2002/02/15 13:21:12  urut
 first complete implementation of scep v2

 Revision 1.36  2002/02/15 10:12:20  urut
 changed endEntityxxxx -> scepxxxx (because of v2 scep)

 Revision 1.35  2002/02/15 06:11:09  urut
 merge with alani
 lots of mods for incorporating full support for HTTP communication with SCEPD; Httpd client is now capable of reading multipart-mime (sort of....??) messages

 Revision 1.34  2002/02/14 16:39:40  alani
 added a few methods & attributes needed by the http proxy

 Revision 1.33  2002/02/13 12:55:22  alani
 some changes

 Revision 1.32  2002/02/12 19:33:23  urut
 replaced all println statements

 Revision 1.31  2002/02/12 14:01:17  urut
 cmd client improved

 Revision 1.30  2002/02/07 17:08:50  urut
 ability to send scep request over http added

 Revision 1.29  2002/02/07 13:16:34  urut
 finished http CA cert get

 Revision 1.28  2002/02/07 12:40:56  urut
 moved util-stuff to Utils.java
 CA get implemented

 Revision 1.27  2002/01/31 14:07:32  urut
 adjustments for new SignedData (that takes certificates as Sequences)

 Revision 1.26  2002/01/31 11:29:45  urut
 new cmd option "-certificate"

 Revision 1.25  2002/01/24 00:11:31  urut
 new flag -response added

 Revision 1.24  2002/01/23 19:10:24  urut
 fixed computation of MD5 fingerprint

 Revision 1.23  2002/01/17 19:44:00  urut
 added attribute certReqOrig, which contains the original PKCS#10 request (because CertificationRequest is buggy)

 Revision 1.22  2002/01/17 11:52:37  urut
 extract publicKey from pkcs#10 request if available, if not load it from file (new function, called from CmdClient )

 Revision 1.21  2002/01/15 21:20:11  urut
 Modified EvelopedData: is now embedded in ia ContentInfo structure (required by PKCS7)
 Modified transactionID (set to fix id for testing because it needs to be printable)
 added missing attributes to signerInfo
 added messageTyp=19 for PKCSReq
 ScepClient uses now DERObject as attribute type to store envelope.

 Revision 1.20  2002/01/10 20:22:01  urut
 bug fixing

 Revision 1.19  2002/01/10 16:17:40  urut
 fixed some bugs

 Revision 1.18  2002/01/10 15:54:23  urut
 load pkcs#10

 Revision 1.17  2002/01/10 15:09:38  alani
 new attribute distinguishedName in ScepClient, scepReq now generates a transactionId

 Revision 1.15  2002/01/10 14:43:44  urut
 merge

 Revision 1.14  2002/01/10 14:37:26  urut
 merge

 Revision 1.13  2002/01/10 14:19:43  alani
 improved certRequest

 Revision 1.10  2002/01/08 21:00:29  urut
 added javadoc header with cvs tags to every file
 Revision 1.9  2002/01/08 11:41:19  urut
 added tags
 

Since:
$Date: 2002/02/28 01:22:16 $
Version:
$Revision: 1.54 $
Author:
See Also:
Serialized Form

Field Summary
private  org.bouncycastle.asn1.x509.X509CertificateStructure caCert
           
private  org.bouncycastle.asn1.x509.RSAPublicKeyStructure caPubKey
           
private  String caUrl
           
private  URL certificate
           
private  org.bouncycastle.asn1.pkcs.CertificationRequest certReq
           
private  org.bouncycastle.asn1.DERObject certReqOrig
           
private  org.bouncycastle.asn1.DERPrintableString challenge
           
(package private) static String COMMAND_PACKAGE
           
private  String communityString
           
private  StateData lnkStateData
           
private  org.bouncycastle.asn1.DERObject pkcsCertReqEnvelope
           
(package private)  org.bouncycastle.asn1.pkcs.SignedData pkcsCertReqSigned
           
private  org.bouncycastle.asn1.pkcs.ContentInfo pkiMessage
           
private  org.bouncycastle.asn1.DERObject proxyCertReq
           
private  org.bouncycastle.asn1.DEROctetString proxyIdentification
           
private  String request
           
private  org.bouncycastle.asn1.DERObject requestPayload
           
private  int requestType
           
private  org.bouncycastle.asn1.DERObject responseFile
           
private  org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure scepPrivateKey
           
private  org.bouncycastle.asn1.x509.RSAPublicKeyStructure scepPublicKey
           
private  int scepVersion
           
private  SecureRandom secureRandom
           
(package private)  org.bouncycastle.asn1.DERInteger serial
           
private  org.bouncycastle.asn1.x509.X509CertificateStructure signedEndEntityCertificate
           
private  org.bouncycastle.asn1.x509.X509Name subject
           
private  org.bouncycastle.asn1.x509.X509Name subjectScep
           
private  org.bouncycastle.asn1.x509.TBSCertificateStructure tbsCACert
           
private  org.bouncycastle.asn1.DERPrintableString transactionId
           
static int TYPE_PKCS10
           
static int TYPE_SPKAC
           
private  String url
           
static int VERSION1
           
static int VERSION2
           
 
Constructor Summary
ScepClient()
           
 
Method Summary
static void debugOut(String str)
           
 boolean Execute(String command)
           
 String getBase64SignedEndEntityCertificate()
           
 org.bouncycastle.asn1.x509.X509CertificateStructure getCaCert()
           
 org.bouncycastle.asn1.x509.RSAPublicKeyStructure getCaPubKey()
          Gets the caPubKey.
 URL getCertificate()
          Getter for property certificate.
 org.bouncycastle.asn1.pkcs.CertificationRequest getCertReq()
          Gets the certReq.
 org.bouncycastle.asn1.DERObject getCertReqEnvelope()
          Gets the pkcsCertReqEnvelope.
 org.bouncycastle.asn1.DERObject getCertReqOrig()
          Gets the certReqOrig
 org.bouncycastle.asn1.DERPrintableString getChallenge()
          Gets the challenge.
 String getCommunityString()
          Getter for property communityString.
 org.bouncycastle.asn1.pkcs.ContentInfo getPkiMessage()
          Getter for property pkiMessage.
 org.bouncycastle.asn1.DEROctetString getProxyIdentification()
          Getter for property proxyIdentification.
 String getRequest()
          Getter for property request.
 org.bouncycastle.asn1.DERObject getRequestPayload()
          Getter for property requestPayload.
 int getRequestType()
          Gets the requestType.
 org.bouncycastle.asn1.DERObject getResponseFile()
          Getter for property responseFile.
 org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure getScepPrivateKey()
          Gets the scepPrivateKey.
 org.bouncycastle.asn1.x509.RSAPublicKeyStructure getScepPublicKey()
          Gets the scepPublicKey.
 int getScepVersion()
          Gets the scepVersion.
 SecureRandom getSecureRandom()
          Gets the secureRandom.
 org.bouncycastle.asn1.x509.X509CertificateStructure getSignedEndEntityCertificate()
          Getter for property signedEndEntityCertificate.
 StateData getStateData()
           
 org.bouncycastle.asn1.x509.X509Name getSubject()
          Getter for property subject.
 org.bouncycastle.asn1.x509.X509Name getSubjectScep()
          Getter for property subjectScep.
 org.bouncycastle.asn1.DERPrintableString getTransactionId()
           
 String getUrl()
          Gets the url.
 boolean loadCA(String url)
           
private  boolean loadCA(URL url)
          Load CA Cert from URL
 void loadPrivateKey(URL url)
          Load CA Certificate from File
 void loadPublicKey(URL url)
           
 void loadRequest(URL url)
           
 void loadResponseFile(String filename)
           
 int post(org.bouncycastle.asn1.DERObject der, String operation)
          send DERObject to scep server (http req)
 void setCaCert(org.bouncycastle.asn1.x509.X509CertificateStructure caCert)
           
 void setCaPubKey(org.bouncycastle.asn1.x509.RSAPublicKeyStructure caPubKey)
          Sets the caPubKey.
 void setCertificate(URL certificate)
           
 void setCertReq(org.bouncycastle.asn1.pkcs.CertificationRequest certReq)
          Sets the certReq.
 void setCertReq(String certReq)
           
 void setCertReqEnvelope(org.bouncycastle.asn1.DERObject envelope)
          Sets the pkcsCertReqEnvelope.
 void setCertReqOrig(org.bouncycastle.asn1.DERObject certReqOrig)
          Sets the certReqOrig.
 void setCertReqOrig(String certReqOrig)
           
 void setChallenge(org.bouncycastle.asn1.DERPrintableString challenge)
          Sets the challenge.
 void setChallenge(String challenge)
          Sets the challenge.
 void setCommunityString(String communityString)
           
 void setPkiMessage(org.bouncycastle.asn1.pkcs.ContentInfo pkiMessage)
           
 void setProxyIdentification(org.bouncycastle.asn1.DEROctetString proxyIdentification)
          Setter for property proxyIdentification.
 void setRequest(String request)
           
 void setRequestPayload(org.bouncycastle.asn1.DERObject requestPayload)
           
 void setRequestType(int requestType)
          Sets the requestType.
 void setResponseFile(org.bouncycastle.asn1.DERObject responseFile)
          Setter for property responseFile.
 void setScepPrivateKey(org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure scepPrivateKey)
          Sets the scepPrivateKey.
 void setScepPublicKey(org.bouncycastle.asn1.x509.RSAPublicKeyStructure scepPublicKey)
          Sets the scepPublicKey.
 void setScepVersion(int scepVersion)
          Sets the scepVersion.
 void setSecureRandom(SecureRandom secureRandom)
          Sets the secureRandom.
 void setSignedEndEntityCertificate(org.bouncycastle.asn1.x509.X509CertificateStructure signedEndEntityCertificate)
          Setter for property signedEndEntityCertificate.
 void setStateData(StateData data)
           
 void setSubject(String subject)
           
 void setSubject(org.bouncycastle.asn1.x509.X509Name subject)
           
 void setSubjectScep(String subject)
           
 void setSubjectScep(org.bouncycastle.asn1.x509.X509Name subjectScep)
           
 void setTransactionId(org.bouncycastle.asn1.DERPrintableString transId)
           
 void setUrl(String url)
          Sets the url.
 void storeCertificate(String filename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMAND_PACKAGE

static final String COMMAND_PACKAGE
See Also:
Constant Field Values

signedEndEntityCertificate

private org.bouncycastle.asn1.x509.X509CertificateStructure signedEndEntityCertificate

caCert

private org.bouncycastle.asn1.x509.X509CertificateStructure caCert

caUrl

private String caUrl

tbsCACert

private org.bouncycastle.asn1.x509.TBSCertificateStructure tbsCACert

pkcsCertReqEnvelope

private org.bouncycastle.asn1.DERObject pkcsCertReqEnvelope

transactionId

private org.bouncycastle.asn1.DERPrintableString transactionId

challenge

private org.bouncycastle.asn1.DERPrintableString challenge

caPubKey

private org.bouncycastle.asn1.x509.RSAPublicKeyStructure caPubKey

scepPrivateKey

private org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure scepPrivateKey

scepPublicKey

private org.bouncycastle.asn1.x509.RSAPublicKeyStructure scepPublicKey

certReq

private org.bouncycastle.asn1.pkcs.CertificationRequest certReq

proxyCertReq

private org.bouncycastle.asn1.DERObject proxyCertReq

certReqOrig

private org.bouncycastle.asn1.DERObject certReqOrig

subject

private org.bouncycastle.asn1.x509.X509Name subject

url

private String url

request

private String request

subjectScep

private org.bouncycastle.asn1.x509.X509Name subjectScep

requestPayload

private org.bouncycastle.asn1.DERObject requestPayload

proxyIdentification

private org.bouncycastle.asn1.DEROctetString proxyIdentification

secureRandom

private SecureRandom secureRandom

pkiMessage

private org.bouncycastle.asn1.pkcs.ContentInfo pkiMessage

responseFile

private org.bouncycastle.asn1.DERObject responseFile

communityString

private String communityString

pkcsCertReqSigned

org.bouncycastle.asn1.pkcs.SignedData pkcsCertReqSigned

serial

org.bouncycastle.asn1.DERInteger serial

TYPE_PKCS10

public static int TYPE_PKCS10

TYPE_SPKAC

public static int TYPE_SPKAC

VERSION1

public static int VERSION1

VERSION2

public static int VERSION2

requestType

private int requestType

scepVersion

private int scepVersion

certificate

private URL certificate

lnkStateData

private StateData lnkStateData
Constructor Detail

ScepClient

public ScepClient()
Method Detail

setCaCert

public void setCaCert(org.bouncycastle.asn1.x509.X509CertificateStructure caCert)

getCaCert

public org.bouncycastle.asn1.x509.X509CertificateStructure getCaCert()

getCertReqOrig

public org.bouncycastle.asn1.DERObject getCertReqOrig()
Gets the certReqOrig

Returns:
Returns a CertificationRequest

setCertReqOrig

public void setCertReqOrig(org.bouncycastle.asn1.DERObject certReqOrig)
Sets the certReqOrig.

Parameters:
certReqOrig - The certReqOri to set

setCertReqOrig

public void setCertReqOrig(String certReqOrig)

getCertReq

public org.bouncycastle.asn1.pkcs.CertificationRequest getCertReq()
Gets the certReq.

Returns:
Returns a CertificationRequest

setCertReq

public void setCertReq(org.bouncycastle.asn1.pkcs.CertificationRequest certReq)
Sets the certReq.

Parameters:
certReq - The certReq to set

setCertReq

public void setCertReq(String certReq)

getCertReqEnvelope

public org.bouncycastle.asn1.DERObject getCertReqEnvelope()
Gets the pkcsCertReqEnvelope.

Returns:
Returns a DERObject

setCertReqEnvelope

public void setCertReqEnvelope(org.bouncycastle.asn1.DERObject envelope)
Sets the pkcsCertReqEnvelope.


setTransactionId

public void setTransactionId(org.bouncycastle.asn1.DERPrintableString transId)

getTransactionId

public org.bouncycastle.asn1.DERPrintableString getTransactionId()

getCaPubKey

public org.bouncycastle.asn1.x509.RSAPublicKeyStructure getCaPubKey()
Gets the caPubKey.

Returns:
Returns a RSAPublicKeyStructure

setCaPubKey

public void setCaPubKey(org.bouncycastle.asn1.x509.RSAPublicKeyStructure caPubKey)
Sets the caPubKey.

Parameters:
caPubKey - The caPubKey to set

getScepPrivateKey

public org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure getScepPrivateKey()
Gets the scepPrivateKey.

Returns:
Returns a RSAPrivateKeyStructure

setScepPrivateKey

public void setScepPrivateKey(org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure scepPrivateKey)
Sets the scepPrivateKey.

Parameters:
scepPrivateKey - The scepPrivateKey to set

getScepPublicKey

public org.bouncycastle.asn1.x509.RSAPublicKeyStructure getScepPublicKey()
Gets the scepPublicKey.

Returns:
Returns a RSAPublicKeyStructure

setScepPublicKey

public void setScepPublicKey(org.bouncycastle.asn1.x509.RSAPublicKeyStructure scepPublicKey)
Sets the scepPublicKey.

Parameters:
scepPublicKey - The scepPublicKey to set

getChallenge

public org.bouncycastle.asn1.DERPrintableString getChallenge()
Gets the challenge.

Returns:
Returns a DERPrintableString

setChallenge

public void setChallenge(org.bouncycastle.asn1.DERPrintableString challenge)
Sets the challenge.

Parameters:
challenge - The challenge to set

setChallenge

public void setChallenge(String challenge)
Sets the challenge.

Parameters:
challenge - The challenge to set

getUrl

public String getUrl()
Gets the url.

Returns:
Returns a String

setUrl

public void setUrl(String url)
Sets the url.

Parameters:
url - The url to set

getSecureRandom

public SecureRandom getSecureRandom()
Gets the secureRandom.

Returns:
Returns a SecureRandom

setSecureRandom

public void setSecureRandom(SecureRandom secureRandom)
Sets the secureRandom.

Parameters:
secureRandom - The secureRandom to set

loadResponseFile

public void loadResponseFile(String filename)
                      throws FileNotFoundException,
                             IOException
FileNotFoundException
IOException

loadCA

public boolean loadCA(String url)
               throws IOException
IOException

loadCA

private boolean loadCA(URL url)
                throws IOException
Load CA Cert from URL

IOException

post

public int post(org.bouncycastle.asn1.DERObject der,
                String operation)
         throws IOException
send DERObject to scep server (http req)

IOException

loadPrivateKey

public void loadPrivateKey(URL url)
                    throws FileNotFoundException,
                           IOException
Load CA Certificate from File

FileNotFoundException
IOException

loadPublicKey

public void loadPublicKey(URL url)
                   throws FileNotFoundException,
                          IOException
FileNotFoundException
IOException

loadRequest

public void loadRequest(URL url)
                 throws FileNotFoundException,
                        IOException
FileNotFoundException
IOException

debugOut

public static void debugOut(String str)

Execute

public boolean Execute(String command)
                throws IOException,
                       ScepError,
                       ScepPending
IOException
ScepError
ScepPending

getResponseFile

public org.bouncycastle.asn1.DERObject getResponseFile()
Getter for property responseFile.

Returns:
Value of property responseFile.

setResponseFile

public void setResponseFile(org.bouncycastle.asn1.DERObject responseFile)
Setter for property responseFile.

Parameters:
responseFile - New value of property responseFile.

getSignedEndEntityCertificate

public org.bouncycastle.asn1.x509.X509CertificateStructure getSignedEndEntityCertificate()
Getter for property signedEndEntityCertificate.

Returns:
Value of property signedEndEntityCertificate.

getBase64SignedEndEntityCertificate

public String getBase64SignedEndEntityCertificate()

setSignedEndEntityCertificate

public void setSignedEndEntityCertificate(org.bouncycastle.asn1.x509.X509CertificateStructure signedEndEntityCertificate)
Setter for property signedEndEntityCertificate.

Parameters:
signedEndEntityCertificate - New value of property signedEndEntityCertificate.

storeCertificate

public void storeCertificate(String filename)
                      throws Exception
Exception

getPkiMessage

public org.bouncycastle.asn1.pkcs.ContentInfo getPkiMessage()
Getter for property pkiMessage.

Returns:
Value of property pkiMessage.

setPkiMessage

public void setPkiMessage(org.bouncycastle.asn1.pkcs.ContentInfo pkiMessage)

getRequest

public String getRequest()
Getter for property request.

Returns:
Value of property request.

setRequest

public void setRequest(String request)

getRequestType

public int getRequestType()
Gets the requestType.

Returns:
Returns a int

setRequestType

public void setRequestType(int requestType)
Sets the requestType.

Parameters:
requestType - The requestType to set

getScepVersion

public int getScepVersion()
Gets the scepVersion.

Returns:
Returns a int

setScepVersion

public void setScepVersion(int scepVersion)
Sets the scepVersion.

Parameters:
scepVersion - The scepVersion to set

getCommunityString

public String getCommunityString()
Getter for property communityString.

Returns:
Value of property communityString.

setCommunityString

public void setCommunityString(String communityString)

getRequestPayload

public org.bouncycastle.asn1.DERObject getRequestPayload()
Getter for property requestPayload.

Returns:
Value of property requestPayload.

setRequestPayload

public void setRequestPayload(org.bouncycastle.asn1.DERObject requestPayload)

getProxyIdentification

public org.bouncycastle.asn1.DEROctetString getProxyIdentification()
Getter for property proxyIdentification.

Returns:
Value of property proxyIdentification.

setProxyIdentification

public void setProxyIdentification(org.bouncycastle.asn1.DEROctetString proxyIdentification)
Setter for property proxyIdentification.


getSubjectScep

public org.bouncycastle.asn1.x509.X509Name getSubjectScep()
Getter for property subjectScep.

Returns:
Value of property subjectScep.

setSubjectScep

public void setSubjectScep(org.bouncycastle.asn1.x509.X509Name subjectScep)

setSubjectScep

public void setSubjectScep(String subject)

getSubject

public org.bouncycastle.asn1.x509.X509Name getSubject()
Getter for property subject.

Returns:
Value of property subject.

setSubject

public void setSubject(String subject)

setSubject

public void setSubject(org.bouncycastle.asn1.x509.X509Name subject)

getStateData

public StateData getStateData()
                       throws ScepError
ScepError

setStateData

public void setStateData(StateData data)

getCertificate

public URL getCertificate()
Getter for property certificate.

Returns:
Value of property certificate.

setCertificate

public void setCertificate(URL certificate)


ScepClient is copyright by Ueli Rutishauser + Alain Schaefer