iaik.pkcs.pkcs9
Class ChallengePassword

java.lang.Object
  |
  +--iaik.asn1.structures.AttributeValue
        |
        +--iaik.pkcs.pkcs9.ChallengePassword
All Implemented Interfaces:
ASN1Type

public class ChallengePassword
extends AttributeValue

The PKCS#9 ChallengePassword attribute.

PKCS#9 specifies the ChallengePassword attribute to may be included in a PKCS#10 CertificateRequest to specify a password by which an entity may request certificate revocation:

 challengePassword ATTRIBUTE ::= {
   WITH SYNTAX DirectoryString {pkcs-9-ub-challengePassword}
   EQUALITY MATCHING RULE caseExactMatch
   SINGLE VALUE TRUE
   ID pkcs-9-at-challengePassword
 }
 
PKCS#9 recommends to use use the PrintableString DirectoryString whenever possible, otherwise UTF8String should be used.

The following example sets a ChallengePassword attribute for a certificate request:

 CertificateRequest request = ...;
 Attribute[] attributes = new Attribute[1];
 // add a ChallengePassword attribute 
 ChallengePassword challengePassword = new ChallengePassword("myPassword");
 attributes[0] = new Attribute(challengePassword);
 // now set the attributes
 request.setAttributes(attributes);
 
On the receiving end, the CA may query for an ChallengePassword attribute included in the certificate request:
 CertificateRequest request = new CertificateRequest(is);
 // verify the request
 if (request.verify()) {
   System.out.println("CertificateRequest verify ok.");
 } else {
   throw new RuntimeException("CertificateRequest verify error.");
 }       
 // look for an ChallengePassword included
 ChallengePassword challengePassword = (ChallengePassword)request.getAttributeValue(ChallengePassword.oid);
 if (challengePassword != null) {
    String password = challengePassword.getPassword();
    ...
 }
 

Version:
File Revision 8
See Also:
Attribute, AttributeValue, CertificateRequest

Field Summary
static ObjectID oid
          The attributeType object identifier of the PKCS#9 ChallengePassword attribute.
 
Constructor Summary
ChallengePassword()
          Default constructor.
ChallengePassword(ASN1Object obj)
          Creates a ChallengePassword from its ASN.1 representation.
ChallengePassword(ASN1String password)
          Creates a ChallengePassword from the given password.
ChallengePassword(String password)
          Creates a ChallengePassword from the given passowrd.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes the given ASN.1 ChallengePassword object for parsing the internal structure.
 ObjectID getAttributeType()
          Returns the OID (1.2.840.113549.1.9.7) identifying the ChallengePassword attribute type.
 String getPassword()
          Gets the challenge password.
 ASN1Object toASN1Object()
          Returns this ChallengePassword as ASN1Object.
 String toString()
          Returns a string representation of this ChallengePassword.
 
Methods inherited from class iaik.asn1.structures.AttributeValue
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

oid

public static final ObjectID oid
The attributeType object identifier of the PKCS#9 ChallengePassword attribute. The corresponding OID string is "1.2.840.113549.1.9.7".
Constructor Detail

ChallengePassword

public ChallengePassword()
Default constructor. Only used for dynamic object creation. Shall NOT be used by an application.

ChallengePassword

public ChallengePassword(String password)
Creates a ChallengePassword from the given passowrd. This ChallengePassword will be encoded as PrintableString if the supplied password contains only printable characters, otherwise it will be encoded as UTF8String.
Parameters:
password - the challenge password

ChallengePassword

public ChallengePassword(ASN1String password)
Creates a ChallengePassword from the given password.

The password has to be supplied as ASN1String. However, please be aware that this constructor does not check if the supplied ASN1 String actually represents a DirectoryString:

 DirectoryString ::= CHOICE {
   teletexString             TeletexString (SIZE (1..MAX)),
   printableString           PrintableString (SIZE (1..MAX)),
   universalString           UniversalString (SIZE (1..MAX)),
   utf8String                UTF8String (SIZE (1..MAX)),
   bmpString                 BMPString (SIZE(1..MAX))   }
 
Parameters:
password - the challenge password as ASN.1 string

ChallengePassword

public ChallengePassword(ASN1Object obj)
                  throws CodingException
Creates a ChallengePassword from its ASN.1 representation.
Parameters:
the - ChallengePassword as ASN1Object
Throws:
CodingException - if the ASN1Object is not an ASN1String
Method Detail

getPassword

public String getPassword()
Gets the challenge password.
Returns:
the challenge password

decode

public void decode(ASN1Object obj)
            throws CodingException
Decodes the given ASN.1 ChallengePassword object for parsing the internal structure.
Parameters:
obj - the ChallengePassword as ASN1Object
Throws:
CodingException - if the ASN1Object is not an ASN1String

toASN1Object

public ASN1Object toASN1Object()
Returns this ChallengePassword as ASN1Object.
Returns:
this ChallengePassword as ASN1Object

getAttributeType

public ObjectID getAttributeType()
Returns the OID (1.2.840.113549.1.9.7) identifying the ChallengePassword attribute type.
Overrides:
getAttributeType in class AttributeValue
Returns:
the OID identifying the ChallengePassword attribute type.

toString

public String toString()
Returns a string representation of this ChallengePassword.
Overrides:
toString in class AttributeValue
Returns:
this ChallengePassword as string

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK