Package org.wildfly.security.x500.cert
Class PKCS10CertificateSigningRequest.Builder
- java.lang.Object
- 
- org.wildfly.security.x500.cert.PKCS10CertificateSigningRequest.Builder
 
- 
- Enclosing class:
- PKCS10CertificateSigningRequest
 
 public static class PKCS10CertificateSigningRequest.Builder extends Object ABuilderto configure and generate aPKCS10CertificateSigningRequest.
- 
- 
Field SummaryFields Modifier and Type Field Description private Certificatecertificateprivate Map<String,X509CertificateExtension>extensionsByOidprivate PublicKeypublicKeyprivate StringsignatureAlgorithmNameprivate StringsignatureAlgorithmOidprivate PrivateKeysigningKeyprivate X500PrincipalsubjectDnprivate static intVERSION
 - 
Constructor SummaryConstructors Constructor Description Builder()Construct a new uninitialized instance.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PKCS10CertificateSigningRequest.BuilderaddExtension(boolean critical, String extensionName, String extensionValue)Add an X.509 certificate extension that should be included in the certificate signing request using the given extension name and string value.PKCS10CertificateSigningRequest.BuilderaddExtension(X509CertificateExtension extension)Add an X.509 certificate extension that should be included in the certificate signing request.PKCS10CertificateSigningRequestbuild()Attempt to generate a PKCS #10 certificate signing request.private voidencodeAlgorithmIdentifier(DEREncoder encoder)Encode anAlgorithmIdentifierusing the given DER encoder.private voidencodeAttributes(DEREncoder encoder)EncodeAttributesusing the given DER encoder.private voidencodeCertificationRequest(DEREncoder encoder)Encode aCertificationRequestusing the given DER encoder.private voidencodeCertificationRequestInfo(DEREncoder encoder)Encode aCertificationRequestInfousing the given DER encoder.private static voidencodeExtension(DEREncoder encoder, X509CertificateExtension extension)Encode anExtensionusing the given DER encoder.private voidencodeExtensionRequest(DEREncoder encoder)Encode anExtensionRequestusing the given DER encoder.PKCS10CertificateSigningRequest.BuildersetCertificate(Certificate certificate)Set the certificate.PKCS10CertificateSigningRequest.BuildersetSignatureAlgorithmName(String signatureAlgorithmName)Set the signature algorithm name.PKCS10CertificateSigningRequest.BuildersetSigningKey(PrivateKey signingKey)Set the signing key.PKCS10CertificateSigningRequest.BuildersetSubjectDn(X500Principal subjectDn)Set the subject DN.
 
- 
- 
- 
Field Detail- 
VERSIONprivate static final int VERSION - See Also:
- Constant Field Values
 
 - 
certificateprivate Certificate certificate 
 - 
publicKeyprivate PublicKey publicKey 
 - 
signingKeyprivate PrivateKey signingKey 
 - 
signatureAlgorithmNameprivate String signatureAlgorithmName 
 - 
signatureAlgorithmOidprivate String signatureAlgorithmOid 
 - 
subjectDnprivate X500Principal subjectDn 
 - 
extensionsByOidprivate final Map<String,X509CertificateExtension> extensionsByOid 
 
- 
 - 
Method Detail- 
setCertificatepublic PKCS10CertificateSigningRequest.Builder setCertificate(Certificate certificate) Set the certificate.- Parameters:
- certificate- the certificate (must not be- null)
- Returns:
- this builder instance
 
 - 
setSigningKeypublic PKCS10CertificateSigningRequest.Builder setSigningKey(PrivateKey signingKey) Set the signing key.- Parameters:
- signingKey- the signing key (must not be- null)
- Returns:
- this builder instance
 
 - 
setSubjectDnpublic PKCS10CertificateSigningRequest.Builder setSubjectDn(X500Principal subjectDn) Set the subject DN.- Parameters:
- subjectDn- the subject DN (must not be- null)
- Returns:
- this builder instance
 
 - 
setSignatureAlgorithmNamepublic PKCS10CertificateSigningRequest.Builder setSignatureAlgorithmName(String signatureAlgorithmName) Set the signature algorithm name.- Parameters:
- signatureAlgorithmName- the signature algorithm name (must not be- null)
- Returns:
- this builder instance
 
 - 
addExtensionpublic PKCS10CertificateSigningRequest.Builder addExtension(X509CertificateExtension extension) throws IllegalArgumentException Add an X.509 certificate extension that should be included in the certificate signing request. If an extension with the same OID already exists, an exception is thrown.- Parameters:
- extension- the extension to add (must not be- null)
- Returns:
- this builder instance
- Throws:
- IllegalArgumentException- if an extension with the same OID has already been added
 
 - 
addExtensionpublic PKCS10CertificateSigningRequest.Builder addExtension(boolean critical, String extensionName, String extensionValue) throws IllegalArgumentException Add an X.509 certificate extension that should be included in the certificate signing request using the given extension name and string value. If an extension with the same name already exists, an exception is thrown. The following extension names and values are supported:-  name: BasicConstraints
 value: ca:{true|false}[,pathlen:<len>]wherecaindicates whether or not the subject is a CA. Ifcais true,pathlenindicates the path length constraint.
