Examples of KeyStoreManager


Examples of com.adito.boot.KeyStoreManager

    WizardActionStatus createNewCertificate(AbstractWizardSequence seq) {

        try {

            KeyStoreManager mgr = KeyStoreManager.getInstance(KeyStoreManager.DEFAULT_KEY_STORE);

            if (mgr.isKeyStoreExists()) {
                mgr.deleteKeyStore();
            }

            String alias = InstallAction.SERVER_CERTIFICATE;
            String passphrase = (String) seq.getAttribute(SetKeyStorePasswordForm.ATTR_KEY_STORE_PASSWORD, null);
            if (passphrase != null && !passphrase.equals("")) {
                Property.setProperty(new ContextKey("webServer.keystore.sslCertificate.password"), passphrase, seq.getSession());
                mgr.setStorePassword(passphrase);
            }

            mgr.createKeyStore();
            String dname = "cn="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_HOSTNAME, ""))
                            + ", ou="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_ORGANISATIONAL_UNIT,
                                "")) + ", o="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_COMPANY, "")) + ", l="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_CITY, "")) + ", st="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_STATE, "")) + ", c="
                            + Util.escapeForDNString((String) seq.getAttribute(CreateNewCertificateForm.ATTR_COUNTRY_CODE, ""));
            mgr.createKey(alias, dname);
            Property.setProperty(new ContextKey("webServer.keyStoreType"), KeyStoreManager.TYPE_JKS.getName(), null);
            Property.setProperty(new ContextKey("webServer.alias"), alias, null);

            CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.KEYSTORE_CERTIFICATE_CREATED, alias, null).addAttribute(
                CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ALIAS, alias).addAttribute(CreateNewCertificateForm.ATTR_HOSTNAME,
View Full Code Here

Examples of com.adito.boot.KeyStoreManager

    WizardActionStatus importCertificate(AbstractWizardSequence seq) {

        try {

            KeyStoreManager mgr = KeyStoreManager.getInstance(KeyStoreManager.DEFAULT_KEY_STORE);

            if (mgr.isKeyStoreExists()) {
                mgr.deleteKeyStore();
            }

            String alias = (String) seq.getAttribute(ImportExistingCertificateForm.ATTR_ALIAS, null);
            String passphrase = (String) seq.getAttribute(ImportExistingCertificateForm.ATTR_PASSPHRASE, "");
            KeyStoreType keyStoreType = KeyStoreManager.getKeyStoreType((String) seq.getAttribute(
                ImportExistingCertificateForm.ATTR_KEY_STORE_TYPE, ""));
            File uploadedFile = (File) seq.getAttribute(ImportExistingCertificateForm.ATTR_UPLOADED_FILE, null);

            mgr.setStorePassword(passphrase);

            if (keyStoreType.equals(KeyStoreManager.TYPE_PKCS12)) {
                mgr.setKeyStoreType(KeyStoreManager.TYPE_JKS);
                alias = mgr.importPKCS12Key(uploadedFile, passphrase, alias, SERVER_CERTIFICATE);
            } else {
              FileOutputStream out = new FileOutputStream(mgr.getKeyStoreFile());
                try {
                    FileInputStream in = new FileInputStream(uploadedFile);
                    try {
                        Util.copy(in, out);
                    } finally {
View Full Code Here

Examples of com.adito.boot.KeyStoreManager

        super.validate(errs, alias, passphrase, seq, sessionInfo);
        if(alias==null || alias.equals("")) {
            errs.add(Globals.ERROR_KEY, new ActionMessage("keyStoreImportWizard.keyStoreImportFile.noNameProvided"));                       
        }
        else {
            KeyStoreManager mgr = KeyStoreManager.getInstance(KeyStoreManager.TRUSTED_SERVER_CERTIFICATES_KEY_STORE);
            if(mgr.getCertificate(alias.toLowerCase()) != null) {
                errs.add(Globals.ERROR_KEY, new ActionMessage("keyStoreImportWizard.keyStoreImportFile.duplicateName", alias.toLowerCase()));                           
            }
        }
    }
View Full Code Here

Examples of com.adito.boot.KeyStoreManager

    /* (non-Javadoc)
     * @see com.adito.keystore.wizards.AbstractKeyStoreImportType#doInstall(java.io.File, java.lang.String, java.lang.String, com.adito.wizard.AbstractWizardSequence)
     */
    public void doInstall(File file, String alias, String passphrase, AbstractWizardSequence seq, SessionInfo sessionInfo) throws Exception {
        KeyStoreManager mgr = KeyStoreManager.getInstance(KeyStoreManager.TRUSTED_SERVER_CERTIFICATES_KEY_STORE);
        mgr.importCert(alias, file, null);
        mgr.reloadKeystore();
        Certificate certif = mgr.getCertificate(alias);

        CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.KEYSTORE_TRUSTED_CERTIFICATE_IMPORTED, Property.getProperty(new ContextKey("webServer.alias")), seq.getSession())
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ALIAS, alias)
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_TYPE, certif.getType())
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_HOSTNAME, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "cn"))
View Full Code Here

Examples of com.adito.boot.KeyStoreManager

   */
  public void doInstall(File file, String alias, String passphrase,
      AbstractWizardSequence seq, SessionInfo sessionInfo) throws Exception {

   
        KeyStoreManager mgr = KeyStoreManager.getInstance(KeyStoreManager.DEFAULT_KEY_STORE);
       
        X509Certificate web = (X509Certificate) mgr.getCertificate(Property.getProperty(new ContextKey("webServer.alias")));

        final String actualCert = KeyStoreManager.getX509CertificateEntity(web, "cn").replaceAll("\\.", "_") + ".crt";       

        File parent = new File(file.getParentFile(), "comodo");
       
        Util.delTree(parent);
        parent.mkdirs();
       
        try {
            ZipExtract.extractZipFile(parent, new FileInputStream(file));
           
            String[] certs = parent.list(new FilenameFilter() {
              public boolean accept(File file, String filename) {
                return filename.endsWith(".crt") && (!filename.equals(actualCert) && !filename.equals(actualCert.replaceAll("\\*", "STAR")));
              }
            });
            String pw = Property.getProperty(new ContextKey("webServer.keystore.sslCertificate.password"));
   
            for(int i=0;i<certs.length;i++) {
              File tmp = new File(parent, certs[i]);
              mgr.importCert(tmp.getName().toLowerCase(), tmp, pw);
             
                Certificate certif = mgr.getCertificate(tmp.getName().toLowerCase());
   
                CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.KEYSTORE_CERTIFICATE_SIGNED_IMPORTED, Property.getProperty(new ContextKey("webServer.alias")), seq.getSession())
                                .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ALIAS, tmp.getName())
                                .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_TYPE, certif.getType())
                                .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_HOSTNAME, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "cn"))
                                .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ORGANISATIONAL_UNIT, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "ou"))
                                .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_COMPANY, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "o"))
                                .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_STATE, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "st"))
                                .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_LOCATION, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "l"))
                                .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_COUNTRY_CODE, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "c"));
               
                 CoreServlet.getServlet().fireCoreEvent(coreEvent);
   
            }
           
            File cert = new File(parent, actualCert);
           
            mgr.importCert(Property.getProperty(new ContextKey("webServer.alias")), cert, pw);
            mgr.reloadKeystore();
            Certificate certif = mgr.getCertificate(Property.getProperty(new ContextKey("webServer.alias")));
           
            CoreServlet.getServlet().fireCoreEvent(new CoreEvent(
                            this, CoreEventConstants.KEYSTORE_CERTIFICATE_SIGNED_IMPORTED, Property.getProperty(new ContextKey("webServer.alias")), seq.getSession())
                            .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ALIAS, Property.getProperty(new ContextKey("webServer.alias")))
                            .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_TYPE, certif.getType())
