Java Doc for CertTools.java in  » Authentication-Authorization » ejbca » org » ejbca » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Authentication Authorization » ejbca » org.ejbca.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.ejbca.util.CertTools

All known Subclasses:   org.ejbca.util.cert.SubjectDirAttrExtension,  org.ejbca.util.cert.QCStatementExtension,
CertTools
public class CertTools (Code)
Tools to handle common certificate operations.
version:
   $Id: CertTools.java,v 1.54 2008/03/14 16:55:36 anatom Exp $


Field Summary
final public static  StringDIRECTORYNAME
    
final public static  StringDNS
    
final public static  StringEFSR_OBJECTID
    
final public static  StringEFS_OBJECTID
    
final public static  StringEMAIL
    
final public static  StringEMAIL1
    
final public static  StringEMAIL2
    
final public static  StringEMAIL3
    
final public static  StringGUID
    
final public static  StringGUID_OBJECTID
    
final public static  StringIPADDR
    
final public static  StringOID_MSTEMPLATE
    
public static  StringSYSTEM_SECURITY_PROVIDER
     System provider used to circumvent a bug in Glassfish.
final public static  StringUPN
    
final public static  StringUPN_OBJECTID
    
final public static  StringURI
    
final public static  StringURI1
    
final public static  StringURI2
    
final public static  Stringid_kp
    
final public static  Stringid_kp_ipsecIKE
    
final public static  Stringid_kp_scvpClient
    
final public static  Stringid_kp_scvpServer
    
final public static  Stringid_pda
    
final public static  Stringid_pda_countryOfCitizenship
    
final public static  Stringid_pda_countryOfResidence
    
final public static  Stringid_pda_dateOfBirth
    
final public static  Stringid_pda_gender
    
final public static  Stringid_pda_placeOfBirth
    
final public static  Stringid_pkix
    

Constructor Summary
protected  CertTools()
    

Method Summary
public static  intbitStringToRevokedCertInfo(DERBitString reasonFlags)
     Converts DERBitString ResonFlags to a RevokedCertInfo constant
Parameters:
  reasonFlags - DERBITString received from org.bouncycastle.asn1.x509.ReasonFlags.
public static  X509CertificategenSelfCert(String dn, long validity, String policyId, PrivateKey privKey, PublicKey pubKey, String sigAlg, boolean isCA)
     Generate a selfsigned certiicate.
public static  X509CertificategenSelfCertForPurpose(String dn, long validity, String policyId, PrivateKey privKey, PublicKey pubKey, String sigAlg, boolean isCA, int keyusage)
     Generate a selfsigned certiicate with possibility to specify key usage.
public static  byte[]generateMD5Fingerprint(byte[] ba)
     Generate a MD5 fingerprint from a byte array containing a X.509 certificate
Parameters:
  ba - Byte array containing DER encoded X509Certificate.
public static  byte[]generateSHA1Fingerprint(byte[] ba)
     Generate a SHA1 fingerprint from a byte array containing a X.509 certificate
Parameters:
  ba - Byte array containing DER encoded X509Certificate.
public static  StringgetAltNameStringFromExtension(X509Extension ext)
    
public static  StringgetAuthorityInformationAccessOcspUrl(X509Certificate cert)
     Returns OCSP URL that is inside AuthorithInformationAccess extension, or null.
public static  byte[]getAuthorityKeyId(X509Certificate cert)
    
public static  X509CRLgetCRLfromByteArray(byte[] crl)
     Creates X509CRL from byte[].
public static  ArrayListgetCertCollectionFromArray(Certificate[] certs, String provider)
     Converts a regular array of certificates into an ArrayList, using the provided provided.
public static  StringgetCertFingerprintAsString(byte[] ba)
     Generate SHA1 fingerprint in string representation.
Parameters:
  ba - Byte array containing DER encoded X509Certificate.
public static  X509CertificategetCertfromByteArray(byte[] cert)
     Creates X509Certificate from byte[].
public static  CertificateFactorygetCertificateFactory()
    
public static  StringgetCertificatePolicyId(X509Certificate cert, int pos)
    
