Package com.adito.core

Examples of com.adito.core.FileDownloadPageInterceptListener


                    throws Exception {
        String id = request.getParameter("id");
        if (id == null) {
            return mapping.findForward("failed");
        }
        FileDownloadPageInterceptListener l = (FileDownloadPageInterceptListener) CoreUtil.getPageInterceptListenerById(request
                        .getSession(),FileDownloadPageInterceptListener.INTERCEPT_ID);
        DownloadContent download = l == null ? null : l.getDownload(Integer.parseInt(id));
        if (l == null || download == null ) {
            return mapping.findForward("failed");
        }

        response.setContentType(download.getMimeType() == null ? "application/octet-stream" : download.getMimeType());
View Full Code Here


                    throws Exception {       
        String id = request.getParameter("id");
        if(id == null) {
            throw new Exception("No download Id provided.");
        }
        FileDownloadPageInterceptListener l = (FileDownloadPageInterceptListener)
          CoreUtil.getPageInterceptListenerById(request.getSession(), FileDownloadPageInterceptListener.INTERCEPT_ID);
        if(l == null) {
            throw new Exception(
                "The requested download is no longer available. Some types of " +
                "content may only be downloaded once.");
        }
        ((FileDownloadForm)form).init(l.getDownload(Integer.parseInt(id)));
        return mapping.findForward("success");
    }
View Full Code Here

    /* (non-Javadoc)
     * @see com.adito.core.actions.AuthenticatedAction#onExecute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                    HttpServletResponse response) throws Exception {
        FileDownloadPageInterceptListener l = (FileDownloadPageInterceptListener) CoreUtil.getPageInterceptListenerById(request
                        .getSession(), "fileDownload");
        if (l == null) {
            l = new FileDownloadPageInterceptListener();
            CoreUtil.addPageInterceptListener(request.getSession(), l);
        }
        File f = new File(CoreUtil.getTempDownloadDirectory(getSessionInfo(request)), "server.csr");
        String pw = Property.getProperty(new ContextKey("webServer.keystore.sslCertificate.password"));
        String data = KeyStoreManager.getInstance(KeyStoreManager.DEFAULT_KEY_STORE).generateCSR(Property.getProperty(new ContextKey("webServer.alias")), pw);
        FileWriter fos = new FileWriter(f);
        fos.write(data);
        fos.flush();
        fos.close();
        l.addDownload(new CSRDownload(f, f.getName(), "application/octet-stream", mapping.findForward("success"),
                        "downloadCSR.message", "keystore"));
        return mapping.findForward("success");
    }
View Full Code Here

     */
    public ActionForward exportCertificate(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                    HttpServletResponse response) throws Exception {
        String sel = ((ShowKeyStoreForm) form).getSelectedItem();
        KeyStore systemClientStore = ((ShowKeyStoreForm) form).getSelectedKeyStore().getKeyStore();
        FileDownloadPageInterceptListener l = (FileDownloadPageInterceptListener) CoreUtil.getPageInterceptListenerById(request
                        .getSession(), "fileDownload");
        if (l == null) {
            l = new FileDownloadPageInterceptListener();
            CoreUtil.addPageInterceptListener(request.getSession(), l);
        }
        File clientCertFile = new File(CoreUtil.getTempDownloadDirectory(getSessionInfo(request)), sel + ".cer");
        FileOutputStream out = new FileOutputStream(clientCertFile);
        X509Certificate cert = (X509Certificate) systemClientStore.getCertificate(sel);
        out.write(cert.getEncoded());
        out.flush();
        out.close();
        l.addDownload(new CSRDownload(clientCertFile, clientCertFile.getName(), "application/octet-stream", mapping
                        .findForward("success"), "exportCertificate.message", "keystore", sel));
        return mapping.findForward("success");
    }
View Full Code Here

    public ActionForward exportPrivate(ActionMapping mapping, ActionForm form, HttpServletRequest request,
                        HttpServletResponse response) throws Exception {
        String sel = ((ShowKeyStoreForm) form).getSelectedItem();
       
        KeyStore systemClientStore = ((ShowKeyStoreForm) form).getSelectedKeyStore().getKeyStore();
        FileDownloadPageInterceptListener l = (FileDownloadPageInterceptListener) CoreUtil.getPageInterceptListenerById(request
                        .getSession(), "fileDownload");
        if (l == null) {
            l = new FileDownloadPageInterceptListener();
            CoreUtil.addPageInterceptListener(request.getSession(), l);
        }
        File clientCertFile = new File(CoreUtil.getTempDownloadDirectory(getSessionInfo(request)), sel + ".p12");
        FileOutputStream out = new FileOutputStream(clientCertFile);
        char[] password = ((ShowKeyStoreForm) form).getSelectedKeyStore().getKeyStorePassword().toCharArray();
        if (systemClientStore.isKeyEntry(sel)){
            PrivateKey keypair = ((ShowKeyStoreForm) form).getSelectedKeyStore().getPrivateKey(sel,
                            password);
          KeyStore userStore = KeyStore.getInstance("PKCS12", "BC");
          userStore.load(null, null);
          userStore.setKeyEntry(sel, keypair, ((ShowKeyStoreForm) form).getPassword().toCharArray(), ((ShowKeyStoreForm) form).getSelectedKeyStore().getCertificateChain(sel));
          userStore.store(out, ((ShowKeyStoreForm) form).getPassword().toCharArray());
          out.close();
        }
        l.addDownload(new CSRDownload(clientCertFile, clientCertFile.getName(), "application/octet-stream", mapping.findForward("success"),
                        "exportPrivateKey.message", "keystore", sel));
        return mapping.findForward("success");
    }
View Full Code Here

                    throws Exception {       
        String id = request.getParameter("id");
        if (id == null) {
            return mapping.findForward("failed");
        }
        FileDownloadPageInterceptListener l = (FileDownloadPageInterceptListener) CoreUtil.getPageInterceptListenerById(request
                        .getSession(), FileDownloadPageInterceptListener.INTERCEPT_ID);
        if (l != null) {
            DownloadContent download = l.getDownload(Integer.parseInt(id));
            if(download == null) {
                log.warn("Expected download " + id + " to be available but it wasn't");
                return mapping.findForward("failed");
            }
            else {
                download.completeDownload(LogonControllerFactory.getInstance().getSessionInfo(request));
                l.removeDownload(download.getId());
                if(l.size() == 0) {
                    CoreUtil.removePageInterceptListener(request.getSession(), l);
                }
                ActionForward fwd = download.getForward();
                if(fwd != null) {
                    return fwd;
View Full Code Here

     * waiting, weird stuff is going to happen.
     *
     * In fact, now there is the possibility of multiple windows for every
     * use page intercept listeners are a bad idea full stop.
     */
    FileDownloadPageInterceptListener l = (FileDownloadPageInterceptListener) CoreUtil.getPageInterceptListenerById(request.getSession(),
      FileDownloadPageInterceptListener.INTERCEPT_ID);
    if (l == null) {
      l = new FileDownloadPageInterceptListener();
      CoreUtil.addPageInterceptListener(request.getSession(), l);
    }
    int id = l.addDownload(new ZipDownload(fileSystemForm.getLaunchSession(),
            fwd,
            fileSystemForm.getPath(),
            uris,
            new ActionForward("/fileSystem.do?actionTarget=list&path=" + fileSystemForm.getPath() + "&" + LaunchSession.LAUNCH_ID + "=" + fileSystemForm.getLaunchId()),
            "downloadZip.message",
View Full Code Here

TOP

Related Classes of com.adito.core.FileDownloadPageInterceptListener

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.