View Full Code Here

Examples of com.adito.boot.KeyStoreManager

    /* (non-Javadoc)
     * @see com.adito.keystore.wizards.AbstractKeyStoreImportType#doInstall(java.io.File, java.lang.String, java.lang.String, com.adito.wizard.AbstractWizardSequence)
     */
    public void doInstall(File file, String alias, String passphrase, AbstractWizardSequence seq, SessionInfo sessionInfo) throws Exception {
        KeyStoreManager mgr = KeyStoreManager.getInstance(KeyStoreManager.DEFAULT_KEY_STORE);
        String pw = Property.getProperty(new ContextKey("webServer.keystore.sslCertificate.password"));
        mgr.importCert(Property.getProperty(new ContextKey("webServer.alias")), file, pw);
        mgr.reloadKeystore();
        Certificate certif = mgr.getCertificate(Property.getProperty(new ContextKey("webServer.alias")));
        CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.KEYSTORE_CERTIFICATE_SIGNED_IMPORTED, Property.getProperty(new ContextKey("webServer.alias")), seq.getSession())
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ALIAS, Property.getProperty(new ContextKey("webServer.alias")))
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_TYPE, certif.getType())
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_HOSTNAME, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "cn"))
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ORGANISATIONAL_UNIT, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "ou"))
View Full Code Here