public static  CollectiongetCertsFromPEM(String certFile)
     Reads a certificate in PEM-format from a file.
public static  CollectiongetCertsFromPEM(InputStream certstream)
     Reads a certificate in PEM-format from an InputStream.
public static  URLgetCrlDistributionPoint(X509Certificate certificate)
     Return the CRL distribution point URL form a certificate.
public static  ArrayListgetCustomOids(String dn)
     Gets a list of all custom OIDs defined in the string.
public static  StringgetEMailAddress(X509Certificate certificate)
     Search for e-mail address, first in SubjectAltName (as in PKIX recomandation) then in subject DN.
public static  ArrayListgetEmailFromDN(String dn)
     Convenience method for getting an email addresses from a DN.
protected static  DERObjectgetExtensionValue(X509Certificate cert, String oid)
    
public static  StringgetFingerprintAsString(X509Certificate cert)
     Generate SHA1 fingerprint of certificate in string representation.
Parameters:
  cert - X509Certificate.
public static  StringgetFingerprintAsString(X509CRL crl)
     Generate SHA1 fingerprint of CRL in string representation.
Parameters:
  crl - X509CRL.
public static  StringgetFingerprintAsString(byte[] in)
     Generate SHA1 fingerprint of byte array in string representation. byte array to fingerprint.
public static  StringgetGeneralNameString(int tag, DEREncodable value)
    
public static  GeneralNamesgetGeneralNamesFromAltName(String altName)
    
public static  StringgetGuidAltName(X509Certificate cert)
     Gets the Microsoft specific GUID altName, that is encoded as an octect string.
public static  StringgetIssuerDN(X509Certificate cert)
     Gets issuer DN in the format we are sure about (BouncyCastle),supporting UTF8.
public static  StringgetIssuerDN(X509CRL crl)
     Gets issuer DN for CRL in the format we are sure about (BouncyCastle),supporting UTF8.
public static  byte[]getPEMFromCerts(Collection certs)
     Returns a certificate in PEM-format.
public static  byte[]getPEMFromCrl(byte[] crlbytes)
     Returns a CRL in PEM-format.
public static  StringgetPartFromDN(String dn, String dnpart)
     Gets a specified part of a DN.
public static  ArrayListgetPartsFromDN(String dn, String dnpart)
     Gets a specified parts of a DN.
public static  StringgetSignatureAlgorithm(X509Certificate cert)
    
public static  StringgetSubjectAlternativeName(X509Certificate certificate)
     SubjectAltName ::= GeneralNames GeneralNames :: = SEQUENCE SIZE (1..MAX) OF GeneralName GeneralName ::= CHOICE { otherName [0] OtherName, rfc822Name [1] IA5String, dNSName [2] IA5String, x400Address [3] ORAddress, directoryName [4] Name, ediPartyName [5] EDIPartyName, uniformResourceIdentifier [6] IA5String, iPAddress [7] OCTET STRING, registeredID [8] OBJECT IDENTIFIER} SubjectAltName is of form \"rfc822Name=, dNSName=, uniformResourceIdentifier=, iPAddress=
, guid=, directoryName= Supported altNames are upn, rfc822Name, uniformResourceIdentifier, dNSName, iPAddress, directoryName
author:
   Marco Ferrante, (c) 2005 CSITA - University of Genoa (Italy)
author:
   Tomas Gustavsson
Parameters:
  certificate - containing alt names String containing altNames of form "rfc822Name=email, dNSName=hostname, uniformResourceIdentifier=uri, iPAddress=ip, upn=upn, directoryName=CN=testDirName|dir|name" or null if no altNames exist.
public static  StringgetSubjectDN(X509Certificate cert)
     Gets subject DN in the format we are sure about (BouncyCastle),supporting UTF8.
public static  byte[]getSubjectKeyId(X509Certificate cert)
    
public static  StringgetUPNAltName(X509Certificate cert)
     Gets the Microsoft specific UPN altName.
public static  VectorgetX509FieldOrder(boolean ldaporder)
     Obtains a Vector with the DERObjectIdentifiers for dNObjects names, in the specified order
Parameters:
  ldaporder - if true the returned order are as defined in LDAP RFC (CN=foo,O=bar,C=SE), otherwise the order is a defined in X.500 (C=SE,O=bar,CN=foo).
public static  StringinsertCNPostfix(String dn, String cnpostfix)
     Method used to insert a CN postfix into DN by extracting the first found CN appending cnpostfix and then replacing the original CN with the new one in DN.
public static synchronized  voidinstallBCProvider()
    
protected static  booleanisDNReversed(String dn)
     Tries to determine if a DN is in reversed form.
public static  booleanisSelfSigned(X509Certificate cert)
     Checks if a certificate is self signed by verifying if subject and issuer are the same.
Parameters:
  cert - the certificate that skall be checked.
public static synchronized  voidremoveBCProvider()
    
public static  StringreverseDN(String dn)
     Takes a DN and reverses it completely so the first attribute ends up last.
public static  StringstringToBCDNString(String dn)
     Every DN-string should look the same.
public static  X509NamestringToBcX509Name(String dn)
     See stringToBcX509Name(String, X509NameEntryConverter), this method uses the default BC converter (X509DefaultEntryConverter)
See Also:   CertTools.stringToBcX509Name(String,X509NameEntryConverter)
Parameters:
  dn - String containing DN that will be transformed into X509Name, TheDN string has the format "CN=zz,OU=yy,O=foo,C=SE".
public static  X509NamestringToBcX509Name(String dn, X509NameEntryConverter converter, Vector dnOrder)
    
public static  intsunKeyUsageToBC(boolean[] sku)
     Converts Sun Key usage bits to Bouncy castle key usage kits
Parameters:
  sku - key usage bit fields according to java.security.cert.X509Certificate#getKeyUsage, must be a boolean aray of size 9.
public static  booleanverify(X509Certificate certificate, Collection caCertPath)
     Check the certificate with CA certificate.

Field Detail
DIRECTORYNAME
final public static String DIRECTORYNAME(Code)



DNS
final public static String DNS(Code)



EFSR_OBJECTID
final public static String EFSR_OBJECTID(Code)
ObjectID for Mircosoft Encrypted File System Recovery Certificates



EFS_OBJECTID
final public static String EFS_OBJECTID(Code)
ObjectID for Mircosoft Encrypted File System Certificates



EMAIL
final public static String EMAIL(Code)



EMAIL1
final public static String EMAIL1(Code)



EMAIL2
final public static String EMAIL2(Code)



EMAIL3
final public static String EMAIL3(Code)



GUID
final public static String GUID(Code)
Microsoft altName for windows domain controller guid



GUID_OBJECTID
final public static String GUID_OBJECTID(Code)
ObjectID for upn altName for windows domain controller guid



IPADDR
final public static String IPADDR(Code)



OID_MSTEMPLATE
final public static String OID_MSTEMPLATE(Code)
OID used for creating MS Templates certificate extension



SYSTEM_SECURITY_PROVIDER
public static String SYSTEM_SECURITY_PROVIDER(Code)
System provider used to circumvent a bug in Glassfish. Should only be used by X509CAInfo, OCSPCAService, XKMSCAService, CMSCAService. Defaults to SUN but can be changed to IBM by the installBCProvider method.



UPN
final public static String UPN(Code)
Microsoft altName for windows smart card logon



UPN_OBJECTID
final public static String UPN_OBJECTID(Code)
ObjectID for upn altName for windows smart card logon



URI
final public static String URI(Code)



URI1
final public static String URI1(Code)



URI2
final public static String URI2(Code)



id_kp
final public static String id_kp(Code)
Object id id-kp



id_kp_ipsecIKE
final public static String id_kp_ipsecIKE(Code)
New OID for ipsec (rfc4945), replaces old deprecated id_kp_ipsecEndSystem, id_kp_ipsecTunnel and id_kp_ipsecUser



id_kp_scvpClient
final public static String id_kp_scvpClient(Code)



id_kp_scvpServer
final public static String id_kp_scvpServer(Code)
OIDs for SCVP (rfc5055)



id_pda
final public static String id_pda(Code)
Object id id-pda



id_pda_countryOfCitizenship
final public static String id_pda_countryOfCitizenship(Code)
Object id id-pda-countryOfCitizenship CountryOfCitizenship ::= PrintableString (SIZE (2)) -- ISO 3166 Country Code



id_pda_countryOfResidence
final public static String id_pda_countryOfResidence(Code)
Object id id-pda-countryOfResidence CountryOfResidence ::= PrintableString (SIZE (2)) -- ISO 3166 Country Code



id_pda_dateOfBirth
final public static String id_pda_dateOfBirth(Code)
Object id id-pda-dateOfBirth DateOfBirth ::= GeneralizedTime



id_pda_gender
final public static String id_pda_gender(Code)
Object id id-pda-gender Gender ::= PrintableString (SIZE(1)) -- "M", "F", "m" or "f"



id_pda_placeOfBirth
final public static String id_pda_placeOfBirth(Code)
Object id id-pda-placeOfBirth PlaceOfBirth ::= DirectoryString



id_pkix
final public static String id_pkix(Code)
Object id id-pkix




Constructor Detail
CertTools
protected CertTools()(Code)
inhibits creation of new CertTools




Method Detail
bitStringToRevokedCertInfo
public static int bitStringToRevokedCertInfo(DERBitString reasonFlags)(Code)
Converts DERBitString ResonFlags to a RevokedCertInfo constant
Parameters:
  reasonFlags - DERBITString received from org.bouncycastle.asn1.x509.ReasonFlags. int according to org.ejbca.core.model.ca.crl.RevokedCertInfo



genSelfCert
public static X509Certificate genSelfCert(String dn, long validity, String policyId, PrivateKey privKey, PublicKey pubKey, String sigAlg, boolean isCA) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, CertificateEncodingException, IllegalStateException(Code)
Generate a selfsigned certiicate.
Parameters:
  dn - subject and issuer DN
Parameters:
  validity - in days
Parameters:
  policyId - policy string ('2.5.29.32.0') or null
Parameters:
  privKey - private key
Parameters:
  pubKey - public key
Parameters:
  sigAlg - signature algorithm, you can use one of the contants CATokenInfo.SIGALG_XXX
Parameters:
  isCA - boolean true or false X509Certificate, self signed
throws:
  NoSuchAlgorithmException - DOCUMENT ME!
throws:
  SignatureException - DOCUMENT ME!
throws:
  InvalidKeyException - DOCUMENT ME!
throws:
  IllegalStateException -
throws:
  CertificateEncodingException -



genSelfCertForPurpose
public static X509Certificate genSelfCertForPurpose(String dn, long validity, String policyId, PrivateKey privKey, PublicKey pubKey, String sigAlg, boolean isCA, int keyusage) throws NoSuchAlgorithmException, SignatureException, InvalidKeyException, CertificateEncodingException, IllegalStateException(Code)
Generate a selfsigned certiicate with possibility to specify key usage.
Parameters:
  dn - subject and issuer DN
Parameters:
  validity - in days
Parameters:
  policyId - policy string ('2.5.29.32.0') or null
Parameters:
  privKey - private key
Parameters:
  pubKey - public key
Parameters:
  sigAlg - signature algorithm, you can use one of the contants CATokenInfo.SIGALG_XXX
Parameters:
  isCA - boolean true or false
Parameters:
  keyusage - as defined by constants in X509KeyUsage X509Certificate, self signed
throws:
  NoSuchAlgorithmException - DOCUMENT ME!
throws:
  SignatureException - DOCUMENT ME!
throws:
  InvalidKeyException - DOCUMENT ME!
throws:
  IllegalStateException -
throws:
  CertificateEncodingException -



generateMD5Fingerprint
public static byte[] generateMD5Fingerprint(byte[] ba)(Code)
Generate a MD5 fingerprint from a byte array containing a X.509 certificate
Parameters:
  ba - Byte array containing DER encoded X509Certificate. Byte array containing MD5 hash of DER encoded certificate.



generateSHA1Fingerprint
public static byte[] generateSHA1Fingerprint(byte[] ba)(Code)
Generate a SHA1 fingerprint from a byte array containing a X.509 certificate
Parameters:
  ba - Byte array containing DER encoded X509Certificate. Byte array containing SHA1 hash of DER encoded certificate.