-  name: KeyUsage
 value: usage(,usage)*wherevalueis a list of the allowed key usages, where eachusagevalue must be one of the following (usagevalues are case-sensitive):- digitalSignature
- nonRepudiation
- keyEncipherment
- dataEncipherment
- keyAgreement
- keyCertSign
- cRLSign
- encipherOnly
- decipherOnly
 
-  name: ExtendedKeyUsage
 value: usage(,usage)*wherevalueis a list of the allowed key purposes, where eachusagevalue must be one of the following (usagevalues are case-sensitive):- serverAuth
- clientAuth
- codeSigning
- emailProtection
- timeStamping
- OCSPSigning
- any OID string
 
-  name SubjectAlternativeName
 value: type:val(,type:val)*wherevalueis a list oftype:valpairs, wheretypecan beEMAIL,URI,DNS,IP, orOIDandvalis a string value for thetype.
-  name: IssuerAlternativeName
 value: type:val(,type:val)*wherevalueis a list oftype:valpairs, wheretypecan beEMAIL,URI,DNS,IP, orOIDandvalis a string value for thetype.
-  name: AuthorityInformationAccess
 value: method:location-type:location-value(,method:location-type:location-value)*wherevalueis a list ofmethod:location-type:location-valuetriples, wheremethodcan beocsp,caIssuers, or any OID andlocation-type:location-valuecan be anytype:valpair as defined for theSubjectAlternativeNameextension.
-  name: SubjectInformationAccess
 value: method:location-type:location-value(,method:location-type:location-value)*wherevalueis a list ofmethod:location-type:location-valuetriples, wheremethodcan betimeStamping,caRepository, or any OID andlocation-type:location-valuecan be anytype:valpair as defined for theSubjectAlternativeNameextension.
 
 
 
 
 - Parameters:
- critical- whether the extension should be marked as critical
- extensionName- the extension name (must not be- null)
- extensionValue- the extension value, as a string (must not be- null)
- Returns:
- this builder instance
- Throws:
- IllegalArgumentException- if an extension with the same name has already been added or if an error occurs while attempting to add the extension
 
-  
 - 
buildpublic PKCS10CertificateSigningRequest build() throws IllegalArgumentException Attempt to generate a PKCS #10 certificate signing request.- Returns:
- the PKCS #10 certificate signing request
- Throws:
- IllegalArgumentException- if a required builder parameter is missing or invalid
 
 - 
encodeCertificationRequestprivate void encodeCertificationRequest(DEREncoder encoder) Encode aCertificationRequestusing the given DER encoder. The ASN.1 definition ofCertificationRequestis:CertificationRequest ::= SEQUENCE { certificationRequestInfo CertificationRequestInfo, signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }}, signature BIT STRING }- Parameters:
- encoder- the DER encoder
 
 - 
encodeCertificationRequestInfoprivate void encodeCertificationRequestInfo(DEREncoder encoder) Encode aCertificationRequestInfousing the given DER encoder. The ASN.1 definition ofCertificationRequestInfois:CertificationRequestInfo ::= SEQUENCE { version INTEGER { v1(0) } (v1,...), subject Name, subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }}, attributes [0] Attributes{{ CRIAttributes }} }- Parameters:
- encoder- the DER encoder
 
 - 
encodeAlgorithmIdentifierprivate void encodeAlgorithmIdentifier(DEREncoder encoder) Encode anAlgorithmIdentifierusing the given DER encoder. The ASN.1 definition ofAlgorithmIdentifieris:AlgorithmIdentifier {ALGORITHM:IOSet } ::= SEQUENCE { algorithm ALGORITHM.&id({IOSet}), parameters ALGORITHM.&Type({IOSet}{@algorithm}) OPTIONAL }- Parameters:
- encoder- the DER encoder
 
 - 
encodeAttributesprivate void encodeAttributes(DEREncoder encoder) EncodeAttributesusing the given DER encoder. The ASN.1 definition ofAttributesis:Attributes ::= SET OF Attribute Attribute :: SEQUENCE { type AttributeType, values SET OF AttributeValue } AttributeType ::= OBJECT IDENTIFIER AttributeValue ::= ANY defined by type- Parameters:
- encoder- the DER encoder
 
 - 
encodeExtensionRequestprivate void encodeExtensionRequest(DEREncoder encoder) Encode anExtensionRequestusing the given DER encoder. The ASN.1 definition ofExtensionRequestis:ExtensionRequest ::= Extensions Extensions ::= SEQUENCE OF Extension- Parameters:
- encoder- the DER encoder
 
 - 
encodeExtensionprivate static void encodeExtension(DEREncoder encoder, X509CertificateExtension extension) Encode anExtensionusing the given DER encoder. The ASN.1 definition ofExtensionis:Extension ::= SEQUENCE { extensionId OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extensionValue OCTET STRING }- Parameters:
- encoder- the DER encoder
- extension- the X.509 certificate extension
 
 
- 
 
-