com.rsa.certj.crmf

Class RegInfo

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

public class RegInfo
extends Object
implements Cloneable, Serializable

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

 regInfo   SEQUENCE SIZE (1...MAX) of AttributeTypeAndValue
 
 AttributeTypeAndValue ::= SEQUENCE {
  type         OBJECT IDENTIFIER,
  value        ANY DEFINED BY type }
 
 id-pkix  OBJECT IDENTIFIER  ::= { iso(1) identified-organization(3)
                        dod(6) internet(1) security(5) mechanisms(5) 7 }
 id-pkip  OBJECT IDENTIFIER ::= { id-pkix 5 }
 id-regInfo       OBJECT IDENTIFIER ::= { id-pkip id-regInfo(2) }
 id-regInfo-utf8Pairs    OBJECT IDENTIFIER ::= { id-regInfo 1 }
 
When regInfo is used to convey one or more name-value pairs (via id-regInfo-utf8Pairs), the first and subsequent pairs SHALL be structured as follows:

[name?value][%name?value]*%

This string is then encoded into an OCTET STRING and placed into the regInfo SEQUENCE.

Reserved characters are encoded using the URL Character Encoding Issues (RFC 1738), unless they are used for their reserved purposes.

The following table defines a recommended set of named elements. The value in the column "Name Value" is the exact text string that will appear in the regInfo.

    Name Value
    ----------
    version            -- version of this variation of regInfo use
    corp_company       -- company affiliation of subscriber
    org_unit           -- organizational unit
    mail_firstName     -- personal name component
    mail_middleName    -- personal name component
    mail_lastName      -- personal name component
    mail_email         -- subscriber's email address
    jobTitle           -- job title of subscriber
    employeeID         -- employee identification number or string
    mailStop           -- mail stop
    issuerName         -- name of CA
    subjectName        -- name of Subject
    validity           -- validity interval

 For example:

    version?1%corp_company?Acme, Inc.%org_unit?Engineering%
    mail_firstName?John%mail_lastName?Smith%jobTitle?Team Leader%
    mail_email?john@acme.com%
 

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

See Also

Serialized Form

Field Summary

static byte[]

REG_INFO_OID

This defines RegInfo OID.

 

Constructor Summary

RegInfo()

The default constructor for this class.

RegInfo(byte[] regInfoBER, int offset, int special)

Creates a RegInfo object that contains the values given.

RegInfo(String name, String value)

Creates a RegInfo object that contains the values given.

 

Method Summary

 void

addNameValuePair(String name, String value, boolean newRegInfo)

Adds name / value pair to the RegInfo object.

 Object

clone()

Overrides the default clone method to get a deeper clone.

 boolean

equals(Object obj)

Returns true if this object and obj contain the same RegInfo, returns false otherwise.

 String

getAttribute(int index)

Gets the attribute value, specified by index

 int

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

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

 int

getDERLen(int special)

Returns the number of bytes that will be used by the DER encoding of this regInfo.

static int

getNextBEROffset(byte[] infoBER, int offset)

Given infoBER, the BER of a RegInfo beginning at offset, finds the index to the next element in the encoding.

 int

getRegInfoCount()

Gets the number of attributes in this RegInfo object.

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

Field Detail

REG_INFO_OID

public static final byte[] REG_INFO_OID
This defines RegInfo OID.
Constructor Detail

RegInfo

public RegInfo()
The default constructor for this class.

RegInfo

public RegInfo(String name,
               String value)
        throws CRMFException
Creates a RegInfo object that contains the values given.

Parameters

         name  

The name of the attribute

         value  

The value of the attribute

Throws

CRMFException - If passed in values are null.

RegInfo

public RegInfo(byte[] regInfoBER,
               int offset,
               int special)
        throws CRMFException
Creates a RegInfo object that contains the values given.

Parameters

         regInfoBER  

The byte array that contains BER encoding of this object

         offset  

Offset in this array

         special  

Set that argument to any special instructions of the DER encoding.

Throws

CRMFException - If encoding is invalid
Method Detail

addNameValuePair

public void addNameValuePair(String name,
                             String value,
                             boolean newRegInfo)
                      throws CRMFException
Adds name / value pair to the RegInfo object.

Parameters

         name  

The name of the attribute

         value  

The value of the attribute

         newRegInfo  

If true, we add this name/value pair to the new attribute, otherwise we attach this name/value pair to the last created attribute.

For example, if newRegInfo is set to false, and name is set to "corp_company", and the value is set to "Acme, Inc." and we already had an attribute with value "version?1%", we just concatenate the new name/value pair to the old one: version?1%corp_company?Acme, Inc.%

Throws

CRMFException - If passed in values are null.

getAttribute

public String getAttribute(int index)
                    throws CRMFException
Gets the attribute value, specified by index

Parameters

         index  

Index into RegInfo, that specifies the attribute.

Throws

CRMFException - If this indexis invalid

getRegInfoCount

public int getRegInfoCount()
Gets the number of attributes in this RegInfo object.

Returns

The number attributes in this RegInfo object.

getNextBEROffset

public static int getNextBEROffset(byte[] infoBER,
                                   int offset)
                            throws CRMFException
Given infoBER, the BER of a RegInfo beginning at offset, finds the index to the next element in the encoding. In other words, gets the next offset after the regInfo.

For example, if the offset is 120 and the regInfo's BER encoding is 1819 bytes, this method will return 1939, the index immediately following the regInfo. That is, infoBER[120] is the first byte in the encoding of the regInfo, infoBER[1938] is the last byte in the encoding of the regInfo, and the next element begins at index 1939.

Parameters

         infoBER  

The BER encoding of a RegInfo.

         offset  

The offset into infoBER where the encoding begins.

Returns

An int, 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 number of bytes that will be used by the DER encoding of this regInfo. 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 regInfo.

getDEREncoding

public int getDEREncoding(byte[] encoding,
                          int offset,
                          int special)
                   throws CRMFException
Places the DER encoding of the RegInfo object into encoding, beginning at offset. To determine how long the encoding will be, call getDERLen. If this object is not yet set with values, this method places nothing into the array and returns 0. To indicate that the DER encoding should follow any special instructions, use the special argument. For instance, to indicate

   extension   [1] IMPLICIT Extension
 
pass in special = (ASN1.CONTEXT_IMPLICIT | 1);

Of course, if there are no special circumstances, pass in 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 the writing is to begin.

         special  

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

Returns

The number of bytes actually placed into encoding.

equals

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

Overrides

equals in class Object

Parameters

         obj  

The instance of RegInfo 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 GeneralNames 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