getAltNameStringFromExtension
public static String getAltNameStringFromExtension(X509Extension ext)(Code)
Gets an altName string from an X509Extension
Parameters:
  ext - X509Extension with AlternativeNames String as defined in method getSubjectAlternativeName



getAuthorityInformationAccessOcspUrl
public static String getAuthorityInformationAccessOcspUrl(X509Certificate cert) throws CertificateParsingException(Code)
Returns OCSP URL that is inside AuthorithInformationAccess extension, or null.
Parameters:
  cert -
throws:
  CertificateParsingException -



getAuthorityKeyId
public static byte[] getAuthorityKeyId(X509Certificate cert) throws IOException(Code)
Get the authority key identifier from a certificate extensions
Parameters:
  cert - certificate containing the extension byte[] containing the authority key identifier, or null if it does not exist
throws:
  IOException - if extension can not be parsed



getCRLfromByteArray
public static X509CRL getCRLfromByteArray(byte[] crl) throws IOException, CRLException(Code)
Creates X509CRL from byte[].
Parameters:
  crl - byte array containing CRL in DER-format X509CRL
throws:
  IOException - if the byte array can not be read.
throws:
  CertificateException - if the byte arrayen does not contani a correct CRL.
throws:
  CRLException - if the byte arrayen does not contani a correct CRL.



getCertCollectionFromArray
public static ArrayList getCertCollectionFromArray(Certificate[] certs, String provider) throws CertificateException, NoSuchProviderException(Code)
Converts a regular array of certificates into an ArrayList, using the provided provided.
Parameters:
  certs - Certificate[] of certificates to convert
Parameters:
  provider - provider for example "SUN" or "BC", use null for the default provider (BC) An ArrayList of certificates in the same order as the passed in array
throws:
  NoSuchProviderException -
throws:
  CertificateException -



getCertFingerprintAsString
public static String getCertFingerprintAsString(byte[] ba)(Code)
Generate SHA1 fingerprint in string representation.
Parameters:
  ba - Byte array containing DER encoded X509Certificate. String containing hex format of SHA1 fingerprint.



getCertfromByteArray
public static X509Certificate getCertfromByteArray(byte[] cert) throws CertificateException(Code)
Creates X509Certificate from byte[].
Parameters:
  cert - byte array containing certificate in DER-format X509Certificate
throws:
  CertificateException - if the byte array does not contain a proper certificate.
throws:
  IOException - if the byte array cannot be read.



getCertificateFactory
public static CertificateFactory getCertificateFactory()(Code)



getCertificatePolicyId
public static String getCertificatePolicyId(X509Certificate cert, int pos) throws IOException(Code)
Get a certificate policy ID from a certificate policies extension
Parameters:
  cert - certificate containing the extension
Parameters:
  pos - position of the policy id, if several exist, the first is as pos 0 String with the certificate policy OID
throws:
  IOException - if extension can not be parsed



getCertsFromPEM
public static Collection getCertsFromPEM(String certFile) throws IOException, CertificateException(Code)
Reads a certificate in PEM-format from a file. The file may contain other things, the first certificate in the file is read.
Parameters:
  certFile - the file containing the certificate in PEM-format Ordered Collection of X509Certificate, first certificate first, or empty Collection
exception:
  IOException - if the filen cannot be read.
exception:
  CertificateException - if the filen does not contain a correct certificate.



getCertsFromPEM
public static Collection getCertsFromPEM(InputStream certstream) throws IOException, CertificateException(Code)
Reads a certificate in PEM-format from an InputStream. The stream may contain other things, the first certificate in the stream is read.
Parameters:
  certFile - the input stream containing the certificate in PEM-format Ordered Collection of X509Certificate, first certificate first, or empty Collection
exception:
  IOException - if the stream cannot be read.
exception:
  CertificateException - if the stream does not contain a correct certificate.



getCrlDistributionPoint
public static URL getCrlDistributionPoint(X509Certificate certificate) throws CertificateParsingException(Code)
Return the CRL distribution point URL form a certificate.



