Package org.ejbca.ui.web.admin.configuration

Examples of org.ejbca.ui.web.admin.configuration.EjbcaWebBean


  public String getApprovalAdmin(){
    return approval.getAdmin().getUsername();
  }
 
  public String getAdminAction(){
    EjbcaWebBean ejbcawebbean = EjbcaJSFHelper.getBean().getEjbcaWebBean();
   
    if(approval.isApproved()){
      return ejbcawebbean.getText("APPROVED");
    }
    return ejbcawebbean.getText("REJECTED");
  }
View Full Code Here


     */
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {       
        // Check if authorized
        EjbcaWebBean ejbcawebbean= getEjbcaWebBean(request);
        try{
            ejbcawebbean.initialize(request, "/ra_functionallity/create_end_entity");
        } catch(Exception e){
            throw new java.io.IOException("Authorization Denied");
        }
       
        X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate");
View Full Code Here

     */
    private final EjbcaWebBean getEjbcaWebBean(HttpServletRequest req)
    throws ServletException
    {
        HttpSession session = req.getSession();
        EjbcaWebBean ejbcawebbean= (EjbcaWebBean)session.getAttribute("ejbcawebbean");
        if ( ejbcawebbean == null ){
            try {
                ejbcawebbean = (EjbcaWebBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName());
            } catch (ClassNotFoundException exc) {
                throw new ServletException(exc.getMessage());
View Full Code Here

    approveRequestData = new ApprovalDataVOView();        
  }

  public  HashMap<Integer, String> getStatusText(){
      if(statustext == null){
        EjbcaWebBean ejbcawebbean = EjbcaJSFHelper.getBean().getEjbcaWebBean();
        statustext = new HashMap<Integer, String>();
        statustext.put(Integer.valueOf(ApprovalDataVO.STATUS_WAITINGFORAPPROVAL), ejbcawebbean.getText("WAITING", true));
        statustext.put(Integer.valueOf(ApprovalDataVO.STATUS_EXPIRED), ejbcawebbean.getText("EXPIRED", true));
        statustext.put(Integer.valueOf(ApprovalDataVO.STATUS_EXPIREDANDNOTIFIED), ejbcawebbean.getText("EXPIREDANDNOTIFIED", true));
        statustext.put(Integer.valueOf(ApprovalDataVO.STATUS_EXECUTED), ejbcawebbean.getText("EXECUTED", true));
        statustext.put(Integer.valueOf(ApprovalDataVO.STATUS_APPROVED), ejbcawebbean.getText("APPROVED", true));
        statustext.put(Integer.valueOf(ApprovalDataVO.STATUS_REJECTED), ejbcawebbean.getText("REJECTED", true));
        statustext.put(Integer.valueOf(ApprovalDataVO.STATUS_EXECUTIONFAILED), ejbcawebbean.getText("EXECUTIONFAILED", true));
        statustext.put(Integer.valueOf(ApprovalDataVO.STATUS_EXECUTIONDENIED), ejbcawebbean.getText("EXECUTIONDENIED", true));
      }
      return statustext;
  }
View Full Code Here

     * @param res The response.
   */
    public void doGet(HttpServletRequest req,  HttpServletResponse res) throws java.io.IOException, ServletException {
      log.trace(">doGet()");
      // Check if authorized
      EjbcaWebBean ejbcawebbean= (org.ejbca.ui.web.admin.configuration.EjbcaWebBean) req.getSession().getAttribute("ejbcawebbean");
      if ( ejbcawebbean == null ) {
        try {
          ejbcawebbean = (org.ejbca.ui.web.admin.configuration.EjbcaWebBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), EjbcaWebBean.class.getName());
        } catch (ClassNotFoundException e) {
          throw new ServletException(e.getMessage());
        } catch (Exception e) {
          throw new ServletException ("Cannot create bean of class org.ejbca.ui.web.admin.configuration.EjbcaWebBean", e);
        }
         req.getSession().setAttribute("ejbcawebbean", ejbcawebbean);
      }
      try{
        ejbcawebbean.initialize(req, AccessRulesConstants.ROLE_SUPERADMINISTRATOR);
      } catch(Exception e) {
        throw new java.io.IOException("Authorization Denied");
      }
      RequestHelper.setDefaultCharacterEncoding(req);
      String caname = req.getParameter(HIDDEN_CANAME);
      String capassword = req.getParameter(TEXTFIELD_EXPORTCA_PASSWORD);
      log.info("Got request from "+req.getRemoteAddr()+" to export "+caname);
      try{
        byte[] keystorebytes = null;
          CAInfo cainfo = caAdminSession.getCAInfo(ejbcawebbean.getAdminObject(), caname);
          String ext = "p12"; // Default for X.509 CAs
          if (cainfo.getCAType() == CAInfo.CATYPE_CVC) {
            ext = "pkcs8";
          }
      keystorebytes = caAdminSession.exportCAKeyStore(ejbcawebbean.getAdminObject(), caname, capassword, capassword, "SignatureKeyAlias", "EncryptionKeyAlias");
            ServletUtils.removeCacheHeaders(res)// We must remove cache headers for IE
          res.setContentType("application/octet-stream");
          res.setContentLength(keystorebytes.length);
          res.setHeader("Content-Disposition", "attachment;filename=\"" + caname + "."+ext+"\"");
          res.getOutputStream().write(keystorebytes);
View Full Code Here

    public void doGet(HttpServletRequest req,  HttpServletResponse res) throws java.io.IOException, ServletException {
        log.trace(">doGet()");

        // Check if authorized
        EjbcaWebBean ejbcawebbean= (org.ejbca.ui.web.admin.configuration.EjbcaWebBean)
                                   req.getSession().getAttribute("ejbcawebbean");
        if ( ejbcawebbean == null ){
          try {
            ejbcawebbean = (org.ejbca.ui.web.admin.configuration.EjbcaWebBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName());
           } catch (ClassNotFoundException exc) {
               throw new ServletException(exc.getMessage());
           }catch (Exception exc) {
               throw new ServletException (" Cannot create bean of class "+ org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName(), exc);
           }
           req.getSession().setAttribute("ejbcawebbean", ejbcawebbean);
        }

        try{
          ejbcawebbean.initialize(req, "/ca_functionality/basic_functions");
        } catch(Exception e){
           throw new java.io.IOException("Authorization Denied");
        }

        RequestHelper.setDefaultCharacterEncoding(req);
        String issuerdn = null;
        if(req.getParameter(ISSUER_PROPERTY) != null){
          issuerdn = java.net.URLDecoder.decode(req.getParameter(ISSUER_PROPERTY),"UTF-8");
        }
       
        String command;
        // Keep this for logging.
        String remoteAddr = req.getRemoteAddr();
        command = req.getParameter(COMMAND_PROPERTY_NAME);
        if (command == null) {
            command = "";
        }
        if (command.equalsIgnoreCase(COMMAND_CRL) && issuerdn != null) {
            try {
                Admin admin = ejbcawebbean.getAdminObject();
                byte[] crl = crlSession.getLastCRL(admin, issuerdn, false);
                X509CRL x509crl = CertTools.getCRLfromByteArray(crl);
                String dn = CertTools.getIssuerDN(x509crl);
            String basename = getBaseFileName(dn);
                String filename = basename+".crl";
                // We must remove cache headers for IE
                ServletUtils.removeCacheHeaders(res);
                res.setHeader("Content-disposition", "attachment; filename=" +  filename);
                res.setContentType("application/pkix-crl");
                res.setContentLength(crl.length);
                res.getOutputStream().write(crl);
                String iMsg = intres.getLocalizedMessage("certreq.sentlatestcrl", remoteAddr);
                log.info(iMsg);
            } catch (Exception e) {
                String errMsg = intres.getLocalizedMessage("certreq.errorsendcrl", remoteAddr, e.getMessage());
                log.error(errMsg, e);
                res.sendError(HttpServletResponse.SC_NOT_FOUND, errMsg);
                return;
            }
        }
        if (command.equalsIgnoreCase(COMMAND_DELTACRL) && issuerdn != null) {
          try {
            Admin admin = ejbcawebbean.getAdminObject();
            byte[] crl = crlSession.getLastCRL(admin, issuerdn, true);
            X509CRL x509crl = CertTools.getCRLfromByteArray(crl);
            String dn = CertTools.getIssuerDN(x509crl);
            String basename = getBaseFileName(dn);
            String filename = basename+"_delta.crl";
View Full Code Here

    public void doGet(HttpServletRequest req,  HttpServletResponse res) throws java.io.IOException, ServletException {
        log.trace(">doGet()");

        // Check if authorized
        EjbcaWebBean ejbcawebbean= (org.ejbca.ui.web.admin.configuration.EjbcaWebBean)
                                   req.getSession().getAttribute("ejbcawebbean");
        if ( ejbcawebbean == null ){
          try {
            ejbcawebbean = (org.ejbca.ui.web.admin.configuration.EjbcaWebBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName());
           } catch (ClassNotFoundException exc) {
               throw new ServletException(exc.getMessage());
           }catch (Exception exc) {
               throw new ServletException (" Cannot create bean of class "+org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName(), exc);
           }
           req.getSession().setAttribute("ejbcawebbean", ejbcawebbean);
        }

    // Check if authorized
    CAInterfaceBean cabean= (org.ejbca.ui.web.admin.cainterface.CAInterfaceBean)
                   req.getSession().getAttribute("cabean");
    if ( cabean == null ){
      try {
      cabean = (org.ejbca.ui.web.admin.cainterface.CAInterfaceBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), org.ejbca.ui.web.admin.cainterface.CAInterfaceBean.class.getName());
       } catch (ClassNotFoundException exc) {
         throw new ServletException(exc.getMessage());
       }catch (Exception exc) {
         throw new ServletException (" Cannot create bean of class "+org.ejbca.ui.web.admin.cainterface.CAInterfaceBean.class.getName(), exc);
       }
       req.getSession().setAttribute("cabean", cabean);
    }


        try{
          ejbcawebbean.initialize(req, "/super_administrator");         
        } catch(Exception e){
           throw new java.io.IOException("Authorization Denied");
        }

    try{
      cabean.initialize(req, ejbcawebbean);
    } catch(Exception e){
       throw new java.io.IOException("Error initializing CACertReqServlet");
    }       
               
       
        // Keep this for logging.
        String remoteAddr = req.getRemoteAddr();
        RequestHelper.setDefaultCharacterEncoding(req);
        String command = req.getParameter(COMMAND_PROPERTY_NAME);
        String format = req.getParameter(FORMAT_PROPERTY_NAME);
        if (command == null) {
            command = "";
        }
        if (command.equalsIgnoreCase(COMMAND_CERTREQ)) {
            try {
              byte[] request = cabean.getRequestData();
                String filename = null;
                CVCertificate cvccert = null;
                boolean isx509cert = false;
                try {
                    CVCObject parsedObject = CertificateParser.parseCVCObject(request);
                    // We will handle both the case if the request is an
                    // authenticated request, i.e. with an outer signature
                    // and when the request is missing the (optional) outer
                    // signature.
                    if (parsedObject instanceof CVCAuthenticatedRequest) {
                        CVCAuthenticatedRequest cvcreq = (CVCAuthenticatedRequest) parsedObject;
                        cvccert = cvcreq.getRequest();
                    } else {
                        cvccert = (CVCertificate) parsedObject;
                    }
                    HolderReferenceField chrf = cvccert.getCertificateBody().getHolderReference();
                    if (chrf != null) {
                      filename = chrf.getConcatenated();
                    }
                } catch (ParseException ex) {
                    // Apparently it wasn't a CVC request, ignore
                } catch (IllegalArgumentException ex) {
                    // Apparently it wasn't a X.509 certificate, was it a certificate request?
                try {
                    PKCS10RequestMessage p10 = RequestMessageUtils.genPKCS10RequestMessage(request);
                    filename = CertTools.getPartFromDN(p10.getRequestX509Name().toString(), "CN");
                } catch (Exception e1) { // NOPMD
                  // Nope, not a certificate request either, see if it was an X.509 certificate
                  Certificate cert = CertTools.getCertfromByteArray(request);
                  filename = CertTools.getPartFromDN(CertTools.getSubjectDN(cert), "CN");
                  if (filename == null) {
                    filename = "cert";
                  }
                  isx509cert = true;
                }
                }

                if (filename == null) {
                    filename = "certificaterequest";
                } else {
                filename = filename.replaceAll("\\W", "");
                }
                int length = request.length;
                byte[] outbytes = request;
              if (!StringUtils.equals(format, "binary")) {
                String begin = RequestHelper.BEGIN_CERTIFICATE_REQUEST_WITH_NL;
                String end = RequestHelper.END_CERTIFICATE_REQUEST_WITH_NL;
                if (isx509cert) {
                  begin = RequestHelper.BEGIN_CERTIFICATE_WITH_NL;
                  end = RequestHelper.END_CERTIFICATE_WITH_NL;
                }
            byte[] b64certreq = org.ejbca.util.Base64.encode(request);
            String out = begin;
            out += new String(b64certreq);
            out += end;
            length = out.length();
                    filename += ".pem";
                    outbytes = out.getBytes();
                } else if (cvccert != null) {
                    filename += ".cvreq";
                } else {
                  if (isx509cert) {
                        filename += ".crt";                   
                  } else {
                        filename += ".req";                   
                  }
                }
             
                // We must remove cache headers for IE
                ServletUtils.removeCacheHeaders(res);
                res.setHeader("Content-disposition", "attachment; filename=" +  filename);
                res.setContentType("application/octet-stream");
                res.setContentLength(length);
                res.getOutputStream().write(outbytes);
            String iMsg = intres.getLocalizedMessage("certreq.sentlatestcertreq", remoteAddr);
                log.info(iMsg);
            } catch (Exception e) {
            String errMsg = intres.getLocalizedMessage("certreq.errorsendlatestcertreq", remoteAddr);
                log.error(errMsg, e);
                res.sendError(HttpServletResponse.SC_NOT_FOUND, errMsg);
                return;
            }
        }
    if (command.equalsIgnoreCase(COMMAND_CERT)) {
       try {
         Certificate cert = cabean.getProcessedCertificate();
              if (!StringUtils.equals(format, "binary")) {
            byte[] b64cert = org.ejbca.util.Base64.encode(cert.getEncoded())
            RequestHelper.sendNewB64Cert(b64cert, res, RequestHelper.BEGIN_CERTIFICATE_WITH_NL, RequestHelper.END_CERTIFICATE_WITH_NL);             
              } else {
                RequestHelper.sendBinaryBytes(cert.getEncoded(), res, "application/octet-stream", "cert.crt");
              }
       } catch (Exception e) {
         String errMsg = intres.getLocalizedMessage("certreq.errorsendcert", remoteAddr, e.getMessage());
                 log.error(errMsg, e);
         res.sendError(HttpServletResponse.SC_NOT_FOUND, errMsg);
         return;
       }
     }
    if (command.equalsIgnoreCase(COMMAND_CERTPKCS7)) {
       try {
        Certificate cert = cabean.getProcessedCertificate();   
            byte[] pkcs7 = signSession.createPKCS7(ejbcawebbean.getAdminObject(), cert, true);                
          byte[] b64cert = org.ejbca.util.Base64.encode(pkcs7)
          RequestHelper.sendNewB64Cert(b64cert, res, RequestHelper.BEGIN_PKCS7_WITH_NL, RequestHelper.END_PKCS7_WITH_NL);                                              
       } catch (Exception e) {
         String errMsg = intres.getLocalizedMessage("certreq.errorsendcert", remoteAddr, e.getMessage());
                 log.error(errMsg, e);
View Full Code Here

    }

    public void doGet(HttpServletRequest req,  HttpServletResponse res) throws IOException, ServletException {
        log.trace(">doGet()");
        // Check if authorized
        EjbcaWebBean ejbcawebbean= (org.ejbca.ui.web.admin.configuration.EjbcaWebBean)
                                   req.getSession().getAttribute("ejbcawebbean");
       
        RAInterfaceBean rabean =  (org.ejbca.ui.web.admin.rainterface.RAInterfaceBean)
                                   req.getSession().getAttribute("rabean");
        if ( ejbcawebbean == null ){
          try {
            ejbcawebbean = (org.ejbca.ui.web.admin.configuration.EjbcaWebBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName());
           } catch (ClassNotFoundException exc) {
               throw new ServletException(exc.getMessage());
           }catch (Exception exc) {
               throw new ServletException (" Cannot create bean of class "+ org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName(), exc);
           }
           req.getSession().setAttribute("ejbcawebbean", ejbcawebbean);
        }
       
        if ( rabean == null ){
            try {
              rabean = (org.ejbca.ui.web.admin.rainterface.RAInterfaceBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), org.ejbca.ui.web.admin.rainterface.RAInterfaceBean.class.getName());
             } catch (ClassNotFoundException exc) {
                 throw new ServletException(exc.getMessage());
             }catch (Exception exc) {
                 throw new ServletException (" Cannot create bean of class "+ org.ejbca.ui.web.admin.rainterface.RAInterfaceBean.class.getName(), exc);
             }
             req.getSession().setAttribute("rabean", ejbcawebbean);
          }

        try{
          ejbcawebbean.initialize(req,AccessRulesConstants.REGULAR_VIEWCERTIFICATE);
          rabean.initialize(req,ejbcawebbean);                   
        } catch(Exception e){
           throw new java.io.IOException("Authorization Denied");
        }
       
View Full Code Here

    }

    public void doGet(HttpServletRequest req,  HttpServletResponse res) throws java.io.IOException, ServletException {
        log.trace(">doGet()");
        // Check if authorized
        EjbcaWebBean ejbcawebbean= (org.ejbca.ui.web.admin.configuration.EjbcaWebBean)
                                   req.getSession().getAttribute("ejbcawebbean");
        if ( ejbcawebbean == null ){
          try {
            ejbcawebbean = (org.ejbca.ui.web.admin.configuration.EjbcaWebBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName());
           } catch (ClassNotFoundException exc) {
               throw new ServletException(exc.getMessage());
           }catch (Exception exc) {
               throw new ServletException (" Cannot create bean of class "+org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName(), exc);
           }
           req.getSession().setAttribute("ejbcawebbean", ejbcawebbean);
        }

        try{
          ejbcawebbean.initialize(req,"/ca_functionality/basic_functions");
        } catch(Exception e){
           throw new java.io.IOException("Authorization Denied");
        }
       
        RequestHelper.setDefaultCharacterEncoding(req);

        String issuerdn = req.getParameter(ISSUER_PROPERTY);
       
        String command;
        // Keep this for logging.
        log.debug("Got request from "+req.getRemoteAddr());
        command = req.getParameter(COMMAND_PROPERTY_NAME);
        if (command == null) {
            command = "";
        }
        if ((command.equalsIgnoreCase(COMMAND_NSCACERT) || command.equalsIgnoreCase(COMMAND_IECACERT) || command.equalsIgnoreCase(COMMAND_JKSTRUSTSTORE)
            || command.equalsIgnoreCase(COMMAND_CACERT)) && issuerdn != null ) {
            String lev = req.getParameter(LEVEL_PROPERTY);
            int level = 0;
            if (lev != null) {
                level = Integer.parseInt(lev);
            }
            // Root CA is level 0, next below root level 1 etc etc
            try {
                Admin admin = ejbcawebbean.getAdminObject();
                Certificate[] chain = (Certificate[]) signSession.getCertificateChain(admin, issuerdn.hashCode()).toArray(new Certificate[0]);
                                                           
                // chain.length-1 is last cert in chain (root CA)
                if ( (chain.length-1-level) < 0 ) {
                    PrintStream ps = new PrintStream(res.getOutputStream());
View Full Code Here

TOP

Related Classes of org.ejbca.ui.web.admin.configuration.EjbcaWebBean

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.