Package org.bouncycastle.asn1.x509

Examples of org.bouncycastle.asn1.x509.X509Name


                        else
                        {
                            genNames = new GeneralName[1];
                            try
                            {
                                genNames[0] = new GeneralName(new X509Name(
                                    (ASN1Sequence)ASN1Sequence.fromByteArray(CertPathValidatorUtilities
                                        .getEncodedIssuerPrincipal(cert).getEncoded())));
                            }
                            catch (IOException e)
                            {
                                throw new AnnotatedException("Could not read certificate issuer.", e);
                            }
                        }
                        for (int j = 0; j < genNames.length; j++)
                        {
                            Enumeration e = ASN1Sequence.getInstance(genNames[j].getName().getDERObject()).getObjects();
                            ASN1EncodableVector vec = new ASN1EncodableVector();
                            while (e.hasMoreElements())
                            {
                                vec.add((DEREncodable)e.nextElement());
                            }
                            vec.add(dpName.getName());
                            genNames[j] = new GeneralName(new X509Name(new DERSequence(vec)));
                        }
                    }
                    if (genNames != null)
                    {
                        for (int j = 0; j < genNames.length; j++)
View Full Code Here


            catch (Exception e)
            {
                throw new CertPathValidatorException("Subject alternative name extension could not be decoded.", e,
                    certPath, index);
            }
            Vector emails = new X509Name(dns).getValues(X509Name.EmailAddress);
            for (Enumeration e = emails.elements(); e.hasMoreElements();)
            {
                String email = (String)e.nextElement();
                GeneralName emailAsGeneralName = new GeneralName(GeneralName.rfc822Name, email);
                try
View Full Code Here

            attrs.put(X509Principal.O, "The Legion of the Bouncy Castle");
            attrs.put(X509Principal.L, "Melbourne");
            attrs.put(X509Principal.ST, "Victoria");
            attrs.put(X509Principal.EmailAddress, "feedback-crypto@bouncycastle.org");

            X509Name    subject = new X509Name(attrs);

            PKCS10CertificationRequest req1 = new PKCS10CertificationRequest(
                                                        "SHA1withRSA",
                                                        subject,
                                                        kp.getPublic(),
                                                        null,
                                                        kp.getPrivate());
                               
            byte[]  bytes = req1.getEncoded();

            PKCS10CertificationRequest req2 = new PKCS10CertificationRequest(bytes);

            if (!req2.verify())
            {
                return new SimpleTestResult(false, getName() + ": Failed verify check.");
            }

            if (!req2.getPublicKey().equals(req1.getPublicKey()))
            {
                return new SimpleTestResult(false, getName() + ": Failed public key check.");
            }

            // elliptic curve GOST A parameter set
            PKCS10CertificationRequest req = new PKCS10CertificationRequest(gost3410EC_A);
            if (!req.verify())
            {
                System.out.println(new SimpleTestResult(false, getName() + ": Failed verify check gost3410EC_A."));
            }

            // elliptic curve GOST B parameter set
            req = new PKCS10CertificationRequest(gost3410EC_B);
            if (!req.verify())
            {
                return new SimpleTestResult(false, getName() + ": Failed verify check gost3410EC_B.");
            }

            // elliptic curve GOST C parameter set
            req = new PKCS10CertificationRequest(gost3410EC_C);
            if (!req.verify())
            {
                return new SimpleTestResult(false, getName() + ": Failed verify check gost3410EC_C.");
            }
           
            // elliptic curve GOST ExA parameter set
            req = new PKCS10CertificationRequest(gost3410EC_ExA);
            if (!req.verify())
            {
                return new SimpleTestResult(false, getName() + ": Failed verify check gost3410EC_ExA.");
            }

            // elliptic curve GOST ExB parameter set
            req = new PKCS10CertificationRequest(gost3410EC_ExB);
            if (!req.verify())
            {
                return new SimpleTestResult(false, getName() + ": Failed verify check gost3410EC_ExA.");
            }
           
            // elliptic curve openSSL
            KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC");

            ECCurve curve = new ECCurve.Fp(
                new BigInteger("883423532389192164791648750360308885314476597252960362792450860609699839"), // q
                new BigInteger("7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc", 16), // a
                new BigInteger("6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a", 16)); // b

            ECParameterSpec ecSpec = new ECParameterSpec(
                curve,
                curve.decodePoint(Hex.decode("020ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf")), // G
                new BigInteger("883423532389192164791648750360308884807550341691627752275345424702807307")); // n

            g.initialize(ecSpec, new SecureRandom());

            kp = g.generateKeyPair();

            req = new PKCS10CertificationRequest(
                    "ECDSAWITHSHA1", new X509Name("CN=XXX"), kp.getPublic(), null, kp.getPrivate());
            if (!req.verify())
            {
                return new SimpleTestResult(false, getName() + ": Failed verify check EC.");
            }
           
View Full Code Here

      String dnInCanonicalForm = certs[0].getSubjectX500Principal()
          .getName("CANONICAL");
      log.info("DN in Cert: " + dnInCanonicalForm);

      X509Name x509NameArgument = new X509Name(dnInCanonicalForm);
      String commonNameInCert = DNUtil.getCommonName(x509NameArgument);
      log.debug("Common Name in Cert: " + commonNameInCert);

      // Check if user is authenticated to MailBox
      sb = Drop_OffUtil.isUserAuthenticated(mailBoxURI, commonNameInCert,
View Full Code Here

            String dnInCanonicalForm = certs[0].getSubjectX500Principal()
                    .getName("CANONICAL");
            log.info("DN in Cert: " + dnInCanonicalForm);

            X509Name x509NameArgument = new X509Name(dnInCanonicalForm);
            String commonNameInCert = DNUtil.getCommonName(x509NameArgument);
            log.debug("Common Name in Cert: " + commonNameInCert);

            // Check if user is authenticated to MailBox
            sb = Drop_OffUtil.isUserAuthenticated(mailBoxURI, commonNameInCert,
View Full Code Here

        String dnInCanonicalForm = certs[0].getSubjectX500Principal()
        .getName("CANONICAL");
        log.info("DN in Cert: " + dnInCanonicalForm);

        X509Name x509NameArgument = new X509Name(dnInCanonicalForm);
        String commonNameInCert = DNUtil.getCommonName(x509NameArgument);
       
        log.debug("comman Name in Cert: " + commonNameInCert);

        return commonNameInCert;
View Full Code Here

            String dnInCanonicalForm = certs[0].getSubjectX500Principal()
                    .getName("CANONICAL");
            log.info("DN in Cert: " + dnInCanonicalForm);

            X509Name x509NameArgument = new X509Name(dnInCanonicalForm);
            String commonNameInCert = DNUtil.getCommonName(x509NameArgument);
            log.debug("Common Name in Cert: " + commonNameInCert);

            // Check if user is authenticated to MailBox
            sb = Drop_OffUtil.isUserAuthenticated(mailBoxURI, commonNameInCert,
View Full Code Here

        String issuer,
        BigInteger serialNumber,
        boolean useSerialNumber
    ) throws WSSecurityException {
        X500Principal issuerRDN = null;
        X509Name issuerName = null;
        Certificate cert = null;
       
        //
        // Convert the issuer DN to a java X500Principal object first. This is to ensure
        // interop with a DN constructed from .NET, where e.g. it uses "S" instead of "ST".
        // Then convert it to a BouncyCastle X509Name, which will order the attributes of
        // the DN in a particular way (see WSS-168). If the conversion to an X500Principal
        // object fails (e.g. if the DN contains "E" instead of "EMAILADDRESS"), then fall
        // back on a direct conversion to a BC X509Name
        //
        try {
            issuerRDN = new X500Principal(issuer);
            issuerName =  new X509Name(issuerRDN.getName());
        } catch (java.lang.IllegalArgumentException ex) {
            issuerName = new X509Name(issuer);
        }

        try {
            for (Enumeration e = keystore.aliases(); e.hasMoreElements();) {
                String alias = (String) e.nextElement();
                Certificate[] certs = keystore.getCertificateChain(alias);
                if (certs == null || certs.length == 0) {
                    // no cert chain, so lets check if getCertificate gives us a result.
                    cert = keystore.getCertificate(alias);
                    if (cert == null) {
                        return null;
                    }
                } else {
                    cert = certs[0];
                }
                if (!(cert instanceof X509Certificate)) {
                    continue;
                }
                X509Certificate x509cert = (X509Certificate) cert;
                if (!useSerialNumber || x509cert.getSerialNumber().compareTo(serialNumber) == 0) {
                    X509Name certName = new X509Name(x509cert.getIssuerDN().getName());
                    if (certName.equals(issuerName)) {
                        return alias;
                    }
                }
            }
        } catch (KeyStoreException e) {
View Full Code Here

                                {
                                    checkPermittedDN(permittedSubtreesDN, altDN);
                                }
                                catch (CertPathValidatorException cpve)
                                {
                                    X509Name altDNName = new X509Name(altDN);
                                    ErrorBundle msg = new ErrorBundle(RESOURCE_NAME,"CertPathReviewer.notPermittedDN",
                                            new Object[] {new UntrustedInput(altDNName)});
                                    throw new CertPathReviewerException(msg,cpve,certPath,index);
                                }
                               
                                try
                                {
                                    checkExcludedDN(excludedSubtreesDN, altDN);
                                }
                                catch (CertPathValidatorException cpve)
                                {
                                    X509Name altDNName = new X509Name(altDN);
                                    ErrorBundle msg = new ErrorBundle(RESOURCE_NAME,"CertPathReviewer.excludedDN",
                                            new Object[] {new UntrustedInput(altDNName)});
                                    throw new CertPathReviewerException(msg,cpve,certPath,index);
                                }
                               
View Full Code Here

        attrs.put(X509Principal.O, "The Legion of the Bouncy Castle");
        attrs.put(X509Principal.L, "Melbourne");
        attrs.put(X509Principal.ST, "Victoria");
        attrs.put(X509Principal.EmailAddress, "feedback-crypto@bouncycastle.org");

        X509Name    subject = new X509Name(attrs);

        PKCS10CertificationRequest req1 = new PKCS10CertificationRequest(
                                                    sigName,
                                                    subject,
                                                    kp.getPublic(),
View Full Code Here

TOP

Related Classes of org.bouncycastle.asn1.x509.X509Name

Copyright © 2018 www.massapicom. 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.