Examples of com.adito.boot.KeyStoreManager

     * the keystore.
     *
     * @return array of {@link CertificateItem}s.
     */
    public CertificateItem[] getCertificateItems() {
        KeyStoreManager sel = getSelectedKeyStore();
        if (!sel.isKeyStoreEmpty()){
            Enumeration e = sel.getCertificateAliases();
            if(e != null) {
                CertificateItem[] cert = new CertificateItem[sel.getSize()];
                int i = 0;
                while(e.hasMoreElements()) {
                    String alias = (String) e.nextElement();
                    cert[i++] = new CertificateItem(alias, sel.getCertificate(alias), sel);
                }
                return cert;
            }
        }
        return null;
View Full Code Here

Examples of com.adito.boot.KeyStoreManager

    /* (non-Javadoc)
     * @see com.adito.keystore.wizards.AbstractKeyStoreImportType#doInstall(java.io.File, java.lang.String, java.lang.String, com.adito.wizard.AbstractWizardSequence)
     */
    public void doInstall(File file, String alias, String passphrase, AbstractWizardSequence seq, SessionInfo sessionInfo) throws Exception {
        KeyStoreManager mgr = KeyStoreManager.getInstance(KeyStoreManager.SERVER_AUTHENTICATION_CERTIFICATES_KEY_STORE);
        alias = mgr.importPKCS12Key(file, passphrase, alias, alias);
        mgr.reloadKeystore();
        Certificate certif = mgr.getCertificate(alias);

        CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.KEYSTORE_SERVER_AUTHENTICATION_CERTIFICATE_IMPORTED, KeyStoreManager.SERVER_AUTHENTICATION_CERTIFICATES_KEY_STORE, seq.getSession())
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ALIAS, alias)
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_TYPE, certif.getType())
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_HOSTNAME, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "cn"))
View Full Code Here

Examples of com.adito.boot.KeyStoreManager

    /* (non-Javadoc)
     * @see com.adito.keystore.wizards.AbstractKeyStoreImportType#doInstall(java.io.File, java.lang.String, java.lang.String, com.adito.wizard.AbstractWizardSequence)
     */
    public void doInstall(File file, String alias, String passphrase, AbstractWizardSequence seq, SessionInfo sessionInfo) throws Exception {
        KeyStoreManager mgr = KeyStoreManager.getInstance(KeyStoreManager.DEFAULT_KEY_STORE);
        String pw = Property.getProperty(new ContextKey("webServer.keystore.sslCertificate.password"));
        mgr.importCert(alias, file, pw);
        Certificate certif = mgr.getCertificate(alias);

        CoreEvent coreEvent = new CoreEvent(this, CoreEventConstants.KEYSTORE_ROOT_CERTIFICATE_IMPORTED, KeyStoreManager.DEFAULT_KEY_STORE, seq.getSession())
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_ALIAS, alias)
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_TYPE, certif.getType())
                        .addAttribute(CoreAttributeConstants.EVENT_ATTR_CERTIFICATE_HOSTNAME, KeyStoreManager.getX509CertificateEntity((X509Certificate)certif, "cn"))
View Full Code Here

Examples of cybervillains.ca.KeyStoreManager

            root.mkdirs();

            ResourceExtractor.extractResourcePath(getClass(), "/sslSupport", root);


            KeyStoreManager mgr = new KeyStoreManager(root);
            mgr.getCertificateByHostname(host);
            mgr.getKeyStore().deleteEntry(KeyStoreManager._caPrivKeyAlias);
            mgr.persist();

            listener.setKeystore(new File(root, "cybervillainsCA.jks").getAbsolutePath());
            listener.setNukeDirOrFile(root);
        } catch (Exception e) {
            throw new RuntimeException(e);
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.