|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object core.crypto.Certificates
public class Certificates
This class is usefull for generating Cerfiticates. For Information about ASN.1 see @link http://asn1.elibel.tm.fr/
Copyright (c) 2006 Sebastian Erdweg Copyright (c) 2006 Dominik Schulz Copyright (c) 2006 Florian Lindner Copyright (c) 2006 Betim Berjani This file is part of FlexiCrypt. FlexiCrypt is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. FlexiCrypt is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FlexiCrypt; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Field Summary | |
---|---|
static int |
EXTENDED_USAGE_ALL
|
static int |
EXTENDED_USAGE_CLIENT_AUTH
|
static int |
EXTENDED_USAGE_CODE_SIGNING
|
static int |
EXTENDED_USAGE_EMAIL_PROTECTION
|
static int |
EXTENDED_USAGE_IPSEC_END_SYSTEM
|
static int |
EXTENDED_USAGE_IPSEC_TUNNEL
|
static int |
EXTENDED_USAGE_IPSEC_USER
|
static int |
EXTENDED_USAGE_OCSP_SIGNING
|
static int |
EXTENDED_USAGE_SERVER_AUTH
extended usage values. add them up to indicate multiple usages. |
static int |
EXTENDED_USAGE_TIME_STAMPING
|
static int |
USAGE_ALL
|
static int |
USAGE_CRL_SIGN
|
static int |
USAGE_DATA_ENCIPHERMENT
|
static int |
USAGE_DIGITAL_SIGNATURE
usage values. add them up to indicate multiple usages. |
static int |
USAGE_KEY_AGREEMENT
|
static int |
USAGE_KEY_CERT_SIGN
|
static int |
USAGE_KEY_ENCIPHERMENT
|
static int |
USAGE_NON_REPUDIATION
|
Constructor Summary | |
---|---|
Certificates()
|
Method Summary | |
---|---|
static X509Certificate |
createCertificate(PublicKey publicKey,
String signatureAlgorithm,
PrivateKey privateKey,
Principal subject,
String email,
Principal issuer,
int usage,
boolean isUsageCritical,
int extendedUsage,
boolean isExtendedUsageCritical,
Calendar notBefore,
Calendar notAfter,
BigInteger serialNumber,
boolean isCA,
boolean isCACritical)
Creates a self signed certificate |
static X509Certificate |
createCertificateFromScratch(String certAlgorithm,
int keyBitLength,
String signatureAlgorithm,
Principal subject,
String email,
Principal issuer,
int usage,
boolean isUsageCritical,
int extendedUsage,
boolean isExtendedUsageCritical,
Calendar notBefore,
Calendar notAfter,
BigInteger serialnumber,
boolean isCA,
boolean isCACritical,
Provider prov)
Creates a new Certificate from Scratch |
static X509Crl |
createCRL(X509Certificate issuersCert,
PrivateKey issuersPrivateKey,
X509Certificate[] toRevoke)
creates and signs an CRL where all certs in 'toRevoke' are added as revokeEntries. |
static X509Certificate |
findIssuersCert(Principal DN,
boolean[] ID)
|
static X509Crl |
getCRLfromFile(File file)
Read a CRL from a file |
static byte[] |
getCSR(PublicKey publicKey,
PrivateKey privateKey,
Name name,
String signatureAlgorithm)
Generate a PKCS#10 CSR (Certificate signing request) |
static CertificationRequest |
getCSRfromFile(File file)
Reads a PKCS#10 CSR from a File |
static String |
getEmail(X509Certificate cert)
|
static boolean |
isCACert(X509Certificate cert)
checks the content of the BasicConstraintsExtension . |
static void |
setAuthorityKeyIdentifier(X509Certificate cert,
byte[] authorityKeyIdent)
|
static String |
verifyCertificate(X509Certificate cert,
Certificate[] chain,
X509CRL certCRL)
Verifys a X509 Certificate |
static void |
writeCRLtoFile(X509Crl crl,
File file)
Write a CRL to a file |
static void |
writeCSRtoFile(BigInteger serial,
PublicKey publickey,
PrivateKey privatekey,
Name name,
File file,
String signatureAlgorithm)
Writes a PKCS#10 CSR to a file |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int USAGE_DIGITAL_SIGNATURE
public static final int USAGE_NON_REPUDIATION
public static final int USAGE_KEY_ENCIPHERMENT
public static final int USAGE_DATA_ENCIPHERMENT
public static final int USAGE_KEY_AGREEMENT
public static final int USAGE_KEY_CERT_SIGN
public static final int USAGE_CRL_SIGN
public static final int USAGE_ALL
public static final int EXTENDED_USAGE_SERVER_AUTH
public static final int EXTENDED_USAGE_CLIENT_AUTH
public static final int EXTENDED_USAGE_CODE_SIGNING
public static final int EXTENDED_USAGE_EMAIL_PROTECTION
public static final int EXTENDED_USAGE_IPSEC_END_SYSTEM
public static final int EXTENDED_USAGE_IPSEC_TUNNEL
public static final int EXTENDED_USAGE_IPSEC_USER
public static final int EXTENDED_USAGE_TIME_STAMPING
public static final int EXTENDED_USAGE_OCSP_SIGNING
public static final int EXTENDED_USAGE_ALL
Constructor Detail |
---|
public Certificates()
Method Detail |
---|
public static X509Certificate createCertificate(PublicKey publicKey, String signatureAlgorithm, PrivateKey privateKey, Principal subject, String email, Principal issuer, int usage, boolean isUsageCritical, int extendedUsage, boolean isExtendedUsageCritical, Calendar notBefore, Calendar notAfter, BigInteger serialNumber, boolean isCA, boolean isCACritical) throws Exception
publicKey
- signatureAlgorithm
- privateKey
- subject
- issuer
- usage
- extendedUsage
- notBefore
- notAfter
- serialNumber
- isCA
-
Exception
public static X509Certificate createCertificateFromScratch(String certAlgorithm, int keyBitLength, String signatureAlgorithm, Principal subject, String email, Principal issuer, int usage, boolean isUsageCritical, int extendedUsage, boolean isExtendedUsageCritical, Calendar notBefore, Calendar notAfter, BigInteger serialnumber, boolean isCA, boolean isCACritical, Provider prov) throws Exception
certAlgorithm
- keyBitLength
- signatureAlgorithm
- subject
- issuer
- usage
- isUsageCritical
- extendedUsage
- isExtendedUsageCritical
- notBefore
- notAfter
- serialnumber
- isCA
- prov
-
Exception
public static void setAuthorityKeyIdentifier(X509Certificate cert, byte[] authorityKeyIdent) throws NumberFormatException, Exception
NumberFormatException
Exception
public static byte[] getCSR(PublicKey publicKey, PrivateKey privateKey, Name name, String signatureAlgorithm) throws BadNameException, NoSuchAlgorithmException, InvalidKeyException, ASN1Exception, SignatureException, CorruptedCodeException
publicKey
- privateKey
- name
- signatureAlgorithm
-
BadNameException
NoSuchAlgorithmException
InvalidKeyException
ASN1Exception
SignatureException
CorruptedCodeException
public static void writeCSRtoFile(BigInteger serial, PublicKey publickey, PrivateKey privatekey, Name name, File file, String signatureAlgorithm) throws InvalidKeyException, ASN1Exception, CorruptedCodeException, NoSuchAlgorithmException, SignatureException, IOException
publickey
- privatekey
- name
- file
- signatureAlgorithm
-
InvalidKeyException
ASN1Exception
CorruptedCodeException
NoSuchAlgorithmException
SignatureException
IOException
public static CertificationRequest getCSRfromFile(File file) throws ASN1Exception, IOException
file
-
ASN1Exception
IOException
public static X509Crl getCRLfromFile(File file) throws ASN1Exception, IOException
file
-
ASN1Exception
IOException
public static void writeCRLtoFile(X509Crl crl, File file) throws CRLException, IOException
crl
- file
-
CRLException
IOException
public static X509Crl createCRL(X509Certificate issuersCert, PrivateKey issuersPrivateKey, X509Certificate[] toRevoke) throws BadNameException, NoSuchAlgorithmException, CRLException, InvalidKeyException, SignatureException
issuersCert
- The certificate of the issuer of this CRLissuersPrivateKey
- The private key of the issuer with which this CRL will be signedtoRevoke
- An array of the certificates which should be revoked
BadNameException
NoSuchAlgorithmException
CRLException
InvalidKeyException
SignatureException
public static String verifyCertificate(X509Certificate cert, Certificate[] chain, X509CRL certCRL) throws CertificateException
cert
- The Certificate to verifychain
- The signing chaincertCRL
- A CRL
CertificateException
public static boolean isCACert(X509Certificate cert)
BasicConstraintsExtension
.
if the extension is not present, the method returns false.
cert
-
public static String getEmail(X509Certificate cert)
cert
-
X509Exception
public static X509Certificate findIssuersCert(Principal DN, boolean[] ID) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |