Package org.xipki.ca.api.profile
Class Certprofile
- java.lang.Object
-
- org.xipki.ca.api.profile.Certprofile
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
BaseCertprofile
public abstract class Certprofile extends java.lang.Object implements java.io.CloseableDefines how the certificate looks like. All Certprofile classes must extend this class.- Since:
- 2.0.0
- Author:
- Lijun Liao (xipki)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCertprofile.AuthorityInfoAccessControlstatic classCertprofile.CertDomainstatic classCertprofile.CertLevelstatic classCertprofile.CrlDistributionPointsControlstatic classCertprofile.ExtensionControlstatic classCertprofile.ExtKeyUsageControlstatic classCertprofile.GeneralNameModestatic classCertprofile.GeneralNameTagstatic classCertprofile.KeyUsageControlstatic classCertprofile.RdnControlstatic classCertprofile.StringTypestatic classCertprofile.SubjectControlstatic classCertprofile.SubjectInfostatic classCertprofile.X509CertVersion
-
Constructor Summary
Constructors Modifier Constructor Description protectedCertprofile()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract org.bouncycastle.asn1.x509.SubjectPublicKeyInfocheckPublicKey(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo publicKey)Checks the public key.voidclose()java.math.BigIntegergenerateSerialNumber(org.bouncycastle.asn1.x500.X500Name caSubject, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo caPublicKeyInfo, org.bouncycastle.asn1.x500.X500Name requestSubject, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo publicKeyInfo, org.xipki.util.ConfPairs caExtraControl)Generate Serial Number of the certificateabstract Certprofile.AuthorityInfoAccessControlgetAiaControl()abstract Certprofile.CertDomaingetCertDomain()abstract org.bouncycastle.asn1.x509.CertificatePoliciesgetCertificatePolicies()abstract Certprofile.CertLevelgetCertLevel()abstract Certprofile.CrlDistributionPointsControlgetCrlDpControl()java.util.Set<Certprofile.ExtKeyUsageControl>getExtendedKeyUsages()abstract java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,Certprofile.ExtensionControl>getExtensionControls()abstract ExtensionValuesgetExtensions(java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,Certprofile.ExtensionControl> extensionControls, org.bouncycastle.asn1.x500.X500Name requestedSubject, org.bouncycastle.asn1.x500.X500Name grantedSubject, java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,org.bouncycastle.asn1.x509.Extension> requestedExtensions, java.time.Instant notBefore, java.time.Instant notAfter, PublicCaInfo caInfo)Checks the requested extensions and returns the canonicalized ones.abstract Certprofile.CrlDistributionPointsControlgetFreshestCrlControl()abstract java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,KeyParametersOption>getKeyAlgorithms()KeypairGenControlgetKeypairGenControl()abstract java.util.Set<Certprofile.KeyUsageControl>getKeyUsage()intgetMaxCertSize()Returns maximal size in bytes of the certificate.NotAfterModegetNotAfterMode()abstract java.time.InstantgetNotBefore(java.time.Instant notBefore)Checks and gets the granted NotBefore.abstract java.lang.IntegergetPathLenBasicConstraint()java.lang.StringgetSerialNumberMode()How to generate the certificate's serial number.java.util.List<org.xipki.security.SignAlgo>getSignatureAlgorithms()abstract Certprofile.SubjectInfogetSubject(org.bouncycastle.asn1.x500.X500Name requestedSubject)Checks the requested subject.Certprofile.SubjectInfogetSubject(org.bouncycastle.asn1.x500.X500Name requestedSubject, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo publicKeyInfo)Checks the requested subject.abstract java.util.Set<Certprofile.GeneralNameMode>getSubjectAltNameModes()abstract Certprofile.SubjectControlgetSubjectControl()Get the SubjectControl.java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,java.util.Set<Certprofile.GeneralNameMode>>getSubjectInfoAccessModes()Returns the SubjectInfoAccess modes.org.bouncycastle.asn1.x509.SubjectKeyIdentifiergetSubjectKeyIdentifier(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo subjectPublicKeyInfo)protected SubjectKeyIdentifierControlgetSubjectKeyIdentifierControl()abstract org.xipki.util.ValiditygetValidity()Certprofile.X509CertVersiongetVersion()booleanhasNoWellDefinedExpirationDate()As in RFC5280:abstract voidinitialize(java.lang.String data)Initializes this object.booleanuseIssuerAndSerialInAki()Returns whether to use subject and serial number of the issuer certificate in the AuthorityKeyIdentifier extension.
-
-
-
Method Detail
-
getNotAfterMode
public NotAfterMode getNotAfterMode()
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
getVersion
public Certprofile.X509CertVersion getVersion()
-
getSignatureAlgorithms
public java.util.List<org.xipki.security.SignAlgo> getSignatureAlgorithms()
-
useIssuerAndSerialInAki
public boolean useIssuerAndSerialInAki()
Returns whether to use subject and serial number of the issuer certificate in the AuthorityKeyIdentifier extension.- Returns:
- whether include subject and serial number of the issuer certificate in the AuthorityKeyIdentifier extension.
-
getSubjectControl
public abstract Certprofile.SubjectControl getSubjectControl()
Get the SubjectControl.- Returns:
- the SubjectControl, may not be
null.
-
getAiaControl
public abstract Certprofile.AuthorityInfoAccessControl getAiaControl()
-
getCrlDpControl
public abstract Certprofile.CrlDistributionPointsControl getCrlDpControl()
-
getFreshestCrlControl
public abstract Certprofile.CrlDistributionPointsControl getFreshestCrlControl()
-
getCertificatePolicies
public abstract org.bouncycastle.asn1.x509.CertificatePolicies getCertificatePolicies()
-
getSubjectAltNameModes
public abstract java.util.Set<Certprofile.GeneralNameMode> getSubjectAltNameModes()
-
getExtendedKeyUsages
public java.util.Set<Certprofile.ExtKeyUsageControl> getExtendedKeyUsages()
-
getSubjectInfoAccessModes
public java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,java.util.Set<Certprofile.GeneralNameMode>> getSubjectInfoAccessModes()
Returns the SubjectInfoAccess modes. Use the dummy oid 0.0.0.0 to identify the NULL accessMethod.- Returns:
- the SubjectInfoAccess modes.
-
getExtensionControls
public abstract java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,Certprofile.ExtensionControl> getExtensionControls()
-
initialize
public abstract void initialize(java.lang.String data) throws CertprofileExceptionInitializes this object.- Parameters:
data- Configuration. Could benull.- Throws:
CertprofileException- if error during the initialization occurs.
-
getCertLevel
public abstract Certprofile.CertLevel getCertLevel()
-
getCertDomain
public abstract Certprofile.CertDomain getCertDomain()
-
getKeypairGenControl
public KeypairGenControl getKeypairGenControl()
-
getKeyAlgorithms
public abstract java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,KeyParametersOption> getKeyAlgorithms()
-
getKeyUsage
public abstract java.util.Set<Certprofile.KeyUsageControl> getKeyUsage()
-
getPathLenBasicConstraint
public abstract java.lang.Integer getPathLenBasicConstraint()
-
getNotBefore
public abstract java.time.Instant getNotBefore(java.time.Instant notBefore)
Checks and gets the granted NotBefore.- Parameters:
notBefore- Requested NotBefore. Could benull.- Returns:
- the granted NotBefore.
-
getValidity
public abstract org.xipki.util.Validity getValidity()
-
hasNoWellDefinedExpirationDate
public boolean hasNoWellDefinedExpirationDate()
As in RFC5280:To indicate that a certificate has no well-defined expiration date, the notAfter SHOULD be assigned the GeneralizedTime value of 99991231235959Z.
- Returns:
- true to use the fixed value 99991231235959Z in notAfter, false
as in defined in
getValidity().
-
checkPublicKey
public abstract org.bouncycastle.asn1.x509.SubjectPublicKeyInfo checkPublicKey(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo publicKey) throws CertprofileException, org.xipki.util.exception.BadCertTemplateExceptionChecks the public key. If the check passes, returns the canonicalized public key.- Parameters:
publicKey- Requested public key. Must not benull.- Returns:
- the granted public key.
- Throws:
org.xipki.util.exception.BadCertTemplateException- if the publicKey does not have correct format or is not permitted.CertprofileException- if error occurs.
-
getSubject
public abstract Certprofile.SubjectInfo getSubject(org.bouncycastle.asn1.x500.X500Name requestedSubject) throws CertprofileException, org.xipki.util.exception.BadCertTemplateException
Checks the requested subject. If the check passes, returns the canonicalized subject.- Parameters:
requestedSubject- Requested subject. Must not benull.- Returns:
- the granted subject
- Throws:
org.xipki.util.exception.BadCertTemplateException- if the subject is not permitted.CertprofileException- if error occurs.
-
getSubject
public Certprofile.SubjectInfo getSubject(org.bouncycastle.asn1.x500.X500Name requestedSubject, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo publicKeyInfo) throws CertprofileException, org.xipki.util.exception.BadCertTemplateException
Checks the requested subject. If the check passes, returns the canonicalized subject.- Parameters:
requestedSubject- Requested subject. Must not benull.publicKeyInfo- SubjectPublicKeyInfo of the certificate.- Returns:
- the granted subject
- Throws:
org.xipki.util.exception.BadCertTemplateException- if the subject is not permitted.CertprofileException- if error occurs.
-
getExtensions
public abstract ExtensionValues getExtensions(java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,Certprofile.ExtensionControl> extensionControls, org.bouncycastle.asn1.x500.X500Name requestedSubject, org.bouncycastle.asn1.x500.X500Name grantedSubject, java.util.Map<org.bouncycastle.asn1.ASN1ObjectIdentifier,org.bouncycastle.asn1.x509.Extension> requestedExtensions, java.time.Instant notBefore, java.time.Instant notAfter, PublicCaInfo caInfo) throws CertprofileException, org.xipki.util.exception.BadCertTemplateException
Checks the requested extensions and returns the canonicalized ones.- Parameters:
extensionControls- Extension controls.requestedSubject- Requested subject. Must not benull.grantedSubject- Granted subject. Must not benull.requestedExtensions- Requested extensions. Could benull.notBefore- NotBefore. Must not benull.notAfter- NotAfter. Must not benull.caInfo- CA information.- Returns:
- extensions of the certificate to be issued.
- Throws:
org.xipki.util.exception.BadCertTemplateException- if at least one of extension is not permitted.CertprofileException- if error occurs.
-
getMaxCertSize
public int getMaxCertSize()
Returns maximal size in bytes of the certificate.- Returns:
- maximal size in bytes of the certificate, 0 or negative value indicates accepting all sizes.
-
getSubjectKeyIdentifier
public org.bouncycastle.asn1.x509.SubjectKeyIdentifier getSubjectKeyIdentifier(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo subjectPublicKeyInfo) throws CertprofileException- Throws:
CertprofileException
-
getSubjectKeyIdentifierControl
protected SubjectKeyIdentifierControl getSubjectKeyIdentifierControl()
-
getSerialNumberMode
public java.lang.String getSerialNumberMode()
How to generate the certificate's serial number.- Returns:
- the mode to generate serial number.
null, empty or 'CA': CA generates serial number
'PROFILE': The function
generateSerialNumber(X500Name, SubjectPublicKeyInfo, X500Name, SubjectPublicKeyInfo, ConfPairs)will be called to generate the serial number. The ConfPairs is case-sensitive.
-
generateSerialNumber
public java.math.BigInteger generateSerialNumber(org.bouncycastle.asn1.x500.X500Name caSubject, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo caPublicKeyInfo, org.bouncycastle.asn1.x500.X500Name requestSubject, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo publicKeyInfo, org.xipki.util.ConfPairs caExtraControl) throws CertprofileExceptionGenerate Serial Number of the certificate- Parameters:
caSubject- CA's subjectcaPublicKeyInfo- CA's public key info.requestSubject- requested subject.publicKeyInfo- requested public key info.caExtraControl- Key-value pairs of CA's extraControl.- Returns:
- the serial number of certificate.
- Throws:
CertprofileException- if Certprofile Exception occurred.
-
-