public class ChallengePassword extends AttributeValue
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();
...
}
Attribute,
AttributeValue,
CertificateRequest| Modifier and Type | Field and Description |
|---|---|
static ObjectID |
oid
The attributeType object identifier of the PKCS#9 ChallengePassword attribute.
|
| Constructor and Description |
|---|
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(java.lang.String password)
Creates a ChallengePassword from the given password.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
java.lang.String |
getPassword()
Gets the challenge password.
|
ASN1Object |
toASN1Object()
Returns this ChallengePassword as ASN1Object.
|
java.lang.String |
toString()
Returns a string representation of this ChallengePassword.
|
getName, multipleAllowedpublic static final ObjectID oid
public ChallengePassword()
public ChallengePassword(java.lang.String password)
PrintableString if the supplied password contains only printable characters,
otherwise it will be encoded as UTF8String.password - the challenge passwordpublic ChallengePassword(ASN1String 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)) }
password - the challenge password as ASN.1 stringpublic ChallengePassword(ASN1Object obj) throws CodingException
obj - the ChallengePassword as ASN1ObjectCodingException - if the ASN1Object is not an ASN1Stringpublic java.lang.String getPassword()
public void decode(ASN1Object obj) throws CodingException
ChallengePassword object for parsing
the internal structure.obj - the ChallengePassword as ASN1ObjectCodingException - if the ASN1Object is not an ASN1Stringpublic ASN1Object toASN1Object()
public ObjectID getAttributeType()
getAttributeType in class AttributeValuepublic java.lang.String toString()
toString in class AttributeValue