com.rsa.certj.crmf

Class CertRequest

java.lang.Object
  |
  +--com.rsa.certj.crmf.CertRequest
All Implemented Interfaces:
Cloneable, Serializable

public class CertRequest
extends Object
implements Cloneable, Serializable

This class contains the CertRequest field from CertReqMsg message defined in CertificateRequest Message Format (RFC 2511).

 CertRequest ::= SEQUENCE {
   certReqId     INTEGER,       -- ID for matching request and reply
   certTemplate  CertTemplate,  -- Selected fields of cer to be issued
   controls      Controls OPTIONAL } -- Attributes affecting issuance

Copyright © RSA Security Inc., 2000-2001. All rights reserved.

See Also

Serialized Form

Constructor Summary

CertRequest()

Constructs an empty CertRequest object.

CertRequest(int id, CertTemplate template, Controls controls)

Creates a CertRequest object and initializes it with the given values.

 

Method Summary

 Object

clone()

Overrides the default clone method to get a deeper clone.

 void

decodeCertRequest(byte[] certBER, int offset, int special)

This method sets the values in this object with the value given by certBER beginning at offset, the BER encoding of a certificate request.

 boolean

equals(Object obj)

Returns true if this object and obj contain the same CertRequest; otherwise, false.

 CertTemplate

getCertTemplate()

Gets the certificate template.

 Controls

getControls()

Gets the Controls field.

 int

getDEREncoding(byte[] encoding, int offset, int special)

Places the DER encoding of the CertRequest object into encoding, beginning at offset.

 int

getDERLen(int special)

Returns the number of bytes that will be used by the DER encoding of the certificate request.

static int

getNextBEROffset(byte[] certBER, int offset)

Given certBER, the BER of a CertRequest object beginning at offset, finds the index to the next element in the encoding.

 int

getRequestID()

Gets the certificate request ID.

 void

setCertTemplate(CertTemplate template)

Sets the cert template to be template.

 void

setControls(Controls controls)

Sets the Controls field.

 void

setEnvironment(CertJ certJ, CertPathCtx pathCtx, com.rsa.jsafe.JSAFE_PublicKey pubKey, com.rsa.jsafe.JSAFE_PrivateKey privKey)

Sets the environment variables; use this method only if use controls, that need database / certificate verification operations (e.g., PKIArchiveOptions control).

 void

setRequestID(int id)

Sets the certificate request ID to id.

 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CertRequest

public CertRequest()
Constructs an empty CertRequest object.

CertRequest

public CertRequest(int id,
                   CertTemplate template,
                   Controls controls)
            throws CRMFException
Creates a CertRequest object and initializes it with the given values.

Parameters

         id  

The ID for matching the request and the reply.

         template  

The selected fields of the certificate to be issued.

         controls  

The attributes affecting issuance. If the controls field is not set, pass null.

Throws

CRMFException - If the passed values are not valid.
Method Detail

decodeCertRequest

public void decodeCertRequest(byte[] certBER,
                              int offset,
                              int special)
                       throws CRMFException
This method sets the values in this object with the value given by certBER beginning at offset, the BER encoding of a certificate request.

This method only reads the certificate request. It does not perform any verification. If this CertRequest has Controls, set environment values (CertJ and CertPathCtx objects) and the recipient's public key and/or private key

Parameters

         certBER  

The BER encoding of a certificate request.

         offset  

The offset into certBER where the encoding begins.

         special  

Any special BER/DER circumstances.

Throws

CRMFException - If the BER is not a valid certificate request.

getNextBEROffset

public static int getNextBEROffset(byte[] certBER,
                                   int offset)
                            throws CRMFException
Given certBER, the BER of a CertRequest object beginning at offset, finds the index to the next element in the encoding. That is, this method gets the next offset after the specified BER.

For example, if the offset is 120 and the BER encoding is 1819 bytes, this method returns 1939, the index immediately following the attributes. That is, certBER[120] is the first byte in the encoding of the attributes, certBER[1938] is the last byte in the encoding of the attributes, and the next element begins at index 1939.

Parameters

         certBER  

The BER encoding of a CertRequest object.

         offset  

The offset into nameBER where the encoding begins.

Returns

An int that is the index to the next element in the BER encoding.