getCustomOids
public static ArrayList getCustomOids(String dn)(Code)
Gets a list of all custom OIDs defined in the string. A custom OID is defined as an OID, simply as that. Otherwise, if it is not a custom oid, the DNpart is defined by a name such as CN och rfc822Name.
Parameters:
  dn - String containing DN, The DN string has the format "C=SE, O=xx, OU=yy, CN=zz", or "rfc822Name=foo@bar.com", etc.
Parameters:
  dnpart - String specifying which part of the DN to get, should be "CN" or "OU" etc. ArrayList containing oids or empty list if no custom OIDs are present



getEMailAddress
public static String getEMailAddress(X509Certificate certificate)(Code)
Search for e-mail address, first in SubjectAltName (as in PKIX recomandation) then in subject DN. Original author: Marco Ferrante, (c) 2005 CSITA - University of Genoa (Italy)
Parameters:
  certificate - subject email or null if not present in certificate



getEmailFromDN
public static ArrayList getEmailFromDN(String dn)(Code)
Convenience method for getting an email addresses from a DN. Uses * getPartsFromDN(String,String) internally, and searches for EMAIL , EMAIL1 , EMAIL2 , EMAIL3 and returns the first one found.
Parameters:
  dn - the DN ArrayList containing email or empty list if email is not present the found email address, or null if none is found



getExtensionValue
protected static DERObject getExtensionValue(X509Certificate cert, String oid) throws IOException(Code)
Return an Extension DERObject from a certificate



getFingerprintAsString
public static String getFingerprintAsString(X509Certificate cert)(Code)
Generate SHA1 fingerprint of certificate in string representation.
Parameters:
  cert - X509Certificate. String containing hex format of SHA1 fingerprint, or null if input is null.



getFingerprintAsString
public static String getFingerprintAsString(X509CRL crl)(Code)
Generate SHA1 fingerprint of CRL in string representation.
Parameters:
  crl - X509CRL. String containing hex format of SHA1 fingerprint.



getFingerprintAsString
public static String getFingerprintAsString(byte[] in)(Code)
Generate SHA1 fingerprint of byte array in string representation. byte array to fingerprint. String containing hex format of SHA1 fingerprint.



getGeneralNameString
public static String getGeneralNameString(int tag, DEREncodable value) throws IOException(Code)
GeneralName ::= CHOICE { otherName [0] OtherName, rfc822Name [1] IA5String, dNSName [2] IA5String, x400Address [3] ORAddress, directoryName [4] Name, ediPartyName [5] EDIPartyName, uniformResourceIdentifier [6] IA5String, iPAddress [7] OCTET STRING, registeredID [8] OBJECT IDENTIFIER}
Parameters:
  tag - the no tag 0-8
Parameters:
  value - the DEREncodable value as returned by GeneralName.getName() String in form rfc822Name= or uri= etc
throws:
  IOException -
See Also:   CertTools.getSubjectAlternativeName



getGeneralNamesFromAltName
public static GeneralNames getGeneralNamesFromAltName(String altName)(Code)
From an altName string as defined in getSubjectAlternativeName
Parameters:
  altName - ASN.1 GeneralNames
See Also:   CertTools.getSubjectAlternativeName



getGuidAltName
public static String getGuidAltName(X509Certificate cert) throws IOException, CertificateParsingException(Code)
Gets the Microsoft specific GUID altName, that is encoded as an octect string.
Parameters:
  cert - certificate containing the extension String with the hex-encoded GUID byte array or null if the altName does not exist



getIssuerDN
public static String getIssuerDN(X509Certificate cert)(Code)
Gets issuer DN in the format we are sure about (BouncyCastle),supporting UTF8.
Parameters:
  cert - X509Certificate String containing the issuers DN.



getIssuerDN
public static String getIssuerDN(X509CRL crl)(Code)
Gets issuer DN for CRL in the format we are sure about (BouncyCastle),supporting UTF8.
Parameters:
  crl - X509RL String containing the DN.



getPEMFromCerts
public static byte[] getPEMFromCerts(Collection certs) throws CertificateException(Code)
Returns a certificate in PEM-format.
Parameters:
  certs - Collection of X509Certificate to convert to PEM byte array containing PEM certificate
