API java : X509Extension


java.security.cert
Interface X509Extension

All Known Implementing Classes:
X509Certificate, X509CRL, X509CRLEntry

public interface X509Extension

Interface for an X.509 extension.

The extensions defined for X.509 v3 Certificates and v2 CRLs (Certificate Revocation Lists) provide methods for associating additional attributes with users or public keys, for managing the certification hierarchy, and for managing CRL distribution. The X.509 extensions format also allows communities to define private extensions to carry information unique to those communities.

Each extension in a certificate/CRL may be designated as critical or non-critical. A certificate/CRL-using system (an application validating a certificate/CRL) must reject the certificate/CRL if it encounters a critical extension it does not recognize. A non-critical extension may be ignored if it is not recognized.

The ASN.1 definition for this is:

  1. Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
  2.  
  3. Extension ::= SEQUENCE {
  4. extnId OBJECT IDENTIFIER,
  5. critical BOOLEAN DEFAULT FALSE,
  6. extnValue OCTET STRING
  7. -- contains a DER encoding of a value
  8. -- of the type registered for use with
  9. -- the extnId object identifier value
  10. }
Since not all extensions are known, the getExtensionValue method returns the DER-encoded OCTET STRING of the extension value (i.e., the extnValue). This can then be handled by a Class that understands the extension.


Method Summary
 Set<String> getCriticalExtensionOIDs()
          Gets a Set of the OID strings for the extension(s) marked CRITICAL in the certificate/CRL managed by the object implementing this interface.
 byte[] getExtensionValue(String oid)
          Gets the DER-encoded OCTET string for the extension value (extnValue) identified by the passed-in oid String.
 Set<String> getNonCriticalExtensionOIDs()
          Gets a Set of the OID strings for the extension(s) marked NON-CRITICAL in the certificate/CRL managed by the object implementing this interface.
 boolean hasUnsupportedCriticalExtension()
          Check if there is a critical extension that is not supported.
 

Method Detail

hasUnsupportedCriticalExtension

boolean hasUnsupportedCriticalExtension()
Check if there is a critical extension that is not supported.

Returns:
true if a critical extension is found that is not supported, otherwise false.

getCriticalExtensionOIDs

Set<String> getCriticalExtensionOIDs()
Gets a Set of the OID strings for the extension(s) marked CRITICAL in the certificate/CRL managed by the object implementing this interface. Here is sample code to get a Set of critical extensions from an X509Certificate and print the OIDs:
  1. InputStream inStrm = new FileInputStream("DER-encoded-Cert");
  2. CertificateFactory cf = CertificateFactory.getInstance("X.509");
  3. X509Certificate cert = (X509Certificate)cf.generateCertificate(inStrm);
  4. inStrm.close();<p>
  5.  
  6. Set critSet = cert.getCriticalExtensionOIDs();
  7. if (critSet != null && !critSet.isEmpty()) {
  8. System.out.println("Set of critical extensions:");
  9. for (Iterator i = critSet.iterator(); i.hasNext();) {
  10. String oid = (String)i.next();
  11. System.out.println(oid);
  12. }
  13. }

Returns:
a Set (or an empty Set if none are marked critical) of the extension OID strings for extensions that are marked critical. If there are no extensions present at all, then this method returns null.

getNonCriticalExtensionOIDs

Set<String> getNonCriticalExtensionOIDs()
Gets a Set of the OID strings for the extension(s) marked NON-CRITICAL in the certificate/CRL managed by the object implementing this interface. Here is sample code to get a Set of non-critical extensions from an X509CRL revoked certificate entry and print the OIDs:
  1. InputStream inStrm = new FileInputStream("DER-encoded-CRL");
  2. CertificateFactory cf = CertificateFactory.getInstance("X.509");
  3. X509CRL crl = (X509CRL)cf.generateCRL(inStrm);
  4. inStrm.close();<p>
  5.  
  6. byte[] certData = <DER-encoded certificate data>
  7. X509Certificate cert = (X509Certificate)cf.generateCertificate(bais);
  8. bais.close();
  9. X509CRLEntry badCert =
  10. crl.getRevokedCertificate(cert.getSerialNumber());<p>
  11.  
  12. if (badCert != null) {
  13. Set nonCritSet = badCert.getNonCriticalExtensionOIDs();<p>
  14. if (nonCritSet != null)
  15. for (Iterator i = nonCritSet.iterator(); i.hasNext();) {
  16. String oid = (String)i.next();
  17. System.out.println(oid);
  18. }
  19. }

Returns:
a Set (or an empty Set if none are marked non-critical) of the extension OID strings for extensions that are marked non-critical. If there are no extensions present at all, then this method returns null.

getExtensionValue

byte[] getExtensionValue(String oid)
Gets the DER-encoded OCTET string for the extension value (extnValue) identified by the passed-in oid String. The oid string is represented by a set of nonnegative whole numbers separated by periods.

For example:
OID (Object Identifier) Extension Name
2.5.29.14 SubjectKeyIdentifier
2.5.29.15 KeyUsage
2.5.29.16 PrivateKeyUsage
2.5.29.17 SubjectAlternativeName
2.5.29.18 IssuerAlternativeName
2.5.29.19 BasicConstraints
2.5.29.30 NameConstraints
2.5.29.33 PolicyMappings
2.5.29.35 AuthorityKeyIdentifier
2.5.29.36 PolicyConstraints

Parameters:
oid - the Object Identifier value for the extension.
Returns:
the DER-encoded octet string of the extension value or null if it is not present.

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

7 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-2872
Document créé le 30/08/06 21:03, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/security/cert/X509Extension.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,85 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
La grandeur de l'homme est dans sa décision d'être plus fort que sa condition.

Albert Camus
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 22:04, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)