Package org.apache.geronimo.crypto.asn1.x509

Examples of org.apache.geronimo.crypto.asn1.x509.AttributeCertificateInfo


                response.setRenderParameter("sNo", sNo.toString());
                portlet.addWarningMessage(request, portlet.getLocalizedString(request, "consolebase.warnMsg06", sNo));
                return VIEW_CERT_MODE;
            }

            X509Name subject = null;
            PublicKey publickey = null;
            // Process the CSR text to get subject details
            String pkcs10certreq = null, certreq = null;
            String challenge = null;
            String requestId = request.getParameter("requestId");
            if(requestId != null && !requestId.equals("")) {
                // Certificate request is being processed using a previously stored request in CertificateRequestStore
                String certreqText = getCertificateRequestStore(request).getRequest(requestId);
                if(certreqText.startsWith(CaUtils.CERT_REQ_HEADER)) {
                    // A PKCS 10 Certificate Request
                    pkcs10certreq = certreqText;
                } else {
                    // Possibly a CSR received through web browser
                    certreq = certreqText;
                }
            } else {
                // No request id is found.  Get the PKCS10 request submitted through form input
                pkcs10certreq = request.getParameter("pkcs10certreq");
            }
           
            if(pkcs10certreq != null && !"".equals(pkcs10certreq)) {
                // Process PKCS 10 Certificate Request text to get Subject name and public-key
                Map certReqMap = CaUtils.processPKCS10Request(pkcs10certreq);
                subject = (X509Name) certReqMap.get(CaUtils.CERT_REQ_SUBJECT);
                publickey = (PublicKey) certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ);
            } else {
                // This is a custom request containing SPKAC and X509Name attributes received through web browser
                Properties csrProps = new Properties();
                csrProps.load(new ByteArrayInputStream(certreq.getBytes()));
                String spkac = csrProps.getProperty("SPKAC");
                String cn = csrProps.getProperty("CN");
                String ou = csrProps.getProperty("OU");
                String o = csrProps.getProperty("O");
                String l = csrProps.getProperty("L");
                String st = csrProps.getProperty("ST");
                String c = csrProps.getProperty("C");
                subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
                Map certReqMap = CaUtils.processSPKAC(spkac);
                publickey = (PublicKey) certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ);
                challenge = (String) certReqMap.get(CaUtils.PKAC_CHALLENGE);
            }

            // Dates have already been validated in the previous screen
            String validFrom = request.getParameter("validFrom");
            String validTo = request.getParameter("validTo");
            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
            Date validFromDate = df.parse(validFrom);
            Date validToDate = df.parse(validTo);
            String algorithm = request.getParameter("algorithm");
            // Issue certificate
            ca.issueCertificate(new X500Principal(subject.getEncoded()), publickey, sNo, validFromDate, validToDate, algorithm);
            // Store the challenge phrase against the issued certificate serial number
            if(challenge != null && !challenge.equals("")) {
                getCertificateStore(request).setCertificateChallenge(sNo, challenge);
            }
           
View Full Code Here


     * @return newly issued certificate
     */
    public Certificate issueCertificate(X500Principal subject, PublicKey publicKey, BigInteger sNo, Date validFromDate, Date validToDate, String algorithm) throws CertificationAuthorityException{
        if(isLocked()) throw new CertificationAuthorityException("CA is locked.");
        try {
            X509Name subName = CaUtils.getX509Name(subject);
            Certificate cert = issueCertificate(subName, caName, sNo, publicKey, caPrivateKey, validFromDate, validToDate, algorithm);
            cert.verify(caPublicKey);
            certStore.storeCertificate(cert);
            return cert;
        } catch(Exception e) {
View Full Code Here

                String ou = csrProps.getProperty("OU");
                String o = csrProps.getProperty("O");
                String l = csrProps.getProperty("L");
                String st = csrProps.getProperty("ST");
                String c = csrProps.getProperty("C");
                X509Name subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
                Map certReqMap = CaUtils.processSPKAC(spkac);
                // Set the subject and publickey values to be shown in subsequent screens
                response.setRenderParameter("subject", subject.toString());
                response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
            }
            return CONFIRM_CERT_REQ_MODE+BEFORE_ACTION;
        } catch(Exception e) {
            portlet.addErrorMessage(request, portlet.getLocalizedString(request, "consolebase.errorMsg18", requestId), e.getMessage());
View Full Code Here

                String ou = csrProps.getProperty("OU");
                String o = csrProps.getProperty("O");
                String l = csrProps.getProperty("L");
                String st = csrProps.getProperty("ST");
                String c = csrProps.getProperty("C");
                X509Name subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
                Map certReqMap = CaUtils.processSPKAC(spkac);
                // Set the subject and publickey values to be displayed in subsequent screens
                response.setRenderParameter("subject", subject.toString());
                response.setRenderParameter("publickey", certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ).toString());
            }
            return CERT_REQ_DETAILS_MODE+BEFORE_ACTION;
        } catch(Exception e) {
            portlet.addErrorMessage(request, portlet.getLocalizedString(request, "consolebase.errorMsg17", requestId), e.getMessage());
View Full Code Here

                response.setRenderParameter("sNo", sNo.toString());
                portlet.addWarningMessage(request, portlet.getLocalizedString(request, "consolebase.warnMsg06", sNo));
                return VIEW_CERT_MODE;
            }

            X509Name subject = null;
            PublicKey publickey = null;
            // Process the CSR text to get subject details
            String pkcs10certreq = null, certreq = null;
            String challenge = null;
            String requestId = request.getParameter("requestId");
            if(requestId != null && !requestId.equals("")) {
                // Certificate request is being processed using a previously stored request in CertificateRequestStore
                String certreqText = getCertificateRequestStore(request).getRequest(requestId);
                if(certreqText.startsWith(CaUtils.CERT_REQ_HEADER)) {
                    // A PKCS 10 Certificate Request
                    pkcs10certreq = certreqText;
                } else {
                    // Possibly a CSR received through web browser
                    certreq = certreqText;
                }
            } else {
                // No request id is found.  Get the PKCS10 request submitted through form input
                pkcs10certreq = request.getParameter("pkcs10certreq");
            }
           
            if(pkcs10certreq != null && !"".equals(pkcs10certreq)) {
                // Process PKCS 10 Certificate Request text to get Subject name and public-key
                Map certReqMap = CaUtils.processPKCS10Request(pkcs10certreq);
                subject = (X509Name) certReqMap.get(CaUtils.CERT_REQ_SUBJECT);
                publickey = (PublicKey) certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ);
            } else {
                // This is a custom request containing SPKAC and X509Name attributes received through web browser
                Properties csrProps = new Properties();
                csrProps.load(new ByteArrayInputStream(certreq.getBytes()));
                String spkac = csrProps.getProperty("SPKAC");
                String cn = csrProps.getProperty("CN");
                String ou = csrProps.getProperty("OU");
                String o = csrProps.getProperty("O");
                String l = csrProps.getProperty("L");
                String st = csrProps.getProperty("ST");
                String c = csrProps.getProperty("C");
                subject = CaUtils.getX509Name(cn, ou, o, l, st, c);
                Map certReqMap = CaUtils.processSPKAC(spkac);
                publickey = (PublicKey) certReqMap.get(CaUtils.CERT_REQ_PUBLICKEY_OBJ);
                challenge = (String) certReqMap.get(CaUtils.PKAC_CHALLENGE);
            }

            // Dates have already been validated in the previous screen
            String validFrom = request.getParameter("validFrom");
            String validTo = request.getParameter("validTo");
            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
            Date validFromDate = df.parse(validFrom);
            Date validToDate = df.parse(validTo);
            String algorithm = request.getParameter("algorithm");
            // Issue certificate
            ca.issueCertificate(new X500Principal(subject.getEncoded()), publickey, sNo, validFromDate, validToDate, algorithm);
            // Store the challenge phrase against the issued certificate serial number
            if(challenge != null && !challenge.equals("")) {
                getCertificateStore(request).setCertificateChallenge(sNo, challenge);
            }
           
