Examples of X509Certificate

  • java.security.cert.X509Certificate
    etf.org/rfc/rfc2459.txt"> http://www.ietf.org/rfc/rfc2459.txt .

    The ASN.1 definition of tbsCertificate is:

     TBSCertificate  ::=  SEQUENCE  { version         [0]  EXPLICIT Version DEFAULT v1, serialNumber         CertificateSerialNumber, signature            AlgorithmIdentifier, issuer               Name, validity             Validity, subject              Name, subjectPublicKeyInfo SubjectPublicKeyInfo, issuerUniqueID  [1]  IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version must be v2 or v3 subjectUniqueID [2]  IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version must be v2 or v3 extensions      [3]  EXPLICIT Extensions OPTIONAL -- If present, version must be v3 } 

    Certificates are instantiated using a certificate factory. The following is an example of how to instantiate an X.509 certificate:

      InputStream inStream = new FileInputStream("fileName-of-cert"); CertificateFactory cf = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream); inStream.close(); 
    @author Hemma Prafullchandra @version 1.40 @see Certificate @see CertificateFactory @see X509Extension
  • javax.security.cert.X509Certificate
    Abstract class for X.509 v1 certificates. This provides a standard way to access all the version 1 attributes of an X.509 certificate. Attributes that are specific to X.509 v2 or v3 are not available through this interface. Future API evolution will provide full access to complete X.509 v3 attributes.

    The basic X.509 format was defined by ISO/IEC and ANSI X9 and is described below in ASN.1:

     Certificate  ::=  SEQUENCE  { tbsCertificate       TBSCertificate, signatureAlgorithm   AlgorithmIdentifier, signature            BIT STRING  } 

    These certificates are widely used to support authentication and other functionality in Internet security systems. Common applications include Privacy Enhanced Mail (PEM), Transport Layer Security (SSL), code signing for trusted software distribution, and Secure Electronic Transactions (SET).

    These certificates are managed and vouched for by Certificate Authorities (CAs). CAs are services which create certificates by placing data in the X.509 standard format and then digitally signing that data. CAs act as trusted third parties, making introductions between principals who have no direct knowledge of each other. CA certificates are either signed by themselves, or by some other CA such as a "root" CA.

    The ASN.1 definition of {@code tbsCertificate} is:

     TBSCertificate  ::=  SEQUENCE  { version         [0]  EXPLICIT Version DEFAULT v1, serialNumber         CertificateSerialNumber, signature            AlgorithmIdentifier, issuer               Name, validity             Validity, subject              Name, subjectPublicKeyInfo SubjectPublicKeyInfo, } 

    Here is sample code to instantiate an X.509 certificate:

     InputStream inStream = new FileInputStream("fileName-of-cert"); X509Certificate cert = X509Certificate.getInstance(inStream); inStream.close(); 
    OR
     byte[] certData = <certificate read from a file, say> X509Certificate cert = X509Certificate.getInstance(certData); 

    In either case, the code that instantiates an X.509 certificate consults the value of the {@code cert.provider.x509v1} security propertyto locate the actual implementation or instantiates a default implementation.

    The {@code cert.provider.x509v1} property is set to a defaultimplementation for X.509 such as:

     cert.provider.x509v1=com.sun.security.cert.internal.x509.X509V1CertImpl 

    The value of this {@code cert.provider.x509v1} property has to bechanged to instantiate another implementation. If this security property is not set, a default implementation will be used. Currently, due to possible security restrictions on access to Security properties, this value is looked up and cached at class initialization time and will fallback on a default implementation if the Security property is not accessible.

    Note: The classes in the package {@code javax.security.cert}exist for compatibility with earlier versions of the Java Secure Sockets Extension (JSSE). New applications should instead use the standard Java SE certificate classes located in {@code java.security.cert}.

    @author Hemma Prafullchandra @since 1.4 @see Certificate @see java.security.cert.X509Extension @see java.security.Security security properties
  • net.rim.device.api.crypto.certificate.x509.X509Certificate
    Implements a X.509v3 certificate according to the following ASN.1 data structure:

     Certificate  ::=  SEQUENCE  { tbsCertificate			TBSCertificate, signatureAlgorithm		AlgorithmIdentifier, signatureValue      	BIT STRING } 
    If you want to create a certificate, follow these steps:
  • create a {@link X509TBSCertificate X509TBSCertificate} object and fillit with sensible data
  • call the {@link #X509Certificate(X509TBSCertificate)} constructor andpass the tbsCertificate as an argument
  • call {@link #setSignature(byte[]) setSignature} with a pre-computedsignature of the tbsCertificate
  • {@link #getEncoded() getEncoded()} will return the DER-encodedcertificate as a Byte array.

    Example:

     PrivateKey CASigningKey = ...; X509Certificate CASignatureCert = ...; PublicKey subjectPublicKey = ...; Name issuerDN = new Name("cn=My CA, c=DE"); Name subjectDN = new Name("cn=Myself, c=DE"); Calendar validFrom = ...; Calendar validUntil = ...; X509TBSCertificate tbs = new X509TBSCertificate(); tbs.setSerialNumber(new BigInteger("1")); tbs.setSubjectPublicKey(subjectPublicKey); tbs.setSubjectDN(subjectDN); tbs.setIssuerDN(issuerDN); tbs.setNotBefore(validFrom); tbs.setNotAfter(validUntil); X509Certificate theCert = new X509Certificate(tbs); Signature mySig = Signature.getInstance(...); mySig.initSign(CASigningKey); theCert.sign(mySig, CASignatureCert); 
    @author Markus Tak
  • org.opensaml.xml.signature.X509Certificate
    XMLObject representing XML Digital Signature, version 20020212, X509Certificate element.

  • Examples of java.security.cert.X509Certificate

        * @return teh publickey
        * @throws XMLSecurityException
        */
       public PublicKey getPublicKey() throws XMLSecurityException {

          X509Certificate cert = this.getX509Certificate();

          if (cert != null) {
             return cert.getPublicKey();
          }

          return null;
       }
    View Full Code Here

    Examples of java.security.cert.X509Certificate

             boolean added = false;
             String dn = null;

             try {
                FileInputStream fis = new FileInputStream(file);
                X509Certificate cert =
                   (X509Certificate) cf.generateCertificate(fis);

                fis.close();

                //add to ArrayList
                cert.checkValidity();
                this._certs.add(cert);

                dn = cert.getSubjectDN().getName();
                added = true;
             } catch (FileNotFoundException ex) {
                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
             } catch (IOException ex) {
                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
    View Full Code Here

    Examples of java.security.cert.X509Certificate

          CertsInFilesystemDirectoryResolver krs =
             new CertsInFilesystemDirectoryResolver(
                "data/ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/certs");

          for (Iterator i = krs.getIterator(); i.hasNext(); ) {
             X509Certificate cert = (X509Certificate) i.next();
             byte[] ski =
                com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI
                   .getSKIBytesFromCert(cert);

             System.out.println();
             System.out.println("Base64(SKI())=                 \""
                                + Base64.encode(ski) + "\"");
             System.out.println("cert.getSerialNumber()=        \""
                                + cert.getSerialNumber().toString() + "\"");
             System.out.println("cert.getSubjectDN().getName()= \""
                                + cert.getSubjectDN().getName() + "\"");
             System.out.println("cert.getIssuerDN().getName()=  \""
                                + cert.getIssuerDN().getName() + "\"");
          }
       }
    View Full Code Here

    Examples of java.security.cert.X509Certificate

                "xmlsecurity".toCharArray());

          KeyStoreResolver krs = new KeyStoreResolver(ks);

          for (Iterator i = krs.getIterator(); i.hasNext(); ) {
             X509Certificate cert = (X509Certificate) i.next();
             byte[] ski =
                com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI
                   .getSKIBytesFromCert(cert);

             System.out.println(com.sun.org.apache.xml.internal.security.utils.Base64.encode(ski));
    View Full Code Here

    Examples of java.security.cert.X509Certificate

        */
       public PublicKey engineResolvePublicKey(
               Element element, String BaseURI, StorageResolver storage)
                  throws KeyResolverException {

          X509Certificate cert = this.engineResolveX509Certificate(element,
                                    BaseURI, storage);

          if (cert != null) {
             return cert.getPublicKey();
          }

          return null;
       }
    View Full Code Here

    Examples of java.security.cert.X509Certificate

       /** @inheritDoc */
       public PublicKey engineResolvePublicKey(
               Element element, String BaseURI, StorageResolver storage)
                  throws KeyResolverException {

          X509Certificate cert = this.engineResolveX509Certificate(element,
                                    BaseURI, storage);

          if (cert != null) {
             return cert.getPublicKey();
          }

          return null;
       }
    View Full Code Here

    Examples of java.security.cert.X509Certificate

             X509Data x509data = new X509Data(element, BaseURI);
             int noOfISS = x509data.lengthIssuerSerial();

             while (storage.hasNext()) {
                X509Certificate cert = storage.next();
                XMLX509IssuerSerial certSerial = new XMLX509IssuerSerial(element.getOwnerDocument(), cert);

                if (true) {
                  if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Found Certificate Issuer: "
                          + certSerial.getIssuerName());
    View Full Code Here

    Examples of java.security.cert.X509Certificate

                   // if the resource stores a raw certificate, we have to handle it
                   CertificateFactory certFact =
                      CertificateFactory
                         .getInstance(XMLX509Certificate.JCA_CERT_ID);
                   X509Certificate cert =
                      (X509Certificate) certFact
                         .generateCertificate(new ByteArrayInputStream(inputBytes));

                   if (cert != null) {
                      return cert.getPublicKey();
                   }
                } else {

                   // otherwise, we parse the resource, create an Element and delegate
                    if (true)
    View Full Code Here

    Examples of java.security.cert.X509Certificate

                   // if the resource stores a raw certificate, we have to handle it
                   CertificateFactory certFact =
                      CertificateFactory
                         .getInstance(XMLX509Certificate.JCA_CERT_ID);
                   X509Certificate cert =
                      (X509Certificate) certFact
                         .generateCertificate(new ByteArrayInputStream(inputBytes));

                   if (cert != null) {
                      return cert;
    View Full Code Here

    Examples of java.security.cert.X509Certificate

        */
       public PublicKey engineResolvePublicKey(
               Element element, String BaseURI, StorageResolver storage)
                  throws KeyResolverException {

          X509Certificate cert = this.engineResolveX509Certificate(element,
                                    BaseURI, storage);

          if (cert != null) {
             return cert.getPublicKey();
          }

          return null;
       }
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. All rights reserved.
    All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.