Throws

CRMFException - If the method cannot read the BER encoding.

setRequestID

public void setRequestID(int id)
Sets the certificate request ID to id.

Parameters

         id  

The ID for matching request and reply.


getRequestID

public int getRequestID()
Gets the certificate request ID.

Returns

The certificate request ID.

setCertTemplate

public void setCertTemplate(CertTemplate template)
                     throws CRMFException
Sets the cert template to be template.

Parameters

         template  

Selected fields of cert to be issued

Throws

CRMFException - If the cert template is not valid or NULL.

getCertTemplate

public CertTemplate getCertTemplate()
                             throws CRMFException
Gets the certificate template.

Returns

The certificate template, the selected fields of the certificate to be issued, or null, if the certificate template fields are not set.

Throws

CRMFException - If there is a cloning error.

setControls

public void setControls(Controls controls)
                 throws CRMFException
Sets the Controls field.

Parameters

         controls  

Attributes affecting issuance

Throws

CRMFException - If the controls data is not valid

getControls

public Controls getControls()
                     throws CRMFException
Gets the Controls field.

Returns

The controls field, attributes affecting issuance, or null, if the controls field is not set.

Throws

CRMFException - If there is a cloning error.

getDERLen

public int getDERLen(int special)
              throws CRMFException
Returns the number of bytes that will be used by the DER encoding of the certificate request. If this object is not set with values, returns 0.

Parameters

         special  

The special DER circumstances of the encoding, if there are any.

Returns

The number of bytes that will be used by the DER encoding of the cert request.

getDEREncoding

public int getDEREncoding(byte[] encoding,
                          int offset,
                          int special)
                   throws CRMFException
Places the DER encoding of the CertRequest object into encoding, beginning at offset. To determine the length of the encoding, call getDERLen. If this object is not yet set with values, then this method places nothing into the array and returns zero. Use the special argument if the DER encoding should follow any special instructions.

For example, to indicate the following:

      data   [1] IMPLICIT INTEGER
 
pass in the following:

      special = (ASN1.IMPLICIT | 1);
 
If there are no special circumstances, pass in the following:

      special = 0
 
The following ASN.1 constants are possible values for special: APP_IMPLICIT, APP_EXPLICIT, PRIVATE_IMPLICIT, PRIVATE_EXPLICIT, OPTIONAL, DEFAULT, CONTEXT_IMPLICIT, or CONTEXT_EXPLICIT.

Parameters

         encoding  

The byte array into which the result will be placed.

         offset  

The offset into encoding where writing begins.

         special  

The special circumstances of the DER encoding, if there are any.

Returns

The number of bytes actually placed into encoding.

Throws

CRMFException - If the method cannot create the DER encoding.

setEnvironment

public void setEnvironment(CertJ certJ,
                           CertPathCtx pathCtx,
                           com.rsa.jsafe.JSAFE_PublicKey pubKey,
                           com.rsa.jsafe.JSAFE_PrivateKey privKey)
Sets the environment variables; use this method only if use controls, that need database / certificate verification operations (e.g., PKIArchiveOptions control).

Parameters

         certJ  

CertJ object that contains environment information

         pathCtx  

The CertPathCtx object that contains certificate path validation information (pass NULL if not using EnvelopedData option in EncryptedKey in PKIArchiveOptions control)

         pubKey  

Public key used to encrypt the Secret key in EncryptedValue structure (pass NULL if decoding, or not using EncryptedValue option in EncryptedKey in PKIArchiveOptions control)

         privKey  

Private key used to decrypt the Secret key in EncryptedValue structure (pass NULL if encoding, or not using EncryptedValue option in EncryptedKey in PKIArchiveOptions control)


equals

public boolean equals(Object obj)
Returns true if this object and obj contain the same CertRequest; otherwise, false.

Overrides

equals in class Object

Parameters

         obj  

The instance of the CertRequest object.

Returns

A boolean that indicates whether these objects are equal.

clone

public Object clone()
             throws CloneNotSupportedException
Overrides the default clone method to get a deeper clone.

Returns

A new CertRequest object, a copy of this object.

Throws

CloneNotSupportedException - If the cloning operation is not successful.


RSA BSAFE ® Cert-J 2.1.1 001-047007-211-001-000