Examples of CertificationAuthority


Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

            if(value != null) response.setRenderParameter(params[i], value);
        }
        String sNo = request.getParameter("sNo");
        if(sNo == null) {
            // Freshly loading the certificate request details screen
            CertificationAuthority ca = getCertificationAuthority(request);
            try {
                sNo = ca.getNextSerialNumber().toString();
                response.setRenderParameter("sNo", sNo);
            } catch (Exception e) {
                log.error("Unable to get next serial number from CA.", e);
                response.setRenderParameter(ERROR_MSG, e.toString());
            }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

        try {
            String password = request.getParameter("password");
            if(password == null) {
                throw new Exception("Password is null.");
            }
            CertificationAuthority ca = getCertificationAuthority(request);
            if(ca == null) {
                throw new Exception("CA is not running.  CA may not have been initialized.");
            }
            ca.unlock(password.toCharArray());

            // Return to CA's index page
            response.setRenderParameter(INFO_MSG, "CA has been unlocked successfully!");
            log.info("CA has been unlocked successfully!");
            return INDEX_MODE+BEFORE_ACTION;
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

        for(int i = 0; i < params.length; ++i) {
            String value = request.getParameter(params[i]);
            if(value != null) request.setAttribute(params[i], value);
        }
        try {
            CertificationAuthority ca = getCertificationAuthority(request);
            if(ca == null) {
                throw new Exception("CA is not running. CA may not have been initialized.");
            }
            if(ca.isLocked()) {
                request.setAttribute("caLocked", Boolean.TRUE);
                throw new Exception("CA is locked.  Unlock CA to view details.");
            }
           
            // Get CA details
            Certificate caCert = ca.getCertificate();
            request.setAttribute("cert", caCert);
            request.setAttribute("highestSerial", ca.getHighestSerialNumber());
            request.setAttribute("certText", CaUtils.base64Certificate(caCert));
            PublicKey publickey = caCert.getPublicKey();
            String keySize = null;
            if(publickey instanceof RSAPublicKey) {
                keySize = ""+((RSAPublicKey)publickey).getModulus().bitLength();
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

            if(!request.getParameterMap().containsKey("sNo")) {
                // Show the page to get serial number of the certificate to be viewed
                request.setAttribute("sNo", null);
                return;
            }
            CertificationAuthority ca = getCertificationAuthority(request);
           
            String certText = ca.getCertificateBase64Text(new BigInteger(sNo.trim()));
            Certificate cert = ca.getCertificate(new BigInteger(sNo.trim()));
            PublicKey publickey = cert.getPublicKey();
            String keySize = null;
            if(publickey instanceof RSAPublicKey) {
                keySize = ""+((RSAPublicKey)publickey).getModulus().bitLength();
            }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

        for(int i = 0; i < params.length; ++i) {
            String value = request.getParameter(params[i]);
            if(value != null) request.setAttribute(params[i], value);
        }
       
        CertificationAuthority ca = getCertificationAuthority(request);
        if(ca == null) {
            // CA GBean is not running or the CA has not been initialized.
            request.setAttribute("caNotSetup", Boolean.TRUE);
        } else {
            request.setAttribute("caNotSetup", Boolean.FALSE);
            request.setAttribute("caLocked", ca.isLocked() ? Boolean.TRUE : Boolean.FALSE);
        }
    }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

        }
    }

    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
        if(request.getParameter("lock") != null) {
            CertificationAuthority ca = getCertificationAuthority(request);
            if(ca == null) {
                log.warn("CA is not running or CA may not have been initialized.  Unable to lock CA.");
                response.setRenderParameter(ERROR_MSG, "CA is not running or CA may not have been initialized.  Unable to lock CA.");
            } else {
                ca.lock();
                log.info("CA is now locked.");
                response.setRenderParameter(INFO_MSG, "CA has been locked!");
            }
        } else if(request.getParameter("publish") != null) {
            CertificationAuthority ca = getCertificationAuthority(request);
            try {
                getCertificateStore(request).storeCACertificate(ca.getCertificate());
                response.setRenderParameter(INFO_MSG, "CA's certificate published to Certificate Store");
            } catch (Exception e) {
                log.error("Error while publishing CA's certificate to Certificate Store", e);
                response.setRenderParameter(ERROR_MSG, "Error while publishing CA's certificate to Certificate Store. "+e);
            }
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

    }

    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
        String errorMsg = null;
        try {
            CertificationAuthority ca = getCertificationAuthority(request);
            if(ca == null) {
                throw new Exception("CA is not running.  CA may not have been initialized!!");
            }
            BigInteger sNo = new BigInteger(request.getParameter("sNo"));
            if(ca.isCertificateIssued(sNo)) {
                // A certificate with the serial number has already been issued.
                // This may happen if the user clicks on "Issue Certificate" button a second time
                log.warn("Second request to issue certificate with serial number'"+sNo+"'.  A certificate has already been issued.");
                response.setRenderParameter("sNo", sNo.toString());
                response.setRenderParameter(INFO_MSG, "A certificate with the serial number '"+sNo+"' has already been issued. "
                        +"You may be seeing this message since you have clicked on 'Issue Certificate' button a second time.");
                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

Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

            caKeystore.unlockPrivateKey(alias, password.toCharArray(), password.toCharArray());
           
            // Create CertificationAuthority, CertificateStore and CertificateRequestStore GBeans
            createCARelatedGBeans(request, (GeronimoManagedBean)caKeystore, defaultCAStoreDir, defaultCSRStoreDir);

            CertificationAuthority ca = getCertificationAuthority(request);
            ca.unlock(password.toCharArray());

            // Certificate validity and serial number.
            // Validity of these have been checked before loading the confirmation page.
            Date validFromDate = null, validToDate = null;
            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
            validFromDate = df.parse(validFrom);
            validToDate = df.parse(validTo);
            BigInteger serialNum = new BigInteger(sNo);
           
            // Instruct the CA to issue a self-signed certificate.
            ca.issueOwnCertificate(serialNum, validFromDate, validToDate, algorithm);
            // Publish the CA's certificate to CertificateStore.
            getCertificateStore(request).storeCACertificate(ca.getCertificate());
           
            // CA Setup is succeessful.
            // Load a page to show CA details.
            response.setRenderParameter(INFO_MSG, "CA Setup is successful!");
            log.info("CA Setup is successful.");
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

            caKeystore.unlockPrivateKey(alias, password.toCharArray(), password.toCharArray());
           
            // Create CertificationAuthority, CertificateStore and CertificateRequestStore GBeans
            createCARelatedGBeans(request, (GeronimoManagedBean)caKeystore, defaultCAStoreDir, defaultCSRStoreDir);

            CertificationAuthority ca = getCertificationAuthority(request);
            ca.unlock(password.toCharArray());

            // Certificate validity and serial number.
            // Validity of these have been checked before loading the confirmation page.
            Date validFromDate = null, validToDate = null;
            DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
            validFromDate = df.parse(validFrom);
            validToDate = df.parse(validTo);
            BigInteger serialNum = new BigInteger(sNo);
           
            // Instruct the CA to issue a self-signed certificate.
            ca.issueOwnCertificate(serialNum, validFromDate, validToDate, algorithm);
            // Publish the CA's certificate to CertificateStore.
            getCertificateStore(request).storeCACertificate(ca.getCertificate());
           
            // CA Setup is succeessful.
            // Load a page to show CA details.
            response.setRenderParameter(INFO_MSG, "CA Setup is successful!");
            log.info("CA Setup is successful.");
View Full Code Here

Examples of org.apache.geronimo.management.geronimo.CertificationAuthority

            if(value != null) response.setRenderParameter(params[i], value);
        }
        String sNo = request.getParameter("sNo");
        if(sNo == null) {
            // Freshly loading the certificate request details screen
            CertificationAuthority ca = getCertificationAuthority(request);
            try {
                sNo = ca.getNextSerialNumber().toString();
                response.setRenderParameter("sNo", sNo);
            } catch (Exception e) {
                log.error("Unable to get next serial number from CA.", e);
                response.setRenderParameter(ERROR_MSG, e.toString());
            }
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.