com.rsa.certj.crmf

Class CertReqMessages

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

public class CertReqMessages
extends Object
implements Cloneable, Serializable

This class contains the CertReqMessages, defined in Certificate Request Message Format (RFC 2511).

 CertReqMessages ::= SEQUENCE SIZE (1...MAX) OF CertReqMsg

 CertReqMsg ::= SEQUENCE {
   certReq CertRequest
   pop ProofOfPossession OPTIONAL,  -- content depends upon key type
   regInfo  SEQUENCE SIZE (1...MAX) of AttributeTypeAndValue OPTIONAL }

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

See Also

Serialized Form

Constructor Summary

CertReqMessages()

The default constructor for this class.

CertReqMessages(CertRequest certRequest, ProofOfPossession pop, RegInfo regInfo)

Creates a CertReqMessages object that and initializes it with the values given.

 

Method Summary

 void

addCertReqMsg(CertRequest certRequest, ProofOfPossession pop, RegInfo regInfo)

Adds a certificate request message to the list of the messages.

 Object

clone()

Overrides the default clone method to get a deeper clone.

 void

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

This method decodes the BER-encoding of a CertReqMessages object setting it with the value given by dataBER beginning at offset.

 boolean

equals(Object obj)

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

 int

getCertReqMsgCount()

Gets the number of Certificate Request Messages in this object.

 CertRequest

getCertRequest(int index)

Gets the certificate request field of the CertReqMsg, specified by index.

 int

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

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

 int

getDERLen(int special)

Returns the length of the DER encoding of this CertReqMessages object.

static int

getNextBEROffset(byte[] certBER, int offset)

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

 ProofOfPossession

getPOP(int index)

Gets the ProofOfPossession field of the CertReqMsg, specified by index.

 RegInfo

getRegInfo(int index)

Gets the RegInfo field of the CertReqMsg, specified by index.

 void

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

Sets the environment variables.

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

Constructor Detail

CertReqMessages

public CertReqMessages()
The default constructor for this class.

CertReqMessages

public CertReqMessages(CertRequest certRequest,
                       ProofOfPossession pop,
                       RegInfo regInfo)
                throws CRMFException
Creates a CertReqMessages object that and initializes it with the values given.

Parameters

         certRequest  

The certificate request data.

         pop  

The proof of possession.

         regInfo  

The supplementary information related to the context of the certificate request.

Throws

CRMFException - If specified values are invalid.
Method Detail

addCertReqMsg

public void addCertReqMsg(CertRequest certRequest,
                          ProofOfPossession pop,
                          RegInfo regInfo)
                   throws CRMFException
Adds a certificate request message to the list of the messages. The objects passed in are not cloned.

Parameters

         certRequest  

The certificate request data.

         pop  

The proof of possession.

         regInfo  

The supplementary information related to the context of the certificate request.

Throws

CRMFException - If specified values are invalid.

decodeCertReqMessages

public void decodeCertReqMessages(byte[] certBER,
                                  int offset,
                                  int special)
                           throws CRMFException
This method decodes the BER-encoding of a CertReqMessages object setting it with the value given by dataBER beginning at offset.

Parameters

         certBER  

The byte array that contains BER encoding of this object.

         offset  

The offset into certBER.

         special  

Any special instructions of the DER encoding.

Throws

CRMFException - If encoding is invalid.

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 when using keyEncipherment or keyAgreement proof of possession, or when using Controls in CertRequest. If you are not sure if you have those POPs or Controls set when decoding, set these environment variables.

Parameters

         certJ  

CertJ object that contains environment information..

         pathCtx  

The CertPathCtx object that contains certificate path validation information Pass null when the EnvelopedData option in EncryptedKey in PKIArchiveOptions control is not used.

         pubKey  

The public key used to encrypt the secret key in the EncryptedValue structure. Pass null if decoding, or when the EncryptedValue option in EncryptedKey in PKIArchiveOptions control is not used.

         privKey  

The public key used to decrypt the secret key in the EncryptedValue structure. Pass null if encoding, or when the EncryptedValue option in EncryptedKey in PKIArchiveOptions control is not used.


getCertRequest

public CertRequest getCertRequest(int index)
                           throws CRMFException
Gets the certificate request field of the CertReqMsg, specified by index. It returns the actual object, not a clone.

Parameters

         index  

The index that specifies the CertReqMsg.

Returns

The CertRequest field of CertReqMsg.

Throws

CRMFException - If index is invalid.

getPOP

public ProofOfPossession getPOP(int index)
                         throws CRMFException
Gets the ProofOfPossession field of the CertReqMsg, specified by index. It returns the actual object, not a clone.

Parameters

         index  

The index that dpecifies CertReqMsg.

Returns

The ProofOfPossession field of CertReqMsg.

Throws

CRMFException - If index is invalid.

getRegInfo

public RegInfo getRegInfo(int index)
                   throws CRMFException
Gets the RegInfo field of the CertReqMsg, specified by index. It returns the actual object, not a clone.

Parameters

         index  

The index that dpecifies CertReqMsg.

Returns

The RegInfo field of CertReqMsg.

Throws

CRMFException - If index is invalid.

getCertReqMsgCount

public int getCertReqMsgCount()
Gets the number of Certificate Request Messages in this object.

Returns

The number of messages.

getNextBEROffset

public static int getNextBEROffset(byte[] certBER,
                                   int offset)
                            throws CRMFException
Given certBER, the BER of a CertReqMessages 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 CertReqMessages 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.

getDERLen

public int getDERLen(int special)
              throws CRMFException
Returns the length of the DER encoding of this CertReqMessages object. 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 this CertReqMessages object.

getDEREncoding

public int getDEREncoding(byte[] encoding,
                          int offset,
                          int special)
                   throws CRMFException
Places the DER encoding of the CertReqMessages 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.

equals

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

Overrides

equals in class Object

Parameters

         obj  

The instance of the CertReqMessages 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 CertReqMessages 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