exception:
  CertificateException - if the stream does not contain a correct certificate.



getPEMFromCrl
public static byte[] getPEMFromCrl(byte[] crlbytes)(Code)
Returns a CRL in PEM-format.
Parameters:
  crlbytes - the der encoded crl bytes to convert to PEM byte array containing PEM CRL
exception:
  IOException - if the stream cannot be read.



getPartFromDN
public static String getPartFromDN(String dn, String dnpart)(Code)
Gets a specified part of a DN. Specifically the first occurrence it the DN contains several instances of a part (i.e. cn=x, cn=y returns x).
Parameters:
  dn - String containing DN, The DN string has the format "C=SE, O=xx, OU=yy, CN=zz".
Parameters:
  dnpart - String specifying which part of the DN to get, should be "CN" or "OU" etc. String containing dnpart or null if dnpart is not present



getPartsFromDN
public static ArrayList getPartsFromDN(String dn, String dnpart)(Code)
Gets a specified parts of a DN. Returns all occurences as an ArrayList, also works if DN contains several instances of a part (i.e. cn=x, cn=y returns {x, y, null}).
Parameters:
  dn - String containing DN, The DN string has the format "C=SE, O=xx, OU=yy, CN=zz".
Parameters:
  dnpart - String specifying which part of the DN to get, should be "CN" or "OU" etc. ArrayList containing dnparts or empty list if dnpart is not present



getSignatureAlgorithm
public static String getSignatureAlgorithm(X509Certificate cert)(Code)
Simple method that looks at the certificate and determines, from EJBCA's standpoint, which signature algorithm it is
Parameters:
  cert - the cert to examine Signature algorithm from CATokenInfo.SIGALG_SHA1_WITH_RSA etc.



getSubjectAlternativeName
public static String getSubjectAlternativeName(X509Certificate certificate) throws CertificateParsingException, IOException(Code)
SubjectAltName ::= GeneralNames GeneralNames :: = SEQUENCE SIZE (1..MAX) OF GeneralName GeneralName ::= CHOICE { otherName [0] OtherName, rfc822Name [1] IA5String, dNSName [2] IA5String, x400Address [3] ORAddress, directoryName [4] Name, ediPartyName [5] EDIPartyName, uniformResourceIdentifier [6] IA5String, iPAddress [7] OCTET STRING, registeredID [8] OBJECT IDENTIFIER} SubjectAltName is of form \"rfc822Name=, dNSName=, uniformResourceIdentifier=, iPAddress=
, guid=, directoryName= Supported altNames are upn, rfc822Name, uniformResourceIdentifier, dNSName, iPAddress, directoryName
author:
   Marco Ferrante, (c) 2005 CSITA - University of Genoa (Italy)
author:
   Tomas Gustavsson
Parameters:
  certificate - containing alt names String containing altNames of form "rfc822Name=email, dNSName=hostname, uniformResourceIdentifier=uri, iPAddress=ip, upn=upn, directoryName=CN=testDirName|dir|name" or null if no altNames exist. Values in returned String is from CertTools constants. AltNames not supported are simply not shown in the resulting string.
throws:
  java.lang.Exception -



getSubjectDN
public static String getSubjectDN(X509Certificate cert)(Code)
Gets subject DN in the format we are sure about (BouncyCastle),supporting UTF8.
Parameters:
  cert - X509Certificate String containing the subjects DN.



getSubjectKeyId
public static byte[] getSubjectKeyId(X509Certificate cert) throws IOException(Code)
Get the subject key identifier from a certificate extensions
Parameters:
  cert - certificate containing the extension byte[] containing the subject key identifier, or null if it does not exist
throws:
  IOException - if extension can not be parsed



getUPNAltName
public static String getUPNAltName(X509Certificate cert) throws IOException, CertificateParsingException(Code)
Gets the Microsoft specific UPN altName.
Parameters:
  cert - certificate containing the extension String with the UPN name or null if the altName does not exist



