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

                //v3CertGen.setSignatureAlgorithm("SHA1WithRSAEncryption");
                v3CertGen.setSignatureAlgorithm(SOSCertificate.hashAlgorithm
                        + "With" + privateKey.getAlgorithm());

                X509Certificate cert = v3CertGen
                        .generateX509Certificate(privateKey);

                return cert;
            } catch (NoClassDefFoundError e) {
                throw new Exception("not found  Definition : " + e);
    View Full Code Here

    Examples of java.security.cert.X509Certificate

                            Certificate[] certs = keystore.getCertificateChain(alias);
                            if (certs != null) {
                                LOG.debug("Certificate chain '" + alias + "':");
                                for (int c = 0; c < certs.length; c++) {
                                    if (certs[c] instanceof X509Certificate) {
                                        X509Certificate cert = (X509Certificate)certs[c];
                                        LOG.debug(" Certificate " + (c + 1) + ":");
                                        LOG.debug("  Subject DN: " + cert.getSubjectDN());
                                        LOG.debug("  Signature Algorithm: " + cert.getSigAlgName());
                                        LOG.debug("  Valid from: " + cert.getNotBefore() );
                                        LOG.debug("  Valid until: " + cert.getNotAfter());
                                        LOG.debug("  Issuer: " + cert.getIssuerDN());
                                    }
                                }
                            }
                        }
                    }
                    keymanagers = createKeyManagers(keystore, this.keystorePassword);
                }
                if (this.truststoreUrl != null) {
                    KeyStore keystore = createKeyStore(this.truststoreUrl, this.truststorePassword);
                    if (LOG.isDebugEnabled()) {
                        Enumeration aliases = keystore.aliases();
                        while (aliases.hasMoreElements()) {
                            String alias = (String)aliases.nextElement();
                            LOG.debug("Trusted certificate '" + alias + "':");
                            Certificate trustedcert = keystore.getCertificate(alias);
                            if (trustedcert != null && trustedcert instanceof X509Certificate) {
                                X509Certificate cert = (X509Certificate)trustedcert;
                                LOG.debug("  Subject DN: " + cert.getSubjectDN());
                                LOG.debug("  Signature Algorithm: " + cert.getSigAlgName());
                                LOG.debug("  Valid from: " + cert.getNotBefore() );
                                LOG.debug("  Valid until: " + cert.getNotAfter());
                                LOG.debug("  Issuer: " + cert.getIssuerDN());
                            }
                        }
                    }
                    trustmanagers = createTrustManagers(keystore);
                }
    View Full Code Here

    Examples of java.security.cert.X509Certificate

         * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType)
         */
        public void checkClientTrusted(X509Certificate[] certificates,String authType) throws CertificateException {
            if (LOG.isInfoEnabled() && certificates != null) {
                for (int c = 0; c < certificates.length; c++) {
                    X509Certificate cert = certificates[c];
                    LOG.info(" Client certificate " + (c + 1) + ":");
                    LOG.info("  Subject DN: " + cert.getSubjectDN());
                    LOG.info("  Signature Algorithm: " + cert.getSigAlgName());
                    LOG.info("  Valid from: " + cert.getNotBefore() );
                    LOG.info("  Valid until: " + cert.getNotAfter());
                    LOG.info("  Issuer: " + cert.getIssuerDN());
                }
            }
            defaultTrustManager.checkClientTrusted(certificates,authType);
        }
    View Full Code Here

    Examples of java.security.cert.X509Certificate

         * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType)
         */
        public void checkServerTrusted(X509Certificate[] certificates,String authType) throws CertificateException {
            if (LOG.isInfoEnabled() && certificates != null) {
                for (int c = 0; c < certificates.length; c++) {
                    X509Certificate cert = certificates[c];
                    LOG.info(" Server certificate " + (c + 1) + ":");
                    LOG.info("  Subject DN: " + cert.getSubjectDN());
                    LOG.info("  Signature Algorithm: " + cert.getSigAlgName());
                    LOG.info("  Valid from: " + cert.getNotBefore() );
                    LOG.info("  Valid until: " + cert.getNotAfter());
                    LOG.info("  Issuer: " + cert.getIssuerDN());
                }
            }
            defaultTrustManager.checkServerTrusted(certificates,authType);
        }
    View Full Code Here

    Examples of java.security.cert.X509Certificate

                for (int i = 0; i < certificates.length; i++) {
                    LOG.debug("X509Certificate[" + i + "]=" + certificates[i]);
                }
            }
            if ((certificates != null) && (certificates.length == 1)) {
                X509Certificate certificate = certificates[0];
                try {
                    certificate.checkValidity();
                }
                catch (CertificateException e) {
                    LOG.error(e.toString());
                    return false;
                }
    View Full Code Here

    Examples of java.security.cert.X509Certificate

               
               
                while(it.hasNext())
                {
                    PublicKeyRecipient recipient = (PublicKeyRecipient)it.next();               
                    X509Certificate certificate = recipient.getX509();
                    int permission = recipient.getPermission().getPermissionBytesForPublicKey();
               
                    byte[] pkcs7input = new byte[24];
                    byte one = (byte)(permission);
                    byte two = (byte)(permission >>> 8);
    View Full Code Here

    Examples of java.security.cert.X509Certificate

            recip1.setPermission(accessPermission);
            recip2.setPermission(accessPermission2);
           
            InputStream inStream = new FileInputStream(publicCert1);       
            Assert.assertNotNull(cf);
            X509Certificate certificate1 = (X509Certificate)cf.generateCertificate(inStream);
            inStream.close();       
           
            InputStream inStream2 = new FileInputStream(publicCert2);       
            Assert.assertNotNull(cf);
            X509Certificate certificate2 = (X509Certificate)cf.generateCertificate(inStream2);
            inStream.close();       
           
            recip1.setX509(certificate1);
            recip2.setX509(certificate2);
           
    View Full Code Here

    Examples of java.security.cert.X509Certificate

        private void protect(PDDocument doc, String certPath) throws Exception
        {
            InputStream inStream = new FileInputStream(certPath);
            CertificateFactory cf = CertificateFactory.getInstance("X.509");
            Assert.assertNotNull(cf);
            X509Certificate certificate = (X509Certificate)cf.generateCertificate(inStream);
            Assert.assertNotNull(certificate);
            inStream.close();       
           
            PublicKeyProtectionPolicy ppp = new PublicKeyProtectionPolicy();               
            PublicKeyRecipient recip = new PublicKeyRecipient();
    View Full Code Here

    Examples of java.security.cert.X509Certificate

                            recip.setPermission(ap);
                           
                           
                            CertificateFactory cf = CertificateFactory.getInstance("X.509");                           
                            InputStream inStream = new FileInputStream(certFile);
                            X509Certificate certificate = (X509Certificate)cf.generateCertificate(inStream);
                            inStream.close();
                           
                            recip.setX509(certificate);
                           
                            ppp.addRecipient(recip);
    View Full Code Here

    Examples of java.security.cert.X509Certificate

          return;

        try {
          CertificateFactory cf = CertificateFactory.getInstance("X.509");
          InputStream is = _clientCert.createInputStream();
          X509Certificate cert = (X509Certificate) cf.generateCertificate(is);
          is.close();

          request.setAttribute("javax.servlet.request.X509Certificate",
                               new X509Certificate[]{cert});
          request.setAttribute(com.caucho.security.AbstractLogin.LOGIN_USER_NAME,
    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.