View Full Code Here

        if (!extGenerator.isEmpty())
        {
            acInfoGen.setExtensions(extGenerator.generate());
        }

        AttributeCertificateInfo acInfo = acInfoGen.generateAttributeCertificateInfo();

        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(acInfo);
        v.add(sigAlgId);
View Full Code Here

        if (!extGenerator.isEmpty())
        {
            acInfoGen.setExtensions(extGenerator.generate());
        }

        AttributeCertificateInfo acInfo = acInfoGen.generateAttributeCertificateInfo();

        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(acInfo);
        v.add(sigAlgId);
View Full Code Here

        if (extensions != null)
        {
            acInfoGen.setExtensions(new X509Extensions(extOrdering, extensions));
        }

        AttributeCertificateInfo acInfo = acInfoGen.generateAttributeCertificateInfo();

        try
        {
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            DEROutputStream         dOut = new DEROutputStream(bOut);
View Full Code Here

            ASN1Sequence seq = (ASN1Sequence) aIn.readObject();
            dump = ASN1Dump.dumpAsString(seq);

            AttributeCertificate obj = new AttributeCertificate(seq);
            AttributeCertificateInfo acInfo = obj.getAcinfo();

            // Version
            if (!(acInfo.getVersion().equals(new DERInteger(1)))
                    && (!(acInfo.getVersion().equals(new DERInteger(2)))))
            {
                return new SimpleTestResult(false,
                        "failed AC Version test for id " + id);
            }

            // Holder
            Holder h = acInfo.getHolder();
            if (h == null)
            {
                return new SimpleTestResult(false,
                        "failed AC Holder test, it's null, for id " + id);
            }

            // Issuer
            AttCertIssuer aci = acInfo.getIssuer();
            if (aci == null)
            {
                return new SimpleTestResult(false,
                        "failed AC Issuer test, it's null, for id " + id);
            }

            // Signature
            AlgorithmIdentifier sig = acInfo.getSignature();
            if (sig == null)
            {
                return new SimpleTestResult(false,
                        "failed AC Signature test for id " + id);
            }

            // Serial
            DERInteger serial = acInfo.getSerialNumber();

            // Validity
            AttCertValidityPeriod validity = acInfo.getAttrCertValidityPeriod();
            if (validity == null)
            {
                return new SimpleTestResult(false,
                        "failed AC AttCertValidityPeriod test for id " + id);
            }

            // Attributes
            ASN1Sequence attribSeq = acInfo.getAttributes();
            Attribute att[] = new Attribute[attribSeq.size()];
            for (int i = 0; i < attribSeq.size(); i++)
            {
                att[i] = Attribute.getInstance(attribSeq.getObjectAt(i));
            }

            // IssuerUniqueId
            // TODO, how to best test?

            // X509 Extensions
            X509Extensions ext = acInfo.getExtensions();
            if (ext != null)
            {
                Enumeration en = ext.oids();
                while (en.hasMoreElements())
                {
View Full Code Here

        if (!extGenerator.isEmpty())
        {
            acInfoGen.setExtensions(extGenerator.generate());
        }

        AttributeCertificateInfo acInfo = acInfoGen.generateAttributeCertificateInfo();

        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(acInfo);
        v.add(sigAlgId);
View Full Code Here

TOP

Related Classes of org.apache.geronimo.crypto.asn1.x509.AttributeCertificateInfo

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.