getX509FieldOrder
public static Vector getX509FieldOrder(boolean ldaporder)(Code)
Obtains a Vector with the DERObjectIdentifiers for dNObjects names, in the specified order
Parameters:
  ldaporder - if true the returned order are as defined in LDAP RFC (CN=foo,O=bar,C=SE), otherwise the order is a defined in X.500 (C=SE,O=bar,CN=foo). Vector with DERObjectIdentifiers defining the known order we require



insertCNPostfix
public static String insertCNPostfix(String dn, String cnpostfix)(Code)
Method used to insert a CN postfix into DN by extracting the first found CN appending cnpostfix and then replacing the original CN with the new one in DN. If no CN could be found in DN then should the given DN be returned untouched
Parameters:
  dn - the DN to manipulate, cannot be null
Parameters:
  cnpostfix - the postfix to insert, cannot be null the new DN



installBCProvider
public static synchronized void installBCProvider()(Code)



isDNReversed
protected static boolean isDNReversed(String dn)(Code)
Tries to determine if a DN is in reversed form. It does this by taking the last attribute and the first attribute. If the last attribute comes before the first in the dNObjects array the DN is assumed to be in reversed order. The check if a DN is revered is relative to the default ordering, so if the default ordering is: "C=SE, O=PrimeKey, CN=Tomas" (dNObjectsReverse ordering in EJBCA) a dn or form "CN=Tomas, O=PrimeKey, C=SE" is reversed. if the default ordering is: "CN=Tomas, O=PrimeKey, C=SE" (dNObjectsForward ordering in EJBCA) a dn or form "C=SE, O=PrimeKey, CN=Tomas" is reversed.
Parameters:
  dn - String containing DN to be checked, The DN string has the format "C=SE, O=xx, OU=yy, CN=zz". true if the DN is believed to be in reversed order, false otherwise



isSelfSigned
public static boolean isSelfSigned(X509Certificate cert)(Code)
Checks if a certificate is self signed by verifying if subject and issuer are the same.
Parameters:
  cert - the certificate that skall be checked. boolean true if the certificate has the same issuer and subject, false otherwise.



removeBCProvider
public static synchronized void removeBCProvider()(Code)



reverseDN
public static String reverseDN(String dn)(Code)
Takes a DN and reverses it completely so the first attribute ends up last. C=SE,O=Foo,CN=Bar becomes CN=Bar,O=Foo,C=SE.
Parameters:
  dn - String containing DN to be reversed, The DN string has the format "C=SE, O=xx, OU=yy, CN=zz". String containing reversed DN



stringToBCDNString
public static String stringToBCDNString(String dn)(Code)
Every DN-string should look the same. Creates a name string ordered and looking like we want it...
Parameters:
  dn - String containing DN String containing DN, or null if input is null



stringToBcX509Name
public static X509Name stringToBcX509Name(String dn)(Code)
See stringToBcX509Name(String, X509NameEntryConverter), this method uses the default BC converter (X509DefaultEntryConverter)
See Also:   CertTools.stringToBcX509Name(String,X509NameEntryConverter)
Parameters:
  dn - String containing DN that will be transformed into X509Name, TheDN string has the format "CN=zz,OU=yy,O=foo,C=SE". Unknown OIDs inthe string will be added to the end positions of OID array. X509Name or null if input is null



stringToBcX509Name
public static X509Name stringToBcX509Name(String dn, X509NameEntryConverter converter, Vector dnOrder)(Code)



sunKeyUsageToBC
public static int sunKeyUsageToBC(boolean[] sku)(Code)
Converts Sun Key usage bits to Bouncy castle key usage kits
Parameters:
  sku - key usage bit fields according to java.security.cert.X509Certificate#getKeyUsage, must be a boolean aray of size 9. key usage int according to org.bouncycastle.jce.X509KeyUsage#X509KeyUsage, or -1 if input is null.
See Also:   java.security.cert.X509Certificate.getKeyUsage
See Also:   org.bouncycastle.jce.X509KeyUsage.X509KeyUsage



verify
public static boolean verify(X509Certificate certificate, Collection caCertPath) throws Exception(Code)
Check the certificate with CA certificate.
Parameters:
  certificate - cert to verify
Parameters:
  caCertPath - collection of X509Certificate true if verified OK, false if not



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.